20 #include <boost/tokenizer.hpp>
21 #include <boost/regex.hpp>
24 #include <TEfficiency.h>
53 std::set<std::string>*
myList,
54 const TString& pattern);
58 using VPSet = std::vector<edm::ParameterSet>;
59 using vstring = std::vector<std::string>;
60 using elsc = boost::escaped_list_separator<char>;
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) {
83 string subDir = *iSubDir;
85 if (subDir[subDir.size() - 1] ==
'/')
86 subDir.erase(subDir.size() - 1);
88 if (boost::regex_search(subDir, what, metacharacters)) {
90 const string searchPath = subDir.substr(0, shiftPos);
91 const string pattern = subDir.substr(shiftPos + 1, subDir.length());
94 findAllSubdirectories(ibooker, igetter, searchPath, &subDirSet, pattern);
97 subDirSet.insert(subDir);
101 for (
auto const& subDir : subDirSet) {
102 for (
unsigned int iEff = 0; iEff != efficiency_.size(); ++iEff) {
103 string eff = efficiency_[iEff];
106 MonitorElement* refEff = igetter.
get(subDir +
"/" + refTriggers_ +
"/" + refEff_[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));
131 ibooker.
cd(subDir +
"/" + trig);
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));
141 ibooker.
cd(subDir +
"/" + trig);
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(
"")) {
160 TString pattern = _pattern;
161 TPRegexp nonPerlWildcard(
"\\w\\*|^\\*");
164 LogError(
"DQMGenericClient") <<
" DQMGenericClient::findAllSubdirectories ==> Missing folder " << dir <<
" !!!";
168 if (pattern.Contains(nonPerlWildcard))
169 pattern.ReplaceAll(
"*",
".*");
170 TPRegexp regexp(pattern);
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());
175 if (dirName.Contains(regexp))
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";
std::vector< std::string > efficiency_
T getUntrackedParameter(std::string const &, T const &) const
const edm::EventSetup & c
virtual DQM_DEPRECATED std::vector< std::string > getSubdirs() const
#define DEFINE_FWK_MODULE(type)
virtual bool dirExists(std::string const &path) const
Log< level::Error, false > LogError
HLTMuonRefMethod(const edm::ParameterSet &set)
std::vector< std::string > subDirs_
virtual MonitorElement * get(std::string const &fullpath) const
void dqmEndJob(DQMStore::IBooker &, DQMStore::IGetter &) override
void beginRun(const edm::Run &, const edm::EventSetup &) override
Log< level::Info, false > LogInfo
MonitorElement * book2D(TString const &name, TString const &title, int nchX, double lowX, double highX, int nchY, double lowY, double highY, FUNC onbooking=NOOP())
std::vector< std::string > refEff_
std::vector< std::string > hltTriggers_
std::string outputFileName_
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX, FUNC onbooking=NOOP())
std::vector< std::string > vstring
virtual TH1 * getTH1() const
void findAllSubdirectories(DQMStore::IBooker &ibooker, DQMStore::IGetter &igetter, const std::string &dir, std::set< std::string > *myList, const TString &pattern)