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