CMS 3D CMS Logo

SiPixelDQMRocLevelAnalyzer.cc
Go to the documentation of this file.
2 
4  usesResource(TFileService::kSharedResource);
5 }
6 
8 
9 // ------------ method called to for each event ------------
11 
12 // ------------ method called once each job just before starting event loop ------------
15  bRS = conf_.getUntrackedParameter<bool>("barrelRocStud");
16  fRS = conf_.getUntrackedParameter<bool>("endcapRocStud");
17  bPixelAlive = conf_.getUntrackedParameter<bool>("pixelAliveStudy");
18  double pixelAliveThresh = conf_.getUntrackedParameter<double>("pixelAliveThreshold");
19  bool bThreshold = conf_.getUntrackedParameter<bool>("thresholdStudy");
20  bool bNoise = conf_.getUntrackedParameter<bool>("noiseStudy");
21  bool bGain = conf_.getUntrackedParameter<bool>("gainStudy");
22  bool bPedestal = conf_.getUntrackedParameter<bool>("pedestalStudy");
23 
24  if (!bRS && !fRS)
25  return;
26 
27  //Open file and get MEs
29  dbe->open(filename);
30  mes = dbe->getAllContents("");
31  std::cout << "found " << mes.size() << " monitoring elements!" << std::endl;
32 
33  //BARREL
34  if (bRS) {
35  //PIXELALIVE
36  if (bPixelAlive) {
37  bhPixelAlive = fs_->make<TH1F>("bpixAlive", "PixelAliveSummary_mean_Barrel", 11520, 0., 11520.);
39  fs_->make<TH1F>("bpixAliveDist", "Mean PixelAliveSummary_mean_Barrel Disbribution", 110, 0., 1.1);
40  }
41  //THRESHOLD
42  if (bThreshold) {
43  bhThresholdMean = fs_->make<TH1F>("bthreshMean", "ScurveThresholdSummary_mean_Barrel", 11520, 0., 11520.);
45  fs_->make<TH1F>("bthreshMeanDist", "Mean ScurveThresholdSummary_mean_Barrel Distribution", 600, 0., 150.);
46  bhThresholdRMS = fs_->make<TH1F>("bthreshRMS", "ScurveThresholdSummary_RMS_Barrel", 11520, 0., 11520.);
48  fs_->make<TH1F>("bthreshRMSDist", "Mean ScurveThresholdSummary_RMS_Barrel Distribution", 800, 0., 80.);
49  }
50  //NOISE
51  if (bNoise) {
52  bhNoiseMean = fs_->make<TH1F>("bnoiseMean", "ScurveSigmasSummary_mean_Barrel", 11520, 0., 11520.);
54  fs_->make<TH1F>("bnoiseMeanDist", "Mean ScurveSigmasSummary_mean_Barrel Distribution", 256, -2., 6.);
55  bhNoiseRMS = fs_->make<TH1F>("bnoiseRMS", "ScurveSigmasSummary_RMS_Barrel", 11520, 0., 11520.);
57  fs_->make<TH1F>("bnoiseRMSDist", "Mean ScurveSigmasSummary_RMS_Barrel Distribution", 768, 0., 8.);
58  }
59  //GAIN
60  if (bGain) {
61  bhGainMean = fs_->make<TH1F>("bgainMean", "ScurveGainSummary_mean_Barrel", 11520, 0., 11520.);
62  bhGainMean_dist = fs_->make<TH1F>("bgainMeanDist", "Mean ScurveGainSummary_mean_Barrel Distribution", 80, 0., 8.);
63  bhGainRMS = fs_->make<TH1F>("bgainRMS", "ScurveGainSummary_RMS_Barrel", 11520, 0., 11520.);
64  bhGainRMS_dist = fs_->make<TH1F>("bgainRMSDist", "Mean ScurveGainSummary_RMS_Barrel Distribution", 100, 0., 10.);
65  }
66  //PEDESTAL
67  if (bPedestal) {
68  bhPedestalMean = fs_->make<TH1F>("bpedestalMean", "ScurvePedestalSummary_mean_Barrel", 11520, 0., 11520.);
70  fs_->make<TH1F>("bpedestalMeanDist", "Mean ScurvePedestalSummary_mean_Barrel Distribution", 600, 0., 300.);
71  bhPedestalRMS = fs_->make<TH1F>("bpedestalRMS", "ScurvePedestalSummary_RMS_Barrel", 11520, 0., 11520.);
73  fs_->make<TH1F>("bpedestalRMSDist", "Mean ScurvePedestalSummary_RMS_Barrel Distribution", 1000, 0., 100.);
74  }
75  }
76 
77  //ENDCAP
78  if (fRS) {
79  //PIXELALIVE
80  if (bPixelAlive) {
81  ehPixelAlive = fs_->make<TH1F>("fpixAlive", "PixelAliveSummary_mean_Endcap", 4320, 0., 4320.);
83  fs_->make<TH1F>("fpixAliveDist", "Mean PixelAliveSummary_mean_Endcap Disbribution", 110, 0., 1.1);
84  }
85  //THRESHOLD
86  if (bThreshold) {
87  ehThresholdMean = fs_->make<TH1F>("fthreshMean", "ScurveThresholdSummary_mean_Endcap", 4320, 0., 4320.);
89  fs_->make<TH1F>("fthreshMeanDist", "Mean ScurveThresholdSummary_mean_Endcap Distribution", 600, 0., 150.);
90  ehThresholdRMS = fs_->make<TH1F>("fthreshRMS", "ScurveThresholdSummary_RMS_Endcap", 4320, 0., 4320.);
92  fs_->make<TH1F>("fthreshRMSDist", "Mean ScurveThresholdSummary_RMS_Endcap Distribution", 800, 0., 80.);
93  }
94  //NOISE
95  if (bNoise) {
96  ehNoiseMean = fs_->make<TH1F>("fnoiseMean", "ScurveSigmasSummary_mean_Endcap", 4320, 0., 4320.);
98  fs_->make<TH1F>("fnoiseMeanDist", "Mean ScurveSigmasSummary_mean_Endcap Distribution", 256, -2., 6.);
99  ehNoiseRMS = fs_->make<TH1F>("fnoiseRMS", "ScurveSigmasSummary_RMS_Endcap", 4320, 0., 4320.);
101  fs_->make<TH1F>("fnoiseRMSDist", "Mean ScurveSigmasSummary_RMS_Endcap Distribution", 384, 0., 4.);
102  }
103  //GAIN
104  if (bGain) {
105  ehGainMean = fs_->make<TH1F>("fgainMean", "ScurveGainSummary_mean_Endcap", 4320, 0., 4320.);
107  fs_->make<TH1F>("fgainMeanDist", "Mean ScurveGainSummary_mean_Endcap Distribution", 600, 0., 150.);
108  ehGainRMS = fs_->make<TH1F>("fgainRMS", "ScurveGainSummary_RMS_Endcap", 4320, 0., 4320.);
109  ehGainRMS_dist = fs_->make<TH1F>("fgainRMSDist", "Mean ScurveGainSummary_RMS_Endcap Distribution", 800, 0., 80.);
110  }
111  //PEDESTAL
112  if (bPedestal) {
113  ehPedestalMean = fs_->make<TH1F>("fpedestalMean", "ScurvePedestalSummary_mean_Endcap", 4320, 0., 4320.);
115  fs_->make<TH1F>("fpedestalMeanDist", "Mean ScurvePedestalSummary_mean_Endcap Distribution", 600, 0., 150.);
116  ehPedestalRMS = fs_->make<TH1F>("fpedestalRMS", "ScurvePedestalSummary_RMS_Endcap", 4320, 0., 4320.);
118  fs_->make<TH1F>("fpedestalRMSDist", "Mean ScurvePedestalSummary_RMS_Endcap Distribution", 800, 0., 80.);
119  }
120  }
121  //PIXELALIVE
122  if (bPixelAlive) {
123  RocSummary("pixelAlive_siPixelCalibDigis_");
124  if (bRS) {
126 
127  //print a list of pixels with pixelAlive quantity below pixelAliveThresh
128  for (unsigned int i = 0; i < vbpixCN.size(); i++) {
129  if (vbpixM[i] < pixelAliveThresh) {
130  double temp = vbpixCN[i];
131  int shell = (int)((temp - 1) / 2880); //0 mi, 1 mo, 2 pi, 3 po
132  temp -= shell * 2880;
133  int lay = 1;
134  if (temp > 576) {
135  temp -= 576;
136  lay++;
137  }
138  if (temp > 960) {
139  temp -= 960;
140  lay++;
141  }
142  int lad = 1;
143  if (temp > 32) {
144  temp -= 32;
145  lad++;
146  }
147  while (temp > 64) {
148  temp -= 64;
149  lad++;
150  }
151  int mod = 1;
152  int modsize = 16;
153  if (lad == 1 || (lay == 1 && lad == 10) || (lay == 2 && lad == 16) || (lay == 3 && lad == 22))
154  modsize = 8;
155  while (temp > modsize) {
156  temp -= modsize;
157  mod++;
158  }
159  std::cout << vbpixCN[i] << " " << vbpixM[i] << ":\n";
160  std::cout << "Shell ";
161  switch (shell) {
162  case 0:
163  std::cout << "mI";
164  break;
165  case 1:
166  std::cout << "mO";
167  break;
168  case 2:
169  std::cout << "pI";
170  break;
171  case 3:
172  std::cout << "pO";
173  break;
174  }
175  std::cout << " Lay" << lay << " Lad" << lad << " Mod" << mod << " Chip" << temp << "\n\n";
176  }
177  }
178  }
179  if (fRS) {
181  //print a list of pixels with pixelAlive quantity below pixelAliveThresh
182  for (unsigned int i = 0; i < vfpixCN.size(); i++) {
183  if (vfpixM[i] < pixelAliveThresh) {
184  double temp = vfpixCN[i];
185  int hcyl = (int)((temp - 1) / 1080); //0 mi, 1 mo, 2 pi, 3 po
186  temp -= hcyl * 1080;
187  int disk = 1;
188  if (temp > 540) {
189  temp -= 540;
190  disk++;
191  }
192  int blade = 1;
193  while (temp > 45) {
194  temp -= 45;
195  blade++;
196  }
197  int panel = 1, mod = 1;
198  if (temp < 22) {
199  //panel 1
200  if (temp > 16) {
201  temp -= 16;
202  mod = 4;
203  } else if (temp > 8) {
204  temp -= 8;
205  mod = 3;
206  } else if (temp > 2) {
207  temp -= 2;
208  mod = 2;
209  }
210  } else {
211  //panel 2
212  temp -= 21;
213  panel++;
214  if (temp > 14) {
215  temp -= 14;
216  mod = 3;
217  } else if (temp > 6) {
218  temp -= 6;
219  mod = 2;
220  }
221  }
222 
223  std::cout << vfpixCN[i] << " " << vfpixM[i] << ":\n";
224  std::cout << "HalfCylinder ";
225  switch (hcyl) {
226  case 0:
227  std::cout << "mI";
228  break;
229  case 1:
230  std::cout << "mO";
231  break;
232  case 2:
233  std::cout << "pI";
234  break;
235  case 3:
236  std::cout << "pO";
237  break;
238  }
239  std::cout << " Disk" << disk << " Blade" << blade << " Panel" << panel << " Mod" << mod << " Chip" << temp
240  << "\n\n";
241  }
242  }
243  }
244  }
245  //THRESHOLD
246  if (bThreshold) {
247  vbpixCN.clear();
248  vbpixM.clear();
249  vbpixSD.clear();
250  vfpixCN.clear();
251  vfpixM.clear();
252  vfpixSD.clear();
253 
254  RocSummary("ScurveThresholds_siPixelCalibDigis_");
255  if (bRS) {
258  }
259  if (fRS) {
262  }
263  }
264  //NOISE
265  if (bNoise) {
266  vbpixCN.clear();
267  vbpixM.clear();
268  vbpixSD.clear();
269  vfpixCN.clear();
270  vfpixM.clear();
271  vfpixSD.clear();
272 
273  RocSummary("ScurveSigmas_siPixelCalibDigis_");
274  if (bRS) {
277  }
278  if (fRS) {
281  }
282  }
283  //GAIN
284  if (bGain) {
285  vbpixCN.clear();
286  vbpixM.clear();
287  vbpixSD.clear();
288  vfpixCN.clear();
289  vfpixM.clear();
290  vfpixSD.clear();
291 
292  RocSummary("Gain2d_siPixelCalibDigis_");
293  if (bRS) {
296  }
297  if (fRS) {
300  }
301  }
302  //PEDESTAL
303  if (bPedestal) {
304  vbpixCN.clear();
305  vbpixM.clear();
306  vbpixSD.clear();
307  vfpixCN.clear();
308  vfpixM.clear();
309  vfpixSD.clear();
310 
311  RocSummary("Pedestal2d_siPixelCalibDigis_");
312  if (bRS) {
315  }
316  if (fRS) {
319  }
320  }
321 }
322 
323 // ------------ method called once each job just after ending the event loop ------------
325 
327  int maxcrow, maxccol;
328  std::string name, path = "first";
329  std::string oldPath = "";
330  int moduleNumber = 0;
331  int bchipNumber = 0;
332  int fchipNumber = 0;
333  bool bbarrel = false, bforward = false, bhalfMod = false, bwasHM = false;
334  bool bPFFM = false;
335  bool bMNCS = false;
336  int panelNumber = -1;
337 
338  for (std::vector<MonitorElement *>::const_iterator ime = mes.begin(); ime != mes.end(); ++ime) {
339  bwasHM = bhalfMod;
340  //set default values
341  bMNCS = false;
342  bbarrel = false;
343  bforward = false;
344  bhalfMod = false;
345  //set name, (old) path
346  name = (*ime)->getName();
347  oldPath = path;
348  path = (*ime)->getPathname();
349 
350  //determine module number if any
351  if (path.find("Module_") < path.size()) {
352  if (path != oldPath) {
353  moduleNumber++;
354  if (moduleNumber != 1)
355  bMNCS = true;
356  }
357  } else {
358  if (moduleNumber > 0)
359  bMNCS = true;
360  moduleNumber = 0;
361  }
362 
363  //find out location (barrel (hm), endcap)
364  if (path.find("Barrel/") < path.size()) {
365  bbarrel = true;
366  if (path.find("H/") < path.size())
367  bhalfMod = true;
368  }
369  if (path.find("Endcap/") < path.size()) {
370  bforward = true;
371  panelNumber = -1;
372  if (path.find("Panel_1") < path.size())
373  panelNumber = 1;
374  if (path.find("Panel_2") < path.size())
375  panelNumber = 2;
376  }
377 
378  //find tagname in histoname
379  if (name.find(tagname) < name.size())
380  bPFFM = true;
381  else {
382  //adjust chip number if necessary, skip ME
383  if (bMNCS) {
384  if (!bPFFM) {
385  if (bbarrel && bRS) {
386  if (bPixelAlive) {
387  int a = 16;
388  if (bwasHM)
389  a = 8;
390  for (int i = 0; i < a; i++) {
391  bchipNumber++;
392  vbpixCN.push_back(bchipNumber);
393  vbpixM.push_back(0);
394  }
395  } else {
396  if (bwasHM)
397  bchipNumber += 8;
398  else
399  bchipNumber += 16;
400  }
401  }
402  if (bforward && fRS) {
403  int maxcol = 2;
404  int mod = moduleNumber;
405  if (mod > 1)
406  mod--;
407  else {
408  if (panelNumber == 1)
409  mod = 4;
410  else
411  mod = 3;
412  }
413  if (panelNumber == 1 && (mod == 1 || mod == 4))
414  maxcol = 1;
415  if (bPixelAlive) {
416  for (int i = 0; i < maxcol * (mod + panelNumber); i++) {
417  fchipNumber++;
418  vfpixCN.push_back(fchipNumber);
419  vfpixM.push_back(0);
420  }
421  } else {
422  fchipNumber += maxcol * (mod + panelNumber);
423  }
424  }
425  } else
426  bPFFM = false;
427  }
428  continue;
429  }
430 
431  //BARREL ROC LEVEL PLOTS
432 
433  if (bbarrel && bRS) {
434  maxccol = 8, maxcrow = 2;
435  if (bhalfMod) {
436  maxcrow = 1;
437  }
438 
439  RocSumOneModule(maxcrow, maxccol, (*ime), vbpixCN, vbpixM, vbpixSD, bchipNumber);
440  }
441 
442  //ENDCAP ROC LEVEL PLOTS
443  if (bforward && fRS) {
444  maxccol = moduleNumber + panelNumber;
445  maxcrow = 2;
446  if (panelNumber == 1 && (moduleNumber == 1 || moduleNumber == 4))
447  maxcrow = 1;
448 
449  RocSumOneModule(maxcrow, maxccol, (*ime), vfpixCN, vfpixM, vfpixSD, fchipNumber);
450  }
451  }
452 
453  std::cout << "Number of Chips: b" << bchipNumber << " f" << fchipNumber << " " << tagname << std::endl;
454 }
455 
457  int maxc,
458  MonitorElement *const &me,
459  std::vector<double> &vecCN,
460  std::vector<double> &vecMean,
461  std::vector<double> &vecSD,
462  int &chipNumber) {
463  float temp, sum, nentries;
464  for (int cr = 0; cr < maxr; cr++) {
465  for (int cc = 0; cc < maxc; cc++) {
466  //compute mean of 1 ROC
467  chipNumber++;
468  sum = 0;
469  nentries = 0;
470  //sum for 1 ROC
471  for (int c = 1; c < 53; c++) {
472  for (int r = 1; r < 81; r++) {
473  temp = me->getBinContent(52 * cc + c, 80 * cr + r);
474 
475  if (temp != 0.) {
476  sum += temp;
477  nentries++;
478  }
479  }
480  }
481  if (nentries == 0 && bPixelAlive) {
482  vecCN.push_back(chipNumber);
483  vecMean.push_back(0);
484  }
485  if (nentries != 0) {
486  double mean = sum / nentries;
487  double avsd = 0.;
488  int ne = 0;
489  vecCN.push_back(chipNumber);
490  vecMean.push_back(mean);
491 
492  //computing std dev.
493  for (int c = 1; c < 53; c++) {
494  for (int r = 1; r < 81; r++) {
495  temp = me->getBinContent(52 * cc + c, 80 * cr + r);
496  if (temp != 0) {
497  avsd += (temp - mean) * (temp - mean);
498  ne++;
499  }
500  }
501  }
502  avsd = avsd / ne;
503  avsd = sqrt(avsd);
504  vecSD.push_back(avsd);
505  }
506  }
507  }
508 }
509 
511  TH1F *hdist,
512  std::vector<double> &vecx,
513  std::vector<double> &vecy) {
514  if (vecx.size() == vecy.size()) {
515  for (unsigned int i = 0; i < vecx.size(); i++) {
516  hrocdep->Fill(vecx[i], vecy[i]);
517  hdist->Fill(vecy[i]);
518  }
519  }
520 }
521 
522 // -- define this as a plug-in
void analyze(const edm::Event &, const edm::EventSetup &) override
static const std::string kSharedResource
Definition: TFileService.h:76
void FillRocLevelHistos(TH1F *hrocdep, TH1F *hdist, std::vector< double > &vecx, std::vector< double > &vecy)
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
void RocSumOneModule(int maxr, int maxc, MonitorElement *const &me, std::vector< double > &vecCN, std::vector< double > &vecMean, std::vector< double > &vecSD, int &chipNumber)
SiPixelDQMRocLevelAnalyzer(const edm::ParameterSet &)
__constant__ float const maxr[nPairs]
~SiPixelDQMRocLevelAnalyzer() override
T getUntrackedParameter(std::string const &, T const &) const
int iEvent
Definition: GenABIO.cc:224
T sqrt(T t)
Definition: SSEVec.h:19
virtual std::vector< dqm::harvesting::MonitorElement * > getAllContents(std::string const &path) const
Definition: DQMStore.cc:609
void RocSummary(std::string tagname)
std::vector< MonitorElement * > mes
double a
Definition: hdecay.h:119
T * make(const Args &...args) const
make new ROOT object
Definition: TFileService.h:64
Definition: shell.py:1
edm::Service< TFileService > fs_
T mod(const T &a, const T &b)
Definition: ecalDccMap.h:4
DQM_DEPRECATED bool open(std::string const &filename, bool overwrite=false, std::string const &path="", std::string const &prepend="", OpenRunDirs stripdirs=KeepRunDirs, bool fileMustExist=true)
Definition: DQMStore.cc:790