22 #include <TGraphAsymmErrors.h>
28 #include <TProfile2D.h>
52 LogDebug(
"FourVectorHLTClient")<<
"FourVectorHLTClient: ending...." ;
65 processname_ = parameters_.getUntrackedParameter<
std::string>(
"processname",
"HLT");
69 sourceDir_ = TString(parameters_.getUntrackedParameter<
string>(
"hltSourceDir",
""));
74 while(sourceDir_.Last(
'/') == sourceDir_.Length()-1) {
75 sourceDir_.Remove(sourceDir_.Length()-1);
77 LogDebug(
"FourVectorHLTClient")<<
"Source dir = " << sourceDir_ << endl;
79 clientDir_ = TString(parameters_.getUntrackedParameter<
string>(
"hltClientDir",
""));
82 while(clientDir_.Last(
'/') == clientDir_.Length()-1) {
83 clientDir_.Remove(clientDir_.Length()-1);
85 LogDebug(
"FourVectorHLTClient")<<
"Client dir = " << clientDir_ << endl;
87 prescaleLS_ = parameters_.getUntrackedParameter<
int>(
"prescaleLS", -1);
88 LogDebug(
"FourVectorHLTClient")<<
"DQM lumi section prescale = " << prescaleLS_ <<
" lumi section(s)"<< endl;
90 prescaleEvt_ = parameters_.getUntrackedParameter<
int>(
"prescaleEvt", -1);
91 LogDebug(
"FourVectorHLTClient")<<
"DQM event prescale = " << prescaleEvt_ <<
" events(s)"<< endl;
93 customEffDir_ = TString(parameters_.getUntrackedParameter<
string>(
"customEffDir",
"custom-efficiencies"));
94 LogDebug(
"FourVectorHLTClient")<<
"Custom Efficiencies dir = " << customEffDir_ << endl;
96 std::vector<edm::ParameterSet> effpaths = parameters_.getParameter<std::vector<edm::ParameterSet> >(
"effpaths");
98 std::pair<std::string, std::string> custompathnamepair;
99 for(std::vector<edm::ParameterSet>::iterator pathconf = effpaths.begin() ; pathconf != effpaths.end();
101 custompathnamepair.first =pathconf->getParameter<
std::string>(
"pathname");
102 custompathnamepair.second = pathconf->getParameter<
std::string>(
"denompathname");
103 custompathnamepairs_.push_back(custompathnamepair);
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/"));
118 LogDebug(
"FourVectorHLTClient")<<
"[FourVectorHLTClient]: beginJob" << endl;
127 LogDebug(
"FourVectorHLTClient")<<
"[FourVectorHLTClient]: beginRun" << endl;
131 if (!hltConfig_.init(r, context, processname_, changed)) {
135 if (!hltConfig_.init(r, context, processname_, changed)){
137 LogDebug(
"FourVectorHLTOffline") <<
"HLTConfigProvider failed to initialize.";
162 if (prescaleEvt_<1)
return;
163 if (prescaleEvt_>0 && counterEvt_%prescaleEvt_ != 0)
return;
165 LogDebug(
"FourVectorHLTClient")<<
"analyze..." << endl;
172 LogDebug(
"FourVectorHLTClient")<<
"FourVectorHLTClient:: endLuminosityBlock " << endl;
179 std::vector<MonitorElement*> summaryME;
180 summaryME =
dbe_->
getContents(pathsSummaryFilterCountsFolder_.c_str());
182 vector<float> hltPassCount;
184 for(
unsigned int i=0;
i< summaryME.size();
i++) {
186 TString nameME = (summaryME[
i])->getName();
187 LogDebug(
"FourVectorHLTClient") <<
"ME = " << nameME << endl;
189 TString fullPathToME = pathsSummaryFilterCountsFolder_ + nameME;
190 LogDebug(
"FourVectorHLTClient") <<
"fullPathME = " << fullPathToME << endl;
192 if(nameME.Contains(
"Filters_")) {
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;
199 TString nameMEeff = nameME+
"_Eff";
200 TString titleMEeff = nameME+
" Efficiency wrt input to L1";
202 TH1F* effHist = (TH1F*) MEHist->Clone(nameMEeff.Data());
203 effHist->SetTitle(titleMEeff.Data());
205 float firstBinContent = MEHist->GetBinContent(1);
207 if(firstBinContent !=0 ) {
209 effHist->Scale(1./firstBinContent);
214 unsigned int nBins = effHist->GetNbinsX();
215 for(
unsigned int bin = 0;
bin < nBins+1;
bin++) effHist->SetBinContent(
bin, 0);
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");
240 vector<string>
datasetNames = hltConfig_.datasetNames() ;
242 for (
unsigned int i=0;
i<datasetNames.size();
i++) {
244 name.push_back(datasetNames[
i]);
250 for (
unsigned int i=0;
i<name.size();
i++) {
252 fullPathToME = pathsSummaryFolder_ +
"HLT_"+name[
i]+
"_PassPass";
253 v_ME_HLTPassPass_.push_back(
dbe_->
get(fullPathToME));
255 fullPathToME = pathsSummaryHLTCorrelationsFolder_+
"HLT_"+name[
i]+
"_PassPass_Normalized";
256 v_ME_HLTPassPass_Normalized_.push_back(
dbe_->
get(fullPathToME));
258 fullPathToME = pathsSummaryHLTCorrelationsFolder_+
"HLT_"+name[
i]+
"_Pass_Normalized_Any";
259 v_ME_HLTPass_Normalized_Any_.push_back(
dbe_->
get(fullPathToME));
262 normalizeHLTMatrix();
267 TObjArray *hltPathNameColl =
new TObjArray(100);
268 hltPathNameColl->SetOwner();
269 std::vector<std::string> fullPathHLTFolders;
278 LogDebug(
"FourVectorHLTClient")<<
"endRun: sourceDir_(" << sourceDir_.Data() <<
") has " << fullPathHLTFolders.size() <<
" folders. " << endl;
281 for(
unsigned int i=0;
i<fullPathHLTFolders.size();
i++) {
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());
287 hltPath = removeVersions(hltPath);
294 TString currEffFolder = clientDir_ +
"/" + hltPath +
"/" + customEffDir_ +
"/";
297 currEffFolder = removeVersions(currEffFolder);
301 LogDebug(
"FourVectorHLTClient")<<
"Custom Efficiencies dir path = " << currEffFolder << endl;
307 LogDebug(
"FourVectorHLTClient")<<
"Number of MEs for this HLT path = " << hltMEs.size() << endl;
311 for (std::vector<std::pair<std::string, std::string> >::iterator custompathnamepair = custompathnamepairs_.begin(); custompathnamepair != custompathnamepairs_.end(); ++custompathnamepair)
320 if(!hltPath.Contains(TString(custompathnamepair->first)))
continue;
322 TString numPathName=hltPath;
323 TString denPathName=TString(custompathnamepair->second);
325 numPathName = removeVersions(numPathName);
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"));
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"));
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++) {
351 TString oldHistPathNum;
352 TString oldHistPathNumBck;
353 TString oldHistPathDen;
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];
360 TString tempDenString = vStage[
l];
361 tempDenString.ReplaceAll(
"UM",
"") ;
362 oldHistPathDen = sourceDir_+
"/"+hltPath+
"/"+numPathName+
"_wrt_"+denPathName+
"_"+vObj[
k]+tempDenString;
368 LogDebug(
"FourVectorHLTClient")<<
" oldHistPathNum = " << oldHistPathNum << endl;
369 LogDebug(
"FourVectorHLTClient")<<
" oldHistPathNumBck = " << oldHistPathNumBck << endl;
370 LogDebug(
"FourVectorHLTClient")<<
" oldHistPathDen = " << oldHistPathDen << endl;
373 if ( numME && denME ) {
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;
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;
386 if ( numMEBck && denME) {
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;
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;
407 TH1F * numHist = numME->
getTH1F();
408 TH1F * denHist = denME->
getTH1F();
411 TString newHistName = hltPath +
"_wrt_" + denPathName +
"_"+vObj[
k]+
"_Eff_"+vStage[
m]+
"To"+vStage[
l];
414 if(newHistName.Contains(
"UM")) {
416 newHistName.ReplaceAll(
"UM",
"");
417 newHistName.Append(
"_UM");
421 TString newHistTitle = numPathName+
" given " + denPathName +
" "+vObj[
k]+
" Eff "+vStage[
m]+
"To"+vStage[
l];
424 if(newHistTitle.Contains(
"UM")) {
426 newHistTitle.ReplaceAll(
"UM",
"");
427 newHistTitle.Append(
"_UM");
431 TString newHistPath = currEffFolder+newHistName;
433 LogDebug(
"FourVectorHLTClient")<<
"Will make efficiency histogram " << newHistPath << endl;
435 TH1F* effHist = (TH1F*) numHist->Clone(newHistName.Data());
437 effHist->SetTitle(newHistTitle.Data());
445 calculateRatio(effHist, denHist);
459 LogDebug(
"FourVectorHLTClient")<<
"Numerator hist " << numHist->GetName() << endl;
460 LogDebug(
"FourVectorHLTClient")<<
"Denominator hist " << denHist->GetName() << endl;
462 LogDebug(
"FourVectorHLTClient")<<
"Booking efficiency histogram path " << newHistPath << endl;
463 LogDebug(
"FourVectorHLTClient")<<
"Booking efficiency histogram name " << newHistName << endl;
474 vObj.push_back(TString(
"l1Etal1Phi"));
475 vObj.push_back(TString(
"onEtaonPhi"));
476 vObj.push_back(TString(
"offEtaoffPhi"));
477 vObj.push_back(TString(
"mcEtamcPhi"));
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++) {
484 TString oldHistPathNum;
485 TString oldHistPathNumBck;
486 TString oldHistPathDen;
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];
493 TString tempDenString = vStage[
l];
494 tempDenString.ReplaceAll(
"UM",
"") ;
495 oldHistPathDen = sourceDir_+
"/"+hltPath+
"/"+numPathName+
"_wrt_"+denPathName+
"_"+vObj[
k]+tempDenString;
501 LogDebug(
"FourVectorHLTClient")<<
" oldHistPathNum = " << oldHistPathNum << endl;
502 LogDebug(
"FourVectorHLTClient")<<
" oldHistPathNumBck = " << oldHistPathNumBck << endl;
503 LogDebug(
"FourVectorHLTClient")<<
" oldHistPathDen = " << oldHistPathDen << endl;
506 if ( numME && denME ) {
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;
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;
519 if ( numMEBck && denME) {
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;
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;
539 TH2F* numHist = numME->
getTH2F();
540 TH2F* denHist = denME->
getTH2F();
544 TString newHistName = hltPath +
"_wrt_" + denPathName +
"_"+vObj[
k]+
"_Eff_"+vStage[
m]+
"To"+vStage[
l];
547 if(newHistName.Contains(
"UM")) {
549 newHistName.ReplaceAll(
"UM",
"");
550 newHistName.Append(
"_UM");
554 TString newHistTitle = numPathName+
" given " + denPathName +
" "+vObj[
k]+
" Eff "+vStage[
m]+
"To"+vStage[
l];
556 if(newHistTitle.Contains(
"UM")) {
558 newHistTitle.ReplaceAll(
"UM",
"");
559 newHistTitle.Append(
"_UM");
563 TString newHistPath = currEffFolder+newHistName;
564 newHistPath = removeVersions(newHistPath);
566 LogDebug(
"FourVectorHLTClient")<<
"Will make efficiency histogram " << newHistPath << endl;
568 TH2F* effHist = (TH2F*) numHist->Clone(newHistName.Data());
570 effHist->SetTitle(newHistTitle.Data());
574 effHist->Divide(numHist,denHist,1.,1.);
578 LogDebug(
"FourVectorHLTClient")<<
"Booking efficiency histogram path " << newHistPath << endl;
579 LogDebug(
"FourVectorHLTClient")<<
"Booking efficiency histogram name " << newHistName << endl;
593 hltPathNameColl->Delete();
608 LogDebug(
"FourVectorHLTClient")<<
"ME NOT FOUND." << endl;
624 LogDebug(
"FourVectorHLTClient")<<
"ME NOT FOUND." << endl;
638 LogDebug(
"FourVectorHLTClient")<<
"ME NOT FOUND." << endl;
652 LogDebug(
"FourVectorHLTClient")<<
"ME NOT FOUND." << endl;
660 for (
int ii = 100;
ii >= 0;
ii--) {
667 if (histVersion.Contains(version)){
668 histVersion.ReplaceAll(version,
"");
677 int nBins= effHist->GetNbinsX();
678 for (
int i=0;
i<=nBins;
i++) {
680 float k = effHist->GetBinContent(
i);
681 float N = denHist->GetBinContent(
i);
687 if(N>0) ratio = k /
N;
693 err =
sqrt(ratio*(1-ratio)/N);
702 effHist->SetBinContent(
i,ratio);
703 effHist->SetBinError(
i,err);
715 for (
unsigned int i =0;
i<v_ME_HLTPassPass_.size();
i++) {
718 MonitorElement* ME_HLTPassPass_Normalized_ = v_ME_HLTPassPass_Normalized_[
i];
719 MonitorElement* ME_HLTPass_Normalized_Any_ = v_ME_HLTPass_Normalized_Any_[
i];
721 if(!ME_HLTPassPass_ || !ME_HLTPassPass_Normalized_ || !ME_HLTPass_Normalized_Any_)
return;
724 unsigned int nBinsX = ME_HLTPassPass_->
getTH2F()->GetNbinsX();
725 unsigned int nBinsY = ME_HLTPassPass_->
getTH2F()->GetNbinsY();
727 for(
unsigned int binX = 0; binX < nBinsX+1; binX++) {
729 passCount = ME_HLTPassPass_->
getTH2F()->GetBinContent(binX,binX);
732 for(
unsigned int binY = 0; binY < nBinsY+1; binY++) {
737 float normalizedBinContentPassPass = (ME_HLTPassPass_->
getTH2F()->GetBinContent(binX,binY))/passCount;
740 ME_HLTPassPass_Normalized_->
getTH2F()->SetBinContent(binX,binY,normalizedBinContentPassPass);
745 ME_HLTPass_Normalized_Any_->
getTH1F()->SetBinContent(binY,normalizedBinContentPassPass);
752 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.