CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
FourVectorHLTClient.cc
Go to the documentation of this file.
1 /*
2 
3  FourVectorHLTClient.cc
4  author: Vladimir Rekovic, U Minn.
5  date of first version: Sept 2008
6 
7 */
8 
10 
20 #include "TRandom.h"
21 #include <TF1.h>
22 #include <TGraphAsymmErrors.h>
23 #include <TGraph.h>
24 #include <stdio.h>
25 #include <sstream>
26 #include <math.h>
27 #include <TProfile.h>
28 #include <TProfile2D.h>
29 #include <memory>
30 #include <iostream>
31 #include <iomanip>
32 #include <map>
33 #include <vector>
34 #include <string>
35 #include <fstream>
36 #include "TROOT.h"
37 
38 
39 using namespace edm;
40 using namespace std;
41 
43 {
44 
45  parameters_=ps;
46  initialize();
47 
48 }
49 
51 
52  LogDebug("FourVectorHLTClient")<< "FourVectorHLTClient: ending...." ;
53 
54 }
55 
56 //--------------------------------------------------------
58 
59  counterLS_=0;
60  counterEvt_=0;
61 
62  // get back-end interface
64 
65  processname_ = parameters_.getUntrackedParameter<std::string>("processname","HLT");
66 
67 
68  // base folder for the contents of this job
69  sourceDir_ = TString(parameters_.getUntrackedParameter<string>("hltSourceDir",""));
70 
71 
72 
73  // remove trainling "/" from dirname
74  while(sourceDir_.Last('/') == sourceDir_.Length()-1) {
75  sourceDir_.Remove(sourceDir_.Length()-1);
76  }
77  LogDebug("FourVectorHLTClient")<< "Source dir = " << sourceDir_ << endl;
78 
79  clientDir_ = TString(parameters_.getUntrackedParameter<string>("hltClientDir",""));
80 
81  // remove trainling "/" from dirname
82  while(clientDir_.Last('/') == clientDir_.Length()-1) {
83  clientDir_.Remove(clientDir_.Length()-1);
84  }
85  LogDebug("FourVectorHLTClient")<< "Client dir = " << clientDir_ << endl;
86 
87  prescaleLS_ = parameters_.getUntrackedParameter<int>("prescaleLS", -1);
88  LogDebug("FourVectorHLTClient")<< "DQM lumi section prescale = " << prescaleLS_ << " lumi section(s)"<< endl;
89 
90  prescaleEvt_ = parameters_.getUntrackedParameter<int>("prescaleEvt", -1);
91  LogDebug("FourVectorHLTClient")<< "DQM event prescale = " << prescaleEvt_ << " events(s)"<< endl;
92 
93  customEffDir_ = TString(parameters_.getUntrackedParameter<string>("customEffDir","custom-efficiencies"));
94  LogDebug("FourVectorHLTClient")<< "Custom Efficiencies dir = " << customEffDir_ << endl;
95 
96  std::vector<edm::ParameterSet> effpaths = parameters_.getParameter<std::vector<edm::ParameterSet> >("effpaths");
97 
98  std::pair<std::string, std::string> custompathnamepair;
99  for(std::vector<edm::ParameterSet>::iterator pathconf = effpaths.begin() ; pathconf != effpaths.end();
100  pathconf++) {
101  custompathnamepair.first =pathconf->getParameter<std::string>("pathname");
102  custompathnamepair.second = pathconf->getParameter<std::string>("denompathname");
103  custompathnamepairs_.push_back(custompathnamepair);
104  // customdenompathnames_.push_back(pathconf->getParameter<std::string>("denompathname"));
105  // custompathnames_.push_back(pathconf->getParameter<std::string>("pathname"));
106  }
107 
108  pathsSummaryFolder_ = parameters_.getUntrackedParameter ("pathsSummaryFolder",std::string("HLT/FourVector/PathsSummary/"));
109  pathsSummaryHLTCorrelationsFolder_ = parameters_.getUntrackedParameter ("hltCorrelationsFolder",std::string("HLT/FourVector/PathsSummary/HLT Correlations/"));
110  pathsSummaryFilterCountsFolder_ = parameters_.getUntrackedParameter ("filterCountsFolder",std::string("HLT/FourVector/PathsSummary/Filters Counts/"));
111  pathsSummaryFilterEfficiencyFolder_ = parameters_.getUntrackedParameter ("filterEfficiencyFolder",std::string("HLT/FourVector/PathsSummary/Filters Efficiencies/"));
112 
113 }
114 
115 //--------------------------------------------------------
117 
118  LogDebug("FourVectorHLTClient")<<"[FourVectorHLTClient]: beginJob" << endl;
119  // get backendinterface
121 
122 }
123 
124 //--------------------------------------------------------
125 void FourVectorHLTClient::beginRun(const Run& r, const EventSetup& context) {
126 
127  LogDebug("FourVectorHLTClient")<<"[FourVectorHLTClient]: beginRun" << endl;
128  // HLT config does not change within runs!
129  bool changed=false;
130 
131  if (!hltConfig_.init(r, context, processname_, changed)) {
132 
133  processname_ = "FU";
134 
135  if (!hltConfig_.init(r, context, processname_, changed)){
136 
137  LogDebug("FourVectorHLTOffline") << "HLTConfigProvider failed to initialize.";
138 
139  }
140 
141  // check if trigger name in (new) config
142  // cout << "Available TriggerNames are: " << endl;
143  // hltConfig_.dump("Triggers");
144  }
145 
146 }
147 
148 //--------------------------------------------------------
150  // optionally reset histograms here
151 }
152 
154 }
155 
156 
157 
158 //--------------------------------------------------------
159 void FourVectorHLTClient::analyze(const Event& e, const EventSetup& context){
160 
161  counterEvt_++;
162  if (prescaleEvt_<1) return;
163  if (prescaleEvt_>0 && counterEvt_%prescaleEvt_ != 0) return;
164 
165  LogDebug("FourVectorHLTClient")<<"analyze..." << endl;
166 
167 }
168 
169 //--------------------------------------------------------
170 void FourVectorHLTClient::endRun(const Run& r, const EventSetup& context){
171 
172  LogDebug("FourVectorHLTClient")<<"FourVectorHLTClient:: endLuminosityBlock " << endl;
173 
174 
175  // Work with PathsSummary ME's
177  dbe_->setCurrentFolder(pathsSummaryFolder_.c_str());
178 
179  std::vector<MonitorElement*> summaryME;
180  summaryME = dbe_->getContents(pathsSummaryFilterCountsFolder_.c_str());
181 
182  vector<float> hltPassCount;
183 
184  for(unsigned int i=0; i< summaryME.size(); i++) {
185 
186  TString nameME = (summaryME[i])->getName();
187  LogDebug("FourVectorHLTClient") << "ME = " << nameME << endl;
188 
189  TString fullPathToME = pathsSummaryFilterCountsFolder_ + nameME;
190  LogDebug("FourVectorHLTClient") << "fullPathME = " << fullPathToME << endl;
191 
192  if(nameME.Contains("Filters_")) {
193 
194 
195  TH1F* MEHist = summaryME[i]->getTH1F() ;
196  LogDebug("FourVectorHLTClient") << "this is TH1 first bin label = " << MEHist->GetXaxis()->GetBinLabel(1) << endl;
197  LogDebug("FourVectorHLTClient") << "is this is TH1 = " << fullPathToME << endl;
198 
199  TString nameMEeff = nameME+"_Eff";
200  TString titleMEeff = nameME+" Efficiency wrt input to L1";
201 
202  TH1F* effHist = (TH1F*) MEHist->Clone(nameMEeff.Data());
203  effHist->SetTitle(titleMEeff.Data());
204 
205  float firstBinContent = MEHist->GetBinContent(1);
206 
207  if(firstBinContent !=0 ) {
208 
209  effHist->Scale(1./firstBinContent);
210 
211  }
212  else {
213 
214  unsigned int nBins = effHist->GetNbinsX();
215  for(unsigned int bin = 0; bin < nBins+1; bin++) effHist->SetBinContent(bin, 0);
216 
217  }
218 
219  dbe_->setCurrentFolder(pathsSummaryFilterEfficiencyFolder_.c_str());
220 
221  dbe_->book1D(nameMEeff.Data(), effHist);
222 
223 
224  } // end if "Filters_" ME
225 
226  } // end for MEs
227 
228  // Normalize PassPass and PassFail Matrices
230  vector<string> name;
231  name.push_back("All");
232  name.push_back("Muon");
233  name.push_back("Egamma");
234  name.push_back("Tau");
235  name.push_back("JetMET");
236  name.push_back("Rest");
237  name.push_back("Special");
238 
240  vector<string> datasetNames = hltConfig_.datasetNames() ;
241 
242  for (unsigned int i=0;i<datasetNames.size();i++) {
243 
244  name.push_back(datasetNames[i]);
245 
246  }
247 
248  string fullPathToME;
249 
250  for (unsigned int i=0;i<name.size();i++) {
251 
252  fullPathToME = pathsSummaryFolder_ +"HLT_"+name[i]+"_PassPass";
253  v_ME_HLTPassPass_.push_back( dbe_->get(fullPathToME));
254 
255  fullPathToME = pathsSummaryHLTCorrelationsFolder_+"HLT_"+name[i]+"_PassPass_Normalized";
256  v_ME_HLTPassPass_Normalized_.push_back( dbe_->get(fullPathToME));
257 
258  fullPathToME = pathsSummaryHLTCorrelationsFolder_+"HLT_"+name[i]+"_Pass_Normalized_Any";
259  v_ME_HLTPass_Normalized_Any_.push_back( dbe_->get(fullPathToME));
260 
261  }
262  normalizeHLTMatrix();
263 
264 
265 
266  // HLT paths
267  TObjArray *hltPathNameColl = new TObjArray(100);
268  hltPathNameColl->SetOwner();
269  std::vector<std::string> fullPathHLTFolders;
270 
271  // get subdir of the sourceDir_ to get HLT path names
273  dbe_->setCurrentFolder(sourceDir_.Data());
274 
275  fullPathHLTFolders = dbe_->getSubdirs();
276 
277 
278  LogDebug("FourVectorHLTClient")<<"endRun: sourceDir_(" << sourceDir_.Data() << ") has " << fullPathHLTFolders.size() << " folders. " << endl;
279 
280 
281  for(unsigned int i=0;i<fullPathHLTFolders.size();i++) {
282 
283  LogDebug("FourVectorHLTClient")<<"endRun: sourceDir_(" << sourceDir_.Data() << ") folder["<< i << "] = " << fullPathHLTFolders[i] << endl;
284  TString hltPath = fullPathHLTFolders[i].substr(fullPathHLTFolders[i].rfind('/')+1, fullPathHLTFolders[i].size());
285 
286  //*****
287  hltPath = removeVersions(hltPath);
288  //*****
289 
291  // Efficiencies
293 
294  TString currEffFolder = clientDir_ + "/" + hltPath + "/" + customEffDir_ + "/";
295 
296  //*****
297  currEffFolder = removeVersions(currEffFolder);
298  //*****
299 
300 
301  LogDebug("FourVectorHLTClient")<< "Custom Efficiencies dir path = " << currEffFolder << endl;
302 
303  dbe_->setCurrentFolder(currEffFolder.Data());
304 
305 
306  hltMEs = dbe_->getContents(fullPathHLTFolders[i]);
307  LogDebug("FourVectorHLTClient")<< "Number of MEs for this HLT path = " << hltMEs.size() << endl;
308 
309  // custom efficiencies
310 
311  for (std::vector<std::pair<std::string, std::string> >::iterator custompathnamepair = custompathnamepairs_.begin(); custompathnamepair != custompathnamepairs_.end(); ++custompathnamepair)
312  {
313 
314  //TString numPathName=TString(custompathnamepair->first);
315  //if(!hltPath.Contains(numPathName,TString::kExact)) continue;
316  //TString numPathName=hltPath;
317  //if(!hltPath.Contains(numPathName,TString::kExact)) continue;
318  //LogDebug("FourVectorHLTClient")<< "hltPath = " << hltPath << " matchString = " << custompathnamepair->first << endl;
319  //if(!hltPath.Contains(TString(custompathnamepair->first),TString::kExact)) continue;
320  if(!hltPath.Contains(TString(custompathnamepair->first))) continue;
321 
322  TString numPathName=hltPath;
323  TString denPathName=TString(custompathnamepair->second);
324 
325  numPathName = removeVersions(numPathName);
326 
327 
328 
329  vector<TString> vStage;
330  vStage.push_back(TString("L1"));
331  vStage.push_back(TString("On"));
332  vStage.push_back(TString("Off"));
333  vStage.push_back(TString("Mc"));
334  vStage.push_back(TString("L1UM"));
335  vStage.push_back(TString("OnUM"));
336  vStage.push_back(TString("OffUM"));
337  vStage.push_back(TString("McUM"));
338 
339  vector<TString> vObj;
340  vObj.push_back(TString("l1Et"));
341  vObj.push_back(TString("onEt"));
342  vObj.push_back(TString("offEt"));
343  vObj.push_back(TString("mcEt"));
344 
345 
346  // TH1Fs
347  for (unsigned int k=0; k<vObj.size();k++) {
348  for (unsigned int l=0; l<vStage.size();l++) {
349  for (unsigned int m=0; m<vStage.size();m++) {
350 
351  TString oldHistPathNum;
352  TString oldHistPathNumBck;
353  TString oldHistPathDen;
354 
355  // not the differeence b/w Num and NumBck, as in OnOff vs OffOn
356  oldHistPathNum = sourceDir_+"/"+hltPath+"/"+numPathName+"_wrt_"+denPathName+"_"+vObj[k]+vStage[l]+vStage[m];
357  oldHistPathNumBck = sourceDir_+"/"+hltPath+"/"+numPathName+"_wrt_"+denPathName+"_"+vObj[k]+vStage[m]+vStage[l];
358 
359  // In the deominator hist name, we don't have any "UM" substrings, so remove them
360  TString tempDenString = vStage[l];
361  tempDenString.ReplaceAll("UM","") ;
362  oldHistPathDen = sourceDir_+"/"+hltPath+"/"+numPathName+"_wrt_"+denPathName+"_"+vObj[k]+tempDenString;
363 
364  MonitorElement *numME = dbe_->get(oldHistPathNum.Data());
365  MonitorElement *numMEBck = dbe_->get(oldHistPathNumBck.Data());
366  MonitorElement *denME = dbe_->get(oldHistPathDen.Data());
367 
368  LogDebug("FourVectorHLTClient")<< " oldHistPathNum = " << oldHistPathNum << endl;
369  LogDebug("FourVectorHLTClient")<< " oldHistPathNumBck = " << oldHistPathNumBck << endl;
370  LogDebug("FourVectorHLTClient")<< " oldHistPathDen = " << oldHistPathDen << endl;
371 
372  //check if HLTOffline histogram exist
373  if ( numME && denME ) {
374 
375  LogDebug("FourVectorHLTClient")<< "DID find NUM and DEN histograms to derive eff " << vStage[m]<<"To"<<vStage[l]<<" using:" <<endl
376  << " NUM = " << oldHistPathNum << endl
377  << " DEN = " << oldHistPathDen << endl;
378 
379  }
380  else {
381 
382  LogDebug("FourVectorHLTClient")<< "Cannot find NUM and DEN histograms to derive eff " << vStage[m]<<"To"<<vStage[l]<<" using:" <<endl
383  << " NUM = " << oldHistPathNum << endl
384  << " DEN = " << oldHistPathDen << endl;
385 
386  if ( numMEBck && denME) {
387 
388  LogDebug("FourVectorHLTClient")<< "DID find NUM and DEN histograms to derive eff " << vStage[m]<<"To"<<vStage[l]<<" using:" <<endl
389  << " NUM = " << oldHistPathNumBck << endl
390  << " DEN = " << oldHistPathDen << endl;
391 
392  numME = numMEBck;
393 
394  }
395  else {
396 
397  LogDebug("FourVectorHLTClient")<< "Cannot find NUM and DEN histograms to derive eff " << vStage[m]<<"To"<<vStage[l]<<" using:" <<endl
398  << " NUM = " << oldHistPathNumBck << endl
399  << " DEN = " << oldHistPathDen << endl;
400 
401  continue;
402  }
403 
404  }
405 
406  // EtaPhi histos are TH2s, the rest are TH1s
407  TH1F * numHist = numME->getTH1F();
408  TH1F * denHist = denME->getTH1F();
409 
410  // build names and title for efficiency histogram
411  TString newHistName = hltPath +"_wrt_" + denPathName +"_"+vObj[k]+"_Eff_"+vStage[m]+"To"+vStage[l];
412 
413  // if there is "UM", remove it first,then append it to the end of the name
414  if(newHistName.Contains("UM")) {
415 
416  newHistName.ReplaceAll("UM","");
417  newHistName.Append("_UM");
418 
419  }
420 
421  TString newHistTitle = numPathName+" given " + denPathName +" "+vObj[k]+" Eff "+vStage[m]+"To"+vStage[l];
422 
423  // if there is "UM", remove it first,then append it to the end of the name
424  if(newHistTitle.Contains("UM")) {
425 
426  newHistTitle.ReplaceAll("UM","");
427  newHistTitle.Append("_UM");
428 
429  }
430 
431  TString newHistPath = currEffFolder+newHistName;
432 
433  LogDebug("FourVectorHLTClient")<< "Will make efficiency histogram " << newHistPath << endl;
434 
435  TH1F* effHist = (TH1F*) numHist->Clone(newHistName.Data());
436 
437  effHist->SetTitle(newHistTitle.Data());
438 
439  //effHist->Sumw2();
440  //denHist->Sumw2();
441  //effHist->Divide(numHist,denHist);
442 
443  //effHist->Divide(numHist,denHist,1.,1.,"B");
444 
445  calculateRatio(effHist, denHist);
446 
447  /*
448  effHist->Divide(numHist,denHist,1.,1.);
449 
450  for (int i=0;i<=effHist->GetNbinsX();i++) {
451 
452  float err = 0;
453  if(numHist->GetBinContent(i)>0) err = 1./sqrt(numHist->GetBinContent(i)); // 1/sqrt(number of total)
454  effHist->SetBinError(i,err);
455 
456  }
457  */
458 
459  LogDebug("FourVectorHLTClient")<< "Numerator hist " << numHist->GetName() << endl;
460  LogDebug("FourVectorHLTClient")<< "Denominator hist " << denHist->GetName() << endl;
461 
462  LogDebug("FourVectorHLTClient")<< "Booking efficiency histogram path " << newHistPath << endl;
463  LogDebug("FourVectorHLTClient")<< "Booking efficiency histogram name " << newHistName << endl;
464 
465  // book eff histos
466  dbe_->book1D(newHistName.Data(), effHist);
467 
468 
469  } // end for Stage m
470  } // end for Stage l
471  } //end for obj k
472 
473  vObj.clear();
474  vObj.push_back(TString("l1Etal1Phi"));
475  vObj.push_back(TString("onEtaonPhi"));
476  vObj.push_back(TString("offEtaoffPhi"));
477  vObj.push_back(TString("mcEtamcPhi"));
478 
479  for (unsigned int k=0; k<vObj.size();k++) {
480  for (unsigned int l=0; l<vStage.size();l++) {
481  for (unsigned int m=0; m<vStage.size();m++) {
482 
483 
484  TString oldHistPathNum;
485  TString oldHistPathNumBck;
486  TString oldHistPathDen;
487 
488  // not the differeence b/w Num and NumBck, as in OnOff vs OffOn
489  oldHistPathNum = sourceDir_+"/"+hltPath+"/"+numPathName+"_wrt_"+denPathName+"_"+vObj[k]+vStage[l]+vStage[m];
490  oldHistPathNumBck = sourceDir_+"/"+hltPath+"/"+numPathName+"_wrt_"+denPathName+"_"+vObj[k]+vStage[m]+vStage[l];
491 
492  // In the deominator hist name, we don't have any "UM" substrings, so remove them
493  TString tempDenString = vStage[l];
494  tempDenString.ReplaceAll("UM","") ;
495  oldHistPathDen = sourceDir_+"/"+hltPath+"/"+numPathName+"_wrt_"+denPathName+"_"+vObj[k]+tempDenString;
496 
497  MonitorElement *numME = dbe_->get(oldHistPathNum.Data());
498  MonitorElement *numMEBck = dbe_->get(oldHistPathNumBck.Data());
499  MonitorElement *denME = dbe_->get(oldHistPathDen.Data());
500 
501  LogDebug("FourVectorHLTClient")<< " oldHistPathNum = " << oldHistPathNum << endl;
502  LogDebug("FourVectorHLTClient")<< " oldHistPathNumBck = " << oldHistPathNumBck << endl;
503  LogDebug("FourVectorHLTClient")<< " oldHistPathDen = " << oldHistPathDen << endl;
504 
505  //check if HLTOffline histogram exist
506  if ( numME && denME ) {
507 
508  LogDebug("FourVectorHLTClient")<< "DID find NUM and DEN histograms to derive eff " << vStage[m]<<"To"<<vStage[l]<<" using:" <<endl
509  << " NUM = " << oldHistPathNum << endl
510  << " DEN = " << oldHistPathDen << endl;
511 
512  }
513  else {
514 
515  LogDebug("FourVectorHLTClient")<< "Cannot find NUM and DEN histograms to derive eff " << vStage[m]<<"To"<<vStage[l]<<" using:" <<endl
516  << " NUM = " << oldHistPathNum << endl
517  << " DEN = " << oldHistPathDen << endl;
518 
519  if ( numMEBck && denME) {
520 
521  LogDebug("FourVectorHLTClient")<< "DID find NUM and DEN histograms to derive eff " << vStage[m]<<"To"<<vStage[l]<<" using:" <<endl
522  << " NUM = " << oldHistPathNumBck << endl
523  << " DEN = " << oldHistPathDen << endl;
524  numME = numMEBck;
525 
526  }
527  else {
528 
529  LogDebug("FourVectorHLTClient")<< "Cannot find NUM and DEN histograms to derive eff " << vStage[m]<<"To"<<vStage[l]<<" using:" <<endl
530  << " NUM = " << oldHistPathNumBck << endl
531  << " DEN = " << oldHistPathDen << endl;
532 
533  continue;
534 
535  }
536 
537  }
538 
539  TH2F* numHist = numME->getTH2F();
540  TH2F* denHist = denME->getTH2F();
541 
542  // build names and title for efficiency histogram
543 
544  TString newHistName = hltPath +"_wrt_" + denPathName +"_"+vObj[k]+"_Eff_"+vStage[m]+"To"+vStage[l];
545 
546  // if there is "UM", remove it first,then append it to the end of the name
547  if(newHistName.Contains("UM")) {
548 
549  newHistName.ReplaceAll("UM","");
550  newHistName.Append("_UM");
551 
552  }
553 
554  TString newHistTitle = numPathName+" given " + denPathName +" "+vObj[k]+" Eff "+vStage[m]+"To"+vStage[l];
555  // if there is "UM", remove it first,then append it to the end of the name
556  if(newHistTitle.Contains("UM")) {
557 
558  newHistTitle.ReplaceAll("UM","");
559  newHistTitle.Append("_UM");
560 
561  }
562 
563  TString newHistPath = currEffFolder+newHistName;
564  newHistPath = removeVersions(newHistPath);
565 
566  LogDebug("FourVectorHLTClient")<< "Will make efficiency histogram " << newHistPath << endl;
567 
568  TH2F* effHist = (TH2F*) numHist->Clone(newHistName.Data());
569 
570  effHist->SetTitle(newHistTitle.Data());
571  effHist->Sumw2();
572  //denHist->Sumw2();
573  //effHist->Divide(numHist,denHist,1.,1.,"B");
574  effHist->Divide(numHist,denHist,1.,1.);
575 
576  //reportSummaryMap_ = dbe_->book2D(numHist->Divide(denHist));
577 
578  LogDebug("FourVectorHLTClient")<< "Booking efficiency histogram path " << newHistPath << endl;
579  LogDebug("FourVectorHLTClient")<< "Booking efficiency histogram name " << newHistName << endl;
580 
581  // book eff histos
582  dbe_->book2D(newHistName.Data(), effHist);
583 
584  } // end for Stage m
585  } // end for Stage l
586  } //end for obj k
587 
588  } // end for custompathpair
589 
590  } // end loop over folders for i
591 
592 
593  hltPathNameColl->Delete();
594 
595 }
596 
597 //--------------------------------------------------------
599 }
600 
601 
602 TH1F * FourVectorHLTClient::get1DHisto(string meName, DQMStore * dbi)
603 {
604 
605  MonitorElement * me_ = dbi->get(meName);
606 
607  if (!me_) {
608  LogDebug("FourVectorHLTClient")<< "ME NOT FOUND." << endl;
609  return NULL;
610  }
611 
612  return me_->getTH1F();
613 
614 }
615 
616 
617 TH2F * FourVectorHLTClient::get2DHisto(string meName, DQMStore * dbi)
618 {
619 
620 
621  MonitorElement * me_ = dbi->get(meName);
622 
623  if (!me_) {
624  LogDebug("FourVectorHLTClient")<< "ME NOT FOUND." << endl;
625  return NULL;
626  }
627 
628  return me_->getTH2F();
629 }
630 
631 
632 TProfile2D * FourVectorHLTClient::get2DProfile(string meName, DQMStore * dbi)
633 {
634 
635  MonitorElement * me_ = dbi->get(meName);
636 
637  if (!me_) {
638  LogDebug("FourVectorHLTClient")<< "ME NOT FOUND." << endl;
639  return NULL;
640  }
641 
642  return me_->getTProfile2D();
643 }
644 
645 
646 TProfile * FourVectorHLTClient::get1DProfile(string meName, DQMStore * dbi)
647 {
648 
649  MonitorElement * me_ = dbi->get(meName);
650 
651  if (!me_) {
652  LogDebug("FourVectorHLTClient")<< "ME NOT FOUND." << endl;
653  return NULL;
654  }
655 
656  return me_->getTProfile();
657 }
658 
659 TString FourVectorHLTClient::removeVersions(TString histVersion) {
660  for (int ii = 100; ii >= 0; ii--) {
661  string ver = "_v";
662  string version ="";
663  stringstream ss;
664  ss << ver << ii;
665  ss >> version;
666 
667  if (histVersion.Contains(version)){
668  histVersion.ReplaceAll(version,"");
669  }
670  }
671  return histVersion;
672 }
673 
674 void FourVectorHLTClient::calculateRatio(TH1F* effHist, TH1F* denHist) {
675 
676  //cout << " NUMERATOR histogram name = " << effHist->GetName() << endl;
677  int nBins= effHist->GetNbinsX();
678  for (int i=0;i<=nBins;i++) {
679 
680  float k = effHist->GetBinContent(i); // number of pass
681  float N = denHist->GetBinContent(i); // number of total
682 
683  float ratio;
684  float err;
685 
686  //ratio = N ? k / N : 0;
687  if(N>0) ratio = k / N;
688  else ratio = 0;
689 
690  if(N > 0) {
691 
692  if(ratio <= 1) {
693  err = sqrt(ratio*(1-ratio)/N);
694  }
695  //else if(ratio == 1) {
696  //err = 1./sqrt(2*N);
697  //}
698  else {
699  err = 0;
700  }
701 
702  effHist->SetBinContent(i,ratio);
703  effHist->SetBinError(i,err);
704 
705  }
706 
707  }
708 
709 }
710 
711 
713 
714 
715  for (unsigned int i =0;i<v_ME_HLTPassPass_.size();i++) {
716 
717  MonitorElement* ME_HLTPassPass_ = v_ME_HLTPassPass_[i];
718  MonitorElement* ME_HLTPassPass_Normalized_ = v_ME_HLTPassPass_Normalized_[i];
719  MonitorElement* ME_HLTPass_Normalized_Any_ = v_ME_HLTPass_Normalized_Any_[i];
720 
721  if(!ME_HLTPassPass_ || !ME_HLTPassPass_Normalized_ || !ME_HLTPass_Normalized_Any_) return;
722 
723  float passCount = 0;
724  unsigned int nBinsX = ME_HLTPassPass_->getTH2F()->GetNbinsX();
725  unsigned int nBinsY = ME_HLTPassPass_->getTH2F()->GetNbinsY();
726 
727  for(unsigned int binX = 0; binX < nBinsX+1; binX++) {
728 
729  passCount = ME_HLTPassPass_->getTH2F()->GetBinContent(binX,binX);
730 
731 
732  for(unsigned int binY = 0; binY < nBinsY+1; binY++) {
733 
734  if(passCount != 0) {
735 
736  // normalize each bin to number of passCount
737  float normalizedBinContentPassPass = (ME_HLTPassPass_->getTH2F()->GetBinContent(binX,binY))/passCount;
738  //float normalizedBinContentPassFail = (ME_HLTPassFail_->getTH2F()->GetBinContent(binX,binY))/passCount;
739 
740  ME_HLTPassPass_Normalized_->getTH2F()->SetBinContent(binX,binY,normalizedBinContentPassPass);
741  //ME_HLTPassFail_Normalized_->getTH2F()->SetBinContent(binX,binY,normalizedBinContentPassFail);
742 
743  if(binX == nBinsX) {
744 
745  ME_HLTPass_Normalized_Any_->getTH1F()->SetBinContent(binY,normalizedBinContentPassPass);
746 
747  }
748 
749  }
750  else {
751 
752  ME_HLTPassPass_Normalized_->getTH2F()->SetBinContent(binX,binY,0);
753  //ME_HLTPassFail_Normalized_->getTH2F()->SetBinContent(binX,binY,0);
754 
755  } // end if else
756 
757  } // end for binY
758 
759  } // end for binX
760 
761  } // end for i
762 
763 }
#define LogDebug(id)
static AlgebraicMatrix initialize()
int i
Definition: DBlmapReader.cc:9
void beginRun(const edm::Run &r, const edm::EventSetup &c)
BeginRun.
std::vector< std::string > getSubdirs(void) const
Definition: DQMStore.cc:1659
TProfile2D * getTProfile2D(void) const
MonitorElement * book1D(const char *name, const char *title, int nchX, double lowX, double highX)
Book 1D histogram.
Definition: DQMStore.cc:954
void beginJob()
BeginJob.
#define NULL
Definition: scimark2.h:8
TH2F * get2DHisto(std::string meName, DQMStore *dbi)
int ii
Definition: cuy.py:588
TString removeVersions(TString histVersion)
void analyze(const edm::Event &e, const edm::EventSetup &c)
Fake Analyze.
TProfile * get1DProfile(std::string meName, DQMStore *dbi)
void endLuminosityBlock(const edm::LuminosityBlock &lumiSeg, const edm::EventSetup &c)
DQM Client Diagnostic.
T sqrt(T t)
Definition: SSEVec.h:48
virtual ~FourVectorHLTClient()
Destructor.
MonitorElement * get(const std::string &path) const
get ME from full pathname (e.g. &quot;my/long/dir/my_histo&quot;)
Definition: DQMStore.cc:1708
std::vector< MonitorElement * > getContents(const std::string &path) const
Definition: DQMStore.cc:1737
DQMStore * dbe_
int k[5][pyjets_maxn]
#define N
Definition: blowfish.cc:9
TH1F * getTH1F(void) const
FourVectorHLTClient(const edm::ParameterSet &ps)
Constructor.
void calculateRatio(TH1F *effHist, TH1F *denHist)
TProfile * getTProfile(void) const
TProfile2D * get2DProfile(std::string meName, DQMStore *dbi)
void beginLuminosityBlock(const edm::LuminosityBlock &lumiSeg, const edm::EventSetup &context)
TH1F * get1DHisto(std::string meName, DQMStore *dbi)
TH2F * getTH2F(void) const
MonitorElement * book2D(const char *name, const char *title, int nchX, double lowX, double highX, int nchY, double lowY, double highY)
Book 2D histogram.
Definition: DQMStore.cc:1082
tuple size
Write out results.
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:667
Definition: Run.h:41
void endRun(const edm::Run &r, const edm::EventSetup &c)
EndRun.