00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #include "DQMOffline/Trigger/interface/FourVectorHLTClient.h"
00011
00012 #include "DQMServices/Core/interface/QTest.h"
00013 #include "FWCore/ServiceRegistry/interface/Service.h"
00014 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00015 #include "FWCore/Framework/interface/ESHandle.h"
00016 #include "FWCore/Framework/interface/EventSetup.h"
00017 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00018 #include "DQMServices/Core/interface/QReport.h"
00019 #include "DQMServices/Core/interface/DQMStore.h"
00020 #include "DQMServices/Core/interface/MonitorElement.h"
00021 #include "TRandom.h"
00022 #include <TF1.h>
00023 #include <TGraphAsymmErrors.h>
00024 #include <TGraph.h>
00025 #include <stdio.h>
00026 #include <sstream>
00027 #include <math.h>
00028 #include <TProfile.h>
00029 #include <TProfile2D.h>
00030 #include <memory>
00031 #include <iostream>
00032 #include <iomanip>
00033 #include <map>
00034 #include <vector>
00035 #include <string>
00036 #include <fstream>
00037 #include "TROOT.h"
00038
00039
00040 using namespace edm;
00041 using namespace std;
00042
00043 FourVectorHLTClient::FourVectorHLTClient(const edm::ParameterSet& ps)
00044 {
00045
00046 parameters_=ps;
00047 initialize();
00048
00049 }
00050
00051 FourVectorHLTClient::~FourVectorHLTClient(){
00052
00053 LogDebug("FourVectorHLTClient")<< "FourVectorHLTClient: ending...." ;
00054
00055 }
00056
00057
00058 void FourVectorHLTClient::initialize(){
00059
00060 counterLS_=0;
00061 counterEvt_=0;
00062
00063
00064 dbe_ = Service<DQMStore>().operator->();
00065
00066 processname_ = parameters_.getUntrackedParameter<std::string>("processname","HLT");
00067
00068
00069
00070 sourceDir_ = TString(parameters_.getUntrackedParameter<string>("hltSourceDir",""));
00071
00072
00073 while(sourceDir_.Last('/') == sourceDir_.Length()-1) {
00074 sourceDir_.Remove(sourceDir_.Length()-1);
00075 }
00076 LogDebug("FourVectorHLTClient")<< "Source dir = " << sourceDir_ << endl;
00077
00078 clientDir_ = TString(parameters_.getUntrackedParameter<string>("hltClientDir",""));
00079
00080
00081 while(clientDir_.Last('/') == clientDir_.Length()-1) {
00082 clientDir_.Remove(clientDir_.Length()-1);
00083 }
00084 LogDebug("FourVectorHLTClient")<< "Client dir = " << clientDir_ << endl;
00085
00086 prescaleLS_ = parameters_.getUntrackedParameter<int>("prescaleLS", -1);
00087 LogDebug("FourVectorHLTClient")<< "DQM lumi section prescale = " << prescaleLS_ << " lumi section(s)"<< endl;
00088
00089 prescaleEvt_ = parameters_.getUntrackedParameter<int>("prescaleEvt", -1);
00090 LogDebug("FourVectorHLTClient")<< "DQM event prescale = " << prescaleEvt_ << " events(s)"<< endl;
00091
00092 customEffDir_ = TString(parameters_.getUntrackedParameter<string>("customEffDir","custom-efficiencies"));
00093 LogDebug("FourVectorHLTClient")<< "Custom Efficiencies dir = " << customEffDir_ << endl;
00094
00095 std::vector<edm::ParameterSet> effpaths = parameters_.getParameter<std::vector<edm::ParameterSet> >("effpaths");
00096
00097 std::pair<std::string, std::string> custompathnamepair;
00098 for(std::vector<edm::ParameterSet>::iterator pathconf = effpaths.begin() ; pathconf != effpaths.end();
00099 pathconf++) {
00100 custompathnamepair.first =pathconf->getParameter<std::string>("pathname");
00101 custompathnamepair.second = pathconf->getParameter<std::string>("denompathname");
00102 custompathnamepairs_.push_back(custompathnamepair);
00103
00104
00105 }
00106
00107 pathsSummaryFolder_ = parameters_.getUntrackedParameter ("pathsSummaryFolder",std::string("HLT/FourVector/PathsSummary/"));
00108 pathsSummaryHLTCorrelationsFolder_ = parameters_.getUntrackedParameter ("hltCorrelationsFolder",std::string("HLT/FourVector/PathsSummary/HLT Correlations/"));
00109 pathsSummaryFilterCountsFolder_ = parameters_.getUntrackedParameter ("filterCountsFolder",std::string("HLT/FourVector/PathsSummary/Filters Counts/"));
00110 pathsSummaryFilterEfficiencyFolder_ = parameters_.getUntrackedParameter ("filterEfficiencyFolder",std::string("HLT/FourVector/PathsSummary/Filters Efficiencies/"));
00111
00112
00113 }
00114
00115
00116 void FourVectorHLTClient::beginJob(){
00117
00118 LogDebug("FourVectorHLTClient")<<"[FourVectorHLTClient]: beginJob" << endl;
00119
00120 dbe_ = Service<DQMStore>().operator->();
00121
00122 }
00123
00124
00125 void FourVectorHLTClient::beginRun(const Run& r, const EventSetup& context) {
00126
00127 LogDebug("FourVectorHLTClient")<<"[FourVectorHLTClient]: beginRun" << endl;
00128
00129 bool changed=false;
00130
00131 if (!hltConfig_.init(r, context, processname_, changed)) {
00132
00133 processname_ = "FU";
00134
00135 if (!hltConfig_.init(r, context, processname_, changed)){
00136
00137 LogDebug("FourVectorHLTOffline") << "HLTConfigProvider failed to initialize.";
00138
00139 }
00140
00141
00142
00143
00144 }
00145
00146 }
00147
00148
00149 void FourVectorHLTClient::beginLuminosityBlock(const LuminosityBlock& lumiSeg, const EventSetup& context) {
00150
00151 }
00152
00153 void FourVectorHLTClient::endLuminosityBlock(const edm::LuminosityBlock& lumiSeg, const edm::EventSetup& c){
00154 }
00155
00156
00157
00158
00159 void FourVectorHLTClient::analyze(const Event& e, const EventSetup& context){
00160
00161 counterEvt_++;
00162 if (prescaleEvt_<1) return;
00163 if (prescaleEvt_>0 && counterEvt_%prescaleEvt_ != 0) return;
00164
00165 LogDebug("FourVectorHLTClient")<<"analyze..." << endl;
00166
00167 }
00168
00169
00170 void FourVectorHLTClient::endRun(const Run& r, const EventSetup& context){
00171
00172 LogDebug("FourVectorHLTClient")<<"FourVectorHLTClient:: endLuminosityBlock " << endl;
00173
00174
00175
00177 dbe_->setCurrentFolder(pathsSummaryFolder_.c_str());
00178
00179 std::vector<MonitorElement*> summaryME;
00180 summaryME = dbe_->getContents(pathsSummaryFilterCountsFolder_.c_str());
00181
00182 vector<float> hltPassCount;
00183
00184 for(unsigned int i=0; i< summaryME.size(); i++) {
00185
00186 TString nameME = (summaryME[i])->getName();
00187 LogDebug("FourVectorHLTClient") << "ME = " << nameME << endl;
00188
00189 TString fullPathToME = pathsSummaryFilterCountsFolder_ + nameME;
00190 LogDebug("FourVectorHLTClient") << "fullPathME = " << fullPathToME << endl;
00191
00192 if(nameME.Contains("Filters_")) {
00193
00194
00195 TH1F* MEHist = summaryME[i]->getTH1F() ;
00196 LogDebug("FourVectorHLTClient") << "this is TH1 first bin label = " << MEHist->GetXaxis()->GetBinLabel(1) << endl;
00197 LogDebug("FourVectorHLTClient") << "is this is TH1 = " << fullPathToME << endl;
00198
00199 TString nameMEeff = nameME+"_Eff";
00200 TString titleMEeff = nameME+" Efficiency wrt input to L1";
00201
00202 TH1F* effHist = (TH1F*) MEHist->Clone(nameMEeff.Data());
00203 effHist->SetTitle(titleMEeff.Data());
00204
00205 float firstBinContent = MEHist->GetBinContent(1);
00206
00207 if(firstBinContent !=0 ) {
00208
00209 effHist->Scale(1./firstBinContent);
00210
00211 }
00212 else {
00213
00214 unsigned int nBins = effHist->GetNbinsX();
00215 for(unsigned int bin = 0; bin < nBins+1; bin++) effHist->SetBinContent(bin, 0);
00216
00217 }
00218
00219 dbe_->setCurrentFolder(pathsSummaryFilterEfficiencyFolder_.c_str());
00220
00221 dbe_->book1D(nameMEeff.Data(), effHist);
00222
00223
00224 }
00225
00226 }
00227
00228
00230 vector<string> name;
00231 name.push_back("All");
00232 name.push_back("Muon");
00233 name.push_back("Egamma");
00234 name.push_back("Tau");
00235 name.push_back("JetMET");
00236 name.push_back("Rest");
00237 name.push_back("Special");
00238
00240 vector<string> datasetNames = hltConfig_.datasetNames() ;
00241
00242 for (unsigned int i=0;i<datasetNames.size();i++) {
00243
00244 name.push_back(datasetNames[i]);
00245
00246 }
00247
00248 string fullPathToME;
00249
00250 for (unsigned int i=0;i<name.size();i++) {
00251
00252 fullPathToME = pathsSummaryFolder_ +"HLT_"+name[i]+"_PassPass";
00253 v_ME_HLTPassPass_.push_back( dbe_->get(fullPathToME));
00254
00255 fullPathToME = pathsSummaryHLTCorrelationsFolder_+"HLT_"+name[i]+"_PassPass_Normalized";
00256 v_ME_HLTPassPass_Normalized_.push_back( dbe_->get(fullPathToME));
00257
00258 fullPathToME = pathsSummaryHLTCorrelationsFolder_+"HLT_"+name[i]+"_Pass_Normalized_Any";
00259 v_ME_HLTPass_Normalized_Any_.push_back( dbe_->get(fullPathToME));
00260
00261 }
00262 normalizeHLTMatrix();
00263
00264
00265
00266
00267 TObjArray *hltPathNameColl = new TObjArray(100);
00268 hltPathNameColl->SetOwner();
00269 std::vector<std::string> fullPathHLTFolders;
00270
00271
00273 dbe_->setCurrentFolder(sourceDir_.Data());
00274
00275 fullPathHLTFolders = dbe_->getSubdirs();
00276
00277 LogDebug("FourVectorHLTClient")<<"endRun: sourceDir_(" << sourceDir_.Data() << ") has " << fullPathHLTFolders.size() << " folders. " << endl;
00278
00279
00280 for(unsigned int i=0;i<fullPathHLTFolders.size();i++) {
00281
00282 LogDebug("FourVectorHLTClient")<<"endRun: sourceDir_(" << sourceDir_.Data() << ") folder["<< i << "] = " << fullPathHLTFolders[i] << endl;
00283 TString hltPath = fullPathHLTFolders[i].substr(fullPathHLTFolders[i].rfind('/')+1, fullPathHLTFolders[i].size());
00284
00286
00288 TString currEffFolder = clientDir_ + "/" + hltPath + "/" + customEffDir_ + "/";
00289 LogDebug("FourVectorHLTClient")<< "Custom Efficiencies dir path = " << currEffFolder << endl;
00290
00291 dbe_->setCurrentFolder(currEffFolder.Data());
00292
00293 hltMEs = dbe_->getContents(fullPathHLTFolders[i]);
00294 LogDebug("FourVectorHLTClient")<< "Number of MEs for this HLT path = " << hltMEs.size() << endl;
00295
00296
00297
00298 for (std::vector<std::pair<std::string, std::string> >::iterator custompathnamepair = custompathnamepairs_.begin(); custompathnamepair != custompathnamepairs_.end(); ++custompathnamepair)
00299 {
00300
00301
00302
00303
00304
00305
00306
00307 if(!hltPath.Contains(TString(custompathnamepair->first))) continue;
00308
00309 TString numPathName=hltPath;
00310 TString denPathName=TString(custompathnamepair->second);
00311
00312
00313 vector<TString> vStage;
00314 vStage.push_back(TString("L1"));
00315 vStage.push_back(TString("On"));
00316 vStage.push_back(TString("Off"));
00317 vStage.push_back(TString("Mc"));
00318 vStage.push_back(TString("L1UM"));
00319 vStage.push_back(TString("OnUM"));
00320 vStage.push_back(TString("OffUM"));
00321 vStage.push_back(TString("McUM"));
00322
00323 vector<TString> vObj;
00324 vObj.push_back(TString("l1Et"));
00325 vObj.push_back(TString("onEt"));
00326 vObj.push_back(TString("offEt"));
00327 vObj.push_back(TString("mcEt"));
00328
00329
00330
00331 for (unsigned int k=0; k<vObj.size();k++) {
00332 for (unsigned int l=0; l<vStage.size();l++) {
00333 for (unsigned int m=0; m<vStage.size();m++) {
00334
00335 TString oldHistPathNum;
00336 TString oldHistPathNumBck;
00337 TString oldHistPathDen;
00338
00339
00340 oldHistPathNum = sourceDir_+"/"+hltPath+"/"+numPathName+"_wrt_"+denPathName+"_"+vObj[k]+vStage[l]+vStage[m];
00341 oldHistPathNumBck = sourceDir_+"/"+hltPath+"/"+numPathName+"_wrt_"+denPathName+"_"+vObj[k]+vStage[m]+vStage[l];
00342
00343
00344 TString tempDenString = vStage[l];
00345 tempDenString.ReplaceAll("UM","") ;
00346 oldHistPathDen = sourceDir_+"/"+hltPath+"/"+numPathName+"_wrt_"+denPathName+"_"+vObj[k]+tempDenString;
00347
00348 MonitorElement *numME = dbe_->get(oldHistPathNum.Data());
00349 MonitorElement *numMEBck = dbe_->get(oldHistPathNumBck.Data());
00350 MonitorElement *denME = dbe_->get(oldHistPathDen.Data());
00351
00352 LogDebug("FourVectorHLTClient")<< " oldHistPathNum = " << oldHistPathNum << endl;
00353 LogDebug("FourVectorHLTClient")<< " oldHistPathNumBck = " << oldHistPathNumBck << endl;
00354 LogDebug("FourVectorHLTClient")<< " oldHistPathDen = " << oldHistPathDen << endl;
00355
00356
00357 if ( numME && denME ) {
00358
00359 LogDebug("FourVectorHLTClient")<< "DID find NUM and DEN histograms to derive eff " << vStage[m]<<"To"<<vStage[l]<<" using:" <<endl
00360 << " NUM = " << oldHistPathNum << endl
00361 << " DEN = " << oldHistPathDen << endl;
00362
00363 }
00364 else {
00365
00366 LogDebug("FourVectorHLTClient")<< "Cannot find NUM and DEN histograms to derive eff " << vStage[m]<<"To"<<vStage[l]<<" using:" <<endl
00367 << " NUM = " << oldHistPathNum << endl
00368 << " DEN = " << oldHistPathDen << endl;
00369
00370 if ( numMEBck && denME) {
00371
00372 LogDebug("FourVectorHLTClient")<< "DID find NUM and DEN histograms to derive eff " << vStage[m]<<"To"<<vStage[l]<<" using:" <<endl
00373 << " NUM = " << oldHistPathNumBck << endl
00374 << " DEN = " << oldHistPathDen << endl;
00375
00376 numME = numMEBck;
00377
00378 }
00379 else {
00380
00381 LogDebug("FourVectorHLTClient")<< "Cannot find NUM and DEN histograms to derive eff " << vStage[m]<<"To"<<vStage[l]<<" using:" <<endl
00382 << " NUM = " << oldHistPathNumBck << endl
00383 << " DEN = " << oldHistPathDen << endl;
00384
00385 continue;
00386 }
00387
00388 }
00389
00390
00391 TH1F * numHist = numME->getTH1F();
00392 TH1F * denHist = denME->getTH1F();
00393
00394
00395 TString newHistName = hltPath +"_wrt_" + denPathName +"_"+vObj[k]+"_Eff_"+vStage[m]+"To"+vStage[l];
00396
00397
00398 if(newHistName.Contains("UM")) {
00399
00400 newHistName.ReplaceAll("UM","");
00401 newHistName.Append("_UM");
00402
00403 }
00404
00405 TString newHistTitle = numPathName+" given " + denPathName +" "+vObj[k]+" Eff "+vStage[m]+"To"+vStage[l];
00406
00407
00408 if(newHistTitle.Contains("UM")) {
00409
00410 newHistTitle.ReplaceAll("UM","");
00411 newHistTitle.Append("_UM");
00412
00413 }
00414
00415 TString newHistPath = currEffFolder+newHistName;
00416
00417 LogDebug("FourVectorHLTClient")<< "Will make efficiency histogram " << newHistPath << endl;
00418
00419 TH1F* effHist = (TH1F*) numHist->Clone(newHistName.Data());
00420
00421 effHist->SetTitle(newHistTitle.Data());
00422
00423
00424
00425
00426
00427
00428
00429 calculateRatio(effHist, denHist);
00430
00431
00432
00433
00434
00435
00436
00437
00438
00439
00440
00441
00442
00443 LogDebug("FourVectorHLTClient")<< "Numerator hist " << numHist->GetName() << endl;
00444 LogDebug("FourVectorHLTClient")<< "Denominator hist " << denHist->GetName() << endl;
00445
00446 LogDebug("FourVectorHLTClient")<< "Booking efficiency histogram path " << newHistPath << endl;
00447 LogDebug("FourVectorHLTClient")<< "Booking efficiency histogram name " << newHistName << endl;
00448
00449
00450 dbe_->book1D(newHistName.Data(), effHist);
00451
00452
00453 }
00454 }
00455 }
00456
00457 vObj.clear();
00458 vObj.push_back(TString("l1Etal1Phi"));
00459 vObj.push_back(TString("onEtaonPhi"));
00460 vObj.push_back(TString("offEtaoffPhi"));
00461 vObj.push_back(TString("mcEtamcPhi"));
00462
00463 for (unsigned int k=0; k<vObj.size();k++) {
00464 for (unsigned int l=0; l<vStage.size();l++) {
00465 for (unsigned int m=0; m<vStage.size();m++) {
00466
00467
00468 TString oldHistPathNum;
00469 TString oldHistPathNumBck;
00470 TString oldHistPathDen;
00471
00472
00473 oldHistPathNum = sourceDir_+"/"+hltPath+"/"+numPathName+"_wrt_"+denPathName+"_"+vObj[k]+vStage[l]+vStage[m];
00474 oldHistPathNumBck = sourceDir_+"/"+hltPath+"/"+numPathName+"_wrt_"+denPathName+"_"+vObj[k]+vStage[m]+vStage[l];
00475
00476
00477 TString tempDenString = vStage[l];
00478 tempDenString.ReplaceAll("UM","") ;
00479 oldHistPathDen = sourceDir_+"/"+hltPath+"/"+numPathName+"_wrt_"+denPathName+"_"+vObj[k]+tempDenString;
00480
00481 MonitorElement *numME = dbe_->get(oldHistPathNum.Data());
00482 MonitorElement *numMEBck = dbe_->get(oldHistPathNumBck.Data());
00483 MonitorElement *denME = dbe_->get(oldHistPathDen.Data());
00484
00485 LogDebug("FourVectorHLTClient")<< " oldHistPathNum = " << oldHistPathNum << endl;
00486 LogDebug("FourVectorHLTClient")<< " oldHistPathNumBck = " << oldHistPathNumBck << endl;
00487 LogDebug("FourVectorHLTClient")<< " oldHistPathDen = " << oldHistPathDen << endl;
00488
00489
00490 if ( numME && denME ) {
00491
00492 LogDebug("FourVectorHLTClient")<< "DID find NUM and DEN histograms to derive eff " << vStage[m]<<"To"<<vStage[l]<<" using:" <<endl
00493 << " NUM = " << oldHistPathNum << endl
00494 << " DEN = " << oldHistPathDen << endl;
00495
00496 }
00497 else {
00498
00499 LogDebug("FourVectorHLTClient")<< "Cannot find NUM and DEN histograms to derive eff " << vStage[m]<<"To"<<vStage[l]<<" using:" <<endl
00500 << " NUM = " << oldHistPathNum << endl
00501 << " DEN = " << oldHistPathDen << endl;
00502
00503 if ( numMEBck && denME) {
00504
00505 LogDebug("FourVectorHLTClient")<< "DID find NUM and DEN histograms to derive eff " << vStage[m]<<"To"<<vStage[l]<<" using:" <<endl
00506 << " NUM = " << oldHistPathNumBck << endl
00507 << " DEN = " << oldHistPathDen << endl;
00508 numME = numMEBck;
00509
00510 }
00511 else {
00512
00513 LogDebug("FourVectorHLTClient")<< "Cannot find NUM and DEN histograms to derive eff " << vStage[m]<<"To"<<vStage[l]<<" using:" <<endl
00514 << " NUM = " << oldHistPathNumBck << endl
00515 << " DEN = " << oldHistPathDen << endl;
00516
00517 continue;
00518
00519 }
00520
00521 }
00522
00523 TH2F* numHist = numME->getTH2F();
00524 TH2F* denHist = denME->getTH2F();
00525
00526
00527
00528 TString newHistName = hltPath +"_wrt_" + denPathName +"_"+vObj[k]+"_Eff_"+vStage[m]+"To"+vStage[l];
00529
00530
00531 if(newHistName.Contains("UM")) {
00532
00533 newHistName.ReplaceAll("UM","");
00534 newHistName.Append("_UM");
00535
00536 }
00537
00538 TString newHistTitle = numPathName+" given " + denPathName +" "+vObj[k]+" Eff "+vStage[m]+"To"+vStage[l];
00539
00540 if(newHistTitle.Contains("UM")) {
00541
00542 newHistTitle.ReplaceAll("UM","");
00543 newHistTitle.Append("_UM");
00544
00545 }
00546
00547 TString newHistPath = currEffFolder+newHistName;
00548
00549 LogDebug("FourVectorHLTClient")<< "Will make efficiency histogram " << newHistPath << endl;
00550
00551 TH2F* effHist = (TH2F*) numHist->Clone(newHistName.Data());
00552
00553 effHist->SetTitle(newHistTitle.Data());
00554 effHist->Sumw2();
00555
00556
00557 effHist->Divide(numHist,denHist,1.,1.);
00558
00559
00560
00561 LogDebug("FourVectorHLTClient")<< "Booking efficiency histogram path " << newHistPath << endl;
00562 LogDebug("FourVectorHLTClient")<< "Booking efficiency histogram name " << newHistName << endl;
00563
00564
00565 dbe_->book2D(newHistName.Data(), effHist);
00566
00567 }
00568 }
00569 }
00570
00571 }
00572
00573 }
00574
00575
00576 hltPathNameColl->Delete();
00577
00578 }
00579
00580
00581 void FourVectorHLTClient::endJob(){
00582 }
00583
00584
00585 TH1F * FourVectorHLTClient::get1DHisto(string meName, DQMStore * dbi)
00586 {
00587
00588 MonitorElement * me_ = dbi->get(meName);
00589
00590 if (!me_) {
00591 LogDebug("FourVectorHLTClient")<< "ME NOT FOUND." << endl;
00592 return NULL;
00593 }
00594
00595 return me_->getTH1F();
00596
00597 }
00598
00599
00600 TH2F * FourVectorHLTClient::get2DHisto(string meName, DQMStore * dbi)
00601 {
00602
00603
00604 MonitorElement * me_ = dbi->get(meName);
00605
00606 if (!me_) {
00607 LogDebug("FourVectorHLTClient")<< "ME NOT FOUND." << endl;
00608 return NULL;
00609 }
00610
00611 return me_->getTH2F();
00612 }
00613
00614
00615 TProfile2D * FourVectorHLTClient::get2DProfile(string meName, DQMStore * dbi)
00616 {
00617
00618 MonitorElement * me_ = dbi->get(meName);
00619
00620 if (!me_) {
00621 LogDebug("FourVectorHLTClient")<< "ME NOT FOUND." << endl;
00622 return NULL;
00623 }
00624
00625 return me_->getTProfile2D();
00626 }
00627
00628
00629 TProfile * FourVectorHLTClient::get1DProfile(string meName, DQMStore * dbi)
00630 {
00631
00632 MonitorElement * me_ = dbi->get(meName);
00633
00634 if (!me_) {
00635 LogDebug("FourVectorHLTClient")<< "ME NOT FOUND." << endl;
00636 return NULL;
00637 }
00638
00639 return me_->getTProfile();
00640 }
00641
00642
00643 void FourVectorHLTClient::calculateRatio(TH1F* effHist, TH1F* denHist) {
00644
00645
00646 int nBins= effHist->GetNbinsX();
00647 for (int i=0;i<=nBins;i++) {
00648
00649 float k = effHist->GetBinContent(i);
00650 float N = denHist->GetBinContent(i);
00651
00652 float ratio;
00653 float err;
00654
00655
00656 if(N>0) ratio = k / N;
00657 else ratio = 0;
00658
00659 if(N > 0) {
00660
00661 if(ratio <= 1) {
00662 err = sqrt(ratio*(1-ratio)/N);
00663 }
00664
00665
00666
00667 else {
00668 err = 0;
00669 }
00670
00671 effHist->SetBinContent(i,ratio);
00672 effHist->SetBinError(i,err);
00673
00674 }
00675
00676 }
00677
00678 }
00679
00680
00681 void FourVectorHLTClient::normalizeHLTMatrix() {
00682
00683
00684 for (unsigned int i =0;i<v_ME_HLTPassPass_.size();i++) {
00685
00686 MonitorElement* ME_HLTPassPass_ = v_ME_HLTPassPass_[i];
00687 MonitorElement* ME_HLTPassPass_Normalized_ = v_ME_HLTPassPass_Normalized_[i];
00688 MonitorElement* ME_HLTPass_Normalized_Any_ = v_ME_HLTPass_Normalized_Any_[i];
00689
00690 if(!ME_HLTPassPass_ || !ME_HLTPassPass_Normalized_ || !ME_HLTPass_Normalized_Any_) return;
00691
00692 float passCount = 0;
00693 unsigned int nBinsX = ME_HLTPassPass_->getTH2F()->GetNbinsX();
00694 unsigned int nBinsY = ME_HLTPassPass_->getTH2F()->GetNbinsY();
00695
00696 for(unsigned int binX = 0; binX < nBinsX+1; binX++) {
00697
00698 passCount = ME_HLTPassPass_->getTH2F()->GetBinContent(binX,binX);
00699
00700
00701 for(unsigned int binY = 0; binY < nBinsY+1; binY++) {
00702
00703 if(passCount != 0) {
00704
00705
00706 float normalizedBinContentPassPass = (ME_HLTPassPass_->getTH2F()->GetBinContent(binX,binY))/passCount;
00707
00708
00709 ME_HLTPassPass_Normalized_->getTH2F()->SetBinContent(binX,binY,normalizedBinContentPassPass);
00710
00711
00712 if(binX == nBinsX) {
00713
00714 ME_HLTPass_Normalized_Any_->getTH1F()->SetBinContent(binY,normalizedBinContentPassPass);
00715
00716 }
00717
00718 }
00719 else {
00720
00721 ME_HLTPassPass_Normalized_->getTH2F()->SetBinContent(binX,binY,0);
00722
00723
00724 }
00725
00726 }
00727
00728 }
00729
00730 }
00731
00732 }