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 37 of file HLTMuonRefMethod.cc.

Constructor & Destructor Documentation

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

Definition at line 69 of file HLTMuonRefMethod.cc.

References edm::ParameterSet::getUntrackedParameter(), and HistogramManager_cfi::VPSet().

70 {
71  using VPSet = std::vector<edm::ParameterSet>;
72  using vstring = std::vector<std::string>;
73  using elsc = boost::escaped_list_separator<char>;
74 
75  subDirs_ = pset.getUntrackedParameter<vstring>("subDirs");
76  hltTriggers_ = pset.getUntrackedParameter<vstring>("hltTriggers");
77  refTriggers_ = pset.getUntrackedParameter<string> ("refTriggers");
78  efficiency_ = pset.getUntrackedParameter<vstring>("efficiency" );
79  refEff_ = pset.getUntrackedParameter<vstring>("refEff");
80 }
std::vector< std::string > efficiency_
vector< string > vstring
Definition: ExoticaDQM.cc:8
std::vector< std::string > subDirs_
std::string refTriggers_
std::vector< std::string > refEff_
std::vector< std::string > hltTriggers_
HLTMuonRefMethod::~HLTMuonRefMethod ( )
overridedefault

Member Function Documentation

void HLTMuonRefMethod::beginJob ( void  )
override

Definition at line 83 of file HLTMuonRefMethod.cc.

84 {
85 
86 }
void HLTMuonRefMethod::beginRun ( const edm::Run run,
const edm::EventSetup c 
)
override

Definition at line 176 of file HLTMuonRefMethod.cc.

177 {
178 
179 
180 }
void HLTMuonRefMethod::dqmEndJob ( DQMStore::IBooker ibooker,
DQMStore::IGetter igetter 
)
override

Definition at line 89 of file HLTMuonRefMethod.cc.

References stringResolutionProvider_cfi::bin, DQMStore::IBooker::book1D(), DQMStore::IBooker::book2D(), DQMStore::IBooker::cd(), DQMStore::IGetter::get(), mps_fire::i, metacharacters(), listBenchmarks::pattern, and muonValidation_cff::subDir.

90 {
91  using vstring = std::vector<std::string>;
92  boost::regex metacharacters{"[\\^\\$\\.\\*\\+\\?\\|\\(\\)\\{\\}\\[\\]]"};
93  boost::smatch what;
94 
95  // theDQM = 0;
96  // theDQM = Service<DQMStore>().operator->();
97 
98  ibooker.cd();
99  set<string> subDirSet;
100 
101  for(auto iSubDir = subDirs_.begin();
102  iSubDir != subDirs_.end(); ++iSubDir) {
103  string subDir = *iSubDir;
104 
105  if ( subDir[subDir.size()-1] == '/' ) subDir.erase(subDir.size()-1);
106 
107  if ( boost::regex_search(subDir, what, metacharacters)) {
108  const string::size_type shiftPos = subDir.rfind('/');
109  const string searchPath = subDir.substr(0, shiftPos);
110  const string pattern = subDir.substr(shiftPos + 1, subDir.length());
111  //std::cout << "\n\n\n\nLooking for all subdirs of " << subDir << std::endl;
112 
113  findAllSubdirectories (ibooker, igetter, searchPath, &subDirSet, pattern);
114 
115  }
116  else {
117  subDirSet.insert(subDir);
118  }
119  }
120 
121  for(auto const & subDir : subDirSet) {
122  for (unsigned int iEff = 0; iEff != efficiency_.size(); ++iEff){
123  string eff = efficiency_[iEff];
124 
125  // Getting reference trigger efficiency
126  MonitorElement* refEff = igetter.get(subDir + "/" + refTriggers_ + "/" + refEff_[iEff]);
127 
128  if (!refEff) continue;
129 
130 
131  // looping over all reference triggers
132  for (auto iTrigger = hltTriggers_.begin();
133  iTrigger != hltTriggers_.end(); ++iTrigger){
134  string trig = *iTrigger;
135  MonitorElement* trigEff = igetter.get(subDir + "/" + trig + "/" + eff );
136  if (!trigEff) continue;
137  TH1* hRef = refEff -> getTH1();
138  TH1* hTrig = trigEff -> getTH1();
139  TH1* hEff = (TH1*) hTrig->Clone( ("eff_" + eff + "_ref").c_str() );
140  hEff->SetTitle("Efficiency obtained with reference method");
141  TClass* myHistClass = hTrig->IsA();
142  TString histClassName = myHistClass->GetName();
143 
144  if (histClassName == "TH1F"){
145  for (int bin = 0; bin < hEff->GetNbinsX(); ++bin){
146  hEff->SetBinContent(bin+1, hEff->GetBinContent(bin+1)*hRef->GetBinContent(bin+1));
147  hEff->SetBinError (bin+1, hEff->GetBinContent(bin+1)*hRef->GetBinError(bin+1)+hEff->GetBinError(bin+1)*hRef->GetBinContent(bin+1));
148  }
149  ibooker.cd(subDir + "/" + trig);
150  ibooker.book1D( hEff->GetName(), (TH1F*) hEff);
151 
152  }
153  else if (histClassName == "TH2F"){
154  for (int i = 0; i < hRef->GetXaxis()->GetNbins(); ++i){
155  for (int j = 0; j < hRef->GetYaxis()->GetNbins(); ++j){
156  int bin = hEff->GetBin(i+1,j+1);
157  hEff -> SetBinContent( bin, hRef->GetBinContent(i+1,j+1) * hTrig->GetBinContent(i+1) );
158  }
159  }
160  ibooker.cd(subDir + "/" + trig);
161  ibooker.book2D( hEff->GetName(), (TH2F*) hEff);
162  }
163  else{
164  LogInfo ("HLTMuonRefMethod") << "Histo class type << " << histClassName << " not implemented";
165  }
166 
167  delete hEff;
168 
169  }
170  }
171  }
172 }
std::vector< std::string > efficiency_
vector< string > vstring
Definition: ExoticaDQM.cc:8
void cd(void)
Definition: DQMStore.cc:269
MonitorElement * get(const std::string &path)
Definition: DQMStore.cc:305
TPRegexp metacharacters("[\\^\\$\\.\\*\\+\\?\\|\\(\\)\\{\\}\\[\\]]")
uint16_t size_type
std::vector< std::string > subDirs_
MonitorElement * book1D(Args &&...args)
Definition: DQMStore.h:115
std::string refTriggers_
bin
set the eta bin as selection string.
MonitorElement * book2D(Args &&...args)
Definition: DQMStore.h:133
std::vector< std::string > refEff_
std::vector< std::string > hltTriggers_
void findAllSubdirectories(DQMStore::IBooker &ibooker, DQMStore::IGetter &igetter, const std::string &dir, std::set< std::string > *myList, const TString &pattern)
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 185 of file HLTMuonRefMethod.cc.

