CMS 3D CMS Logo

SiPixelActionExecutor.cc
Go to the documentation of this file.
1 //#define printing false
2 //#define occupancyprinting false
3 
18 
19 #include <cmath>
20 
21 #include <iostream>
22 using namespace std;
23 //=============================================================================================================
24 //
25 // -- Constructor
26 //
28  : offlineXMLfile_(offlineXMLfile), Tier0Flag_(Tier0Flag) {
29  edm::LogInfo("SiPixelActionExecutor") << " Creating SiPixelActionExecutor "
30  << "\n";
31  configParser_ = nullptr;
32  configWriter_ = nullptr;
33  ndet_ = 0;
34  // collationDone = false;
35 }
36 //=============================================================================================================
37 //
38 // -- Destructor
39 //
41  edm::LogInfo("SiPixelActionExecutor") << " Deleting SiPixelActionExecutor "
42  << "\n";
43  if (configParser_)
44  delete configParser_;
45  if (configWriter_)
46  delete configWriter_;
47 }
48 //=============================================================================================================
49 //
50 // -- Read Configuration File
51 //
53  string localPath;
54  if (offlineXMLfile_)
55  localPath = string("DQM/SiPixelMonitorClient/test/sipixel_tier0_config.xml");
56  else
57  localPath = string("DQM/SiPixelMonitorClient/test/sipixel_monitorelement_config.xml");
58  if (configParser_ == nullptr) {
61  }
62 }
63 //=============================================================================================================
64 //
65 // -- Read Configuration File
66 //
68  int &sum_barrel_freq,
69  int &sum_endcap_freq,
70  int &sum_grandbarrel_freq,
71  int &sum_grandendcap_freq,
72  int &message_limit_,
73  int &source_type_,
74  int &calib_type_) {
75  // printing cout<<"Entering
76  // SiPixelActionExecutor::readConfiguration..."<<endl;
77  string localPath;
78  if (offlineXMLfile_)
79  localPath = string("DQM/SiPixelMonitorClient/test/sipixel_tier0_config.xml");
80  else
81  localPath = string("DQM/SiPixelMonitorClient/test/sipixel_monitorelement_config.xml");
82  if (configParser_ == nullptr) {
85  }
86 
87  if (!configParser_->getFrequencyForTrackerMap(tkmap_freq)) {
88  cout << "SiPixelActionExecutor::readConfiguration: Failed to read "
89  "TrackerMap configuration parameters!! ";
90  return false;
91  }
92  if (!configParser_->getFrequencyForBarrelSummary(sum_barrel_freq)) {
93  edm::LogInfo("SiPixelActionExecutor") << "Failed to read Barrel Summary configuration parameters!! "
94  << "\n";
95  return false;
96  }
97  if (!configParser_->getFrequencyForEndcapSummary(sum_endcap_freq)) {
98  edm::LogInfo("SiPixelActionExecutor") << "Failed to read Endcap Summary configuration parameters!! "
99  << "\n";
100  return false;
101  }
102  if (!configParser_->getFrequencyForGrandBarrelSummary(sum_grandbarrel_freq)) {
103  edm::LogInfo("SiPixelActionExecutor") << "Failed to read Grand Barrel Summary configuration parameters!! "
104  << "\n";
105  return false;
106  }
107  if (!configParser_->getFrequencyForGrandEndcapSummary(sum_grandendcap_freq)) {
108  edm::LogInfo("SiPixelActionExecutor") << "Failed to read Grand Endcap Summary configuration parameters!! "
109  << "\n";
110  return false;
111  }
112  if (!configParser_->getMessageLimitForQTests(message_limit_)) {
113  edm::LogInfo("SiPixelActionExecutor") << "Failed to read QTest Message Limit"
114  << "\n";
115  return false;
116  }
117  if (!configParser_->getSourceType(source_type_)) {
118  edm::LogInfo("SiPixelActionExecutor") << "Failed to read Source Type"
119  << "\n";
120  return false;
121  }
122  if (!configParser_->getCalibType(calib_type_)) {
123  edm::LogInfo("SiPixelActionExecutor") << "Failed to read Calib Type"
124  << "\n";
125  return false;
126  }
127  // printing cout<<"...leaving
128  // SiPixelActionExecutor::readConfiguration..."<<endl;
129  return true;
130 }
131 //=============================================================================================================
132 bool SiPixelActionExecutor::readConfiguration(int &tkmap_freq, int &summary_freq) {
133  // printing cout<<"Entering
134  // SiPixelActionExecutor::readConfiguration..."<<endl;
135  string localPath;
136  if (offlineXMLfile_)
137  localPath = string("DQM/SiPixelMonitorClient/test/sipixel_tier0_config.xml");
138  else
139  localPath = string("DQM/SiPixelMonitorClient/test/sipixel_monitorelement_config.xml");
140  if (configParser_ == nullptr) {
143  }
144 
145  if (!configParser_->getFrequencyForTrackerMap(tkmap_freq)) {
146  cout << "SiPixelActionExecutor::readConfiguration: Failed to read "
147  "TrackerMap configuration parameters!! ";
148  return false;
149  }
150  if (!configParser_->getFrequencyForBarrelSummary(summary_freq)) {
151  edm::LogInfo("SiPixelActionExecutor") << "Failed to read Summary configuration parameters!! "
152  << "\n";
153  return false;
154  }
155  // printing cout<<"...leaving
156  // SiPixelActionExecutor::readConfiguration..."<<endl;
157  return true;
158 }
159 
160 //=============================================================================================================
162  // To be majorly overhauled and split into two, I guess.
163 
164  // cout<<"entering SiPixelActionExecutor::createSummary..."<<endl;
165  string barrel_structure_name;
166  vector<string> barrel_me_names;
167  string localPath;
168  if (offlineXMLfile_)
169  localPath = string("DQM/SiPixelMonitorClient/test/sipixel_tier0_config.xml");
170  else
171  localPath = string("DQM/SiPixelMonitorClient/test/sipixel_monitorelement_config.xml");
172  // cout<<"*********************ATTENTION! LOCALPATH= "<<localPath<<endl;
173  if (configParser_ == nullptr) {
176  }
177  if (!configParser_->getMENamesForBarrelSummary(barrel_structure_name, barrel_me_names)) {
178  cout << "SiPixelActionExecutor::createSummary: Failed to read Barrel "
179  "Summary configuration parameters!! ";
180  return;
181  }
183 
184  iBooker.setCurrentFolder("Pixel/");
185  iGetter.setCurrentFolder("Pixel/");
186  fillSummary(iBooker, iGetter, barrel_structure_name, barrel_me_names, true,
187  isUpgrade); // Barrel
188  iBooker.setCurrentFolder("Pixel/");
189  iGetter.setCurrentFolder("Pixel/");
190  string endcap_structure_name;
191  vector<string> endcap_me_names;
192  if (!configParser_->getMENamesForEndcapSummary(endcap_structure_name, endcap_me_names)) {
193  edm::LogInfo("SiPixelActionExecutor") << "Failed to read Endcap Summary configuration parameters!! "
194  << "\n";
195  return;
196  }
197 
198  // cout << "--- Processing endcap" << endl;
199 
200  iBooker.setCurrentFolder("Pixel/");
201  iGetter.setCurrentFolder("Pixel/");
202 
203  fillSummary(iBooker, iGetter, endcap_structure_name, endcap_me_names, false,
204  isUpgrade); // Endcap
205  iBooker.setCurrentFolder("Pixel/");
206  iGetter.setCurrentFolder("Pixel/");
207 
208  if (source_type_ == 0 || source_type_ == 5 || source_type_ == 20) { // do this only if RawData source is present
209  string federror_structure_name;
210  vector<string> federror_me_names;
211  if (!configParser_->getMENamesForFEDErrorSummary(federror_structure_name, federror_me_names)) {
212  cout << "SiPixelActionExecutor::createSummary: Failed to read FED Error "
213  "Summary configuration parameters!! ";
214  return;
215  }
216  iBooker.setCurrentFolder("Pixel/");
217  iGetter.setCurrentFolder("Pixel/");
218 
219  fillFEDErrorSummary(iBooker, iGetter, federror_structure_name, federror_me_names);
220  iBooker.setCurrentFolder("Pixel/");
221  iGetter.setCurrentFolder("Pixel/");
222  }
223  if (configWriter_)
224  delete configWriter_;
225  configWriter_ = nullptr;
226  // cout<<"leaving SiPixelActionExecutor::createSummary..."<<endl;
227 }
228 
229 //=============================================================================================================
231  int nBPixModules;
232  if (isUpgrade) {
233  nBPixModules = 1184;
234  } else {
235  nBPixModules = 768;
236  }
237 
238  iBooker.cd();
239  iBooker.setCurrentFolder("Pixel/Barrel");
240  DEV_adc_Barrel = iBooker.book1D(
241  "DEV_adc_Barrel", "Deviation from reference;Module;<adc_ref>-<adc>", nBPixModules, 0., nBPixModules);
242  DEV_ndigis_Barrel = iBooker.book1D(
243  "DEV_ndigis_Barrel", "Deviation from reference;Module;<ndigis_ref>-<ndigis>", nBPixModules, 0., nBPixModules);
244  DEV_charge_Barrel = iBooker.book1D(
245  "DEV_charge_Barrel", "Deviation from reference;Module;<charge_ref>-<charge>", nBPixModules, 0., nBPixModules);
246  DEV_nclusters_Barrel = iBooker.book1D("DEV_nclusters_Barrel",
247  "Deviation from reference;Module;<nclusters_ref>-<nclusters>",
248  nBPixModules,
249  0.,
250  nBPixModules);
251  DEV_size_Barrel = iBooker.book1D(
252  "DEV_size_Barrel", "Deviation from reference;Module;<size_ref>-<size>", nBPixModules, 0., nBPixModules);
253  iBooker.cd();
254  iBooker.setCurrentFolder("Pixel/Endcap");
255  DEV_adc_Endcap = iBooker.book1D("DEV_adc_Endcap", "Deviation from reference;Module;<adc_ref>-<adc>", 672, 0., 672.);
257  iBooker.book1D("DEV_ndigis_Endcap", "Deviation from reference;Module;<ndigis_ref>-<ndigis>", 672, 0., 672.);
259  iBooker.book1D("DEV_charge_Endcap", "Deviation from reference;Module;<charge_ref>-<charge>", 672, 0., 672.);
260  DEV_nclusters_Endcap = iBooker.book1D(
261  "DEV_nclusters_Endcap", "Deviation from reference;Module;<nclusters_ref>-<nclusters>", 672, 0., 672.);
263  iBooker.book1D("DEV_size_Endcap", "Deviation from reference;Module;<size_ref>-<size>", 672, 0., 672.);
264  iBooker.cd();
265 }
266 
267 //=============================================================================================================
268 
270  DQMStore::IGetter &iGetter,
271  vector<string> &blade_subdirs) {
272  blade_subdirs.clear();
273  vector<string> panels = iGetter.getSubdirs();
274  vector<string> modules;
275  for (vector<string>::const_iterator it = panels.begin(); it != panels.end(); it++) {
276  iGetter.cd(*it);
277  iBooker.cd(*it);
278  modules = iGetter.getSubdirs();
279  for (vector<string>::const_iterator m_it = modules.begin(); m_it != modules.end(); m_it++) {
280  blade_subdirs.push_back(*m_it);
281  }
282  }
283 }
284 
285 //=============================================================================================================
286 
288  DQMStore::IGetter &iGetter,
289  string dir_name,
290  vector<string> &me_names,
291  bool isbarrel,
292  bool isUpgrade) {
293  // cout<<"entering SiPixelActionExecutor::fillSummary..."<<endl;
294  string currDir = iBooker.pwd();
295  string prefix;
296  if (source_type_ == 0)
297  prefix = "SUMRAW";
298  else if (source_type_ == 1)
299  prefix = "SUMDIG";
300  else if (source_type_ == 2)
301  prefix = "SUMCLU";
302  else if (source_type_ == 3)
303  prefix = "SUMTRK";
304  else if (source_type_ == 4)
305  prefix = "SUMHIT";
306  else if (source_type_ >= 7 && source_type_ < 20)
307  prefix = "SUMCAL";
308  else if (source_type_ == 20)
309  prefix = "SUMOFF";
310  if (currDir.find(dir_name) != string::npos) {
311  vector<MonitorElement *> sum_mes;
312  for (vector<string>::const_iterator iv = me_names.begin(); iv != me_names.end(); iv++) {
313  if (source_type_ == 5 || source_type_ == 6) {
314  if ((*iv) == "errorType" || (*iv) == "NErrors" || (*iv) == "fullType" || (*iv) == "chanNmbr" ||
315  (*iv) == "TBMType" || (*iv) == "EvtNbr" || (*iv) == "evtSize" || (*iv) == "linkId" || (*iv) == "ROCId" ||
316  (*iv) == "DCOLId" || (*iv) == "PXId" || (*iv) == "ROCNmbr" || (*iv) == "TBMMessage" ||
317  (*iv) == "Type36Hitmap")
318  prefix = "SUMRAW";
319  else if ((*iv) == "ndigis" || (*iv) == "adc")
320  prefix = "SUMDIG";
321  else if ((*iv) == "nclusters" || (*iv) == "x" || (*iv) == "y" || (*iv) == "charge" || (*iv) == "size" ||
322  (*iv) == "sizeX" || (*iv) == "sizeY" || (*iv) == "minrow" || (*iv) == "maxrow" || (*iv) == "mincol" ||
323  (*iv) == "maxcol")
324  prefix = "SUMCLU";
325  if (currDir.find("Track") != string::npos)
326  prefix = "SUMTRK";
327  else if ((*iv) == "residualX" || (*iv) == "residualY")
328  prefix = "SUMTRK";
329  else if ((*iv) == "ClustX" || (*iv) == "ClustY" || (*iv) == "nRecHits" || (*iv) == "ErrorX" ||
330  (*iv) == "ErrorY")
331  prefix = "SUMHIT";
332  else if ((*iv) == "Gain1d" || (*iv) == "GainChi2NDF1d" || (*iv) == "GainChi2Prob1d" || (*iv) == "Pedestal1d" ||
333  (*iv) == "GainNPoints1d" || (*iv) == "GainHighPoint1d" || (*iv) == "GainLowPoint1d" ||
334  (*iv) == "GainEndPoint1d" || (*iv) == "GainFitResult2d" || (*iv) == "GainDynamicRange2d" ||
335  (*iv) == "GainSaturate2d" || (*iv) == "ScurveChi2ProbSummary" || (*iv) == "ScurveFitResultSummary" ||
336  (*iv) == "ScurveSigmasSummary" || (*iv) == "ScurveThresholdSummary" || (*iv) == "pixelAliveSummary" ||
337  (*iv) == "SiPixelErrorsCalibDigis")
338  prefix = "SUMCAL";
339  }
341  string tag;
342  if ((*iv).find("residual") != string::npos) { // track residuals
343  tag = prefix + "_" + (*iv) + "_mean_" + currDir.substr(currDir.find(dir_name));
344  temp = getSummaryME(iBooker, iGetter, tag, isUpgrade);
345  sum_mes.push_back(temp);
346  tag = prefix + "_" + (*iv) + "_RMS_" + currDir.substr(currDir.find(dir_name));
347  temp = getSummaryME(iBooker, iGetter, tag, isUpgrade);
348  sum_mes.push_back(temp);
349  } else if (prefix == "SUMCAL") { // calibrations
350  if ((*iv) == "Gain1d" || (*iv) == "GainChi2NDF1d" || (*iv) == "GainChi2Prob1d" || (*iv) == "GainNPoints1d" ||
351  (*iv) == "GainHighPoint1d" || (*iv) == "GainLowPoint1d" || (*iv) == "GainEndPoint1d" ||
352  (*iv) == "GainDynamicRange2d" || (*iv) == "GainSaturate2d" || (*iv) == "Pedestal1d" ||
353  (*iv) == "ScurveChi2ProbSummary" || (*iv) == "ScurveFitResultSummary" || (*iv) == "ScurveSigmasSummary" ||
354  (*iv) == "ScurveThresholdSummary") {
355  tag = prefix + "_" + (*iv) + "_mean_" + currDir.substr(currDir.find(dir_name));
356  temp = getSummaryME(iBooker, iGetter, tag, isUpgrade);
357  sum_mes.push_back(temp);
358  tag = prefix + "_" + (*iv) + "_RMS_" + currDir.substr(currDir.find(dir_name));
359  temp = getSummaryME(iBooker, iGetter, tag, isUpgrade);
360  sum_mes.push_back(temp);
361  } else if ((*iv) == "SiPixelErrorsCalibDigis") {
362  tag = prefix + "_" + (*iv) + "_NCalibErrors_" + currDir.substr(currDir.find(dir_name));
363  temp = getSummaryME(iBooker, iGetter, tag, isUpgrade);
364  sum_mes.push_back(temp);
365  } else if ((*iv) == "GainFitResult2d") {
366  tag = prefix + "_" + (*iv) + "_NNegativeFits_" + currDir.substr(currDir.find(dir_name));
367  temp = getSummaryME(iBooker, iGetter, tag, isUpgrade);
368  sum_mes.push_back(temp);
369  } else if ((*iv) == "pixelAliveSummary") {
370  tag = prefix + "_" + (*iv) + "_FracOfPerfectPix_" + currDir.substr(currDir.find(dir_name));
371  temp = getSummaryME(iBooker, iGetter, tag, isUpgrade);
372  sum_mes.push_back(temp);
373  tag = prefix + "_" + (*iv) + "_mean_" + currDir.substr(currDir.find(dir_name));
374  temp = getSummaryME(iBooker, iGetter, tag, isUpgrade);
375  sum_mes.push_back(temp);
376  }
377  } else {
378  tag = prefix + "_" + (*iv) + "_" + currDir.substr(currDir.find(dir_name));
379  temp = getSummaryME(iBooker, iGetter, tag, isUpgrade);
380  sum_mes.push_back(temp);
381  if ((*iv) == "ndigis") {
382  tag = prefix + "_" + (*iv) + "FREQ_" + currDir.substr(currDir.find(dir_name));
383  temp = getSummaryME(iBooker, iGetter, tag, isUpgrade);
384  sum_mes.push_back(temp);
385  }
386  if (prefix == "SUMDIG" && (*iv) == "adc") {
387  tag = "ALLMODS_" + (*iv) + "COMB_" + currDir.substr(currDir.find(dir_name));
388  temp = nullptr;
389  string fullpathname = iBooker.pwd() + "/" + tag;
390  temp = iGetter.get(fullpathname);
391  if (temp) {
392  temp->Reset();
393  } else {
394  temp = iBooker.book1D(tag.c_str(), tag.c_str(), 128, 0., 256.);
395  }
396  sum_mes.push_back(temp);
397  }
398  if (prefix == "SUMCLU" && (*iv) == "charge") {
399  tag = "ALLMODS_" + (*iv) + "COMB_" + currDir.substr(currDir.find(dir_name));
400  temp = nullptr;
401  string fullpathname = iBooker.pwd() + "/" + tag;
402  temp = iGetter.get(fullpathname);
403  if (temp) {
404  temp->Reset();
405  } else {
406  temp = iBooker.book1D(tag.c_str(), tag.c_str(), 100, 0.,
407  200.); // To look to get the size automatically
408  }
409  sum_mes.push_back(temp);
410  }
411  }
412  }
413  if (sum_mes.empty()) {
414  edm::LogInfo("SiPixelActionExecutor") << " Summary MEs can not be created"
415  << "\n";
416  return;
417  }
418  vector<string> subdirs = iGetter.getSubdirs();
419  // Blade
420  if (dir_name.find("Blade_") == 0)
421  GetBladeSubdirs(iBooker, iGetter, subdirs);
422 
423  int ndet = 0;
424  for (vector<string>::const_iterator it = subdirs.begin(); it != subdirs.end(); it++) {
425  if (prefix != "SUMOFF" && (*it).find("Module_") == string::npos)
426  continue;
427  if (prefix == "SUMOFF" && (*it).find(isbarrel ? "Layer_" : "Disk_") == string::npos)
428  continue;
429  iBooker.cd(*it);
430  iGetter.cd(*it);
431  ndet++;
432 
433  vector<string> contents = iGetter.getMEs();
434 
435  for (vector<MonitorElement *>::const_iterator isum = sum_mes.begin(); isum != sum_mes.end(); isum++) {
436  for (vector<string>::const_iterator im = contents.begin(); im != contents.end(); im++) {
437  string sname = ((*isum)->getName());
438  string tname = " ";
439  tname = sname.substr(7, (sname.find("_", 7) - 6));
440  if (sname.find("ALLMODS_adcCOMB_") != string::npos)
441  tname = "adc_";
442  if (sname.find("ALLMODS_chargeCOMB_") != string::npos)
443  tname = "charge_";
444  if (sname.find("_charge_") != string::npos && sname.find("Track_") == string::npos)
445  tname = "charge_";
446  if (sname.find("_nclusters_") != string::npos && sname.find("Track_") == string::npos)
447  tname = "nclusters_";
448  if (sname.find("_size_") != string::npos && sname.find("Track_") == string::npos)
449  tname = "size_";
450  if (sname.find("_charge_OffTrack_") != string::npos)
451  tname = "charge_OffTrack_";
452  if (sname.find("_nclusters_OffTrack_") != string::npos)
453  tname = "nclusters_OffTrack_";
454  if (sname.find("_size_OffTrack_") != string::npos)
455  tname = "size_OffTrack_";
456  if (sname.find("_sizeX_OffTrack_") != string::npos)
457  tname = "sizeX_OffTrack_";
458  if (sname.find("_sizeY_OffTrack_") != string::npos)
459  tname = "sizeY_OffTrack_";
460  if (sname.find("_charge_OnTrack_") != string::npos)
461  tname = "charge_OnTrack_";
462  if (sname.find("_nclusters_OnTrack_") != string::npos)
463  tname = "nclusters_OnTrack_";
464  if (sname.find("_size_OnTrack_") != string::npos)
465  tname = "size_OnTrack_";
466  if (sname.find("_sizeX_OnTrack_") != string::npos)
467  tname = "sizeX_OnTrack_";
468  if (sname.find("_sizeY_OnTrack_") != string::npos)
469  tname = "sizeY_OnTrack_";
470  if (tname.find("FREQ") != string::npos)
471  tname = "ndigis_";
472  if (((*im)).find(tname) == 0) {
473  string fullpathname = iBooker.pwd() + "/" + (*im);
474  MonitorElement *me = iGetter.get(fullpathname);
475 
476  if (me) {
477  if (sname.find("_charge") != string::npos && sname.find("Track_") == string::npos &&
478  me->getName().find("Track_") != string::npos)
479  continue;
480  if (sname.find("_nclusters_") != string::npos && sname.find("Track_") == string::npos &&
481  me->getName().find("Track_") != string::npos)
482  continue;
483  if (sname.find("_size") != string::npos && sname.find("Track_") == string::npos &&
484  me->getName().find("Track_") != string::npos)
485  continue;
486  // fill summary histos:
487  if (sname.find("_RMS_") != string::npos && sname.find("GainDynamicRange2d") == string::npos &&
488  sname.find("GainSaturate2d") == string::npos) {
489  (*isum)->Fill(ndet, me->getRMS());
490  } else if (sname.find("GainDynamicRange2d") != string::npos ||
491  sname.find("GainSaturate2d") != string::npos) {
492  float SumOfEntries = 0.;
493  float SumOfSquaredEntries = 0.;
494  int SumOfPixels = 0;
495  for (int cols = 1; cols != me->getNbinsX() + 1; cols++)
496  for (int rows = 1; rows != me->getNbinsY() + 1; rows++) {
497  SumOfEntries += me->getBinContent(cols, rows);
498  SumOfSquaredEntries += (me->getBinContent(cols, rows)) * (me->getBinContent(cols, rows));
499  SumOfPixels++;
500  }
501 
502  float MeanInZ = SumOfEntries / float(SumOfPixels);
503  float RMSInZ = sqrt(SumOfSquaredEntries / float(SumOfPixels));
504  if (sname.find("_mean_") != string::npos)
505  (*isum)->Fill(ndet, MeanInZ);
506  if (sname.find("_RMS_") != string::npos)
507  (*isum)->Fill(ndet, RMSInZ);
508  } else if (sname.find("_FracOfPerfectPix_") != string::npos) {
509  float nlast = me->getBinContent(me->getNbinsX());
510  float nall = (me->getTH1F())->Integral(1, 11);
511  (*isum)->Fill(ndet, nlast / nall);
512  } else if (sname.find("_NCalibErrors_") != string::npos || sname.find("FREQ_") != string::npos) {
513  float nall = me->getEntries();
514  (*isum)->Fill(ndet, nall);
515  } else if (sname.find("GainFitResult2d") != string::npos) {
516  int NegFitPixels = 0;
517  for (int cols = 1; cols != me->getNbinsX() + 1; cols++)
518  for (int rows = 1; rows != me->getNbinsY() + 1; rows++) {
519  if (me->getBinContent(cols, rows) < 0.)
520  NegFitPixels++;
521  }
522  (*isum)->Fill(ndet, float(NegFitPixels));
523  } else if (sname.find("ALLMODS_adcCOMB_") != string::npos ||
524  (sname.find("ALLMODS_chargeCOMB_") != string::npos &&
525  me->getName().find("Track_") == string::npos)) {
526  (*isum)->getTH1F()->Add(me->getTH1F());
527  } else if (sname.find("_NErrors_") != string::npos) {
528  string path1 = fullpathname;
529  path1 = path1.replace(path1.find("NErrors"), 7, "errorType");
530  MonitorElement *me1 = iGetter.get(path1);
531  bool notReset = true;
532  if (me1) {
533  for (int jj = 1; jj < 16; jj++) {
534  if (me1->getBinContent(jj) > 0.) {
535  if (jj == 6) { // errorType=30 (reset)
536  string path2 = path1;
537  path2 = path2.replace(path2.find("errorType"), 9, "TBMMessage");
538  MonitorElement *me2 = iGetter.get(path2);
539  if (me2)
540  if (me2->getBinContent(6) > 0. || me2->getBinContent(7) > 0.)
541  notReset = false;
542  }
543  }
544  }
545  }
546  if (notReset)
547  (*isum)->Fill(ndet, me1->getEntries());
548  } else if ((sname.find("_charge_") != string::npos && sname.find("Track_") == string::npos &&
549  me->getName().find("Track_") == string::npos) ||
550  (sname.find("_charge_") != string::npos && sname.find("_OnTrack_") != string::npos &&
551  me->getName().find("_OnTrack_") != string::npos) ||
552  (sname.find("_charge_") != string::npos && sname.find("_OffTrack_") != string::npos &&
553  me->getName().find("_OffTrack_") != string::npos) ||
554  (sname.find("_nclusters_") != string::npos && sname.find("Track_") == string::npos &&
555  me->getName().find("Track_") == string::npos) ||
556  (sname.find("_nclusters_") != string::npos && sname.find("_OnTrack_") != string::npos &&
557  me->getName().find("_OnTrack_") != string::npos) ||
558  (sname.find("_nclusters_") != string::npos && sname.find("_OffTrack_") != string::npos &&
559  me->getName().find("_OffTrack_") != string::npos) ||
560  (sname.find("_size") != string::npos && sname.find("Track_") == string::npos &&
561  me->getName().find("Track_") == string::npos) ||
562  (sname.find("_size") != string::npos && sname.find("_OnTrack_") != string::npos &&
563  me->getName().find("_OnTrack_") != string::npos) ||
564  (sname.find("_size") != string::npos && sname.find("_OffTrack_") != string::npos &&
565  me->getName().find("_OffTrack_") != string::npos)) {
566  (*isum)->Fill(ndet, me->getMean());
567  } else if (sname.find("_charge_") == string::npos && sname.find("_nclusters_") == string::npos &&
568  sname.find("_size") == string::npos) {
569  (*isum)->Fill(ndet, me->getMean());
570  }
571 
572  // set titles:
573  if (prefix == "SUMOFF") {
574  (*isum)->setAxisTitle(isbarrel ? "Ladders" : "Blades", 1);
575  } else if (sname.find("ALLMODS_adcCOMB_") != string::npos) {
576  (*isum)->setAxisTitle("Digi charge [ADC]", 1);
577  } else if (sname.find("ALLMODS_chargeCOMB_") != string::npos) {
578  (*isum)->setAxisTitle("Cluster charge [kilo electrons]", 1);
579  } else {
580  (*isum)->setAxisTitle("Modules", 1);
581  }
582  string title = " ";
583  if (sname.find("_RMS_") != string::npos) {
584  title = "RMS of " + sname.substr(7, (sname.find("_", 7) - 7)) + " per module";
585  } else if (sname.find("_FracOfPerfectPix_") != string::npos) {
586  title = "FracOfPerfectPix " + sname.substr(7, (sname.find("_", 7) - 7)) + " per module";
587  } else if (sname.find("_NCalibErrors_") != string::npos) {
588  title = "Number of CalibErrors " + sname.substr(7, (sname.find("_", 7) - 7)) + " per module";
589  } else if (sname.find("_NNegativeFits_") != string::npos) {
590  title = "Number of pixels with neg. fit result " + sname.substr(7, (sname.find("_", 7) - 7)) +
591  " per module";
592  } else if (sname.find("FREQ_") != string::npos) {
593  title = "NEvents with digis per module";
594  } else if (sname.find("ALLMODS_adcCOMB_") != string::npos) {
595  title = "NDigis";
596  } else if (sname.find("ALLMODS_chargeCOMB_") != string::npos) {
597  title = "NClusters";
598  } else if (sname.find("_NErrors_") != string::npos) {
599  if (prefix == "SUMOFF" && isbarrel)
600  title = "Total number of errors per Ladder";
601  else if (prefix == "SUMOFF" && !isbarrel)
602  title = "Total number of errors per Blade";
603  else
604  title = "Total number of errors per Module";
605  } else {
606  if (prefix == "SUMOFF")
607  title =
608  "Mean " + sname.substr(7, (sname.find("_", 7) - 7)) + (isbarrel ? " per Ladder" : " per Blade");
609  else
610  title = "Mean " + sname.substr(7, (sname.find("_", 7) - 7)) + " per Module";
611  }
612  (*isum)->setAxisTitle(title, 2);
613  }
614  break;
615  }
616  }
617  }
618  iBooker.goUp();
619  iGetter.setCurrentFolder(iBooker.pwd());
620  if (dir_name.find("Blade") == 0) {
621  iBooker.goUp(); // Going up a second time if we are processing the Blade
622  iGetter.setCurrentFolder(iBooker.pwd());
623  }
624  } // end for it (subdirs)
625  } else {
626  vector<string> subdirs = iGetter.getSubdirs();
627  // printing cout << "#\t" << iBooker.pwd() << endl;
628  if (isbarrel) {
629  for (vector<string>::const_iterator it = subdirs.begin(); it != subdirs.end(); it++) {
630  // cout << "##\t" << iBooker.pwd() << "\t"
631  //<<
632  //(*it) << endl;
633  if ((iBooker.pwd()).find("Endcap") != string::npos ||
634  (iBooker.pwd()).find("AdditionalPixelErrors") != string::npos) {
635  iBooker.goUp();
636  iGetter.setCurrentFolder(iBooker.pwd());
637  }
638  iBooker.cd(*it);
639  iGetter.cd(*it);
640  if ((*it).find("Endcap") != string::npos || (*it).find("AdditionalPixelErrors") != string::npos)
641  continue;
642  fillSummary(iBooker, iGetter, dir_name, me_names, true,
643  isUpgrade); // Barrel
644  iBooker.goUp();
645  iGetter.setCurrentFolder(iBooker.pwd());
646  }
647  string grandbarrel_structure_name;
648  vector<string> grandbarrel_me_names;
649  if (!configParser_->getMENamesForGrandBarrelSummary(grandbarrel_structure_name, grandbarrel_me_names)) {
650  cout << "SiPixelActionExecutor::createSummary: Failed to read Grand "
651  "Barrel Summary configuration parameters!! ";
652  return;
653  }
654  fillGrandBarrelSummaryHistos(iBooker, iGetter, grandbarrel_me_names, isUpgrade);
655 
656  } else // Endcap
657  {
658  for (vector<string>::const_iterator it = subdirs.begin(); it != subdirs.end(); it++) {
659  if ((iBooker.pwd()).find("Barrel") != string::npos ||
660  (iBooker.pwd()).find("AdditionalPixelErrors") != string::npos) {
661  iBooker.goUp();
662  iGetter.setCurrentFolder(iBooker.pwd());
663  }
664  iBooker.cd(*it);
665  iGetter.cd(*it);
666  if ((*it).find("Barrel") != string::npos || (*it).find("AdditionalPixelErrors") != string::npos)
667  continue;
668  fillSummary(iBooker, iGetter, dir_name, me_names, false,
669  isUpgrade); // Endcap
670  iBooker.goUp();
671  iGetter.setCurrentFolder(iBooker.pwd());
672  }
673  string grandendcap_structure_name;
674  vector<string> grandendcap_me_names;
675  if (!configParser_->getMENamesForGrandEndcapSummary(grandendcap_structure_name, grandendcap_me_names)) {
676  cout << "SiPixelActionExecutor::createSummary: Failed to read Grand "
677  "Endcap Summary configuration parameters!! ";
678  return;
679  }
680  fillGrandEndcapSummaryHistos(iBooker, iGetter, grandendcap_me_names, isUpgrade);
681  }
682  }
683  // cout<<"...leaving SiPixelActionExecutor::fillSummary!"<<endl;
684 }
685 
686 //=============================================================================================================
688  DQMStore::IGetter &iGetter,
689  string dir_name,
690  vector<string> &me_names) {
691  // printing cout<<"entering
692  // SiPixelActionExecutor::fillFEDErrorSummary..."<<endl;
693  string currDir = iBooker.pwd();
694  string prefix;
695  if (source_type_ == 0)
696  prefix = "SUMRAW";
697  else if (source_type_ == 20)
698  prefix = "SUMOFF";
699 
700  if (currDir.find(dir_name) != string::npos) {
701  vector<MonitorElement *> sum_mes;
702  for (vector<string>::const_iterator iv = me_names.begin(); iv != me_names.end(); iv++) {
703  bool isBooked = false;
704  vector<string> contents = iGetter.getMEs();
705  for (vector<string>::const_iterator im = contents.begin(); im != contents.end(); im++)
706  if ((*im).find(*iv) != string::npos)
707  isBooked = true;
708  if (source_type_ == 5 || source_type_ == 6) {
709  if ((*iv) == "errorType" || (*iv) == "NErrors" || (*iv) == "fullType" || (*iv) == "chanNmbr" ||
710  (*iv) == "TBMType" || (*iv) == "EvtNbr" || (*iv) == "evtSize" || (*iv) == "linkId" || (*iv) == "ROCId" ||
711  (*iv) == "DCOLId" || (*iv) == "PXId" || (*iv) == "ROCNmbr" || (*iv) == "TBMMessage" ||
712  (*iv) == "Type36Hitmap" || (*iv) == "FedChLErr" || (*iv) == "FedChNErr" || (*iv) == "FedETypeNErr")
713  prefix = "SUMRAW";
714  }
715  if ((*iv) == "errorType" || (*iv) == "NErrors" || (*iv) == "fullType" || (*iv) == "chanNmbr" ||
716  (*iv) == "TBMType" || (*iv) == "EvtNbr" || (*iv) == "evtSize" || (*iv) == "linkId" || (*iv) == "ROCId" ||
717  (*iv) == "DCOLId" || (*iv) == "PXId" || (*iv) == "ROCNmbr" || (*iv) == "TBMMessage" ||
718  (*iv) == "Type36Hitmap") {
719  string tag = prefix + "_" + (*iv) + "_FEDErrors";
720  MonitorElement *temp = getFEDSummaryME(iBooker, iGetter, tag);
721  sum_mes.push_back(temp);
722  } else if ((*iv) == "FedChLErr" || (*iv) == "FedChNErr" || (*iv) == "FedETypeNErr") {
723  string tag = prefix + "_" + (*iv);
725  if ((*iv) == "FedChLErr") {
726  if (!isBooked)
727  temp = iBooker.book2D("FedChLErr", "Type of last error", 40, -0.5, 39.5, 37, 0., 37.);
728  else {
729  string fullpathname = iBooker.pwd() + "/" + (*iv);
730  temp = iGetter.get(fullpathname);
731  temp->Reset();
732  }
733  } // If I don't reset this one, then I instead start adding error
734  // codes..
735  if ((*iv) == "FedChNErr") {
736  if (!isBooked)
737  temp = iBooker.book2D("FedChNErr", "Total number of errors", 40, -0.5, 39.5, 37, 0., 37.);
738  else {
739  string fullpathname = iBooker.pwd() + "/" + (*iv);
740  temp = iGetter.get(fullpathname);
741  temp->Reset();
742  }
743  } // If I don't reset this one, then I instead start adding error
744  // codes..
745  if ((*iv) == "FedETypeNErr") {
746  if (!isBooked) {
747  temp = iBooker.book2D("FedETypeNErr", "Number of each error type", 40, -0.5, 39.5, 21, 0., 21.);
748  temp->setBinLabel(1, "ROC of 25", 2);
749  temp->setBinLabel(2, "Gap word", 2);
750  temp->setBinLabel(3, "Dummy word", 2);
751  temp->setBinLabel(4, "FIFO full", 2);
752  temp->setBinLabel(5, "Timeout", 2);
753  temp->setBinLabel(6, "Stack full", 2);
754  temp->setBinLabel(7, "Pre-cal issued", 2);
755  temp->setBinLabel(8, "Trigger clear or sync", 2);
756  temp->setBinLabel(9, "No token bit", 2);
757  temp->setBinLabel(10, "Overflow", 2);
758  temp->setBinLabel(11, "FSM error", 2);
759  temp->setBinLabel(12, "Invalid #ROCs", 2);
760  temp->setBinLabel(13, "Event number", 2);
761  temp->setBinLabel(14, "Slink header", 2);
762  temp->setBinLabel(15, "Slink trailer", 2);
763  temp->setBinLabel(16, "Event size", 2);
764  temp->setBinLabel(17, "Invalid channel#", 2);
765  temp->setBinLabel(18, "ROC value", 2);
766  temp->setBinLabel(19, "Dcol or pixel value", 2);
767  temp->setBinLabel(20, "Readout order", 2);
768  temp->setBinLabel(21, "CRC error", 2);
769  } else {
770  string fullpathname = iBooker.pwd() + "/" + (*iv);
771  temp = iGetter.get(fullpathname);
772  temp->Reset();
773  } // If I don't reset this one, then I instead start adding error
774  // codes..
775  }
776  sum_mes.push_back(temp);
777  }
778  }
779  if (sum_mes.empty()) {
780  edm::LogInfo("SiPixelActionExecutor") << " Summary MEs can not be created"
781  << "\n";
782  return;
783  }
784  vector<string> subdirs = iGetter.getSubdirs();
785  int ndet = 0;
786  for (vector<string>::const_iterator it = subdirs.begin(); it != subdirs.end(); it++) {
787  if ((*it).find("FED_") == string::npos)
788  continue;
789  iBooker.cd(*it);
790  iGetter.cd(*it);
791  string fedid = (*it).substr((*it).find("_") + 1);
792  std::istringstream isst;
793  isst.str(fedid);
794  isst >> ndet;
795  ndet++;
796  vector<string> contents = iGetter.getMEs();
797 
798  for (vector<MonitorElement *>::const_iterator isum = sum_mes.begin(); isum != sum_mes.end(); isum++) {
799  for (vector<string>::const_iterator im = contents.begin(); im != contents.end(); im++) {
800  if (((*im).find("FedChNErr") != std::string::npos &&
801  (*isum)->getName().find("FedChNErr") != std::string::npos) ||
802  ((*im).find("FedChLErr") != std::string::npos &&
803  (*isum)->getName().find("FedChLErr") != std::string::npos) ||
804  ((*im).find("FedETypeNErr") != std::string::npos &&
805  (*isum)->getName().find("FedETypeNErr") != std::string::npos)) {
806  string fullpathname = iBooker.pwd() + "/" + (*im);
807  MonitorElement *me = iGetter.get(fullpathname);
808  if (me) {
809  for (int i = 0; i != 37; i++) {
810  if ((*im).find("FedETypeNErr") != std::string::npos && i < 21)
811  (*isum)->Fill(ndet - 1, i, me->getBinContent(i + 1));
812  else
813  (*isum)->Fill(ndet - 1, i, me->getBinContent(i + 1));
814  }
815  }
816  }
817  string sname = ((*isum)->getName());
818  string tname = " ";
819  tname = sname.substr(7, (sname.find("_", 7) - 6));
820  if (((*im)).find(tname) == 0) {
821  string fullpathname = iBooker.pwd() + "/" + (*im);
822  MonitorElement *me = iGetter.get(fullpathname);
823 
824  if (me) {
825  if (me->getMean() > 0.) {
826  if (sname.find("_NErrors_") != string::npos) {
827  string path1 = fullpathname;
828  path1 = path1.replace(path1.find("NErrors"), 7, "errorType");
829  MonitorElement *me1 = iGetter.get(path1);
830  bool notReset = true;
831  if (me1) {
832  for (int jj = 1; jj < 16; jj++) {
833  if (me1->getBinContent(jj) > 0.) {
834  if (jj == 6) { // errorType=30 (reset)
835  string path2 = path1;
836  path2 = path2.replace(path2.find("errorType"), 9, "TBMMessage");
837  MonitorElement *me2 = iGetter.get(path2);
838  if (me2)
839  if (me2->getBinContent(6) > 0. || me2->getBinContent(7) > 0.)
840  notReset = false;
841  }
842  }
843  }
844  }
845  if (notReset)
846  (*isum)->setBinContent(ndet, (*isum)->getBinContent(ndet) + me1->getEntries());
847  } else
848  (*isum)->setBinContent(ndet, (*isum)->getBinContent(ndet) + me->getEntries());
849  }
850  (*isum)->setAxisTitle("FED #", 1);
851  string title = " ";
852  title = sname.substr(7, (sname.find("_", 7) - 7)) + " per FED";
853  (*isum)->setAxisTitle(title, 2);
854  }
855  break;
856  }
857  }
858  }
859  iBooker.goUp();
860  iGetter.setCurrentFolder(iBooker.pwd());
861  }
862  } else {
863  vector<string> subdirs = iGetter.getSubdirs();
864  for (vector<string>::const_iterator it = subdirs.begin(); it != subdirs.end(); it++) {
865  if ((*it).find("Endcap") != string::npos || (*it).find("Barrel") != string::npos)
866  continue;
867  iBooker.cd(*it);
868  iGetter.cd(*it);
869  fillFEDErrorSummary(iBooker, iGetter, dir_name, me_names);
870  iBooker.goUp();
871  iGetter.setCurrentFolder(iBooker.pwd());
872  }
873  }
874  // printing cout<<"...leaving
875  // SiPixelActionExecutor::fillFEDErrorSummary!"<<endl;
876 }
877 
878 //=============================================================================================================
880  DQMStore::IGetter &iGetter,
881  vector<string> &me_names,
882  bool isUpgrade) {
883  // cout<<"Entering
884  // SiPixelActionExecutor::fillGrandBarrelSummaryHistos...:"<<me_names.size()<<endl;
885  vector<MonitorElement *> gsum_mes;
886  string currDir = iBooker.pwd();
887  string path_name = iBooker.pwd();
888  string dir_name = path_name.substr(path_name.find_last_of("/") + 1);
889  if ((dir_name.find("DQMData") == 0) || (dir_name.find("Pixel") == 0) ||
890  (dir_name.find("AdditionalPixelErrors") == 0) || (dir_name.find("Endcap") == 0) ||
891  (dir_name.find("HalfCylinder") == 0) || (dir_name.find("Disk") == 0) || (dir_name.find("Blade") == 0) ||
892  (dir_name.find("Panel") == 0))
893  return;
894  vector<string> subdirs = iGetter.getSubdirs();
895  int nDirs = subdirs.size();
896  int iDir = 0;
897  int nbin = 0;
898  int nbin_i = 0;
899  int nbin_subdir = 0;
900  int cnt = 0;
901  bool first_subdir = true;
902  for (vector<string>::const_iterator it = subdirs.begin(); it != subdirs.end(); it++) {
903  cnt++;
904  iBooker.cd(*it);
905  iGetter.cd(*it);
906  vector<string> contents = iGetter.getMEs();
907 
908  iBooker.goUp();
909  iGetter.setCurrentFolder(iBooker.pwd());
910 
911  string prefix;
912  if (source_type_ == 0)
913  prefix = "SUMRAW";
914  else if (source_type_ == 1)
915  prefix = "SUMDIG";
916  else if (source_type_ == 2)
917  prefix = "SUMCLU";
918  else if (source_type_ == 3)
919  prefix = "SUMTRK";
920  else if (source_type_ == 4)
921  prefix = "SUMHIT";
922  else if (source_type_ >= 7 && source_type_ < 20)
923  prefix = "SUMCAL";
924  else if (source_type_ == 20)
925  prefix = "SUMOFF";
926 
927  for (vector<string>::const_iterator im = contents.begin(); im != contents.end(); im++) {
928  for (vector<string>::const_iterator iv = me_names.begin(); iv != me_names.end(); iv++) {
929  string var = "_" + (*iv) + "_";
930  if ((*im).find(var) != string::npos) {
931  if ((var == "_charge_" || var == "_nclusters_" || var == "_size_" || var == "_sizeX_" || var == "_sizeY_") &&
932  (*im).find("Track_") != string::npos)
933  continue;
934  string full_path = (*it) + "/" + (*im);
935  MonitorElement *me = iGetter.get(full_path);
936  if (!me)
937  continue;
938  if (source_type_ == 5 || source_type_ == 6) {
939  if ((*iv) == "errorType" || (*iv) == "NErrors" || (*iv) == "fullType" || (*iv) == "chanNmbr" ||
940  (*iv) == "TBMType" || (*iv) == "EvtNbr" || (*iv) == "evtSize" || (*iv) == "linkId" ||
941  (*iv) == "ROCId" || (*iv) == "DCOLId" || (*iv) == "PXId" || (*iv) == "ROCNmbr" ||
942  (*iv) == "TBMMessage" || (*iv) == "Type36Hitmap")
943  prefix = "SUMRAW";
944  else if ((*iv) == "ndigis" || (*iv) == "adc" || (*iv) == "ndigisFREQ" || (*iv) == "adcCOMB")
945  prefix = "SUMDIG";
946  else if ((*iv) == "nclusters" || (*iv) == "x" || (*iv) == "y" || (*iv) == "charge" ||
947  (*iv) == "chargeCOMB" || (*iv) == "size" || (*iv) == "sizeX" || (*iv) == "sizeY" ||
948  (*iv) == "minrow" || (*iv) == "maxrow" || (*iv) == "mincol" || (*iv) == "maxcol")
949  prefix = "SUMCLU";
950  if (currDir.find("Track") != string::npos)
951  prefix = "SUMTRK";
952  else if ((*iv) == "residualX_mean" || (*iv) == "residualY_mean" || (*iv) == "residualX_RMS" ||
953  (*iv) == "residualY_RMS")
954  prefix = "SUMTRK";
955  else if ((*iv) == "ClustX" || (*iv) == "ClustY" || (*iv) == "nRecHits" || (*iv) == "ErrorX" ||
956  (*iv) == "ErrorY")
957  prefix = "SUMHIT";
958  else if ((*iv) == "Gain1d_mean" || (*iv) == "GainChi2NDF1d_mean" || (*iv) == "GainChi2Prob1d_mean" ||
959  (*iv) == "Pedestal1d_mean" || (*iv) == "ScurveChi2ProbSummary_mean" ||
960  (*iv) == "ScurveFitResultSummary_mean" || (*iv) == "ScurveSigmasSummary_mean" ||
961  (*iv) == "ScurveThresholdSummary_mean" || (*iv) == "Gain1d_RMS" || (*iv) == "GainChi2NDF1d_RMS" ||
962  (*iv) == "GainChi2Prob1d_RMS" || (*iv) == "Pedestal1d_RMS" || (*iv) == "GainNPoints1d_mean" ||
963  (*iv) == "GainNPoints1d_RMS" || (*iv) == "GainHighPoint1d_mean" ||
964  (*iv) == "GainHighPoint1d_RMS" || (*iv) == "GainLowPoint1d_mean" ||
965  (*iv) == "GainLowPoint1d_RMS" || (*iv) == "GainEndPoint1d_mean" || (*iv) == "GainEndPoint1d_RMS" ||
966  (*iv) == "GainFitResult2d_mean" || (*iv) == "GainFitResult2d_RMS" ||
967  (*iv) == "GainDynamicRange2d_mean" || (*iv) == "GainDynamicRange2d_RMS" ||
968  (*iv) == "GainSaturate2d_mean" || (*iv) == "GainSaturate2d_RMS" ||
969  (*iv) == "ScurveChi2ProbSummary_RMS" || (*iv) == "ScurveFitResultSummary_RMS" ||
970  (*iv) == "ScurveSigmasSummary_RMS" || (*iv) == "ScurveThresholdSummary_RMS" ||
971  (*iv) == "pixelAliveSummary_mean" || (*iv) == "pixelAliveSummary_FracOfPerfectPix" ||
972  (*iv) == "SiPixelErrorsCalibDigis_NCalibErrors")
973  prefix = "SUMCAL";
974  } // end source_type if
975 
976  if (first_subdir && !isUpgrade) {
977  nbin = me->getTH1F()->GetNbinsX();
978  string me_name = prefix + "_" + (*iv) + "_" + dir_name;
979  if ((*iv) == "adcCOMB" || (*iv) == "chargeCOMB")
980  me_name = "ALLMODS_" + (*iv) + "_" + dir_name;
981  else if (prefix == "SUMOFF" && dir_name == "Barrel")
982  nbin = 192;
983  else if ((*iv) == "adcCOMB")
984  nbin = 256;
985  else if (dir_name == "Barrel")
986  nbin = 768;
987  else if (prefix == "SUMOFF" && dir_name.find("Shell") != string::npos)
988  nbin = 48;
989  else if (dir_name.find("Shell") != string::npos)
990  nbin = 192;
991  else
992  nbin = nbin * nDirs;
993 
994  getGrandSummaryME(iBooker, iGetter, nbin, me_name, gsum_mes);
995  } else if (first_subdir && isUpgrade) {
996  nbin = me->getTH1F()->GetNbinsX();
997  string me_name = prefix + "_" + (*iv) + "_" + dir_name;
998  if ((*iv) == "adcCOMB" || (*iv) == "chargeCOMB")
999  me_name = "ALLMODS_" + (*iv) + "_" + dir_name;
1000  else if (prefix == "SUMOFF" && dir_name == "Barrel")
1001  nbin = 296;
1002  else if ((*iv) == "adcCOMB")
1003  nbin = 256;
1004  else if (dir_name == "Barrel")
1005  nbin = 1184;
1006  else if (prefix == "SUMOFF" && dir_name.find("Shell") != string::npos)
1007  nbin = 74;
1008  else if (dir_name.find("Shell") != string::npos)
1009  nbin = 296;
1010  else
1011  nbin = nbin * nDirs;
1012 
1013  getGrandSummaryME(iBooker, iGetter, nbin, me_name, gsum_mes);
1014  }
1015 
1016  for (vector<MonitorElement *>::const_iterator igm = gsum_mes.begin(); igm != gsum_mes.end(); igm++) {
1017  if ((*igm)->getName().find(var) != string::npos) {
1018  if (prefix == "SUMOFF")
1019  (*igm)->setAxisTitle("Ladders", 1);
1020  else if ((*igm)->getName().find("adcCOMB_") != string::npos)
1021  (*igm)->setAxisTitle("Digi charge [ADC]", 1);
1022  else if ((*igm)->getName().find("chargeCOMB_") != string::npos)
1023  (*igm)->setAxisTitle("Cluster charge [kilo electrons]", 1);
1024  else
1025  (*igm)->setAxisTitle("Modules", 1);
1026 
1027  // Setting title
1028 
1029  string title = "";
1030  if ((*igm)->getName().find("NErrors_") != string::npos && prefix == "SUMOFF")
1031  title = "Total number of errors per Ladder";
1032  else if ((*igm)->getName().find("NErrors_") != string::npos && prefix == "SUMRAW")
1033  title = "Total number of errors per Module";
1034  else if (prefix == "SUMOFF")
1035  title = "mean " + (*iv) + " per Ladder";
1036  else if ((*igm)->getName().find("FREQ_") != string::npos && prefix != "SUMOFF")
1037  title = "NEvents with digis per Module";
1038  else if ((*igm)->getName().find("FREQ_") != string::npos && prefix == "SUMOFF")
1039  title = "NEvents with digis per Ladder/Blade";
1040  else if ((*igm)->getName().find("adcCOMB_") != string::npos)
1041  title = "NDigis";
1042  else if ((*igm)->getName().find("chargeCOMB_") != string::npos)
1043  title = "NClusters";
1044  else
1045  title = "mean " + (*iv) + " per Module";
1046  (*igm)->setAxisTitle(title, 2);
1047 
1048  // Setting binning
1049  if (!isUpgrade) {
1050  if ((*igm)->getName().find("ALLMODS_adcCOMB_") != string::npos) {
1051  nbin_subdir = 128;
1052  } else if ((*igm)->getName().find("ALLMODS_chargeCOMB_") != string::npos) {
1053  nbin_subdir = 100;
1054  } else if ((*igm)->getName().find("Ladder") != string::npos) {
1055  nbin_i = 0;
1056  nbin_subdir = 4;
1057  } else if ((*igm)->getName().find("Layer") != string::npos) {
1058  nbin_i = (cnt - 1) * 4;
1059  nbin_subdir = 4;
1060  } else if ((*igm)->getName().find("Shell") != string::npos) {
1061  if (prefix != "SUMOFF") {
1062  if (iDir == 0) {
1063  nbin_i = 0;
1064  nbin_subdir = 40;
1065  } else if (iDir == 1) {
1066  nbin_i = 40;
1067  nbin_subdir = 64;
1068  } else if (iDir == 2) {
1069  nbin_i = 104;
1070  nbin_subdir = 88;
1071  }
1072  } else {
1073  if (iDir == 0) {
1074  nbin_i = 0;
1075  nbin_subdir = 10;
1076  } else if (iDir == 1) {
1077  nbin_i = 10;
1078  nbin_subdir = 16;
1079  } else if (iDir == 2) {
1080  nbin_i = 26;
1081  nbin_subdir = 22;
1082  }
1083  }
1084  } else if ((*igm)->getName().find("Barrel") != string::npos) {
1085  if (prefix != "SUMOFF") {
1086  if (iDir == 0) {
1087  nbin_i = 0;
1088  nbin_subdir = 192;
1089  } else if (iDir == 1) {
1090  nbin_i = 192;
1091  nbin_subdir = 192;
1092  } else if (iDir == 2) {
1093  nbin_i = 384;
1094  nbin_subdir = 192;
1095  } else if (iDir == 3) {
1096  nbin_i = 576;
1097  nbin_subdir = 192;
1098  }
1099  } else {
1100  if (iDir == 0) {
1101  nbin_i = 0;
1102  nbin_subdir = 48;
1103  } else if (iDir == 1) {
1104  nbin_i = 48;
1105  nbin_subdir = 48;
1106  } else if (iDir == 2) {
1107  nbin_i = 96;
1108  nbin_subdir = 48;
1109  } else if (iDir == 3) {
1110  nbin_i = 144;
1111  nbin_subdir = 48;
1112  }
1113  }
1114  }
1115  } else if (isUpgrade) {
1116  if ((*igm)->getName().find("ALLMODS_adcCOMB_") != string::npos) {
1117  nbin_subdir = 128;
1118  } else if ((*igm)->getName().find("ALLMODS_chargeCOMB_") != string::npos) {
1119  nbin_subdir = 100;
1120  } else if ((*igm)->getName().find("Ladder") != string::npos) {
1121  nbin_i = 0;
1122  nbin_subdir = 4;
1123  } else if ((*igm)->getName().find("Layer") != string::npos) {
1124  nbin_i = (cnt - 1) * 4;
1125  nbin_subdir = 4;
1126  } else if ((*igm)->getName().find("Shell") != string::npos) {
1127  if (prefix != "SUMOFF") {
1128  if (iDir == 0) {
1129  nbin_i = 0;
1130  nbin_subdir = 24;
1131  } // 40(2*20)-->24(2*12)
1132  else if (iDir == 1) {
1133  nbin_i = 24;
1134  nbin_subdir = 56;
1135  } // 64(32*2)-->56(2*28)
1136  else if (iDir == 2) {
1137  nbin_i = 80;
1138  nbin_subdir = 88;
1139  } // 88(44*2)-->same88(44*2)
1140  else if (iDir == 3) {
1141  nbin_i = 168;
1142  nbin_subdir = 128;
1143  }
1144  } else {
1145  if (iDir == 0) {
1146  nbin_i = 0;
1147  nbin_subdir = 6;
1148  } // 10-->6
1149  else if (iDir == 1) {
1150  nbin_i = 6;
1151  nbin_subdir = 14;
1152  } // 16-->14
1153  else if (iDir == 2) {
1154  nbin_i = 20;
1155  nbin_subdir = 22;
1156  } // 22-->same22
1157  else if (iDir == 3) {
1158  nbin_i = 42;
1159  nbin_subdir = 32;
1160  }
1161  }
1162  } else if ((*igm)->getName().find("Barrel") != string::npos) {
1163  if (prefix != "SUMOFF") {
1164  if (iDir == 0) {
1165  nbin_i = 0;
1166  nbin_subdir = 296;
1167  } // 192=76 8/4-->296=1184/4
1168  else if (iDir == 1) {
1169  nbin_i = 296;
1170  nbin_subdir = 296;
1171  } // 296*2,*3,*4=1184
1172  else if (iDir == 2) {
1173  nbin_i = 592;
1174  nbin_subdir = 296;
1175  } else if (iDir == 3) {
1176  nbin_i = 888;
1177  nbin_subdir = 296;
1178  } else if (iDir == 4) {
1179  nbin_i = 1184;
1180  nbin_subdir = 296;
1181  }
1182  } else {
1183  if (iDir == 0) {
1184  nbin_i = 0;
1185  nbin_subdir = 74;
1186  } // 48=192/4-->74=296/4
1187  else if (iDir == 1) {
1188  nbin_i = 74;
1189  nbin_subdir = 74;
1190  } // 74*2,...*4=296
1191  else if (iDir == 2) {
1192  nbin_i = 148;
1193  nbin_subdir = 74;
1194  } else if (iDir == 3) {
1195  nbin_i = 222;
1196  nbin_subdir = 74;
1197  } else if (iDir == 4) {
1198  nbin_i = 296;
1199  nbin_subdir = 74;
1200  }
1201  }
1202  }
1203  }
1204 
1205  if ((*igm)->getName().find("ndigisFREQ") == string::npos) {
1206  if (((*igm)->getName().find("adcCOMB") != string::npos &&
1207  me->getName().find("adcCOMB") != string::npos) ||
1208  ((*igm)->getName().find("chargeCOMB") != string::npos &&
1209  me->getName().find("chargeCOMB") != string::npos)) {
1210  (*igm)->getTH1F()->Add(me->getTH1F());
1211  } else if (((*igm)->getName().find("charge_") != string::npos &&
1212  (*igm)->getName().find("Track_") == string::npos &&
1213  me->getName().find("charge_") != string::npos &&
1214  me->getName().find("Track_") == string::npos) ||
1215  ((*igm)->getName().find("nclusters_") != string::npos &&
1216  (*igm)->getName().find("Track_") == string::npos &&
1217  me->getName().find("nclusters_") != string::npos &&
1218  me->getName().find("Track_") == string::npos) ||
1219  ((*igm)->getName().find("size_") != string::npos &&
1220  (*igm)->getName().find("Track_") == string::npos &&
1221  me->getName().find("size_") != string::npos &&
1222  me->getName().find("Track_") == string::npos) ||
1223  ((*igm)->getName().find("charge_OffTrack_") != string::npos &&
1224  me->getName().find("charge_OffTrack_") != string::npos) ||
1225  ((*igm)->getName().find("nclusters_OffTrack_") != string::npos &&
1226  me->getName().find("nclusters_OffTrack_") != string::npos) ||
1227  ((*igm)->getName().find("size_OffTrack_") != string::npos &&
1228  me->getName().find("size_OffTrack_") != string::npos) ||
1229  ((*igm)->getName().find("charge_OnTrack_") != string::npos &&
1230  me->getName().find("charge_OnTrack_") != string::npos) ||
1231  ((*igm)->getName().find("nclusters_OnTrack_") != string::npos &&
1232  me->getName().find("nclusters_OnTrack_") != string::npos) ||
1233  ((*igm)->getName().find("size_OnTrack_") != string::npos &&
1234  me->getName().find("size_OnTrack_") != string::npos) ||
1235  ((*igm)->getName().find("charge_") == string::npos &&
1236  (*igm)->getName().find("nclusters_") == string::npos &&
1237  (*igm)->getName().find("size_") == string::npos)) {
1238  for (int k = 1; k < nbin_subdir + 1; k++)
1239  if (me->getBinContent(k) > 0)
1240  (*igm)->setBinContent(k + nbin_i, me->getBinContent(k));
1241  }
1242  } else if (me->getName().find("ndigisFREQ") != string::npos) {
1243  for (int k = 1; k < nbin_subdir + 1; k++)
1244  if (me->getBinContent(k) > 0)
1245  (*igm)->setBinContent(k + nbin_i, me->getBinContent(k));
1246  }
1247  } // end var in igm (gsum_mes)
1248  } // end igm loop
1249  } // end var in im (contents)
1250  } // end of iv loop
1251  } // end of im loop
1252  iDir++;
1253  first_subdir = false; // We are done processing the first directory, we
1254  // don't add any new MEs in the future passes.
1255  } // end of it loop (subdirs)
1256  // cout<<"...leaving
1257  // SiPixelActionExecutor::fillGrandBarrelSummaryHistos!"<<endl;
1258 }
1259 
1260 //=============================================================================================================
1262  DQMStore::IGetter &iGetter,
1263  vector<string> &me_names,
1264  bool isUpgrade) {
1265  // printing cout<<"Entering
1266  // SiPixelActionExecutor::fillGrandEndcapSummaryHistos..."<<endl;
1267  vector<MonitorElement *> gsum_mes;
1268  string currDir = iBooker.pwd();
1269  string path_name = iBooker.pwd();
1270  string dir_name = path_name.substr(path_name.find_last_of("/") + 1);
1271  if ((dir_name.find("DQMData") == 0) || (dir_name.find("Pixel") == 0) ||
1272  (dir_name.find("AdditionalPixelErrors") == 0) || (dir_name.find("Barrel") == 0) ||
1273  (dir_name.find("Shell") == 0) || (dir_name.find("Layer") == 0) || (dir_name.find("Ladder") == 0))
1274  return;
1275  vector<string> subdirs = iGetter.getSubdirs();
1276  int iDir = 0;
1277  int nbin = 0;
1278  int nbin_i = 0;
1279  int nbin_subdir = 0;
1280  int cnt = 0;
1281  bool first_subdir = true;
1282  for (vector<string>::const_iterator it = subdirs.begin(); it != subdirs.end(); it++) {
1283  cnt++;
1284  iBooker.cd(*it);
1285  iGetter.cd(*it);
1286  vector<string> contents = iGetter.getMEs();
1287  iBooker.goUp();
1288  iGetter.setCurrentFolder(iBooker.pwd());
1289 
1290  string prefix;
1291  if (source_type_ == 0)
1292  prefix = "SUMRAW";
1293  else if (source_type_ == 1)
1294  prefix = "SUMDIG";
1295  else if (source_type_ == 2)
1296  prefix = "SUMCLU";
1297  else if (source_type_ == 3)
1298  prefix = "SUMTRK";
1299  else if (source_type_ == 4)
1300  prefix = "SUMHIT";
1301  else if (source_type_ >= 7 && source_type_ < 20)
1302  prefix = "SUMCAL";
1303  else if (source_type_ == 20)
1304  prefix = "SUMOFF";
1305 
1306  for (vector<string>::const_iterator im = contents.begin(); im != contents.end(); im++) {
1307  for (vector<string>::const_iterator iv = me_names.begin(); iv != me_names.end(); iv++) {
1308  string var = "_" + (*iv) + "_";
1309  if ((*im).find(var) != string::npos) {
1310  if ((var == "_charge_" || var == "_nclusters_" || var == "_size_" || var == "_sizeX_" || var == "_sizeY_") &&
1311  (*im).find("Track_") != string::npos)
1312  continue;
1313  string full_path = (*it) + "/" + (*im);
1314  MonitorElement *me = iGetter.get(full_path);
1315  if (!me)
1316  continue;
1317  if (source_type_ == 5 || source_type_ == 6) {
1318  if ((*iv) == "errorType" || (*iv) == "NErrors" || (*iv) == "fullType" || (*iv) == "chanNmbr" ||
1319  (*iv) == "TBMType" || (*iv) == "EvtNbr" || (*iv) == "evtSize" || (*iv) == "linkId" ||
1320  (*iv) == "ROCId" || (*iv) == "DCOLId" || (*iv) == "PXId" || (*iv) == "ROCNmbr" ||
1321  (*iv) == "TBMMessage" || (*iv) == "Type36Hitmap")
1322  prefix = "SUMRAW";
1323  else if ((*iv) == "ndigis" || (*iv) == "adc" || (*iv) == "ndigisFREQ" || (*iv) == "adcCOMB")
1324  prefix = "SUMDIG";
1325  else if ((*iv) == "nclusters" || (*iv) == "x" || (*iv) == "y" || (*iv) == "charge" ||
1326  (*iv) == "chargeCOMB" || (*iv) == "size" || (*iv) == "sizeX" || (*iv) == "sizeY" ||
1327  (*iv) == "minrow" || (*iv) == "maxrow" || (*iv) == "mincol" || (*iv) == "maxcol")
1328  prefix = "SUMCLU";
1329  if (currDir.find("Track") != string::npos)
1330  prefix = "SUMTRK";
1331  else if ((*iv) == "residualX_mean" || (*iv) == "residualY_mean" || (*iv) == "residualX_RMS" ||
1332  (*iv) == "residualY_RMS")
1333  prefix = "SUMTRK";
1334  else if ((*iv) == "ClustX" || (*iv) == "ClustY" || (*iv) == "nRecHits" || (*iv) == "ErrorX" ||
1335  (*iv) == "ErrorY")
1336  prefix = "SUMHIT";
1337  else if ((*iv) == "Gain1d_mean" || (*iv) == "GainChi2NDF1d_mean" || (*iv) == "GainChi2Prob1d_mean" ||
1338  (*iv) == "Pedestal1d_mean" || (*iv) == "ScurveChi2ProbSummary_mean" ||
1339  (*iv) == "ScurveFitResultSummary_mean" || (*iv) == "ScurveSigmasSummary_mean" ||
1340  (*iv) == "ScurveThresholdSummary_mean" || (*iv) == "Gain1d_RMS" || (*iv) == "GainChi2NDF1d_RMS" ||
1341  (*iv) == "GainChi2Prob1d_RMS" || (*iv) == "Pedestal1d_RMS" || (*iv) == "GainNPoints1d_mean" ||
1342  (*iv) == "GainNPoints1d_RMS" || (*iv) == "GainHighPoint1d_mean" ||
1343  (*iv) == "GainHighPoint1d_RMS" || (*iv) == "GainLowPoint1d_mean" ||
1344  (*iv) == "GainLowPoint1d_RMS" || (*iv) == "GainEndPoint1d_mean" || (*iv) == "GainEndPoint1d_RMS" ||
1345  (*iv) == "GainFitResult2d_mean" || (*iv) == "GainFitResult2d_RMS" ||
1346  (*iv) == "GainDynamicRange2d_mean" || (*iv) == "GainDynamicRange2d_RMS" ||
1347  (*iv) == "GainSaturate2d_mean" || (*iv) == "GainSaturate2d_RMS" ||
1348  (*iv) == "ScurveChi2ProbSummary_RMS" || (*iv) == "ScurveFitResultSummary_RMS" ||
1349  (*iv) == "ScurveSigmasSummary_RMS" || (*iv) == "ScurveThresholdSummary_RMS" ||
1350  (*iv) == "pixelAliveSummary_mean" || (*iv) == "pixelAliveSummary_FracOfPerfectPix" ||
1351  (*iv) == "SiPixelErrorsCalibDigis_NCalibErrors")
1352  prefix = "SUMCAL";
1353  }
1354 
1355  if (first_subdir && !isUpgrade) {
1356  nbin = me->getTH1F()->GetNbinsX();
1357  string me_name = prefix + "_" + (*iv) + "_" + dir_name;
1358  if ((*iv) == "adcCOMB" || (*iv) == "chargeCOMB")
1359  me_name = "ALLMODS_" + (*iv) + "_" + dir_name;
1360  else if (prefix == "SUMOFF" && dir_name == "Endcap")
1361  nbin = 96;
1362  else if (dir_name == "Endcap")
1363  nbin = 672;
1364  else if (prefix == "SUMOFF" && dir_name.find("HalfCylinder") != string::npos)
1365  nbin = 24;
1366  else if (dir_name.find("HalfCylinder") != string::npos)
1367  nbin = 168;
1368  else if (prefix == "SUMOFF" && dir_name.find("Disk") != string::npos)
1369  nbin = 12;
1370  else if (dir_name.find("Disk") != string::npos)
1371  nbin = 84;
1372  else if (dir_name.find("Blade") != string::npos)
1373  nbin = 7;
1374  getGrandSummaryME(iBooker, iGetter, nbin, me_name, gsum_mes);
1375  } else if (first_subdir && isUpgrade) {
1376  nbin = me->getTH1F()->GetNbinsX();
1377  string me_name = prefix + "_" + (*iv) + "_" + dir_name;
1378  if ((*iv) == "adcCOMB" || (*iv) == "chargeCOMB")
1379  me_name = "ALLMODS_" + (*iv) + "_" + dir_name;
1380  else if (prefix == "SUMOFF" && dir_name == "Endcap")
1381  nbin = 336;
1382  else if (dir_name == "Endcap")
1383  nbin = 672;
1384  else if (prefix == "SUMOFF" && dir_name.find("HalfCylinder") != string::npos)
1385  nbin = 84;
1386  else if (dir_name.find("HalfCylinder") != string::npos)
1387  nbin = 168;
1388  else if (prefix == "SUMOFF" && dir_name.find("Disk") != string::npos)
1389  nbin = 28;
1390  else if (dir_name.find("Disk") != string::npos)
1391  nbin = 56;
1392  else if (dir_name.find("Blade") != string::npos)
1393  nbin = 2;
1394  getGrandSummaryME(iBooker, iGetter, nbin, me_name, gsum_mes);
1395  }
1396 
1397  for (vector<MonitorElement *>::const_iterator igm = gsum_mes.begin(); igm != gsum_mes.end(); igm++) {
1398  if ((*igm)->getName().find(var) != string::npos) {
1399  if (prefix == "SUMOFF")
1400  (*igm)->setAxisTitle("Blades", 1);
1401  else if ((*igm)->getName().find("adcCOMB_") != string::npos)
1402  (*igm)->setAxisTitle("Digi charge [ADC]", 1);
1403  else if ((*igm)->getName().find("chargeCOMB_") != string::npos)
1404  (*igm)->setAxisTitle("Cluster charge [kilo electrons]", 1);
1405  else
1406  (*igm)->setAxisTitle("Modules", 1);
1407  string title = "";
1408  if ((*igm)->getName().find("NErrors_") != string::npos && prefix == "SUMOFF")
1409  title = "Total number of errors per Blade";
1410  else if ((*igm)->getName().find("NErrors_") != string::npos && prefix == "SUMRAW")
1411  title = "Total number of errors per Module";
1412  else if (prefix == "SUMOFF")
1413  title = "mean " + (*iv) + " per Blade";
1414  else if ((*igm)->getName().find("FREQ_") != string::npos)
1415  title = "NEvents with digis per Module";
1416  else if ((*igm)->getName().find("adcCOMB_") != string::npos)
1417  title = "NDigis";
1418  else if ((*igm)->getName().find("chargeCOMB_") != string::npos)
1419  title = "NClusters";
1420  else
1421  title = "mean " + (*iv) + " per Module";
1422  (*igm)->setAxisTitle(title, 2);
1423  nbin_i = 0;
1424  if (!isUpgrade) {
1425  if ((*igm)->getName().find("ALLMODS_adcCOMB_") != string::npos) {
1426  nbin_subdir = 128;
1427  } else if ((*igm)->getName().find("ALLMODS_chargeCOMB_") != string::npos) {
1428  nbin_subdir = 100;
1429  } else if ((*igm)->getName().find("Panel_") != string::npos) {
1430  nbin_subdir = 7;
1431  } else if ((*igm)->getName().find("Blade") != string::npos) {
1432  if ((*im).find("_1") != string::npos)
1433  nbin_subdir = 4;
1434  if ((*im).find("_2") != string::npos) {
1435  nbin_i = 4;
1436  nbin_subdir = 3;
1437  }
1438  } else if ((*igm)->getName().find("Disk") != string::npos) {
1439  nbin_i = ((cnt - 1) % 12) * 7;
1440  nbin_subdir = 7;
1441  } else if ((*igm)->getName().find("HalfCylinder") != string::npos) {
1442  if (prefix != "SUMOFF") {
1443  nbin_subdir = 84;
1444  if ((*im).find("_2") != string::npos)
1445  nbin_i = 84;
1446  } else {
1447  nbin_subdir = 12;
1448  if ((*im).find("_2") != string::npos)
1449  nbin_i = 12;
1450  }
1451  } else if ((*igm)->getName().find("Endcap") != string::npos) {
1452  if (prefix != "SUMOFF") {
1453  nbin_subdir = 168;
1454  if ((*im).find("_mO") != string::npos)
1455  nbin_i = 168;
1456  if ((*im).find("_pI") != string::npos)
1457  nbin_i = 336;
1458  if ((*im).find("_pO") != string::npos)
1459  nbin_i = 504;
1460  } else {
1461  nbin_subdir = 24;
1462  if ((*im).find("_mO") != string::npos)
1463  nbin_i = 24;
1464  if ((*im).find("_pI") != string::npos)
1465  nbin_i = 48;
1466  if ((*im).find("_pO") != string::npos)
1467  nbin_i = 72;
1468  }
1469  }
1470  } else if (isUpgrade) {
1471  if ((*igm)->getName().find("ALLMODS_adcCOMB_") != string::npos) {
1472  nbin_subdir = 128;
1473  } else if ((*igm)->getName().find("ALLMODS_chargeCOMB_") != string::npos) {
1474  nbin_subdir = 100;
1475  } else if ((*igm)->getName().find("Panel_") != string::npos) {
1476  nbin_subdir = 2;
1477  } else if ((*igm)->getName().find("Blade") != string::npos) {
1478  if ((*im).find("_1") != string::npos)
1479  nbin_subdir = 1;
1480  if ((*im).find("_2") != string::npos) {
1481  nbin_i = 1;
1482  nbin_subdir = 1;
1483  }
1484  } else if ((*igm)->getName().find("Disk") != string::npos) {
1485  nbin_i = ((cnt - 1) % 28) * 2;
1486  nbin_subdir = 2;
1487  } else if ((*igm)->getName().find("HalfCylinder") != string::npos) {
1488  if (prefix != "SUMOFF") {
1489  nbin_subdir = 56;
1490  if ((*im).find("_2") != string::npos)
1491  nbin_i = 56;
1492  if ((*im).find("_3") != string::npos)
1493  nbin_i = 112;
1494  } else {
1495  nbin_subdir = 28;
1496  if ((*im).find("_2") != string::npos)
1497  nbin_i = 28;
1498  if ((*im).find("_3") != string::npos)
1499  nbin_i = 56;
1500  }
1501  } else if ((*igm)->getName().find("Endcap") != string::npos) {
1502  if (prefix != "SUMOFF") {
1503  nbin_subdir = 168;
1504  if ((*im).find("_mO") != string::npos)
1505  nbin_i = 168;
1506  if ((*im).find("_pI") != string::npos)
1507  nbin_i = 336;
1508  if ((*im).find("_pO") != string::npos)
1509  nbin_i = 504;
1510  } else {
1511  nbin_subdir = 84;
1512  if ((*im).find("_mO") != string::npos)
1513  nbin_i = 84;
1514  if ((*im).find("_pI") != string::npos)
1515  nbin_i = 168;
1516  if ((*im).find("_pO") != string::npos)
1517  nbin_i = 252;
1518  }
1519  }
1520  }
1521 
1522  if ((*igm)->getName().find("ndigisFREQ") == string::npos) {
1523  if (((*igm)->getName().find("adcCOMB") != string::npos &&
1524  me->getName().find("adcCOMB") != string::npos) ||
1525  ((*igm)->getName().find("chargeCOMB") != string::npos &&
1526  me->getName().find("chargeCOMB") != string::npos)) {
1527  (*igm)->getTH1F()->Add(me->getTH1F());
1528  } else if (((*igm)->getName().find("charge_") != string::npos &&
1529  (*igm)->getName().find("Track_") == string::npos &&
1530  me->getName().find("charge_") != string::npos &&
1531  me->getName().find("Track_") == string::npos) ||
1532  ((*igm)->getName().find("nclusters_") != string::npos &&
1533  (*igm)->getName().find("Track_") == string::npos &&
1534  me->getName().find("nclusters_") != string::npos &&
1535  me->getName().find("Track_") == string::npos) ||
1536  ((*igm)->getName().find("size_") != string::npos &&
1537  (*igm)->getName().find("Track_") == string::npos &&
1538  me->getName().find("size_") != string::npos &&
1539  me->getName().find("Track_") == string::npos) ||
1540  ((*igm)->getName().find("charge_OffTrack_") != string::npos &&
1541  me->getName().find("charge_OffTrack_") != string::npos) ||
1542  ((*igm)->getName().find("nclusters_OffTrack_") != string::npos &&
1543  me->getName().find("nclusters_OffTrack_") != string::npos) ||
1544  ((*igm)->getName().find("size_OffTrack_") != string::npos &&
1545  me->getName().find("size_OffTrack_") != string::npos) ||
1546  ((*igm)->getName().find("charge_OnTrack_") != string::npos &&
1547  me->getName().find("charge_OnTrack_") != string::npos) ||
1548  ((*igm)->getName().find("nclusters_OnTrack_") != string::npos &&
1549  me->getName().find("nclusters_OnTrack_") != string::npos) ||
1550  ((*igm)->getName().find("size_OnTrack_") != string::npos &&
1551  me->getName().find("size_OnTrack_") != string::npos) ||
1552  ((*igm)->getName().find("charge_") == string::npos &&
1553  (*igm)->getName().find("nclusters_") == string::npos &&
1554  (*igm)->getName().find("size_") == string::npos)) {
1555  for (int k = 1; k < nbin_subdir + 1; k++)
1556  if (me->getBinContent(k) > 0)
1557  (*igm)->setBinContent(k + nbin_i, me->getBinContent(k));
1558  }
1559  } else if (me->getName().find("ndigisFREQ") != string::npos) {
1560  for (int k = 1; k < nbin_subdir + 1; k++)
1561  if (me->getBinContent(k) > 0)
1562  (*igm)->setBinContent(k + nbin_i, me->getBinContent(k));
1563  }
1564  // }// for
1565  }
1566  }
1567  }
1568  }
1569  }
1570 
1571  iDir++;
1572  first_subdir = false; // We are done processing the first directory, we
1573  // don't add any new MEs in the future passes.
1574  } // end for it (subdirs)
1575 }
1576 //=============================================================================================================
1577 //
1578 // -- Get Summary ME
1579 //
1581  DQMStore::IBooker &iBooker, DQMStore::IGetter &iGetter, int nbin, string &me_name, vector<MonitorElement *> &mes) {
1582  // printing cout<<"Entering SiPixelActionExecutor::getGrandSummaryME for:
1583  // "<<me_name<<endl;
1584  if ((iBooker.pwd()).find("Pixel") == string::npos)
1585  return; // If one doesn't find pixel
1586  vector<string> contents = iGetter.getMEs();
1587 
1588  for (vector<string>::const_iterator it = contents.begin(); it != contents.end(); it++) {
1589  // printing cout<<"in grand summary me: "<<me_name<<","<<(*it)<<endl;
1590  if ((*it).find(me_name) == 0) {
1591  string fullpathname = iBooker.pwd() + "/" + me_name;
1592  MonitorElement *me = iGetter.get(fullpathname);
1593 
1594  if (me) {
1595  me->Reset();
1596  mes.push_back(me);
1597  return;
1598  }
1599  }
1600  }
1601 
1602  MonitorElement *temp_me(nullptr);
1603  if (me_name.find("ALLMODS_adcCOMB_") != string::npos)
1604  temp_me = iBooker.book1D(me_name.c_str(), me_name.c_str(), 128, 0, 256);
1605  else if (me_name.find("ALLMODS_chargeCOMB_") != string::npos)
1606  temp_me = iBooker.book1D(me_name.c_str(), me_name.c_str(), 100, 0, 200);
1607  else
1608  temp_me = iBooker.book1D(me_name.c_str(), me_name.c_str(), nbin, 1., nbin + 1.);
1609  if (temp_me)
1610  mes.push_back(temp_me);
1611 
1612  // if(temp_me) cout<<"finally found grand ME: "<<me_name<<endl;
1613 }
1614 
1615 //=============================================================================================================
1616 //
1617 // -- Get Summary ME
1618 //
1620  DQMStore::IGetter &iGetter,
1621  string me_name,
1622  bool isUpgrade) {
1623  // printing cout<<"Entering SiPixelActionExecutor::getSummaryME for:
1624  // "<<me_name<<endl;
1625  MonitorElement *me = nullptr;
1626  if ((iBooker.pwd()).find("Pixel") == string::npos)
1627  return me;
1628  vector<string> contents = iGetter.getMEs();
1629 
1630  for (vector<string>::const_iterator it = contents.begin(); it != contents.end(); it++) {
1631  if ((*it).find(me_name) == 0) {
1632  string fullpathname = iBooker.pwd() + "/" + (*it);
1633  me = iGetter.get(fullpathname);
1634  if (me) {
1635  me->Reset();
1636  return me;
1637  }
1638  }
1639  }
1640  contents.clear();
1641  if (!isUpgrade) {
1642  if (me_name.find("SUMOFF") == string::npos) {
1643  if (me_name.find("Blade_") != string::npos)
1644  me = iBooker.book1D(me_name.c_str(), me_name.c_str(), 7, 1., 8.);
1645  else
1646  me = iBooker.book1D(me_name.c_str(), me_name.c_str(), 4, 1., 5.);
1647  } else if (me_name.find("Layer_1") != string::npos) {
1648  me = iBooker.book1D(me_name.c_str(), me_name.c_str(), 10, 1., 11.);
1649  } else if (me_name.find("Layer_2") != string::npos) {
1650  me = iBooker.book1D(me_name.c_str(), me_name.c_str(), 16, 1., 17.);
1651  } else if (me_name.find("Layer_3") != string::npos) {
1652  me = iBooker.book1D(me_name.c_str(), me_name.c_str(), 22, 1., 23.);
1653  } else if (me_name.find("Disk_") != string::npos) {
1654  me = iBooker.book1D(me_name.c_str(), me_name.c_str(), 12, 1., 13.);
1655  }
1656  } // endifNOTUpgrade
1657  else if (isUpgrade) {
1658  if (me_name.find("SUMOFF") == string::npos) {
1659  if (me_name.find("Blade_") != string::npos)
1660  me = iBooker.book1D(me_name.c_str(), me_name.c_str(), 2, 1., 3.);
1661  else
1662  me = iBooker.book1D(me_name.c_str(), me_name.c_str(), 1, 1., 2.);
1663  } else if (me_name.find("Layer_1") != string::npos) {
1664  me = iBooker.book1D(me_name.c_str(), me_name.c_str(), 6, 1., 7.);
1665  } else if (me_name.find("Layer_2") != string::npos) {
1666  me = iBooker.book1D(me_name.c_str(), me_name.c_str(), 14, 1., 15.);
1667  } else if (me_name.find("Layer_3") != string::npos) {
1668  me = iBooker.book1D(me_name.c_str(), me_name.c_str(), 22, 1., 23.);
1669  } else if (me_name.find("Layer_4") != string::npos) {
1670  me = iBooker.book1D(me_name.c_str(), me_name.c_str(), 32, 1., 33.);
1671  } else if (me_name.find("Disk_") != string::npos) {
1672  me = iBooker.book1D(me_name.c_str(), me_name.c_str(), 28, 1., 29.);
1673  }
1674  } // endifUpgrade
1675 
1676  return me;
1677 }
1678 
1679 //=============================================================================================================
1681  DQMStore::IGetter &iGetter,
1682  string me_name) {
1683  // printing cout<<"Entering SiPixelActionExecutor::getFEDSummaryME..."<<endl;
1684  MonitorElement *me = nullptr;
1685  if ((iBooker.pwd()).find("Pixel") == string::npos)
1686  return me;
1687  vector<string> contents = iGetter.getMEs();
1688 
1689  for (vector<string>::const_iterator it = contents.begin(); it != contents.end(); it++) {
1690  if ((*it).find(me_name) == 0) {
1691  string fullpathname = iBooker.pwd() + "/" + (*it);
1692 
1693  me = iGetter.get(fullpathname);
1694 
1695  if (me) {
1696  me->Reset();
1697  return me;
1698  }
1699  }
1700  }
1701  contents.clear();
1702  me = iBooker.book1D(me_name.c_str(), me_name.c_str(), 40, -0.5, 39.5);
1703 
1704  return me;
1705 }
1706 
1707 //=============================================================================================================
1709  DQMStore::IGetter &iGetter,
1710  bool hiRes,
1711  bool isbarrel) // Polymorphism
1712 {
1713  if (Tier0Flag_)
1714  return;
1715  vector<string> subdirs = iGetter.getSubdirs();
1716  for (vector<string>::const_iterator it = subdirs.begin(); it != subdirs.end(); it++) {
1717  if (isbarrel && (*it).find("Barrel") == string::npos)
1718  continue;
1719  if (!isbarrel && (*it).find("Endcap") == string::npos)
1720  continue;
1721 
1722  if ((*it).find("Module_") != string::npos)
1723  continue;
1724  if ((*it).find("Panel_") != string::npos)
1725  continue;
1726  if ((*it).find("Ladder_") != string::npos)
1727  continue;
1728  if ((*it).find("Blade_") != string::npos)
1729  continue;
1730  if ((*it).find("Layer_") != string::npos)
1731  continue;
1732  if ((*it).find("Disk_") != string::npos)
1733  continue;
1734  iBooker.cd(*it);
1735  iGetter.cd(*it);
1736  bookOccupancyPlots(iBooker, iGetter, hiRes, isbarrel);
1737  if (!hiRes) {
1738  // occupancyprinting cout<<"booking low res barrel occ plot now!"<<endl;
1739  OccupancyMap = iBooker.book2D((isbarrel ? "barrelOccupancyMap" : "endcapOccupancyMap"),
1740  "Barrel Digi Occupancy Map (4 pix per bin)",
1741  isbarrel ? 208 : 130,
1742  0.,
1743  isbarrel ? 416. : 260.,
1744  80,
1745  0.,
1746  160.);
1747  } else {
1748  // occupancyprinting cout<<"booking high res barrel occ plot now!"<<endl;
1749  OccupancyMap = iBooker.book2D((isbarrel ? "barrelOccupancyMap" : "endcapOccupancyMap"),
1750  "Barrel Digi Occupancy Map (1 pix per bin)",
1751  isbarrel ? 416 : 260,
1752  0.,
1753  isbarrel ? 416. : 260.,
1754  160,
1755  0.,
1756  160.);
1757  }
1758  OccupancyMap->setAxisTitle("Columns", 1);
1759  OccupancyMap->setAxisTitle("Rows", 2);
1760 
1761  iBooker.goUp();
1762  iGetter.setCurrentFolder(iBooker.pwd());
1763  }
1764 }
1765 //=============================================================================================================
1767  if (Tier0Flag_)
1768  return;
1769  // Barrel
1770  iGetter.cd();
1771  iBooker.cd();
1772  iGetter.setCurrentFolder("Pixel");
1773  iBooker.setCurrentFolder("Pixel");
1774  this->bookOccupancyPlots(iBooker, iGetter, hiRes, true);
1775 
1776  // Endcap
1777  iGetter.cd();
1778  iBooker.cd();
1779  iGetter.setCurrentFolder("Pixel");
1780  iBooker.setCurrentFolder("Pixel");
1781  this->bookOccupancyPlots(iBooker, iGetter, hiRes, false);
1782 }
1783 
1785  // std::cout<<"entering SiPixelActionExecutor::createOccupancy..."<<std::endl;
1786  if (Tier0Flag_)
1787  return;
1788  iBooker.cd();
1789  iGetter.cd();
1790  fillOccupancy(iBooker, iGetter, true);
1791  iBooker.cd();
1792  iGetter.cd();
1793  fillOccupancy(iBooker, iGetter, false);
1794  iBooker.cd();
1795  iGetter.cd();
1796 
1797  // std::cout<<"leaving SiPixelActionExecutor::createOccupancy..."<<std::endl;
1798 }
1799 
1800 //=============================================================================================================
1801 
1803  // occupancyprinting cout<<"entering
1804  // SiPixelActionExecutor::fillOccupancy..."<<std::endl;
1805  if (Tier0Flag_)
1806  return;
1807  string currDir = iBooker.pwd();
1808  string dname = currDir.substr(currDir.find_last_of("/") + 1);
1809 
1810  if (dname.find("Layer_") != string::npos || dname.find("Disk_") != string::npos) {
1811  vector<string> meVec = iGetter.getMEs();
1812  for (vector<string>::const_iterator it = meVec.begin(); it != meVec.end(); it++) {
1813  string full_path = currDir + "/" + (*it);
1814  if (full_path.find("hitmap_siPixelDigis") != string::npos) { // If we have the hitmap ME
1815  MonitorElement *me = iGetter.get(full_path);
1816  if (!me)
1817  continue;
1818  string path = full_path;
1819  while (path.find_last_of("/") != 5) // Stop before Pixel/
1820  {
1821  path = path.substr(0, path.find_last_of("/"));
1822  // cout << "\t" <<
1823  // path
1824  //<< endl;
1825  OccupancyMap = iGetter.get(path + "/" + (isbarrel ? "barrel" : "endcap") + "OccupancyMap");
1826 
1827  if (OccupancyMap) {
1828  for (int i = 1; i != me->getNbinsX() + 1; i++)
1829  for (int j = 1; j != me->getNbinsY() + 1; j++) {
1830  float previous = OccupancyMap->getBinContent(i, j);
1831  OccupancyMap->setBinContent(i, j, previous + me->getBinContent(i, j));
1832  }
1833  OccupancyMap->getTH2F()->SetEntries(OccupancyMap->getTH2F()->Integral());
1834  }
1835  }
1836  }
1837  }
1838  } else {
1839  vector<string> subdirs = iGetter.getSubdirs();
1840  for (vector<string>::const_iterator it = subdirs.begin(); it != subdirs.end(); it++) {
1841  iGetter.cd(*it);
1842  iBooker.cd(*it);
1843  if (*it != "Pixel" &&
1844  ((isbarrel && (*it).find("Barrel") == string::npos) || (!isbarrel && (*it).find("Endcap") == string::npos)))
1845  continue;
1846  fillOccupancy(iBooker, iGetter, isbarrel);
1847  iBooker.goUp();
1848  iGetter.setCurrentFolder(iBooker.pwd());
1849  }
1850  }
1851 
1852  // occupancyprinting cout<<"leaving
1853  // SiPixelActionExecutor::fillOccupancy..."<<std::endl;
1854 }
1855 
1856 //=============================================================================================================
1857 
1859  // occupancyprinting cout<<"entering
1860  // SiPixelActionExecutor::normaliseAvDigiOcc..."<<std::endl;
1861 
1862  iGetter.cd();
1863 
1864  MonitorElement *roccupancyPlot = iGetter.get("Pixel/averageDigiOccupancy");
1865 
1866  float totalDigisBPIX = 0.;
1867  float totalDigisFPIX = 0.;
1868  for (int i = 1; i != 41; i++) {
1869  if (i < 33)
1870  totalDigisBPIX += roccupancyPlot->getBinContent(i);
1871  else
1872  totalDigisFPIX += roccupancyPlot->getBinContent(i);
1873  }
1874  float averageBPIXOcc = totalDigisBPIX / 32.;
1875  float averageFPIXOcc = totalDigisFPIX / 8.;
1876  for (int i = 1; i != 41; i++) {
1877  if (i < 33)
1878  roccupancyPlot->setBinContent(i, roccupancyPlot->getBinContent(i) / averageBPIXOcc);
1879  else
1880  roccupancyPlot->setBinContent(i, roccupancyPlot->getBinContent(i) / averageFPIXOcc);
1881  }
1882 
1883  iGetter.setCurrentFolder(iBooker.pwd());
1884 }
1885 
1886 //=============================================================================================================
1887 
1889  DQMStore::IGetter &iGetter,
1890  int lumisec) {
1891  iGetter.cd();
1892 
1893  MonitorElement *avgfedDigiOccvsLumi = iGetter.get("Pixel/avgfedDigiOccvsLumi");
1894 
1895  float totalDigisBPIX = 0.;
1896  float totalDigisFPIX = 0.;
1897  for (int i = 1; i != 41; i++) {
1898  if (i < 33)
1899  totalDigisBPIX += avgfedDigiOccvsLumi->getBinContent(lumisec, i);
1900  else
1901  totalDigisFPIX += avgfedDigiOccvsLumi->getBinContent(lumisec, i);
1902  }
1903  float averageBPIXOcc = totalDigisBPIX / 32.;
1904  float averageFPIXOcc = totalDigisFPIX / 8.;
1905  for (int i = 1; i != 41; i++) {
1906  if (i < 33)
1907  avgfedDigiOccvsLumi->setBinContent(lumisec, i, avgfedDigiOccvsLumi->getBinContent(lumisec, i) / averageBPIXOcc);
1908  else
1909  avgfedDigiOccvsLumi->setBinContent(lumisec, i, avgfedDigiOccvsLumi->getBinContent(lumisec, i) / averageFPIXOcc);
1910  }
1911 
1912  iGetter.setCurrentFolder(iBooker.pwd());
1913 }
1914 
1915 //=============================================================================================================
1916 
1918  // Barrel
1919  iBooker.cd();
1920  iBooker.setCurrentFolder("Pixel/Barrel");
1921  if (!isUpgrade) {
1922  if (Tier0Flag_) {
1923  HitEfficiency_L1 = iBooker.book2D(
1924  "HitEfficiency_L1", "Hit Efficiency in Barrel_Layer1;Module;Ladder", 9, -4.5, 4.5, 21, -10.5, 10.5);
1925  HitEfficiency_L2 = iBooker.book2D(
1926  "HitEfficiency_L2", "Hit Efficiency in Barrel_Layer2;Module;Ladder", 9, -4.5, 4.5, 33, -16.5, 16.5);
1927  HitEfficiency_L3 = iBooker.book2D(
1928  "HitEfficiency_L3", "Hit Efficiency in Barrel_Layer3;Module;Ladder", 9, -4.5, 4.5, 45, -22.5, 22.5);
1929  } else {
1930  HitEfficiency_L1 = iBooker.book2D(
1931  "HitEfficiency_L1", "Hit Efficiency in Barrel_Layer1;Module;Ladder", 9, -4.5, 4.5, 21, -10.5, 10.5);
1932  HitEfficiency_L2 = iBooker.book2D(
1933  "HitEfficiency_L2", "Hit Efficiency in Barrel_Layer2;Module;Ladder", 9, -4.5, 4.5, 33, -16.5, 16.5);
1934  HitEfficiency_L3 = iBooker.book2D(
1935  "HitEfficiency_L3", "Hit Efficiency in Barrel_Layer3;Module;Ladder", 9, -4.5, 4.5, 45, -22.5, 22.5);
1936  }
1937  } // endifNOTUpgrade
1938  else if (isUpgrade) {
1939  if (Tier0Flag_) {
1941  iBooker.book2D("HitEfficiency_L1", "Hit Efficiency in Barrel_Layer1;z-side;Ladder", 2, -1., 1., 12, -6., 6.);
1942  HitEfficiency_L2 = iBooker.book2D(
1943  "HitEfficiency_L2", "Hit Efficiency in Barrel_Layer2;z-side;Ladder", 2, -1., 1., 28, -14., 14.);
1944  HitEfficiency_L3 = iBooker.book2D(
1945  "HitEfficiency_L3", "Hit Efficiency in Barrel_Layer3;z-side;Ladder", 2, -1., 1., 44, -22., 22.);
1946  HitEfficiency_L4 = iBooker.book2D(
1947  "HitEfficiency_L4", "Hit Efficiency in Barrel_Layer4;z-side;Ladder", 2, -1., 1., 64, -32., 32.);
1948  } else {
1950  iBooker.book2D("HitEfficiency_L1", "Hit Efficiency in Barrel_Layer1;Module;Ladder", 8, -4., 4., 12, -6., 6.);
1951  HitEfficiency_L2 = iBooker.book2D(
1952  "HitEfficiency_L2", "Hit Efficiency in Barrel_Layer2;Module;Ladder", 8, -4., 4., 28, -14., 14.);
1953  HitEfficiency_L3 = iBooker.book2D(
1954  "HitEfficiency_L3", "Hit Efficiency in Barrel_Layer3;Module;Ladder", 8, -4., 4., 44, -22., 22.);
1955  HitEfficiency_L4 = iBooker.book2D(
1956  "HitEfficiency_L4", "Hit Efficiency in Barrel_Layer4;Module;Ladder", 8, -4., 4., 64, -32., 32.);
1957  }
1958  } // endifUpgrade
1959  // Endcap
1960  iBooker.cd();
1961  iBooker.setCurrentFolder("Pixel/Endcap");
1962  if (!isUpgrade) {
1963  if (Tier0Flag_) {
1964  HitEfficiency_Dp1 = iBooker.book2D(
1965  "HitEfficiency_Dp1", "Hit Efficiency in Endcap_Disk_p1;Blade;Panel", 26, -13., 13., 2, 0.5, 2.5);
1966  HitEfficiency_Dp2 = iBooker.book2D(
1967  "HitEfficiency_Dp2", "Hit Efficiency in Endcap_Disk_p2;Blade;Panel", 26, -13., 13., 2, 0.5, 2.5);
1968  HitEfficiency_Dm1 = iBooker.book2D(
1969  "HitEfficiency_Dm1", "Hit Efficiency in Endcap_Disk_m1;Blade;Panel", 26, -13., 13., 2, 0.5, 2.5);
1970  HitEfficiency_Dm2 = iBooker.book2D(
1971  "HitEfficiency_Dm2", "Hit Efficiency in Endcap_Disk_m2;;Blade;Panel", 26, -13., 13., 2, 0.5, 2.5);
1972  } else {
1973  HitEfficiency_Dp1 = iBooker.book2D(
1974  "HitEfficiency_Dp1", "Hit Efficiency in Endcap_Disk_p1;Blades;Modules", 24, -12., 12., 7, 1., 8.);
1975  HitEfficiency_Dp2 = iBooker.book2D(
1976  "HitEfficiency_Dp2", "Hit Efficiency in Endcap_Disk_p2;Blades;Modules", 24, -12., 12., 7, 1., 8.);
1977  HitEfficiency_Dm1 = iBooker.book2D(
1978  "HitEfficiency_Dm1", "Hit Efficiency in Endcap_Disk_m1;Blades;Modules", 24, -12., 12., 7, 1., 8.);
1979  HitEfficiency_Dm2 = iBooker.book2D(
1980  "HitEfficiency_Dm2", "Hit Efficiency in Endcap_Disk_m2;Blades;Modules", 24, -12., 12., 7, 1., 8.);
1981  }
1982  } else if (isUpgrade) {
1983  if (Tier0Flag_) {
1985  iBooker.book2D("HitEfficiency_Dp1", "Hit Efficiency in Endcap_Disk_p1;Blades;", 28, -17., 11., 1, 0., 1.);
1987  iBooker.book2D("HitEfficiency_Dp2", "Hit Efficiency in Endcap_Disk_p2;Blades;", 28, -17., 11., 1, 0., 1.);
1989  iBooker.book2D("HitEfficiency_Dp3", "Hit Efficiency in Endcap_Disk_p3;Blades;", 28, -17., 11., 1, 0., 1.);
1991  iBooker.book2D("HitEfficiency_Dm1", "Hit Efficiency in Endcap_Disk_m1;Blades;", 28, -17., 11., 1, 0., 1.);
1993  iBooker.book2D("HitEfficiency_Dm2", "Hit Efficiency in Endcap_Disk_m2;Blades;", 28, -17., 11., 1, 0., 1.);
1995  iBooker.book2D("HitEfficiency_Dm3", "Hit Efficiency in Endcap_Disk_m3;Blades;", 28, -17., 11., 1, 0., 1.);
1996  } else {
1997  HitEfficiency_Dp1 = iBooker.book2D(
1998  "HitEfficiency_Dp1", "Hit Efficiency in Endcap_Disk_p1;Blades;Modules", 28, -17., 11., 2, 1., 3.);
1999  HitEfficiency_Dp2 = iBooker.book2D(
2000  "HitEfficiency_Dp2", "Hit Efficiency in Endcap_Disk_p2;Blades;Modules", 28, -17., 11., 2, 1., 3.);
2001  HitEfficiency_Dp3 = iBooker.book2D(
2002  "HitEfficiency_Dp3", "Hit Efficiency in Endcap_Disk_p3;Blades;Modules", 28, -17., 11., 2, 1., 3.);
2003  HitEfficiency_Dm1 = iBooker.book2D(
2004  "HitEfficiency_Dm1", "Hit Efficiency in Endcap_Disk_m1;Blades;Modules", 28, -17., 11., 2, 1., 3.);
2005  HitEfficiency_Dm2 = iBooker.book2D(
2006  "HitEfficiency_Dm2", "Hit Efficiency in Endcap_Disk_m2;Blades;Modules", 28, -17., 11., 2, 1., 3.);
2007  HitEfficiency_Dm3 = iBooker.book2D(
2008  "HitEfficiency_Dm3", "Hit Efficiency in Endcap_Disk_m3;Blades;Modules", 28, -17., 11., 2, 1., 3.);
2009  }
2010  } // endif(isUpgrade)
2011  iBooker.cd();
2012  iBooker.cd("Pixel/");
2013  string bins[] = {"Layer1", "Layer2", "Layer3", "Disk1+", "Disk2+", "Disk1-", "Disk2-"};
2014  HitEfficiencySummary = iBooker.book1D("HitEfficiencySummary", "Hit efficiency per sub detector", 7, 0, 7);
2015  HitEfficiencySummary->setAxisTitle("Sub Detector", 1);
2016  HitEfficiencySummary->setAxisTitle("Efficiency (%)", 2);
2017  for (int i = 1; i < 8; i++) {
2018  HitEfficiencySummary->setBinLabel(i, bins[i - 1]);
2019  }
2020 }
2021 
2022 //=============================================================================================================
2023 
2025  // std::cout<<"entering
2026  // SiPixelActionExecutor::createEfficiency..."<<std::endl;
2027  iGetter.cd();
2028  iBooker.cd();
2029  fillEfficiency(iBooker, iGetter, true, isUpgrade); // Barrel
2030  iGetter.cd();
2031  iBooker.cd();
2032  fillEfficiency(iBooker, iGetter, false, isUpgrade); // Endcap
2033  iGetter.cd();
2034  iBooker.cd();
2035  // std::cout<<"leaving SiPixelActionExecutor::createEfficiency..."<<std::endl;
2036 }
2037 
2038 //=============================================================================================================
2039 
2041  int biny_ = 0;
2042  string lad = dname_.substr(dname_.find("Ladder_") + 7, 2);
2043  if (dname_.find(lad) != string::npos) {
2044  biny_ = atoi(lad.c_str());
2045  }
2046  return biny_;
2047 }
2048 
2049 //=============================================================================================================
2050 
2052  int binx_ = 0;
2053  string blad = dname_.substr(dname_.find("Blade_") + 6, 2);
2054  if (dname_.find(blad) != string::npos) {
2055  binx_ = atoi(blad.c_str());
2056  }
2057  return binx_;
2058 }
2059 
2060 //=============================================================================================================
2061 
2063  DQMStore::IGetter &iGetter,
2064  bool isbarrel,
2065  bool isUpgrade) {
2066  // cout<<"entering SiPixelActionExecutor::fillEfficiency..."<<std::endl;
2067  string currDir = iBooker.pwd();
2068  string dname = currDir.substr(currDir.find_last_of("/") + 1);
2069  // cout<<"currDir= "<<currDir<< " , dname= "<<dname<<std::endl;
2070 
2071  if (Tier0Flag_) { // Offline
2072  if (isbarrel && dname.find("Ladder_") != string::npos) {
2073  if (!isUpgrade) {
2074  vector<string> meVec = iGetter.getMEs();
2075  for (vector<string>::const_iterator it = meVec.begin(); it != meVec.end(); it++) {
2076  string full_path = currDir + "/" + (*it);
2077 
2078  if (full_path.find("missingMod_") != string::npos) { // If we have missing hits ME
2079 
2080  // Get the MEs that contain missing and valid hits
2081  MonitorElement *missing = iGetter.get(full_path);
2082  if (!missing)
2083  continue;
2084  string new_path = full_path.replace(full_path.find("missing"), 7, "valid");
2085  MonitorElement *valid = iGetter.get(new_path);
2086  if (!valid)
2087  continue;
2088  int binx = 0;
2089  int biny = 0;
2090  // get the ladder number
2091  biny = getLadder(dname); // Current
2092  if (currDir.find("Shell_mO") != string::npos || currDir.find("Shell_pO") != string::npos) {
2093  biny = -biny;
2094  }
2095  const int nMod = 4;
2096  for (int i = 1; i < nMod + 1; i++) {
2097  float hitEfficiency = -1.0;
2098  float missingHits = 0;
2099  float validHits = 0;
2100  binx = i; // Module
2101  if (currDir.find("Shell_m") != string::npos)
2102  binx = -binx;
2103 
2104  missingHits = missing->getBinContent(i);
2105  validHits = valid->getBinContent(i);
2106  if (validHits + missingHits > 0.)
2107  hitEfficiency = validHits / (validHits + missingHits);
2108 
2109  if (currDir.find("Layer_1") != string::npos) {
2110  HitEfficiency_L1 = iGetter.get("Pixel/Barrel/HitEfficiency_L1");
2111  if (HitEfficiency_L1)
2112  HitEfficiency_L1->setBinContent(HitEfficiency_L1->getTH2F()->FindBin(binx, biny),
2113  (float)hitEfficiency);
2114  } else if (currDir.find("Layer_2") != string::npos) {
2115  HitEfficiency_L2 = iGetter.get("Pixel/Barrel/HitEfficiency_L2");
2116  if (HitEfficiency_L2)
2117  HitEfficiency_L2->setBinContent(HitEfficiency_L2->getTH2F()->FindBin(binx, biny),
2118  (float)hitEfficiency);
2119  } else if (currDir.find("Layer_3") != string::npos) {
2120  HitEfficiency_L3 = iGetter.get("Pixel/Barrel/HitEfficiency_L3");
2121  if (HitEfficiency_L3)
2122  HitEfficiency_L3->setBinContent(HitEfficiency_L3->getTH2F()->FindBin(binx, biny),
2123  (float)hitEfficiency);
2124  }
2125  }
2126  }
2127  }
2128  } // endifNOTUpgradeInBPix
2129  else if (isUpgrade) {
2130  vector<string> meVec = iGetter.getMEs();
2131  for (vector<string>::const_iterator it = meVec.begin(); it != meVec.end(); it++) {
2132  string full_path = currDir + "/" + (*it);
2133  if (full_path.find("missing_") != string::npos) { // If we have missing hits ME
2134  MonitorElement *me = iGetter.get(full_path);
2135  if (!me)
2136  continue;
2137  float missingHits = me->getEntries();
2138  string new_path = full_path.replace(full_path.find("missing"), 7, "valid");
2139  me = iGetter.get(new_path);
2140  if (!me)
2141  continue;
2142  float validHits = me->getEntries();
2143  float hitEfficiency = -1.;
2144  if (validHits + missingHits > 0.)
2145  hitEfficiency = validHits / (validHits + missingHits);
2146  int binx = 0;
2147  int biny = 0;
2148  biny = getLadder(dname);
2149  if (currDir.find("Shell_mO") != string::npos || currDir.find("Shell_pO") != string::npos) {
2150  biny = -biny;
2151  }
2152  if (currDir.find("Shell_m") != string::npos) {
2153  binx = 1;
2154  } else {
2155  binx = 2;
2156  } // x-axis: z-side
2157  if (currDir.find("Layer_1") != string::npos) {
2158  HitEfficiency_L1 = iGetter.get("Pixel/Barrel/HitEfficiency_L1");
2159  if (HitEfficiency_L1)
2160  HitEfficiency_L1->setBinContent(binx, biny, (float)hitEfficiency);
2161  } else if (currDir.find("Layer_2") != string::npos) {
2162  HitEfficiency_L2 = iGetter.get("Pixel/Barrel/HitEfficiency_L2");
2163  if (HitEfficiency_L2)
2164  HitEfficiency_L2->setBinContent(binx, biny, (float)hitEfficiency);
2165  } else if (currDir.find("Layer_3") != string::npos) {
2166  HitEfficiency_L3 = iGetter.get("Pixel/Barrel/HitEfficiency_L3");
2167  if (HitEfficiency_L3)
2168  HitEfficiency_L3->setBinContent(binx, biny, (float)hitEfficiency);
2169  } else if (currDir.find("Layer_4") != string::npos) {
2170  HitEfficiency_L4 = iGetter.get("Pixel/Barrel/HitEfficiency_L4");
2171  if (HitEfficiency_L4)
2172  HitEfficiency_L4->setBinContent(binx, biny, (float)hitEfficiency);
2173  }
2174  }
2175  }
2176  } // endifUpgradeInBPix
2177  } else if (!isbarrel && dname.find("Blade_") != string::npos && !isUpgrade) {
2178  vector<string> meVec = iGetter.getMEs();
2179  for (vector<string>::const_iterator it = meVec.begin(); it != meVec.end(); it++) {
2180  string full_path = currDir + "/" + (*it);
2181  if (full_path.find("missing_") != string::npos) { // If we have missing hits ME
2182  MonitorElement *missing = iGetter.get(full_path);
2183  if (!missing)
2184  continue;
2185  // float missingHits = missing->getEntries();
2186  string new_path = full_path.replace(full_path.find("missing"), 7, "valid");
2187  MonitorElement *valid = iGetter.get(new_path);
2188  if (!valid)
2189  continue;
2190  // float validHits = valid->getEntries();
2191  int binx = 0;
2192  int biny = 0;
2193  binx = getBlade(dname);
2194  if (currDir.find("HalfCylinder_mI") != string::npos || currDir.find("HalfCylinder_pI") != string::npos) {
2195  binx = binx + 14;
2196  } else {
2197  binx = 13 - binx;
2198  }
2199  const int nPanel = 2;
2200  for (int i = 1; i < nPanel + 1; i++) {
2201  float hitEfficiency = -1.;
2202  float missingHits = 0;
2203  float validHits = 0;
2204  biny = i;
2205  missingHits = missing->getBinContent(i);
2206  validHits = valid->getBinContent(i);
2207  if (validHits + missingHits > 0.)
2208  hitEfficiency = validHits / (validHits + missingHits);
2209  if (currDir.find("Disk_1") != string::npos && currDir.find("HalfCylinder_m") != string::npos) {
2210  HitEfficiency_Dm1 = iGetter.get("Pixel/Endcap/HitEfficiency_Dm1");
2211  if (HitEfficiency_Dm1)
2212  HitEfficiency_Dm1->setBinContent(binx, biny, (float)hitEfficiency);
2213  } else if (currDir.find("Disk_2") != string::npos && currDir.find("HalfCylinder_m") != string::npos) {
2214  HitEfficiency_Dm2 = iGetter.get("Pixel/Endcap/HitEfficiency_Dm2");
2215  if (HitEfficiency_Dm2)
2216  HitEfficiency_Dm2->setBinContent(binx, biny, (float)hitEfficiency);
2217  } else if (currDir.find("Disk_1") != string::npos && currDir.find("HalfCylinder_p") != string::npos) {
2218  HitEfficiency_Dp1 = iGetter.get("Pixel/Endcap/HitEfficiency_Dp1");
2219  if (HitEfficiency_Dp1)
2220  HitEfficiency_Dp1->setBinContent(binx, biny, (float)hitEfficiency);
2221  } else if (currDir.find("Disk_2") != string::npos && currDir.find("HalfCylinder_p") != string::npos) {
2222  HitEfficiency_Dp2 = iGetter.get("Pixel/Endcap/HitEfficiency_Dp2");
2223  if (HitEfficiency_Dp2)
2224  HitEfficiency_Dp2->setBinContent(binx, biny, (float)hitEfficiency);
2225  }
2226  } // EndOfFor
2227  }
2228  }
2229  } else if (!isbarrel && dname.find("Blade_") != string::npos && isUpgrade) {
2230  vector<string> meVec = iGetter.getMEs();
2231  for (vector<string>::const_iterator it = meVec.begin(); it != meVec.end(); it++) {
2232  string full_path = currDir + "/" + (*it);
2233  if (full_path.find("missing_") != string::npos) { // If we have missing hits ME
2234  MonitorElement *me = iGetter.get(full_path);
2235  if (!me)
2236  continue;
2237  float missingHits = me->getEntries();
2238  string new_path = full_path.replace(full_path.find("missing"), 7, "valid");
2239  me = iGetter.get(new_path);
2240  if (!me)
2241  continue;
2242  float validHits = me->getEntries();
2243  float hitEfficiency = -1.;
2244  if (validHits + missingHits > 0.)
2245  hitEfficiency = validHits / (validHits + missingHits);
2246  int binx = 0;
2247  int biny = 1;
2248  binx = getBlade(dname);
2249  if (currDir.find("HalfCylinder_mI") != string::npos || currDir.find("HalfCylinder_pI") != string::npos) {
2250  binx = binx + 12;
2251  } else {
2252  if (binx == 1)
2253  binx = 17;
2254  else if (binx == 2)
2255  binx = 16;
2256  else if (binx == 3)
2257  binx = 15;
2258  else if (binx == 4)
2259  binx = 14;
2260  else if (binx == 5)
2261  binx = 13;
2262  else if (binx == 6)
2263  binx = 12;
2264  else if (binx == 7)
2265  binx = 11;
2266  else if (binx == 8)
2267  binx = 10;
2268  else if (binx == 9)
2269  binx = 9;
2270  else if (binx == 10)
2271  binx = 8;
2272  else if (binx == 11)
2273  binx = 7;
2274  else if (binx == 12)
2275  binx = 6;
2276  else if (binx == 13)
2277  binx = 5;
2278  else if (binx == 14)
2279  binx = 4;
2280  else if (binx == 15)
2281  binx = 3;
2282  else if (binx == 16)
2283  binx = 2;
2284  else if (binx == 17)
2285  binx = 1;
2286  }
2287  if (currDir.find("Disk_1") != string::npos && currDir.find("HalfCylinder_m") != string::npos) {
2288  HitEfficiency_Dm1 = iGetter.get("Pixel/Endcap/HitEfficiency_Dm1");
2289  if (HitEfficiency_Dm1)
2290  HitEfficiency_Dm1->setBinContent(binx, biny, (float)hitEfficiency);
2291  } else if (currDir.find("Disk_2") != string::npos && currDir.find("HalfCylinder_m") != string::npos) {
2292  HitEfficiency_Dm2 = iGetter.get("Pixel/Endcap/HitEfficiency_Dm2");
2293  if (HitEfficiency_Dm2)
2294  HitEfficiency_Dm2->setBinContent(binx, biny, (float)hitEfficiency);
2295  } else if (currDir.find("Disk_3") != string::npos && currDir.find("HalfCylinder_m") != string::npos) {
2296  HitEfficiency_Dm3 = iGetter.get("Pixel/Endcap/HitEfficiency_Dm3");
2297  if (HitEfficiency_Dm3)
2298  HitEfficiency_Dm3->setBinContent(binx, biny, (float)hitEfficiency);
2299  } else if (currDir.find("Disk_1") != string::npos && currDir.find("HalfCylinder_p") != string::npos) {
2300  HitEfficiency_Dp1 = iGetter.get("Pixel/Endcap/HitEfficiency_Dp1");
2301  if (HitEfficiency_Dp1)
2302  HitEfficiency_Dp1->setBinContent(binx, biny, (float)hitEfficiency);
2303  } else if (currDir.find("Disk_2") != string::npos && currDir.find("HalfCylinder_p") != string::npos) {
2304  HitEfficiency_Dp2 = iGetter.get("Pixel/Endcap/HitEfficiency_Dp2");
2305  if (HitEfficiency_Dp2)
2306  HitEfficiency_Dp2->setBinContent(binx, biny, (float)hitEfficiency);
2307  } else if (currDir.find("Disk_3") != string::npos && currDir.find("HalfCylinder_p") != string::npos) {
2308  HitEfficiency_Dp3 = iGetter.get("Pixel/Endcap/HitEfficiency_Dp3");
2309  if (HitEfficiency_Dp3)
2310  HitEfficiency_Dp3->setBinContent(binx, biny, (float)hitEfficiency);
2311  }
2312  // std::cout<<"EFFI: "<<currDir<<" , x: "<<binx<<" , y:
2313  // "<<biny<<std::endl;
2314  }
2315  }
2316  } else {
2317  vector<string> subdirs = iGetter.getSubdirs();
2318  for (vector<string>::const_iterator it = subdirs.begin(); it != subdirs.end(); it++) {
2319  iBooker.cd(*it);
2320  iGetter.cd(*it);
2321  if (*it != "Pixel" &&
2322  ((isbarrel && (*it).find("Barrel") == string::npos) || (!isbarrel && (*it).find("Endcap") == string::npos)))
2323  continue;
2324  fillEfficiency(iBooker, iGetter, isbarrel, isUpgrade);
2325  iBooker.goUp();
2326  iGetter.setCurrentFolder(iBooker.pwd());
2327  }
2328  }
2329  } else { // Online
2330  if (dname.find("Module_") != string::npos) {
2331  vector<string> meVec = iGetter.getMEs();
2332  for (vector<string>::const_iterator it = meVec.begin(); it != meVec.end(); it++) {
2333  string full_path = currDir + "/" + (*it);
2334  if (full_path.find("missing_") != string::npos) { // If we have missing hits ME
2335  MonitorElement *me = iGetter.get(full_path);
2336  if (!me)
2337  continue;
2338  float missingHits = me->getEntries();
2339  string new_path = full_path.replace(full_path.find("missing"), 7, "valid");
2340  me = iGetter.get(new_path);
2341  if (!me)
2342  continue;
2343  float validHits = me->getEntries();
2344  float hitEfficiency = -1.;
2345  if (validHits + missingHits > 0.)
2346  hitEfficiency = validHits / (validHits + missingHits);
2347  int binx = 0;
2348  int biny = 0;
2349  if (isbarrel) {
2350  if (currDir.find("Shell_m") != string::npos) {
2351  if (currDir.find("Module_4") != string::npos) {
2352  binx = 1;
2353  } else if (currDir.find("Module_3") != string::npos) {
2354  binx = 2;
2355  }
2356  if (currDir.find("Module_2") != string::npos) {
2357  binx = 3;
2358  } else if (currDir.find("Module_1") != string::npos) {
2359  binx = 4;
2360  }
2361  } else if (currDir.find("Shell_p") != string::npos) {
2362  if (currDir.find("Module_1") != string::npos) {
2363  binx = 5;
2364  } else if (currDir.find("Module_2") != string::npos) {
2365  binx = 6;
2366  }
2367  if (currDir.find("Module_3") != string::npos) {
2368  binx = 7;
2369  } else if (currDir.find("Module_4") != string::npos) {
2370  binx = 8;
2371  }
2372  }
2373  if (!isUpgrade) {
2374  if (currDir.find("01") != string::npos) {
2375  biny = 1;
2376  } else if (currDir.find("02") != string::npos) {
2377  biny = 2;
2378  } else if (currDir.find("03") != string::npos) {
2379  biny = 3;
2380  } else if (currDir.find("04") != string::npos) {
2381  biny = 4;
2382  } else if (currDir.find("05") != string::npos) {
2383  biny = 5;
2384  } else if (currDir.find("06") != string::npos) {
2385  biny = 6;
2386  } else if (currDir.find("07") != string::npos) {
2387  biny = 7;
2388  } else if (currDir.find("08") != string::npos) {
2389  biny = 8;
2390  } else if (currDir.find("09") != string::npos) {
2391  biny = 9;
2392  } else if (currDir.find("10") != string::npos) {
2393  biny = 10;
2394  } else if (currDir.find("11") != string::npos) {
2395  biny = 11;
2396  } else if (currDir.find("12") != string::npos) {
2397  biny = 12;
2398  } else if (currDir.find("13") != string::npos) {
2399  biny = 13;
2400  } else if (currDir.find("14") != string::npos) {
2401  biny = 14;
2402  } else if (currDir.find("15") != string::npos) {
2403  biny = 15;
2404  } else if (currDir.find("16") != string::npos) {
2405  biny = 16;
2406  } else if (currDir.find("17") != string::npos) {
2407  biny = 17;
2408  } else if (currDir.find("18") != string::npos) {
2409  biny = 18;
2410  } else if (currDir.find("19") != string::npos) {
2411  biny = 19;
2412  } else if (currDir.find("20") != string::npos) {
2413  biny = 20;
2414  } else if (currDir.find("21") != string::npos) {
2415  biny = 21;
2416  } else if (currDir.find("22") != string::npos) {
2417  biny = 22;
2418  }
2419  if (currDir.find("Shell_mO") != string::npos || currDir.find("Shell_pO") != string::npos) {
2420  if (currDir.find("Layer_1") != string::npos) {
2421  biny = biny + 10;
2422  } else if (currDir.find("Layer_2") != string::npos) {
2423  biny = biny + 16;
2424  } else if (currDir.find("Layer_3") != string::npos) {
2425  biny = biny + 22;
2426  }
2427  }
2428  } else if (isUpgrade) {
2429  if (currDir.find("01") != string::npos) {
2430  biny = 1;
2431  } else if (currDir.find("02") != string::npos) {
2432  biny = 2;
2433  } else if (currDir.find("03") != string::npos) {
2434  biny = 3;
2435  } else if (currDir.find("04") != string::npos) {
2436  biny = 4;
2437  } else if (currDir.find("05") != string::npos) {
2438  biny = 5;
2439  } else if (currDir.find("06") != string::npos) {
2440  biny = 6;
2441  } else if (currDir.find("07") != string::npos) {
2442  biny = 7;
2443  } else if (currDir.find("08") != string::npos) {
2444  biny = 8;
2445  } else if (currDir.find("09") != string::npos) {
2446  biny = 9;
2447  } else if (currDir.find("10") != string::npos) {
2448  biny = 10;
2449  } else if (currDir.find("11") != string::npos) {
2450  biny = 11;
2451  } else if (currDir.find("12") != string::npos) {
2452  biny = 12;
2453  } else if (currDir.find("13") != string::npos) {
2454  biny = 13;
2455  } else if (currDir.find("14") != string::npos) {
2456  biny = 14;
2457  } else if (currDir.find("15") != string::npos) {
2458  biny = 15;
2459  } else if (currDir.find("16") != string::npos) {
2460  biny = 16;
2461  } else if (currDir.find("17") != string::npos) {
2462  biny = 17;
2463  } else if (currDir.find("18") != string::npos) {
2464  biny = 18;
2465  } else if (currDir.find("19") != string::npos) {
2466  biny = 19;
2467  } else if (currDir.find("20") != string::npos) {
2468  biny = 20;
2469  } else if (currDir.find("21") != string::npos) {
2470  biny = 21;
2471  } else if (currDir.find("22") != string::npos) {
2472  biny = 22;
2473  } else if (currDir.find("23") != string::npos) {
2474  biny = 23;
2475  } else if (currDir.find("24") != string::npos) {
2476  biny = 24;
2477  } else if (currDir.find("25") != string::npos) {
2478  biny = 25;
2479  } else if (currDir.find("25") != string::npos) {
2480  biny = 25;
2481  } else if (currDir.find("26") != string::npos) {
2482  biny = 26;
2483  } else if (currDir.find("27") != string::npos) {
2484  biny = 27;
2485  } else if (currDir.find("28") != string::npos) {
2486  biny = 28;
2487  } else if (currDir.find("29") != string::npos) {
2488  biny = 29;
2489  } else if (currDir.find("30") != string::npos) {
2490  biny = 30;
2491  } else if (currDir.find("31") != string::npos) {
2492  biny = 31;
2493  } else if (currDir.find("32") != string::npos) {
2494  biny = 32;
2495  }
2496  if (currDir.find("Shell_mO") != string::npos || currDir.find("Shell_pO") != string::npos) {
2497  if (currDir.find("Layer_1") != string::npos) {
2498  biny = biny + 6;
2499  } else if (currDir.find("Layer_2") != string::npos) {
2500  biny = biny + 14;
2501  } else if (currDir.find("Layer_3") != string::npos) {
2502  biny = biny + 22;
2503  } else if (currDir.find("Layer_4") != string::npos) {
2504  biny = biny + 32;
2505  }
2506  }
2507  }
2508  } else { // endcap
2509  if (!isUpgrade) {
2510  if (currDir.find("01") != string::npos) {
2511  binx = 1;
2512  } else if (currDir.find("02") != string::npos) {
2513  binx = 2;
2514  } else if (currDir.find("03") != string::npos) {
2515  binx = 3;
2516  } else if (currDir.find("04") != string::npos) {
2517  binx = 4;
2518  } else if (currDir.find("05") != string::npos) {
2519  binx = 5;
2520  } else if (currDir.find("06") != string::npos) {
2521  binx = 6;
2522  } else if (currDir.find("07") != string::npos) {
2523  binx = 7;
2524  } else if (currDir.find("08") != string::npos) {
2525  binx = 8;
2526  } else if (currDir.find("09") != string::npos) {
2527  binx = 9;
2528  } else if (currDir.find("10") != string::npos) {
2529  binx = 10;
2530  } else if (currDir.find("11") != string::npos) {
2531  binx = 11;
2532  } else if (currDir.find("12") != string::npos) {
2533  binx = 12;
2534  }
2535  if (currDir.find("HalfCylinder_mO") != string::npos || currDir.find("HalfCylinder_pO") != string::npos) {
2536  binx = binx + 12;
2537  }
2538  if (currDir.find("Panel_1/Module_1") != string::npos) {
2539  biny = 1;
2540  } else if (currDir.find("Panel_2/Module_1") != string::npos) {
2541  biny = 2;
2542  } else if (currDir.find("Panel_1/Module_2") != string::npos) {
2543  biny = 3;
2544  } else if (currDir.find("Panel_2/Module_2") != string::npos) {
2545  biny = 4;
2546  } else if (currDir.find("Panel_1/Module_3") != string::npos) {
2547  biny = 5;
2548  } else if (currDir.find("Panel_2/Module_3") != string::npos) {
2549  biny = 6;
2550  } else if (currDir.find("Panel_1/Module_4") != string::npos) {
2551  biny = 7;
2552  }
2553  } else if (isUpgrade) {
2554  if (currDir.find("01") != string::npos) {
2555  binx = 1;
2556  } else if (currDir.find("02") != string::npos) {
2557  binx = 2;
2558  } else if (currDir.find("03") != string::npos) {
2559  binx = 3;
2560  } else if (currDir.find("04") != string::npos) {
2561  binx = 4;
2562  } else if (currDir.find("05") != string::npos) {
2563  binx = 5;
2564  } else if (currDir.find("06") != string::npos) {
2565  binx = 6;
2566  } else if (currDir.find("07") != string::npos) {
2567  binx = 7;
2568  } else if (currDir.find("08") != string::npos) {
2569  binx = 8;
2570  } else if (currDir.find("09") != string::npos) {
2571  binx = 9;
2572  } else if (currDir.find("10") != string::npos) {
2573  binx = 10;
2574  } else if (currDir.find("11") != string::npos) {
2575  binx = 11;
2576  } else if (currDir.find("12") != string::npos) {
2577  binx = 12;
2578  } else if (currDir.find("13") != string::npos) {
2579  binx = 13;
2580  } else if (currDir.find("14") != string::npos) {
2581  binx = 14;
2582  } else if (currDir.find("15") != string::npos) {
2583  binx = 15;
2584  } else if (currDir.find("16") != string::npos) {
2585  binx = 16;
2586  } else if (currDir.find("17") != string::npos) {
2587  binx = 17;
2588  }
2589  if (currDir.find("HalfCylinder_mO") != string::npos || currDir.find("HalfCylinder_pO") != string::npos) {
2590  binx = binx + 17;
2591  }
2592  if (currDir.find("Panel_1/Module_1") != string::npos) {
2593  biny = 1;
2594  } else if (currDir.find("Panel_2/Module_1") != string::npos) {
2595  biny = 2;
2596  }
2597  } // endif(isUpgrade)
2598  }
2599 
2600  if (currDir.find("Layer_1") != string::npos) {
2601  HitEfficiency_L1 = iGetter.get("Pixel/Barrel/HitEfficiency_L1");
2602  if (HitEfficiency_L1)
2603  HitEfficiency_L1->setBinContent(binx, biny, (float)hitEfficiency);
2604  } else if (currDir.find("Layer_2") != string::npos) {
2605  HitEfficiency_L2 = iGetter.get("Pixel/Barrel/HitEfficiency_L2");
2606  if (HitEfficiency_L2)
2607  HitEfficiency_L2->setBinContent(binx, biny, (float)hitEfficiency);
2608  } else if (currDir.find("Layer_3") != string::npos) {
2609  HitEfficiency_L3 = iGetter.get("Pixel/Barrel/HitEfficiency_L3");
2610  if (HitEfficiency_L3)
2611  HitEfficiency_L3->setBinContent(binx, biny, (float)hitEfficiency);
2612  } else if (isUpgrade && (currDir.find("Layer_4") != string::npos)) {
2613  HitEfficiency_L4 = iGetter.get("Pixel/Barrel/HitEfficiency_L4");
2614  if (HitEfficiency_L4)
2615  HitEfficiency_L4->setBinContent(binx, biny, (float)hitEfficiency);
2616  } else if (currDir.find("Disk_1") != string::npos && currDir.find("HalfCylinder_m") != string::npos) {
2617  HitEfficiency_Dm1 = iGetter.get("Pixel/Endcap/HitEfficiency_Dm1");
2618  if (HitEfficiency_Dm1)
2619  HitEfficiency_Dm1->setBinContent(binx, biny, (float)hitEfficiency);
2620  } else if (currDir.find("Disk_2") != string::npos && currDir.find("HalfCylinder_m") != string::npos) {
2621  HitEfficiency_Dm2 = iGetter.get("Pixel/Endcap/HitEfficiency_Dm2");
2622  if (HitEfficiency_Dm2)
2623  HitEfficiency_Dm2->setBinContent(binx, biny, (float)hitEfficiency);
2624  } else if (currDir.find("Disk_3") != string::npos && currDir.find("HalfCylinder_m") != string::npos) {
2625  HitEfficiency_Dm3 = iGetter.get("Pixel/Endcap/HitEfficiency_Dm3");
2626  if (HitEfficiency_Dm3)
2627  HitEfficiency_Dm3->setBinContent(binx, biny, (float)hitEfficiency);
2628  } else if (currDir.find("Disk_1") != string::npos && currDir.find("HalfCylinder_p") != string::npos) {
2629  HitEfficiency_Dp1 = iGetter.get("Pixel/Endcap/HitEfficiency_Dp1");
2630  if (HitEfficiency_Dp1)
2631  HitEfficiency_Dp1->setBinContent(binx, biny, (float)hitEfficiency);
2632  } else if (currDir.find("Disk_2") != string::npos && currDir.find("HalfCylinder_p") != string::npos) {
2633  HitEfficiency_Dp2 = iGetter.get("Pixel/Endcap/HitEfficiency_Dp2");
2634  if (HitEfficiency_Dp2)
2635  HitEfficiency_Dp2->setBinContent(binx, biny, (float)hitEfficiency);
2636  } else if (currDir.find("Disk_3") != string::npos && currDir.find("HalfCylinder_p") != string::npos) {
2637  HitEfficiency_Dp3 = iGetter.get("Pixel/Endcap/HitEfficiency_Dp3");
2638  if (HitEfficiency_Dp3)
2639  HitEfficiency_Dp3->setBinContent(binx, biny, (float)hitEfficiency);
2640  }
2641  }
2642  }
2643  } else {
2644  // cout<<"finding subdirs now"<<std::endl;
2645  vector<string> subdirs = iGetter.getSubdirs();
2646  for (vector<string>::const_iterator it = subdirs.begin(); it != subdirs.end(); it++) {
2647  iBooker.cd(*it);
2648  iGetter.cd(*it);
2649  if (*it != "Pixel" &&
2650  ((isbarrel && (*it).find("Barrel") == string::npos) || (!isbarrel && (*it).find("Endcap") == string::npos)))
2651  continue;
2652  fillEfficiency(iBooker, iGetter, isbarrel, isUpgrade);
2653  iBooker.goUp();
2654  iGetter.setCurrentFolder(iBooker.pwd());
2655  }
2656  }
2657  } // end online/offline
2658  // cout<<"leaving SiPixelActionExecutor::fillEfficiency..."<<std::endl;
2659 }
2660 
2661 //=============================================================================================================
2662 
2664  // cout<<"entering
2665  // SiPixelActionExecutor::fillEfficiencySummary..."<<std::endl; First we get
2666  // the summary plot"
2667  if (!Tier0Flag_)
2668  return;
2669  HitEfficiencySummary = iGetter.get("Pixel/HitEfficiencySummary");
2670  // Now we will loop over the hit efficiency plots and fill it"
2671  string hitEfficiencyPostfix[] = {"L1", "L2", "L3", "Dp1", "Dp2", "Dm1", "Dm2"};
2672  std::vector<std::vector<float>> ignoreXBins = {
2673  {-4, 2}, {4, 4, -1, -3, 3, -4, -3, -2, -1, -4, -3, -2, -1, 1, -4}, {1, -4, 1}, {}, {}, {}, {}};
2674  std::vector<std::vector<float>> ignoreYBins = {
2675  {-9, -3}, {1, 16, 1, -13, -13, -5, -5, -5, -5, -6, -6, -6, -6, -8, -8}, {3, 14, 6}, {}, {}, {}, {}};
2676 
2677  for (int i = 0; i < 7; i++) {
2678  string subdetName = "Endcap/";
2679  if (i < 3)
2680  subdetName = "Barrel/";
2681  char meName[50];
2682  sprintf(meName, "Pixel/%sHitEfficiency_%s", subdetName.c_str(), hitEfficiencyPostfix[i].c_str());
2683  MonitorElement *tempHitEffMap = iGetter.get(meName);
2684  float totalEff = 0.;
2685  int totalBins = 0;
2686  TH1 *hitEffMap = tempHitEffMap->getTH1();
2687  for (int xBin = 1; xBin < tempHitEffMap->getNbinsX() + 1; xBin++) {
2688  if (fabs(hitEffMap->GetXaxis()->GetBinCenter(xBin)) < 1.)
2689  continue;
2690  for (int yBin = 1; yBin < tempHitEffMap->getNbinsY() + 1; yBin++) {
2691  if (fabs(hitEffMap->GetYaxis()->GetBinCenter(yBin)) < 0.5)
2692  continue;
2693  bool ignoreBin = false;
2694  for (unsigned int j = 0; j < ignoreXBins[i].size(); j++) {
2695  if (hitEffMap->GetXaxis()->GetBinCenter(xBin) == ignoreXBins[i][j] &&
2696  hitEffMap->GetYaxis()->GetBinCenter(yBin) == ignoreYBins[i][j]) {
2697  ignoreBin = true;
2698  break;
2699  }
2700  }
2701  if (ignoreBin)
2702  continue;
2703  if (!(tempHitEffMap->getBinContent(xBin, yBin) < 0.))
2704  totalEff += tempHitEffMap->getBinContent(xBin, yBin);
2705  totalBins++;
2706  }
2707  }
2708  float overalEff = 0.;
2709  // std::cout << i << " " << totalEff << " " << totalBins << std::endl;
2710  if (totalBins > 0)
2711  overalEff = totalEff / float(totalBins);
2712  HitEfficiencySummary->setBinContent(i + 1, overalEff);
2713  }
2714 }
void normaliseAvDigiOccVsLumi(DQMStore::IBooker &iBooker, DQMStore::IGetter &iGetter, int lumisec)
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX)
Definition: DQMStore.cc:239
virtual TH2F * getTH2F() const
MonitorElement * HitEfficiency_Dp3
virtual int getNbinsY() const
get # of bins in Y-axis
void getDocument(std::string configFile, bool UseDB=false)
Methor that parses the xml file configFile.
void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:418
void createEfficiency(DQMStore::IBooker &iBooker, DQMStore::IGetter &iGetter, bool isUpgrade)
virtual TH1F * getTH1F() const
static char const * tname
Definition: GTSchema.h:13
void getGrandSummaryME(DQMStore::IBooker &iBooker, DQMStore::IGetter &iGetter, int nbin, std::string &me_name, std::vector< MonitorElement * > &mes)
MonitorElement * HitEfficiency_L4
void bookOccupancyPlots(DQMStore::IBooker &iBooker, DQMStore::IGetter &iGetter, bool hiRes, bool isbarrel)
MonitorElement * DEV_size_Barrel
MonitorElement * HitEfficiency_L3
const std::string & getName() const
get name of ME
SiPixelConfigParser * configParser_
MonitorElement * DEV_nclusters_Barrel
void fillGrandEndcapSummaryHistos(DQMStore::IBooker &iBooker, DQMStore::IGetter &iGetter, std::vector< std::string > &me_names, bool isUpgrade)
double isum
bool getMENamesForEndcapSummary(std::string &structure_name, std::vector< std::string > &me_names)
MonitorElement * HitEfficiency_Dm2
MonitorElement * HitEfficiency_L2
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
int getBlade(const std::string &dname)
missing
Definition: combine.py:5
void normaliseAvDigiOcc(DQMStore::IBooker &iBooker, DQMStore::IGetter &iGetter)
bool getCalibType(int &u_freq)
void fillEfficiency(DQMStore::IBooker &iBooker, DQMStore::IGetter &iGetter, bool isbarrel, bool isUpgrade)
void Fill(long long x)
virtual void Reset()
reset ME (ie. contents, errors, etc)
bool getMENamesForGrandEndcapSummary(std::string &structure_name, std::vector< std::string > &me_names)
SiPixelConfigWriter * configWriter_
bool getFrequencyForGrandBarrelSummary(int &u_freq)
bool getFrequencyForEndcapSummary(int &u_freq)
virtual int getNbinsX() const
get # of bins in X-axis
bool getMENamesForFEDErrorSummary(std::string &structure_name, std::vector< std::string > &me_names)
virtual double getEntries() const
get # of entries
void bookDeviations(DQMStore::IBooker &iBooker, bool isUpgrade)
T sqrt(T t)
Definition: SSEVec.h:19
void createSummary(DQMStore::IBooker &iBooker, DQMStore::IGetter &iGetter, bool isUpgrade)
MonitorElement * DEV_adc_Endcap
bool getMENamesForGrandBarrelSummary(std::string &structure_name, std::vector< std::string > &me_names)
bool getFrequencyForBarrelSummary(int &u_freq)
std::vector< std::string > getMEs()
Definition: DQMStore.cc:455
void fillFEDErrorSummary(DQMStore::IBooker &iBooker, DQMStore::IGetter &iGetter, std::string dir_name, std::vector< std::string > &me_names)
bool getFrequencyForGrandEndcapSummary(int &u_freq)
MonitorElement * DEV_charge_Endcap
bool getMENamesForBarrelSummary(std::string &structure_name, std::vector< std::string > &me_names)
virtual void setBinLabel(int bin, const std::string &label, int axis=1)
set bin label for x, y or z axis (axis=1, 2, 3 respectively)
int getLadder(const std::string &dname)
virtual double getBinContent(int binx) const
get content of bin (1-D)
MonitorElement * getSummaryME(DQMStore::IBooker &iBooker, DQMStore::IGetter &iGetter, std::string me_name, bool isUpgrade)
void fillOccupancy(DQMStore::IBooker &iBooker, DQMStore::IGetter &iGetter, bool isbarrel)
MonitorElement * getFEDSummaryME(DQMStore::IBooker &iBooker, DQMStore::IGetter &iGetter, std::string me_name)
SiPixelActionExecutor(bool offlineXMLfile, bool Tier0Flag)
MonitorElement * DEV_charge_Barrel
MonitorElement * HitEfficiency_Dm3
virtual double getMean(int axis=1) const
get mean value of histogram along x, y or z axis (axis=1, 2, 3 respectively)
virtual void setBinContent(int binx, double content)
set content of bin (1-D)
bool getMessageLimitForQTests(int &u_freq)
MonitorElement * HitEfficiency_L1
virtual double getRMS(int axis=1) const
get RMS of histogram along x, y or z axis (axis=1, 2, 3 respectively)
MonitorElement * DEV_nclusters_Endcap
MonitorElement * HitEfficiency_Dp1
bool getSourceType(int &u_freq)
MonitorElement * DEV_size_Endcap
int nlast
Definition: AMPTWrapper.h:57
MonitorElement * book2D(TString const &name, TString const &title, int nchX, double lowX, double highX, int nchY, double lowY, double highY)
Definition: DQMStore.cc:266
MonitorElement * HitEfficiencySummary
void fillEfficiencySummary(DQMStore::IBooker &iBooker, DQMStore::IGetter &iGetter)
void createOccupancy(DQMStore::IBooker &iBooker, DQMStore::IGetter &iGetter)
MonitorElement * HitEfficiency_Dp2
bool getFrequencyForTrackerMap(int &u_freq)
void fillGrandBarrelSummaryHistos(DQMStore::IBooker &iBooker, DQMStore::IGetter &iGetter, std::vector< std::string > &me_names, bool isUpgrade)
void fillSummary(DQMStore::IBooker &iBooker, DQMStore::IGetter &iGetter, std::string dir_name, std::vector< std::string > &me_names, bool isbarrel, bool isUpgrade)
MonitorElement * DEV_ndigis_Endcap
void GetBladeSubdirs(DQMStore::IBooker &iBooker, DQMStore::IGetter &iGetter, std::vector< std::string > &blade_subdirs)
MonitorElement * HitEfficiency_Dm1
MonitorElement * get(std::string const &path)
Definition: DQMStore.cc:437
MonitorElement * DEV_ndigis_Barrel
virtual TH1 * getTH1() const
void bookEfficiency(DQMStore::IBooker &iBooker, bool isUpgrade)
MonitorElement * DEV_adc_Barrel
void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:424
std::vector< std::string > getSubdirs()
Definition: DQMStore.cc:453
virtual void setAxisTitle(const std::string &title, int axis=1)
set x-, y- or z-axis title (axis=1, 2, 3 respectively)