CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
HLTMuonRefMethod Class Reference
Inheritance diagram for HLTMuonRefMethod:

Public Member Functions

void beginJob () override
 
void beginRun (const edm::Run &, const edm::EventSetup &) override
 
void dqmEndJob (DQMStore::IBooker &, DQMStore::IGetter &) override
 
 HLTMuonRefMethod (const edm::ParameterSet &set)
 
 ~HLTMuonRefMethod () override=default
 

Private Member Functions

void findAllSubdirectories (DQMStore::IBooker &ibooker, DQMStore::IGetter &igetter, const std::string &dir, std::set< std::string > *myList, const TString &pattern)
 

Private Attributes

std::vector< std::string > efficiency_
 
std::vector< std::string > hltTriggers_
 
std::string outputFileName_
 
std::vector< std::string > refEff_
 
std::string refTriggers_
 
std::vector< std::string > subDirs_
 

Detailed Description

Definition at line 29 of file HLTMuonRefMethod.cc.

Constructor & Destructor Documentation

◆ HLTMuonRefMethod()

HLTMuonRefMethod::HLTMuonRefMethod ( const edm::ParameterSet set)
explicit

Definition at line 57 of file HLTMuonRefMethod.cc.

References muonDTDigis_cfi::pset, and HistogramManager_cfi::VPSet().

57  {
58  using VPSet = std::vector<edm::ParameterSet>;
59  using vstring = std::vector<std::string>;
60  using elsc = boost::escaped_list_separator<char>;
61 
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");
67 }
std::vector< std::string > efficiency_
vector< string > vstring
Definition: ExoticaDQM.cc:7
std::vector< std::string > subDirs_
std::string refTriggers_
std::vector< std::string > refEff_
std::vector< std::string > hltTriggers_

◆ ~HLTMuonRefMethod()

HLTMuonRefMethod::~HLTMuonRefMethod ( )
overridedefault

Member Function Documentation

◆ beginJob()

void HLTMuonRefMethod::beginJob ( void  )
override

Definition at line 69 of file HLTMuonRefMethod.cc.

69 {}

◆ beginRun()

void HLTMuonRefMethod::beginRun ( const edm::Run run,
const edm::EventSetup c 
)
override

Definition at line 153 of file HLTMuonRefMethod.cc.

153 {}

◆ dqmEndJob()

void HLTMuonRefMethod::dqmEndJob ( DQMStore::IBooker ibooker,
DQMStore::IGetter igetter 
)
override

Definition at line 71 of file HLTMuonRefMethod.cc.

References newFWLiteAna::bin, dqm::implementation::IBooker::book1D(), dqm::implementation::IBooker::book2D(), dqm::implementation::NavigatorBase::cd(), dqm::implementation::IGetter::get(), dqm::legacy::MonitorElement::getTH1(), mps_fire::i, dqmiolumiharvest::j, topSingleLeptonDQM_PU_cfi::pattern, MuonPostProcessor_cff::refEff, PostProcessorHcalIsoTrack_cfi::subDir, and ClusterTask_cfi::trig.

71  {
72  using vstring = std::vector<std::string>;
73  boost::regex metacharacters{"[\\^\\$\\.\\*\\+\\?\\|\\(\\)\\{\\}\\[\\]]"};
74  boost::smatch what;
75 
76  // theDQM = 0;
77  // theDQM = Service<DQMStore>().operator->();
78 
79  ibooker.cd();
80  set<string> subDirSet;
81 
82  for (auto iSubDir = subDirs_.begin(); iSubDir != subDirs_.end(); ++iSubDir) {
83  string subDir = *iSubDir;
84 
85  if (subDir[subDir.size() - 1] == '/')
86  subDir.erase(subDir.size() - 1);
87 
88  if (boost::regex_search(subDir, what, metacharacters)) {
89  const string::size_type shiftPos = subDir.rfind('/');
90  const string searchPath = subDir.substr(0, shiftPos);
91  const string pattern = subDir.substr(shiftPos + 1, subDir.length());
92  //std::cout << "\n\n\n\nLooking for all subdirs of " << subDir << std::endl;
93 
94  findAllSubdirectories(ibooker, igetter, searchPath, &subDirSet, pattern);
95 
96  } else {
97  subDirSet.insert(subDir);
98  }
99  }
100 
101  for (auto const& subDir : subDirSet) {
102  for (unsigned int iEff = 0; iEff != efficiency_.size(); ++iEff) {
103  string eff = efficiency_[iEff];
104 
105  // Getting reference trigger efficiency
106  MonitorElement* refEff = igetter.get(subDir + "/" + refTriggers_ + "/" + refEff_[iEff]);
107 
108  if (!refEff)
109  continue;
110 
111  // looping over all reference triggers
112  for (auto iTrigger = hltTriggers_.begin(); iTrigger != hltTriggers_.end(); ++iTrigger) {
113  string trig = *iTrigger;
114  MonitorElement* trigEff = igetter.get(subDir + "/" + trig + "/" + eff);
115  if (!trigEff)
116  continue;
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();
123 
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));
130  }
131  ibooker.cd(subDir + "/" + trig);
132  ibooker.book1D(hEff->GetName(), (TH1F*)hEff);
133 
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));
139  }
140  }
141  ibooker.cd(subDir + "/" + trig);
142  ibooker.book2D(hEff->GetName(), (TH2F*)hEff);
143  } else {
144  LogInfo("HLTMuonRefMethod") << "Histo class type << " << histClassName << " not implemented";
145  }
146 
147  delete hEff;
148  }
149  }
150  }
151 }
std::vector< std::string > efficiency_
vector< string > vstring
Definition: ExoticaDQM.cc:7
uint16_t size_type
std::vector< std::string > subDirs_
std::string refTriggers_
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())
Definition: DQMStore.h:212
virtual MonitorElement * get(std::string const &fullpath) const
Definition: DQMStore.cc:697
std::vector< std::string > refEff_
virtual TH1 * getTH1() const
std::vector< std::string > hltTriggers_
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX, FUNC onbooking=NOOP())
Definition: DQMStore.h:98
void findAllSubdirectories(DQMStore::IBooker &ibooker, DQMStore::IGetter &igetter, const std::string &dir, std::set< std::string > *myList, const TString &pattern)

