test
CMS 3D CMS Logo

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