CMS 3D CMS Logo

EcalFloatCondObjectContainerUtils.h
Go to the documentation of this file.
5 
6 #include "TH2F.h"
7 #include <string>
8 
9 enum { kEBChannels = 61200, kEEChannels = 14648 };
10 enum {
11  MIN_IETA = 1,
12  MIN_IPHI = 1,
13  MAX_IETA = 85,
14  MAX_IPHI = 360,
16 }; // barrel lower and upper bounds on eta and phi
17 enum {
18  IX_MIN = 1,
19  IY_MIN = 1,
20  IX_MAX = 100,
21  IY_MAX = 100,
22  EEhistXMax = 220
23 }; // endcaps lower and upper bounds on x and y
24 
25 template <class floatCondObj>
26 void fillEBMap_SingleIOV(std::shared_ptr<floatCondObj> payload, TH2F*& barrel) {
27  for (int cellid = EBDetId::MIN_HASH; cellid < EBDetId::kSizeForDenseIndexing; ++cellid) {
28  uint32_t rawid = EBDetId::unhashIndex(cellid);
30  if (value_ptr == payload->end())
31  continue; // cell absent from payload
32 
33  float weight = (float)(*value_ptr);
34  Double_t phi = (Double_t)(EBDetId(rawid)).iphi() - 0.5;
35  Double_t eta = (Double_t)(EBDetId(rawid)).ieta();
36 
37  if (eta > 0.)
38  eta = eta - 0.5; // 0.5 to 84.5
39  else
40  eta = eta + 0.5; // -84.5 to -0.5
41 
42  barrel->Fill(phi, eta, weight);
43  } // loop over cellid
44 }
45 
46 template <class floatCondObj>
47 void fillEEMap_SingleIOV(std::shared_ptr<floatCondObj> payload, TH2F*& endc_m, TH2F*& endc_p) {
48  // looping over the EE channels
49  for (int iz = -1; iz < 2; iz = iz + 2) // -1 or +1
50  for (int iy = IY_MIN; iy < IY_MAX + IY_MIN; iy++)
51  for (int ix = IX_MIN; ix < IX_MAX + IX_MIN; ix++)
52  if (EEDetId::validDetId(ix, iy, iz)) {
53  EEDetId myEEId = EEDetId(ix, iy, iz, EEDetId::XYMODE);
54  uint32_t rawid = myEEId.rawId();
56  if (value_ptr == payload->end())
57  continue; // cell absent from payload
58 
59  float weight = (float)(*value_ptr);
60  if (iz == 1)
61  endc_p->Fill(ix, iy, weight);
62  else
63  endc_m->Fill(ix, iy, weight);
64 
65  } // validDetId
66 }
67 
68 template <class floatCondObj>
69 void fillEBMap_TwoIOVs(std::shared_ptr<floatCondObj> payload,
70  TH2F*& barrel,
71  int irun,
72  float pEB[],
73  float& pEBmin,
74  float& pEBmax,
75  int method) {
76  for (int cellid = EBDetId::MIN_HASH; cellid < EBDetId::kSizeForDenseIndexing; ++cellid) {
77  uint32_t rawid = EBDetId::unhashIndex(cellid);
79  if (value_ptr == payload->end())
80  continue; // cell absent from payload
81 
82  float weight = (float)(*value_ptr);
83  if (irun == 0)
84  pEB[cellid] = weight;
85  else {
86  Double_t phi = (Double_t)(EBDetId(rawid)).iphi() - 0.5;
87  Double_t eta = (Double_t)(EBDetId(rawid)).ieta();
88 
89  if (eta > 0.)
90  eta = eta - 0.5; // 0.5 to 84.5
91  else
92  eta = eta + 0.5; // -84.5 to -0.5
93  double dr;
94  if (method == 0) {
95  dr = weight - pEB[cellid];
96  } // diff
97  else {
98  if (pEB[cellid] != 0.)
99  dr = weight / pEB[cellid];
100  else {
101  if (weight == 0.)
102  dr = 1.;
103  else
104  dr = 9999.; // use a large value
105  }
106  } // ratio
107  if (dr < pEBmin)
108  pEBmin = dr;
109  if (dr > pEBmax)
110  pEBmax = dr;
111  barrel->Fill(phi, eta, dr);
112  }
113  } // loop over cellid
114 }
115 
116 template <class floatCondObj>
117 void fillEEMap_TwoIOVs(std::shared_ptr<floatCondObj> payload,
118  TH2F*& endc_m,
119  TH2F*& endc_p,
120  int irun,
121  float pEE[],
122  float& pEEmin,
123  float& pEEmax,
124  int method) {
125  // looping over the EE channels
126  for (int iz = -1; iz < 2; iz = iz + 2) // -1 or +1
127  for (int iy = IY_MIN; iy < IY_MAX + IY_MIN; iy++)
128  for (int ix = IX_MIN; ix < IX_MAX + IX_MIN; ix++)
129  if (EEDetId::validDetId(ix, iy, iz)) {
130  EEDetId myEEId = EEDetId(ix, iy, iz, EEDetId::XYMODE);
131  uint32_t cellid = myEEId.hashedIndex();
132  uint32_t rawid = myEEId.rawId();
134 
135  if (value_ptr == payload->end())
136  continue; // cell absent from payload
137  float weight = (float)(*value_ptr);
138 
139  if (irun == 0)
140  pEE[cellid] = weight;
141  else {
142  double dr;
143  if (method == 0) {
144  dr = weight - pEE[cellid];
145  } // diff
146  else {
147  if (pEE[cellid] != 0.)
148  dr = weight / pEE[cellid];
149  else {
150  if (weight == 0.)
151  dr = 1.;
152  else
153  dr = 9999.; // use a large value
154  }
155  } // ratio
156  if (dr < pEEmin)
157  pEEmin = dr;
158  if (dr > pEEmax)
159  pEEmax = dr;
160  if (iz == 1)
161  endc_p->Fill(ix, iy, dr);
162  else
163  endc_m->Fill(ix, iy, dr);
164  }
165 
166  } // validDetId
167 }
168 
169 inline void fillTableWithSummary(TH2F*& align,
171  const float& mean_x_EB,
172  const float& rms_EB,
173  const int& num_x_EB,
174  const float& mean_x_EE,
175  const float& rms_EE,
176  const int& num_x_EE) {
177  int NbRows = 2;
178  align = new TH2F(title.c_str(), "EB/EE mean_x rms num_x", 4, 0, 4, NbRows, 0, NbRows);
179 
180  double row = NbRows - 0.5;
181 
182  align->Fill(0.5, row, 1);
183  align->Fill(1.5, row, mean_x_EB);
184  align->Fill(2.5, row, rms_EB);
185  align->Fill(3.5, row, num_x_EB);
186 
187  row--;
188 
189  align->Fill(0.5, row, 2);
190  align->Fill(1.5, row, mean_x_EE);
191  align->Fill(2.5, row, rms_EE);
192  align->Fill(3.5, row, num_x_EE);
193 
194  align->GetXaxis()->SetTickLength(0.);
195  align->GetXaxis()->SetLabelSize(0.);
196  align->GetYaxis()->SetTickLength(0.);
197  align->GetYaxis()->SetLabelSize(0.);
198 }
void fillTableWithSummary(TH2F *&align, std::string title, const float &mean_x_EB, const float &rms_EB, const int &num_x_EB, const float &mean_x_EE, const float &rms_EE, const int &num_x_EE)
void fillEBMap_TwoIOVs(std::shared_ptr< floatCondObj > payload, TH2F *&barrel, int irun, float pEB[], float &pEBmin, float &pEBmax, int method)
static const int XYMODE
Definition: EEDetId.h:335
Definition: weight.py:1
void fillEEMap_TwoIOVs(std::shared_ptr< floatCondObj > payload, TH2F *&endc_m, TH2F *&endc_p, int irun, float pEE[], float &pEEmin, float &pEEmax, int method)
static const int MIN_HASH
Definition: EBDetId.h:149
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
static bool validDetId(int crystal_ix, int crystal_iy, int iz)
Definition: EEDetId.h:248
std::vector< Item >::const_iterator const_iterator
void fillEEMap_SingleIOV(std::shared_ptr< floatCondObj > payload, TH2F *&endc_m, TH2F *&endc_p)
static EBDetId unhashIndex(int hi)
get a DetId from a compact index for arrays
Definition: EBDetId.h:110
int hashedIndex() const
Definition: EEDetId.h:183
void fillEBMap_SingleIOV(std::shared_ptr< floatCondObj > payload, TH2F *&barrel)