◆ findAllSubdirectories()

void HLTMuonRefMethod::findAllSubdirectories ( DQMStore::IBooker ibooker,
DQMStore::IGetter igetter,
const std::string &  dir,
std::set< std::string > *  myList,
const TString &  pattern = TString("") 
)
private

Definition at line 155 of file HLTMuonRefMethod.cc.

References dqm::implementation::NavigatorBase::cd(), DeadROC_duringRun::dir, dqm::implementation::IGetter::dirExists(), TrackerOfflineValidation_Dqm_cff::dirName, dqm::implementation::IGetter::getSubdirs(), PatBasicFWLiteJetAnalyzer_Selector_cfg::myList, topSingleLeptonDQM_PU_cfi::pattern, and fetchall_from_DQM_v2::regexp.

159  {
160  TString pattern = _pattern;
161  TPRegexp nonPerlWildcard("\\w\\*|^\\*");
162 
163  if (!igetter.dirExists(dir)) {
164  LogError("DQMGenericClient") << " DQMGenericClient::findAllSubdirectories ==> Missing folder " << dir << " !!!";
165  return;
166  }
167  if (pattern != "") {
168  if (pattern.Contains(nonPerlWildcard))
169  pattern.ReplaceAll("*", ".*");
170  TPRegexp regexp(pattern);
171  ibooker.cd(dir);
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);
177  }
178  }
179  //std::cout << "Looking for directory " << dir ;
180  else if (igetter.dirExists(dir)) {
181  //std::cout << "... it exists! Inserting it into the list ";
182  myList->insert(dir);
183  //std::cout << "... now list has size " << myList->size() << std::endl;
184  ibooker.cd(dir);
185  findAllSubdirectories(ibooker, igetter, dir, myList, "*");
186  } else {
187  //std::cout << "... DOES NOT EXIST!!! Skip bogus dir" << std::endl;
188 
189  LogInfo("DQMGenericClient") << "Trying to find sub-directories of " << dir << " failed because " << dir
190  << " does not exist";
191  }
192  return;
193 }
virtual bool dirExists(std::string const &path) const
Definition: DQMStore.cc:754
Log< level::Error, false > LogError
Log< level::Info, false > LogInfo
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
Definition: DQMStore.cc:724

Member Data Documentation

◆ efficiency_

std::vector<std::string> HLTMuonRefMethod::efficiency_
private

Definition at line 44 of file HLTMuonRefMethod.cc.

◆ hltTriggers_

std::vector<std::string> HLTMuonRefMethod::hltTriggers_
private

Definition at line 43 of file HLTMuonRefMethod.cc.

◆ outputFileName_

std::string HLTMuonRefMethod::outputFileName_
private

Definition at line 48 of file HLTMuonRefMethod.cc.

◆ refEff_

std::vector<std::string> HLTMuonRefMethod::refEff_
private

Definition at line 45 of file HLTMuonRefMethod.cc.

◆ refTriggers_

std::string HLTMuonRefMethod::refTriggers_
private

Definition at line 46 of file HLTMuonRefMethod.cc.

◆ subDirs_

std::vector<std::string> HLTMuonRefMethod::subDirs_
private

Definition at line 42 of file HLTMuonRefMethod.cc.