24 #include <boost/tokenizer.hpp> 31 TPRegexp
metacharacters(
"[\\^\\$\\.\\*\\+\\?\\|\\(\\)\\{\\}\\[\\]]");
36 typedef std::vector<edm::ParameterSet>
VPSet;
37 typedef std::vector<std::string>
vstring;
38 typedef boost::escaped_list_separator<char> elsc;
40 elsc commonEscapes(
"\\",
" \t",
"\'");
48 vstring effCmds = pset.
getParameter<vstring>(
"efficiency");
49 for ( vstring::const_iterator effCmd = effCmds.begin();
50 effCmd != effCmds.end(); ++effCmd )
52 if ( effCmd->empty() )
continue;
54 boost::tokenizer<elsc> tokens(*effCmd, commonEscapes);
57 for(boost::tokenizer<elsc>::const_iterator iToken = tokens.begin();
58 iToken != tokens.end(); ++iToken) {
59 if ( iToken->empty() )
continue;
60 args.push_back(*iToken);
63 if ( args.size() < 4 ) {
64 LogInfo(
"DQMGenericClient") <<
"Wrong input to effCmds\n";
75 const string typeName = args.size() == 4 ?
"eff" : args[4];
77 else if ( typeName ==
"fake" ) opt.
type = EfficType::fakerate;
78 else if ( typeName ==
"simpleratio" ) opt.
type = EfficType::simpleratio;
81 efficOptions_.push_back(opt);
85 for ( VPSet::const_iterator
efficSet = efficSets.begin();
89 opt.
name =
efficSet->getUntrackedParameter<
string>(
"name");
95 const string typeName =
efficSet->getUntrackedParameter<
string>(
"typeName",
"eff");
97 else if ( typeName ==
"fake" ) opt.
type = EfficType::fakerate;
98 else if ( typeName ==
"simpleratio" ) opt.
type = EfficType::simpleratio;
101 efficOptions_.push_back(opt);
106 for ( vstring::const_iterator effProfileCmd = effProfileCmds.begin();
107 effProfileCmd != effProfileCmds.end(); ++effProfileCmd )
109 if ( effProfileCmd->empty() )
continue;
111 boost::tokenizer<elsc> tokens(*effProfileCmd, commonEscapes);
114 for(boost::tokenizer<elsc>::const_iterator iToken = tokens.begin();
115 iToken != tokens.end(); ++iToken) {
116 if ( iToken->empty() )
continue;
117 args.push_back(*iToken);
120 if ( args.size() < 4 ) {
121 LogInfo(
"DQMGenericClient") <<
"Wrong input to effProfileCmds\n";
132 const string typeName = args.size() == 4 ?
"eff" : args[4];
134 else if ( typeName ==
"fake" ) opt.
type = EfficType::fakerate;
135 else if ( typeName ==
"simpleratio" ) opt.
type = EfficType::simpleratio;
138 efficOptions_.push_back(opt);
142 for ( VPSet::const_iterator effProfileSet = effProfileSets.begin();
143 effProfileSet != effProfileSets.end(); ++effProfileSet )
146 opt.
name = effProfileSet->getUntrackedParameter<
string>(
"name");
147 opt.
title = effProfileSet->getUntrackedParameter<
string>(
"title");
148 opt.
numerator = effProfileSet->getUntrackedParameter<
string>(
"numerator");
149 opt.
denominator = effProfileSet->getUntrackedParameter<
string>(
"denominator");
152 const string typeName = effProfileSet->getUntrackedParameter<
string>(
"typeName",
"eff");
154 else if ( typeName ==
"fake" ) opt.
type = EfficType::fakerate;
155 else if ( typeName ==
"simpleratio" ) opt.
type = EfficType::simpleratio;
158 efficOptions_.push_back(opt);
162 vstring resCmds = pset.
getParameter<vstring>(
"resolution");
163 for ( vstring::const_iterator resCmd = resCmds.begin();
164 resCmd != resCmds.end(); ++resCmd )
166 if ( resCmd->empty() )
continue;
167 boost::tokenizer<elsc> tokens(*resCmd, commonEscapes);
170 for(boost::tokenizer<elsc>::const_iterator iToken = tokens.begin();
171 iToken != tokens.end(); ++iToken) {
172 if ( iToken->empty() )
continue;
173 args.push_back(*iToken);
176 if ( args.size() != 3 ) {
177 LogInfo(
"DQMGenericClient") <<
"Wrong input to resCmds\n";
186 resolOptions_.push_back(opt);
190 for ( VPSet::const_iterator resolSet = resolSets.begin();
191 resolSet != resolSets.end(); ++resolSet )
194 opt.
namePrefix = resolSet->getUntrackedParameter<
string>(
"namePrefix");
195 opt.
titlePrefix = resolSet->getUntrackedParameter<
string>(
"titlePrefix");
196 opt.
srcName = resolSet->getUntrackedParameter<
string>(
"srcName");
198 resolOptions_.push_back(opt);
203 for(
const auto& profileCmd: profileCmds) {
204 boost::tokenizer<elsc> tokens(profileCmd, commonEscapes);
207 for(boost::tokenizer<elsc>::const_iterator iToken = tokens.begin();
208 iToken != tokens.end(); ++iToken) {
209 if ( iToken->empty() )
continue;
210 args.push_back(*iToken);
213 if ( args.size() != 3 ) {
214 LogInfo(
"DQMGenericClient") <<
"Wrong input to profileCmds\n";
223 profileOptions_.push_back(opt);
227 for(
const auto& profileSet: profileSets) {
229 opt.
name = profileSet.getUntrackedParameter<
string>(
"name");
230 opt.
title = profileSet.getUntrackedParameter<
string>(
"title");
231 opt.
srcName = profileSet.getUntrackedParameter<
string>(
"srcName");
233 profileOptions_.push_back(opt);
238 for ( vstring::const_iterator normCmd = normCmds.begin();
239 normCmd != normCmds.end(); ++normCmd )
241 if ( normCmd->empty() )
continue;
242 boost::tokenizer<elsc> tokens(*normCmd, commonEscapes);
245 for(boost::tokenizer<elsc>::const_iterator iToken = tokens.begin();
246 iToken != tokens.end(); ++iToken) {
247 if ( iToken->empty() )
continue;
248 args.push_back(*iToken);
251 if ( args.empty()
or args.size() > 2 ) {
252 LogInfo(
"DQMGenericClient") <<
"Wrong input to normCmds\n";
258 opt.
normHistName = args.size() == 2 ? args[1] : args[0];
260 normOptions_.push_back(opt);
264 for ( VPSet::const_iterator normSet = normSets.begin();
265 normSet != normSets.end(); ++normSet )
268 opt.
name = normSet->getUntrackedParameter<
string>(
"name");
269 opt.
normHistName = normSet->getUntrackedParameter<
string>(
"normalizedTo", opt.
name);
271 normOptions_.push_back(opt);
276 for ( vstring::const_iterator cdCmd = cdCmds.begin();
277 cdCmd != cdCmds.end(); ++cdCmd )
279 if ( cdCmd->empty() )
continue;
280 boost::tokenizer<elsc> tokens(*cdCmd, commonEscapes);
283 for(boost::tokenizer<elsc>::const_iterator iToken = tokens.begin();
284 iToken != tokens.end(); ++iToken) {
285 if ( iToken->empty() )
continue;
286 args.push_back(*iToken);
289 if ( args.empty() || args.size() > 2) {
290 LogInfo(
"DQMGenericClient") <<
"Wrong input to cdCmds\n";
296 opt.
ascending = args.size() == 2 ? (args[1] !=
"descending") :
true;
298 cdOptions_.push_back(opt);
302 for ( VPSet::const_iterator cdSet = cdSets.begin();
303 cdSet != cdSets.end(); ++cdSet )
306 opt.
name = cdSet->getUntrackedParameter<
string>(
"name");
307 opt.
ascending = cdSet->getUntrackedParameter<
bool>(
"ascending",
true);
309 cdOptions_.push_back(opt);
314 for ( vstring::const_iterator noFlowCmd = noFlowCmds.begin();
315 noFlowCmd != noFlowCmds.end(); ++noFlowCmd )
317 if ( noFlowCmd->empty() )
continue;
318 boost::tokenizer<elsc> tokens(*noFlowCmd, commonEscapes);
321 for(boost::tokenizer<elsc>::const_iterator iToken = tokens.begin();
322 iToken != tokens.end(); ++iToken) {
323 if ( iToken->empty() )
continue;
324 args.push_back(*iToken);
327 if ( args.empty() || args.size() > 2) {
328 LogInfo(
"DQMGenericClient") <<
"Wrong input to noFlowCmds\n";
335 noFlowOptions_.push_back(opt);
339 for ( VPSet::const_iterator noFlowSet = noFlowSets.begin();
340 noFlowSet != noFlowSets.end(); ++noFlowSet )
343 opt.
name = noFlowSet->getUntrackedParameter<
string>(
"name");
345 noFlowOptions_.push_back(opt);
353 isWildcardUsed_ =
false;
358 makeAllPlots(ibooker, igetter);
383 makeAllPlots(ibooker, igetter);
386 if ( ! outputFileName_.empty() ) theDQM->save(outputFileName_);
391 typedef vector<string>
vstring;
394 set<string> subDirSet;
396 for(vstring::const_iterator iSubDir = subDirs_.begin();
397 iSubDir != subDirs_.end(); ++iSubDir) {
400 if ( subDir[subDir.size()-1] ==
'/' ) subDir.erase(subDir.size()-1);
403 isWildcardUsed_ =
true;
406 const string searchPath = subDir.substr(0, shiftPos);
407 const string pattern = subDir.substr(shiftPos + 1, subDir.length());
410 findAllSubdirectories (ibooker, igetter, searchPath, &subDirSet, pattern);
414 subDirSet.insert(subDir);
418 for(set<string>::const_iterator iSubDir = subDirSet.begin();
419 iSubDir != subDirSet.end(); ++iSubDir) {
420 const string&
dirName = *iSubDir;
425 for ( vector<NormOption>::const_iterator normOption = normOptions_.begin();
426 normOption != normOptions_.end(); ++normOption )
428 normalizeToEntries(ibooker, igetter, dirName, normOption->name, normOption->normHistName);
431 for ( vector<NoFlowOption>::const_iterator noFlowOption = noFlowOptions_.begin();
432 noFlowOption != noFlowOptions_.end(); ++noFlowOption )
434 makeNoFlowDist(ibooker, igetter, dirName, noFlowOption->name);
437 for ( vector<CDOption>::const_iterator cdOption = cdOptions_.begin();
438 cdOption != cdOptions_.end(); ++cdOption )
440 makeCumulativeDist(ibooker, igetter, dirName, cdOption->name, cdOption->ascending);
443 for ( vector<EfficOption>::const_iterator efficOption = efficOptions_.begin();
444 efficOption != efficOptions_.end(); ++efficOption )
446 computeEfficiency(ibooker, igetter, dirName, efficOption->name, efficOption->title,
447 efficOption->numerator, efficOption->denominator,
448 efficOption->type, efficOption->isProfile);
451 for ( vector<ResolOption>::const_iterator resolOption = resolOptions_.begin();
452 resolOption != resolOptions_.end(); ++resolOption )
454 computeResolution(ibooker, igetter, dirName, resolOption->namePrefix, resolOption->titlePrefix, resolOption->srcName);
457 for(
const auto& profileOption: profileOptions_) {
458 computeProfile(ibooker, igetter, dirName, profileOption.name, profileOption.title, profileOption.srcName);
467 const string& efficMETitle,
const string& recoMEName,
const string& simMEName,
const EfficType type,
const bool makeProfile)
470 if ( verbose_ >= 2 || (verbose_ == 1 && !isWildcardUsed_) ) {
471 LogInfo(
"DQMGenericClient") <<
"computeEfficiency() : " 472 <<
"Cannot find sub-directory " << startDir << endl;
479 ME* simME = igetter.
get(startDir+
"/"+simMEName);
480 ME* recoME = igetter.
get(startDir+
"/"+recoMEName);
483 if ( verbose_ >= 2 || (verbose_ == 1 && !isWildcardUsed_) ) {
484 LogInfo(
"DQMGenericClient") <<
"computeEfficiency() : " 485 <<
"No sim-ME '" << simMEName <<
"' found\n";
491 if ( verbose_ >= 2 || (verbose_ == 1 && !isWildcardUsed_) ) {
492 LogInfo(
"DQMGenericClient") <<
"computeEfficiency() : " 493 <<
"No reco-ME '" << recoMEName <<
"' found\n";
500 TH1* hSim = simME ->getTH1();
501 TH1* hReco = recoME->getTH1();
503 if ( !hSim || !hReco ) {
504 if ( verbose_ >= 2 || (verbose_ == 1 && !isWildcardUsed_) ) {
505 LogInfo(
"DQMGenericClient") <<
"computeEfficiency() : " 506 <<
"Cannot create TH1 from ME\n";
511 string efficDir = startDir;
512 string newEfficMEName = efficMEName;
514 if ( string::npos != (shiftPos = efficMEName.rfind(
'/')) ) {
515 efficDir +=
"/"+efficMEName.substr(0, shiftPos);
516 newEfficMEName.erase(0, shiftPos+1);
521 TProfile * efficHist = (hReco->GetXaxis()->GetXbins()->GetSize()==0) ?
522 new TProfile(newEfficMEName.c_str(), efficMETitle.c_str(),
523 hReco->GetXaxis()->GetNbins(),
524 hReco->GetXaxis()->GetXmin(),
525 hReco->GetXaxis()->GetXmax()) :
526 new TProfile(newEfficMEName.c_str(), efficMETitle.c_str(),
527 hReco->GetXaxis()->GetNbins(),
528 hReco->GetXaxis()->GetXbins()->GetArray());
530 efficHist->GetXaxis()->SetTitle(hSim->GetXaxis()->GetTitle());
531 efficHist->GetYaxis()->SetTitle(hSim->GetYaxis()->GetTitle());
533 for (
int i=1;
i <= hReco->GetNbinsX();
i++) {
534 const double nReco = hReco->GetBinContent(
i);
535 const double nSim = hSim->GetBinContent(
i);
538 efficHist->GetXaxis()->SetBinLabel(
i, hSim->GetXaxis()->GetBinLabel(
i));
540 if (nSim == 0
or nReco < 0 or nReco > nSim)
continue;
541 const double effVal = nReco/nSim;
542 const double errLo = TEfficiency::ClopperPearson(nSim, nReco, 0.683,
false);
543 const double errUp = TEfficiency::ClopperPearson(nSim, nReco, 0.683,
true);
544 const double errVal = (effVal - errLo > errUp - effVal) ? effVal - errLo : errUp - effVal;
545 efficHist->SetBinContent(
i, effVal);
546 efficHist->SetBinEntries(
i, 1);
547 efficHist->SetBinError(
i, std::hypot(effVal, errVal));
549 removeMEIfBooked(newEfficMEName, igetter);
556 TH1* efficHist = (TH1*)hSim->Clone(newEfficMEName.c_str());
557 efficHist->SetTitle(efficMETitle.c_str());
562 ME* efficME =
nullptr;
566 TClass * myHistClass = efficHist->IsA();
567 TString histClassName = myHistClass->GetName();
569 if (histClassName ==
"TH1F"){
570 removeMEIfBooked(newEfficMEName, igetter);
571 efficME = ibooker.
book1D(newEfficMEName, (TH1F*)efficHist);
572 }
else if (histClassName ==
"TH2F"){
573 removeMEIfBooked(newEfficMEName, igetter);
574 efficME = ibooker.
book2D(newEfficMEName, (TH2F*)efficHist);
575 }
else if (histClassName ==
"TH3F"){
576 removeMEIfBooked(newEfficMEName, igetter);
577 efficME = ibooker.
book3D(newEfficMEName, (TH3F*)efficHist);
583 LogInfo(
"DQMGenericClient") <<
"computeEfficiency() : " 584 <<
"Cannot book effic-ME from the DQM\n";
592 generic_eff (hSim, hReco, efficME, type);
605 efficME->setEntries(simME->getEntries());
610 if (makeGlobalEffPlot_) {
611 ME* globalEfficME = igetter.
get(efficDir+
"/globalEfficiencies");
612 if ( !globalEfficME ) globalEfficME = ibooker.
book1D(
"globalEfficiencies",
"Global efficiencies", 1, 0, 1);
613 if ( !globalEfficME ) {
614 LogInfo(
"DQMGenericClient") <<
"computeEfficiency() : " 615 <<
"Cannot book globalEffic-ME from the DQM\n";
618 globalEfficME->setEfficiencyFlag();
619 TH1F* hGlobalEffic = globalEfficME->getTH1F();
620 if ( !hGlobalEffic ) {
621 LogInfo(
"DQMGenericClient") <<
"computeEfficiency() : " 622 <<
"Cannot create TH1F from ME, globalEfficME\n";
626 const float nSimAll = hSim->GetEntries();
627 const float nRecoAll = hReco->GetEntries();
629 if ( type ==
EfficType::efficiency || type == EfficType::simpleratio ) efficAll = nSimAll ? nRecoAll/nSimAll : 0;
630 else if ( type == EfficType::fakerate ) efficAll = nSimAll ? 1-nRecoAll/nSimAll : 0;
632 if ( type == EfficType::simpleratio ) {
634 const float x = nRecoAll/nSimAll;
639 errorAll = nSimAll && efficAll < 1 ?
sqrt(efficAll*(1-efficAll)/nSimAll) : 0;
641 const int iBin = hGlobalEffic->Fill(newEfficMEName.c_str(), 0);
642 hGlobalEffic->SetBinContent(iBin, efficAll);
643 hGlobalEffic->SetBinError(iBin, errorAll);
651 if ( verbose_ >= 2 || (verbose_ == 1 && !isWildcardUsed_) ) {
652 LogInfo(
"DQMGenericClient") <<
"computeResolution() : " 653 <<
"Cannot find sub-directory " << startDir << endl;
660 ME* srcME = igetter.
get(startDir+
"/"+srcName);
662 if ( verbose_ >= 2 || (verbose_ == 1 && !isWildcardUsed_) ) {
663 LogInfo(
"DQMGenericClient") <<
"computeResolution() : " 664 <<
"No source ME '" << srcName <<
"' found\n";
669 TH2F* hSrc = srcME->getTH2F();
671 if ( verbose_ >= 2 || (verbose_ == 1 && !isWildcardUsed_) ) {
672 LogInfo(
"DQMGenericClient") <<
"computeResolution() : " 673 <<
"Cannot create TH2F from source-ME\n";
678 const int nBin = hSrc->GetNbinsX();
680 string newDir = startDir;
683 if ( string::npos != (shiftPos = namePrefix.rfind(
'/')) ) {
684 newDir +=
"/"+namePrefix.substr(0, shiftPos);
685 newPrefix.erase(0, shiftPos+1);
690 float * lowedgesfloats =
new float[nBin+1];
693 removeMEIfBooked(newPrefix+
"_Mean", igetter);
694 removeMEIfBooked(newPrefix+
"_Sigme", igetter);
695 if (hSrc->GetXaxis()->GetXbins()->GetSize())
697 for (
int j=0; j<nBin+1; ++j)
698 lowedgesfloats[j] = (
float)hSrc->GetXaxis()->GetXbins()->GetAt(j);
699 meanME = ibooker.
book1D(newPrefix+
"_Mean", titlePrefix+
" Mean", nBin, lowedgesfloats);
700 sigmaME = ibooker.
book1D(newPrefix+
"_Sigma", titlePrefix+
" Sigma", nBin, lowedgesfloats);
704 meanME = ibooker.
book1D(newPrefix+
"_Mean", titlePrefix+
" Mean", nBin,
705 hSrc->GetXaxis()->GetXmin(),
706 hSrc->GetXaxis()->GetXmax());
707 sigmaME = ibooker.
book1D(newPrefix+
"_Sigma", titlePrefix+
" Sigma", nBin,
708 hSrc->GetXaxis()->GetXmin(),
709 hSrc->GetXaxis()->GetXmax());
712 if (meanME && sigmaME)
714 meanME->setEfficiencyFlag();
715 sigmaME->setEfficiencyFlag();
717 if (! resLimitedFit_ ) {
723 limitedFit(srcME,meanME,sigmaME);
726 delete[] lowedgesfloats;
731 if(verbose_ >= 2 || (verbose_ == 1 && !isWildcardUsed_) ) {
732 LogInfo(
"DQMGenericClient") <<
"computeProfile() : " 733 <<
"Cannot find sub-directory " << startDir << endl;
740 ME* srcME = igetter.
get(startDir+
"/"+srcMEName);
742 if ( verbose_ >= 2 || (verbose_ == 1 && !isWildcardUsed_) ) {
743 LogInfo(
"DQMGenericClient") <<
"computeProfile() : " 744 <<
"No source ME '" << srcMEName <<
"' found\n";
749 TH2F* hSrc = srcME->getTH2F();
751 if ( verbose_ >= 2 || (verbose_ == 1 && !isWildcardUsed_) ) {
752 LogInfo(
"DQMGenericClient") <<
"computeProfile() : " 753 <<
"Cannot create TH2F from source-ME\n";
758 string profileDir = startDir;
759 string newProfileMEName = profileMEName;
761 if ( string::npos != (shiftPos = profileMEName.rfind(
'/')) ) {
762 profileDir +=
"/"+profileMEName.substr(0, shiftPos);
763 newProfileMEName.erase(0, shiftPos+1);
767 std::unique_ptr<TProfile>
profile(hSrc->ProfileX());
768 profile->SetTitle(profileMETitle.c_str());
769 removeMEIfBooked(profileMEName, igetter);
778 if ( verbose_ >= 2 || (verbose_ == 1 && !isWildcardUsed_) ) {
779 LogInfo(
"DQMGenericClient") <<
"normalizeToEntries() : " 780 <<
"Cannot find sub-directory " << startDir << endl;
787 ME* element = igetter.
get(startDir+
"/"+histName);
788 ME* normME = igetter.
get(startDir+
"/"+normHistName);
791 if ( verbose_ >= 2 || (verbose_ == 1 && !isWildcardUsed_) ) {
792 LogInfo(
"DQMGenericClient") <<
"normalizeToEntries() : " 793 <<
"No such element '" << histName <<
"' found\n";
799 if ( verbose_ >= 2 || (verbose_ == 1 && !isWildcardUsed_) ) {
800 LogInfo(
"DQMGenericClient") <<
"normalizeToEntries() : " 801 <<
"No such element '" << normHistName <<
"' found\n";
806 TH1F*
hist = element->getTH1F();
808 if ( verbose_ >= 2 || (verbose_ == 1 && !isWildcardUsed_) ) {
809 LogInfo(
"DQMGenericClient") <<
"normalizeToEntries() : " 810 <<
"Cannot create TH1F from ME\n";
815 TH1F* normHist = normME->getTH1F();
817 if ( verbose_ >= 2 || (verbose_ == 1 && !isWildcardUsed_) ) {
818 LogInfo(
"DQMGenericClient") <<
"normalizeToEntries() : " 819 <<
"Cannot create TH1F from ME\n";
824 const double entries = normHist->GetEntries();
825 if ( entries != 0 ) {
826 hist->Scale(1./entries);
829 LogInfo(
"DQMGenericClient") <<
"normalizeToEntries() : " 830 <<
"Zero entries in histogram\n";
839 if ( verbose_ >= 2 || (verbose_ == 1 && !isWildcardUsed_) ) {
840 LogInfo(
"DQMGenericClient") <<
"makeCumulativeDist() : " 841 <<
"Cannot find sub-directory " << startDir << endl;
848 ME* element_cd = igetter.
get(startDir+
"/"+cdName);
851 if ( verbose_ >= 2 || (verbose_ == 1 && !isWildcardUsed_) ) {
852 LogInfo(
"DQMGenericClient") <<
"makeCumulativeDist() : " 853 <<
"No such element '" << cdName <<
"' found\n";
858 TH1F* cd = element_cd->getTH1F();
861 if ( verbose_ >= 2 || (verbose_ == 1 && !isWildcardUsed_) ) {
862 LogInfo(
"DQMGenericClient") <<
"makeCumulativeDist() : " 863 <<
"Cannot create TH1F from ME\n";
868 int n_bins = cd->GetNbinsX() + 1;
871 for (
int i = 1;
i <= n_bins;
i++) {
872 cd->SetBinContent(
i,cd->GetBinContent(
i) + cd->GetBinContent(
i-1));
876 for (
int i = n_bins-1;
i >= 0;
i--) {
877 cd->SetBinContent(
i,cd->GetBinContent(
i) + cd->GetBinContent(
i+1));
887 if ( verbose_ >= 2 || (verbose_ == 1 && !isWildcardUsed_) ) {
888 LogInfo(
"DQMGenericClient") <<
"makeNoFlowDist() : " 889 <<
"Cannot find sub-directory " << startDir << endl;
896 ME* element_noFlow = igetter.
get(startDir+
"/"+noFlowName);
898 if ( !element_noFlow ) {
899 if ( verbose_ >= 2 || (verbose_ == 1 && !isWildcardUsed_) ) {
900 LogInfo(
"DQMGenericClient") <<
"makeNoFlowDist() : " 901 <<
"No such element '" << noFlowName <<
"' found\n";
906 TH1F* noFlow = element_noFlow->getTH1F();
909 if ( verbose_ >= 2 || (verbose_ == 1 && !isWildcardUsed_) ) {
910 LogInfo(
"DQMGenericClient") <<
"makeNoFlowDist() : " 911 <<
"Cannot create TH1F from ME\n";
916 noFlow->AddBinContent(1, noFlow->GetBinContent(0));
917 noFlow->SetBinContent(0, 0.);
919 const auto lastBin = noFlow->GetNbinsX();
920 noFlow->AddBinContent(lastBin, noFlow->GetBinContent(lastBin+1));
921 noFlow->SetBinContent(lastBin+1, 0.);
932 double cont_min = 100;
933 Int_t binx = histo->GetXaxis()->GetNbins();
935 for (
int i = 1; i <= binx ; i++) {
937 TH1 *histoY = histo->ProjectionY(
" ", i, i);
938 double cont = histoY->GetEntries();
940 if (cont >= cont_min) {
941 float minfit = histoY->GetMean() - histoY->GetRMS();
942 float maxfit = histoY->GetMean() + histoY->GetRMS();
944 TF1 *fitFcn =
new TF1(TString(
"g")+histo->GetName()+iString,
"gaus",minfit,maxfit);
946 fitFcn->GetRange(x1,x2);
948 histoY->Fit(fitFcn,
"QR0 SERIAL",
"",x1,x2);
951 double *par = fitFcn->GetParameters();
952 const double *err = fitFcn->GetParErrors();
964 if(fitFcn)
delete fitFcn;
965 if(histoY)
delete histoY;
968 if(histoY)
delete histoY;
977 const TString& _pattern = TString(
"")) {
980 LogError(
"DQMGenericClient") <<
" DQMGenericClient::findAllSubdirectories ==> Missing folder " << dir <<
" !!!";
987 vector <string> foundDirs = igetter.
getSubdirs();
988 for(vector<string>::const_iterator iDir = foundDirs.begin();
989 iDir != foundDirs.end(); ++iDir) {
990 TString
dirName = iDir->substr(iDir->rfind(
'/') + 1, iDir->length());
991 if (dirName.Contains(regexp))
992 findAllSubdirectories (ibooker, igetter, *iDir, myList);
1001 findAllSubdirectories (ibooker, igetter, dir, myList,
"*");
1005 LogInfo (
"DQMGenericClient") <<
"Trying to find sub-directories of " << dir
1006 <<
" failed because " << dir <<
" does not exist";
1014 for (
int iBinX = 1; iBinX < denom->GetNbinsX()+1; iBinX++){
1015 for (
int iBinY = 1; iBinY < denom->GetNbinsY()+1; iBinY++){
1016 for (
int iBinZ = 1; iBinZ < denom->GetNbinsZ()+1; iBinZ++){
1018 int globalBinNum = denom->GetBin(iBinX, iBinY, iBinZ);
1020 float numerVal = numer->GetBinContent(globalBinNum);
1021 float denomVal = denom->GetBinContent(globalBinNum);
1026 if (type == EfficType::fakerate) {
1027 effVal = denomVal ? (1 - numerVal / denomVal) : 0;
1029 effVal = denomVal ? numerVal / denomVal : 0;
1033 if (type == EfficType::simpleratio) {
1035 float numerErr = numer->GetBinError(globalBinNum);
1036 float denomErr = denom->GetBinError(globalBinNum);
1037 float denomsq = denomVal*denomVal;
1038 errVal = denomVal ?
sqrt(
pow( 1.
f/denomVal*numerErr,2.0) +
pow(numerVal/denomsq*denomErr,2) ): 0;
1040 errVal = (denomVal && (effVal <=1)) ?
sqrt(effVal*(1-effVal)/denomVal) : 0;
1043 LogDebug (
"DQMGenericClient") <<
"(iBinX, iBinY, iBinZ) = " 1046 << iBinZ <<
"), global bin = " << globalBinNum
1047 <<
"eff = " << numerVal <<
" / " << denomVal
1049 <<
" ... setting the error for that bin ... " << endl
1054 efficiencyHist->
setBinError(globalBinNum, errVal);
1065 if (igetter.
get(meName)) {
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
void dqmEndJob(DQMStore::IBooker &, DQMStore::IGetter &) override
void setBinContent(int binx, double content)
set content of bin (1-D)
MonitorElement * bookProfile(Args &&...args)
MonitorElement * get(const std::string &path)
TPRegexp metacharacters("[\\^\\$\\.\\*\\+\\?\\|\\(\\)\\{\\}\\[\\]]")
void makeCumulativeDist(DQMStore::IBooker &ibooker, DQMStore::IGetter &igetter, const std::string &startDir, const std::string &cdName, bool ascending=true)
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e< void, edm::EventID const &, edm::Timestamp const & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
void makeAllPlots(DQMStore::IBooker &, DQMStore::IGetter &)
void normalizeToEntries(DQMStore::IBooker &ibooker, DQMStore::IGetter &igetter, const std::string &startDir, const std::string &histName, const std::string &normHistName)
MonitorElement * book1D(Args &&...args)
void computeResolution(DQMStore::IBooker &ibooker, DQMStore::IGetter &igetter, const std::string &startDir, const std::string &fitMEPrefix, const std::string &fitMETitlePrefix, const std::string &srcMEName)
void setBinError(int binx, double error)
set uncertainty on content of bin (1-D)
void makeNoFlowDist(DQMStore::IBooker &ibooker, DQMStore::IGetter &igetter, const std::string &startDir, const std::string &cdName)
bool dirExists(const std::string &path)
void findAllSubdirectories(DQMStore::IBooker &ibooker, DQMStore::IGetter &igetter, std::string dir, std::set< std::string > *myList, const TString &pattern)
void setCurrentFolder(const std::string &fullpath)
MonitorElement * book2D(Args &&...args)
void dqmEndLuminosityBlock(DQMStore::IBooker &ibooker, DQMStore::IGetter &igetter, const edm::LuminosityBlock &lumiSeg, const edm::EventSetup &c) override
TPRegexp nonPerlWildcard("\\w\\*|^\\*")
void computeEfficiency(DQMStore::IBooker &ibooker, DQMStore::IGetter &igetter, const std::string &startDir, const std::string &efficMEName, const std::string &efficMETitle, const std::string &recoMEName, const std::string &simMEName, const EfficType type=EfficType::efficiency, const bool makeProfile=false)
std::vector< std::string > getSubdirs()
DQMGenericClient(const edm::ParameterSet &pset)
def efficSet(nameIn, titleIn, numeratorIn, denominatorIn, typeIn="eff")
void computeProfile(DQMStore::IBooker &ibooker, DQMStore::IGetter &igetter, const std::string &startDir, const std::string &profileMEName, const std::string &profileMETitle, const std::string &srcMEName)
MonitorElement * book3D(Args &&...args)
void removeElement(Args &&...args)
void removeMEIfBooked(const std::string &meName, DQMStore::IGetter &igetter)
Power< A, B >::type pow(const A &a, const B &b)
void limitedFit(MonitorElement *srcME, MonitorElement *meanME, MonitorElement *sigmaME)
void generic_eff(TH1 *denom, TH1 *numer, MonitorElement *efficiencyHist, const EfficType type=EfficType::efficiency)