20 #include <boost/tokenizer.hpp>
21 #include <boost/regex.hpp>
24 #include <TEfficiency.h>
53 std::set<std::string>*
myList,
58 using VPSet = std::vector<edm::ParameterSet>;
59 using vstring = std::vector<std::string>;
60 using elsc = boost::escaped_list_separator<char>;
62 subDirs_ =
pset.getUntrackedParameter<
vstring>(
"subDirs");
63 hltTriggers_ =
pset.getUntrackedParameter<
vstring>(
"hltTriggers");
64 refTriggers_ =
pset.getUntrackedParameter<
string>(
"refTriggers");
65 efficiency_ =
pset.getUntrackedParameter<
vstring>(
"efficiency");
66 refEff_ =
pset.getUntrackedParameter<
vstring>(
"refEff");
72 using vstring = std::vector<std::string>;
73 boost::regex metacharacters{
"[\\^\\$\\.\\*\\+\\?\\|\\(\\)\\{\\}\\[\\]]"};
80 set<string> subDirSet;
82 for (
auto iSubDir = subDirs_.begin(); iSubDir != subDirs_.end(); ++iSubDir) {
88 if (boost::regex_search(
subDir, what, metacharacters)) {
90 const string searchPath =
subDir.substr(0, shiftPos);
94 findAllSubdirectories(ibooker, igetter, searchPath, &subDirSet,
pattern);
101 for (
auto const&
subDir : subDirSet) {
102 for (
unsigned int iEff = 0; iEff != efficiency_.size(); ++iEff) {
103 string eff = efficiency_[iEff];
112 for (
auto iTrigger = hltTriggers_.begin(); iTrigger != hltTriggers_.end(); ++iTrigger) {
113 string trig = *iTrigger;
117 TH1* hRef =
refEff->getTH1();
118 TH1* hTrig = trigEff->
getTH1();
119 TH1* hEff = (TH1*)hTrig->Clone((
"eff_" + eff +
"_ref").c_str());
120 hEff->SetTitle(
"Efficiency obtained with reference method");
121 TClass* myHistClass = hTrig->IsA();
122 TString histClassName = myHistClass->GetName();
124 if (histClassName ==
"TH1F") {
125 for (
int bin = 0;
bin < hEff->GetNbinsX(); ++
bin) {
126 hEff->SetBinContent(
bin + 1, hEff->GetBinContent(
bin + 1) * hRef->GetBinContent(
bin + 1));
127 hEff->SetBinError(
bin + 1,
128 hEff->GetBinContent(
bin + 1) * hRef->GetBinError(
bin + 1) +
129 hEff->GetBinError(
bin + 1) * hRef->GetBinContent(
bin + 1));
132 ibooker.
book1D(hEff->GetName(), (TH1F*)hEff);
134 }
else if (histClassName ==
"TH2F") {
135 for (
int i = 0;
i < hRef->GetXaxis()->GetNbins(); ++
i) {
136 for (
int j = 0;
j < hRef->GetYaxis()->GetNbins(); ++
j) {
137 int bin = hEff->GetBin(
i + 1,
j + 1);
138 hEff->SetBinContent(
bin, hRef->GetBinContent(
i + 1,
j + 1) * hTrig->GetBinContent(
i + 1));
142 ibooker.
book2D(hEff->GetName(), (TH2F*)hEff);
144 LogInfo(
"HLTMuonRefMethod") <<
"Histo class type << " << histClassName <<
" not implemented";
158 std::set<std::string>*
myList,
159 const TString& _pattern = TString(
"")) {
161 TPRegexp nonPerlWildcard(
"\\w\\*|^\\*");
164 LogError(
"DQMGenericClient") <<
" DQMGenericClient::findAllSubdirectories ==> Missing folder " <<
dir <<
" !!!";
168 if (
pattern.Contains(nonPerlWildcard))
172 vector<string> foundDirs = igetter.
getSubdirs();
173 for (
auto iDir = foundDirs.begin(); iDir != foundDirs.end(); ++iDir) {
174 TString
dirName = iDir->substr(iDir->rfind(
'/') + 1, iDir->length());
176 findAllSubdirectories(ibooker, igetter, *iDir,
myList);
185 findAllSubdirectories(ibooker, igetter,
dir,
myList,
"*");
189 LogInfo(
"DQMGenericClient") <<
"Trying to find sub-directories of " <<
dir <<
" failed because " <<
dir
190 <<
" does not exist";