CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
EcalDQMBinningService.h
Go to the documentation of this file.
1 #ifndef EcalDQMBinningService_H
2 #define EcalDQMBinningService_H
3 
4 #include <map>
5 #include <stdint.h>
6 #include <string>
7 #include <vector>
8 
10 
12 
13 // Keeps a map between channel ids and DQM histogram bins
14 // The map is booked ad-hoc
15 
16 namespace edm {
17  class ParameterSet;
18  class ActivityRegistry;
19  class Run;
20  class EventSetup;
21 }
22 class CaloGeometry;
23 class DQMStore;
24 class EcalElectronicsId;
25 
27  public:
28  enum ObjectType {
29  kEB,
31  kEE,
35  kSM,
43  };
44 
45  enum BinningType {
57  };
58 
59  enum Constants {
62 
63  nDCC = 54,
64  nDCCMEM = 44,
65 
66  nTCC = 108,
68  kEEpTCCLow = 72, kEEpTCCHigh = 107,
69  kEBTCCLow = 36, kEBTCCHigh = 71,
70 
71  nEBSMEta = 85,
72  nEBSMPhi = 20,
74  nEESMX = 40,
75  nEESMY = 40,
77  nEESMXExt = 45, // for EE+-02&08
79 
80 
81  nEBEtaBins = 34,
82  nEEEtaBins = 20,
83  nPhiBins = 36
84  };
85 
86  struct AxisSpecs {
87  int nbins;
88  double low, high;
89  double* edges;
90  std::string title;
91  AxisSpecs() : nbins(1), edges(0) {}
92  AxisSpecs(AxisSpecs const& _specs) :
93  nbins(_specs.nbins), low(_specs.low), high(_specs.high), edges(0), title(_specs.title)
94  {
95  if(_specs.edges){
96  edges = new double[nbins + 1];
97  for(int i(0); i <= nbins; i++) edges[i] = _specs.edges[i];
98  }
99  }
101  {
102  if(edges){ delete [] edges; edges = 0; }
103  nbins = _rhs.nbins; low = _rhs.low; high = _rhs.high; title = _rhs.title;
104  if(_rhs.edges){
105  edges = new double[nbins + 1];
106  for(int i(0); i <= nbins; i++) edges[i] = _rhs.edges[i];
107  }
108  return *this;
109  }
110  ~AxisSpecs() { if(edges) delete [] edges; }
111  };
112 
115 
116  void postBeginRun(const edm::Run&, const edm::EventSetup&);
117 
118  std::vector<AxisSpecs> getBinning(ObjectType, BinningType, bool _isMap = true, unsigned _objOffset = 0) const;
119 
120  // takes care of "key translations" as well - okey and bkey can have changed after the function returns
121  const std::vector<int>* getBinMap(ObjectType&, BinningType&) const;
122 
123  std::pair<unsigned, std::vector<int> > findBins(ObjectType, BinningType, const DetId&) const;
124  std::pair<unsigned, std::vector<int> > findBins(ObjectType, BinningType, const EcalElectronicsId&) const;
125  std::pair<unsigned, std::vector<int> > findBins(ObjectType, BinningType, unsigned) const;
126  // EcalElectronicsId version returns at most one bin
127 
128  std::pair<unsigned, std::vector<int> > findBinsNoMap(ObjectType, BinningType, const DetId&) const;
129  std::pair<unsigned, std::vector<int> > findBinsNoMap(ObjectType, BinningType, const EcalElectronicsId&) const;
130 
131  unsigned findOffset(ObjectType, const DetId&) const;
132  unsigned findOffset(ObjectType, const EcalElectronicsId&) const;
133  unsigned findOffset(ObjectType, BinningType, unsigned) const;
134 
135  ObjectType objectFromOffset(ObjectType, unsigned) const;
136 
137  int smOffsetBins(ObjectType, BinningType, unsigned) const;
138 
139  // used for EE binnings
140  int xlow(int) const;
141  int ylow(int) const;
142 
143  std::string channelName(uint32_t, BinningType _btype = kDCC) const;
144 
145  uint32_t idFromName(std::string const&) const;
146 
147  private:
148  std::vector<AxisSpecs> getBinningEB_(BinningType, bool) const;
149  std::vector<AxisSpecs> getBinningEBMEM_(BinningType, bool) const;
150  std::vector<AxisSpecs> getBinningEE_(BinningType, bool, int) const;
151  std::vector<AxisSpecs> getBinningEEMEM_(BinningType, bool) const;
152  std::vector<AxisSpecs> getBinningSM_(BinningType, bool, unsigned) const;
153  std::vector<AxisSpecs> getBinningSMMEM_(BinningType, bool, unsigned) const;
154  std::vector<AxisSpecs> getBinningEcal_(BinningType, bool) const;
155 
156  const std::vector<int>* getBinMapEB_(BinningType) const;
157  const std::vector<int>* getBinMapEBMEM_(BinningType) const;
158  const std::vector<int>* getBinMapEE_(BinningType, int) const;
159  const std::vector<int>* getBinMapEEMEM_(BinningType) const;
160  const std::vector<int>* getBinMapSM_(BinningType) const;
161  const std::vector<int>* getBinMapSMMEM_(BinningType) const;
162  const std::vector<int>* getBinMapEcal_(BinningType) const;
163 
164  void findBinsCrystal_(const DetId&, ObjectType, const std::vector<int>&, std::vector<int>&) const;
165  void findBinsTriggerTower_(const DetId&, ObjectType, const std::vector<int>&, std::vector<int>&) const;
166  void findBinsSuperCrystal_(const DetId&, ObjectType, const std::vector<int>&, std::vector<int>&) const;
167  void findBinsDCC_(const DetId&, ObjectType, const std::vector<int>&, std::vector<int>&) const;
168  void findBinsTCC_(const DetId&, ObjectType, const std::vector<int>&, std::vector<int>&) const;
169  void findBinsProjEta_(const DetId&, ObjectType, const std::vector<int>&, std::vector<int>&) const;
170  void findBinsProjPhi_(const DetId&, ObjectType, const std::vector<int>&, std::vector<int>&) const;
171 
172  // need to be mutable to allow ad-hoc booking
173  mutable std::vector<int> binMaps_[nPlotType][nPresetBinnings];
174  /*
175  Following dictionaries are created during postBeginRun:
176  (kEB, kCrystal) (kEB, kSuperCrystal) (kEB, kDCC) (kEB, kTCC) (kEBMEM, kCrystal)
177  (kEE, kCrystal) (kEE, kSuperCrystal) (kEE, kDCC) (kEE, kTCC) (kEEMEM, kCrystal)
178  (kEEm, kCrystal) (kEEm, kSuperCrystal) (kEEm, kDCC) (kEEm, kTCC)
179  (kEEp, kCrystal) (kEEp, kSuperCrystal) (kEEp, kDCC) (kEEp, kTCC)
180  (kSM, kCrystal) (kSM, kSuperCrystal) (kSM, kTriggerTower) (kSMMEM, kCrystal)
181  */
182 
183  mutable uint32_t cacheId_;
186  mutable std::pair<unsigned, std::vector<int> > cache_;
187 
188  const double etaBound_;
189 
191 
193 
195 
196 };
197 
198 #endif
std::vector< AxisSpecs > getBinningEBMEM_(BinningType, bool) const
const std::vector< int > * getBinMapSMMEM_(BinningType) const
int i
Definition: DBlmapReader.cc:9
std::string channelName(uint32_t, BinningType _btype=kDCC) const
std::vector< AxisSpecs > getBinningEcal_(BinningType, bool) const
void findBinsDCC_(const DetId &, ObjectType, const std::vector< int > &, std::vector< int > &) const
const std::vector< int > * getBinMapEcal_(BinningType) const
Ecal readout channel identification [32:20] Unused (so far) [19:13] DCC id [12:6] tower [5:3] strip [...
const std::vector< int > * getBinMap(ObjectType &, BinningType &) const
std::vector< AxisSpecs > getBinning(ObjectType, BinningType, bool _isMap=true, unsigned _objOffset=0) const
std::vector< AxisSpecs > getBinningSMMEM_(BinningType, bool, unsigned) const
void findBinsTCC_(const DetId &, ObjectType, const std::vector< int > &, std::vector< int > &) const
const std::vector< int > * getBinMapEE_(BinningType, int) const
ObjectType objectFromOffset(ObjectType, unsigned) const
const std::vector< int > * getBinMapEEMEM_(BinningType) const
void findBinsProjPhi_(const DetId &, ObjectType, const std::vector< int > &, std::vector< int > &) const
void findBinsCrystal_(const DetId &, ObjectType, const std::vector< int > &, std::vector< int > &) const
void findBinsSuperCrystal_(const DetId &, ObjectType, const std::vector< int > &, std::vector< int > &) const
std::vector< AxisSpecs > getBinningEE_(BinningType, bool, int) const
void postBeginRun(const edm::Run &, const edm::EventSetup &)
std::vector< int > binMaps_[nPlotType][nPresetBinnings]
const std::vector< int > * getBinMapSM_(BinningType) const
unsigned findOffset(ObjectType, const DetId &) const
std::vector< AxisSpecs > getBinningEB_(BinningType, bool) const
std::pair< unsigned, std::vector< int > > findBinsNoMap(ObjectType, BinningType, const DetId &) const
AxisSpecs(AxisSpecs const &_specs)
EcalDQMBinningService(const edm::ParameterSet &, edm::ActivityRegistry &)
const std::vector< int > * getBinMapEB_(BinningType) const
Definition: DetId.h:20
AxisSpecs & operator=(AxisSpecs const &_rhs)
const std::vector< int > * getBinMapEBMEM_(BinningType) const
uint32_t idFromName(std::string const &) const
std::pair< unsigned, std::vector< int > > findBins(ObjectType, BinningType, const DetId &) const
void findBinsTriggerTower_(const DetId &, ObjectType, const std::vector< int > &, std::vector< int > &) const
const CaloGeometry * geometry_
std::vector< AxisSpecs > getBinningSM_(BinningType, bool, unsigned) const
std::pair< unsigned, std::vector< int > > cache_
int smOffsetBins(ObjectType, BinningType, unsigned) const
void findBinsProjEta_(const DetId &, ObjectType, const std::vector< int > &, std::vector< int > &) const
Definition: Run.h:33
std::vector< AxisSpecs > getBinningEEMEM_(BinningType, bool) const