CMS 3D CMS Logo

DQMGenericClient.cc
Go to the documentation of this file.
1 /*
2  * Class:DQMGenericClient
3  *
4  * DQM histogram post processor
5  *
6  *
7  * \author Junghwan Goh - SungKyunKwan University
8  */
9 
15 
16 #include <TH1.h>
17 #include <TH1F.h>
18 #include <TH2F.h>
19 #include <TClass.h>
20 #include <TString.h>
21 #include <TPRegexp.h>
22 #include <TDirectory.h>
23 #include <TEfficiency.h>
24 
25 #include <set>
26 #include <cmath>
27 #include <string>
28 #include <vector>
29 #include <climits>
30 #include <boost/tokenizer.hpp>
31 
32 using namespace std;
33 using namespace edm;
34 
36 public:
38  ~DQMGenericClient() override{};
39 
40  void dqmEndLuminosityBlock(DQMStore::IBooker& ibooker,
41  DQMStore::IGetter& igetter,
42  const edm::LuminosityBlock& lumiSeg,
43  const edm::EventSetup& c) override;
44  void dqmEndRun(DQMStore::IBooker&, DQMStore::IGetter&, edm::Run const&, edm::EventSetup const&) override;
46 
47  enum class EfficType { none = 0, efficiency, fakerate, simpleratio };
48 
49  struct EfficOption {
53  bool isProfile;
54  };
55 
56  struct ResolOption {
59  };
60 
61  struct ProfileOption {
64  };
65 
66  struct NormOption {
68  };
69 
70  struct CDOption {
72  bool ascending;
73  };
74 
75  struct NoFlowOption {
77  };
78 
79  void computeEfficiency(DQMStore::IBooker& ibooker,
80  DQMStore::IGetter& igetter,
81  const std::string& startDir,
82  const std::string& efficMEName,
83  const std::string& efficMETitle,
84  const std::string& recoMEName,
85  const std::string& simMEName,
87  const bool makeProfile = false);
88  void computeResolution(DQMStore::IBooker& ibooker,
89  DQMStore::IGetter& igetter,
90  const std::string& startDir,
91  const std::string& fitMEPrefix,
92  const std::string& fitMETitlePrefix,
93  const std::string& srcMEName);
94  void computeProfile(DQMStore::IBooker& ibooker,
95  DQMStore::IGetter& igetter,
96  const std::string& startDir,
97  const std::string& profileMEName,
98  const std::string& profileMETitle,
99  const std::string& srcMEName);
100 
101  void normalizeToEntries(DQMStore::IBooker& ibooker,
102  DQMStore::IGetter& igetter,
103  const std::string& startDir,
104  const std::string& histName,
105  const std::string& normHistName);
106  void makeCumulativeDist(DQMStore::IBooker& ibooker,
107  DQMStore::IGetter& igetter,
108  const std::string& startDir,
109  const std::string& cdName,
110  bool ascending = true);
111  void makeNoFlowDist(DQMStore::IBooker& ibooker,
112  DQMStore::IGetter& igetter,
113  const std::string& startDir,
114  const std::string& cdName);
115 
116  void limitedFit(MonitorElement* srcME, MonitorElement* meanME, MonitorElement* sigmaME);
117 
118 private:
119  TPRegexp metacharacters_;
121  unsigned int verbose_;
127 
129  std::vector<std::string> subDirs_;
131 
132  std::vector<EfficOption> efficOptions_;
133  std::vector<ResolOption> resolOptions_;
134  std::vector<ProfileOption> profileOptions_;
135  std::vector<NormOption> normOptions_;
136  std::vector<CDOption> cdOptions_;
137  std::vector<NoFlowOption> noFlowOptions_;
138 
139  void generic_eff(TH1* denom, TH1* numer, MonitorElement* efficiencyHist, const EfficType type = EfficType::efficiency);
140 
141  void findAllSubdirectories(DQMStore::IBooker& ibooker,
142  DQMStore::IGetter& igetter,
144  std::set<std::string>* myList,
145  const TString& pattern);
146 
147  void makeAllPlots(DQMStore::IBooker&, DQMStore::IGetter&);
148 
149  void removeMEIfBooked(const std::string& meName, DQMStore::IGetter& igetter);
150 };
151 
153 public:
156  const bool oldAddDir = TH1::AddDirectoryStatus();
157  TH1::AddDirectory(true);
158  // ... create your hists
159  TH2F* h = me->getTH2F();
160  TF1 fgaus("fgaus", "gaus", h->GetYaxis()->GetXmin(), h->GetYaxis()->GetXmax(), TF1::EAddToList::kNo);
161  h->FitSlicesY(&fgaus, 0, -1, 0, "QNR SERIAL");
162  string name(h->GetName());
163  h0 = (TH1*)gDirectory->Get((name + "_0").c_str());
164  h1 = (TH1*)gDirectory->Get((name + "_1").c_str());
165  h2 = (TH1*)gDirectory->Get((name + "_2").c_str());
166  h3 = (TH1*)gDirectory->Get((name + "_chi2").c_str());
167  TH1::AddDirectory(oldAddDir);
168  }
169 
172  delete h0;
173  delete h1;
174  delete h2;
175  delete h3;
176  }
179  if (!(h1 && me))
180  throw cms::Exception("FitSlicesYTool") << "Pointer =0 : h1=" << h1 << " me=" << me;
181  if (h1->GetNbinsX() == me->getNbinsX()) {
182  for (int bin = 0; bin != h1->GetNbinsX(); bin++) {
183  me->setBinContent(bin + 1, h1->GetBinContent(bin + 1));
184  // me->setBinEntries(bin+1, 1.);
185  }
186  } else {
187  throw cms::Exception("FitSlicesYTool") << "Different number of bins!";
188  }
189  }
192  if (!(h2 && me))
193  throw cms::Exception("FitSlicesYTool") << "Pointer =0 : h1=" << h1 << " me=" << me;
194  if (h2->GetNbinsX() == me->getNbinsX()) {
195  for (int bin = 0; bin != h2->GetNbinsX(); bin++) {
196  me->setBinContent(bin + 1, h2->GetBinContent(bin + 1));
197  // me->setBinEntries(bin+1, 1.);
198  }
199  } else {
200  throw cms::Exception("FitSlicesYTool") << "Different number of bins!";
201  }
202  }
205  if (!(h1 && me))
206  throw cms::Exception("FitSlicesYTool") << "Pointer =0 : h1=" << h1 << " me=" << me;
207  if (h1->GetNbinsX() == me->getNbinsX()) {
208  for (int bin = 0; bin != h1->GetNbinsX(); bin++) {
209  me->setBinContent(bin + 1, h1->GetBinContent(bin + 1));
210  // me->setBinEntries(bin+1, 1.);
211  me->setBinError(bin + 1, h1->GetBinError(bin + 1));
212  }
213  } else {
214  throw cms::Exception("FitSlicesYTool") << "Different number of bins!";
215  }
216  }
219  if (!(h2 && me))
220  throw cms::Exception("FitSlicesYTool") << "Pointer =0 : h1=" << h1 << " me=" << me;
221  if (h2->GetNbinsX() == me->getNbinsX()) {
222  for (int bin = 0; bin != h2->GetNbinsX(); bin++) {
223  me->setBinContent(bin + 1, h2->GetBinContent(bin + 1));
224  // me->setBinEntries(bin+1, 1.);
225  me->setBinError(bin + 1, h2->GetBinError(bin + 1));
226  }
227  } else {
228  throw cms::Exception("FitSlicesYTool") << "Different number of bins!";
229  }
230  }
231 
232 private:
233  TH1* h0;
234  TH1* h1;
235  TH1* h2;
236  TH1* h3;
237 };
238 
240 
242  : metacharacters_("[\\^\\$\\.\\*\\+\\?\\|\\(\\)\\{\\}\\[\\]]"), nonPerlWildcard_("\\w\\*|^\\*") {
243  typedef std::vector<edm::ParameterSet> VPSet;
244  typedef std::vector<std::string> vstring;
245  typedef boost::escaped_list_separator<char> elsc;
246 
247  elsc commonEscapes("\\", " \t", "\'");
248 
249  verbose_ = pset.getUntrackedParameter<unsigned int>("verbose", 0);
250  runOnEndLumi_ = pset.getUntrackedParameter<bool>("runOnEndLumi", false);
251  runOnEndJob_ = pset.getUntrackedParameter<bool>("runOnEndJob", true);
252  makeGlobalEffPlot_ = pset.getUntrackedParameter<bool>("makeGlobalEffienciesPlot", true);
253 
254  // Parse efficiency commands
255  vstring effCmds = pset.getParameter<vstring>("efficiency");
256  for (vstring::const_iterator effCmd = effCmds.begin(); effCmd != effCmds.end(); ++effCmd) {
257  if (effCmd->empty())
258  continue;
259 
260  boost::tokenizer<elsc> tokens(*effCmd, commonEscapes);
261 
262  vector<string> args;
263  for (boost::tokenizer<elsc>::const_iterator iToken = tokens.begin(); iToken != tokens.end(); ++iToken) {
264  if (iToken->empty())
265  continue;
266  args.push_back(*iToken);
267  }
268 
269  if (args.size() < 4) {
270  LogInfo("DQMGenericClient") << "Wrong input to effCmds\n";
271  continue;
272  }
273 
275  opt.name = args[0];
276  opt.title = args[1];
277  opt.numerator = args[2];
278  opt.denominator = args[3];
279  opt.isProfile = false;
280 
281  const string typeName = args.size() == 4 ? "eff" : args[4];
282  if (typeName == "eff")
283  opt.type = EfficType::efficiency;
284  else if (typeName == "fake")
285  opt.type = EfficType::fakerate;
286  else if (typeName == "simpleratio")
288  else
289  opt.type = EfficType::none;
290 
291  efficOptions_.push_back(opt);
292  }
293 
294  VPSet efficSets = pset.getUntrackedParameter<VPSet>("efficiencySets", VPSet());
295  for (VPSet::const_iterator efficSet = efficSets.begin(); efficSet != efficSets.end(); ++efficSet) {
297  opt.name = efficSet->getUntrackedParameter<string>("name");
298  opt.title = efficSet->getUntrackedParameter<string>("title");
299  opt.numerator = efficSet->getUntrackedParameter<string>("numerator");
300  opt.denominator = efficSet->getUntrackedParameter<string>("denominator");
301  opt.isProfile = false;
302 
303  const string typeName = efficSet->getUntrackedParameter<string>("typeName", "eff");
304  if (typeName == "eff")
305  opt.type = EfficType::efficiency;
306  else if (typeName == "fake")
307  opt.type = EfficType::fakerate;
308  else if (typeName == "simpleratio")
310  else
311  opt.type = EfficType::none;
312 
313  efficOptions_.push_back(opt);
314  }
315 
316  // Parse efficiency profiles
317  vstring effProfileCmds = pset.getUntrackedParameter<vstring>("efficiencyProfile", vstring());
318  for (vstring::const_iterator effProfileCmd = effProfileCmds.begin(); effProfileCmd != effProfileCmds.end();
319  ++effProfileCmd) {
320  if (effProfileCmd->empty())
321  continue;
322 
323  boost::tokenizer<elsc> tokens(*effProfileCmd, commonEscapes);
324 
325  vector<string> args;
326  for (boost::tokenizer<elsc>::const_iterator iToken = tokens.begin(); iToken != tokens.end(); ++iToken) {
327  if (iToken->empty())
328  continue;
329  args.push_back(*iToken);
330  }
331 
332  if (args.size() < 4) {
333  LogInfo("DQMGenericClient") << "Wrong input to effProfileCmds\n";
334  continue;
335  }
336 
338  opt.name = args[0];
339  opt.title = args[1];
340  opt.numerator = args[2];
341  opt.denominator = args[3];
342  opt.isProfile = true;
343 
344  const string typeName = args.size() == 4 ? "eff" : args[4];
345  if (typeName == "eff")
346  opt.type = EfficType::efficiency;
347  else if (typeName == "fake")
348  opt.type = EfficType::fakerate;
349  else if (typeName == "simpleratio")
351  else
352  opt.type = EfficType::none;
353 
354  efficOptions_.push_back(opt);
355  }
356 
357  VPSet effProfileSets = pset.getUntrackedParameter<VPSet>("efficiencyProfileSets", VPSet());
358  for (VPSet::const_iterator effProfileSet = effProfileSets.begin(); effProfileSet != effProfileSets.end();
359  ++effProfileSet) {
361  opt.name = effProfileSet->getUntrackedParameter<string>("name");
362  opt.title = effProfileSet->getUntrackedParameter<string>("title");
363  opt.numerator = effProfileSet->getUntrackedParameter<string>("numerator");
364  opt.denominator = effProfileSet->getUntrackedParameter<string>("denominator");
365  opt.isProfile = true;
366 
367  const string typeName = effProfileSet->getUntrackedParameter<string>("typeName", "eff");
368  if (typeName == "eff")
369  opt.type = EfficType::efficiency;
370  else if (typeName == "fake")
371  opt.type = EfficType::fakerate;
372  else if (typeName == "simpleratio")
374  else
375  opt.type = EfficType::none;
376 
377  efficOptions_.push_back(opt);
378  }
379 
380  // Parse resolution commands
381  vstring resCmds = pset.getParameter<vstring>("resolution");
382  for (vstring::const_iterator resCmd = resCmds.begin(); resCmd != resCmds.end(); ++resCmd) {
383  if (resCmd->empty())
384  continue;
385  boost::tokenizer<elsc> tokens(*resCmd, commonEscapes);
386 
387  vector<string> args;
388  for (boost::tokenizer<elsc>::const_iterator iToken = tokens.begin(); iToken != tokens.end(); ++iToken) {
389  if (iToken->empty())
390  continue;
391  args.push_back(*iToken);
392  }
393 
394  if (args.size() != 3) {
395  LogInfo("DQMGenericClient") << "Wrong input to resCmds\n";
396  continue;
397  }
398 
400  opt.namePrefix = args[0];
401  opt.titlePrefix = args[1];
402  opt.srcName = args[2];
403 
404  resolOptions_.push_back(opt);
405  }
406 
407  VPSet resolSets = pset.getUntrackedParameter<VPSet>("resolutionSets", VPSet());
408  for (VPSet::const_iterator resolSet = resolSets.begin(); resolSet != resolSets.end(); ++resolSet) {
410  opt.namePrefix = resolSet->getUntrackedParameter<string>("namePrefix");
411  opt.titlePrefix = resolSet->getUntrackedParameter<string>("titlePrefix");
412  opt.srcName = resolSet->getUntrackedParameter<string>("srcName");
413 
414  resolOptions_.push_back(opt);
415  }
416 
417  // Parse profiles
418  vstring profileCmds = pset.getUntrackedParameter<vstring>("profile", vstring());
419  for (const auto& profileCmd : profileCmds) {
420  boost::tokenizer<elsc> tokens(profileCmd, commonEscapes);
421 
422  vector<string> args;
423  for (boost::tokenizer<elsc>::const_iterator iToken = tokens.begin(); iToken != tokens.end(); ++iToken) {
424  if (iToken->empty())
425  continue;
426  args.push_back(*iToken);
427  }
428 
429  if (args.size() != 3) {
430  LogInfo("DQMGenericClient") << "Wrong input to profileCmds\n";
431  continue;
432  }
433 
435  opt.name = args[0];
436  opt.title = args[1];
437  opt.srcName = args[2];
438 
439  profileOptions_.push_back(opt);
440  }
441 
442  VPSet profileSets = pset.getUntrackedParameter<VPSet>("profileSets", VPSet());
443  for (const auto& profileSet : profileSets) {
445  opt.name = profileSet.getUntrackedParameter<string>("name");
446  opt.title = profileSet.getUntrackedParameter<string>("title");
447  opt.srcName = profileSet.getUntrackedParameter<string>("srcName");
448 
449  profileOptions_.push_back(opt);
450  }
451 
452  // Parse Normalization commands
453  vstring normCmds = pset.getUntrackedParameter<vstring>("normalization", vstring());
454  for (vstring::const_iterator normCmd = normCmds.begin(); normCmd != normCmds.end(); ++normCmd) {
455  if (normCmd->empty())
456  continue;
457  boost::tokenizer<elsc> tokens(*normCmd, commonEscapes);
458 
459  vector<string> args;
460  for (boost::tokenizer<elsc>::const_iterator iToken = tokens.begin(); iToken != tokens.end(); ++iToken) {
461  if (iToken->empty())
462  continue;
463  args.push_back(*iToken);
464  }
465 
466  if (args.empty() or args.size() > 2) {
467  LogInfo("DQMGenericClient") << "Wrong input to normCmds\n";
468  continue;
469  }
470 
471  NormOption opt;
472  opt.name = args[0];
473  opt.normHistName = args.size() == 2 ? args[1] : args[0];
474 
475  normOptions_.push_back(opt);
476  }
477 
478  VPSet normSets = pset.getUntrackedParameter<VPSet>("normalizationSets", VPSet());
479  for (VPSet::const_iterator normSet = normSets.begin(); normSet != normSets.end(); ++normSet) {
480  NormOption opt;
481  opt.name = normSet->getUntrackedParameter<string>("name");
482  opt.normHistName = normSet->getUntrackedParameter<string>("normalizedTo", opt.name);
483 
484  normOptions_.push_back(opt);
485  }
486 
487  // Cumulative distributions
488  vstring cdCmds = pset.getUntrackedParameter<vstring>("cumulativeDists", vstring());
489  for (vstring::const_iterator cdCmd = cdCmds.begin(); cdCmd != cdCmds.end(); ++cdCmd) {
490  if (cdCmd->empty())
491  continue;
492  boost::tokenizer<elsc> tokens(*cdCmd, commonEscapes);
493 
494  vector<string> args;
495  for (boost::tokenizer<elsc>::const_iterator iToken = tokens.begin(); iToken != tokens.end(); ++iToken) {
496  if (iToken->empty())
497  continue;
498  args.push_back(*iToken);
499  }
500 
501  if (args.empty() || args.size() > 2) {
502  LogInfo("DQMGenericClient") << "Wrong input to cdCmds\n";
503  continue;
504  }
505 
506  CDOption opt;
507  opt.name = args[0];
508  opt.ascending = args.size() == 2 ? (args[1] != "descending") : true;
509 
510  cdOptions_.push_back(opt);
511  }
512 
513  VPSet cdSets = pset.getUntrackedParameter<VPSet>("cumulativeDistSets", VPSet());
514  for (VPSet::const_iterator cdSet = cdSets.begin(); cdSet != cdSets.end(); ++cdSet) {
515  CDOption opt;
516  opt.name = cdSet->getUntrackedParameter<string>("name");
517  opt.ascending = cdSet->getUntrackedParameter<bool>("ascending", true);
518 
519  cdOptions_.push_back(opt);
520  }
521 
522  // move under/overflows to first/last bins
523  vstring noFlowCmds = pset.getUntrackedParameter<vstring>("noFlowDists", vstring());
524  for (vstring::const_iterator noFlowCmd = noFlowCmds.begin(); noFlowCmd != noFlowCmds.end(); ++noFlowCmd) {
525  if (noFlowCmd->empty())
526  continue;
527  boost::tokenizer<elsc> tokens(*noFlowCmd, commonEscapes);
528 
529  vector<string> args;
530  for (boost::tokenizer<elsc>::const_iterator iToken = tokens.begin(); iToken != tokens.end(); ++iToken) {
531  if (iToken->empty())
532  continue;
533  args.push_back(*iToken);
534  }
535 
536  if (args.empty() || args.size() > 2) {
537  LogInfo("DQMGenericClient") << "Wrong input to noFlowCmds\n";
538  continue;
539  }
540 
542  opt.name = args[0];
543 
544  noFlowOptions_.push_back(opt);
545  }
546 
547  VPSet noFlowSets = pset.getUntrackedParameter<VPSet>("noFlowDistSets", VPSet());
548  for (VPSet::const_iterator noFlowSet = noFlowSets.begin(); noFlowSet != noFlowSets.end(); ++noFlowSet) {
550  opt.name = noFlowSet->getUntrackedParameter<string>("name");
551 
552  noFlowOptions_.push_back(opt);
553  }
554 
555  outputFileName_ = pset.getUntrackedParameter<string>("outputFileName", "");
556  subDirs_ = pset.getUntrackedParameter<vstring>("subDirs");
557 
558  resLimitedFit_ = pset.getUntrackedParameter<bool>("resolutionLimitedFit", false);
559  isWildcardUsed_ = false;
560 }
561 
563  DQMStore::IGetter& igetter,
564  const edm::LuminosityBlock& lumiSeg,
565  const edm::EventSetup& c) {
566  if (runOnEndLumi_) {
567  makeAllPlots(ibooker, igetter);
568  }
569 }
570 
572  DQMStore::IGetter& igetter,
573  edm::Run const&,
574  edm::EventSetup const&) {
575  // Create new MEs in endRun, even though we are requested to do it in endJob.
576  // This gives the QTests a chance to run, before summaries are created in
577  // endJob. The negative side effect is that we cannot run the GenericClient
578  // for plots produced in Harvesting, but that seems rather rare.
579  //
580  // It is important that this is still save in the presence of multiple runs,
581  // first because in multi-run harvesting, we accumulate statistics over all
582  // runs and have full statistics at the endRun of the last run, and second,
583  // because we set the efficiencyFlag so any further aggregation should produce
584  // correct results. Also, all operations should be idempotent; running them
585  // more than once does no harm.
586 
587  // needed to access the DQMStore::save method
588  theDQM = nullptr;
590 
591  if (runOnEndJob_) {
592  makeAllPlots(ibooker, igetter);
593  }
594 
595  if (!outputFileName_.empty())
597 }
598 
600  typedef vector<string> vstring;
601 
602  // Process wildcard in the sub-directory
603  set<string> subDirSet;
604 
605  for (vstring::const_iterator iSubDir = subDirs_.begin(); iSubDir != subDirs_.end(); ++iSubDir) {
606  string subDir = *iSubDir;
607 
608  if (subDir[subDir.size() - 1] == '/')
609  subDir.erase(subDir.size() - 1);
610 
611  if (TString(subDir).Contains(metacharacters_)) {
612  isWildcardUsed_ = true;
613 
614  const string::size_type shiftPos = subDir.rfind('/');
615  const string searchPath = subDir.substr(0, shiftPos);
616  const string pattern = subDir.substr(shiftPos + 1, subDir.length());
617  //std::cout << "\n\n\n\nLooking for all subdirs of " << subDir << std::endl;
618 
619  findAllSubdirectories(ibooker, igetter, searchPath, &subDirSet, pattern);
620 
621  } else {
622  subDirSet.insert(subDir);
623  }
624  }
625 
626  for (set<string>::const_iterator iSubDir = subDirSet.begin(); iSubDir != subDirSet.end(); ++iSubDir) {
627  const string& dirName = *iSubDir;
628 
629  // First normalize, then move under/overflows, then make
630  // cumulative, and only then efficiency This allows to use the
631  // cumulative distributions for efficiency calculation
632  for (vector<NormOption>::const_iterator normOption = normOptions_.begin(); normOption != normOptions_.end();
633  ++normOption) {
634  normalizeToEntries(ibooker, igetter, dirName, normOption->name, normOption->normHistName);
635  }
636 
637  for (vector<NoFlowOption>::const_iterator noFlowOption = noFlowOptions_.begin();
638  noFlowOption != noFlowOptions_.end();
639  ++noFlowOption) {
640  makeNoFlowDist(ibooker, igetter, dirName, noFlowOption->name);
641  }
642 
643  for (vector<CDOption>::const_iterator cdOption = cdOptions_.begin(); cdOption != cdOptions_.end(); ++cdOption) {
644  makeCumulativeDist(ibooker, igetter, dirName, cdOption->name, cdOption->ascending);
645  }
646 
647  for (vector<EfficOption>::const_iterator efficOption = efficOptions_.begin(); efficOption != efficOptions_.end();
648  ++efficOption) {
649  computeEfficiency(ibooker,
650  igetter,
651  dirName,
652  efficOption->name,
653  efficOption->title,
654  efficOption->numerator,
655  efficOption->denominator,
656  efficOption->type,
657  efficOption->isProfile);
658  }
659  if (makeGlobalEffPlot_) {
660  ME* globalEfficME = igetter.get(dirName + "/globalEfficiencies");
661  if (globalEfficME)
662  globalEfficME->getTH1F()->LabelsDeflate("X");
663  }
664 
665  for (vector<ResolOption>::const_iterator resolOption = resolOptions_.begin(); resolOption != resolOptions_.end();
666  ++resolOption) {
668  ibooker, igetter, dirName, resolOption->namePrefix, resolOption->titlePrefix, resolOption->srcName);
669  }
670 
671  for (const auto& profileOption : profileOptions_) {
672  computeProfile(ibooker, igetter, dirName, profileOption.name, profileOption.title, profileOption.srcName);
673  }
674  }
675 }
676 
678  DQMStore::IGetter& igetter,
679  const string& startDir,
680  const string& efficMEName,
681  const string& efficMETitle,
682  const string& recoMEName,
683  const string& simMEName,
684  const EfficType type,
685  const bool makeProfile) {
686  if (!igetter.dirExists(startDir)) {
687  if (verbose_ >= 2 || (verbose_ == 1 && !isWildcardUsed_)) {
688  LogInfo("DQMGenericClient") << "computeEfficiency() : "
689  << "Cannot find sub-directory " << startDir << endl;
690  }
691  return;
692  }
693 
694  ibooker.cd();
695 
696  ME* simME = igetter.get(startDir + "/" + simMEName);
697  ME* recoME = igetter.get(startDir + "/" + recoMEName);
698 
699  if (!simME) {
700  if (verbose_ >= 2 || (verbose_ == 1 && !isWildcardUsed_)) {
701  LogInfo("DQMGenericClient") << "computeEfficiency() : "
702  << "No sim-ME '" << simMEName << "' found\n";
703  }
704  return;
705  }
706 
707  if (!recoME) {
708  if (verbose_ >= 2 || (verbose_ == 1 && !isWildcardUsed_)) {
709  LogInfo("DQMGenericClient") << "computeEfficiency() : "
710  << "No reco-ME '" << recoMEName << "' found\n";
711  }
712  return;
713  }
714 
715  // Treat everything as the base class, TH1
716 
717  TH1* hSim = simME->getTH1();
718  TH1* hReco = recoME->getTH1();
719 
720  if (!hSim || !hReco) {
721  if (verbose_ >= 2 || (verbose_ == 1 && !isWildcardUsed_)) {
722  LogInfo("DQMGenericClient") << "computeEfficiency() : "
723  << "Cannot create TH1 from ME\n";
724  }
725  return;
726  }
727 
728  string efficDir = startDir;
729  string newEfficMEName = efficMEName;
730  string::size_type shiftPos;
731  if (string::npos != (shiftPos = efficMEName.rfind('/'))) {
732  efficDir += "/" + efficMEName.substr(0, shiftPos);
733  newEfficMEName.erase(0, shiftPos + 1);
734  }
735  ibooker.setCurrentFolder(efficDir);
736 
737  if (makeProfile) {
738  TProfile* efficHist = (hReco->GetXaxis()->GetXbins()->GetSize() == 0)
739  ? new TProfile(newEfficMEName.c_str(),
740  efficMETitle.c_str(),
741  hReco->GetXaxis()->GetNbins(),
742  hReco->GetXaxis()->GetXmin(),
743  hReco->GetXaxis()->GetXmax())
744  : new TProfile(newEfficMEName.c_str(),
745  efficMETitle.c_str(),
746  hReco->GetXaxis()->GetNbins(),
747  hReco->GetXaxis()->GetXbins()->GetArray());
748 
749  efficHist->GetXaxis()->SetTitle(hSim->GetXaxis()->GetTitle());
750  efficHist->GetYaxis()->SetTitle(hSim->GetYaxis()->GetTitle());
751 
752  for (int i = 1; i <= hReco->GetNbinsX(); i++) {
753  const double nReco = hReco->GetBinContent(i);
754  const double nSim = hSim->GetBinContent(i);
755 
756  if (!std::string(hSim->GetXaxis()->GetBinLabel(i)).empty())
757  efficHist->GetXaxis()->SetBinLabel(i, hSim->GetXaxis()->GetBinLabel(i));
758 
759  if (nSim == 0 or nReco < 0 or nReco > nSim)
760  continue;
761  const double effVal = nReco / nSim;
762  const double errLo = TEfficiency::ClopperPearson(nSim, nReco, 0.683, false);
763  const double errUp = TEfficiency::ClopperPearson(nSim, nReco, 0.683, true);
764  const double errVal = (effVal - errLo > errUp - effVal) ? effVal - errLo : errUp - effVal;
765  efficHist->SetBinContent(i, effVal);
766  efficHist->SetBinEntries(i, 1);
767  efficHist->SetBinError(i, std::hypot(effVal, errVal));
768  }
769  ibooker.bookProfile(newEfficMEName, efficHist);
770  delete efficHist;
771  }
772 
773  else {
774  TH1* efficHist = (TH1*)hSim->Clone(newEfficMEName.c_str());
775  efficHist->SetTitle(efficMETitle.c_str());
776 
777  // Here is where you have trouble --- you need
778  // to understand what type of hist you have.
779 
780  ME* efficME = nullptr;
781 
782  // Parse the class name
783  // This works, but there might be a better way
784  TClass* myHistClass = efficHist->IsA();
785  TString histClassName = myHistClass->GetName();
786 
787  if (histClassName == "TH1F") {
788  efficME = ibooker.book1D(newEfficMEName, (TH1F*)efficHist);
789  } else if (histClassName == "TH2F") {
790  efficME = ibooker.book2D(newEfficMEName, (TH2F*)efficHist);
791  } else if (histClassName == "TH3F") {
792  efficME = ibooker.book3D(newEfficMEName, (TH3F*)efficHist);
793  }
794 
795  delete efficHist;
796 
797  if (!efficME) {
798  LogInfo("DQMGenericClient") << "computeEfficiency() : "
799  << "Cannot book effic-ME from the DQM\n";
800  return;
801  }
802 
803  // Update: 2009-9-16 slaunwhj
804  // call the most generic efficiency function
805  // works up to 3-d histograms
806 
807  generic_eff(hSim, hReco, efficME, type);
808 
809  // const int nBin = efficME->getNbinsX();
810  // for(int bin = 0; bin <= nBin; ++bin) {
811  // const float nSim = simME ->getBinContent(bin);
812  // const float nReco = recoME->getBinContent(bin);
813  // float eff =0;
814  // if (type=="fake")eff = nSim ? 1-nReco/nSim : 0.;
815  // else eff= nSim ? nReco/nSim : 0.;
816  // const float err = nSim && eff <= 1 ? sqrt(eff*(1-eff)/nSim) : 0.;
817  // efficME->setBinContent(bin, eff);
818  // efficME->setBinError(bin, err);
819  // }
820  efficME->setEntries(simME->getEntries());
821  }
822 
823  // Global efficiency
824  if (makeGlobalEffPlot_) {
825  ME* globalEfficME = igetter.get(efficDir + "/globalEfficiencies");
826  if (!globalEfficME)
827  globalEfficME = ibooker.book1D("globalEfficiencies", "Global efficiencies", 1, 0, 1);
828  if (!globalEfficME) {
829  LogInfo("DQMGenericClient") << "computeEfficiency() : "
830  << "Cannot book globalEffic-ME from the DQM\n";
831  return;
832  }
833  globalEfficME->setEfficiencyFlag();
834  TH1F* hGlobalEffic = globalEfficME->getTH1F();
835  if (!hGlobalEffic) {
836  LogInfo("DQMGenericClient") << "computeEfficiency() : "
837  << "Cannot create TH1F from ME, globalEfficME\n";
838  return;
839  }
840 
841  const float nSimAll = hSim->GetEntries();
842  const float nRecoAll = hReco->GetEntries();
843  float efficAll = 0;
845  efficAll = nSimAll ? nRecoAll / nSimAll : 0;
846  else if (type == EfficType::fakerate)
847  efficAll = nSimAll ? 1 - nRecoAll / nSimAll : 0;
848  float errorAll = 0;
849  if (type == EfficType::simpleratio) {
850  if (nSimAll) {
851  const float x = nRecoAll / nSimAll;
852  errorAll = std::sqrt(1.f / nSimAll * x * (1 + x));
853  }
854  } else
855  errorAll = nSimAll && efficAll < 1 ? sqrt(efficAll * (1 - efficAll) / nSimAll) : 0;
856 
857  const int iBin = hGlobalEffic->Fill(newEfficMEName.c_str(), 0);
858  hGlobalEffic->SetBinContent(iBin, efficAll);
859  hGlobalEffic->SetBinError(iBin, errorAll);
860  }
861 }
862 
864  DQMStore::IGetter& igetter,
865  const string& startDir,
866  const string& namePrefix,
867  const string& titlePrefix,
868  const std::string& srcName) {
869  if (!igetter.dirExists(startDir)) {
870  if (verbose_ >= 2 || (verbose_ == 1 && !isWildcardUsed_)) {
871  LogInfo("DQMGenericClient") << "computeResolution() : "
872  << "Cannot find sub-directory " << startDir << endl;
873  }
874  return;
875  }
876 
877  ibooker.cd();
878 
879  ME* srcME = igetter.get(startDir + "/" + srcName);
880  if (!srcME) {
881  if (verbose_ >= 2 || (verbose_ == 1 && !isWildcardUsed_)) {
882  LogInfo("DQMGenericClient") << "computeResolution() : "
883  << "No source ME '" << srcName << "' found\n";
884  }
885  return;
886  }
887 
888  TH2F* hSrc = srcME->getTH2F();
889  if (!hSrc) {
890  if (verbose_ >= 2 || (verbose_ == 1 && !isWildcardUsed_)) {
891  LogInfo("DQMGenericClient") << "computeResolution() : "
892  << "Cannot create TH2F from source-ME\n";
893  }
894  return;
895  }
896 
897  const int nBin = hSrc->GetNbinsX();
898 
899  string newDir = startDir;
900  string newPrefix = namePrefix;
901  string::size_type shiftPos;
902  if (string::npos != (shiftPos = namePrefix.rfind('/'))) {
903  newDir += "/" + namePrefix.substr(0, shiftPos);
904  newPrefix.erase(0, shiftPos + 1);
905  }
906 
907  ibooker.setCurrentFolder(newDir);
908 
909  float* lowedgesfloats = new float[nBin + 1];
910  ME* meanME;
911  ME* sigmaME;
912  if (hSrc->GetXaxis()->GetXbins()->GetSize()) {
913  for (int j = 0; j < nBin + 1; ++j)
914  lowedgesfloats[j] = (float)hSrc->GetXaxis()->GetXbins()->GetAt(j);
915  meanME = ibooker.book1D(newPrefix + "_Mean", titlePrefix + " Mean", nBin, lowedgesfloats);
916  sigmaME = ibooker.book1D(newPrefix + "_Sigma", titlePrefix + " Sigma", nBin, lowedgesfloats);
917  } else {
918  meanME = ibooker.book1D(
919  newPrefix + "_Mean", titlePrefix + " Mean", nBin, hSrc->GetXaxis()->GetXmin(), hSrc->GetXaxis()->GetXmax());
920  sigmaME = ibooker.book1D(
921  newPrefix + "_Sigma", titlePrefix + " Sigma", nBin, hSrc->GetXaxis()->GetXmin(), hSrc->GetXaxis()->GetXmax());
922  }
923 
924  if (meanME && sigmaME) {
925  meanME->setEfficiencyFlag();
926  sigmaME->setEfficiencyFlag();
927 
928  if (!resLimitedFit_) {
929  FitSlicesYTool fitTool(srcME);
930  fitTool.getFittedMeanWithError(meanME);
931  fitTool.getFittedSigmaWithError(sigmaME);
933  } else {
934  limitedFit(srcME, meanME, sigmaME);
935  }
936  }
937  delete[] lowedgesfloats;
938 }
939 
941  DQMStore::IGetter& igetter,
942  const std::string& startDir,
943  const std::string& profileMEName,
944  const std::string& profileMETitle,
945  const std::string& srcMEName) {
946  if (!igetter.dirExists(startDir)) {
947  if (verbose_ >= 2 || (verbose_ == 1 && !isWildcardUsed_)) {
948  LogInfo("DQMGenericClient") << "computeProfile() : "
949  << "Cannot find sub-directory " << startDir << endl;
950  }
951  return;
952  }
953 
954  ibooker.cd();
955 
956  ME* srcME = igetter.get(startDir + "/" + srcMEName);
957  if (!srcME) {
958  if (verbose_ >= 2 || (verbose_ == 1 && !isWildcardUsed_)) {
959  LogInfo("DQMGenericClient") << "computeProfile() : "
960  << "No source ME '" << srcMEName << "' found\n";
961  }
962  return;
963  }
964 
965  TH2F* hSrc = srcME->getTH2F();
966  if (!hSrc) {
967  if (verbose_ >= 2 || (verbose_ == 1 && !isWildcardUsed_)) {
968  LogInfo("DQMGenericClient") << "computeProfile() : "
969  << "Cannot create TH2F from source-ME\n";
970  }
971  return;
972  }
973 
974  string profileDir = startDir;
975  string newProfileMEName = profileMEName;
976  string::size_type shiftPos;
977  if (string::npos != (shiftPos = profileMEName.rfind('/'))) {
978  profileDir += "/" + profileMEName.substr(0, shiftPos);
979  newProfileMEName.erase(0, shiftPos + 1);
980  }
981  ibooker.setCurrentFolder(profileDir);
982 
983  std::unique_ptr<TProfile> profile(hSrc->ProfileX()); // We own the pointer
984  profile->SetTitle(profileMETitle.c_str());
985  ibooker.bookProfile(profileMEName, profile.get()); // ibooker makes a copy
986 }
987 
989  DQMStore::IGetter& igetter,
990  const std::string& startDir,
991  const std::string& histName,
992  const std::string& normHistName) {
993  if (!igetter.dirExists(startDir)) {
994  if (verbose_ >= 2 || (verbose_ == 1 && !isWildcardUsed_)) {
995  LogInfo("DQMGenericClient") << "normalizeToEntries() : "
996  << "Cannot find sub-directory " << startDir << endl;
997  }
998  return;
999  }
1000 
1001  ibooker.cd();
1002 
1003  ME* element = igetter.get(startDir + "/" + histName);
1004  ME* normME = igetter.get(startDir + "/" + normHistName);
1005 
1006  if (!element) {
1007  if (verbose_ >= 2 || (verbose_ == 1 && !isWildcardUsed_)) {
1008  LogInfo("DQMGenericClient") << "normalizeToEntries() : "
1009  << "No such element '" << histName << "' found\n";
1010  }
1011  return;
1012  }
1013 
1014  if (!normME) {
1015  if (verbose_ >= 2 || (verbose_ == 1 && !isWildcardUsed_)) {
1016  LogInfo("DQMGenericClient") << "normalizeToEntries() : "
1017  << "No such element '" << normHistName << "' found\n";
1018  }
1019  return;
1020  }
1021 
1022  TH1F* hist = element->getTH1F();
1023  if (!hist) {
1024  if (verbose_ >= 2 || (verbose_ == 1 && !isWildcardUsed_)) {
1025  LogInfo("DQMGenericClient") << "normalizeToEntries() : "
1026  << "Cannot create TH1F from ME\n";
1027  }
1028  return;
1029  }
1030 
1031  TH1F* normHist = normME->getTH1F();
1032  if (!normHist) {
1033  if (verbose_ >= 2 || (verbose_ == 1 && !isWildcardUsed_)) {
1034  LogInfo("DQMGenericClient") << "normalizeToEntries() : "
1035  << "Cannot create TH1F from ME\n";
1036  }
1037  return;
1038  }
1039 
1040  const double entries = normHist->GetEntries();
1041  if (entries != 0) {
1042  hist->Scale(1. / entries);
1043  } else {
1044  LogInfo("DQMGenericClient") << "normalizeToEntries() : "
1045  << "Zero entries in histogram\n";
1046  }
1047 
1048  return;
1049 }
1050 
1052  DQMStore::IGetter& igetter,
1053  const std::string& startDir,
1054  const std::string& cdName,
1055  bool ascending) {
1056  if (!igetter.dirExists(startDir)) {
1057  if (verbose_ >= 2 || (verbose_ == 1 && !isWildcardUsed_)) {
1058  LogInfo("DQMGenericClient") << "makeCumulativeDist() : "
1059  << "Cannot find sub-directory " << startDir << endl;
1060  }
1061  return;
1062  }
1063 
1064  ibooker.cd();
1065 
1066  ME* element_cd = igetter.get(startDir + "/" + cdName);
1067 
1068  if (!element_cd) {
1069  if (verbose_ >= 2 || (verbose_ == 1 && !isWildcardUsed_)) {
1070  LogInfo("DQMGenericClient") << "makeCumulativeDist() : "
1071  << "No such element '" << cdName << "' found\n";
1072  }
1073  return;
1074  }
1075 
1076  TH1F* cd = element_cd->getTH1F();
1077 
1078  if (!cd) {
1079  if (verbose_ >= 2 || (verbose_ == 1 && !isWildcardUsed_)) {
1080  LogInfo("DQMGenericClient") << "makeCumulativeDist() : "
1081  << "Cannot create TH1F from ME\n";
1082  }
1083  return;
1084  }
1085 
1086  int n_bins = cd->GetNbinsX() + 1;
1087 
1088  if (ascending) {
1089  for (int i = 1; i <= n_bins; i++) {
1090  cd->SetBinContent(i, cd->GetBinContent(i) + cd->GetBinContent(i - 1));
1091  }
1092  } else {
1093  for (int i = n_bins - 1; i >= 0; i--) { // n_bins points to the overflow bin
1094  cd->SetBinContent(i, cd->GetBinContent(i) + cd->GetBinContent(i + 1));
1095  }
1096  }
1097 
1098  return;
1099 }
1100 
1102  DQMStore::IGetter& igetter,
1103  const std::string& startDir,
1104  const std::string& noFlowName) {
1105  if (!igetter.dirExists(startDir)) {
1106  if (verbose_ >= 2 || (verbose_ == 1 && !isWildcardUsed_)) {
1107  LogInfo("DQMGenericClient") << "makeNoFlowDist() : "
1108  << "Cannot find sub-directory " << startDir << endl;
1109  }
1110  return;
1111  }
1112 
1113  ibooker.cd();
1114 
1115  ME* element_noFlow = igetter.get(startDir + "/" + noFlowName);
1116 
1117  if (!element_noFlow) {
1118  if (verbose_ >= 2 || (verbose_ == 1 && !isWildcardUsed_)) {
1119  LogInfo("DQMGenericClient") << "makeNoFlowDist() : "
1120  << "No such element '" << noFlowName << "' found\n";
1121  }
1122  return;
1123  }
1124 
1125  TH1F* noFlow = element_noFlow->getTH1F();
1126 
1127  if (!noFlow) {
1128  if (verbose_ >= 2 || (verbose_ == 1 && !isWildcardUsed_)) {
1129  LogInfo("DQMGenericClient") << "makeNoFlowDist() : "
1130  << "Cannot create TH1F from ME\n";
1131  }
1132  return;
1133  }
1134 
1135  noFlow->AddBinContent(1, noFlow->GetBinContent(0));
1136  noFlow->SetBinContent(0, 0.);
1137 
1138  const auto lastBin = noFlow->GetNbinsX();
1139  noFlow->AddBinContent(lastBin, noFlow->GetBinContent(lastBin + 1));
1140  noFlow->SetBinContent(lastBin + 1, 0.);
1141 }
1142 
1144  TH2F* histo = srcME->getTH2F();
1145 
1146  // Fit slices projected along Y from bins in X
1147  double cont_min = 100; //Minimum number of entries
1148  Int_t binx = histo->GetXaxis()->GetNbins();
1149 
1150  for (int i = 1; i <= binx; i++) {
1151  TString iString(i);
1152  TH1* histoY = histo->ProjectionY(" ", i, i);
1153  double cont = histoY->GetEntries();
1154 
1155  if (cont >= cont_min) {
1156  float minfit = histoY->GetMean() - histoY->GetRMS();
1157  float maxfit = histoY->GetMean() + histoY->GetRMS();
1158 
1159  TF1* fitFcn = new TF1(TString("g") + histo->GetName() + iString, "gaus", minfit, maxfit);
1160  double x1, x2;
1161  fitFcn->GetRange(x1, x2);
1162  //To avoid DQMGenericClient maintains state between fit calls
1163  fitFcn->SetParameters(histoY->Integral(), histoY->GetMean(), histoY->GetRMS());
1164 
1165  histoY->Fit(fitFcn, "QR0 SERIAL", "", x1, x2);
1166 
1167  // histoY->Fit(fitFcn->GetName(),"RME");
1168  double* par = fitFcn->GetParameters();
1169  const double* err = fitFcn->GetParErrors();
1170 
1171  meanME->setBinContent(i, par[1]);
1172  meanME->setBinError(i, err[1]);
1173  // meanME->setBinEntries(i, 1.);
1174  // meanME->setBinError(i,sqrt(err[1]*err[1]+par[1]*par[1]));
1175 
1176  sigmaME->setBinContent(i, par[2]);
1177  sigmaME->setBinError(i, err[2]);
1178  // sigmaME->setBinEntries(i, 1.);
1179  // sigmaME->setBinError(i,sqrt(err[2]*err[2]+par[2]*par[2]));
1180 
1181  if (fitFcn)
1182  delete fitFcn;
1183  if (histoY)
1184  delete histoY;
1185  } else {
1186  if (histoY)
1187  delete histoY;
1188  continue;
1189  }
1190  }
1191 }
1192 
1193 //=================================
1194 
1196  DQMStore::IGetter& igetter,
1197  std::string dir,
1198  std::set<std::string>* myList,
1199  const TString& _pattern = TString("")) {
1200  TString pattern = _pattern;
1201  if (!igetter.dirExists(dir)) {
1202  LogError("DQMGenericClient") << " DQMGenericClient::findAllSubdirectories ==> Missing folder " << dir << " !!!";
1203  return;
1204  }
1205  if (pattern != "") {
1206  if (pattern.Contains(nonPerlWildcard_))
1207  pattern.ReplaceAll("*", ".*");
1208  TPRegexp regexp(pattern);
1209  ibooker.cd(dir);
1210  vector<string> foundDirs = igetter.getSubdirs();
1211  for (vector<string>::const_iterator iDir = foundDirs.begin(); iDir != foundDirs.end(); ++iDir) {
1212  TString dirName = iDir->substr(iDir->rfind('/') + 1, iDir->length());
1213  if (dirName.Contains(regexp))
1214  findAllSubdirectories(ibooker, igetter, *iDir, myList);
1215  }
1216  }
1217  //std::cout << "Looking for directory " << dir ;
1218  else if (igetter.dirExists(dir)) {
1219  //std::cout << "... it exists! Inserting it into the list ";
1220  myList->insert(dir);
1221  //std::cout << "... now list has size " << myList->size() << std::endl;
1222  ibooker.cd(dir);
1223  findAllSubdirectories(ibooker, igetter, dir, myList, "*");
1224  } else {
1225  //std::cout << "... DOES NOT EXIST!!! Skip bogus dir" << std::endl;
1226 
1227  LogInfo("DQMGenericClient") << "Trying to find sub-directories of " << dir << " failed because " << dir
1228  << " does not exist";
1229  }
1230  return;
1231 }
1232 
1233 void DQMGenericClient::generic_eff(TH1* denom, TH1* numer, MonitorElement* efficiencyHist, const EfficType type) {
1234  for (int iBinX = 1; iBinX < denom->GetNbinsX() + 1; iBinX++) {
1235  for (int iBinY = 1; iBinY < denom->GetNbinsY() + 1; iBinY++) {
1236  for (int iBinZ = 1; iBinZ < denom->GetNbinsZ() + 1; iBinZ++) {
1237  int globalBinNum = denom->GetBin(iBinX, iBinY, iBinZ);
1238 
1239  float numerVal = numer->GetBinContent(globalBinNum);
1240  float denomVal = denom->GetBinContent(globalBinNum);
1241 
1242  float effVal = 0;
1243 
1244  // fake eff is in use
1245  if (type == EfficType::fakerate) {
1246  effVal = denomVal ? (1 - numerVal / denomVal) : 0;
1247  } else {
1248  effVal = denomVal ? numerVal / denomVal : 0;
1249  }
1250 
1251  float errVal = 0;
1252  if (type == EfficType::simpleratio) {
1253  // errVal = denomVal ? 1.f/denomVal*effVal*(1+effVal) : 0;
1254  float numerErr = numer->GetBinError(globalBinNum);
1255  float denomErr = denom->GetBinError(globalBinNum);
1256  float denomsq = denomVal * denomVal;
1257  errVal = denomVal ? sqrt(pow(1.f / denomVal * numerErr, 2.0) + pow(numerVal / denomsq * denomErr, 2)) : 0;
1258  } else {
1259  errVal = (denomVal && (effVal <= 1)) ? sqrt(effVal * (1 - effVal) / denomVal) : 0;
1260  }
1261 
1262  LogDebug("DQMGenericClient") << "(iBinX, iBinY, iBinZ) = " << iBinX << ", " << iBinY << ", " << iBinZ
1263  << "), global bin = " << globalBinNum << "eff = " << numerVal << " / "
1264  << denomVal << " = " << effVal << " ... setting the error for that bin ... "
1265  << endl
1266  << endl;
1267 
1268  efficiencyHist->setBinContent(globalBinNum, effVal);
1269  efficiencyHist->setBinError(globalBinNum, errVal);
1270  efficiencyHist->setEfficiencyFlag();
1271  }
1272  }
1273  }
1274 
1275  //efficiencyHist->setMinimum(0.0);
1276  //efficiencyHist->setMaximum(1.0);
1277 }
1278 
1280 
1281 /* vim:set ts=2 sts=2 sw=2 expandtab: */
std::vector< EfficOption > efficOptions_
~FitSlicesYTool()
Destructor.
void dqmEndJob(DQMStore::IBooker &, DQMStore::IGetter &) override
MPlex< T, D1, D2, N > hypot(const MPlex< T, D1, D2, N > &a, const MPlex< T, D1, D2, N > &b)
Definition: Matriplex.h:436
std::vector< ProfileOption > profileOptions_
void dqmEndRun(DQMStore::IBooker &, DQMStore::IGetter &, edm::Run const &, edm::EventSetup const &) override
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:36
vector< string > vstring
Definition: ExoticaDQM.cc:7
virtual bool dirExists(std::string const &path) const
Definition: DQMStore.cc:769
void makeCumulativeDist(DQMStore::IBooker &ibooker, DQMStore::IGetter &igetter, const std::string &startDir, const std::string &cdName, bool ascending=true)
FitSlicesYTool(MonitorElement *me)
Log< level::Error, false > LogError
uint16_t size_type
std::vector< ResolOption > resolOptions_
virtual TH2F * getTH2F() const
Definition: ME.h:11
DQMGenericClient::MonitorElement ME
void getFittedMeanWithError(MonitorElement *me)
Fill the ME with the mean value (with error) of the gaussian fit in each slice.
void getFittedSigma(MonitorElement *me)
Fill the ME with the sigma value of the gaussian fit in each slice.
MonitorElement * bookProfile(TString const &name, TString const &title, int nchX, double lowX, double highX, int, double lowY, double highY, char const *option="s", FUNC onbooking=NOOP())
Definition: DQMStore.h:408
T sqrt(T t)
Definition: SSEVec.h:19
std::vector< std::string > subDirs_
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e< void, edm::EventID const &, edm::Timestamp const & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
Definition: Activities.doc:12
void makeAllPlots(DQMStore::IBooker &, DQMStore::IGetter &)
void normalizeToEntries(DQMStore::IBooker &ibooker, DQMStore::IGetter &igetter, const std::string &startDir, const std::string &histName, const std::string &normHistName)
double f[11][100]
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
void computeResolution(DQMStore::IBooker &ibooker, DQMStore::IGetter &igetter, const std::string &startDir, const std::string &fitMEPrefix, const std::string &fitMETitlePrefix, const std::string &srcMEName)
void makeNoFlowDist(DQMStore::IBooker &ibooker, DQMStore::IGetter &igetter, const std::string &startDir, const std::string &cdName)
def efficSet(nameIn, titleIn, numeratorIn, denominatorIn, typeIn="eff")
void getFittedSigmaWithError(MonitorElement *me)
Fill the ME with the sigma value (with error) of the gaussian fit in each slice.
std::string outputFileName_
void getFittedMean(MonitorElement *me)
Fill the ME with the mean value of the gaussian fit in each slice.
Log< level::Info, false > LogInfo
void findAllSubdirectories(DQMStore::IBooker &ibooker, DQMStore::IGetter &igetter, std::string dir, std::set< std::string > *myList, const TString &pattern)
unsigned int verbose_
virtual void setBinContent(int binx, double content)
set content of bin (1-D)
dqm::legacy::MonitorElement MonitorElement
void dqmEndLuminosityBlock(DQMStore::IBooker &ibooker, DQMStore::IGetter &igetter, const edm::LuminosityBlock &lumiSeg, const edm::EventSetup &c) override
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:221
virtual MonitorElement * get(std::string const &fullpath) const
Definition: DQMStore.cc:712
std::vector< CDOption > cdOptions_
DQM_DEPRECATED void save(std::string const &filename, std::string const &path="")
Definition: DQMStore.cc:824
HLT enums.
void computeEfficiency(DQMStore::IBooker &ibooker, DQMStore::IGetter &igetter, const std::string &startDir, const std::string &efficMEName, const std::string &efficMETitle, const std::string &recoMEName, const std::string &simMEName, const EfficType type=EfficType::efficiency, const bool makeProfile=false)
dqm::harvesting::MonitorElement MonitorElement
std::vector< NoFlowOption > noFlowOptions_
~DQMGenericClient() override
DQMGenericClient(const edm::ParameterSet &pset)
void computeProfile(DQMStore::IBooker &ibooker, DQMStore::IGetter &igetter, const std::string &startDir, const std::string &profileMEName, const std::string &profileMETitle, const std::string &srcMEName)
virtual void setBinError(int binx, double error)
set uncertainty on content of bin (1-D)
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX, FUNC onbooking=NOOP())
Definition: DQMStore.h:98
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4
MonitorElement * book3D(TString const &name, TString const &title, int nchX, double lowX, double highX, int nchY, double lowY, double highY, int nchZ, double lowZ, double highZ, FUNC onbooking=NOOP())
Definition: DQMStore.h:376
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:29
void limitedFit(MonitorElement *srcME, MonitorElement *meanME, MonitorElement *sigmaME)
cont
load Luminosity info ##
Definition: generateEDF.py:620
Definition: Run.h:45
void generic_eff(TH1 *denom, TH1 *numer, MonitorElement *efficiencyHist, const EfficType type=EfficType::efficiency)
#define LogDebug(id)
std::vector< NormOption > normOptions_
virtual DQM_DEPRECATED std::vector< std::string > getSubdirs() const
Definition: DQMStore.cc:739