24 #include <boost/tokenizer.hpp> 31 TPRegexp
metacharacters(
"[\\^\\$\\.\\*\\+\\?\\|\\(\\)\\{\\}\\[\\]]");
35 typedef std::vector<edm::ParameterSet>
VPSet;
36 typedef std::vector<std::string>
vstring;
37 typedef boost::escaped_list_separator<char> elsc;
39 elsc commonEscapes(
"\\",
" \t",
"\'");
47 vstring effCmds = pset.
getParameter<vstring>(
"efficiency");
48 for (vstring::const_iterator effCmd = effCmds.begin(); effCmd != effCmds.end(); ++effCmd) {
52 boost::tokenizer<elsc> tokens(*effCmd, commonEscapes);
55 for (boost::tokenizer<elsc>::const_iterator iToken = tokens.begin(); iToken != tokens.end(); ++iToken) {
58 args.push_back(*iToken);
61 if (args.size() < 4) {
62 LogInfo(
"DQMGenericClient") <<
"Wrong input to effCmds\n";
73 const string typeName = args.size() == 4 ?
"eff" : args[4];
74 if (typeName ==
"eff")
76 else if (typeName ==
"fake")
77 opt.
type = EfficType::fakerate;
78 else if (typeName ==
"simpleratio")
79 opt.
type = EfficType::simpleratio;
83 efficOptions_.push_back(opt);
89 opt.
name =
efficSet->getUntrackedParameter<
string>(
"name");
95 const string typeName =
efficSet->getUntrackedParameter<
string>(
"typeName",
"eff");
96 if (typeName ==
"eff")
98 else if (typeName ==
"fake")
99 opt.
type = EfficType::fakerate;
100 else if (typeName ==
"simpleratio")
101 opt.
type = EfficType::simpleratio;
105 efficOptions_.push_back(opt);
110 for (vstring::const_iterator effProfileCmd = effProfileCmds.begin(); effProfileCmd != effProfileCmds.end();
112 if (effProfileCmd->empty())
115 boost::tokenizer<elsc> tokens(*effProfileCmd, commonEscapes);
118 for (boost::tokenizer<elsc>::const_iterator iToken = tokens.begin(); iToken != tokens.end(); ++iToken) {
121 args.push_back(*iToken);
124 if (args.size() < 4) {
125 LogInfo(
"DQMGenericClient") <<
"Wrong input to effProfileCmds\n";
136 const string typeName = args.size() == 4 ?
"eff" : args[4];
137 if (typeName ==
"eff")
139 else if (typeName ==
"fake")
140 opt.
type = EfficType::fakerate;
141 else if (typeName ==
"simpleratio")
142 opt.
type = EfficType::simpleratio;
146 efficOptions_.push_back(opt);
150 for (VPSet::const_iterator effProfileSet = effProfileSets.begin(); effProfileSet != effProfileSets.end();
153 opt.
name = effProfileSet->getUntrackedParameter<
string>(
"name");
154 opt.
title = effProfileSet->getUntrackedParameter<
string>(
"title");
155 opt.
numerator = effProfileSet->getUntrackedParameter<
string>(
"numerator");
156 opt.
denominator = effProfileSet->getUntrackedParameter<
string>(
"denominator");
159 const string typeName = effProfileSet->getUntrackedParameter<
string>(
"typeName",
"eff");
160 if (typeName ==
"eff")
162 else if (typeName ==
"fake")
163 opt.
type = EfficType::fakerate;
164 else if (typeName ==
"simpleratio")
165 opt.
type = EfficType::simpleratio;
169 efficOptions_.push_back(opt);
173 vstring resCmds = pset.
getParameter<vstring>(
"resolution");
174 for (vstring::const_iterator resCmd = resCmds.begin(); resCmd != resCmds.end(); ++resCmd) {
177 boost::tokenizer<elsc> tokens(*resCmd, commonEscapes);
180 for (boost::tokenizer<elsc>::const_iterator iToken = tokens.begin(); iToken != tokens.end(); ++iToken) {
183 args.push_back(*iToken);
186 if (args.size() != 3) {
187 LogInfo(
"DQMGenericClient") <<
"Wrong input to resCmds\n";
196 resolOptions_.push_back(opt);
200 for (VPSet::const_iterator resolSet = resolSets.begin(); resolSet != resolSets.end(); ++resolSet) {
202 opt.
namePrefix = resolSet->getUntrackedParameter<
string>(
"namePrefix");
203 opt.
titlePrefix = resolSet->getUntrackedParameter<
string>(
"titlePrefix");
204 opt.
srcName = resolSet->getUntrackedParameter<
string>(
"srcName");
206 resolOptions_.push_back(opt);
211 for (
const auto& profileCmd : profileCmds) {
212 boost::tokenizer<elsc> tokens(profileCmd, commonEscapes);
215 for (boost::tokenizer<elsc>::const_iterator iToken = tokens.begin(); iToken != tokens.end(); ++iToken) {
218 args.push_back(*iToken);
221 if (args.size() != 3) {
222 LogInfo(
"DQMGenericClient") <<
"Wrong input to profileCmds\n";
231 profileOptions_.push_back(opt);
235 for (
const auto& profileSet : profileSets) {
237 opt.
name = profileSet.getUntrackedParameter<
string>(
"name");
238 opt.
title = profileSet.getUntrackedParameter<
string>(
"title");
239 opt.
srcName = profileSet.getUntrackedParameter<
string>(
"srcName");
241 profileOptions_.push_back(opt);
246 for (vstring::const_iterator normCmd = normCmds.begin(); normCmd != normCmds.end(); ++normCmd) {
247 if (normCmd->empty())
249 boost::tokenizer<elsc> tokens(*normCmd, commonEscapes);
252 for (boost::tokenizer<elsc>::const_iterator iToken = tokens.begin(); iToken != tokens.end(); ++iToken) {
255 args.push_back(*iToken);
258 if (args.empty()
or args.size() > 2) {
259 LogInfo(
"DQMGenericClient") <<
"Wrong input to normCmds\n";
265 opt.
normHistName = args.size() == 2 ? args[1] : args[0];
267 normOptions_.push_back(opt);
271 for (VPSet::const_iterator normSet = normSets.begin(); normSet != normSets.end(); ++normSet) {
273 opt.
name = normSet->getUntrackedParameter<
string>(
"name");
274 opt.
normHistName = normSet->getUntrackedParameter<
string>(
"normalizedTo", opt.
name);
276 normOptions_.push_back(opt);
281 for (vstring::const_iterator cdCmd = cdCmds.begin(); cdCmd != cdCmds.end(); ++cdCmd) {
284 boost::tokenizer<elsc> tokens(*cdCmd, commonEscapes);
287 for (boost::tokenizer<elsc>::const_iterator iToken = tokens.begin(); iToken != tokens.end(); ++iToken) {
290 args.push_back(*iToken);
293 if (args.empty() || args.size() > 2) {
294 LogInfo(
"DQMGenericClient") <<
"Wrong input to cdCmds\n";
300 opt.
ascending = args.size() == 2 ? (args[1] !=
"descending") :
true;
302 cdOptions_.push_back(opt);
306 for (VPSet::const_iterator cdSet = cdSets.begin(); cdSet != cdSets.end(); ++cdSet) {
308 opt.
name = cdSet->getUntrackedParameter<
string>(
"name");
309 opt.
ascending = cdSet->getUntrackedParameter<
bool>(
"ascending",
true);
311 cdOptions_.push_back(opt);
316 for (vstring::const_iterator noFlowCmd = noFlowCmds.begin(); noFlowCmd != noFlowCmds.end(); ++noFlowCmd) {
317 if (noFlowCmd->empty())
319 boost::tokenizer<elsc> tokens(*noFlowCmd, commonEscapes);
322 for (boost::tokenizer<elsc>::const_iterator iToken = tokens.begin(); iToken != tokens.end(); ++iToken) {
325 args.push_back(*iToken);
328 if (args.empty() || args.size() > 2) {
329 LogInfo(
"DQMGenericClient") <<
"Wrong input to noFlowCmds\n";
336 noFlowOptions_.push_back(opt);
340 for (VPSet::const_iterator noFlowSet = noFlowSets.begin(); noFlowSet != noFlowSets.end(); ++noFlowSet) {
342 opt.
name = noFlowSet->getUntrackedParameter<
string>(
"name");
344 noFlowOptions_.push_back(opt);
351 isWildcardUsed_ =
false;
359 makeAllPlots(ibooker, igetter);
383 makeAllPlots(ibooker, igetter);
386 if (!outputFileName_.empty())
387 theDQM->save(outputFileName_);
391 typedef vector<string>
vstring;
394 set<string> subDirSet;
396 for (vstring::const_iterator iSubDir = subDirs_.begin(); iSubDir != subDirs_.end(); ++iSubDir) {
399 if (subDir[subDir.size() - 1] ==
'/')
400 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);
413 subDirSet.insert(subDir);
417 for (set<string>::const_iterator iSubDir = subDirSet.begin(); iSubDir != subDirSet.end(); ++iSubDir) {
418 const string&
dirName = *iSubDir;
423 for (vector<NormOption>::const_iterator normOption = normOptions_.begin(); normOption != normOptions_.end();
425 normalizeToEntries(ibooker, igetter, dirName, normOption->name, normOption->normHistName);
428 for (vector<NoFlowOption>::const_iterator noFlowOption = noFlowOptions_.begin();
429 noFlowOption != noFlowOptions_.end();
431 makeNoFlowDist(ibooker, igetter, dirName, noFlowOption->name);
434 for (vector<CDOption>::const_iterator cdOption = cdOptions_.begin(); cdOption != cdOptions_.end(); ++cdOption) {
435 makeCumulativeDist(ibooker, igetter, dirName, cdOption->name, cdOption->ascending);
438 for (vector<EfficOption>::const_iterator efficOption = efficOptions_.begin(); efficOption != efficOptions_.end();
440 computeEfficiency(ibooker,
445 efficOption->numerator,
446 efficOption->denominator,
448 efficOption->isProfile);
451 for (vector<ResolOption>::const_iterator resolOption = resolOptions_.begin(); resolOption != resolOptions_.end();
454 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);
465 const string& startDir,
466 const string& efficMEName,
467 const string& efficMETitle,
468 const string& recoMEName,
469 const string& simMEName,
471 const bool makeProfile) {
473 if (verbose_ >= 2 || (verbose_ == 1 && !isWildcardUsed_)) {
474 LogInfo(
"DQMGenericClient") <<
"computeEfficiency() : " 475 <<
"Cannot find sub-directory " << startDir << endl;
482 ME* simME = igetter.
get(startDir +
"/" + simMEName);
483 ME* recoME = igetter.
get(startDir +
"/" + recoMEName);
486 if (verbose_ >= 2 || (verbose_ == 1 && !isWildcardUsed_)) {
487 LogInfo(
"DQMGenericClient") <<
"computeEfficiency() : " 488 <<
"No sim-ME '" << simMEName <<
"' found\n";
494 if (verbose_ >= 2 || (verbose_ == 1 && !isWildcardUsed_)) {
495 LogInfo(
"DQMGenericClient") <<
"computeEfficiency() : " 496 <<
"No reco-ME '" << recoMEName <<
"' found\n";
503 TH1* hSim = simME->getTH1();
504 TH1* hReco = recoME->getTH1();
506 if (!hSim || !hReco) {
507 if (verbose_ >= 2 || (verbose_ == 1 && !isWildcardUsed_)) {
508 LogInfo(
"DQMGenericClient") <<
"computeEfficiency() : " 509 <<
"Cannot create TH1 from ME\n";
514 string efficDir = startDir;
515 string newEfficMEName = efficMEName;
517 if (string::npos != (shiftPos = efficMEName.rfind(
'/'))) {
518 efficDir +=
"/" + efficMEName.substr(0, shiftPos);
519 newEfficMEName.erase(0, shiftPos + 1);
524 TProfile* efficHist = (hReco->GetXaxis()->GetXbins()->GetSize() == 0)
525 ?
new TProfile(newEfficMEName.c_str(),
526 efficMETitle.c_str(),
527 hReco->GetXaxis()->GetNbins(),
528 hReco->GetXaxis()->GetXmin(),
529 hReco->GetXaxis()->GetXmax())
530 :
new TProfile(newEfficMEName.c_str(),
531 efficMETitle.c_str(),
532 hReco->GetXaxis()->GetNbins(),
533 hReco->GetXaxis()->GetXbins()->GetArray());
535 efficHist->GetXaxis()->SetTitle(hSim->GetXaxis()->GetTitle());
536 efficHist->GetYaxis()->SetTitle(hSim->GetYaxis()->GetTitle());
538 for (
int i = 1;
i <= hReco->GetNbinsX();
i++) {
539 const double nReco = hReco->GetBinContent(
i);
540 const double nSim = hSim->GetBinContent(
i);
543 efficHist->GetXaxis()->SetBinLabel(
i, hSim->GetXaxis()->GetBinLabel(
i));
545 if (nSim == 0
or nReco < 0 or nReco > nSim)
547 const double effVal = nReco / nSim;
548 const double errLo = TEfficiency::ClopperPearson(nSim, nReco, 0.683,
false);
549 const double errUp = TEfficiency::ClopperPearson(nSim, nReco, 0.683,
true);
550 const double errVal = (effVal - errLo > errUp - effVal) ? effVal - errLo : errUp - effVal;
551 efficHist->SetBinContent(
i, effVal);
552 efficHist->SetBinEntries(
i, 1);
553 efficHist->SetBinError(
i, std::hypot(effVal, errVal));
560 TH1* efficHist = (TH1*)hSim->Clone(newEfficMEName.c_str());
561 efficHist->SetTitle(efficMETitle.c_str());
566 ME* efficME =
nullptr;
570 TClass* myHistClass = efficHist->IsA();
571 TString histClassName = myHistClass->GetName();
573 if (histClassName ==
"TH1F") {
574 efficME = ibooker.
book1D(newEfficMEName, (TH1F*)efficHist);
575 }
else if (histClassName ==
"TH2F") {
576 efficME = ibooker.
book2D(newEfficMEName, (TH2F*)efficHist);
577 }
else if (histClassName ==
"TH3F") {
578 efficME = ibooker.
book3D(newEfficMEName, (TH3F*)efficHist);
584 LogInfo(
"DQMGenericClient") <<
"computeEfficiency() : " 585 <<
"Cannot book effic-ME from the DQM\n";
593 generic_eff(hSim, hReco, efficME, type);
606 efficME->setEntries(simME->getEntries());
610 if (makeGlobalEffPlot_) {
611 ME* globalEfficME = igetter.
get(efficDir +
"/globalEfficiencies");
613 globalEfficME = ibooker.
book1D(
"globalEfficiencies",
"Global efficiencies", 1, 0, 1);
614 if (!globalEfficME) {
615 LogInfo(
"DQMGenericClient") <<
"computeEfficiency() : " 616 <<
"Cannot book globalEffic-ME from the DQM\n";
619 globalEfficME->setEfficiencyFlag();
620 TH1F* hGlobalEffic = globalEfficME->getTH1F();
622 LogInfo(
"DQMGenericClient") <<
"computeEfficiency() : " 623 <<
"Cannot create TH1F from ME, globalEfficME\n";
627 const float nSimAll = hSim->GetEntries();
628 const float nRecoAll = hReco->GetEntries();
631 efficAll = nSimAll ? nRecoAll / nSimAll : 0;
632 else if (type == EfficType::fakerate)
633 efficAll = nSimAll ? 1 - nRecoAll / nSimAll : 0;
635 if (type == EfficType::simpleratio) {
637 const float x = nRecoAll / nSimAll;
638 errorAll =
std::sqrt(1.
f / nSimAll * x * (1 + x));
641 errorAll = nSimAll && efficAll < 1 ?
sqrt(efficAll * (1 - efficAll) / nSimAll) : 0;
643 const int iBin = hGlobalEffic->Fill(newEfficMEName.c_str(), 0);
644 hGlobalEffic->SetBinContent(iBin, efficAll);
645 hGlobalEffic->SetBinError(iBin, errorAll);
651 const string& startDir,
656 if (verbose_ >= 2 || (verbose_ == 1 && !isWildcardUsed_)) {
657 LogInfo(
"DQMGenericClient") <<
"computeResolution() : " 658 <<
"Cannot find sub-directory " << startDir << endl;
665 ME* srcME = igetter.
get(startDir +
"/" + srcName);
667 if (verbose_ >= 2 || (verbose_ == 1 && !isWildcardUsed_)) {
668 LogInfo(
"DQMGenericClient") <<
"computeResolution() : " 669 <<
"No source ME '" << srcName <<
"' found\n";
674 TH2F* hSrc = srcME->getTH2F();
676 if (verbose_ >= 2 || (verbose_ == 1 && !isWildcardUsed_)) {
677 LogInfo(
"DQMGenericClient") <<
"computeResolution() : " 678 <<
"Cannot create TH2F from source-ME\n";
683 const int nBin = hSrc->GetNbinsX();
685 string newDir = startDir;
688 if (string::npos != (shiftPos = namePrefix.rfind(
'/'))) {
689 newDir +=
"/" + namePrefix.substr(0, shiftPos);
690 newPrefix.erase(0, shiftPos + 1);
695 float* lowedgesfloats =
new float[nBin + 1];
698 if (hSrc->GetXaxis()->GetXbins()->GetSize()) {
699 for (
int j = 0;
j < nBin + 1; ++
j)
700 lowedgesfloats[
j] = (
float)hSrc->GetXaxis()->GetXbins()->GetAt(
j);
701 meanME = ibooker.
book1D(newPrefix +
"_Mean", titlePrefix +
" Mean", nBin, lowedgesfloats);
702 sigmaME = ibooker.
book1D(newPrefix +
"_Sigma", titlePrefix +
" Sigma", nBin, lowedgesfloats);
705 newPrefix +
"_Mean", titlePrefix +
" Mean", nBin, hSrc->GetXaxis()->GetXmin(), hSrc->GetXaxis()->GetXmax());
707 newPrefix +
"_Sigma", titlePrefix +
" Sigma", nBin, hSrc->GetXaxis()->GetXmin(), hSrc->GetXaxis()->GetXmax());
710 if (meanME && sigmaME) {
711 meanME->setEfficiencyFlag();
712 sigmaME->setEfficiencyFlag();
714 if (!resLimitedFit_) {
720 limitedFit(srcME, meanME, sigmaME);
723 delete[] lowedgesfloats;
733 if (verbose_ >= 2 || (verbose_ == 1 && !isWildcardUsed_)) {
734 LogInfo(
"DQMGenericClient") <<
"computeProfile() : " 735 <<
"Cannot find sub-directory " << startDir << endl;
742 ME* srcME = igetter.
get(startDir +
"/" + srcMEName);
744 if (verbose_ >= 2 || (verbose_ == 1 && !isWildcardUsed_)) {
745 LogInfo(
"DQMGenericClient") <<
"computeProfile() : " 746 <<
"No source ME '" << srcMEName <<
"' found\n";
751 TH2F* hSrc = srcME->getTH2F();
753 if (verbose_ >= 2 || (verbose_ == 1 && !isWildcardUsed_)) {
754 LogInfo(
"DQMGenericClient") <<
"computeProfile() : " 755 <<
"Cannot create TH2F from source-ME\n";
760 string profileDir = startDir;
761 string newProfileMEName = profileMEName;
763 if (string::npos != (shiftPos = profileMEName.rfind(
'/'))) {
764 profileDir +=
"/" + profileMEName.substr(0, shiftPos);
765 newProfileMEName.erase(0, shiftPos + 1);
769 std::unique_ptr<TProfile>
profile(hSrc->ProfileX());
770 profile->SetTitle(profileMETitle.c_str());
780 if (verbose_ >= 2 || (verbose_ == 1 && !isWildcardUsed_)) {
781 LogInfo(
"DQMGenericClient") <<
"normalizeToEntries() : " 782 <<
"Cannot find sub-directory " << startDir << endl;
789 ME* element = igetter.
get(startDir +
"/" + histName);
790 ME* normME = igetter.
get(startDir +
"/" + normHistName);
793 if (verbose_ >= 2 || (verbose_ == 1 && !isWildcardUsed_)) {
794 LogInfo(
"DQMGenericClient") <<
"normalizeToEntries() : " 795 <<
"No such element '" << histName <<
"' found\n";
801 if (verbose_ >= 2 || (verbose_ == 1 && !isWildcardUsed_)) {
802 LogInfo(
"DQMGenericClient") <<
"normalizeToEntries() : " 803 <<
"No such element '" << normHistName <<
"' found\n";
808 TH1F*
hist = element->getTH1F();
810 if (verbose_ >= 2 || (verbose_ == 1 && !isWildcardUsed_)) {
811 LogInfo(
"DQMGenericClient") <<
"normalizeToEntries() : " 812 <<
"Cannot create TH1F from ME\n";
817 TH1F* normHist = normME->getTH1F();
819 if (verbose_ >= 2 || (verbose_ == 1 && !isWildcardUsed_)) {
820 LogInfo(
"DQMGenericClient") <<
"normalizeToEntries() : " 821 <<
"Cannot create TH1F from ME\n";
826 const double entries = normHist->GetEntries();
828 hist->Scale(1. / entries);
830 LogInfo(
"DQMGenericClient") <<
"normalizeToEntries() : " 831 <<
"Zero entries in histogram\n";
843 if (verbose_ >= 2 || (verbose_ == 1 && !isWildcardUsed_)) {
844 LogInfo(
"DQMGenericClient") <<
"makeCumulativeDist() : " 845 <<
"Cannot find sub-directory " << startDir << endl;
852 ME* element_cd = igetter.
get(startDir +
"/" + cdName);
855 if (verbose_ >= 2 || (verbose_ == 1 && !isWildcardUsed_)) {
856 LogInfo(
"DQMGenericClient") <<
"makeCumulativeDist() : " 857 <<
"No such element '" << cdName <<
"' found\n";
862 TH1F*
cd = element_cd->getTH1F();
865 if (verbose_ >= 2 || (verbose_ == 1 && !isWildcardUsed_)) {
866 LogInfo(
"DQMGenericClient") <<
"makeCumulativeDist() : " 867 <<
"Cannot create TH1F from ME\n";
872 int n_bins = cd->GetNbinsX() + 1;
875 for (
int i = 1;
i <= n_bins;
i++) {
876 cd->SetBinContent(
i, cd->GetBinContent(
i) + cd->GetBinContent(
i - 1));
879 for (
int i = n_bins - 1;
i >= 0;
i--) {
880 cd->SetBinContent(
i, cd->GetBinContent(
i) + cd->GetBinContent(
i + 1));
892 if (verbose_ >= 2 || (verbose_ == 1 && !isWildcardUsed_)) {
893 LogInfo(
"DQMGenericClient") <<
"makeNoFlowDist() : " 894 <<
"Cannot find sub-directory " << startDir << endl;
901 ME* element_noFlow = igetter.
get(startDir +
"/" + noFlowName);
903 if (!element_noFlow) {
904 if (verbose_ >= 2 || (verbose_ == 1 && !isWildcardUsed_)) {
905 LogInfo(
"DQMGenericClient") <<
"makeNoFlowDist() : " 906 <<
"No such element '" << noFlowName <<
"' found\n";
911 TH1F* noFlow = element_noFlow->getTH1F();
914 if (verbose_ >= 2 || (verbose_ == 1 && !isWildcardUsed_)) {
915 LogInfo(
"DQMGenericClient") <<
"makeNoFlowDist() : " 916 <<
"Cannot create TH1F from ME\n";
921 noFlow->AddBinContent(1, noFlow->GetBinContent(0));
922 noFlow->SetBinContent(0, 0.);
924 const auto lastBin = noFlow->GetNbinsX();
925 noFlow->AddBinContent(lastBin, noFlow->GetBinContent(lastBin + 1));
926 noFlow->SetBinContent(lastBin + 1, 0.);
936 double cont_min = 100;
937 Int_t binx = histo->GetXaxis()->GetNbins();
939 for (
int i = 1; i <= binx; i++) {
941 TH1* histoY = histo->ProjectionY(
" ", i, i);
942 double cont = histoY->GetEntries();
944 if (cont >= cont_min) {
945 float minfit = histoY->GetMean() - histoY->GetRMS();
946 float maxfit = histoY->GetMean() + histoY->GetRMS();
948 TF1* fitFcn =
new TF1(TString(
"g") + histo->GetName() + iString,
"gaus", minfit, maxfit);
950 fitFcn->GetRange(x1, x2);
952 histoY->Fit(fitFcn,
"QR0 SERIAL",
"", x1, x2);
955 double* par = fitFcn->GetParameters();
956 const double*
err = fitFcn->GetParErrors();
985 std::set<std::string>*
myList,
986 const TString& _pattern = TString(
"")) {
989 LogError(
"DQMGenericClient") <<
" DQMGenericClient::findAllSubdirectories ==> Missing folder " << dir <<
" !!!";
994 pattern.ReplaceAll(
"*",
".*");
997 vector<string> foundDirs = igetter.
getSubdirs();
998 for (vector<string>::const_iterator iDir = foundDirs.begin(); iDir != foundDirs.end(); ++iDir) {
999 TString
dirName = iDir->substr(iDir->rfind(
'/') + 1, iDir->length());
1000 if (dirName.Contains(regexp))
1001 findAllSubdirectories(ibooker, igetter, *iDir, myList);
1007 myList->insert(dir);
1010 findAllSubdirectories(ibooker, igetter, dir, myList,
"*");
1014 LogInfo(
"DQMGenericClient") <<
"Trying to find sub-directories of " << dir <<
" failed because " << dir
1015 <<
" does not exist";
1021 for (
int iBinX = 1; iBinX < denom->GetNbinsX() + 1; iBinX++) {
1022 for (
int iBinY = 1; iBinY < denom->GetNbinsY() + 1; iBinY++) {
1023 for (
int iBinZ = 1; iBinZ < denom->GetNbinsZ() + 1; iBinZ++) {
1024 int globalBinNum = denom->GetBin(iBinX, iBinY, iBinZ);
1026 float numerVal = numer->GetBinContent(globalBinNum);
1027 float denomVal = denom->GetBinContent(globalBinNum);
1032 if (type == EfficType::fakerate) {
1033 effVal = denomVal ? (1 - numerVal / denomVal) : 0;
1035 effVal = denomVal ? numerVal / denomVal : 0;
1039 if (type == EfficType::simpleratio) {
1041 float numerErr = numer->GetBinError(globalBinNum);
1042 float denomErr = denom->GetBinError(globalBinNum);
1043 float denomsq = denomVal * denomVal;
1044 errVal = denomVal ?
sqrt(
pow(1.
f / denomVal * numerErr, 2.0) +
pow(numerVal / denomsq * denomErr, 2)) : 0;
1046 errVal = (denomVal && (effVal <= 1)) ?
sqrt(effVal * (1 - effVal) / denomVal) : 0;
1049 LogDebug(
"DQMGenericClient") <<
"(iBinX, iBinY, iBinZ) = " << iBinX <<
", " << iBinY <<
", " << iBinZ
1050 <<
"), global bin = " << globalBinNum <<
"eff = " << numerVal <<
" / " 1051 << denomVal <<
" = " << effVal <<
" ... setting the error for that bin ... " 1056 efficiencyHist->
setBinError(globalBinNum, errVal);
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX)
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
void dqmEndJob(DQMStore::IBooker &, DQMStore::IGetter &) override
virtual TH2F * getTH2F() const
void setCurrentFolder(std::string const &fullpath)
TPRegexp metacharacters("[\\^\\$\\.\\*\\+\\?\\|\\(\\)\\{\\}\\[\\]]")
void makeCumulativeDist(DQMStore::IBooker &ibooker, DQMStore::IGetter &igetter, const std::string &startDir, const std::string &cdName, bool ascending=true)
bool dirExists(std::string const &path)
DQMGenericClient::MonitorElement ME
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 &)
MonitorElement * bookProfile(TString const &name, TString const &title, int nchX, double lowX, double highX, int nchY, double lowY, double highY, char const *option="s")
void normalizeToEntries(DQMStore::IBooker &ibooker, DQMStore::IGetter &igetter, const std::string &startDir, const std::string &histName, const std::string &normHistName)
MonitorElement * book3D(TString const &name, TString const &title, int nchX, double lowX, double highX, int nchY, double lowY, double highY, int nchZ, double lowZ, double highZ)
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 makeNoFlowDist(DQMStore::IBooker &ibooker, DQMStore::IGetter &igetter, const std::string &startDir, const std::string &cdName)
void findAllSubdirectories(DQMStore::IBooker &ibooker, DQMStore::IGetter &igetter, std::string dir, std::set< std::string > *myList, const TString &pattern)
virtual void setBinContent(int binx, double content)
set content of bin (1-D)
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)
MonitorElement * book2D(TString const &name, TString const &title, int nchX, double lowX, double highX, int nchY, double lowY, double highY)
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)
virtual void setBinError(int binx, double error)
set uncertainty on content of bin (1-D)
MonitorElement * get(std::string const &path)
Power< A, B >::type pow(const A &a, const B &b)
void limitedFit(MonitorElement *srcME, MonitorElement *meanME, MonitorElement *sigmaME)
cont
load Luminosity info ##
void generic_eff(TH1 *denom, TH1 *numer, MonitorElement *efficiencyHist, const EfficType type=EfficType::efficiency)
std::vector< std::string > getSubdirs()