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 #include "boost/unordered_map.hpp"
7 #include "boost/foreach.hpp"
8 
9 namespace hcaldqm
10 {
11  namespace quantity
12  {
14  {
15  fN = 0,
16  fEvents = 1,
17  fEnergy = 2,
19  fADC_128 = 4,
20  fADC_5 = 5,
21  fADC_15 = 6,
22  ffC_10000 = 7,
23  ffC_1000 = 8,
24  ffC_3000 = 9,
25  fTiming_TS = 10,
27  fLS = 12,
28  fEt_256 = 13,
29  fEt_128 = 14,
30  fFG = 15,
31  fRatio = 16,
32  fDigiSize = 17,
34  fRatio2 = 19,
35  fdEtRatio = 20,
36  fSumdEt = 21,
38 
42  fDiffAbs = 26,
43 
45  fN_to3000 = 28,
50 
51  fBX = 33,
53  fState = 35,
54 
56  fDataSize = 37,
60  };
62  "N", "Events", "Energy", "Timing", "ADC (QIE8)", "ADC (QIE8)", "ADC QIE8()",
63  "fC (QIE8)", "fC (QIE8)", "fC (QIE8)", "Timing", "Timing", "LS", "Et", "Et",
64  "FG", "Ratio", "DigiSize", "Q", "Ratio",
65  "dEtRatio", "SumdEt", "Timing", "ADC (QIE10)", "TDC", "TDC",
66  "Q", "Ratio", "N", "Energy", "N", "Et", "ADC", "BX",
67  "Energy", "State", "fC (QIE10)", "FED Data Size (kB)", "fC (QIE10)",
68  "fC (QIE8)"
69  };
70  double const min_value[nValueQuantityType] = {
71  -0.05, 0, 0, -50, -0.5, -0.5, -0.5, 0, 0, 0, -0.5, 0, 0.5, 0,
72  0, 0, 0, -0.5, -1, 0.5, 0, 0, -0.5, -0.5, -0.5, -0.5,
73  0, 0, 0, 0, -0.05, -2, -2, -0.5, 0, flag::fNA, 0, 0, 0, 0
74  };
75  double const max_value[nValueQuantityType] = {
76  1000, 1000, 200, 50, 127.5, 5, 15, 10000, 1000, 3000,
77  9.5, 9.5, 4000.5, 255.5, 255.5, 2, 1, 20.5, 1, 1.5,
78  1, 1000, 9.5, 255.5, 63.5, 15.5, 1, 2, 3000, 100000, 10000,
79  256, 128, 3600.5, 1000, flag::nState, 300000, 100, 2000, 1000
80  };
82  200, 200, 100, 200, 128, 100, 300, 1000, 200, 600,
83  10, 200, 4000, 256, 128, 2, 100, 20, 100, 100, 100, 100, 10,
84  256, 64, 16, 200, 100, 3000, 500, 100, 258, 130, 3601, 200,
85  flag::nState, 10000, 100, 100, 50
86  };
87 
88  class ValueQuantity : public Quantity
89  {
90  public:
93  Quantity(name_value[type], isLog), _type(type)
94  {}
95  virtual ~ValueQuantity() {}
96 
98  {return new ValueQuantity(_type, _isLog);}
99 
100  // get Value to be overriden
101  virtual int getValue(int x)
102  {return x;}
103  virtual double getValue(double x)
104  {return x;}
105 
106  // standard properties
107  virtual QuantityType type() {return fValueQuantity;}
108  virtual int nbins() {return nbins_value[_type];}
109  virtual double min() {return min_value[_type];}
110  virtual double max() {return max_value[_type];}
111 
112  virtual void setBits(TH1* o)
113  {Quantity::setBits(o);setLS(o);}
114  virtual void setLS(TH1* o)
115  {
116  if (_type==fLS)
117  {
118  // for LS axis - set the bit
119  // set extendable axes.
120  o->SetBit(BIT(BIT_OFFSET+BIT_AXIS_LS));
121  // o->SetCanExtend(TH1::kXaxis);
122  }
123  }
124 
125  protected:
127  };
128 
130  {
131  public:
133  FlagQuantity(std::vector<flag::Flag> const& flags) :
134  _flags(flags) {}
135  virtual ~FlagQuantity() {}
136 
138  {return new FlagQuantity(_flags);}
139 
140  virtual std::string name() {return "Flag";}
141  virtual int nbins() {return _flags.size();}
142  virtual double min() {return 0;}
143  virtual double max() {return _flags.size();}
144  virtual int getValue(int f) {return f;}
145  virtual uint32_t getBin(int f) {return f+1;}
146  virtual std::vector<std::string> getLabels()
147  {
148  std::vector<std::string> vnames;
149  for (std::vector<flag::Flag>::const_iterator
150  it=_flags.begin(); it!=_flags.end(); ++it)
151  vnames.push_back(it->_name);
152 
153  return vnames;
154  }
155  protected:
156 
157  std::vector<flag::Flag> _flags;
158  };
159 
160  class LumiSection : public ValueQuantity
161  {
162  public:
164  {}
166  _n(n)
167  {}
168  virtual ~LumiSection() {}
169 
171  {return new LumiSection(_n);}
172 
173  virtual std::string name() {return "LS";}
174  virtual int nbins() {return _n;}
175  virtual double min() {return 1;}
176  virtual double max() {return _n+1;}
177  virtual int getValue(int l) {return l;}
178  virtual uint32_t getBin(int l)
179  {return getValue(l);}
180  virtual void setMax(double x) {_n=x;}
181 
182  protected:
183  int _n;
184  };
185 
186  class RunNumber : public ValueQuantity
187  {
188  public:
190  RunNumber(std::vector<int> runs) :
191  _runs(runs)
192  {}
193  virtual ~RunNumber() {}
194 
195  virtual std::string name() {return "Run";}
196  virtual int nbins() {return _runs.size();}
197  virtual double min() {return 0;}
198  virtual double max() {return _runs.size();}
199  virtual std::vector<std::string> getLabels()
200  {
201  char name[10];
202  std::vector<std::string> labels;
203  for (uint32_t i=0; i<_runs.size(); i++)
204  {
205  sprintf(name, "%d", _runs[i]);
206  labels.push_back(name);
207  }
208  return labels;
209  }
210  virtual int getValue(int run)
211  {
212  int ir = -1;
213  for (uint32_t i=0; i<_runs.size(); i++)
214  if (_runs[i]==run)
215  {
216  ir = (int)i;
217  break;
218  }
219 
220  if (ir==-1)
221  throw cms::Exception("HCALDQM")
222  << "run number doens't exist " << run;
223 
224  return ir;
225  }
226 
227  virtual uint32_t getBin(int run)
228  {
229  return (this->getValue(run)+1);
230  }
231 
232  protected:
233  std::vector<int> _runs;
234  };
235 
236  class EventNumber : public ValueQuantity
237  {
238  public:
241  ValueQuantity(fN), _nevents(nevents)
242  {}
243  virtual ~EventNumber() {}
244 
245  virtual std::string name() {return "Event";}
246  virtual int nbins() {return _nevents;}
247  virtual double min() {return 0.5;}
248  virtual double max() {return _nevents+0.5;}
249 
250  protected:
251  int _nevents;
252  };
253 
254  class EventType : public ValueQuantity
255  {
256  public:
258  EventType(std::vector<uint32_t> const& vtypes):
260  {this->setup(vtypes);}
261  virtual ~EventType() {}
262 
263  virtual void setup(std::vector<uint32_t> const& vtypes)
264  {
265  std::cout << "SIZE = " << vtypes.size() << std::endl;
266  for (uint32_t i=0; i<vtypes.size(); i++)
267  _types.insert(std::make_pair((uint32_t)vtypes[i], i));
268  }
269  virtual int getValue(int v)
270  {
271  return _types[(uint32_t)v];
272  }
273  virtual uint32_t getBin(int v)
274  {
275  return getValue(v)+1;
276  }
277 
278  virtual int nbins() {return _types.size();}
279  virtual double min() {return 0;}
280  virtual double max() {return _types.size();}
281  virtual std::string name() {return "Event Type";}
282 
283  protected:
284  typedef boost::unordered_map<uint32_t, int> TypeMap;
286 
287  public:
288  virtual std::vector<std::string> getLabels()
289  {
290  std::vector<std::string> labels(_types.size());
291  std::cout << "SIZE = " << _types.size() << std::endl;
292  BOOST_FOREACH(TypeMap::value_type &v, _types)
293  {
295  v.first);
296  }
297  return labels;
298  }
299  virtual EventType* makeCopy()
300  {
301  std::vector<uint32_t> vtypes;
302  BOOST_FOREACH(TypeMap::value_type &p, _types)
303  {
304  vtypes.push_back(p.first);
305  }
306 
307  std::sort(vtypes.begin(), vtypes.end());
308  return new EventType(vtypes);
309  }
310  };
311  }
312 }
313 
314 #endif
ValueQuantity(ValueQuantityType type, bool isLog=false)
Definition: ValueQuantity.h:92
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:81
std::string const name_value[nValueQuantityType]
Definition: ValueQuantity.h:61
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 void setup(std::vector< uint32_t > const &vtypes)
std::string ogtype2string(OrbitGapType type)
Definition: Utilities.cc:195
virtual LumiSection * makeCopy()
virtual std::string name()
virtual EventType * 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()
boost::unordered_map< uint32_t, int > TypeMap
double const max_value[nValueQuantityType]
Definition: ValueQuantity.h:75
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 int getValue(int v)
virtual ValueQuantity * makeCopy()
Definition: ValueQuantity.h:97
virtual uint32_t getBin(int f)
virtual double getValue(double x)
virtual std::vector< std::string > getLabels()
virtual FlagQuantity * makeCopy()
virtual uint32_t getBin(int v)
virtual void setBits(TH1 *o)
EventType(std::vector< uint32_t > const &vtypes)
double const min_value[nValueQuantityType]
Definition: ValueQuantity.h:70
virtual bool isLog()
Definition: Quantity.h:48
RunNumber(std::vector< int > runs)
int const BIT_OFFSET
Definition: Constants.h:263
int const BIT_AXIS_LS
Definition: Constants.h:267
tuple cout
Definition: gather_cfg.py:145
virtual QuantityType type()
virtual std::string name()
virtual std::vector< std::string > getLabels()