20 #include <boost/tokenizer.hpp> 21 #include <boost/regex.hpp> 24 #include <TEfficiency.h> 37 void dqmEndJob(DQMStore::IBooker&, DQMStore::IGetter&)
override;
50 void findAllSubdirectories(DQMStore::IBooker& ibooker,
51 DQMStore::IGetter& igetter,
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>;
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) {
85 if (subDir[subDir.size() - 1] ==
'/')
86 subDir.erase(subDir.size() - 1);
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];
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";
156 DQMStore::IGetter& igetter,
158 std::set<std::string>*
myList,
159 const TString& _pattern = TString(
"")) {
163 if (!igetter.dirExists(dir)) {
164 LogError(
"DQMGenericClient") <<
" DQMGenericClient::findAllSubdirectories ==> Missing folder " << dir <<
" !!!";
168 if (pattern.Contains(nonPerlWildcard))
169 pattern.ReplaceAll(
"*",
".*");
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);
180 else if (igetter.dirExists(dir)) {
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
TPRegexp metacharacters("[\\^\\$\\.\\*\\+\\?\\|\\(\\)\\{\\}\\[\\]]")
#define DEFINE_FWK_MODULE(type)
HLTMuonRefMethod(const edm::ParameterSet &set)
std::vector< std::string > subDirs_
void dqmEndJob(DQMStore::IBooker &, DQMStore::IGetter &) override
void beginRun(const edm::Run &, const edm::EventSetup &) override
std::vector< std::string > refEff_
std::vector< std::string > hltTriggers_
TPRegexp nonPerlWildcard("\\w\\*|^\\*")
std::string outputFileName_
virtual TH1 * getTH1() const
void findAllSubdirectories(DQMStore::IBooker &ibooker, DQMStore::IGetter &igetter, const std::string &dir, std::set< std::string > *myList, const TString &pattern)