CMS 3D CMS Logo

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) {
59  configParser_->getDocument(edm::FileInPath(localPath).fullPath());
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) {
80  configParser_->getDocument(edm::FileInPath(localPath).fullPath());
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) {
126  configParser_->getDocument(edm::FileInPath(localPath).fullPath());
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) {
154  configParser_->getDocument(edm::FileInPath(localPath).fullPath());
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;
227  MonitorElement* me1; MonitorElement* me2;
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 
1577  //std::cout<<"leaving SiPixelActionExecutor::createOccupancy..."<<std::endl;
1578 }
1579 
1580 //=============================================================================================================
1581 
1583 {
1584  //occupancyprinting cout<<"entering SiPixelActionExecutor::fillOccupancy..."<<std::endl;
1585  if(Tier0Flag_) return;
1586  string currDir = iBooker.pwd();
1587  string dname = currDir.substr(currDir.find_last_of("/")+1);
1588 
1589  if(dname.find("Layer_")!=string::npos || dname.find("Disk_")!=string::npos){
1590  vector<string> meVec = iGetter.getMEs();
1591  for (vector<string>::const_iterator it = meVec.begin(); it != meVec.end(); it++) {
1592  string full_path = currDir + "/" + (*it);
1593  if(full_path.find("hitmap_siPixelDigis")!=string::npos){ // If we have the hitmap ME
1594  MonitorElement * me = iGetter.get(full_path);
1595  if (!me) continue;
1596  string path = full_path;
1597  while (path.find_last_of("/") != 5) // Stop before Pixel/
1598  {
1599  path = path.substr(0,path.find_last_of("/"));
1600  // cout << "\t" << path << endl;
1601  OccupancyMap = iGetter.get(path + "/" + (isbarrel?"barrel":"endcap") + "OccupancyMap");
1602 
1603  if(OccupancyMap){
1604  for(int i=1; i!=me->getNbinsX()+1; i++) for(int j=1; j!=me->getNbinsY()+1; j++){
1605  float previous = OccupancyMap->getBinContent(i,j);
1606  OccupancyMap->setBinContent(i,j,previous + me->getBinContent(i,j));
1607  }
1608  OccupancyMap->getTH2F()->SetEntries(OccupancyMap->getTH2F()->Integral());
1609  }
1610 
1611  }
1612  }
1613 
1614  }
1615  } else {
1616  vector<string> subdirs = iGetter.getSubdirs();
1617  for (vector<string>::const_iterator it = subdirs.begin(); it != subdirs.end(); it++) {
1618  iGetter.cd(*it);
1619  iBooker.cd(*it);
1620  if(*it != "Pixel" && ((isbarrel && (*it).find("Barrel")==string::npos) || (!isbarrel && (*it).find("Endcap")==string::npos))) continue;
1621  fillOccupancy(iBooker,iGetter, isbarrel);
1622  iBooker.goUp();
1623  iGetter.setCurrentFolder(iBooker.pwd());
1624  }
1625  }
1626 
1627  //occupancyprinting cout<<"leaving SiPixelActionExecutor::fillOccupancy..."<<std::endl;
1628 
1629 }
1630 
1631 //=============================================================================================================
1632 
1634  //occupancyprinting cout<<"entering SiPixelActionExecutor::normaliseAvDigiOcc..."<<std::endl;
1635 
1636  iGetter.cd();
1637 
1638  MonitorElement * roccupancyPlot = iGetter.get("Pixel/averageDigiOccupancy");
1639 
1640  float totalDigisBPIX = 0.;
1641  float totalDigisFPIX = 0.;
1642  for (int i = 1; i !=41; i++){
1643  if (i < 33) totalDigisBPIX += roccupancyPlot->getBinContent(i);
1644  else totalDigisFPIX += roccupancyPlot->getBinContent(i);
1645  }
1646  float averageBPIXOcc = totalDigisBPIX/32.;
1647  float averageFPIXOcc = totalDigisFPIX/8.;
1648  for (int i = 1; i !=41; i++){
1649  if (i < 33) roccupancyPlot->setBinContent(i,roccupancyPlot->getBinContent(i)/averageBPIXOcc);
1650  else roccupancyPlot->setBinContent(i,roccupancyPlot->getBinContent(i)/averageFPIXOcc);
1651  }
1652 
1653  iGetter.setCurrentFolder(iBooker.pwd());
1654 
1655 }
1656 
1657 //=============================================================================================================
1658 
1660 
1661  iGetter.cd();
1662 
1663  MonitorElement* avgfedDigiOccvsLumi = iGetter.get("Pixel/avgfedDigiOccvsLumi");
1664 
1665  float totalDigisBPIX = 0.;
1666  float totalDigisFPIX = 0.;
1667  for (int i = 1; i !=41; i++){
1668  if (i < 33) totalDigisBPIX += avgfedDigiOccvsLumi->getBinContent(lumisec,i);
1669  else totalDigisFPIX += avgfedDigiOccvsLumi->getBinContent(lumisec,i);
1670  }
1671  float averageBPIXOcc = totalDigisBPIX/32.;
1672  float averageFPIXOcc = totalDigisFPIX/8.;
1673  for (int i = 1; i !=41; i++){
1674  if (i < 33) avgfedDigiOccvsLumi->setBinContent(lumisec,i,avgfedDigiOccvsLumi->getBinContent(lumisec,i)/averageBPIXOcc);
1675  else avgfedDigiOccvsLumi->setBinContent(lumisec,i,avgfedDigiOccvsLumi->getBinContent(lumisec,i)/averageFPIXOcc);
1676  }
1677 
1678  iGetter.setCurrentFolder(iBooker.pwd());
1679 
1680 }
1681 
1682 //=============================================================================================================
1683 
1685  // Barrel
1686  iBooker.cd();
1687  iBooker.setCurrentFolder("Pixel/Barrel");
1688  if (!isUpgrade) {
1689  if(Tier0Flag_){
1690  HitEfficiency_L1 = iBooker.book2D("HitEfficiency_L1","Hit Efficiency in Barrel_Layer1;Module;Ladder",9,-4.5,4.5,21,-10.5,10.5);
1691  HitEfficiency_L2 = iBooker.book2D("HitEfficiency_L2","Hit Efficiency in Barrel_Layer2;Module;Ladder",9,-4.5,4.5,33,-16.5,16.5);
1692  HitEfficiency_L3 = iBooker.book2D("HitEfficiency_L3","Hit Efficiency in Barrel_Layer3;Module;Ladder",9,-4.5,4.5,45,-22.5,22.5);
1693  }else{
1694  HitEfficiency_L1 = iBooker.book2D("HitEfficiency_L1","Hit Efficiency in Barrel_Layer1;Module;Ladder",9,-4.5,4.5,21,-10.5,10.5);
1695  HitEfficiency_L2 = iBooker.book2D("HitEfficiency_L2","Hit Efficiency in Barrel_Layer2;Module;Ladder",9,-4.5,4.5,33,-16.5,16.5);
1696  HitEfficiency_L3 = iBooker.book2D("HitEfficiency_L3","Hit Efficiency in Barrel_Layer3;Module;Ladder",9,-4.5,4.5,45,-22.5,22.5);
1697  }
1698  }//endifNOTUpgrade
1699  else if (isUpgrade) {
1700  if(Tier0Flag_){
1701  HitEfficiency_L1 = iBooker.book2D("HitEfficiency_L1","Hit Efficiency in Barrel_Layer1;z-side;Ladder",2,-1.,1.,12,-6.,6.);
1702  HitEfficiency_L2 = iBooker.book2D("HitEfficiency_L2","Hit Efficiency in Barrel_Layer2;z-side;Ladder",2,-1.,1.,28,-14.,14.);
1703  HitEfficiency_L3 = iBooker.book2D("HitEfficiency_L3","Hit Efficiency in Barrel_Layer3;z-side;Ladder",2,-1.,1.,44,-22.,22.);
1704  HitEfficiency_L4 = iBooker.book2D("HitEfficiency_L4","Hit Efficiency in Barrel_Layer4;z-side;Ladder",2,-1.,1.,64,-32.,32.);
1705  }else{
1706  HitEfficiency_L1 = iBooker.book2D("HitEfficiency_L1","Hit Efficiency in Barrel_Layer1;Module;Ladder",8,-4.,4.,12,-6.,6.);
1707  HitEfficiency_L2 = iBooker.book2D("HitEfficiency_L2","Hit Efficiency in Barrel_Layer2;Module;Ladder",8,-4.,4.,28,-14.,14.);
1708  HitEfficiency_L3 = iBooker.book2D("HitEfficiency_L3","Hit Efficiency in Barrel_Layer3;Module;Ladder",8,-4.,4.,44,-22.,22.);
1709  HitEfficiency_L4 = iBooker.book2D("HitEfficiency_L4","Hit Efficiency in Barrel_Layer4;Module;Ladder",8,-4.,4.,64,-32.,32.);
1710  }
1711  }//endifUpgrade
1712  // Endcap
1713  iBooker.cd();
1714  iBooker.setCurrentFolder("Pixel/Endcap");
1715  if (!isUpgrade) {
1716  if(Tier0Flag_){
1717  HitEfficiency_Dp1 = iBooker.book2D("HitEfficiency_Dp1","Hit Efficiency in Endcap_Disk_p1;Blade;Panel",26,-13.,13.,2,0.5,2.5);
1718  HitEfficiency_Dp2 = iBooker.book2D("HitEfficiency_Dp2","Hit Efficiency in Endcap_Disk_p2;Blade;Panel",26,-13.,13.,2,0.5,2.5);
1719  HitEfficiency_Dm1 = iBooker.book2D("HitEfficiency_Dm1","Hit Efficiency in Endcap_Disk_m1;Blade;Panel",26,-13.,13.,2,0.5,2.5);
1720  HitEfficiency_Dm2 = iBooker.book2D("HitEfficiency_Dm2","Hit Efficiency in Endcap_Disk_m2;;Blade;Panel",26,-13.,13.,2,0.5,2.5);
1721  }else{
1722  HitEfficiency_Dp1 = iBooker.book2D("HitEfficiency_Dp1","Hit Efficiency in Endcap_Disk_p1;Blades;Modules",24,-12.,12.,7,1.,8.);
1723  HitEfficiency_Dp2 = iBooker.book2D("HitEfficiency_Dp2","Hit Efficiency in Endcap_Disk_p2;Blades;Modules",24,-12.,12.,7,1.,8.);
1724  HitEfficiency_Dm1 = iBooker.book2D("HitEfficiency_Dm1","Hit Efficiency in Endcap_Disk_m1;Blades;Modules",24,-12.,12.,7,1.,8.);
1725  HitEfficiency_Dm2 = iBooker.book2D("HitEfficiency_Dm2","Hit Efficiency in Endcap_Disk_m2;Blades;Modules",24,-12.,12.,7,1.,8.);
1726  }
1727  } else if (isUpgrade) {
1728  if(Tier0Flag_){
1729  HitEfficiency_Dp1 = iBooker.book2D("HitEfficiency_Dp1","Hit Efficiency in Endcap_Disk_p1;Blades;",28,-17.,11.,1,0.,1.);
1730  HitEfficiency_Dp2 = iBooker.book2D("HitEfficiency_Dp2","Hit Efficiency in Endcap_Disk_p2;Blades;",28,-17.,11.,1,0.,1.);
1731  HitEfficiency_Dp3 = iBooker.book2D("HitEfficiency_Dp3","Hit Efficiency in Endcap_Disk_p3;Blades;",28,-17.,11.,1,0.,1.);
1732  HitEfficiency_Dm1 = iBooker.book2D("HitEfficiency_Dm1","Hit Efficiency in Endcap_Disk_m1;Blades;",28,-17.,11.,1,0.,1.);
1733  HitEfficiency_Dm2 = iBooker.book2D("HitEfficiency_Dm2","Hit Efficiency in Endcap_Disk_m2;Blades;",28,-17.,11.,1,0.,1.);
1734  HitEfficiency_Dm3 = iBooker.book2D("HitEfficiency_Dm3","Hit Efficiency in Endcap_Disk_m3;Blades;",28,-17.,11.,1,0.,1.);
1735  }else{
1736  HitEfficiency_Dp1 = iBooker.book2D("HitEfficiency_Dp1","Hit Efficiency in Endcap_Disk_p1;Blades;Modules",28,-17.,11.,2,1.,3.);
1737  HitEfficiency_Dp2 = iBooker.book2D("HitEfficiency_Dp2","Hit Efficiency in Endcap_Disk_p2;Blades;Modules",28,-17.,11.,2,1.,3.);
1738  HitEfficiency_Dp3 = iBooker.book2D("HitEfficiency_Dp3","Hit Efficiency in Endcap_Disk_p3;Blades;Modules",28,-17.,11.,2,1.,3.);
1739  HitEfficiency_Dm1 = iBooker.book2D("HitEfficiency_Dm1","Hit Efficiency in Endcap_Disk_m1;Blades;Modules",28,-17.,11.,2,1.,3.);
1740  HitEfficiency_Dm2 = iBooker.book2D("HitEfficiency_Dm2","Hit Efficiency in Endcap_Disk_m2;Blades;Modules",28,-17.,11.,2,1.,3.);
1741  HitEfficiency_Dm3 = iBooker.book2D("HitEfficiency_Dm3","Hit Efficiency in Endcap_Disk_m3;Blades;Modules",28,-17.,11.,2,1.,3.);
1742  }
1743  }//endif(isUpgrade)
1744  iBooker.cd();
1745  iBooker.cd("Pixel/");
1746  string bins[] = {"Layer1","Layer2","Layer3","Disk1+","Disk2+","Disk1-","Disk2-"};
1747  HitEfficiencySummary = iBooker.book1D("HitEfficiencySummary","Hit efficiency per sub detector",7,0,7);
1748  HitEfficiencySummary->setAxisTitle("Sub Detector", 1);
1749  HitEfficiencySummary->setAxisTitle("Efficiency (%)",2);
1750  for (int i = 1; i < 8; i++){
1751  HitEfficiencySummary->setBinLabel(i,bins[i-1]);
1752  }
1753 }
1754 
1755 //=============================================================================================================
1756 
1758  //std::cout<<"entering SiPixelActionExecutor::createEfficiency..."<<std::endl;
1759  iGetter.cd();
1760  iBooker.cd();
1761  fillEfficiency(iBooker, iGetter, true, isUpgrade); // Barrel
1762  iGetter.cd();
1763  iBooker.cd();
1764  fillEfficiency(iBooker, iGetter, false, isUpgrade); // Endcap
1765  iGetter.cd();
1766  iBooker.cd();
1767  //std::cout<<"leaving SiPixelActionExecutor::createEfficiency..."<<std::endl;
1768 }
1769 
1770 //=============================================================================================================
1771 
1773  int biny_= 0;
1774  string lad=dname_.substr(dname_.find("Ladder_") + 7, 2);
1775  if(dname_.find(lad)!=string::npos){ biny_ = atoi(lad.c_str());}
1776  return biny_;
1777 }
1778 
1779 //=============================================================================================================
1780 
1782  int binx_= 0;
1783  string blad=dname_.substr(dname_.find("Blade_") + 6, 2);
1784  if(dname_.find(blad)!=string::npos){ binx_ = atoi(blad.c_str());}
1785  return binx_;
1786 }
1787 
1788 //=============================================================================================================
1789 
1790 void SiPixelActionExecutor::fillEfficiency(DQMStore::IBooker & iBooker, DQMStore::IGetter & iGetter, bool isbarrel, bool isUpgrade){
1791  //cout<<"entering SiPixelActionExecutor::fillEfficiency..."<<std::endl;
1792  string currDir = iBooker.pwd();
1793  string dname = currDir.substr(currDir.find_last_of("/")+1);
1794  //cout<<"currDir= "<<currDir<< " , dname= "<<dname<<std::endl;
1795 
1796  if(Tier0Flag_){ // Offline
1797  if(isbarrel && dname.find("Ladder_")!=string::npos){
1798  if (!isUpgrade) {
1799  vector<string> meVec = iGetter.getMEs();
1800  for (vector<string>::const_iterator it = meVec.begin(); it != meVec.end(); it++) {
1801  string full_path = currDir + "/" + (*it);
1802 
1803  if(full_path.find("missingMod_")!=string::npos){ // If we have missing hits ME
1804 
1805  //Get the MEs that contain missing and valid hits
1806  MonitorElement * missing = iGetter.get(full_path);
1807  if (!missing) continue;
1808  string new_path = full_path.replace(full_path.find("missing"),7,"valid");
1809  MonitorElement * valid = iGetter.get(new_path);
1810  if (!valid) continue;
1811  int binx = 0;
1812  int biny = 0;
1813  //get the ladder number
1814  biny = getLadder(dname);//Current
1815  if(currDir.find("Shell_mO")!=string::npos || currDir.find("Shell_pO")!=string::npos){
1816  biny=-biny;
1817  }
1818  const int nMod = 4;
1819  for(int i=1; i<nMod+1;i++){
1820  float hitEfficiency = -1.0;
1821  float missingHits=0;
1822  float validHits=0;
1823  binx=i; //Module
1824  if(currDir.find("Shell_m")!=string::npos) binx=-binx;
1825 
1826  missingHits=missing->getBinContent(i);
1827  validHits=valid->getBinContent(i);
1828  if(validHits + missingHits > 0.) hitEfficiency = validHits / (validHits + missingHits);
1829 
1830  if(currDir.find("Layer_1")!=string::npos){
1831  HitEfficiency_L1 = iGetter.get("Pixel/Barrel/HitEfficiency_L1");
1832  if(HitEfficiency_L1) HitEfficiency_L1->setBinContent(HitEfficiency_L1->getTH2F()->FindBin(binx, biny),(float)hitEfficiency);
1833  }
1834  else if(currDir.find("Layer_2")!=string::npos){
1835  HitEfficiency_L2 = iGetter.get("Pixel/Barrel/HitEfficiency_L2");
1836  if(HitEfficiency_L2) HitEfficiency_L2->setBinContent(HitEfficiency_L2->getTH2F()->FindBin(binx, biny),(float)hitEfficiency);
1837  }
1838  else if(currDir.find("Layer_3")!=string::npos){
1839  HitEfficiency_L3 = iGetter.get("Pixel/Barrel/HitEfficiency_L3");
1840  if(HitEfficiency_L3) HitEfficiency_L3->setBinContent(HitEfficiency_L3->getTH2F()->FindBin(binx, biny),(float)hitEfficiency);
1841  }
1842 
1843  }
1844 
1845  }
1846  }
1847  }//endifNOTUpgradeInBPix
1848  else if (isUpgrade) {
1849  vector<string> meVec = iGetter.getMEs();
1850  for (vector<string>::const_iterator it = meVec.begin(); it != meVec.end(); it++) {
1851  string full_path = currDir + "/" + (*it);
1852  if(full_path.find("missing_")!=string::npos){ // If we have missing hits ME
1853  MonitorElement * me = iGetter.get(full_path);
1854  if (!me) continue;
1855  float missingHits = me->getEntries();
1856  string new_path = full_path.replace(full_path.find("missing"),7,"valid");
1857  me = iGetter.get(new_path);
1858  if (!me) continue;
1859  float validHits = me->getEntries();
1860  float hitEfficiency = -1.;
1861  if(validHits + missingHits > 0.) hitEfficiency = validHits / (validHits + missingHits);
1862  int binx = 0; int biny = 0;
1863  biny = getLadder(dname);
1864  if(currDir.find("Shell_mO")!=string::npos || currDir.find("Shell_pO")!=string::npos){
1865  biny=-biny;
1866  }
1867  if(currDir.find("Shell_m")!=string::npos){ binx = 1;}else{ binx = 2;} //x-axis: z-side
1868  if(currDir.find("Layer_1")!=string::npos){
1869  HitEfficiency_L1 = iGetter.get("Pixel/Barrel/HitEfficiency_L1");
1870  if(HitEfficiency_L1) HitEfficiency_L1->setBinContent(binx, biny,(float)hitEfficiency);
1871  }else if(currDir.find("Layer_2")!=string::npos){
1872  HitEfficiency_L2 = iGetter.get("Pixel/Barrel/HitEfficiency_L2");
1873  if(HitEfficiency_L2) HitEfficiency_L2->setBinContent(binx, biny,(float)hitEfficiency);
1874  }else if(currDir.find("Layer_3")!=string::npos){
1875  HitEfficiency_L3 = iGetter.get("Pixel/Barrel/HitEfficiency_L3");
1876  if(HitEfficiency_L3) HitEfficiency_L3->setBinContent(binx, biny,(float)hitEfficiency);
1877  }else if(currDir.find("Layer_4")!=string::npos){
1878  HitEfficiency_L4 = iGetter.get("Pixel/Barrel/HitEfficiency_L4");
1879  if(HitEfficiency_L4) HitEfficiency_L4->setBinContent(binx, biny,(float)hitEfficiency);
1880  }
1881  }
1882  }
1883  }//endifUpgradeInBPix
1884  }else if(!isbarrel && dname.find("Blade_")!=string::npos && !isUpgrade){
1885  vector<string> meVec = iGetter.getMEs();
1886  for (vector<string>::const_iterator it = meVec.begin(); it != meVec.end(); it++) {
1887  string full_path = currDir + "/" + (*it);
1888  if(full_path.find("missing_")!=string::npos){ // If we have missing hits ME
1889  MonitorElement * missing = iGetter.get(full_path);
1890  if (!missing) continue;
1891  //float missingHits = missing->getEntries();
1892  string new_path = full_path.replace(full_path.find("missing"),7,"valid");
1893  MonitorElement * valid = iGetter.get(new_path);
1894  if (!valid) continue;
1895  //float validHits = valid->getEntries();
1896  int binx = 0; int biny = 0;
1897  binx = getBlade(dname);
1898  if(currDir.find("HalfCylinder_mI")!=string::npos || currDir.find("HalfCylinder_pI")!=string::npos){ binx = binx + 14;}
1899  else{ binx = 13 -binx;}
1900  const int nPanel=2;
1901  for (int i=1; i<nPanel+1; i++){
1902  float hitEfficiency = -1.;
1903  float missingHits=0;
1904  float validHits=0;
1905  biny=i;
1906  missingHits=missing->getBinContent(i);
1907  validHits=valid->getBinContent(i);
1908  if(validHits + missingHits > 0.) hitEfficiency = validHits / (validHits + missingHits);
1909  if(currDir.find("Disk_1")!=string::npos && currDir.find("HalfCylinder_m")!=string::npos){
1910  HitEfficiency_Dm1 = iGetter.get("Pixel/Endcap/HitEfficiency_Dm1");
1911  if(HitEfficiency_Dm1) HitEfficiency_Dm1->setBinContent(binx, biny, (float)hitEfficiency);
1912  }else if(currDir.find("Disk_2")!=string::npos && currDir.find("HalfCylinder_m")!=string::npos){
1913  HitEfficiency_Dm2 = iGetter.get("Pixel/Endcap/HitEfficiency_Dm2");
1914  if(HitEfficiency_Dm2) HitEfficiency_Dm2->setBinContent(binx, biny, (float)hitEfficiency);
1915  }else if(currDir.find("Disk_1")!=string::npos && currDir.find("HalfCylinder_p")!=string::npos){
1916  HitEfficiency_Dp1 = iGetter.get("Pixel/Endcap/HitEfficiency_Dp1");
1917  if(HitEfficiency_Dp1) HitEfficiency_Dp1->setBinContent(binx, biny, (float)hitEfficiency);
1918  }else if(currDir.find("Disk_2")!=string::npos && currDir.find("HalfCylinder_p")!=string::npos){
1919  HitEfficiency_Dp2 = iGetter.get("Pixel/Endcap/HitEfficiency_Dp2");
1920  if(HitEfficiency_Dp2) HitEfficiency_Dp2->setBinContent(binx, biny, (float)hitEfficiency);
1921  }
1922  }//EndOfFor
1923  }
1924  }
1925  }else if(!isbarrel && dname.find("Blade_")!=string::npos && isUpgrade){
1926  vector<string> meVec = iGetter.getMEs();
1927  for (vector<string>::const_iterator it = meVec.begin(); it != meVec.end(); it++) {
1928  string full_path = currDir + "/" + (*it);
1929  if(full_path.find("missing_")!=string::npos){ // If we have missing hits ME
1930  MonitorElement * me = iGetter.get(full_path);
1931  if (!me) continue;
1932  float missingHits = me->getEntries();
1933  string new_path = full_path.replace(full_path.find("missing"),7,"valid");
1934  me = iGetter.get(new_path);
1935  if (!me) continue;
1936  float validHits = me->getEntries();
1937  float hitEfficiency = -1.;
1938  if(validHits + missingHits > 0.) hitEfficiency = validHits / (validHits + missingHits);
1939  int binx = 0; int biny = 1;
1940  binx = getBlade(dname);
1941  if(currDir.find("HalfCylinder_mI")!=string::npos || currDir.find("HalfCylinder_pI")!=string::npos){ binx = binx + 12;}
1942  else{
1943  if(binx==1) binx = 17;
1944  else if(binx==2) binx = 16;
1945  else if(binx==3) binx = 15;
1946  else if(binx==4) binx = 14;
1947  else if(binx==5) binx = 13;
1948  else if(binx==6) binx = 12;
1949  else if(binx==7) binx = 11;
1950  else if(binx==8) binx = 10;
1951  else if(binx==9) binx = 9;
1952  else if(binx==10) binx = 8;
1953  else if(binx==11) binx = 7;
1954  else if(binx==12) binx = 6;
1955  else if(binx==13) binx = 5;
1956  else if(binx==14) binx = 4;
1957  else if(binx==15) binx = 3;
1958  else if(binx==16) binx = 2;
1959  else if(binx==17) binx = 1;
1960  }
1961  if(currDir.find("Disk_1")!=string::npos && currDir.find("HalfCylinder_m")!=string::npos){
1962  HitEfficiency_Dm1 = iGetter.get("Pixel/Endcap/HitEfficiency_Dm1");
1963  if(HitEfficiency_Dm1) HitEfficiency_Dm1->setBinContent(binx, biny, (float)hitEfficiency);
1964  }else if(currDir.find("Disk_2")!=string::npos && currDir.find("HalfCylinder_m")!=string::npos){
1965  HitEfficiency_Dm2 = iGetter.get("Pixel/Endcap/HitEfficiency_Dm2");
1966  if(HitEfficiency_Dm2) HitEfficiency_Dm2->setBinContent(binx, biny, (float)hitEfficiency);
1967  }else if(currDir.find("Disk_3")!=string::npos && currDir.find("HalfCylinder_m")!=string::npos){
1968  HitEfficiency_Dm3 = iGetter.get("Pixel/Endcap/HitEfficiency_Dm3");
1969  if(HitEfficiency_Dm3) HitEfficiency_Dm3->setBinContent(binx, biny, (float)hitEfficiency);
1970  }else if(currDir.find("Disk_1")!=string::npos && currDir.find("HalfCylinder_p")!=string::npos){
1971  HitEfficiency_Dp1 = iGetter.get("Pixel/Endcap/HitEfficiency_Dp1");
1972  if(HitEfficiency_Dp1) HitEfficiency_Dp1->setBinContent(binx, biny, (float)hitEfficiency);
1973  }else if(currDir.find("Disk_2")!=string::npos && currDir.find("HalfCylinder_p")!=string::npos){
1974  HitEfficiency_Dp2 = iGetter.get("Pixel/Endcap/HitEfficiency_Dp2");
1975  if(HitEfficiency_Dp2) HitEfficiency_Dp2->setBinContent(binx, biny, (float)hitEfficiency);
1976  }else if(currDir.find("Disk_3")!=string::npos && currDir.find("HalfCylinder_p")!=string::npos){
1977  HitEfficiency_Dp3 = iGetter.get("Pixel/Endcap/HitEfficiency_Dp3");
1978  if(HitEfficiency_Dp3) HitEfficiency_Dp3->setBinContent(binx, biny, (float)hitEfficiency);
1979  }
1980  //std::cout<<"EFFI: "<<currDir<<" , x: "<<binx<<" , y: "<<biny<<std::endl;
1981  }
1982  }
1983  }else{
1984  vector<string> subdirs = iGetter.getSubdirs();
1985  for (vector<string>::const_iterator it = subdirs.begin(); it != subdirs.end(); it++) {
1986  iBooker.cd(*it);
1987  iGetter.cd(*it);
1988  if(*it != "Pixel" && ((isbarrel && (*it).find("Barrel")==string::npos) || (!isbarrel && (*it).find("Endcap")==string::npos))) continue;
1989  fillEfficiency(iBooker, iGetter, isbarrel, isUpgrade);
1990  iBooker.goUp();
1991  iGetter.setCurrentFolder(iBooker.pwd());
1992  }
1993  }
1994  }else{ // Online
1995  if(dname.find("Module_")!=string::npos){
1996  vector<string> meVec = iGetter.getMEs();
1997  for (vector<string>::const_iterator it = meVec.begin(); it != meVec.end(); it++) {
1998  string full_path = currDir + "/" + (*it);
1999  if(full_path.find("missing_")!=string::npos){ // If we have missing hits ME
2000  MonitorElement * me = iGetter.get(full_path);
2001  if (!me) continue;
2002  float missingHits = me->getEntries();
2003  string new_path = full_path.replace(full_path.find("missing"),7,"valid");
2004  me = iGetter.get(new_path);
2005  if (!me) continue;
2006  float validHits = me->getEntries();
2007  float hitEfficiency = -1.;
2008  if(validHits + missingHits > 0.) hitEfficiency = validHits / (validHits + missingHits);
2009  int binx = 0; int biny = 0;
2010  if(isbarrel){
2011  if(currDir.find("Shell_m")!=string::npos){
2012  if(currDir.find("Module_4")!=string::npos){ binx = 1;}else if(currDir.find("Module_3")!=string::npos){ binx = 2;}
2013  if(currDir.find("Module_2")!=string::npos){ binx = 3;}else if(currDir.find("Module_1")!=string::npos){ binx = 4;}
2014  }else if(currDir.find("Shell_p")!=string::npos){
2015  if(currDir.find("Module_1")!=string::npos){ binx = 5;}else if(currDir.find("Module_2")!=string::npos){ binx = 6;}
2016  if(currDir.find("Module_3")!=string::npos){ binx = 7;}else if(currDir.find("Module_4")!=string::npos){ binx = 8;}
2017  }
2018  if (!isUpgrade) {
2019  if(currDir.find("01")!=string::npos){ biny = 1;}else if(currDir.find("02")!=string::npos){ biny = 2;}
2020  else if(currDir.find("03")!=string::npos){ biny = 3;}else if(currDir.find("04")!=string::npos){ biny = 4;}
2021  else if(currDir.find("05")!=string::npos){ biny = 5;}else if(currDir.find("06")!=string::npos){ biny = 6;}
2022  else if(currDir.find("07")!=string::npos){ biny = 7;}else if(currDir.find("08")!=string::npos){ biny = 8;}
2023  else if(currDir.find("09")!=string::npos){ biny = 9;}else if(currDir.find("10")!=string::npos){ biny = 10;}
2024  else if(currDir.find("11")!=string::npos){ biny = 11;}else if(currDir.find("12")!=string::npos){ biny = 12;}
2025  else if(currDir.find("13")!=string::npos){ biny = 13;}else if(currDir.find("14")!=string::npos){ biny = 14;}
2026  else if(currDir.find("15")!=string::npos){ biny = 15;}else if(currDir.find("16")!=string::npos){ biny = 16;}
2027  else if(currDir.find("17")!=string::npos){ biny = 17;}else if(currDir.find("18")!=string::npos){ biny = 18;}
2028  else if(currDir.find("19")!=string::npos){ biny = 19;}else if(currDir.find("20")!=string::npos){ biny = 20;}
2029  else if(currDir.find("21")!=string::npos){ biny = 21;}else if(currDir.find("22")!=string::npos){ biny = 22;}
2030  if(currDir.find("Shell_mO")!=string::npos || currDir.find("Shell_pO")!=string::npos){
2031  if(currDir.find("Layer_1")!=string::npos){ biny = biny + 10;}
2032  else if(currDir.find("Layer_2")!=string::npos){ biny = biny + 16;}
2033  else if(currDir.find("Layer_3")!=string::npos){ biny = biny + 22;}
2034  }
2035  }
2036  else if (isUpgrade) {
2037  if(currDir.find("01")!=string::npos){ biny = 1;}else if(currDir.find("02")!=string::npos){ biny = 2;}
2038  else if(currDir.find("03")!=string::npos){ biny = 3;}else if(currDir.find("04")!=string::npos){ biny = 4;}
2039  else if(currDir.find("05")!=string::npos){ biny = 5;}else if(currDir.find("06")!=string::npos){ biny = 6;}
2040  else if(currDir.find("07")!=string::npos){ biny = 7;}else if(currDir.find("08")!=string::npos){ biny = 8;}
2041  else if(currDir.find("09")!=string::npos){ biny = 9;}else if(currDir.find("10")!=string::npos){ biny = 10;}
2042  else if(currDir.find("11")!=string::npos){ biny = 11;}else if(currDir.find("12")!=string::npos){ biny = 12;}
2043  else if(currDir.find("13")!=string::npos){ biny = 13;}else if(currDir.find("14")!=string::npos){ biny = 14;}
2044  else if(currDir.find("15")!=string::npos){ biny = 15;}else if(currDir.find("16")!=string::npos){ biny = 16;}
2045  else if(currDir.find("17")!=string::npos){ biny = 17;}else if(currDir.find("18")!=string::npos){ biny = 18;}
2046  else if(currDir.find("19")!=string::npos){ biny = 19;}else if(currDir.find("20")!=string::npos){ biny = 20;}
2047  else if(currDir.find("21")!=string::npos){ biny = 21;}else if(currDir.find("22")!=string::npos){ biny = 22;}
2048  else if(currDir.find("23")!=string::npos){ biny = 23;}else if(currDir.find("24")!=string::npos){ biny = 24;}
2049  else if(currDir.find("25")!=string::npos){ biny = 25;}else if(currDir.find("25")!=string::npos){ biny = 25;}
2050  else if(currDir.find("26")!=string::npos){ biny = 26;}else if(currDir.find("27")!=string::npos){ biny = 27;}
2051  else if(currDir.find("28")!=string::npos){ biny = 28;}else if(currDir.find("29")!=string::npos){ biny = 29;}
2052  else if(currDir.find("30")!=string::npos){ biny = 30;}else if(currDir.find("31")!=string::npos){ biny = 31;}
2053  else if(currDir.find("32")!=string::npos){ biny = 32;}
2054  if(currDir.find("Shell_mO")!=string::npos || currDir.find("Shell_pO")!=string::npos){
2055  if(currDir.find("Layer_1")!=string::npos){ biny = biny + 6;}
2056  else if(currDir.find("Layer_2")!=string::npos){ biny = biny + 14;}
2057  else if(currDir.find("Layer_3")!=string::npos){ biny = biny + 22;}
2058  else if(currDir.find("Layer_4")!=string::npos){ biny = biny + 32;}
2059  }
2060  }
2061  }else{ //endcap
2062  if (!isUpgrade) {
2063  if(currDir.find("01")!=string::npos){ binx = 1;}else if(currDir.find("02")!=string::npos){ binx = 2;}
2064  else if(currDir.find("03")!=string::npos){ binx = 3;}else if(currDir.find("04")!=string::npos){ binx = 4;}
2065  else if(currDir.find("05")!=string::npos){ binx = 5;}else if(currDir.find("06")!=string::npos){ binx = 6;}
2066  else if(currDir.find("07")!=string::npos){ binx = 7;}else if(currDir.find("08")!=string::npos){ binx = 8;}
2067  else if(currDir.find("09")!=string::npos){ binx = 9;}else if(currDir.find("10")!=string::npos){ binx = 10;}
2068  else if(currDir.find("11")!=string::npos){ binx = 11;}else if(currDir.find("12")!=string::npos){ binx = 12;}
2069  if(currDir.find("HalfCylinder_mO")!=string::npos || currDir.find("HalfCylinder_pO")!=string::npos){ binx = binx + 12;}
2070  if(currDir.find("Panel_1/Module_1")!=string::npos){ biny = 1;}else if(currDir.find("Panel_2/Module_1")!=string::npos){ biny = 2;}
2071  else if(currDir.find("Panel_1/Module_2")!=string::npos){ biny = 3;}else if(currDir.find("Panel_2/Module_2")!=string::npos){ biny = 4;}
2072  else if(currDir.find("Panel_1/Module_3")!=string::npos){ biny = 5;}else if(currDir.find("Panel_2/Module_3")!=string::npos){ biny = 6;}
2073  else if(currDir.find("Panel_1/Module_4")!=string::npos){ biny = 7;}
2074  } else if (isUpgrade) {
2075  if(currDir.find("01")!=string::npos){ binx = 1;}else if(currDir.find("02")!=string::npos){ binx = 2;}
2076  else if(currDir.find("03")!=string::npos){ binx = 3;}else if(currDir.find("04")!=string::npos){ binx = 4;}
2077  else if(currDir.find("05")!=string::npos){ binx = 5;}else if(currDir.find("06")!=string::npos){ binx = 6;}
2078  else if(currDir.find("07")!=string::npos){ binx = 7;}else if(currDir.find("08")!=string::npos){ binx = 8;}
2079  else if(currDir.find("09")!=string::npos){ binx = 9;}else if(currDir.find("10")!=string::npos){ binx = 10;}
2080  else if(currDir.find("11")!=string::npos){ binx = 11;}else if(currDir.find("12")!=string::npos){ binx = 12;}
2081  else if(currDir.find("13")!=string::npos){ binx = 13;}else if(currDir.find("14")!=string::npos){ binx = 14;}
2082  else if(currDir.find("15")!=string::npos){ binx = 15;}else if(currDir.find("16")!=string::npos){ binx = 16;}
2083  else if(currDir.find("17")!=string::npos){ binx = 17;}
2084  if(currDir.find("HalfCylinder_mO")!=string::npos || currDir.find("HalfCylinder_pO")!=string::npos){ binx = binx + 17;}
2085  if(currDir.find("Panel_1/Module_1")!=string::npos){ biny = 1;}else if(currDir.find("Panel_2/Module_1")!=string::npos){ biny = 2;}
2086  }//endif(isUpgrade)
2087  }
2088 
2089  if(currDir.find("Layer_1")!=string::npos){
2090  HitEfficiency_L1 = iGetter.get("Pixel/Barrel/HitEfficiency_L1");
2091  if(HitEfficiency_L1) HitEfficiency_L1->setBinContent(binx, biny,(float)hitEfficiency);
2092  }else if(currDir.find("Layer_2")!=string::npos){
2093  HitEfficiency_L2 = iGetter.get("Pixel/Barrel/HitEfficiency_L2");
2094  if(HitEfficiency_L2) HitEfficiency_L2->setBinContent(binx, biny,(float)hitEfficiency);
2095  }else if(currDir.find("Layer_3")!=string::npos){
2096  HitEfficiency_L3 = iGetter.get("Pixel/Barrel/HitEfficiency_L3");
2097  if(HitEfficiency_L3) HitEfficiency_L3->setBinContent(binx, biny,(float)hitEfficiency);
2098  }else if( isUpgrade && (currDir.find("Layer_4")!=string::npos) ){
2099  HitEfficiency_L4 = iGetter.get("Pixel/Barrel/HitEfficiency_L4");
2100  if(HitEfficiency_L4) HitEfficiency_L4->setBinContent(binx, biny,(float)hitEfficiency);
2101  }else if(currDir.find("Disk_1")!=string::npos && currDir.find("HalfCylinder_m")!=string::npos){
2102  HitEfficiency_Dm1 = iGetter.get("Pixel/Endcap/HitEfficiency_Dm1");
2103  if(HitEfficiency_Dm1) HitEfficiency_Dm1->setBinContent(binx, biny,(float)hitEfficiency);
2104  }else if(currDir.find("Disk_2")!=string::npos && currDir.find("HalfCylinder_m")!=string::npos){
2105  HitEfficiency_Dm2 = iGetter.get("Pixel/Endcap/HitEfficiency_Dm2");
2106  if(HitEfficiency_Dm2) HitEfficiency_Dm2->setBinContent(binx, biny,(float)hitEfficiency);
2107  }else if(currDir.find("Disk_3")!=string::npos && currDir.find("HalfCylinder_m")!=string::npos){
2108  HitEfficiency_Dm3 = iGetter.get("Pixel/Endcap/HitEfficiency_Dm3");
2109  if(HitEfficiency_Dm3) HitEfficiency_Dm3->setBinContent(binx, biny,(float)hitEfficiency);
2110  }else if(currDir.find("Disk_1")!=string::npos && currDir.find("HalfCylinder_p")!=string::npos){
2111  HitEfficiency_Dp1 = iGetter.get("Pixel/Endcap/HitEfficiency_Dp1");
2112  if(HitEfficiency_Dp1) HitEfficiency_Dp1->setBinContent(binx, biny,(float)hitEfficiency);
2113  }else if(currDir.find("Disk_2")!=string::npos && currDir.find("HalfCylinder_p")!=string::npos){
2114  HitEfficiency_Dp2 = iGetter.get("Pixel/Endcap/HitEfficiency_Dp2");
2115  if(HitEfficiency_Dp2) HitEfficiency_Dp2->setBinContent(binx, biny,(float)hitEfficiency);
2116  }else if(currDir.find("Disk_3")!=string::npos && currDir.find("HalfCylinder_p")!=string::npos){
2117  HitEfficiency_Dp3 = iGetter.get("Pixel/Endcap/HitEfficiency_Dp3");
2118  if(HitEfficiency_Dp3) HitEfficiency_Dp3->setBinContent(binx, biny,(float)hitEfficiency);
2119  }
2120  }
2121  }
2122  }else{
2123  //cout<<"finding subdirs now"<<std::endl;
2124  vector<string> subdirs = iGetter.getSubdirs();
2125  for (vector<string>::const_iterator it = subdirs.begin(); it != subdirs.end(); it++) {
2126  iBooker.cd(*it);
2127  iGetter.cd(*it);
2128  if(*it != "Pixel" && ((isbarrel && (*it).find("Barrel")==string::npos) || (!isbarrel && (*it).find("Endcap")==string::npos))) continue;
2129  fillEfficiency(iBooker, iGetter, isbarrel, isUpgrade);
2130  iBooker.goUp();
2131  iGetter.setCurrentFolder(iBooker.pwd());
2132  }
2133  }
2134  } // end online/offline
2135  //cout<<"leaving SiPixelActionExecutor::fillEfficiency..."<<std::endl;
2136 }
2137 
2138 //=============================================================================================================
2139 
2141  //cout<<"entering SiPixelActionExecutor::fillEfficiencySummary..."<<std::endl;
2142  //First we get the summary plot"
2143  if (!Tier0Flag_) return;
2144  HitEfficiencySummary = iGetter.get("Pixel/HitEfficiencySummary");
2145  //Now we will loop over the hit efficiency plots and fill it"
2146  string hitEfficiencyPostfix[] = {"L1","L2","L3","Dp1","Dp2","Dm1","Dm2"};
2147  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},{},{},{},{}};
2148  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},{},{},{},{}};
2149 
2150  for (int i = 0; i < 7; i++){
2151  string subdetName = "Endcap/";
2152  if (i < 3) subdetName = "Barrel/";
2153  char meName [50];
2154  sprintf(meName,"Pixel/%sHitEfficiency_%s",subdetName.c_str(),hitEfficiencyPostfix[i].c_str());
2155  MonitorElement * tempHitEffMap = iGetter.get(meName);
2156  float totalEff = 0.;
2157  int totalBins = 0;
2158  TH1 * hitEffMap = tempHitEffMap->getTH1();
2159  for (int xBin = 1; xBin < tempHitEffMap->getNbinsX() + 1; xBin++){
2160  if (fabs(hitEffMap->GetXaxis()->GetBinCenter(xBin)) < 1.) continue;
2161  for (int yBin = 1; yBin < tempHitEffMap->getNbinsY() + 1; yBin++){
2162  if (fabs(hitEffMap->GetYaxis()->GetBinCenter(yBin)) < 0.5) continue;
2163  bool ignoreBin = false;
2164  for (unsigned int j = 0; j < ignoreXBins[i].size(); j++){
2165  if (hitEffMap->GetXaxis()->GetBinCenter(xBin) == ignoreXBins[i][j] && hitEffMap->GetYaxis()->GetBinCenter(yBin) == ignoreYBins[i][j]){
2166  ignoreBin = true;
2167  break;
2168  }
2169  }
2170  if (ignoreBin) continue;
2171  if (!(tempHitEffMap->getBinContent(xBin,yBin) < 0.)) totalEff += tempHitEffMap->getBinContent(xBin,yBin);
2172  totalBins++;
2173  }
2174  }
2175  float overalEff = 0.;
2176  // std::cout << i << " " << totalEff << " " << totalBins << std::endl;
2177  if (totalBins > 0) overalEff = totalEff/float(totalBins);
2178  HitEfficiencySummary->setBinContent(i+1,overalEff);
2179  }
2180 
2181 }
void normaliseAvDigiOccVsLumi(DQMStore::IBooker &iBooker, DQMStore::IGetter &iGetter, int lumisec)
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:339
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.
void cd(void)
Definition: DQMStore.cc:269
MonitorElement * get(const std::string &path)
Definition: DQMStore.cc:305
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:285
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:327
void fillOccupancy(DQMStore::IBooker &iBooker, DQMStore::IGetter &iGetter, bool isbarrel)
int k[5][pyjets_maxn]
SiPixelActionExecutor(bool offlineXMLfile, bool Tier0Flag)
MonitorElement * DEV_charge_Barrel
MonitorElement * HitEfficiency_Dm3
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:277
void goUp(void)
Definition: DQMStore.cc:281
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:323
MonitorElement * DEV_size_Endcap
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:347
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
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
yBin
Definition: cuy.py:891
void bookEfficiency(DQMStore::IBooker &iBooker, bool isUpgrade)
MonitorElement * DEV_adc_Barrel