References DQMStore::IBooker::cd(), DEFINE_FWK_MODULE, DQMStore::IGetter::dirExists(), TrackerOfflineValidation_Dqm_cff::dirName, DQMStore::IGetter::getSubdirs(), nonPerlWildcard(), listBenchmarks::pattern, and fetchall_from_DQM_v2::regexp.

186  {
187  TString pattern = _pattern;
188  TPRegexp nonPerlWildcard("\\w\\*|^\\*");
189 
190  if (!igetter.dirExists(dir)) {
191  LogError("DQMGenericClient") << " DQMGenericClient::findAllSubdirectories ==> Missing folder " << dir << " !!!";
192  return;
193  }
194  if (pattern != "") {
195  if (pattern.Contains(nonPerlWildcard)) pattern.ReplaceAll("*",".*");
196  TPRegexp regexp(pattern);
197  ibooker.cd(dir);
198  vector <string> foundDirs = igetter.getSubdirs();
199  for(auto iDir = foundDirs.begin();
200  iDir != foundDirs.end(); ++iDir) {
201  TString dirName = iDir->substr(iDir->rfind('/') + 1, iDir->length());
202  if (dirName.Contains(regexp))
203  findAllSubdirectories (ibooker, igetter, *iDir, myList);
204  }
205  }
206  //std::cout << "Looking for directory " << dir ;
207  else if (igetter.dirExists(dir)){
208  //std::cout << "... it exists! Inserting it into the list ";
209  myList->insert(dir);
210  //std::cout << "... now list has size " << myList->size() << std::endl;
211  ibooker.cd(dir);
212  findAllSubdirectories (ibooker, igetter, dir, myList, "*");
213  } else {
214  //std::cout << "... DOES NOT EXIST!!! Skip bogus dir" << std::endl;
215 
216  LogInfo ("DQMGenericClient") << "Trying to find sub-directories of " << dir
217  << " failed because " << dir << " does not exist";
218 
219  }
220  return;
221 }
void cd(void)
Definition: DQMStore.cc:269
bool dirExists(const std::string &path)
Definition: DQMStore.cc:335
std::vector< std::string > getSubdirs(void)
Definition: DQMStore.cc:323
TPRegexp nonPerlWildcard("\\w\\*|^\\*")
dbl *** dir
Definition: mlp_gen.cc:35
void findAllSubdirectories(DQMStore::IBooker &ibooker, DQMStore::IGetter &igetter, const std::string &dir, std::set< std::string > *myList, const TString &pattern)

Member Data Documentation

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

Definition at line 53 of file HLTMuonRefMethod.cc.

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

Definition at line 52 of file HLTMuonRefMethod.cc.

std::string HLTMuonRefMethod::outputFileName_
private

Definition at line 57 of file HLTMuonRefMethod.cc.

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

Definition at line 54 of file HLTMuonRefMethod.cc.

std::string HLTMuonRefMethod::refTriggers_
private

Definition at line 55 of file HLTMuonRefMethod.cc.

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

Definition at line 51 of file HLTMuonRefMethod.cc.