CMS 3D CMS Logo

EcalPedestals_PayloadInspector.cc
Go to the documentation of this file.
4 
5 // the data format of the condition to be inspected
10 
11 #include "TH2F.h"
12 #include "TCanvas.h"
13 #include "TStyle.h"
14 #include "TLine.h"
15 #include "TLatex.h"
16 
17 #include <memory>
18 #include <sstream>
19 
20 namespace {
21  enum {kEBChannels = 61200, kEEChannels = 14648, kGains = 3, kRMS = 5};
22  enum {MIN_IETA = 1, MIN_IPHI = 1, MAX_IETA = 85, MAX_IPHI = 360}; // barrel lower and upper bounds on eta and phi
23  enum {IX_MIN = 1, IY_MIN = 1, IX_MAX = 100, IY_MAX = 100}; // endcaps lower and upper bounds on x and y
24 
25  /*************************************************
26  1d plot of ECAL pedestal of 1 IOV
27  *************************************************/
28  class EcalPedestalsHist : public cond::payloadInspector::PlotImage<EcalPedestals> {
29 
30  public:
31  EcalPedestalsHist() : cond::payloadInspector::PlotImage<EcalPedestals>( "ECAL pedestal map") {
32  setSingleIov(true);
33  }
34  bool fill( const std::vector<std::tuple<cond::Time_t,cond::Hash> >& iovs ) override{
35  uint32_t gainValues[kGains] = {12, 6, 1};
36  TH1F** barrel_m = new TH1F*[kGains];
37  TH1F** endcap_m = new TH1F*[kGains];
38  TH1F** barrel_r = new TH1F*[kGains];
39  TH1F** endcap_r = new TH1F*[kGains];
40  float bmin[kGains] ={0.7, 0.5, 0.4};
41  float bmax[kGains] ={2.2, 1.3, 0.7};
42  float emin[kGains] ={1.5, 0.8, 0.4};
43  float emax[kGains] ={2.5, 1.5, 0.8};
44  for (int gainId = 0; gainId < kGains; gainId++) {
45  barrel_m[gainId] = new TH1F(Form("EBm%i", gainId), Form("mean %i EB", gainValues[gainId]), 100, 150., 250.);
46  endcap_m[gainId] = new TH1F(Form("EEm%i", gainId), Form("mean %i EE", gainValues[gainId]), 100, 150., 250.);
47  barrel_r[gainId] = new TH1F(Form("EBr%i", gainId), Form("rms %i EB", gainValues[gainId]), 100, bmin[gainId], bmax[gainId]);
48  endcap_r[gainId] = new TH1F(Form("EEr%i", gainId), Form("rms %i EE", gainValues[gainId]), 100, emin[gainId], emax[gainId]);
49  }
50  auto iov = iovs.front();
51  std::shared_ptr<EcalPedestals> payload = fetchPayload( std::get<1>(iov) );
52  unsigned int run = std::get<0>(iov);
53  if( payload.get() ){
54  // looping over the EB channels, via the dense-index, mapped into EBDetId's
55  if (payload->barrelItems().empty()) return false;
56  for(int cellid = EBDetId::MIN_HASH;
58  ++cellid) {
59  uint32_t rawid = EBDetId::unhashIndex(cellid);
60  if (payload->find(rawid) == payload->end()) continue;
61  barrel_m[0]->Fill((*payload)[rawid].mean_x12);
62  barrel_r[0]->Fill((*payload)[rawid].rms_x12);
63  barrel_m[1]->Fill((*payload)[rawid].mean_x6);
64  barrel_r[1]->Fill((*payload)[rawid].rms_x6);
65  barrel_m[2]->Fill((*payload)[rawid].mean_x1);
66  barrel_r[2]->Fill((*payload)[rawid].rms_x1);
67  } // loop over cellid
68  if (payload->endcapItems().empty()) return false;
69 
70  // looping over the EE channels
71  for(int iz = -1; iz < 2; iz = iz + 2) // -1 or +1
72  for(int iy = IY_MIN; iy < IY_MAX+IY_MIN; iy++)
73  for(int ix = IX_MIN; ix < IX_MAX+IX_MIN; ix++)
74  if(EEDetId::validDetId(ix, iy, iz)) {
75  EEDetId myEEId = EEDetId(ix, iy, iz, EEDetId::XYMODE);
76  uint32_t rawid = myEEId.rawId();
77  if (payload->find(rawid) == payload->end()) continue;
78  endcap_m[0]->Fill((*payload)[rawid].mean_x12);
79  endcap_r[0]->Fill((*payload)[rawid].rms_x12);
80  endcap_m[1]->Fill((*payload)[rawid].mean_x6);
81  endcap_r[1]->Fill((*payload)[rawid].rms_x6);
82  endcap_m[2]->Fill((*payload)[rawid].mean_x1);
83  endcap_r[2]->Fill((*payload)[rawid].rms_x1);
84  } // validDetId
85  } // if payload.get()
86  else return false;
87 
88  gStyle->SetPalette(1);
89  gStyle->SetOptStat(111110);
90  TCanvas canvas("CC map","CC map", 1600, 2600);
91  TLatex t1;
92  t1.SetNDC();
93  t1.SetTextAlign(26);
94  t1.SetTextSize(0.05);
95  t1.DrawLatex(0.5, 0.96, Form("Ecal Pedestals, IOV %i", run));
96 
97  float xmi[2] = {0.0 , 0.50};
98  float xma[2] = {0.50, 1.00};
99  TPad*** pad = new TPad**[6];
100  for (int gId = 0; gId < 6; gId++) {
101  pad[gId] = new TPad*[2];
102  for (int obj = 0; obj < 2; obj++) {
103  // float yma = 1.- (0.17 * gId);
104  // float ymi = yma - 0.15;
105  float yma = 0.94- (0.16 * gId);
106  float ymi = yma - 0.14;
107  pad[gId][obj] = new TPad(Form("p_%i_%i", obj, gId),Form("p_%i_%i", obj, gId),
108  xmi[obj], ymi, xma[obj], yma);
109  pad[gId][obj]->Draw();
110  }
111  }
112  for (int gId = 0; gId < kGains; gId++) {
113  pad[gId][0]->cd();
114  barrel_m[gId]->Draw();
115  pad[gId + kGains][0]->cd();
116  barrel_r[gId]->Draw();
117  pad[gId][1]->cd();
118  endcap_m[gId]->Draw();
119  pad[gId + kGains][1]->cd();
120  endcap_r[gId]->Draw();
121  }
122 
123  std::string ImageName(m_imageFileName);
124  canvas.SaveAs(ImageName.c_str());
125  return true;
126  } // fill method
127  }; // class EcalPedestalsHist
128 
129  /*************************************************
130  2d plot of ECAL pedestal of 1 IOV
131  *************************************************/
132 
133  class EcalPedestalsPlot : public cond::payloadInspector::PlotImage<EcalPedestals> {
134 
135  public:
136  EcalPedestalsPlot() : cond::payloadInspector::PlotImage<EcalPedestals>( "ECAL pedestal map") {
137  setSingleIov(true);
138  }
139  bool fill( const std::vector<std::tuple<cond::Time_t,cond::Hash> >& iovs ) override{
140  uint32_t gainValues[kGains] = {12, 6, 1};
141  TH2F** barrel_m = new TH2F*[kGains];
142  TH2F** endc_p_m = new TH2F*[kGains];
143  TH2F** endc_m_m = new TH2F*[kGains];
144  TH2F** barrel_r = new TH2F*[kGains];
145  TH2F** endc_p_r = new TH2F*[kGains];
146  TH2F** endc_m_r = new TH2F*[kGains];
147  double EBmean[kGains], EBrms[kGains], EEmean[kGains], EErms[kGains], pEBmin[kGains], pEBmax[kGains], pEEmin[kGains], pEEmax[kGains];
148  int EBtot[kGains], EEtot[kGains];
149  for (int gId = 0; gId < kGains; gId++) {
150  barrel_m[gId] = new TH2F(Form("EBm%i", gId),Form("mean %i EB", gainValues[gId]), MAX_IPHI, 0, MAX_IPHI, 2 * MAX_IETA, -MAX_IETA, MAX_IETA);
151  endc_p_m[gId] = new TH2F(Form("EE+m%i",gId),Form("mean %i EE+",gainValues[gId]), IX_MAX, IX_MIN, IX_MAX + 1, IY_MAX, IY_MIN, IY_MAX + 1);
152  endc_m_m[gId] = new TH2F(Form("EE-m%i",gId),Form("mean %i EE-",gainValues[gId]), IX_MAX, IX_MIN, IX_MAX + 1, IY_MAX, IY_MIN, IY_MAX + 1);
153  barrel_r[gId] = new TH2F(Form("EBr%i", gId),Form("rms %i EB", gainValues[gId]), MAX_IPHI, 0, MAX_IPHI, 2 * MAX_IETA, -MAX_IETA, MAX_IETA);
154  endc_p_r[gId] = new TH2F(Form("EE+r%i",gId),Form("rms %i EE+", gainValues[gId]), IX_MAX, IX_MIN, IX_MAX + 1, IY_MAX, IY_MIN, IY_MAX + 1);
155  endc_m_r[gId] = new TH2F(Form("EE-r%i",gId),Form("rms %i EE-", gainValues[gId]), IX_MAX, IX_MIN, IX_MAX + 1, IY_MAX, IY_MIN, IY_MAX + 1);
156  EBmean[gId] = 0.;
157  EBrms[gId] = 0.;
158  EEmean[gId] = 0.;
159  EErms[gId] = 0.;
160  EBtot[gId] = 0;
161  EEtot[gId] = 0;
162  }
163  auto iov = iovs.front();
164  std::shared_ptr<EcalPedestals> payload = fetchPayload( std::get<1>(iov) );
165  unsigned int run = std::get<0>(iov);
166  if( payload.get() ){
167  // looping over the EB channels, via the dense-index, mapped into EBDetId's
168  if (payload->barrelItems().empty()) return false;
169  for(int cellid = EBDetId::MIN_HASH; cellid < EBDetId::kSizeForDenseIndexing; ++cellid) { // loop on EE cells
170  uint32_t rawid = EBDetId::unhashIndex(cellid);
171  if (payload->find(rawid) == payload->end()) continue;
172  Double_t phi = (Double_t)(EBDetId(rawid)).iphi() - 0.5;
173  Double_t eta = (Double_t)(EBDetId(rawid)).ieta();
174  if(eta > 0.) eta = eta - 0.5; // 0.5 to 84.5
175  else eta = eta + 0.5; // -84.5 to -0.5
176  barrel_m[0]->Fill(phi, eta, (*payload)[rawid].mean_x12);
177  Double_t val =(*payload)[rawid].rms_x12;
178  barrel_r[0]->Fill(phi, eta, val);
179  if(val < 10) {
180  EBmean[0] = EBmean[0] + val;
181  EBrms[0] = EBrms[0] + val * val;
182  EBtot[0]++;
183  }
184  // else std::cout << " gain 12 chan " << cellid << " val " << val << std::endl;
185  barrel_m[1]->Fill(phi, eta, (*payload)[rawid].mean_x6);
186  val =(*payload)[rawid].rms_x6;
187  barrel_r[1]->Fill(phi, eta, val);
188  if(val < 10) {
189  EBmean[1] = EBmean[1] + val;
190  EBrms[1] = EBrms[1] + val * val;
191  EBtot[1]++;
192  }
193  // else std::cout << " gain 6 chan " << cellid << " val " << val << std::endl;
194  barrel_m[2]->Fill(phi, eta, (*payload)[rawid].mean_x1);
195  val =(*payload)[rawid].rms_x1;
196  barrel_r[2]->Fill(phi, eta, val);
197  if(val < 10) {
198  EBmean[2] = EBmean[2] + val;
199  EBrms[2] = EBrms[2] + val * val;
200  EBtot[2]++;
201  }
202  // else std::cout << " gain 1 chan " << cellid << " val " << val << std::endl;
203  } // loop over cellid
204  if (payload->endcapItems().empty()) return false;
205 
206  // looping over the EE channels
207  for(int iz = -1; iz < 2; iz = iz + 2) // -1 or +1
208  for(int iy = IY_MIN; iy < IY_MAX+IY_MIN; iy++)
209  for(int ix = IX_MIN; ix < IX_MAX+IX_MIN; ix++)
210  if(EEDetId::validDetId(ix, iy, iz)) {
211  EEDetId myEEId = EEDetId(ix, iy, iz, EEDetId::XYMODE);
212  uint32_t rawid = myEEId.rawId();
213  if (payload->find(rawid) == payload->end()) continue;
214  if (iz == 1) {
215  endc_p_m[0]->Fill(ix, iy, (*payload)[rawid].mean_x12);
216  Double_t val = (*payload)[rawid].rms_x12;
217  endc_p_r[0]->Fill(ix, iy, val);
218  if(val < 10) {
219  EEmean[0] = EEmean[0] + val;
220  EErms[0] = EErms[0] + val * val;
221  EEtot[0]++;
222  }
223  endc_p_m[1]->Fill(ix, iy, (*payload)[rawid].mean_x6);
224  val = (*payload)[rawid].rms_x6;
225  endc_p_r[1]->Fill(ix, iy, val);
226  if(val < 10) {
227  EEmean[1] = EEmean[1] + val;
228  EErms[1] = EErms[1] + val * val;
229  EEtot[1]++;
230  }
231  endc_p_m[2]->Fill(ix, iy, (*payload)[rawid].mean_x1);
232  val = (*payload)[rawid].rms_x1;
233  endc_p_r[2]->Fill(ix, iy, val);
234  if(val < 10) {
235  EEmean[2] = EEmean[2] + val;
236  EErms[2] = EErms[2] + val * val;
237  EEtot[2]++;
238  }
239  }
240  else {
241  endc_m_m[0]->Fill(ix, iy, (*payload)[rawid].mean_x12);
242  Double_t val = (*payload)[rawid].rms_x12;
243  endc_m_r[0]->Fill(ix, iy, val);
244  if(val < 10) {
245  EEmean[0] = EEmean[0] + val;
246  EErms[0] = EErms[0] + val * val;
247  EEtot[0]++;
248  }
249  endc_m_m[1]->Fill(ix, iy, (*payload)[rawid].mean_x6);
250  val = (*payload)[rawid].rms_x6;
251  endc_m_r[1]->Fill(ix, iy, val);
252  if(val < 10) {
253  EEmean[1] = EEmean[1] + val;
254  EErms[1] = EErms[1] + val * val;
255  EEtot[1]++;
256  }
257  endc_m_m[2]->Fill(ix, iy, (*payload)[rawid].mean_x1);
258  val = (*payload)[rawid].rms_x1;
259  endc_m_r[2]->Fill(ix, iy, val);
260  if(val < 10) {
261  EEmean[2] = EEmean[2] + val;
262  EErms[2] = EErms[2] + val * val;
263  EEtot[2]++;
264  }
265  }
266  } // validDetId
267  } // if payload.get()
268  else return false;
269 
270  gStyle->SetPalette(1);
271  gStyle->SetOptStat(0);
272  TCanvas canvas("CC map","CC map", 1600, 2600);
273  TLatex t1;
274  t1.SetNDC();
275  t1.SetTextAlign(26);
276  t1.SetTextSize(0.05);
277  t1.DrawLatex(0.5, 0.96, Form("Ecal Pedestals, IOV %i", run));
278 
279  float xmi[3] = {0.0 , 0.24, 0.76};
280  float xma[3] = {0.24, 0.76, 1.00};
281  TPad*** pad = new TPad**[6];
282  int view = 0;
283  for (int gId = 0; gId < kGains; gId++) {
284  for (int val = 0; val < 2; val++) { // mean and sigma
285  pad[view] = new TPad*[3];
286  for (int obj = 0; obj < 3; obj++) {
287  float yma = 0.94- (0.16 * view);
288  float ymi = yma - 0.14;
289  pad[view][obj] = new TPad(Form("p_%i_%i", obj, view),Form("p_%i_%i", obj, view),
290  xmi[obj], ymi, xma[obj], yma);
291  pad[view][obj]->Draw();
292  }
293  view++;
294  }
295  double vt =(double)EBtot[gId];
296  EBmean[gId] = EBmean[gId] / vt;
297  EBrms[gId] = (EBrms[gId] / vt) - (EBmean[gId] * EBmean[gId]);
298  EBrms[gId] = sqrt(EBrms[gId]);
299  if(EBrms[gId] == 0.) EBrms[gId] = 0.001;
300  pEBmin[gId] = EBmean[gId] - kRMS * EBrms[gId];
301  pEBmax[gId] = EBmean[gId] + kRMS * EBrms[gId];
302  // std::cout << " mean " << EBmean[gId] << " rms " << EBrms[gId] << " entries " << EBtot[gId] << " min " << pEBmin[gId]
303  // << " max " << pEBmax[gId] << std::endl;
304  if(pEBmin[gId] < 0.) pEBmin[gId] = 0.;
305  vt =(double)EEtot[gId];
306  EEmean[gId] = EEmean[gId] / vt;
307  EErms[gId] = (EErms[gId] / vt) -(EEmean[gId] * EEmean[gId]);
308  EErms[gId] = sqrt(EErms[gId]);
309  if(EErms[gId] == 0.) EErms[gId] = 0.001;
310  pEEmin[gId] = EEmean[gId] - kRMS * EErms[gId];
311  pEEmax[gId] = EEmean[gId] + kRMS * EErms[gId];
312  // std::cout << " mean " << EEmean[gId] << " rms " << EErms[gId] << " entries " << EEtot[gId] << " min " << pEEmin[gId]
313  // << " max " << pEEmax[gId] << std::endl;
314  if(pEEmin[gId] < 0.) pEEmin[gId] = 0.;
315  }
316  //float bmin[kGains] ={0.7, 0.5, 0.4};
317  //float bmax[kGains] ={2.2, 1.3, 0.7};
318  //float emin[kGains] ={1.5, 0.8, 0.4};
319  //float emax[kGains] ={2.5, 1.5, 0.8};
320  // TLine* l = new TLine(0., 0., 0., 0.);
321  // l->SetLineWidth(1);
322  for (int gId = 0; gId < kGains; gId++) {
323  pad[gId][0]->cd();
324  DrawEE(endc_m_m[gId], 175., 225.);
325  pad[gId + kGains][0]->cd();
326  DrawEE(endc_m_r[gId], pEEmin[gId], pEEmax[gId]);
327  pad[gId][1]->cd();
328  DrawEB(barrel_m[gId], 175., 225.);
329  pad[gId + kGains][1]->cd();
330  DrawEB(barrel_r[gId], pEBmin[gId], pEBmax[gId]);
331  pad[gId][2]->cd();
332  DrawEE(endc_p_m[gId], 175., 225.);
333  pad[gId + kGains][2]->cd();
334  DrawEE(endc_p_r[gId], pEEmin[gId], pEEmax[gId]);
335  }
336 
337  std::string ImageName(m_imageFileName);
338  canvas.SaveAs(ImageName.c_str());
339  return true;
340  }// fill method
341 
342  }; // class EcalPedestalsPlot
343 
344  /************************************************************
345  2d plot of ECAL pedestals difference between 2 IOVs
346  *************************************************************/
347  class EcalPedestalsDiff : public cond::payloadInspector::PlotImage<EcalPedestals> {
348 
349  public:
350  EcalPedestalsDiff() : cond::payloadInspector::PlotImage<EcalPedestals>("ECAL Barrel channel status difference") {
351  setSingleIov(false);
352  }
353  bool fill( const std::vector<std::tuple<cond::Time_t,cond::Hash> >& iovs ) override{
354  uint32_t gainValues[kGains] = {12, 6, 1};
355  TH2F** barrel_m = new TH2F*[kGains];
356  TH2F** endc_p_m = new TH2F*[kGains];
357  TH2F** endc_m_m = new TH2F*[kGains];
358  TH2F** barrel_r = new TH2F*[kGains];
359  TH2F** endc_p_r = new TH2F*[kGains];
360  TH2F** endc_m_r = new TH2F*[kGains];
361  double EBmean[kGains], EBrms[kGains], EEmean[kGains], EErms[kGains], pEBmin[kGains], pEBmax[kGains], pEEmin[kGains], pEEmax[kGains];
362  int EBtot[kGains], EEtot[kGains];
363  for (int gId = 0; gId < kGains; gId++) {
364  barrel_m[gId] = new TH2F(Form("EBm%i", gId),Form("mean %i EB", gainValues[gId]), MAX_IPHI, 0, MAX_IPHI, 2 * MAX_IETA, -MAX_IETA, MAX_IETA);
365  endc_p_m[gId] = new TH2F(Form("EE+m%i",gId),Form("mean %i EE+",gainValues[gId]), IX_MAX, IX_MIN, IX_MAX + 1, IY_MAX, IY_MIN, IY_MAX + 1);
366  endc_m_m[gId] = new TH2F(Form("EE-m%i",gId),Form("mean %i EE-",gainValues[gId]), IX_MAX, IX_MIN, IX_MAX + 1, IY_MAX, IY_MIN, IY_MAX + 1);
367  barrel_r[gId] = new TH2F(Form("EBr%i", gId),Form("rms %i EB", gainValues[gId]), MAX_IPHI, 0, MAX_IPHI, 2 * MAX_IETA, -MAX_IETA, MAX_IETA);
368  endc_p_r[gId] = new TH2F(Form("EE+r%i",gId),Form("rms %i EE+", gainValues[gId]), IX_MAX, IX_MIN, IX_MAX + 1, IY_MAX, IY_MIN, IY_MAX + 1);
369  endc_m_r[gId] = new TH2F(Form("EE-r%i",gId),Form("rms %i EE-", gainValues[gId]), IX_MAX, IX_MIN, IX_MAX + 1, IY_MAX, IY_MIN, IY_MAX + 1);
370  EBmean[gId] = 0.;
371  EBrms[gId] = 0.;
372  EEmean[gId] = 0.;
373  EErms[gId] = 0.;
374  EBtot[gId] = 0;
375  EEtot[gId] = 0;
376  }
377  unsigned int run[2], irun = 0;
378  // unsigned int irun = 0;
379  double meanEB[kGains][kEBChannels], rmsEB[kGains][kEBChannels], meanEE[kGains][kEEChannels], rmsEE[kGains][kEEChannels];
380  for ( auto const & iov: iovs) {
381  std::shared_ptr<EcalPedestals> payload = fetchPayload( std::get<1>(iov) );
382  run[irun] = std::get<0>(iov);
383  // std::cout << "run " << irun << " : " << run[irun] << std::endl;
384  if( payload.get() ){
385  if (payload->barrelItems().empty()) return false;
386  for(int cellid = EBDetId::MIN_HASH;
388  ++cellid) {
389  uint32_t rawid = EBDetId::unhashIndex(cellid);
390  if (payload->find(rawid) == payload->end()) continue;
391 
392  if(irun == 0) {
393  meanEB[0][cellid] = (*payload)[rawid].mean_x12;
394  rmsEB[0][cellid] = (*payload)[rawid].rms_x12;
395  meanEB[1][cellid] = (*payload)[rawid].mean_x6;
396  rmsEB[1][cellid] = (*payload)[rawid].rms_x6;
397  meanEB[2][cellid] = (*payload)[rawid].mean_x1;
398  rmsEB[2][cellid] = (*payload)[rawid].rms_x1;
399  }
400  else {
401  Double_t phi = (Double_t)(EBDetId(rawid)).iphi() - 0.5;
402  Double_t eta = (Double_t)(EBDetId(rawid)).ieta();
403  if(eta > 0.) eta = eta - 0.5; // 0.5 to 84.5
404  else eta = eta + 0.5; // -84.5 to -0.5
405  barrel_m[0]->Fill(phi, eta, (*payload)[rawid].mean_x12 - meanEB[0][cellid]);
406  double diff = (*payload)[rawid].rms_x12 - rmsEB[0][cellid];
407  barrel_r[0]->Fill(phi, eta, diff);
408  if(std::abs(diff) < 1.) {
409  EBmean[0] = EBmean[0] + diff;
410  EBrms[0] = EBrms[0] + diff * diff;
411  EBtot[0]++;
412  }
413  // else std::cout << " gain 12 chan " << cellid << " diff " << diff << std::endl;
414  barrel_m[1]->Fill(phi, eta,(*payload)[rawid].mean_x6 - meanEB[1][cellid]);
415  diff = (*payload)[rawid].rms_x6 - rmsEB[1][cellid];
416  barrel_r[1]->Fill(phi, eta, diff);
417  if(std::abs(diff) < 1.) {
418  EBmean[1] = EBmean[1] + diff;
419  EBrms[1] = EBrms[1] + diff * diff;
420  EBtot[1]++;
421  }
422  // else std::cout << " gain 6 chan " << cellid << " diff " << diff << std::endl;
423  barrel_m[2]->Fill(phi, eta, (*payload)[rawid].mean_x1 - meanEB[2][cellid]);
424  diff = (*payload)[rawid].rms_x1 - rmsEB[2][cellid];
425  barrel_r[2]->Fill(phi, eta, diff);
426  if(std::abs(diff) < 1.) {
427  EBmean[2] = EBmean[2] + diff;
428  EBrms[2] = EBrms[2] + diff * diff;
429  EBtot[2]++;
430  }
431  // else std::cout << " gain 1 chan " << cellid << " diff " << diff << std::endl;
432  }
433  } // loop over cellid
434 
435  if (payload->endcapItems().empty()) return false;
436  // looping over the EE channels
437  for(int iz = -1; iz < 2; iz = iz + 2) { // -1 or +1
438  for(int iy = IY_MIN; iy < IY_MAX+IY_MIN; iy++) {
439  for(int ix = IX_MIN; ix < IX_MAX+IX_MIN; ix++) {
440  if(EEDetId::validDetId(ix, iy, iz)) {
441  EEDetId myEEId = EEDetId(ix, iy, iz, EEDetId::XYMODE);
442  uint32_t rawid = myEEId.rawId();
443  uint32_t index = myEEId.hashedIndex();
444  if (payload->find(rawid) == payload->end()) continue;
445  if(irun == 0) {
446  meanEE[0][index] = (*payload)[rawid].mean_x12;
447  rmsEE[0][index] = (*payload)[rawid].rms_x12;
448  meanEE[1][index] = (*payload)[rawid].mean_x6;
449  rmsEE[1][index] = (*payload)[rawid].rms_x6;
450  meanEE[2][index] = (*payload)[rawid].mean_x1;
451  rmsEE[2][index] = (*payload)[rawid].rms_x1;
452  } // fist run
453  else {
454  if (iz == 1) {
455  endc_p_m[0]->Fill(ix, iy, (*payload)[rawid].mean_x12 - meanEE[0][index]);
456  double diff = (*payload)[rawid].rms_x12 - rmsEE[0][index];
457  endc_p_r[0]->Fill(ix, iy, rmsEE[0][index] - (*payload)[rawid].rms_x12);
458  if(std::abs(diff) < 1.) {
459  EEmean[0] = EEmean[0] + diff;
460  EErms[0] = EErms[0] + diff * diff;
461  EEtot[0]++;
462  }
463  //else std::cout << " gain 12 chan " << index << " diff " << diff << std::endl;
464  endc_p_m[1]->Fill(ix, iy, (*payload)[rawid].mean_x6 - meanEE[1][index]);
465  diff = (*payload)[rawid].rms_x6 - rmsEE[1][index];
466  endc_p_r[1]->Fill(ix, iy, diff);
467  if(std::abs(diff) < 1.) {
468  EEmean[1] = EEmean[1] + diff;
469  EErms[1] = EErms[1] + diff * diff;
470  EEtot[1]++;
471  }
472  //else std::cout << " gain 6 chan " << index << " diff " << diff << std::endl;
473  endc_p_m[2]->Fill(ix, iy, (*payload)[rawid].mean_x1 - meanEE[2][index]);
474  diff = (*payload)[rawid].rms_x1 - rmsEE[2][index];
475  endc_p_r[2]->Fill(ix, iy, diff);
476  if(std::abs(diff) < 1.) {
477  EEmean[2] = EEmean[2] + diff;
478  EErms[2] = EErms[2] + diff * diff;
479  EEtot[2]++;
480  }
481  //else std::cout << " gain 1 chan " << index << " diff " << diff << std::endl;
482  }// EE+
483  else {
484  endc_m_m[0]->Fill(ix, iy, (*payload)[rawid].mean_x12 - meanEE[0][index]);
485  double diff = (*payload)[rawid].rms_x12 - rmsEE[0][index];
486  endc_m_r[0]->Fill(ix, iy, rmsEE[0][index] - (*payload)[rawid].rms_x12);
487  if(std::abs(diff) < 1.) {
488  EEmean[0] = EEmean[0] + diff;
489  EErms[0] = EErms[0] + diff * diff;
490  EEtot[0]++;
491  }
492  //else std::cout << " gain 12 chan " << index << " diff " << diff << std::endl;
493  endc_m_m[1]->Fill(ix, iy, (*payload)[rawid].mean_x6 - meanEE[1][index]);
494  diff = (*payload)[rawid].rms_x6 - rmsEE[1][index];
495  endc_m_r[1]->Fill(ix, iy, diff);
496  if(std::abs(diff) < 1.) {
497  EEmean[1] = EEmean[1] + diff;
498  EErms[1] = EErms[1] + diff * diff;
499  EEtot[1]++;
500  }
501  //else std::cout << " gain 6 chan " << index << " diff " << diff << std::endl;
502  endc_m_m[2]->Fill(ix, iy, (*payload)[rawid].mean_x1 - meanEE[2][index]);
503  diff = (*payload)[rawid].rms_x1 - rmsEE[2][index];
504  endc_m_r[2]->Fill(ix, iy, diff);
505  if(std::abs(diff) < 1.) {
506  EEmean[2] = EEmean[2] + diff;
507  EErms[2] = EErms[2] + diff * diff;
508  EEtot[2]++;
509  }
510  //else std::cout << " gain 1 chan " << index << " diff " << diff << std::endl;
511  }// EE-
512  } // second run
513  } // validDetId
514  } // loop over ix
515  } // loop over iy
516  } // loop over iz
517  } // if payload.get()
518  else return false;
519  irun++;
520  } // loop over IOVs
521 
522  gStyle->SetPalette(1);
523  gStyle->SetOptStat(0);
524  TCanvas canvas("CC map","CC map", 1600, 2600);
525  TLatex t1;
526  t1.SetNDC();
527  t1.SetTextAlign(26);
528  t1.SetTextSize(0.05);
529  t1.DrawLatex(0.5, 0.96, Form("Ecal Pedestals, IOV %i - %i", run[1], run[0]));
530 
531  float xmi[3] = {0.0 , 0.24, 0.76};
532  float xma[3] = {0.24, 0.76, 1.00};
533  TPad*** pad = new TPad**[6];
534  int view = 0;
535  for (int gId = 0; gId < kGains; gId++) {
536  for (int val = 0; val < 2; val++) { // mean and sigma
537  pad[view] = new TPad*[3];
538  for (int obj = 0; obj < 3; obj++) {
539  float yma = 0.94- (0.16 * view);
540  float ymi = yma - 0.14;
541  pad[view][obj] = new TPad(Form("p_%i_%i", obj, view),Form("p_%i_%i", obj, view),
542  xmi[obj], ymi, xma[obj], yma);
543  pad[view][obj]->Draw();
544  }
545  view++;
546  }
547  double vt =(double)EBtot[gId];
548  EBmean[gId] = EBmean[gId] / vt;
549  EBrms[gId] = (EBrms[gId] / vt) - (EBmean[gId] * EBmean[gId]);
550  EBrms[gId] = sqrt(EBrms[gId]);
551  if(EBrms[gId] == 0.) EBrms[gId] = 0.001;
552  pEBmin[gId] = EBmean[gId] - kRMS * EBrms[gId];
553  pEBmax[gId] = EBmean[gId] + kRMS * EBrms[gId];
554  // std::cout << " mean " << EBmean[gId] << " rms " << EBrms[gId] << " entries " << EBtot[gId] << " min " << pEBmin[gId]
555  // << " max " << pEBmax[gId] << std::endl;
556  vt =(double)EEtot[gId];
557  EEmean[gId] = EEmean[gId] / vt;
558  EErms[gId] = (EErms[gId] / vt) -(EEmean[gId] * EEmean[gId]);
559  EErms[gId] = sqrt(EErms[gId]);
560  if(EErms[gId] == 0.) EErms[gId] = 0.001;
561  pEEmin[gId] = EEmean[gId] - kRMS * EErms[gId];
562  pEEmax[gId] = EEmean[gId] + kRMS * EErms[gId];
563  // std::cout << " mean " << EEmean[gId] << " rms " << EErms[gId] << " entries " << EEtot[gId] << " min " << pEEmin[gId]
564  // << " max " << pEEmax[gId] << std::endl;
565  }
566  for (int gId = 0; gId < kGains; gId++) {
567  pad[gId][0]->cd();
568  DrawEE(endc_m_m[gId], -2., 2.);
569  pad[gId + kGains][0]->cd();
570  DrawEE(endc_m_r[gId], pEEmin[gId], pEEmax[gId]);
571  pad[gId][1]->cd();
572  DrawEB(barrel_m[gId], -2., 2.);
573  pad[gId + kGains][1]->cd();
574  DrawEB(barrel_r[gId], pEBmin[gId], pEBmax[gId]);
575  pad[gId][2]->cd();
576  DrawEE(endc_p_m[gId], -2., 2.);
577  pad[gId + kGains][2]->cd();
578  DrawEE(endc_p_r[gId], pEEmin[gId], pEEmax[gId]);
579  }
580 
581  std::string ImageName(m_imageFileName);
582  canvas.SaveAs(ImageName.c_str());
583  return true;
584  }// fill method
585  }; // class EcalPedestalsDiff
586 
587 
588  /*************************************************
589  2d histogram of ECAL barrel pedestal of 1 IOV
590  *************************************************/
591 
592  // inherit from one of the predefined plot class: Histogram2D
593  class EcalPedestalsEBMean12Map : public cond::payloadInspector::Histogram2D<EcalPedestals> {
594 
595  public:
596  EcalPedestalsEBMean12Map() : cond::payloadInspector::Histogram2D<EcalPedestals>( "ECAL Barrel pedestal gain12 - map",
597  "iphi", MAX_IPHI, MIN_IPHI, MAX_IPHI+MIN_IPHI, "ieta", 2*MAX_IETA+1, -1*MAX_IETA, MAX_IETA+1) {
598  Base::setSingleIov( true );
599  }
600 
601  // Histogram2D::fill (virtual) needs be overridden - the implementation should use fillWithValue
602  bool fill( const std::vector<std::tuple<cond::Time_t,cond::Hash> >& iovs ) override{
603 
604  for( auto const & iov : iovs ) {
605  std::shared_ptr<EcalPedestals> payload = Base::fetchPayload( std::get<1>(iov) );
606  if( payload.get() ){
607  // looping over the EB channels, via the dense-index, mapped into EBDetId's
608  if (payload->barrelItems().empty()) return false;
609  for(int cellid = EBDetId::MIN_HASH;
611  ++cellid) {
612  uint32_t rawid = EBDetId::unhashIndex(cellid);
613 
614  // check the existence of ECAL pedestal, for a given ECAL barrel channel
615  if (payload->find(rawid) == payload->end()) continue;
616  if (!(*payload)[rawid].mean_x12 && !(*payload)[rawid].rms_x12) continue;
617 
618  // there's no ieta==0 in the EB numbering
619  // int delta = (EBDetId(rawid)).ieta() > 0 ? -1 : 0 ;
620  // fill the Histogram2D here
621  // fillWithValue( (EBDetId(rawid)).iphi() , (EBDetId(rawid)).ieta()+0.5+delta, (*payload)[rawid].mean_x12 );
622  // set min and max on 2d plots
623  float valped = (*payload)[rawid].mean_x12;
624  if(valped > 250.) valped = 250.;
625  // if(valped < 150.) valped = 150.;
626  fillWithValue( (EBDetId(rawid)).iphi(), (EBDetId(rawid)).ieta(), valped);
627  }// loop over cellid
628  }// if payload.get()
629  }// loop over IOV's (1 in this case)
630  return true;
631  }// fill method
632  };
633 
634  class EcalPedestalsEBMean6Map : public cond::payloadInspector::Histogram2D<EcalPedestals> {
635 
636  public:
637  EcalPedestalsEBMean6Map() : cond::payloadInspector::Histogram2D<EcalPedestals>( "ECAL Barrel pedestal gain6 - map",
638  "iphi", MAX_IPHI, MIN_IPHI, MAX_IPHI+MIN_IPHI, "ieta", 2*MAX_IETA+1, -MAX_IETA, MAX_IETA+1){
639  Base::setSingleIov( true );
640  }
641 
642  bool fill( const std::vector<std::tuple<cond::Time_t,cond::Hash> >& iovs ) override{
643  for( auto const & iov : iovs ) {
644  std::shared_ptr<EcalPedestals> payload = Base::fetchPayload( std::get<1>(iov) );
645  if( payload.get() ){
646  // looping over the EB channels, via the dense-index, mapped into EBDetId's
647  if (payload->barrelItems().empty()) return false;
648  for(int cellid = EBDetId::MIN_HASH;
650  ++cellid) {
651  uint32_t rawid = EBDetId::unhashIndex(cellid);
652 
653  // check the existence of ECAL pedestal, for a given ECAL barrel channel
654  if (payload->find(rawid) == payload->end()) continue;
655  if (!(*payload)[rawid].mean_x6 && !(*payload)[rawid].rms_x6) continue;
656 
657  // set min and max on 2d plots
658  float valped = (*payload)[rawid].mean_x6;
659  if(valped > 250.) valped = 250.;
660  // if(valped < 150.) valped = 150.;
661  fillWithValue( (EBDetId(rawid)).iphi(), (EBDetId(rawid)).ieta(), valped);
662  } // loop over cellid
663  } // if payload.get()
664  } // loop over IOV's (1 in this case)
665  return true;
666  } // fill method
667  };
668 
669  class EcalPedestalsEBMean1Map : public cond::payloadInspector::Histogram2D<EcalPedestals> {
670 
671  public:
672  EcalPedestalsEBMean1Map() : cond::payloadInspector::Histogram2D<EcalPedestals>( "ECAL Barrel pedestal gain1 - map",
673  "iphi", MAX_IPHI, MIN_IPHI, MAX_IPHI+MIN_IPHI, "ieta", 2*MAX_IETA+1, -MAX_IETA, MAX_IETA+1) {
674  Base::setSingleIov( true );
675  }
676 
677  bool fill( const std::vector<std::tuple<cond::Time_t,cond::Hash> >& iovs ) override{
678  for( auto const & iov : iovs ) {
679  std::shared_ptr<EcalPedestals> payload = Base::fetchPayload( std::get<1>(iov) );
680  if( payload.get() ){
681  // looping over the EB channels, via the dense-index, mapped into EBDetId's
682  if (payload->barrelItems().empty()) return false;
683  for(int cellid = EBDetId::MIN_HASH;
685  ++cellid) {
686  uint32_t rawid = EBDetId::unhashIndex(cellid);
687 
688  // check the existence of ECAL pedestal, for a given ECAL barrel channel
689  if (payload->find(rawid) == payload->end()) continue;
690  if (!(*payload)[rawid].mean_x1 && !(*payload)[rawid].rms_x1) continue;
691 
692  // set min and max on 2d plots
693  float valped = (*payload)[rawid].mean_x1;
694  if(valped > 250.) valped = 250.;
695  // if(valped < 150.) valped = 150.;
696  fillWithValue( (EBDetId(rawid)).iphi(), (EBDetId(rawid)).ieta(), valped);
697  } // loop over cellid
698  } // if payload.get()
699  } // loop over IOV's (1 in this case)
700  return true;
701  } // fill method
702  };
703 
704  class EcalPedestalsEEMean12Map : public cond::payloadInspector::Histogram2D<EcalPedestals> {
705 
706  public:
707  EcalPedestalsEEMean12Map() : cond::payloadInspector::Histogram2D<EcalPedestals>( "ECAL Endcap pedestal gain12 - map",
708  "ix", 2.2*IX_MAX, IX_MIN, 2.2*IX_MAX+1, "iy", IY_MAX, IY_MIN, IY_MAX+IY_MIN) {
709  Base::setSingleIov( true );
710  }
711 
712  // Histogram2D::fill (virtual) needs be overridden - the implementation should use fillWithValue
713  bool fill( const std::vector<std::tuple<cond::Time_t,cond::Hash> >& iovs ) override{
714 
715  for( auto const & iov : iovs ) {
716  std::shared_ptr<EcalPedestals> payload = Base::fetchPayload( std::get<1>(iov) );
717  if( payload.get() ){
718  if (payload->endcapItems().empty()) return false;
719 
720  // looping over the EE channels
721  for(int iz = -1; iz < 2; iz = iz + 2) // -1 or +1
722  for(int iy = IY_MIN; iy < IY_MAX+IY_MIN; iy++)
723  for(int ix = IX_MIN; ix < IX_MAX+IX_MIN; ix++)
724  if(EEDetId::validDetId(ix, iy, iz)) {
725  EEDetId myEEId = EEDetId(ix, iy, iz, EEDetId::XYMODE);
726  uint32_t rawid = myEEId.rawId();
727  // check the existence of ECAL pedestal, for a given ECAL endcap channel
728  if (payload->find(rawid) == payload->end()) continue;
729  if (!(*payload)[rawid].mean_x12 && !(*payload)[rawid].rms_x12) continue;
730  // set min and max on 2d plots
731  float valped = (*payload)[rawid].mean_x12;
732  if(valped > 250.) valped = 250.;
733  // if(valped < 150.) valped = 150.;
734  if(iz == -1)
735  fillWithValue(ix, iy, valped);
736  else
737  fillWithValue(ix + IX_MAX + 20, iy, valped);
738 
739  } // validDetId
740  } // payload
741  }// loop over IOV's (1 in this case)
742  return true;
743  }// fill method
744  };
745 
746  class EcalPedestalsEEMean6Map : public cond::payloadInspector::Histogram2D<EcalPedestals> {
747 
748  public:
749  EcalPedestalsEEMean6Map() : cond::payloadInspector::Histogram2D<EcalPedestals>( "ECAL Endcap pedestal gain6 - map",
750 "ix", 2.2*IX_MAX, IX_MIN, 2.2*IX_MAX+1, "iy", IY_MAX, IY_MIN, IY_MAX+IY_MIN) {
751  Base::setSingleIov( true );
752  }
753 
754  bool fill( const std::vector<std::tuple<cond::Time_t,cond::Hash> >& iovs ) override{
755  for( auto const & iov : iovs ) {
756  std::shared_ptr<EcalPedestals> payload = Base::fetchPayload( std::get<1>(iov) );
757  if( payload.get() ){
758  if (payload->endcapItems().empty()) return false;
759 
760 
761  // looping over the EE channels
762  for(int iz = -1; iz < 2; iz = iz + 2) // -1 or +1
763  for(int iy = IY_MIN; iy < IY_MAX+IY_MIN; iy++)
764  for(int ix = IX_MIN; ix < IX_MAX+IX_MIN; ix++)
765  if(EEDetId::validDetId(ix, iy, iz)) {
766  EEDetId myEEId = EEDetId(ix, iy, iz, EEDetId::XYMODE);
767  uint32_t rawid = myEEId.rawId();
768  // check the existence of ECAL pedestal, for a given ECAL endcap channel
769  if (payload->find(rawid) == payload->end()) continue;
770  if (!(*payload)[rawid].mean_x6 && !(*payload)[rawid].rms_x6) continue;
771  // set min and max on 2d plots
772  float valped = (*payload)[rawid].mean_x6;
773  if(valped > 250.) valped = 250.;
774  // if(valped < 150.) valped = 150.;
775  if(iz == -1)
776  fillWithValue(ix, iy, valped);
777  else
778  fillWithValue(ix + IX_MAX + 20, iy, valped);
779  } // validDetId
780  } // payload
781  } // loop over IOV's (1 in this case)
782  return true;
783  } // fill method
784  };
785 
786  class EcalPedestalsEEMean1Map : public cond::payloadInspector::Histogram2D<EcalPedestals> {
787 
788  public:
789  EcalPedestalsEEMean1Map() : cond::payloadInspector::Histogram2D<EcalPedestals>( "ECAL Endcap pedestal gain1 - map",
790  "ix", 2.2*IX_MAX, IX_MIN, 2.2*IX_MAX+1, "iy", IY_MAX, IY_MIN, IY_MAX+IY_MIN) {
791  Base::setSingleIov( true );
792  }
793 
794  bool fill( const std::vector<std::tuple<cond::Time_t,cond::Hash> >& iovs ) override{
795  for( auto const & iov : iovs ) {
796  std::shared_ptr<EcalPedestals> payload = Base::fetchPayload( std::get<1>(iov) );
797  if( payload.get() ){
798  if (payload->endcapItems().empty()) return false;
799 
800  // looping over the EE channels
801  for(int iz = -1; iz < 2; iz = iz + 2) // -1 or +1
802  for(int iy = IY_MIN; iy < IY_MAX+IY_MIN; iy++)
803  for(int ix = IX_MIN; ix < IX_MAX+IX_MIN; ix++)
804  if(EEDetId::validDetId(ix, iy, iz)) {
805  EEDetId myEEId = EEDetId(ix, iy, iz, EEDetId::XYMODE);
806  uint32_t rawid = myEEId.rawId();
807  // check the existence of ECAL pedestal, for a given ECAL endcap channel
808  if (payload->find(rawid) == payload->end()) continue;
809  if (!(*payload)[rawid].mean_x1 && !(*payload)[rawid].rms_x12) continue;
810  // set min and max on 2d plots
811  float valped = (*payload)[rawid].mean_x1;
812  if(valped > 250.) valped = 250.;
813  // if(valped < 150.) valped = 150.;
814  if(iz == -1)
815  fillWithValue(ix, iy, valped);
816  else
817  fillWithValue(ix + IX_MAX + 20, iy, valped);
818  } // validDetId
819  } // if payload.get()
820  } // loop over IOV's (1 in this case)
821  return true;
822  } // fill method
823  };
824 
825  class EcalPedestalsEBRMS12Map : public cond::payloadInspector::Histogram2D<EcalPedestals> {
826 
827  public:
828  EcalPedestalsEBRMS12Map() : cond::payloadInspector::Histogram2D<EcalPedestals>( "ECAL Barrel noise gain12 - map",
829  "iphi", MAX_IPHI, MIN_IPHI, MAX_IPHI+MIN_IPHI, "ieta", 2*MAX_IETA+1, -1*MAX_IETA, MAX_IETA+1) { Base::setSingleIov( true );
830  }
831 
832  // Histogram2D::fill (virtual) needs be overridden - the implementation should use fillWithValue
833  bool fill( const std::vector<std::tuple<cond::Time_t,cond::Hash> >& iovs ) override{
834 
835  for( auto const & iov : iovs ) {
836  std::shared_ptr<EcalPedestals> payload = Base::fetchPayload( std::get<1>(iov) );
837  if( payload.get() ){
838  // looping over the EB channels, via the dense-index, mapped into EBDetId's
839  if (payload->barrelItems().empty()) return false;
840  for(int cellid = EBDetId::MIN_HASH;
842  ++cellid) {
843  uint32_t rawid = EBDetId::unhashIndex(cellid);
844 
845  // check the existence of ECAL pedestal, for a given ECAL barrel channel
846  if (payload->find(rawid) == payload->end()) continue;
847  if (!(*payload)[rawid].mean_x12 && !(*payload)[rawid].rms_x12) continue;
848 
849  // there's no ieta==0 in the EB numbering
850  // int delta = (EBDetId(rawid)).ieta() > 0 ? -1 : 0 ;
851  // fill the Histogram2D here
852  // fillWithValue( (EBDetId(rawid)).iphi() , (EBDetId(rawid)).ieta()+0.5+delta, (*payload)[rawid].mean_x12 );
853  // set max on noise 2d plots
854  float valrms = (*payload)[rawid].rms_x12;
855  if(valrms > 2.2) valrms = 2.2;
856  fillWithValue( (EBDetId(rawid)).iphi(), (EBDetId(rawid)).ieta(), valrms);
857  }// loop over cellid
858  }// if payload.get()
859  }// loop over IOV's (1 in this case)
860  return true;
861  }// fill method
862  };
863 
864  class EcalPedestalsEBRMS6Map : public cond::payloadInspector::Histogram2D<EcalPedestals> {
865 
866  public:
867  EcalPedestalsEBRMS6Map() : cond::payloadInspector::Histogram2D<EcalPedestals>( "ECAL Barrel noise gain6 - map",
868  "iphi", MAX_IPHI, MIN_IPHI, MAX_IPHI+MIN_IPHI, "ieta", 2*MAX_IETA+1, -1*MAX_IETA, MAX_IETA+1) { Base::setSingleIov( true );
869  }
870 
871  bool fill( const std::vector<std::tuple<cond::Time_t,cond::Hash> >& iovs ) override{
872  for( auto const & iov : iovs ) {
873  std::shared_ptr<EcalPedestals> payload = Base::fetchPayload( std::get<1>(iov) );
874  if( payload.get() ){
875  // looping over the EB channels, via the dense-index, mapped into EBDetId's
876  if (payload->barrelItems().empty()) return false;
877  for(int cellid = EBDetId::MIN_HASH;
879  ++cellid) {
880  uint32_t rawid = EBDetId::unhashIndex(cellid);
881 
882  // check the existence of ECAL pedestal, for a given ECAL barrel channel
883  if (payload->find(rawid) == payload->end()) continue;
884  if (!(*payload)[rawid].mean_x6 && !(*payload)[rawid].rms_x6) continue;
885 
886  // set max on noise 2d plots
887  float valrms = (*payload)[rawid].rms_x6;
888  if(valrms > 1.5) valrms = 1.5;
889  fillWithValue( (EBDetId(rawid)).iphi(), (EBDetId(rawid)).ieta(), valrms);
890  } // loop over cellid
891  } // if payload.get()
892  } // loop over IOV's (1 in this case)
893  return true;
894  } // fill method
895  };
896 
897  class EcalPedestalsEBRMS1Map : public cond::payloadInspector::Histogram2D<EcalPedestals> {
898 
899  public:
900  EcalPedestalsEBRMS1Map() : cond::payloadInspector::Histogram2D<EcalPedestals>( "ECAL Barrel noise gain1 - map",
901  "iphi", MAX_IPHI, MIN_IPHI, MAX_IPHI+MIN_IPHI, "ieta", 2*MAX_IETA+1, -1*MAX_IETA, MAX_IETA+1) { Base::setSingleIov( true );
902  }
903 
904  bool fill( const std::vector<std::tuple<cond::Time_t,cond::Hash> >& iovs ) override{
905  for( auto const & iov : iovs ) {
906  std::shared_ptr<EcalPedestals> payload = Base::fetchPayload( std::get<1>(iov) );
907  if( payload.get() ){
908  // looping over the EB channels, via the dense-index, mapped into EBDetId's
909  if (payload->barrelItems().empty()) return false;
910  for(int cellid = EBDetId::MIN_HASH;
912  ++cellid) {
913  uint32_t rawid = EBDetId::unhashIndex(cellid);
914 
915  // check the existence of ECAL pedestal, for a given ECAL barrel channel
916  if (payload->find(rawid) == payload->end()) continue;
917  if (!(*payload)[rawid].mean_x1 && !(*payload)[rawid].rms_x1) continue;
918 
919  // set max on noise 2d plots
920  float valrms = (*payload)[rawid].rms_x1;
921  if(valrms > 1.0) valrms = 1.0;
922  fillWithValue( (EBDetId(rawid)).iphi(), (EBDetId(rawid)).ieta(), valrms);
923  } // loop over cellid
924  } // if payload.get()
925  } // loop over IOV's (1 in this case)
926  return true;
927  } // fill method
928  };
929 
930  class EcalPedestalsEERMS12Map : public cond::payloadInspector::Histogram2D<EcalPedestals> {
931 
932  public:
933  EcalPedestalsEERMS12Map() : cond::payloadInspector::Histogram2D<EcalPedestals>( "ECAL Endcap noise gain12 - map",
934 "ix", 2.2*IX_MAX, IX_MIN, 2.2*IX_MAX+1, "iy", IY_MAX, IY_MIN, IY_MAX+IY_MIN) {
935  Base::setSingleIov( true );
936  }
937 
938  // Histogram2D::fill (virtual) needs be overridden - the implementation should use fillWithValue
939  bool fill( const std::vector<std::tuple<cond::Time_t,cond::Hash> >& iovs ) override{
940 
941  for( auto const & iov : iovs ) {
942  std::shared_ptr<EcalPedestals> payload = Base::fetchPayload( std::get<1>(iov) );
943  if( payload.get() ){
944  if (payload->endcapItems().empty()) return false;
945 
946  // looping over the EE channels
947  for(int iz = -1; iz < 2; iz = iz + 2) // -1 or +1
948  for(int iy = IY_MIN; iy < IY_MAX+IY_MIN; iy++)
949  for(int ix = IX_MIN; ix < IX_MAX+IX_MIN; ix++)
950  if(EEDetId::validDetId(ix, iy, iz)) {
951  EEDetId myEEId = EEDetId(ix, iy, iz, EEDetId::XYMODE);
952  uint32_t rawid = myEEId.rawId();
953  // check the existence of ECAL pedestal, for a given ECAL endcap channel
954  if (payload->find(rawid) == payload->end()) continue;
955  if (!(*payload)[rawid].mean_x12 && !(*payload)[rawid].rms_x12) continue;
956  // set max on noise 2d plots
957  float valrms = (*payload)[rawid].rms_x12;
958  if(valrms > 3.5) valrms = 3.5;
959  if(iz == -1)
960  fillWithValue(ix, iy, valrms);
961  else
962  fillWithValue(ix + IX_MAX + 20, iy, valrms);
963 
964  } // validDetId
965  } // payload
966  }// loop over IOV's (1 in this case)
967  return true;
968  }// fill method
969  };
970 
971  class EcalPedestalsEERMS6Map : public cond::payloadInspector::Histogram2D<EcalPedestals> {
972 
973  public:
974  EcalPedestalsEERMS6Map() : cond::payloadInspector::Histogram2D<EcalPedestals>( "ECAL Endcap noise gain6 - map",
975 "ix", 2.2*IX_MAX, IX_MIN, 2.2*IX_MAX+1, "iy", IY_MAX, IY_MIN, IY_MAX+IY_MIN) {
976  Base::setSingleIov( true );
977  }
978 
979  bool fill( const std::vector<std::tuple<cond::Time_t,cond::Hash> >& iovs ) override{
980  for( auto const & iov : iovs ) {
981  std::shared_ptr<EcalPedestals> payload = Base::fetchPayload( std::get<1>(iov) );
982  if( payload.get() ){
983  if (payload->endcapItems().empty()) return false;
984 
985  // looping over the EE channels
986  for(int iz = -1; iz < 2; iz = iz + 2) // -1 or +1
987  for(int iy = IY_MIN; iy < IY_MAX+IY_MIN; iy++)
988  for(int ix = IX_MIN; ix < IX_MAX+IX_MIN; ix++)
989  if(EEDetId::validDetId(ix, iy, iz)) {
990  EEDetId myEEId = EEDetId(ix, iy, iz, EEDetId::XYMODE);
991  uint32_t rawid = myEEId.rawId();
992  // check the existence of ECAL pedestal, for a given ECAL endcap channel
993  if (payload->find(rawid) == payload->end()) continue;
994  if (!(*payload)[rawid].mean_x6 && !(*payload)[rawid].rms_x6) continue;
995  // set max on noise 2d plots
996  float valrms = (*payload)[rawid].rms_x6;
997  if(valrms > 2.0) valrms = 2.0;
998  if(iz == -1)
999  fillWithValue( ix, iy, valrms);
1000  else
1001  fillWithValue( ix + IX_MAX + 20, iy, valrms);
1002  } // validDetId
1003  } // payload
1004  } // loop over IOV's (1 in this case)
1005  return true;
1006  } // fill method
1007  };
1008 
1009  class EcalPedestalsEERMS1Map : public cond::payloadInspector::Histogram2D<EcalPedestals> {
1010 
1011  public:
1012  EcalPedestalsEERMS1Map() : cond::payloadInspector::Histogram2D<EcalPedestals>( "ECAL Endcap noise gain1 - map",
1013  "ix", 2.2*IX_MAX, IX_MIN, 2.2*IX_MAX+1, "iy", IY_MAX, IY_MIN, IY_MAX+IY_MIN) {
1014  Base::setSingleIov( true );
1015  }
1016 
1017  bool fill( const std::vector<std::tuple<cond::Time_t,cond::Hash> >& iovs ) override{
1018  for( auto const & iov : iovs ) {
1019  std::shared_ptr<EcalPedestals> payload = Base::fetchPayload( std::get<1>(iov) );
1020  if( payload.get() ){
1021  if (payload->endcapItems().empty()) return false;
1022 
1023  // looping over the EE channels
1024  for(int iz = -1; iz < 2; iz = iz + 2) // -1 or +1
1025  for(int iy = IY_MIN; iy < IY_MAX+IY_MIN; iy++)
1026  for(int ix = IX_MIN; ix < IX_MAX+IX_MIN; ix++)
1027  if(EEDetId::validDetId(ix, iy, iz)) {
1028  EEDetId myEEId = EEDetId(ix, iy, iz, EEDetId::XYMODE);
1029  uint32_t rawid = myEEId.rawId();
1030  // check the existence of ECAL pedestal, for a given ECAL endcap channel
1031  if (payload->find(rawid) == payload->end()) continue;
1032  if (!(*payload)[rawid].mean_x1 && !(*payload)[rawid].rms_x12) continue;
1033  // set max on noise 2d plots
1034  float valrms = (*payload)[rawid].rms_x1;
1035  if(valrms > 1.5) valrms = 1.5;
1036  if(iz == -1)
1037  fillWithValue( ix, iy, valrms);
1038  else
1039  fillWithValue( ix + IX_MAX + 20, iy, valrms);
1040  } // validDetId
1041  } // if payload.get()
1042  } // loop over IOV's (1 in this case)
1043  return true;
1044  } // fill method
1045  };
1046 
1047 
1048 /*****************************************
1049  2d plot of Ecal Pedestals Summary of 1 IOV
1050  ******************************************/
1051 class EcalPedestalsSummaryPlot: public cond::payloadInspector::PlotImage<EcalPedestals> {
1052 public:
1053  EcalPedestalsSummaryPlot() :
1054  cond::payloadInspector::PlotImage<EcalPedestals>("Ecal Pedestals Summary - map ") {
1055  setSingleIov(true);
1056  }
1057 
1058  bool fill(const std::vector<std::tuple<cond::Time_t, cond::Hash> >& iovs)override {
1059 
1060  auto iov = iovs.front(); //get reference to 1st element in the vector iovs
1061  std::shared_ptr < EcalPedestals > payload = fetchPayload(std::get < 1 > (iov)); //std::get<1>(iov) refers to the Hash in the tuple iov
1062  unsigned int run = std::get < 0 > (iov); //referes to Time_t in iov.
1063  TH2F* align; //pointer to align which is a 2D histogram
1064 
1065  int NbRows=6;
1066  int NbColumns=5;
1067 
1068  if (payload.get()) { //payload is an iov retrieved from payload using hash.
1069 
1070  align =new TH2F("Ecal Pedestals Summary","EB/EE Gain Mean RMS Total Items",NbColumns, 0, NbColumns, NbRows, 0, NbRows);
1071 
1072 
1073  float ebVals[]={0.0f,0.0f,0.0f,0.0f,0.0f,0.0f};
1074  float eeVals[]={0.0f,0.0f,0.0f,0.0f,0.0f,0.0f};
1075 
1076  long unsigned int ebTotal=(payload->barrelItems()).size();
1077  long unsigned int eeTotal=(payload->endcapItems()).size();
1078 
1079  pedestalsSummary(payload->barrelItems(),ebVals,ebTotal);
1080  pedestalsSummary(payload->endcapItems(),eeVals,eeTotal);
1081 
1082 
1083  double row = NbRows - 0.5;
1084 
1085  //EB summary values
1086  align->Fill(1.5, row, 12);//Gain
1087  align->Fill(2.5, row, ebVals[0]);//mean12
1088  align->Fill(3.5, row, ebVals[1]);//rms12
1089 
1090  row--;
1091 
1092  align->Fill(0.5, row, 1);
1093  align->Fill(1.5, row, 6);//Gain
1094  align->Fill(2.5, row, ebVals[2]);//mean6
1095  align->Fill(3.5, row, ebVals[3]);//rms6
1096  align->Fill(4.5, row, ebTotal);
1097 
1098  row--;
1099 
1100  align->Fill(1.5, row, 1);//Gain
1101  align->Fill(2.5, row, ebVals[4]);//mean1
1102  align->Fill(3.5, row, ebVals[5]);//rms1
1103 
1104  row--;
1105 
1106  //EE summary values
1107  align->Fill(1.5, row, 12);//Gain
1108  align->Fill(2.5, row, eeVals[0]);//mean12
1109  align->Fill(3.5, row, eeVals[1]);//rms12
1110 
1111  row--;
1112 
1113  align->Fill(0.5, row, 2);
1114  align->Fill(1.5, row, 6);//Gain
1115  align->Fill(2.5, row, eeVals[2]);//mean6
1116  align->Fill(3.5, row, eeVals[3]);//rms6
1117  align->Fill(4.5, row, eeTotal);
1118 
1119  row--;
1120 
1121  align->Fill(1.5, row, 1);//Gain
1122  align->Fill(2.5, row, eeVals[4]);//mean1
1123  align->Fill(3.5, row, eeVals[5]);//rms1
1124 
1125 
1126  } // if payload.get()
1127  else
1128  return false;
1129 
1130  gStyle->SetPalette(1);
1131  gStyle->SetOptStat(0);
1132  TCanvas canvas("CC map", "CC map", 1000, 1000);
1133  TLatex t1;
1134  t1.SetNDC();
1135  t1.SetTextAlign(26);
1136  t1.SetTextSize(0.05);
1137  t1.SetTextColor(2);
1138  t1.DrawLatex(0.5, 0.96,Form("Ecal Pedestals Summary, IOV %i", run));
1139 
1140 
1141  TPad* pad = new TPad("pad", "pad", 0.0, 0.0, 1.0, 0.94);
1142  pad->Draw();
1143  pad->cd();
1144  align->Draw("TEXT");
1145  TLine* l = new TLine;
1146  l->SetLineWidth(1);
1147 
1148  for (int i = 1; i < NbRows; i++) {
1149  double y = (double) i;
1150  if(i==NbRows/2) l = new TLine(0., y, NbColumns, y);
1151  else l = new TLine(1., y, NbColumns-1, y);
1152  l->Draw();
1153  }
1154 
1155  for (int i = 1; i < NbColumns; i++) {
1156  double x = (double) i;
1157  double y = (double) NbRows;
1158  l = new TLine(x, 0., x, y);
1159  l->Draw();
1160  }
1161 
1162  align->GetXaxis()->SetTickLength(0.);
1163  align->GetXaxis()->SetLabelSize(0.);
1164  align->GetYaxis()->SetTickLength(0.);
1165  align->GetYaxis()->SetLabelSize(0.);
1166 
1167  std::string ImageName(m_imageFileName);
1168  canvas.SaveAs(ImageName.c_str());
1169  return true;
1170  } // fill method
1171 
1172  void pedestalsSummary(std::vector<EcalPedestal> vItems,float vals[],long unsigned int & total){
1173 
1174  for(std::vector<EcalPedestal>::const_iterator iItems = vItems.begin(); iItems != vItems.end(); ++iItems){
1175  //vals[0]=100;
1176  vals[0] += iItems->mean(1);//G12
1177  vals[1] += iItems->rms(1);
1178  vals[2] += iItems->mean(2);//G6
1179  vals[3] += iItems->rms(2);
1180  vals[4] += iItems->mean(3);//G1
1181  vals[5] += iItems->rms(3);
1182  }
1183 
1184  vals[0]=vals[0]/total;
1185  vals[1]=vals[1]/total;
1186  vals[2]=vals[2]/total;
1187  vals[3]=vals[3]/total;
1188  vals[4]=vals[4]/total;
1189  vals[5]=vals[5]/total;
1190 
1191  }
1192 
1193 
1194 };
1195 
1196 
1197 } // close namespace
1198 
1199 // Register the classes as boost python plugin
1201  PAYLOAD_INSPECTOR_CLASS( EcalPedestalsHist);
1202  PAYLOAD_INSPECTOR_CLASS( EcalPedestalsPlot);
1203  PAYLOAD_INSPECTOR_CLASS( EcalPedestalsDiff);
1204  PAYLOAD_INSPECTOR_CLASS( EcalPedestalsEBMean12Map);
1205  PAYLOAD_INSPECTOR_CLASS( EcalPedestalsEBMean6Map );
1206  PAYLOAD_INSPECTOR_CLASS( EcalPedestalsEBMean1Map );
1207  PAYLOAD_INSPECTOR_CLASS( EcalPedestalsEEMean12Map);
1208  PAYLOAD_INSPECTOR_CLASS( EcalPedestalsEEMean6Map );
1209  PAYLOAD_INSPECTOR_CLASS( EcalPedestalsEEMean1Map );
1210  PAYLOAD_INSPECTOR_CLASS( EcalPedestalsEBRMS12Map);
1211  PAYLOAD_INSPECTOR_CLASS( EcalPedestalsEBRMS6Map );
1212  PAYLOAD_INSPECTOR_CLASS( EcalPedestalsEBRMS1Map );
1213  PAYLOAD_INSPECTOR_CLASS( EcalPedestalsEERMS12Map);
1214  PAYLOAD_INSPECTOR_CLASS( EcalPedestalsEERMS6Map );
1215  PAYLOAD_INSPECTOR_CLASS( EcalPedestalsEERMS1Map );
1216  PAYLOAD_INSPECTOR_CLASS( EcalPedestalsSummaryPlot );
1217 }
size
Write out results.
static const int XYMODE
Definition: EEDetId.h:335
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:50
const Int_t gainValues[kGains]
void DrawEE(TH2F *endc, float min, float max)
Definition: EcalDrawUtils.h:29
void DrawEB(TH2F *ebmap, float min, float max)
Definition: EcalDrawUtils.h:4
#define PAYLOAD_INSPECTOR_CLASS(CLASS_NAME)
T sqrt(T t)
Definition: SSEVec.h:18
static const int MIN_HASH
Definition: EBDetId.h:149
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
#define PAYLOAD_INSPECTOR_MODULE(PAYLOAD_TYPENAME)
int hashedIndex() const
Definition: EEDetId.h:183
static bool validDetId(int crystal_ix, int crystal_iy, int iz)
Definition: EEDetId.h:248
static EBDetId unhashIndex(int hi)
get a DetId from a compact index for arrays
Definition: EBDetId.h:110
constexpr int gainId(sample_type sample)
get the gainId (2 bits)
Definition: plugin.cc:24
def canvas(sub, attr)
Definition: svgfig.py:482
const Int_t kGains