CMS 3D CMS Logo

EcalTPGPedestals_PayloadInspector.cc
Go to the documentation of this file.
7 
8 // the data format of the condition to be inspected
10 
11 #include "TH2F.h"
12 #include "TCanvas.h"
13 #include "TLine.h"
14 #include "TStyle.h"
15 #include "TLatex.h"
16 #include "TPave.h"
17 #include "TPaveStats.h"
18 #include <string>
19 #include <fstream>
20 
21 namespace {
22  enum { kEBChannels = 61200, kEEChannels = 14648, kGains = 3, kSides = 2 };
23  enum { MIN_IETA = 1, MIN_IPHI = 1, MAX_IETA = 85, MAX_IPHI = 360 }; // barrel lower and upper bounds on eta and phi
24  enum { IX_MIN = 1, IY_MIN = 1, IX_MAX = 100, IY_MAX = 100 }; // endcaps lower and upper bounds on x and y
25  int gainValues[kGains] = {12, 6, 1};
26 
27  /**************************************************
28  2d plot of ECAL TPGPedestals of 1 IOV
29  **************************************************/
30  class EcalTPGPedestalsPlot : public cond::payloadInspector::PlotImage<EcalTPGPedestals> {
31  public:
32  EcalTPGPedestalsPlot() : cond::payloadInspector::PlotImage<EcalTPGPedestals>("ECAL Gain Ratios - map ") {
33  setSingleIov(true);
34  }
35 
36  bool fill(const std::vector<std::tuple<cond::Time_t, cond::Hash> >& iovs) override {
37  TH2F** barrel_m = new TH2F*[kGains];
38  TH2F** endc_p_m = new TH2F*[kGains];
39  TH2F** endc_m_m = new TH2F*[kGains];
40  float mEBmin[kGains], mEEmin[kGains], mEBmax[kGains], mEEmax[kGains];
41  for (int gainId = 0; gainId < kGains; gainId++) {
42  barrel_m[gainId] = new TH2F(Form("EBm%i", gainId),
43  Form("EB mean_x%i ", gainValues[gainId]),
44  MAX_IPHI,
45  0,
46  MAX_IPHI,
47  2 * MAX_IETA,
48  -MAX_IETA,
49  MAX_IETA);
50  endc_p_m[gainId] = new TH2F(Form("EE+m%i", gainId),
51  Form("EE+ mean_x%i", gainValues[gainId]),
52  IX_MAX,
53  IX_MIN,
54  IX_MAX + 1,
55  IY_MAX,
56  IY_MIN,
57  IY_MAX + 1);
58  endc_m_m[gainId] = new TH2F(Form("EE-m%i", gainId),
59  Form("EE- mean_x%i", gainValues[gainId]),
60  IX_MAX,
61  IX_MIN,
62  IX_MAX + 1,
63  IY_MAX,
64  IY_MIN,
65  IY_MAX + 1);
66  mEBmin[gainId] = 10.;
67  mEEmin[gainId] = 10.;
68  mEBmax[gainId] = -10.;
69  mEEmax[gainId] = -10.;
70  }
71 
72  // std::ofstream fout;
73  // fout.open("./bid.txt");
74  auto iov = iovs.front();
75  std::shared_ptr<EcalTPGPedestals> payload = fetchPayload(std::get<1>(iov));
76  unsigned int run = std::get<0>(iov);
77  if (payload.get()) {
78  for (int sign = 0; sign < kSides; sign++) {
79  int thesign = sign == 1 ? 1 : -1;
80 
81  for (int ieta = 0; ieta < MAX_IETA; ieta++) {
82  for (int iphi = 0; iphi < MAX_IPHI; iphi++) {
83  EBDetId id((ieta + 1) * thesign, iphi + 1);
84  float y = -1 - ieta;
85  if (sign == 1)
86  y = ieta;
87  float val = (*payload)[id.rawId()].mean_x12;
88  barrel_m[0]->Fill(iphi, y, val);
89  if (val < mEBmin[0])
90  mEBmin[0] = val;
91  if (val > mEBmax[0])
92  mEBmax[0] = val;
93  val = (*payload)[id.rawId()].mean_x6;
94  barrel_m[1]->Fill(iphi, y, val);
95  if (val < mEBmin[1])
96  mEBmin[1] = val;
97  if (val > mEBmax[1])
98  mEBmax[1] = val;
99  val = (*payload)[id.rawId()].mean_x1;
100  barrel_m[2]->Fill(iphi, y, val);
101  if (val < mEBmin[2])
102  mEBmin[2] = val;
103  if (val > mEBmax[2])
104  mEBmax[2] = val;
105  } // iphi
106  } // ieta
107 
108  for (int ix = 0; ix < IX_MAX; ix++) {
109  for (int iy = 0; iy < IY_MAX; iy++) {
110  if (!EEDetId::validDetId(ix + 1, iy + 1, thesign))
111  continue;
112  EEDetId id(ix + 1, iy + 1, thesign);
113  float val = (*payload)[id.rawId()].mean_x12;
114  if (thesign == 1)
115  endc_p_m[0]->Fill(ix + 1, iy + 1, val);
116  else
117  endc_m_m[0]->Fill(ix + 1, iy + 1, val);
118  if (val < mEEmin[0])
119  mEEmin[0] = val;
120  if (val > mEEmax[0])
121  mEEmax[0] = val;
122  val = (*payload)[id.rawId()].mean_x6;
123  if (thesign == 1)
124  endc_p_m[1]->Fill(ix + 1, iy + 1, val);
125  else
126  endc_m_m[1]->Fill(ix + 1, iy + 1, val);
127  if (val < mEEmin[1])
128  mEEmin[1] = val;
129  if (val > mEEmax[1])
130  mEEmax[1] = val;
131  val = (*payload)[id.rawId()].mean_x1;
132  if (thesign == 1)
133  endc_p_m[2]->Fill(ix + 1, iy + 1, val);
134  else
135  endc_m_m[2]->Fill(ix + 1, iy + 1, val);
136  if (val < mEEmin[2])
137  mEEmin[2] = val;
138  if (val > mEEmax[2])
139  mEEmax[2] = val;
140  // fout << " x " << ix << " y " << " val " << val << std::endl;
141  } // iy
142  } // ix
143  } // side
144  } // if payload.get()
145  else
146  return false;
147  // std::cout << " min " << rEEmin[2] << " max " << rEEmax[2] << std::endl;
148  // fout.close();
149 
150  gStyle->SetPalette(1);
151  gStyle->SetOptStat(0);
152  TCanvas canvas("CC map", "CC map", 1200, 900);
153  TLatex t1;
154  t1.SetNDC();
155  t1.SetTextAlign(26);
156  t1.SetTextSize(0.05);
157  t1.DrawLatex(0.5, 0.96, Form("Ecal Gain TPGPedestals, IOV %i", run));
158 
159  float xmi[3] = {0.0, 0.22, 0.78};
160  float xma[3] = {0.22, 0.78, 1.00};
161  TPad*** pad = new TPad**[kGains];
162  for (int gId = 0; gId < kGains; gId++) {
163  pad[gId] = new TPad*[3];
164  for (int obj = 0; obj < 3; obj++) {
165  float yma = 0.94 - (0.32 * gId);
166  float ymi = yma - 0.30;
167  pad[gId][obj] = new TPad(Form("p_%i_%i", obj, gId), Form("p_%i_%i", obj, gId), xmi[obj], ymi, xma[obj], yma);
168  pad[gId][obj]->Draw();
169  }
170  }
171 
172  for (int gId = 0; gId < kGains; gId++) {
173  pad[gId][0]->cd();
174  DrawEE(endc_m_m[gId], mEEmin[gId], mEEmax[gId]);
175  pad[gId][1]->cd();
176  DrawEB(barrel_m[gId], mEBmin[gId], mEBmax[gId]);
177  pad[gId][2]->cd();
178  DrawEE(endc_p_m[gId], mEEmin[gId], mEEmax[gId]);
179  }
180 
181  std::string ImageName(m_imageFileName);
182  canvas.SaveAs(ImageName.c_str());
183  return true;
184  } // fill method
185  };
186 
187  /******************************************************************
188  2d plot of ECAL TPGPedestals difference between 2 IOVs
189  ******************************************************************/
190  class EcalTPGPedestalsDiff : public cond::payloadInspector::PlotImage<EcalTPGPedestals> {
191  public:
192  EcalTPGPedestalsDiff() : cond::payloadInspector::PlotImage<EcalTPGPedestals>("ECAL Gain Ratios difference") {
193  setSingleIov(false);
194  }
195 
196  bool fill(const std::vector<std::tuple<cond::Time_t, cond::Hash> >& iovs) override {
197  TH2F** barrel_m = new TH2F*[kGains];
198  TH2F** endc_p_m = new TH2F*[kGains];
199  TH2F** endc_m_m = new TH2F*[kGains];
200  float mEBmin[kGains], mEEmin[kGains], mEBmax[kGains], mEEmax[kGains];
201  float mEB[kGains][kEBChannels], mEE[kGains][kEEChannels];
202  for (int gainId = 0; gainId < kGains; gainId++) {
203  barrel_m[gainId] = new TH2F(Form("EBm%i", gainId),
204  Form("EB mean_x%i ", gainValues[gainId]),
205  MAX_IPHI,
206  0,
207  MAX_IPHI,
208  2 * MAX_IETA,
209  -MAX_IETA,
210  MAX_IETA);
211  endc_p_m[gainId] = new TH2F(Form("EE+m%i", gainId),
212  Form("EE+ mean_x%i", gainValues[gainId]),
213  IX_MAX,
214  IX_MIN,
215  IX_MAX + 1,
216  IY_MAX,
217  IY_MIN,
218  IY_MAX + 1);
219  endc_m_m[gainId] = new TH2F(Form("EE-m%i", gainId),
220  Form("EE- mean_x%i", gainValues[gainId]),
221  IX_MAX,
222  IX_MIN,
223  IX_MAX + 1,
224  IY_MAX,
225  IY_MIN,
226  IY_MAX + 1);
227  mEBmin[gainId] = 10.;
228  mEEmin[gainId] = 10.;
229  mEBmax[gainId] = -10.;
230  mEEmax[gainId] = -10.;
231  }
232 
233  unsigned int run[2], irun = 0;
234  //float gEB[3][kEBChannels], gEE[3][kEEChannels];
235  for (auto const& iov : iovs) {
236  std::shared_ptr<EcalTPGPedestals> payload = fetchPayload(std::get<1>(iov));
237  run[irun] = std::get<0>(iov);
238  if (payload.get()) {
239  for (int sign = 0; sign < kSides; sign++) {
240  int thesign = sign == 1 ? 1 : -1;
241 
242  for (int ieta = 0; ieta < MAX_IETA; ieta++) {
243  for (int iphi = 0; iphi < MAX_IPHI; iphi++) {
244  EBDetId id((ieta + 1) * thesign, iphi + 1);
245  int hashindex = id.hashedIndex();
246  float y = -1 - ieta;
247  if (sign == 1)
248  y = ieta;
249  float val = (*payload)[id.rawId()].mean_x12;
250  if (irun == 0) {
251  mEB[0][hashindex] = val;
252  } else {
253  float diff = val - mEB[0][hashindex];
254  barrel_m[0]->Fill(iphi, y, diff);
255  if (diff < mEBmin[0])
256  mEBmin[0] = diff;
257  if (diff > mEBmax[0])
258  mEBmax[0] = diff;
259  }
260  val = (*payload)[id.rawId()].mean_x6;
261  if (irun == 0) {
262  mEB[1][hashindex] = val;
263  } else {
264  float diff = val - mEB[1][hashindex];
265  barrel_m[1]->Fill(iphi, y, diff);
266  if (diff < mEBmin[1])
267  mEBmin[1] = diff;
268  if (diff > mEBmax[1])
269  mEBmax[1] = diff;
270  }
271  val = (*payload)[id.rawId()].mean_x1;
272  if (irun == 0) {
273  mEB[2][hashindex] = val;
274  } else {
275  float diff = val - mEB[2][hashindex];
276  barrel_m[2]->Fill(iphi, y, diff);
277  if (diff < mEBmin[2])
278  mEBmin[2] = diff;
279  if (diff > mEBmax[2])
280  mEBmax[2] = diff;
281  }
282  } // iphi
283  } // ieta
284 
285  for (int ix = 0; ix < IX_MAX; ix++) {
286  for (int iy = 0; iy < IY_MAX; iy++) {
287  if (!EEDetId::validDetId(ix + 1, iy + 1, thesign))
288  continue;
289  EEDetId id(ix + 1, iy + 1, thesign);
290  int hashindex = id.hashedIndex();
291  float val = (*payload)[id.rawId()].mean_x12;
292  if (irun == 0) {
293  mEE[0][hashindex] = val;
294  } else {
295  float diff = val - mEE[0][hashindex];
296  if (thesign == 1)
297  endc_p_m[0]->Fill(ix + 1, iy + 1, diff);
298  else
299  endc_m_m[0]->Fill(ix + 1, iy + 1, diff);
300  if (diff < mEEmin[0])
301  mEEmin[0] = diff;
302  if (diff > mEEmax[0])
303  mEEmax[0] = diff;
304  }
305  val = (*payload)[id.rawId()].mean_x6;
306  if (irun == 0) {
307  mEE[1][hashindex] = val;
308  } else {
309  float diff = val - mEE[1][hashindex];
310  if (thesign == 1)
311  endc_p_m[1]->Fill(ix + 1, iy + 1, diff);
312  else
313  endc_m_m[1]->Fill(ix + 1, iy + 1, diff);
314  if (diff < mEEmin[1])
315  mEEmin[1] = diff;
316  if (diff > mEEmax[1])
317  mEEmax[1] = diff;
318  }
319  val = (*payload)[id.rawId()].mean_x1;
320  if (irun == 0) {
321  mEE[2][hashindex] = val;
322  } else {
323  float diff = val - mEE[2][hashindex];
324  if (thesign == 1)
325  endc_p_m[2]->Fill(ix + 1, iy + 1, diff);
326  else
327  endc_m_m[2]->Fill(ix + 1, iy + 1, diff);
328  if (diff < mEEmin[2])
329  mEEmin[2] = diff;
330  if (diff > mEEmax[2])
331  mEEmax[2] = diff;
332  }
333  // fout << " x " << ix << " y " << " diff " << diff << std::endl;
334  } // iy
335  } // ix
336  } // side
337  } // if payload.get()
338  else
339  return false;
340  irun++;
341  } // loop over IOVs
342 
343  gStyle->SetPalette(1);
344  gStyle->SetOptStat(0);
345  TCanvas canvas("CC map", "CC map", 1200, 900);
346  TLatex t1;
347  t1.SetNDC();
348  t1.SetTextAlign(26);
349  t1.SetTextSize(0.05);
350  t1.DrawLatex(0.5, 0.96, Form("Ecal TPGPedestals, IOV %i - %i", run[1], run[0]));
351 
352  float xmi[3] = {0.0, 0.22, 0.78};
353  float xma[3] = {0.22, 0.78, 1.00};
354  TPad*** pad = new TPad**[kGains];
355  for (int gId = 0; gId < kGains; gId++) {
356  pad[gId] = new TPad*[3];
357  for (int obj = 0; obj < 3; obj++) {
358  float yma = 0.94 - (0.32 * gId);
359  float ymi = yma - 0.30;
360  pad[gId][obj] = new TPad(Form("p_%i_%i", obj, gId), Form("p_%i_%i", obj, gId), xmi[obj], ymi, xma[obj], yma);
361  pad[gId][obj]->Draw();
362  }
363  }
364 
365  for (int gId = 0; gId < kGains; gId++) {
366  pad[gId][0]->cd();
367  DrawEE(endc_m_m[gId], mEEmin[gId], mEEmax[gId]);
368  pad[gId][1]->cd();
369  DrawEB(barrel_m[gId], mEBmin[gId], mEBmax[gId]);
370  pad[gId][2]->cd();
371  DrawEE(endc_p_m[gId], mEEmin[gId], mEEmax[gId]);
372  }
373 
374  std::string ImageName(m_imageFileName);
375  canvas.SaveAs(ImageName.c_str());
376  return true;
377  } // fill method
378  };
379 
380 } // namespace
381 
382 // Register the classes as boost python plugin
384  PAYLOAD_INSPECTOR_CLASS(EcalTPGPedestalsPlot);
385  PAYLOAD_INSPECTOR_CLASS(EcalTPGPedestalsDiff);
386 }
change_name.diff
diff
Definition: change_name.py:13
svgfig.canvas
def canvas(*sub, **attr)
Definition: svgfig.py:482
DDAxes::y
ecalLiteDTU::gainId
constexpr int gainId(sample_type sample)
get the gainId (2 bits)
Definition: EcalLiteDTUSample.h:14
kEEChannels
Definition: EcalFloatCondObjectContainerUtils.h:9
MAX_IPHI
Definition: EcalFloatCondObjectContainerUtils.h:14
IX_MAX
Definition: EcalFloatCondObjectContainerUtils.h:20
IY_MAX
Definition: EcalFloatCondObjectContainerUtils.h:21
EBDetId
Definition: EBDetId.h:17
PayloadInspector.h
EBDetId.h
EEDetId.h
Validation_hcalonly_cfi.sign
sign
Definition: Validation_hcalonly_cfi.py:32
PAYLOAD_INSPECTOR_CLASS
#define PAYLOAD_INSPECTOR_CLASS(CLASS_NAME)
Definition: PayloadInspectorModule.h:10
EcalCondObjectContainer
Definition: EcalCondObjectContainer.h:13
PayloadInspectorModule.h
DrawEE
void DrawEE(TH2F *endc, float min, float max)
Definition: EcalDrawUtils.h:29
LEDCalibrationChannels.iphi
iphi
Definition: LEDCalibrationChannels.py:64
RandomServiceHelper.t1
t1
Definition: RandomServiceHelper.py:256
DrawEB
void DrawEB(TH2F *ebmap, float min, float max)
Definition: EcalDrawUtils.h:4
MIN_IETA
Definition: EcalFloatCondObjectContainerUtils.h:11
jets_cff.payload
payload
Definition: jets_cff.py:32
PAYLOAD_INSPECTOR_MODULE
#define PAYLOAD_INSPECTOR_MODULE(PAYLOAD_TYPENAME)
Definition: PayloadInspectorModule.h:8
getGTfromDQMFile.obj
obj
Definition: getGTfromDQMFile.py:32
EEDetId
Definition: EEDetId.h:14
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
cond
Definition: plugin.cc:23
LEDCalibrationChannels.ieta
ieta
Definition: LEDCalibrationChannels.py:63
Time.h
IY_MIN
Definition: EcalFloatCondObjectContainerUtils.h:19
cond::payloadInspector::PlotImage::fetchPayload
std::shared_ptr< PayloadType > fetchPayload(const cond::Hash &payloadHash)
Definition: PayloadInspector.h:863
MIN_IPHI
Definition: EcalFloatCondObjectContainerUtils.h:12
trackerHitRTTI::vector
Definition: trackerHitRTTI.h:21
EcalTPGPedestals.h
EcalDrawUtils.h
kSides
static const int kSides
Definition: EcalGeomPhiSymHelper.h:9
heppy_batch.val
val
Definition: heppy_batch.py:351
writedatasetfile.run
run
Definition: writedatasetfile.py:27
gainValues
const Int_t gainValues[kGains]
Definition: EcalPedestalsHandler.cc:15
kGains
const Int_t kGains
Definition: EcalPedestalsHandler.cc:13
triggerObjects_cff.id
id
Definition: triggerObjects_cff.py:31
cond::payloadInspector::PlotImpl::fill
virtual bool fill()=0
cond::payloadInspector::PlotImage
Definition: PayloadInspector.h:852
EEDetId::validDetId
static bool validDetId(int crystal_ix, int crystal_iy, int iz)
Definition: EEDetId.h:248
kEBChannels
Definition: EcalFloatCondObjectContainerUtils.h:9
IX_MIN
Definition: EcalFloatCondObjectContainerUtils.h:18
MAX_IETA
Definition: EcalFloatCondObjectContainerUtils.h:13