GRUTinizer
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
TChannel.h
Go to the documentation of this file.
1 #ifndef _TCHANNEL__H_
2 #define _TCHANNEL__H_
3 
4 
5 #include<string>
6 #include<map>
7 
8 #include<TNamed.h>
9 #include<TList.h>
10 
11 class TChannel : public TNamed {
12  public:
13  TChannel();
14  TChannel(const char*);
15  TChannel(const TChannel&);
16 
17  virtual ~TChannel();
18 
19  void Print(Option_t *opt="") const;
20  std::string PrintToString(Option_t *opt="") const;
21  void Copy(TObject&) const;
22  void Clear(Option_t *opt ="");
23  //int Compare(const TObject*) const;
24  static bool AlphaSort(const TChannel&,const TChannel&);
25 
26  private:
27  unsigned int address;
28  int number;
29  std::string info;
30  std::vector<double> energy_coeff;
31  std::vector<double> efficiency_coeff;
32  //name and title held by TNamed.
33 
34  //static std::vector<std::string> fFileNames;
35  static std::string fChannelData;
36 
37  void SetEnergyCoeff(std::vector<double> tmp) { energy_coeff = tmp; }
38  void SetEfficiencyCoeff(std::vector<double> tmp) { efficiency_coeff = tmp; }
39 
40 
41  private:
42  static std::map<unsigned int,TChannel*> fChannelMap;
43 
44 
45  public:
46  static TChannel* GetChannel(unsigned int);
47  static TChannel* FindChannel(std::string);
48  static bool AddChannel(TChannel*,Option_t *opt="");
49  static bool RemoveChannel(TChannel&);
50  bool AppendChannel(TChannel*);
51  bool ReplaceChannel(TChannel*);
52 
53  static int DeleteAllChannels();
54  static int Size() { return fChannelMap.size(); }
55 
56 
57  public:
58  void SetAddress(unsigned int temp) { address = temp; }
59  void SetName(const char *temp) { TNamed::SetNameTitle(temp,temp); }
60  void SetInfo(const char *temp) { info.assign(temp); }
61  void SetNumber(int temp) { number = temp; }
62 
63  unsigned int GetAddress() const { return address; }
64  const char* GetName() const { return TNamed::GetName(); }
65  const char* GetInfo() const { return info.c_str(); }
66  int GetNumber() const { return number; }
67 
68  std::vector<double> GetEnergyCoeff() const { return energy_coeff; }
69  void AddEnergyCoeff(double &tmp) { energy_coeff.push_back(tmp); }
70  std::vector<double> GetEfficiencyCoeff() const { return efficiency_coeff; }
71  void AddEfficiencyCoeff(double &tmp) { efficiency_coeff.push_back(tmp); }
72 
73  void DestroyEnergyCoeff() { energy_coeff.clear(); }
75 
76  void DestroyCalibrations();
77 
78  double CalEnergy(int);
79  double CalEnergy(double);
80 
81  //double CalEfficiency(int);
82  //double CalEfficiency(double) const;
83 
84  public:
85  static int ReadCalFile(const char* filename="",Option_t *opt="replace");
86  static int WriteCalFile(std::string filename="",Option_t *opt="");
87 
88  private:
89  static int ParseInputData(std::string &input,Option_t *opt);
90  static int WriteToBuffer(Option_t *opt);
91  static void trim(std::string *, const std::string &trimChars=" \f\n\r\t\v");
92 
93  ClassDef(TChannel,1);
94 };
95 
96 #endif
97 
98