CMS 3D CMS Logo

EgHLTOfflineClient.cc
Go to the documentation of this file.
2 
3 
8 
10 
13 
15 
17 
18 #include <boost/algorithm/string.hpp>
19 
20 #include "TGraphAsymmErrors.h"
21 
23 {
24 
25  eleHLTFilterNames_ = iConfig.getParameter<std::vector<std::string> >("eleHLTFilterNames");
26  eleHLTFilterNames2Leg_ = iConfig.getParameter<std::vector<std::string> >("eleHLTFilterNames2Leg");
27  eleTightLooseTrigNames_ = iConfig.getParameter<std::vector<std::string> >("eleTightLooseTrigNames");
28  phoHLTFilterNames_ = iConfig.getParameter<std::vector<std::string> >("phoHLTFilterNames");
29  phoHLTFilterNames2Leg_ = iConfig.getParameter<std::vector<std::string> >("phoHLTFilterNames2Leg");
30  phoTightLooseTrigNames_ = iConfig.getParameter<std::vector<std::string> >("phoTightLooseTrigNames");
31 
32  eleN1EffVars_ = iConfig.getParameter<std::vector<std::string> >("eleN1EffVars");
33  eleSingleEffVars_ = iConfig.getParameter<std::vector<std::string> >("eleSingleEffVars");
34  eleEffTags_ = iConfig.getParameter<std::vector<std::string> >("eleEffTags");
35  eleTrigTPEffVsVars_ = iConfig.getParameter<std::vector<std::string> >("eleTrigTPEffVsVars");
36  eleLooseTightTrigEffVsVars_ = iConfig.getParameter<std::vector<std::string> >("eleLooseTightTrigEffVsVars");
37  eleHLTvOfflineVars_ = iConfig.getParameter<std::vector<std::string> >("eleHLTvOfflineVars");
38 
39  phoN1EffVars_ = iConfig.getParameter<std::vector<std::string> >("phoN1EffVars");
40  phoSingleEffVars_ = iConfig.getParameter<std::vector<std::string> >("phoSingleEffVars");
41  phoEffTags_ = iConfig.getParameter<std::vector<std::string> >("phoEffTags");
42  phoTrigTPEffVsVars_ = iConfig.getParameter<std::vector<std::string> >("phoTrigTPEffVsVars");
43  phoLooseTightTrigEffVsVars_ = iConfig.getParameter<std::vector<std::string> >("phoLooseTightTrigEffVsVars");
44  phoHLTvOfflineVars_ = iConfig.getParameter<std::vector<std::string> >("phoHLTvOfflineVars");
45 
46  runClientEndLumiBlock_ = iConfig.getParameter<bool>("runClientEndLumiBlock");
47  runClientEndRun_ = iConfig.getParameter<bool>("runClientEndRun");
48  runClientEndJob_ = iConfig.getParameter<bool>("runClientEndJob");
49 
50  dirName_ = iConfig.getParameter<std::string>("DQMDirName");
51 
52  filterInactiveTriggers_ =iConfig.getParameter<bool>("filterInactiveTriggers");
53  hltTag_ = iConfig.getParameter<std::string>("hltTag");
54 
55 
56 }
57 
58 
60 
61 
63 
64  if (runClientEndJob_) runClient_(ibooker_, igetter_);
65 }
66 
68 {
69  if (!isSetup_) {
71  HLTConfigProvider hltConfig;
72  bool changed = false;
73  hltConfig.init(run, c, hltTag_, changed);
74  std::vector<std::string> activeFilters;
75  std::vector<std::string> activeEleFilters;
76  std::vector<std::string> activeEle2LegFilters;
77  std::vector<std::string> activePhoFilters;
78  std::vector<std::string> activePho2LegFilters;
79  egHLT::trigTools::getActiveFilters(hltConfig, activeFilters, activeEleFilters,
80  activeEle2LegFilters, activePhoFilters, activePho2LegFilters);
81 
87  }
88  isSetup_ = true;
89  }
90 }
91 
93  DQMStore::IGetter & igetter_, edm::LuminosityBlock const & iLumi,
94  edm::EventSetup const& iSetup) {
95 
96  if (runClientEndLumiBlock_) runClient_(ibooker_, igetter_);
97 }
98 
100 {
101 
102  ibooker.setCurrentFolder(dirName_ + "/Client_Histos");
103 
104 
105  std::vector<std::string> regions;
106  regions.emplace_back("eb");
107  regions.emplace_back("ee");
108 
109  for (auto const & eleHLTFilterName : eleHLTFilterNames_) {
110  //std::cout<<"FilterName: "<<eleHLTFilterNames_[filterNr]<<std::endl;
111  for (auto const & region : regions) {
112  for (auto const & eleEffTag : eleEffTags_) {
113  //----Morse----
114  ibooker.setCurrentFolder(dirName_+"/Client_Histos/"+eleHLTFilterName);
115  //--------------
116  createN1EffHists(eleHLTFilterName,
117  eleHLTFilterName + "_gsfEle_" + eleEffTag, region,
118  eleN1EffVars_, ibooker, igetter);
119 
120  createSingleEffHists(eleHLTFilterName,
121  eleHLTFilterName + "_gsfEle_" + eleEffTag, region,
122  eleSingleEffVars_, ibooker, igetter);
123 
124  createTrigTagProbeEffHistsNewAlgo(eleHLTFilterName, region,
125  eleTrigTPEffVsVars_, "gsfEle", ibooker, igetter);
126 
127  createHLTvsOfflineHists(eleHLTFilterName,
128  eleHLTFilterName + "_gsfEle_passFilter", region,
129  eleHLTvOfflineVars_, ibooker, igetter);
130 
131  }
132  }
133  }
134  for (auto & filterNr : eleHLTFilterNames2Leg_) {
135  for (auto const & region : regions) {
136  for (size_t effNr = 0; effNr < eleEffTags_.size(); effNr++) {
137  std::string trigNameLeg1 = filterNr.substr(
138  0, filterNr.find("::"));
139 
140  std::string trigNameLeg2 = filterNr.substr(
141  filterNr.find("::") + 2);
142 
143  ibooker.setCurrentFolder(dirName_+"/Client_Histos/"+trigNameLeg2);
144  createTrigTagProbeEffHists2Leg(trigNameLeg1, trigNameLeg2, region,
145  eleTrigTPEffVsVars_, "gsfEle", ibooker, igetter);
146  }
147  }
148  }
149 
150  for (auto const & phoHLTFilterName : phoHLTFilterNames_) {
151  for (auto const & region : regions) {
152  for (auto const & phoEffTag : phoEffTags_) {
153  //----Morse----
154  ibooker.setCurrentFolder(dirName_+"/Client_Histos/"+phoHLTFilterName);
155  createN1EffHists(phoHLTFilterName,
156  phoHLTFilterName + "_pho_" + phoEffTag, region,
157  phoN1EffVars_, ibooker, igetter);
158 
159  createSingleEffHists(phoHLTFilterName,
160  phoHLTFilterName + "_pho_" + phoEffTag, region,
161  phoSingleEffVars_, ibooker, igetter);
162 
163  createTrigTagProbeEffHistsNewAlgo(phoHLTFilterName, region,
164  phoTrigTPEffVsVars_, "pho", ibooker, igetter);
165 
166  createHLTvsOfflineHists(phoHLTFilterName,
167  phoHLTFilterName + "_pho_passFilter", region,
168  phoHLTvOfflineVars_, ibooker, igetter);
169 
170  //--------------
171  }
172  }
173  }
174 
175  for (auto const & region : regions) {
177  eleLooseTightTrigEffVsVars_, "gsfEle", ibooker, igetter);
178 
180  eleLooseTightTrigEffVsVars_, "gsfEle_trigCuts", ibooker, igetter);
181 
183  phoLooseTightTrigEffVsVars_, "pho", ibooker, igetter);
184 
186  phoLooseTightTrigEffVsVars_, "pho_trigCuts", ibooker, igetter);
187 
188  }
189  //----Morse-----
190  ibooker.setCurrentFolder(dirName_);
191  //----------
192 }
193 
195  const std::string& baseName, const std::string& region,
196  const std::vector<std::string>& varNames, DQMStore::IBooker& ibooker,
197  DQMStore::IGetter& igetter){
198 
199  //need to do Energy manually to get SC Energy
200  /*
201  MonitorElement* numer = dbe_->get(dirName_+"/Source_Histos/"+filterName+"/"+baseName+"_HLTenergy"+"_"+region);
202  MonitorElement* denom = dbe_->get(dirName_+"/Source_Histos/"+filterName+"/"+baseName+"_energy"+"_"+region);
203 
204  if(numer!=NULL && denom!=NULL){
205  std::string effHistName(baseName+"_HLToverOfflineSC_energy_"+region);//std::cout<<"hltVSoffline: "<<effHistName<<std::endl;
206  std::string effHistTitle(effHistName);
207  if(region=="eb" || region=="ee"){
208  if(region=="eb") effHistTitle = "Barrel "+baseName+" HLToverOfflineSC Energy";
209  if(region=="ee") effHistTitle = "Endcap "+baseName+" HLToverOfflineSC Energy";
210  FillHLTvsOfflineHist(filterName,effHistName,effHistTitle,numer,denom);
211  }
212  }//end Et
213  */
214 
215  //now eta, phi automatically
216  for (auto const & varName : varNames) {
217  MonitorElement* numer = igetter.get(dirName_+"/Source_Histos/"+filterName+"/"+baseName+"_HLT"+varName+"_"+region);
218  MonitorElement* denom = igetter.get(dirName_+"/Source_Histos/"+filterName+"/"+baseName+"_"+varName+"_"+region);
219  if (numer != nullptr && denom != nullptr) {
220  std::string effHistName(baseName + "_HLToverOffline_" + varName + "_" + region);//std::cout<<"hltVSoffline: "<<effHistName<<std::endl;
221  std::string effHistTitle(effHistName);
222  if (region == "eb" || region == "ee") {
223  if (region == "eb") effHistTitle = "Barrel " + baseName + " HLToverOffline " + varName;
224  if (region == "ee") effHistTitle = "Endcap " + baseName + " HLToverOffline " + varName;
225  FillHLTvsOfflineHist(filterName, effHistName, effHistTitle, numer, denom, ibooker, igetter);
226  }
227  }
228  }//end loop over varNames
229 }
230 
232  const std::string& name, const std::string& title, const MonitorElement* numer,
233  const MonitorElement* denom, DQMStore::IBooker& ibooker, DQMStore::IGetter& igetter) {
234 
235  TH1F* num = numer->getTH1F();
236  if (num->GetSumw2N() == 0) num->Sumw2();
237 
238  TH1F* den = denom->getTH1F();
239  if (den->GetSumw2N() == 0) den->Sumw2();
240 
241  auto* h_eff = (TH1F*)num->Clone(name.c_str());
242  h_eff->Divide(num, den, 1, 1, "B");
243  h_eff->SetTitle(title.c_str());
244  MonitorElement* eff = igetter.get(dirName_ + "/Client_Histos/" + filter + "/" + name);
245  if (eff == nullptr) {
246  eff = ibooker.book1D(name, h_eff);
247  } else { //I was having problems with collating the histograms, hence why I'm just resetting the histogram value
248  *eff->getTH1F() = *h_eff;
249  delete h_eff;
250  }
251  return eff;
252 }
253 
255  const std::string& baseName, const std::string& region,
256  const std::vector<std::string>& varNames, DQMStore::IBooker& ibooker,
257  DQMStore::IGetter& igetter) {
258 
259  MonitorElement* numer = igetter.get(dirName_+"/Source_Histos/"+filterName+"/"+baseName+"_allCuts_"+region);
260 
261  for (auto const & varName : varNames) {
262  MonitorElement* denom = igetter.get(dirName_+"/Source_Histos/"+filterName+"/"+baseName+"_n1_"+varName+"_"+region);
263  if (numer != nullptr && denom != nullptr) {
264  std::string effHistName(baseName+"_n1Eff_"+varName+"_"+region);//std::cout<<"N1: "<<effHistName<<std::endl;
265  //std::cout<<region<<" ";
266  //----Morse-----------
267  std::string effHistTitle(effHistName);//std::cout<<effHistTitle<<std::endl;
268  if ( region == "eb" || region == "ee"){
269  if (region == "eb") effHistTitle = "Barrel "+baseName+" N1eff "+varName;
270  if (region == "ee") effHistTitle = "Endcap "+baseName+" N1eff "+varName;
271  }//std::cout<<effHistTitle<<std::endl;
272  makeEffMonElemFromPassAndAll(filterName, effHistName, effHistTitle, numer, denom, ibooker,
273  igetter);
274  //---------------------
275  }
276  }//end loop over varNames
277 }
278 
280  const std::string& baseName, const std::string& region,
281  const std::vector<std::string>& varNames, DQMStore::IBooker& ibooker,
282  DQMStore::IGetter& igetter) {
283 
284  MonitorElement* denom = igetter.get(dirName_+"/Source_Histos/"+filterName+"/"+baseName+"_noCuts_"+region);
285 
286  for (auto const & varName : varNames) {
287  MonitorElement* numer = igetter.get(dirName_+"/Source_Histos/"+filterName+"/"+baseName+"_single_"+varName+"_"+region);
288  if (numer != nullptr && denom != nullptr) {
289  std::string effHistName(baseName + "_singleEff_" + varName + "_" + region);//std::cout<<"Si: "<<effHistName<<std::endl;
290  //----Morse-----------
291  std::string effHistTitle(effHistName);//std::cout<<effHistTitle<<std::endl;
292  if (region == "eb" || region == "ee") {
293  if (region == "eb") effHistTitle = "Barrel " + baseName + " SingleEff " + varName;
294  if (region == "ee") effHistTitle = "Endcap " + baseName + " SingleEff " + varName;
295  }//std::cout<<effHistTitle<<std::endl;
296  makeEffMonElemFromPassAndAll(filterName, effHistName, effHistTitle, numer, denom, ibooker,
297  igetter);
298  //--------------------
299  }
300  }//end loop over varNames
301 }
302 
304  const std::string& region, const std::vector<std::string>& vsVarNames,
305  const std::string& objName, DQMStore::IBooker& ibooker, DQMStore::IGetter& igetter) {
306 
307  for (auto const & vsVarName : vsVarNames) {
308  std::string allName(dirName_ + "/Source_Histos/" + filterName + "/" + filterName + "_trigTagProbe_" + objName + "_all_" + vsVarName + "_" + region);
309  MonitorElement* all = igetter.get(allName);
310  if (all == nullptr) {
311  continue;
312  }
313  std::string passName(dirName_ + "/Source_Histos/" + filterName + "/" + filterName + "_trigTagProbe_" + objName + "_pass_" + vsVarName + "_" + region);
314  MonitorElement* pass = igetter.get(passName);
315  if (pass == nullptr) {
316  continue;
317  }
318  //----Morse-----
319  std::string effHistTitle(filterName + "_trigTagProbeEff_" + objName + "_vs_" + vsVarName + "_" + region);//std::cout<<effHistTitle<<std::endl;
320  if (region == "eb" || region == "ee") {
321  if (region == "eb") effHistTitle = "Barrel " + filterName + "_" + objName + " TrigTagProbeEff vs " + vsVarName;
322  if (region == "ee") effHistTitle = "Endcap " + filterName + "_" + objName + " TrigTagProbeEff vs " + vsVarName;
323  }
324  //------------
325  makeEffMonElemFromPassAndAll(filterName,
326  filterName + "_trigTagProbeEff_" + objName + "_vs_" + vsVarName + "_" + region,
327  effHistTitle, pass, all, ibooker, igetter);
328 
329  }//end loop over vsVarNames
330 }
331 
333  const std::string& region, const std::vector<std::string>& vsVarNames,
334  const std::string& objName, DQMStore::IBooker& ibooker, DQMStore::IGetter& igetter) {
335 
336  for (auto const & vsVarName : vsVarNames) {
337  /*
338  std::string allName(dirName_+"/Source_Histos/"+filterName+"/"+filterName+"_trigTagProbe_"+objName+"_all_"+vsVarNames[varNr]+"_"+region);
339  MonitorElement* all = dbe_->get(allName);
340  if(all==NULL){
341  //edm::LogInfo("EgHLTOfflineClient") <<" couldnt get hist "<<allName;
342  continue;
343  }*/
344  std::string passName(dirName_+"/Source_Histos/"+filterName+"/"+filterName+"_trigTagProbe_"+objName+"_passNotTag_"+vsVarName+"_"+region);
345  MonitorElement* passNotTag = igetter.get(passName);
346  if (passNotTag == nullptr) {
347  //edm::LogInfo("EgHLTOfflineClient") <<" couldnt get hist "<<passName;
348  continue;
349  }
350  std::string passTagTagName(dirName_+"/Source_Histos/"+filterName+"/"+filterName+"_trigTagProbe_"+objName+"_passTagTag_"+vsVarName+"_"+region);
351  MonitorElement* passTagTag = igetter.get(passTagTagName);
352  if (passTagTag == nullptr) {
353  //edm::LogInfo("EgHLTOfflineClient") <<" couldnt get hist "<<passTagTagName;
354  continue;
355  }
356  std::string failName(dirName_+"/Source_Histos/"+filterName+"/"+filterName+"_trigTagProbe_"+objName+"_fail_"+vsVarName+"_"+region);
357  MonitorElement* fail = igetter.get(failName);
358  if (fail == nullptr) {
359  //edm::LogInfo("EgHLTOfflineClient") <<" couldnt get hist "<<failName;
360  continue;
361  }
362  //----Morse-----
363  std::string effHistTitle(filterName+"_trigTagProbeEff_"+objName+"_vs_"+vsVarName+"_"+region);//std::cout<<effHistTitle<<std::endl;
364  if (region == "eb" || region == "ee") {
365  if (region == "eb") effHistTitle = "Barrel " + filterName + "_"+objName + " TrigTagProbeEff vs " + vsVarName;
366  if (region == "ee") effHistTitle = "Endcap " + filterName + "_"+objName + " TrigTagProbeEff vs " + vsVarName;
367  }//std::cout<<effHistTitle<<std::endl;
368  //------------
370  filterName + "_trigTagProbeEff_" + objName + "_vs_" + vsVarName + "_" + region,
371  effHistTitle, passNotTag, fail, passTagTag, ibooker, igetter);
372  }//end loop over vsVarNames
373 }
374 
376  const std::string& filterNameLeg2, const std::string& region,
377  const std::vector<std::string>& vsVarNames, const std::string& objName,
378  DQMStore::IBooker& ibooker, DQMStore::IGetter& igetter) {
379 
380  for (auto const & vsVarName : vsVarNames) {
381 
382  std::string allName(dirName_+"/Source_Histos/"+filterNameLeg2+"/"+filterNameLeg2+"_trigTagProbe_"+objName+"_all_"+vsVarName+"_"+region);
383  MonitorElement* all = igetter.get(allName);
384  if (all == nullptr) {
385  edm::LogInfo("EgHLTOfflineClient") <<" couldnt get hist "<<allName;
386  continue;
387  }
388 
389  std::string Leg2NotLeg1SourceName(dirName_+"/Source_Histos/"+filterNameLeg2+"/"+filterNameLeg2+"_trigTagProbe_"+objName+"_passLeg2failLeg1_"+vsVarName+"_"+region);
390  MonitorElement* Leg2NotLeg1Source = igetter.get(Leg2NotLeg1SourceName);
391  if (Leg2NotLeg1Source == nullptr) {
392  edm::LogInfo("EgHLTOfflineClient") <<" couldnt get hist "<<Leg2NotLeg1SourceName;
393  continue;
394  }
395 
396  std::string Leg1EffName(dirName_+"/Client_Histos/"+filterNameLeg1+"/"+filterNameLeg1+"_trigTagProbeEff_"+objName+"_vs_"+vsVarName+"_"+region);
397  MonitorElement *Leg1Eff = igetter.get(Leg1EffName);
398  if (Leg1Eff == nullptr) {
399  edm::LogInfo("EgHLTOfflineClient") <<" couldnt get hist "<<Leg1EffName;
400  continue;
401  }
402 
403  std::string effHistTitle(filterNameLeg2+"_trigTagProbeEff2Leg_"+objName+"_vs_"+vsVarName+"_"+region);//std::cout<<effHistTitle<<std::endl;
404  if (region == "eb" || region == "ee") {
405  if (region == "eb") effHistTitle = "Barrel " + filterNameLeg2 + "_" + objName + " TrigTagProbeEff2Leg vs " + vsVarName;
406  if (region == "ee") effHistTitle = "Endcap " + filterNameLeg2 + "_" + objName + " TrigTagProbeEff2Leg vs " + vsVarName;
407  }//std::cout<<effHistTitle<<std::endl;
408  makeEffMonElem2Leg(filterNameLeg2,
409  filterNameLeg2 + "_trigTagProbeEff2Leg_" + objName + "_vs_" + vsVarName + "_" + region,
410  effHistTitle, Leg1Eff, Leg2NotLeg1Source, all, ibooker, igetter);
411  }//end loop over vsVarNames
412 }
413 
414 
416  const std::vector<std::string>& tightLooseTrigNames, const std::string& region,
417  const std::vector<std::string>& vsVarNames, const std::string& objName,
418  DQMStore::IBooker& ibooker, DQMStore::IGetter& igetter) {
419 
420  for (auto const & vsVarName : vsVarNames) {
421  for (auto const & tightLooseTrigName : tightLooseTrigNames) {
422  std::vector<std::string> splitString;
423  boost::split(splitString, tightLooseTrigName, boost::is_any_of(std::string(":")));
424  if (splitString.size() != 2) {
425  continue; //format incorrect
426  }
427 
428  const std::string& tightTrig = splitString[0];
429  const std::string& looseTrig = splitString[1];
430  MonitorElement* fail = igetter.get(dirName_ + "/Source_Histos/" + tightTrig + "_" + looseTrig + "_" + objName + "_failTrig_" + vsVarName + "_" + region);
431  if (fail == nullptr) {
432  continue;
433  }
434 
435  MonitorElement* pass = igetter.get(dirName_ + "/Source_Histos/" + tightTrig + "_" + looseTrig + "_" + objName + "_passTrig_" + vsVarName + "_" + region);
436  if (pass == nullptr) {
437  continue;
438  }
439 
440  const std::string newHistName(tightTrig + "_trigEffTo_" + looseTrig + "_" + objName + "_vs_" + vsVarName + "_" + region);
441  //----Morse-----
442  std::string effHistTitle(newHistName);//std::cout<<effHistTitle<<std::endl;
443  if (region == "eb" || region == "ee") {
444  if (region == "eb") effHistTitle = "Barrel " + tightTrig + "_TrigEffTo_" + looseTrig + "_" + objName + " vs " + vsVarName;
445  if (region == "ee") effHistTitle = "Endcap " + tightTrig + "_TrigEffTo_" + looseTrig + "_" + objName + " vs " + vsVarName;
446  }
447  //------------
448  makeEffMonElemFromPassAndFail("LooseTight", newHistName, effHistTitle, pass, fail,
449  ibooker, igetter);
450 
451  }//end loop over trigger pairs
452  } //end loop over vsVarNames
453 
454 }
455 //-----Morse-------
457  const std::string& name, const std::string& title, const MonitorElement* pass,
458  const MonitorElement* all, DQMStore::IBooker& ibooker, DQMStore::IGetter& igetter) {
459 
460  TH1F* passHist = pass->getTH1F();
461  if (passHist->GetSumw2N() == 0) passHist->Sumw2();
462  TH1F* allHist = all->getTH1F();
463  if (allHist->GetSumw2N() == 0) allHist->Sumw2();
464  auto* effHist = (TH1F*) passHist->Clone(name.c_str());
465  effHist->Divide(passHist,allHist,1,1,"B");
466  //----Morse---------
467  effHist->SetTitle(title.c_str());
468  //------------------
469  MonitorElement* eff = igetter.get(dirName_+"/Client_Histos/"+filterName+"/"+name);
470  if (eff == nullptr) {
471  eff = ibooker.book1D(name,effHist);
472  } else { //I was having problems with collating the histograms, hence why I'm just resetting the histogram value
473  *eff->getTH1F()=*effHist;
474  delete effHist;
475  }
476  return eff;
477 }
478 
480  const std::string& filter, const std::string& name, const std::string& title,
481  const MonitorElement* passNotTag, const MonitorElement* fail, const MonitorElement* tagtag,
482  DQMStore::IBooker& ibooker, DQMStore::IGetter& igetter) {
483 
484  TH1F* passHist = passNotTag->getTH1F();
485  if (passHist->GetSumw2N() == 0) passHist->Sumw2();
486  TH1F* failHist = fail->getTH1F();
487  if (failHist->GetSumw2N() == 0) failHist->Sumw2();
488  TH1F* tagtagHist = tagtag->getTH1F();
489  if (tagtagHist->GetSumw2N() == 0) tagtagHist->Sumw2();
490  auto* numer = (TH1F*) passHist->Clone(name.c_str());
491  if (numer->GetSumw2N() == 0) numer->Sumw2();
492  numer->Add(tagtagHist,passHist,2,1);
493  auto* denom = (TH1F*) passHist->Clone(name.c_str());
494  if (denom->GetSumw2N() == 0) denom->Sumw2();
495  denom->Add(tagtagHist,passHist,2,1);
496  denom->Add(failHist,1);
497  auto* effHist = (TH1F*) passHist->Clone(name.c_str());
498  //TGraphAsymmErrors *effHist = new TGraphAsymmErrors(numer,denom,"cl=0.683 b(1,1) mode");
499  effHist->Divide(numer, denom, 1, 1, "B");
500  //effHist->Divide(numer,denom,"cl=0.683 b(1,1) mode");
501  //----Morse---------
502  effHist->SetTitle(title.c_str());
503  //------------------
504  MonitorElement* eff = igetter.get(dirName_+"/Client_Histos/"+filter+"/"+name);
505  if (eff == nullptr) {
506  eff = ibooker.book1D(name, effHist);
507  }
508  else { //I was having problems with collating the histograms, hence why I'm just resetting the histogram value
509  *eff->getTH1F()=*effHist;
510  //*eff->getTGraphAsymmErrors()=*effHist;
511  delete effHist;
512  }
513  return eff;
514 }
515 
517  const std::string& name, const std::string& title, const MonitorElement* Leg1Eff,
518  const MonitorElement* Leg2NotLeg1Source, const MonitorElement* all, DQMStore::IBooker& ibooker,
519  DQMStore::IGetter& igetter) {
520 
521  TH1F* allHist = all->getTH1F();
522  if (allHist->GetSumw2() == nullptr) allHist->Sumw2();
523  TH1F* Leg2NotLeg1SourceHist = Leg2NotLeg1Source->getTH1F();
524  if (Leg2NotLeg1SourceHist->GetSumw2() == nullptr) Leg2NotLeg1SourceHist->Sumw2();
525 
526  auto* effHistLeg2NotLeg1 = (TH1F*)allHist->Clone(name.c_str());
527  if (effHistLeg2NotLeg1->GetSumw2() == nullptr) effHistLeg2NotLeg1->Sumw2();
528  effHistLeg2NotLeg1->Divide(Leg2NotLeg1SourceHist, allHist, 1, 1, "B");
529 
530  TH1F* Leg1EffHist = Leg1Eff->getTH1F();
531  if (Leg1EffHist->GetSumw2() == nullptr) Leg1EffHist->Sumw2();
532 
533  auto* effHistTerm1 = (TH1F*)allHist->Clone(name.c_str());
534  if (effHistTerm1->GetSumw2() == nullptr) effHistTerm1->Sumw2();
535  effHistTerm1->Multiply(Leg1EffHist, Leg1EffHist, 1, 1, "B");
536 
537  auto* effHistTerm2 = (TH1F*)allHist->Clone(name.c_str());
538  if (effHistTerm2->GetSumw2() == nullptr) effHistTerm2->Sumw2();
539  effHistTerm2->Multiply(Leg1EffHist, effHistLeg2NotLeg1, 1, 1, "B");
540  effHistTerm2->Scale(2);
541 
542  auto* effHist = (TH1F*)allHist->Clone(name.c_str());
543  if (effHist->GetSumw2() == nullptr) effHist->Sumw2();
544  effHist->Add(effHistTerm1, effHistTerm2, 1, 1);
545  effHist->SetTitle(title.c_str());
546 
547  MonitorElement* eff = igetter.get(dirName_ + "/Client_Histos/" + filter + "/" + name);
548  if (eff == nullptr) {
549  eff = ibooker.book1D(name, effHist);
550  } else { //I was having problems with collating the histograms, hence why I'm just resetting the histogram value
551  *eff->getTH1F() = *effHist;
552  delete effHist;
553  }
554  return eff;
555 }
556 
557 //-----Morse-------
559  const std::string& name, const std::string& title, const MonitorElement* pass,
560  const MonitorElement* fail, DQMStore::IBooker& ibooker, DQMStore::IGetter& igetter) {
561 
562  TH1F* failHist = fail->getTH1F();
563  if (failHist->GetSumw2N() == 0) failHist->Sumw2();
564  TH1F* passHist = pass->getTH1F();
565  if (passHist->GetSumw2N() == 0) passHist->Sumw2();
566 
567  auto* effHist = (TH1F*) passHist->Clone(name.c_str());
568  effHist->Add(failHist);
569  effHist->Divide(passHist, effHist, 1, 1, "B");
570  //----Morse---------
571  effHist->SetTitle(title.c_str());
572  //------------------
573  MonitorElement* eff = igetter.get(dirName_ + "/Client_Histos/" + filterName + "/" + name);
574  if (eff == nullptr) {
575  eff = ibooker.book1D(name, effHist);
576  } else { //I was having problems with collating the histograms, hence why I'm just reseting the histogram value
577  *eff->getTH1F() = *effHist;
578  delete effHist;
579  }
580  return eff;
581 }
void createTrigTagProbeEffHists(const std::string &filterName, const std::string &region, const std::vector< std::string > &vsVarNames, const std::string &objName, DQMStore::IBooker &, DQMStore::IGetter &)
T getParameter(std::string const &) const
MonitorElement * FillHLTvsOfflineHist(const std::string &filter, const std::string &name, const std::string &title, const MonitorElement *numer, const MonitorElement *denom, DQMStore::IBooker &, DQMStore::IGetter &)
void createTrigTagProbeEffHistsNewAlgo(const std::string &filterName, const std::string &region, const std::vector< std::string > &vsVarNames, const std::string &objName, DQMStore::IBooker &, DQMStore::IGetter &)
void dqmEndJob(DQMStore::IBooker &, DQMStore::IGetter &) override
TH1F * getTH1F() const
std::vector< std::string > eleHLTFilterNames_
std::vector< std::string > phoHLTFilterNames2Leg_
MonitorElement * get(const std::string &path)
Definition: DQMStore.cc:307
std::vector< std::string > phoLooseTightTrigEffVsVars_
EgHLTOfflineClient(const EgHLTOfflineClient &rhs)
constexpr char const * varNames[]
std::vector< std::string > splitString(const std::string &fLine)
std::vector< std::string > phoTrigTPEffVsVars_
std::vector< std::string > eleTightLooseTrigNames_
void dqmEndLuminosityBlock(DQMStore::IBooker &, DQMStore::IGetter &, edm::LuminosityBlock const &, edm::EventSetup const &) override
std::vector< std::string > phoN1EffVars_
std::vector< std::string > eleHLTvOfflineVars_
std::vector< std::string > eleTrigTPEffVsVars_
void createSingleEffHists(const std::string &filterName, const std::string &baseName, const std::string &region, const std::vector< std::string > &varNames, DQMStore::IBooker &, DQMStore::IGetter &)
void createLooseTightTrigEff(const std::vector< std::string > &tightLooseTrigNames, const std::string &region, const std::vector< std::string > &vsVarNames, const std::string &objName, DQMStore::IBooker &, DQMStore::IGetter &)
MonitorElement * book1D(Args &&...args)
Definition: DQMStore.h:118
std::vector< std::string > phoEffTags_
std::vector< std::string > phoSingleEffVars_
void createHLTvsOfflineHists(const std::string &filterName, const std::string &baseName, const std::string &region, const std::vector< std::string > &varNames, DQMStore::IBooker &, DQMStore::IGetter &)
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:279
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
MonitorElement * makeEffMonElem2Leg(const std::string &filter, const std::string &name, const std::string &title, const MonitorElement *Leg1Eff, const MonitorElement *Leg2NotLeg1Source, const MonitorElement *all, DQMStore::IBooker &, DQMStore::IGetter &)
MonitorElement * makeEffMonElemFromPassAndAll(const std::string &filterName, const std::string &name, const std::string &title, const MonitorElement *pass, const MonitorElement *all, DQMStore::IBooker &, DQMStore::IGetter &)
void runClient_(DQMStore::IBooker &, DQMStore::IGetter &)
void createTrigTagProbeEffHists2Leg(const std::string &filterNameLeg1, const std::string &filterNameLeg2, const std::string &region, const std::vector< std::string > &vsVarNames, const std::string &objName, DQMStore::IBooker &, DQMStore::IGetter &)
std::vector< std::string > eleN1EffVars_
std::vector< std::string > phoTightLooseTrigNames_
std::vector< std::string > phoHLTvOfflineVars_
MonitorElement * makeEffMonElemFromPassAndFail(const std::string &filterName, const std::string &name, const std::string &title, const MonitorElement *pass, const MonitorElement *fail, DQMStore::IBooker &, DQMStore::IGetter &)
std::vector< std::string > phoHLTFilterNames_
std::vector< std::string > eleLooseTightTrigEffVsVars_
void filterInactiveTriggers(std::vector< std::string > &namesToFilter, std::vector< std::string > &activeFilters)
void createN1EffHists(const std::string &filterName, const std::string &baseName, const std::string &region, const std::vector< std::string > &varNames, DQMStore::IBooker &, DQMStore::IGetter &)
std::vector< std::string > eleEffTags_
void beginRun(const edm::Run &run, const edm::EventSetup &c) override
MonitorElement * makeEffMonElemFromPassAndFailAndTagTag(const std::string &filter, const std::string &name, const std::string &title, const MonitorElement *pass, const MonitorElement *fail, const MonitorElement *tagtag, DQMStore::IBooker &, DQMStore::IGetter &)
def fail(errstr="")
void filterInactiveTightLooseTriggers(std::vector< std::string > &namesToFilter, const std::vector< std::string > &activeFilters)
double split
Definition: MVATrainer.cc:139
Definition: Run.h:43
std::vector< std::string > eleHLTFilterNames2Leg_
~EgHLTOfflineClient() override
std::vector< std::string > eleSingleEffVars_