test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
ValueQuantity.h
Go to the documentation of this file.
1 #ifndef ValueQuantity_h
2 #define ValueQuantity_h
3 
6 
7 namespace hcaldqm
8 {
9  namespace quantity
10  {
12  {
13  fN = 0,
14  fEvents = 1,
15  fEnergy = 2,
17  fADC_128 = 4,
18  fADC_5 = 5,
19  fADC_15 = 6,
20  ffC_10000 = 7,
21  ffC_1000 = 8,
22  ffC_3000 = 9,
23  fTiming_TS = 10,
25  fLS = 12,
26  fEt_256 = 13,
27  fEt_128 = 14,
28  fFG = 15,
29  fRatio = 16,
30  fDigiSize = 17,
32  fRatio2 = 19,
33  fdEtRatio = 20,
34  fSumdEt = 21,
36 
40  fDiffAbs = 26,
41 
43  fN_to3000 = 28,
48 
49  fBX = 33,
51  fState = 35,
53  };
55  "N", "Events", "Energy", "Timing", "ADC", "ADC", "ADC",
56  "fC", "fC", "fC", "Timing", "Timing", "LS", "Et", "Et",
57  "FG", "Ratio", "DigiSize", "Q", "Ratio",
58  "dEtRatio", "SumdEt", "Timing", "ADC", "TDC", "TDC",
59  "Q", "Ratio", "N", "Energy", "N", "Et", "ADC", "BX",
60  "Energy", "State"
61  };
62  double const min_value[nValueQuantityType] = {
63  -0.05, 0, 0, -50, -0.5, -0.5, -0.5, 0, 0, 0, -0.5, 0, 0.5, 0,
64  0, 0, 0, -0.5, -1, 0.5, 0, 0, -0.5, -0.5, -0.5, -0.5,
65  0, 0, 0, 0, -0.05, -2, -2, -0.5, 0, flag::fNA
66  };
67  double const max_value[nValueQuantityType] = {
68  1000, 1000, 200, 50, 127.5, 5, 15, 10000, 1000, 3000,
69  9.5, 9.5, 4000.5, 255.5, 255.5, 2, 1, 20.5, 1, 1.5,
70  1, 1000, 9.5, 255.5, 63.5, 15.5, 1, 2, 3000, 100000, 10000,
71  256, 128, 3600.5, 1000, flag::nState
72  };
74  200, 200, 100, 200, 128, 100, 300, 1000, 200, 600,
75  10, 200, 4000, 256, 128, 2, 100, 20, 100, 100, 100, 100, 10,
76  256, 64, 16, 200, 100, 3000, 500, 100, 258, 130, 3601, 200,
78  };
79 
80  class ValueQuantity : public Quantity
81  {
82  public:
85  Quantity(name_value[type], isLog), _type(type)
86  {}
87  virtual ~ValueQuantity() {}
88 
90  {return new ValueQuantity(_type, _isLog);}
91 
92  // get Value to be overriden
93  virtual int getValue(int x)
94  {return x;}
95  virtual double getValue(double x)
96  {return x;}
97 
98  // standard properties
99  virtual QuantityType type() {return fValueQuantity;}
100  virtual int nbins() {return nbins_value[_type];}
101  virtual double min() {return min_value[_type];}
102  virtual double max() {return max_value[_type];}
103 
104  virtual void setBits(TH1* o)
105  {Quantity::setBits(o);setLS(o);}
106  virtual void setLS(TH1* o)
107  {
108  if (_type==fLS)
109  {
110  // for LS axis - set the bit
111  // set extendable axes.
112  o->SetBit(BIT(BIT_OFFSET+BIT_AXIS_LS));
113  // o->SetCanExtend(TH1::kXaxis);
114  }
115  }
116 
117  protected:
119  };
120 
122  {
123  public:
125  FlagQuantity(std::vector<flag::Flag> const& flags) :
126  _flags(flags) {}
127  virtual ~FlagQuantity() {}
128 
130  {return new FlagQuantity(_flags);}
131 
132  virtual std::string name() {return "Flag";}
133  virtual int nbins() {return _flags.size();}
134  virtual double min() {return 0;}
135  virtual double max() {return _flags.size();}
136  virtual int getValue(int f) {return f;}
137  virtual uint32_t getBin(int f) {return f+1;}
138  virtual std::vector<std::string> getLabels()
139  {
140  std::vector<std::string> vnames;
141  for (std::vector<flag::Flag>::const_iterator
142  it=_flags.begin(); it!=_flags.end(); ++it)
143  vnames.push_back(it->_name);
144 
145  return vnames;
146  }
147  protected:
148 
149  std::vector<flag::Flag> _flags;
150  };
151 
152  class LumiSection : public ValueQuantity
153  {
154  public:
156  {}
158  _n(n)
159  {}
160  virtual ~LumiSection() {}
161 
163  {return new LumiSection(_n);}
164 
165  virtual std::string name() {return "LS";}
166  virtual int nbins() {return _n;}
167  virtual double min() {return 1;}
168  virtual double max() {return _n+1;}
169  virtual int getValue(int l) {return l;}
170  virtual uint32_t getBin(int l)
171  {return getValue(l);}
172  virtual void setMax(double x) {_n=x;}
173 
174  protected:
175  int _n;
176  };
177 
178  class RunNumber : public ValueQuantity
179  {
180  public:
182  RunNumber(std::vector<int> runs) :
183  _runs(runs)
184  {}
185  virtual ~RunNumber() {}
186 
187  virtual std::string name() {return "Run";}
188  virtual int nbins() {return _runs.size();}
189  virtual double min() {return 0;}
190  virtual double max() {return _runs.size();}
191  virtual std::vector<std::string> getLabels()
192  {
193  char name[10];
194  std::vector<std::string> labels;
195  for (uint32_t i=0; i<_runs.size(); i++)
196  {
197  sprintf(name, "%d", _runs[i]);
198  labels.push_back(name);
199  }
200  return labels;
201  }
202  virtual int getValue(int run)
203  {
204  int ir = -1;
205  for (uint32_t i=0; i<_runs.size(); i++)
206  if (_runs[i]==run)
207  {
208  ir = (int)i;
209  break;
210  }
211 
212  if (ir==-1)
213  throw cms::Exception("HCALDQM")
214  << "run number doens't exist " << run;
215 
216  return ir;
217  }
218 
219  virtual uint32_t getBin(int run)
220  {
221  return (this->getValue(run)+1);
222  }
223 
224  protected:
225  std::vector<int> _runs;
226  };
227 
228  class EventNumber : public ValueQuantity
229  {
230  public:
233  ValueQuantity(fN), _nevents(nevents)
234  {}
235  virtual ~EventNumber() {}
236 
237  virtual std::string name() {return "Event";}
238  virtual int nbins() {return _nevents;}
239  virtual double min() {return 0.5;}
240  virtual double max() {return _nevents+0.5;}
241 
242  protected:
243  int _nevents;
244  };
245  }
246 }
247 
248 #endif
ValueQuantity(ValueQuantityType type, bool isLog=false)
Definition: ValueQuantity.h:84
type
Definition: HCALResponse.h:21
int i
Definition: DBlmapReader.cc:9
virtual void setBits(TH1 *o)
Definition: Quantity.h:65
int const nbins_value[nValueQuantityType]
Definition: ValueQuantity.h:73
std::string const name_value[nValueQuantityType]
Definition: ValueQuantity.h:54
FlagQuantity(std::vector< flag::Flag > const &flags)
std::vector< Variable::Flags > flags
Definition: MVATrainer.cc:135
std::vector< int > _runs
virtual std::string name()
virtual LumiSection * makeCopy()
virtual std::string name()
tuple runs
Definition: gather_cfg.py:87
virtual int getValue(int run)
virtual std::vector< std::string > getLabels()
virtual std::string name()
double const max_value[nValueQuantityType]
Definition: ValueQuantity.h:67
virtual void setMax(double x)
virtual uint32_t getBin(int run)
std::vector< flag::Flag > _flags
double f[11][100]
virtual uint32_t getBin(int l)
virtual ValueQuantity * makeCopy()
Definition: ValueQuantity.h:89
virtual uint32_t getBin(int f)
virtual double getValue(double x)
Definition: ValueQuantity.h:95
virtual std::vector< std::string > getLabels()
virtual FlagQuantity * makeCopy()
virtual void setBits(TH1 *o)
double const min_value[nValueQuantityType]
Definition: ValueQuantity.h:62
virtual bool isLog()
Definition: Quantity.h:48
RunNumber(std::vector< int > runs)
int const BIT_OFFSET
Definition: Constants.h:224
int const BIT_AXIS_LS
Definition: Constants.h:228
virtual QuantityType type()
Definition: ValueQuantity.h:99
virtual std::string name()