CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
EgHLTOfflineSummaryClient.cc
Go to the documentation of this file.
2 
3 
8 
10 
13 
16 #include <boost/algorithm/string.hpp>
17 
19  egHLTSumHistName_("egHLTTrigSum"),isSetup_(false)
20 {
21  dirName_=iConfig.getParameter<std::string>("DQMDirName"); //only one chance to get this, if we every have another shot, remember to check isSetup is okay
23  if (!dbe_) {
24  edm::LogError("EgHLTOfflineSummaryClient") << "unable to get DQMStore service, no summary histograms will be produced";
25  }else{
26  if(iConfig.getUntrackedParameter<bool>("DQMStore", false)) {
27  dbe_->setVerbose(0);
28  }
29  dbe_->setCurrentFolder(dirName_);
30  }
31 
32  eleHLTFilterNames_ = iConfig.getParameter<std::vector<std::string> >("eleHLTFilterNames");
33  phoHLTFilterNames_ = iConfig.getParameter<std::vector<std::string> >("phoHLTFilterNames");
34  eleHLTFilterNamesForSumBit_ = iConfig.getParameter<std::vector<std::string> >("eleHLTFilterNamesForSumBit");
35  phoHLTFilterNamesForSumBit_ = iConfig.getParameter<std::vector<std::string> >("phoHLTFilterNamesForSumBit");
36 
37 
38  filterInactiveTriggers_ =iConfig.getParameter<bool>("filterInactiveTriggers");
39  hltTag_ = iConfig.getParameter<std::string>("hltTag");
40 
41  usePathNames_ = iConfig.getParameter<bool>("usePathNames");
42 
43 
44  //std::vector<std::string> egHLTSumQTests = iConfig.getParameter<std::vector<std::string> >("egHLTSumQTests");
45  // splitStringsToPairs_(egHLTSumQTests,egHLTSumHistXBins_);
46 
47  fillQTestData_(iConfig,egHLTSumHistXBins_,"egHLTSumQTests");
48  fillQTestData_(iConfig,eleQTestsForSumBit_,"egHLTEleQTestsForSumBit");
49  fillQTestData_(iConfig,phoQTestsForSumBit_,"egHLTPhoQTestsForSumBit");
50 
51 
52 
53  runClientEndLumiBlock_ = iConfig.getParameter<bool>("runClientEndLumiBlock");
54  runClientEndRun_ = iConfig.getParameter<bool>("runClientEndRun");
55  runClientEndJob_ = iConfig.getParameter<bool>("runClientEndJob");
56 
57 
58  //egHLTSumHistXBins_.push_back(std::make_pair("Ele Rel Trig Eff",&EgHLTOfflineSummaryClient::eleTrigRelEffQTestResult_));
59  //egHLTSumHistXBins_.push_back(std::make_pair("Pho Rel Trig Eff",&EgHLTOfflineSummaryClient::phoTrigRelEffQTestResult_));
60  //egHLTSumHistXBins_.push_back(std::make_pair("Ele T&P Trig Eff",&EgHLTOfflineSummaryClient::eleTrigTPEffQTestResult_));
61  //egHLTSumHistXBins_.push_back(std::make_pair("Triggered Ele",&EgHLTOfflineSummaryClient::trigEleQTestResult_));
62  //egHLTSumHistXBins_.push_back(std::make_pair("Triggered Pho",&EgHLTOfflineSummaryClient::trigPhoQTestResult_));
63 }
64 
65 
67 {
68 
69 }
70 
72 {
73 
74 
75 }
76 
78 {
80 }
81 
83 {
84  if(!isSetup_){
85  bool changed;
87  hltConfig.init(run,c,hltTag_,changed);
89  std::vector<std::string> activeFilters;
90  std::vector<std::string> activeEleFilters;
91  std::vector<std::string> activeEle2LegFilters;
92  std::vector<std::string> activePhoFilters;
93  std::vector<std::string> activePho2LegFilters;
94 
95  egHLT::trigTools::getActiveFilters(hltConfig,activeFilters,activeEleFilters,activeEle2LegFilters,activePhoFilters,activePho2LegFilters);
96 
101 
102  }
104 
106  isSetup_=true;
107  }
108 }
109 
110 
112 {
114 }
115 
116 //dummy analysis function
118 {
119 
120 }
121 
123 {
124 
126 }
127 
129 {
130 
131  MonitorElement* egHLTSumME = getEgHLTSumHist_();
132 
133  for(size_t filterNr=0;filterNr<egHLTFiltersToMon_.size();filterNr++){
134  for(size_t xBinNr=0;xBinNr<egHLTSumHistXBins_.size();xBinNr++){
135  //egHLTSumHist->setBinContent(xBinNr+1,filterNr+1,(*egHLTSumHistXBins_[xBinNr].second)(egHLTFiltersToMon_[filterNr].c_str()));
136  egHLTSumME->setBinContent(xBinNr+1,filterNr+1,
137  getQTestResults_(egHLTFiltersToMon_[filterNr],egHLTSumHistXBins_[xBinNr].qTestPatterns));
138  }
139  }
140 
141  MonitorElement* hltEleSumBit = dbe_->get("HLT/EventInfo/reportSummaryContents/HLT_Electron");
142  MonitorElement* hltPhoSumBit = dbe_->get("HLT/EventInfo/reportSummaryContents/HLT_Photon");
143  dbe_->setCurrentFolder("HLT/EventInfo/reportSummaryContents/");
144  if(hltEleSumBit==NULL) hltEleSumBit = dbe_->bookFloat("HLT_Electron");
145  if(hltPhoSumBit==NULL) hltPhoSumBit = dbe_->bookFloat("HLT_Photon");
146 
147 
148  float eleSumBit=1.;
149  for(size_t filterNr=0;filterNr<eleHLTFilterNamesForSumBit_.size() && eleSumBit==1;filterNr++){ //breaks as soon as a test fails
150  for(size_t testNr=0;testNr<eleQTestsForSumBit_.size() && eleSumBit==1;testNr++){
151  if(getQTestResults_(eleHLTFilterNamesForSumBit_[filterNr],eleQTestsForSumBit_[testNr].qTestPatterns)==0) eleSumBit=0;
152 
153  }
154  }
155  hltEleSumBit->Fill(eleSumBit);
156 
157  float phoSumBit=1.;
158  for(size_t filterNr=0;filterNr<phoHLTFilterNamesForSumBit_.size() && phoSumBit==1;filterNr++){ //breaks as soon as a test fails
159  for(size_t testNr=0;testNr<phoQTestsForSumBit_.size() && phoSumBit==1;testNr++){
160  if(getQTestResults_(phoHLTFilterNamesForSumBit_[filterNr],phoQTestsForSumBit_[testNr].qTestPatterns)==0) phoSumBit=0;
161  }
162  }
163  hltPhoSumBit->Fill(phoSumBit);
164 
165 
166 
167 }
168 void EgHLTOfflineSummaryClient::splitStringsToPairs_(const std::vector<std::string>& stringsToSplit,std::vector<std::pair<std::string,std::string> >& splitStrings)
169 {
170  splitStrings.clear();
171  splitStrings.reserve(stringsToSplit.size());
172  for(size_t stringNr=0;stringNr<stringsToSplit.size();stringNr++){
173  std::vector<std::string> tempSplitStrings;
174  boost::split(tempSplitStrings,stringsToSplit[stringNr],boost::is_any_of(std::string(":")));
175  if(tempSplitStrings.size()==2){
176  splitStrings.push_back(std::make_pair(tempSplitStrings[0],tempSplitStrings[1]));
177  }else{
178  edm::LogWarning("EgHLTOfflineSummaryClient") <<" Error : entry "<<stringsToSplit[stringNr]<<" is not of form A:B, ignoring (ie this quailty test isnt being included in the sumamry hist) ";
179  }
180  }
181 }
182 
183 
184 
186 {
187  MonitorElement* egHLTSumHist = dbe_->get(dirName_+"/"+egHLTSumHistName_);
188  if(egHLTSumHist==NULL){
189  TH2F* hist = new TH2F(egHLTSumHistName_.c_str(),"E/g HLT Offline Summary",egHLTSumHistXBins_.size(),0.,1.,egHLTFiltersToMon_.size(),0.,1.);
190  for(size_t xBinNr=0;xBinNr<egHLTSumHistXBins_.size();xBinNr++){
191  hist->GetXaxis()->SetBinLabel(xBinNr+1,egHLTSumHistXBins_[xBinNr].name.c_str());
192  }
193 
194  for(size_t yBinNr=0;yBinNr<egHLTFiltersToMon_.size();yBinNr++){
196  hist->GetYaxis()->SetBinLabel(yBinNr+1,egHLTFiltersToMonPaths_[yBinNr].c_str());
197  }else{
198  hist->GetYaxis()->SetBinLabel(yBinNr+1,egHLTFiltersToMon_[yBinNr].c_str());
199  }
200  }
201  for(size_t xBinNr=0;xBinNr<egHLTSumHistXBins_.size();xBinNr++){
202  for(size_t yBinNr=0;yBinNr<egHLTFiltersToMon_.size();yBinNr++){
203  hist->SetBinContent(xBinNr+1,yBinNr+1,-2);
204  }
205  }
206 
208  egHLTSumHist = dbe_->book2D(egHLTSumHistName_,hist);
209  }
210  return egHLTSumHist;
211 
212 }
213 
214 //this function puts every e/g trigger monitored in a std::vector
215 //this is *very* similar to EgHLTOfflineSource::getHLTFilterNamesUsed but
216 //it differs in the fact it only gets the E/g primary triggers not the backups
217 //due to the design, to ensure we get every filter, filters will be inserted multiple times
218 //eg electron filters will contain photon triggers which are also in the photon filters
219 //but only want one copy in the vector
220 //this function is intended to be called once per job so some inefficiency can can be tolerated
221 //therefore we will use a std::set to ensure ensure that each filtername is only inserted once
222 //and then convert to a std::vector
223 void EgHLTOfflineSummaryClient::getEgHLTFiltersToMon_(std::vector<std::string>& filterNames)const
224 {
225  std::set<std::string> filterNameSet;
226  for(size_t i=0;i<eleHLTFilterNames_.size();i++) filterNameSet.insert(eleHLTFilterNames_[i]);
227  for(size_t i=0;i<phoHLTFilterNames_.size();i++) filterNameSet.insert(phoHLTFilterNames_[i]);
228 
229  //right all the triggers are inserted once and only once in the set, convert to vector
230  //very lazy, create a new vector so can use the constructor and then use swap to transfer
231  std::vector<std::string>(filterNameSet.begin(),filterNameSet.end()).swap(filterNames);
232 }
233 
234 //only returns 0 or 1, 0 is bad, one is good and if the test is not found defaults to good
235 //(this is because its a dumb algorithm, photon tests are run for electron triggers which unsurprisingly are not found)
236 int EgHLTOfflineSummaryClient::getQTestResults_(const std::string& filterName,const std::vector<std::string>& patterns)const
237 {
238  int nrFail =0;
239  int nrQTests=0;
240  for(size_t patternNr=0;patternNr<patterns.size();patternNr++){
241  std::vector<MonitorElement*> monElems = dbe_->getMatchingContents(dirName_+"/"+filterName+patterns[patternNr]);
242  // std::cout <<"mon elem "<<dirName_+"/"+filterName+patterns[patternNr]<<"nr monElems "<<monElems.size()<<std::endl;
243  for(size_t monElemNr=0;monElemNr<monElems.size();monElemNr++){
244 
245  std::vector<QReport*> qTests = monElems[monElemNr]->getQReports();
246  nrQTests+=qTests.size();
247  // std::cout <<monElems[monElemNr]->getName()<<" "<<monElems[monElemNr]->hasError()<<" nr test "<<qTests.size()<<std::endl;
248  if(monElems[monElemNr]->hasError()) nrFail++;
249  }
250  }
251  if(nrQTests==0) return -1;
252  else if(nrFail==0) return 1;
253  else return 0;
254 }
255 
256 
257 void EgHLTOfflineSummaryClient::fillQTestData_(const edm::ParameterSet& iConfig,std::vector<SumHistBinData>& qTests,const std::string& label)
258 {
259  std::vector<edm::ParameterSet> qTestPara = iConfig.getParameter<std::vector<edm::ParameterSet> >(label);
260  qTests.resize(qTestPara.size());
261  for(size_t testNr=0;testNr<qTestPara.size();testNr++){
262  qTests[testNr].name = qTestPara[testNr].getParameter<std::string>("name");
263  qTests[testNr].qTestPatterns = qTestPara[testNr].getParameter<std::vector<std::string> >("qTestsToCheck");
264  }
265 }
266 
267 
268 // int EgHLTOfflineSummaryClient::eleTrigRelEffQTestResult_(const std::string& filterName)const
269 // {
270 
271 
272 // }
273 
274 // int EgHLTOfflineSummaryClient::phoTrigRelEffQTestResult_(const std::string& filterName)const
275 // {
276 
277 // }
278 
279 // int EgHLTOfflineSummaryClient::eleTrigTPEffQTestResult_(const std::string& filterName)const
280 // {
281 
282 // }
283 
284 // int EgHLTOfflineSummaryClient::trigEleQTestResult_(const std::string& filterName)const
285 // {
286 
287 // }
288 
289 // int EgHLTOfflineSummaryClient::trigPhoQTestResult_(const std::string& filterName)const
290 // {
291 
292 // }
void swap(ora::Record &rh, ora::Record &lh)
Definition: Record.h:70
T getParameter(std::string const &) const
std::vector< std::string > phoHLTFilterNamesForSumBit_
T getUntrackedParameter(std::string const &, T const &) const
int i
Definition: DBlmapReader.cc:9
void setBinContent(int binx, double content)
set content of bin (1-D)
virtual void analyze(const edm::Event &, const edm::EventSetup &)
void splitStringsToPairs_(const std::vector< std::string > &stringsToSplit, std::vector< std::pair< std::string, std::string > > &splitStrings)
std::vector< std::string > egHLTFiltersToMonPaths_
void getEgHLTFiltersToMon_(std::vector< std::string > &filterNames) const
std::vector< std::string > eleHLTFilterNamesForSumBit_
std::vector< MonitorElement * > getMatchingContents(const std::string &pattern, lat::Regexp::Syntax syntaxType=lat::Regexp::Wildcard) const
Definition: DQMStore.cc:1980
std::vector< SumHistBinData > egHLTSumHistXBins_
std::vector< std::string > eleHLTFilterNames_
std::vector< SumHistBinData > eleQTestsForSumBit_
#define NULL
Definition: scimark2.h:8
std::vector< std::string > egHLTFiltersToMon_
MonitorElement * bookFloat(const char *name)
Book float.
Definition: DQMStore.cc:912
virtual void beginRun(const edm::Run &run, const edm::EventSetup &c)
void Fill(long long x)
int iEvent
Definition: GenABIO.cc:230
virtual void endLuminosityBlock(const edm::LuminosityBlock &lumiSeg, const edm::EventSetup &c)
MonitorElement * get(const std::string &path) const
get ME from full pathname (e.g. &quot;my/long/dir/my_histo&quot;)
Definition: DQMStore.cc:1729
std::vector< SumHistBinData > phoQTestsForSumBit_
void getActiveFilters(const HLTConfigProvider &hltConfig, std::vector< std::string > &activeFilters, std::vector< std::string > &activeEleFilters, std::vector< std::string > &activeEle2LegFilters, std::vector< std::string > &activePhoFilters, std::vector< std::string > &activePho2LegFilters)
bool init(const edm::Run &iRun, const edm::EventSetup &iSetup, const std::string &processName, bool &changed)
d&#39;tor
virtual void endRun(const edm::Run &run, const edm::EventSetup &c)
std::vector< std::string > phoHLTFilterNames_
int getQTestResults_(const std::string &filterName, const std::vector< std::string > &pattern) const
void filterInactiveTriggers(std::vector< std::string > &namesToFilter, std::vector< std::string > &activeFilters)
EgHLTOfflineSummaryClient(const EgHLTOfflineSummaryClient &rhs)
volatile std::atomic< bool > shutdown_flag false
MonitorElement * book2D(const char *name, const char *title, int nchX, double lowX, double highX, int nchY, double lowY, double highY)
Book 2D histogram.
Definition: DQMStore.cc:1103
double split
Definition: MVATrainer.cc:139
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:688
void translateFiltersToPathNames(const HLTConfigProvider &hltConfig, const std::vector< std::string > &filters, std::vector< std::string > &paths)
Definition: Run.h:41
static void fillQTestData_(const edm::ParameterSet &iConfig, std::vector< SumHistBinData > &qTests, const std::string &label)