CMS 3D CMS Logo

MESetBinningUtils.h
Go to the documentation of this file.
1 #ifndef MESetBinningUtils_H
2 #define MESetBinningUtils_H
3 
5 
6 #include <string>
7 
8 class DetId;
10 namespace edm {
11  class ParameterSet;
13 } // namespace edm
14 
15 namespace ecaldqm {
16  namespace binning {
17  enum ObjectType {
18  kEB,
19  kEE,
22  kSM,
38  };
39 
40  enum BinningType {
54  };
55 
56  enum Constants {
58 
59  nEBSMEta = 85,
60  nEBSMPhi = 20,
61  nEESMX = 40,
62  nEESMXRed = 30, // for EE+-01&05&09
63  nEESMXExt = 45, // for EE+-02&08
64  nEESMY = 40,
65  nEESMYRed = 35, // for EE+-03&07
66 
67  nEBEtaBins = 34,
68  nEEEtaBins = 20,
69  nPhiBins = 36
70  };
71 
72  struct AxisSpecs {
73  int nbins;
74  float low, high;
75  float *edges;
78  AxisSpecs() : nbins(0), low(0.), high(0.), edges(nullptr), labels(nullptr), title("") {}
79  AxisSpecs(AxisSpecs const &_specs)
80  : nbins(_specs.nbins),
81  low(_specs.low),
82  high(_specs.high),
83  edges(nullptr),
84  labels(nullptr),
85  title(_specs.title) {
86  if (_specs.edges) {
87  edges = new float[nbins + 1];
88  for (int i(0); i <= nbins; i++)
89  edges[i] = _specs.edges[i];
90  }
91  if (_specs.labels) {
92  labels = new std::string[nbins];
93  for (int i(0); i < nbins; i++)
94  labels[i] = _specs.labels[i];
95  }
96  }
97  AxisSpecs &operator=(AxisSpecs const &_rhs) {
98  if (edges) {
99  delete[] edges;
100  edges = nullptr;
101  }
102  if (labels) {
103  delete[] labels;
104  labels = nullptr;
105  }
106  nbins = _rhs.nbins;
107  low = _rhs.low;
108  high = _rhs.high;
109  title = _rhs.title;
110  if (_rhs.edges) {
111  edges = new float[nbins + 1];
112  for (int i(0); i <= nbins; i++)
113  edges[i] = _rhs.edges[i];
114  }
115  if (_rhs.labels) {
116  labels = new std::string[nbins];
117  for (int i(0); i < nbins; i++)
118  labels[i] = _rhs.labels[i];
119  }
120  return *this;
121  }
123  delete[] edges;
124  delete[] labels;
125  }
126  };
127 
128  AxisSpecs getBinning(ObjectType, BinningType, bool, int, unsigned);
129 
130  int findBin1D(ObjectType, BinningType, DetId const &);
132  int findBin1D(ObjectType, BinningType, int);
133 
134  int findBin2D(ObjectType, BinningType, DetId const &);
136  int findBin2D(ObjectType, BinningType, int);
137 
138  unsigned findPlotIndex(ObjectType, DetId const &);
139  unsigned findPlotIndex(ObjectType, EcalElectronicsId const &);
140  unsigned findPlotIndex(ObjectType, int, BinningType _btype = kDCC);
141 
142  ObjectType getObject(ObjectType, unsigned);
143 
144  unsigned getNObjects(ObjectType);
145 
146  bool isValidIdBin(ObjectType, BinningType, unsigned, int);
147 
148  std::string channelName(uint32_t, BinningType _btype = kDCC);
149 
150  uint32_t idFromName(std::string const &);
151  uint32_t idFromBin(ObjectType, BinningType, unsigned, int);
152 
155 
159 
160  /* Functions used only internally within binning namespace */
161 
162  // used for SM binnings
163  int xlow_(int);
164  int ylow_(int);
165 
166  AxisSpecs getBinningEB_(BinningType, bool, int);
167  AxisSpecs getBinningEE_(BinningType, bool, int, int);
168  AxisSpecs getBinningSM_(BinningType, bool, unsigned, int);
169  AxisSpecs getBinningSMMEM_(BinningType, bool, unsigned, int);
171  AxisSpecs getBinningMEM_(BinningType, bool, int, int);
172 
173  int findBinCrystal_(ObjectType, DetId const &, int = -1);
175  int findBinTriggerTower_(ObjectType, DetId const &);
176  int findBinPseudoStrip_(ObjectType, DetId const &);
177  int findBinRCT_(ObjectType, DetId const &);
178  int findBinSuperCrystal_(ObjectType, DetId const &, int = -1);
180  } // namespace binning
181 } // namespace ecaldqm
182 
183 #endif
unsigned findPlotIndex(ObjectType, int, BinningType _btype=kDCC)
int findBinRCT_(ObjectType, DetId const &)
int findBinTriggerTower_(ObjectType, DetId const &)
TObject * getObject(TDirectory *fDir, const std::vector< std::string > &fObjectName)
Definition: compareHists.cc:44
bool isValidIdBin(ObjectType, BinningType, unsigned, int)
Ecal readout channel identification [32:20] Unused (so far) [19:13] DCC id [12:6] tower [5:3] strip [...
unsigned getNObjects(ObjectType)
#define nullptr
int findBinSuperCrystal_(ObjectType, EcalElectronicsId const &)
int findBin2D(ObjectType, BinningType, int)
ObjectType translateObjectType(std::string const &)
AxisSpecs getBinning(ObjectType, BinningType, bool, int, unsigned)
AxisSpecs getBinningSMMEM_(BinningType, bool, unsigned, int)
int findBinCrystal_(ObjectType, EcalElectronicsId const &)
AxisSpecs(AxisSpecs const &_specs)
AxisSpecs getBinningEB_(BinningType, bool, int)
AxisSpecs & operator=(AxisSpecs const &_rhs)
uint32_t idFromName(std::string const &)
AxisSpecs getBinningSM_(BinningType, bool, unsigned, int)
std::string channelName(uint32_t, BinningType _btype=kDCC)
Definition: DetId.h:18
AxisSpecs getBinningEE_(BinningType, bool, int, int)
HLT enums.
void fillAxisDescriptions(edm::ParameterSetDescription &)
int findBin1D(ObjectType, BinningType, int)
MonitorElement::Kind translateKind(std::string const &)
int findBinPseudoStrip_(ObjectType, DetId const &)
BinningType translateBinningType(std::string const &)
AxisSpecs formAxis(edm::ParameterSet const &)
AxisSpecs getBinningMEM_(BinningType, bool, int, int)
AxisSpecs getBinningEcal_(BinningType, bool, int)
uint32_t idFromBin(ObjectType, BinningType, unsigned, int)