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";
std::vector< std::string > efficiency_
#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_
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())
virtual MonitorElement * get(std::string const &fullpath) const
std::vector< std::string > refEff_
virtual TH1 * getTH1() const
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())
void findAllSubdirectories(DQMStore::IBooker &ibooker, DQMStore::IGetter &igetter, const std::string &dir, std::set< std::string > *myList, const TString &pattern)
virtual DQM_DEPRECATED std::vector< std::string > getSubdirs() const