23 #include <TGraphAsymmErrors.h>
29 #include <TProfile2D.h>
53 LogDebug(
"FourVectorHLTClient")<<
"FourVectorHLTClient: ending...." ;
66 processname_ = parameters_.getUntrackedParameter<
std::string>(
"processname",
"HLT");
70 sourceDir_ = TString(parameters_.getUntrackedParameter<
string>(
"hltSourceDir",
""));
75 while(sourceDir_.Last(
'/') == sourceDir_.Length()-1) {
76 sourceDir_.Remove(sourceDir_.Length()-1);
78 LogDebug(
"FourVectorHLTClient")<<
"Source dir = " << sourceDir_ << endl;
80 clientDir_ = TString(parameters_.getUntrackedParameter<
string>(
"hltClientDir",
""));
83 while(clientDir_.Last(
'/') == clientDir_.Length()-1) {
84 clientDir_.Remove(clientDir_.Length()-1);
86 LogDebug(
"FourVectorHLTClient")<<
"Client dir = " << clientDir_ << endl;
88 prescaleLS_ = parameters_.getUntrackedParameter<
int>(
"prescaleLS", -1);
89 LogDebug(
"FourVectorHLTClient")<<
"DQM lumi section prescale = " << prescaleLS_ <<
" lumi section(s)"<< endl;
91 prescaleEvt_ = parameters_.getUntrackedParameter<
int>(
"prescaleEvt", -1);
92 LogDebug(
"FourVectorHLTClient")<<
"DQM event prescale = " << prescaleEvt_ <<
" events(s)"<< endl;
94 customEffDir_ = TString(parameters_.getUntrackedParameter<
string>(
"customEffDir",
"custom-efficiencies"));
95 LogDebug(
"FourVectorHLTClient")<<
"Custom Efficiencies dir = " << customEffDir_ << endl;
97 std::vector<edm::ParameterSet> effpaths = parameters_.getParameter<std::vector<edm::ParameterSet> >(
"effpaths");
99 std::pair<std::string, std::string> custompathnamepair;
100 for(std::vector<edm::ParameterSet>::iterator pathconf = effpaths.begin() ; pathconf != effpaths.end();
102 custompathnamepair.first =pathconf->getParameter<
std::string>(
"pathname");
103 custompathnamepair.second = pathconf->getParameter<
std::string>(
"denompathname");
104 custompathnamepairs_.push_back(custompathnamepair);
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/"));
119 LogDebug(
"FourVectorHLTClient")<<
"[FourVectorHLTClient]: beginJob" << endl;
128 LogDebug(
"FourVectorHLTClient")<<
"[FourVectorHLTClient]: beginRun" << endl;
132 if (!hltConfig_.init(r, context, processname_, changed)) {
136 if (!hltConfig_.init(r, context, processname_, changed)){
138 LogDebug(
"FourVectorHLTOffline") <<
"HLTConfigProvider failed to initialize.";
163 if (prescaleEvt_<1)
return;
164 if (prescaleEvt_>0 && counterEvt_%prescaleEvt_ != 0)
return;
166 LogDebug(
"FourVectorHLTClient")<<
"analyze..." << endl;
173 LogDebug(
"FourVectorHLTClient")<<
"FourVectorHLTClient:: endLuminosityBlock " << endl;
180 std::vector<MonitorElement*> summaryME;
181 summaryME =
dbe_->
getContents(pathsSummaryFilterCountsFolder_.c_str());
183 vector<float> hltPassCount;
185 for(
unsigned int i=0;
i< summaryME.size();
i++) {
187 TString nameME = (summaryME[
i])->getName();
188 LogDebug(
"FourVectorHLTClient") <<
"ME = " << nameME << endl;
190 TString fullPathToME = pathsSummaryFilterCountsFolder_ + nameME;
191 LogDebug(
"FourVectorHLTClient") <<
"fullPathME = " << fullPathToME << endl;
193 if(nameME.Contains(
"Filters_")) {
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;
200 TString nameMEeff = nameME+
"_Eff";
201 TString titleMEeff = nameME+
" Efficiency wrt input to L1";
203 TH1F* effHist = (TH1F*) MEHist->Clone(nameMEeff.Data());
204 effHist->SetTitle(titleMEeff.Data());
206 float firstBinContent = MEHist->GetBinContent(1);
208 if(firstBinContent !=0 ) {
210 effHist->Scale(1./firstBinContent);
215 unsigned int nBins = effHist->GetNbinsX();
216 for(
unsigned int bin = 0;
bin < nBins+1;
bin++) effHist->SetBinContent(
bin, 0);
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");
241 vector<string>
datasetNames = hltConfig_.datasetNames() ;
243 for (
unsigned int i=0;
i<datasetNames.size();
i++) {
245 name.push_back(datasetNames[
i]);
251 for (
unsigned int i=0;
i<name.size();
i++) {
253 fullPathToME = pathsSummaryFolder_ +
"HLT_"+name[
i]+
"_PassPass";
254 v_ME_HLTPassPass_.push_back(
dbe_->
get(fullPathToME));
256 fullPathToME = pathsSummaryHLTCorrelationsFolder_+
"HLT_"+name[
i]+
"_PassPass_Normalized";
257 v_ME_HLTPassPass_Normalized_.push_back(
dbe_->
get(fullPathToME));
259 fullPathToME = pathsSummaryHLTCorrelationsFolder_+
"HLT_"+name[
i]+
"_Pass_Normalized_Any";
260 v_ME_HLTPass_Normalized_Any_.push_back(
dbe_->
get(fullPathToME));
263 normalizeHLTMatrix();
268 TObjArray *hltPathNameColl =
new TObjArray(100);
269 hltPathNameColl->SetOwner();
270 std::vector<std::string> fullPathHLTFolders;
279 LogDebug(
"FourVectorHLTClient")<<
"endRun: sourceDir_(" << sourceDir_.Data() <<
") has " << fullPathHLTFolders.size() <<
" folders. " << endl;
282 for(
unsigned int i=0;
i<fullPathHLTFolders.size();
i++) {
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());
288 hltPath = removeVersions(hltPath);
295 TString currEffFolder = clientDir_ +
"/" + hltPath +
"/" + customEffDir_ +
"/";
298 currEffFolder = removeVersions(currEffFolder);
302 LogDebug(
"FourVectorHLTClient")<<
"Custom Efficiencies dir path = " << currEffFolder << endl;
308 LogDebug(
"FourVectorHLTClient")<<
"Number of MEs for this HLT path = " << hltMEs.size() << endl;
312 for (std::vector<std::pair<std::string, std::string> >::iterator custompathnamepair = custompathnamepairs_.begin(); custompathnamepair != custompathnamepairs_.end(); ++custompathnamepair)
321 if(!hltPath.Contains(TString(custompathnamepair->first)))
continue;
323 TString numPathName=hltPath;
324 TString denPathName=TString(custompathnamepair->second);
326 numPathName = removeVersions(numPathName);
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"));
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"));
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++) {
352 TString oldHistPathNum;
353 TString oldHistPathNumBck;
354 TString oldHistPathDen;
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];
361 TString tempDenString = vStage[
l];
362 tempDenString.ReplaceAll(
"UM",
"") ;
363 oldHistPathDen = sourceDir_+
"/"+hltPath+
"/"+numPathName+
"_wrt_"+denPathName+
"_"+vObj[
k]+tempDenString;
369 LogDebug(
"FourVectorHLTClient")<<
" oldHistPathNum = " << oldHistPathNum << endl;
370 LogDebug(
"FourVectorHLTClient")<<
" oldHistPathNumBck = " << oldHistPathNumBck << endl;
371 LogDebug(
"FourVectorHLTClient")<<
" oldHistPathDen = " << oldHistPathDen << endl;
374 if ( numME && denME ) {
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;
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;
387 if ( numMEBck && denME) {
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;
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;
408 TH1F * numHist = numME->
getTH1F();
409 TH1F * denHist = denME->
getTH1F();
412 TString newHistName = hltPath +
"_wrt_" + denPathName +
"_"+vObj[
k]+
"_Eff_"+vStage[
m]+
"To"+vStage[
l];
415 if(newHistName.Contains(
"UM")) {
417 newHistName.ReplaceAll(
"UM",
"");
418 newHistName.Append(
"_UM");
422 TString newHistTitle = numPathName+
" given " + denPathName +
" "+vObj[
k]+
" Eff "+vStage[
m]+
"To"+vStage[
l];
425 if(newHistTitle.Contains(
"UM")) {
427 newHistTitle.ReplaceAll(
"UM",
"");
428 newHistTitle.Append(
"_UM");
432 TString newHistPath = currEffFolder+newHistName;
434 LogDebug(
"FourVectorHLTClient")<<
"Will make efficiency histogram " << newHistPath << endl;
436 TH1F* effHist = (TH1F*) numHist->Clone(newHistName.Data());
438 effHist->SetTitle(newHistTitle.Data());
446 calculateRatio(effHist, denHist);
460 LogDebug(
"FourVectorHLTClient")<<
"Numerator hist " << numHist->GetName() << endl;
461 LogDebug(
"FourVectorHLTClient")<<
"Denominator hist " << denHist->GetName() << endl;
463 LogDebug(
"FourVectorHLTClient")<<
"Booking efficiency histogram path " << newHistPath << endl;
464 LogDebug(
"FourVectorHLTClient")<<
"Booking efficiency histogram name " << newHistName << endl;
475 vObj.push_back(TString(
"l1Etal1Phi"));
476 vObj.push_back(TString(
"onEtaonPhi"));
477 vObj.push_back(TString(
"offEtaoffPhi"));
478 vObj.push_back(TString(
"mcEtamcPhi"));
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++) {
485 TString oldHistPathNum;
486 TString oldHistPathNumBck;
487 TString oldHistPathDen;
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];
494 TString tempDenString = vStage[
l];
495 tempDenString.ReplaceAll(
"UM",
"") ;
496 oldHistPathDen = sourceDir_+
"/"+hltPath+
"/"+numPathName+
"_wrt_"+denPathName+
"_"+vObj[
k]+tempDenString;
502 LogDebug(
"FourVectorHLTClient")<<
" oldHistPathNum = " << oldHistPathNum << endl;
503 LogDebug(
"FourVectorHLTClient")<<
" oldHistPathNumBck = " << oldHistPathNumBck << endl;
504 LogDebug(
"FourVectorHLTClient")<<
" oldHistPathDen = " << oldHistPathDen << endl;
507 if ( numME && denME ) {
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;
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;
520 if ( numMEBck && denME) {
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;
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;
540 TH2F* numHist = numME->
getTH2F();
541 TH2F* denHist = denME->
getTH2F();
545 TString newHistName = hltPath +
"_wrt_" + denPathName +
"_"+vObj[
k]+
"_Eff_"+vStage[
m]+
"To"+vStage[
l];
548 if(newHistName.Contains(
"UM")) {
550 newHistName.ReplaceAll(
"UM",
"");
551 newHistName.Append(
"_UM");
555 TString newHistTitle = numPathName+
" given " + denPathName +
" "+vObj[
k]+
" Eff "+vStage[
m]+
"To"+vStage[
l];
557 if(newHistTitle.Contains(
"UM")) {
559 newHistTitle.ReplaceAll(
"UM",
"");
560 newHistTitle.Append(
"_UM");
564 TString newHistPath = currEffFolder+newHistName;
565 newHistPath = removeVersions(newHistPath);
567 LogDebug(
"FourVectorHLTClient")<<
"Will make efficiency histogram " << newHistPath << endl;
569 TH2F* effHist = (TH2F*) numHist->Clone(newHistName.Data());
571 effHist->SetTitle(newHistTitle.Data());
575 effHist->Divide(numHist,denHist,1.,1.);
579 LogDebug(
"FourVectorHLTClient")<<
"Booking efficiency histogram path " << newHistPath << endl;
580 LogDebug(
"FourVectorHLTClient")<<
"Booking efficiency histogram name " << newHistName << endl;
594 hltPathNameColl->Delete();
609 LogDebug(
"FourVectorHLTClient")<<
"ME NOT FOUND." << endl;
625 LogDebug(
"FourVectorHLTClient")<<
"ME NOT FOUND." << endl;
639 LogDebug(
"FourVectorHLTClient")<<
"ME NOT FOUND." << endl;
653 LogDebug(
"FourVectorHLTClient")<<
"ME NOT FOUND." << endl;
661 for (
int ii = 100;
ii >= 0;
ii--) {
668 if (histVersion.Contains(version)){
669 histVersion.ReplaceAll(version,
"");
678 int nBins= effHist->GetNbinsX();
679 for (
int i=0;
i<=nBins;
i++) {
681 float k = effHist->GetBinContent(
i);
682 float N = denHist->GetBinContent(
i);
688 if(N>0) ratio = k /
N;
694 err =
sqrt(ratio*(1-ratio)/N);
703 effHist->SetBinContent(
i,ratio);
704 effHist->SetBinError(
i,err);
716 for (
unsigned int i =0;
i<v_ME_HLTPassPass_.size();
i++) {
719 MonitorElement* ME_HLTPassPass_Normalized_ = v_ME_HLTPassPass_Normalized_[
i];
720 MonitorElement* ME_HLTPass_Normalized_Any_ = v_ME_HLTPass_Normalized_Any_[
i];
722 if(!ME_HLTPassPass_ || !ME_HLTPassPass_Normalized_ || !ME_HLTPass_Normalized_Any_)
return;
725 unsigned int nBinsX = ME_HLTPassPass_->
getTH2F()->GetNbinsX();
726 unsigned int nBinsY = ME_HLTPassPass_->
getTH2F()->GetNbinsY();
728 for(
unsigned int binX = 0; binX < nBinsX+1; binX++) {
730 passCount = ME_HLTPassPass_->
getTH2F()->GetBinContent(binX,binX);
733 for(
unsigned int binY = 0; binY < nBinsY+1; binY++) {
738 float normalizedBinContentPassPass = (ME_HLTPassPass_->
getTH2F()->GetBinContent(binX,binY))/passCount;
741 ME_HLTPassPass_Normalized_->
getTH2F()->SetBinContent(binX,binY,normalizedBinContentPassPass);
746 ME_HLTPass_Normalized_Any_->
getTH1F()->SetBinContent(binY,normalizedBinContentPassPass);
753 ME_HLTPassPass_Normalized_->
getTH2F()->SetBinContent(binX,binY,0);
void beginRun(const edm::Run &r, const edm::EventSetup &c)
BeginRun.
std::vector< std::string > getSubdirs(void) const
TProfile2D * getTProfile2D(void) const
MonitorElement * book1D(const char *name, const char *title, int nchX, double lowX, double highX)
Book 1D histogram.
void normalizeHLTMatrix()
TH2F * get2DHisto(std::string meName, DQMStore *dbi)
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.
virtual ~FourVectorHLTClient()
Destructor.
MonitorElement * get(const std::string &path) const
get ME from full pathname (e.g. "my/long/dir/my_histo")
std::vector< MonitorElement * > getContents(const std::string &path) const
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.
tuple size
Write out results.
void setCurrentFolder(const std::string &fullpath)
void endRun(const edm::Run &r, const edm::EventSetup &c)
EndRun.