CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
List of all members | Classes | Public Types | Public Member Functions | Private Member Functions | Private Attributes
DQMGenericClient Class Reference
Inheritance diagram for DQMGenericClient:

Classes

struct  CDOption
 
struct  EfficOption
 
struct  NoFlowOption
 
struct  NormOption
 
struct  ProfileOption
 
struct  ResolOption
 

Public Types

enum  EfficType { EfficType::none = 0, EfficType::efficiency, EfficType::fakerate, EfficType::simpleratio }
 

Public Member Functions

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)
 
void computeProfile (DQMStore::IBooker &ibooker, DQMStore::IGetter &igetter, const std::string &startDir, const std::string &profileMEName, const std::string &profileMETitle, const std::string &srcMEName)
 
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 dqmEndJob (DQMStore::IBooker &, DQMStore::IGetter &) override
 
void dqmEndLuminosityBlock (DQMStore::IBooker &ibooker, DQMStore::IGetter &igetter, const edm::LuminosityBlock &lumiSeg, const edm::EventSetup &c) override
 
void dqmEndRun (DQMStore::IBooker &, DQMStore::IGetter &, edm::Run const &, edm::EventSetup const &) override
 
 DQMGenericClient (const edm::ParameterSet &pset)
 
void limitedFit (MonitorElement *srcME, MonitorElement *meanME, MonitorElement *sigmaME)
 
void makeCumulativeDist (DQMStore::IBooker &ibooker, DQMStore::IGetter &igetter, const std::string &startDir, const std::string &cdName, bool ascending=true)
 
void makeNoFlowDist (DQMStore::IBooker &ibooker, DQMStore::IGetter &igetter, const std::string &startDir, const std::string &cdName)
 
void normalizeToEntries (DQMStore::IBooker &ibooker, DQMStore::IGetter &igetter, const std::string &startDir, const std::string &histName, const std::string &normHistName)
 
 ~DQMGenericClient () override
 

Private Member Functions

void findAllSubdirectories (DQMStore::IBooker &ibooker, DQMStore::IGetter &igetter, std::string dir, std::set< std::string > *myList, const TString &pattern)
 
void generic_eff (TH1 *denom, TH1 *numer, MonitorElement *efficiencyHist, const EfficType type=EfficType::efficiency)
 
void makeAllPlots (DQMStore::IBooker &, DQMStore::IGetter &)
 
void removeMEIfBooked (const std::string &meName, DQMStore::IGetter &igetter)
 

Private Attributes

std::vector< CDOptioncdOptions_
 
std::vector< EfficOptionefficOptions_
 
bool isWildcardUsed_
 
bool makeGlobalEffPlot_
 
TPRegexp metacharacters_
 
std::vector< NoFlowOptionnoFlowOptions_
 
TPRegexp nonPerlWildcard_
 
std::vector< NormOptionnormOptions_
 
std::string outputFileName_
 
std::vector< ProfileOptionprofileOptions_
 
bool resLimitedFit_
 
std::vector< ResolOptionresolOptions_
 
bool runOnEndJob_
 
bool runOnEndLumi_
 
std::vector< std::string > subDirs_
 
DQMStoretheDQM
 
unsigned int verbose_
 

Detailed Description

Definition at line 35 of file DQMGenericClient.cc.

Member Enumeration Documentation

Enumerator
none 
efficiency 
fakerate 
simpleratio 

Definition at line 47 of file DQMGenericClient.cc.

47 { none = 0, efficiency, fakerate, simpleratio };

Constructor & Destructor Documentation

DQMGenericClient::DQMGenericClient ( const edm::ParameterSet pset)

Definition at line 241 of file DQMGenericClient.cc.

References writedatasetfile::args, DQMGenericClient::CDOption::ascending, cdOptions_, DQMGenericClient::EfficOption::denominator, efficiency, efficOptions_, postValidation_cfi::efficSet(), fakerate, edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), DQMGenericClient::EfficOption::isProfile, isWildcardUsed_, makeGlobalEffPlot_, DQMGenericClient::EfficOption::name, DQMGenericClient::ProfileOption::name, DQMGenericClient::NormOption::name, DQMGenericClient::CDOption::name, DQMGenericClient::NoFlowOption::name, DQMGenericClient::ResolOption::namePrefix, noFlowOptions_, none, DQMGenericClient::NormOption::normHistName, normOptions_, DQMGenericClient::EfficOption::numerator, runTheMatrix::opt, or, outputFileName_, profileOptions_, resLimitedFit_, resolOptions_, runOnEndJob_, runOnEndLumi_, simpleratio, DQMGenericClient::ResolOption::srcName, DQMGenericClient::ProfileOption::srcName, subDirs_, DQMGenericClient::EfficOption::title, DQMGenericClient::ProfileOption::title, DQMGenericClient::ResolOption::titlePrefix, DQMGenericClient::EfficOption::type, dqmiodumpindices::typeName, verbose_, and HistogramManager_cfi::VPSet().

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 
274  EfficOption opt;
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")
287  opt.type = EfficType::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) {
296  EfficOption opt;
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")
309  opt.type = EfficType::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 
337  EfficOption opt;
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")
350  opt.type = EfficType::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) {
360  EfficOption opt;
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")
373  opt.type = EfficType::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 
399  ResolOption opt;
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) {
409  ResolOption opt;
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 
434  ProfileOption opt;
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) {
444  ProfileOption opt;
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 
541  NoFlowOption opt;
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) {
549  NoFlowOption opt;
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 }
std::vector< EfficOption > efficOptions_
T getUntrackedParameter(std::string const &, T const &) const
std::vector< ProfileOption > profileOptions_
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::EventIDconst &, edm::Timestampconst & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
Definition: Activities.doc:12
vector< string > vstring
Definition: ExoticaDQM.cc:8
std::vector< ResolOption > resolOptions_
std::vector< std::string > subDirs_
std::string outputFileName_
Log< level::Info, false > LogInfo
unsigned int verbose_
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
std::vector< CDOption > cdOptions_
std::vector< NoFlowOption > noFlowOptions_
std::vector< NormOption > normOptions_
DQMGenericClient::~DQMGenericClient ( )
inlineoverride

Definition at line 38 of file DQMGenericClient.cc.

38 {};

Member Function Documentation

void DQMGenericClient::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 
)

Definition at line 672 of file DQMGenericClient.cc.

References dqm::implementation::IBooker::book1D(), dqm::implementation::IBooker::book2D(), dqm::implementation::IBooker::book3D(), dqm::implementation::IBooker::bookProfile(), dqm::implementation::NavigatorBase::cd(), dqm::implementation::IGetter::dirExists(), efficiency, relativeConstraints::empty, validate-o2o-wbm::f, fakerate, generic_eff(), dqm::implementation::IGetter::get(), mps_fire::i, isWildcardUsed_, makeGlobalEffPlot_, or, dqm::implementation::NavigatorBase::setCurrentFolder(), simpleratio, mathSSE::sqrt(), AlCaHLTBitMon_QueryRunRegistry::string, verbose_, and x.

Referenced by makeAllPlots().

680  {
681  if (!igetter.dirExists(startDir)) {
682  if (verbose_ >= 2 || (verbose_ == 1 && !isWildcardUsed_)) {
683  LogInfo("DQMGenericClient") << "computeEfficiency() : "
684  << "Cannot find sub-directory " << startDir << endl;
685  }
686  return;
687  }
688 
689  ibooker.cd();
690 
691  ME* simME = igetter.get(startDir + "/" + simMEName);
692  ME* recoME = igetter.get(startDir + "/" + recoMEName);
693 
694  if (!simME) {
695  if (verbose_ >= 2 || (verbose_ == 1 && !isWildcardUsed_)) {
696  LogInfo("DQMGenericClient") << "computeEfficiency() : "
697  << "No sim-ME '" << simMEName << "' found\n";
698  }
699  return;
700  }
701 
702  if (!recoME) {
703  if (verbose_ >= 2 || (verbose_ == 1 && !isWildcardUsed_)) {
704  LogInfo("DQMGenericClient") << "computeEfficiency() : "
705  << "No reco-ME '" << recoMEName << "' found\n";
706  }
707  return;
708  }
709 
710  // Treat everything as the base class, TH1
711 
712  TH1* hSim = simME->getTH1();
713  TH1* hReco = recoME->getTH1();
714 
715  if (!hSim || !hReco) {
716  if (verbose_ >= 2 || (verbose_ == 1 && !isWildcardUsed_)) {
717  LogInfo("DQMGenericClient") << "computeEfficiency() : "
718  << "Cannot create TH1 from ME\n";
719  }
720  return;
721  }
722 
723  string efficDir = startDir;
724  string newEfficMEName = efficMEName;
725  string::size_type shiftPos;
726  if (string::npos != (shiftPos = efficMEName.rfind('/'))) {
727  efficDir += "/" + efficMEName.substr(0, shiftPos);
728  newEfficMEName.erase(0, shiftPos + 1);
729  }
730  ibooker.setCurrentFolder(efficDir);
731 
732  if (makeProfile) {
733  TProfile* efficHist = (hReco->GetXaxis()->GetXbins()->GetSize() == 0)
734  ? new TProfile(newEfficMEName.c_str(),
735  efficMETitle.c_str(),
736  hReco->GetXaxis()->GetNbins(),
737  hReco->GetXaxis()->GetXmin(),
738  hReco->GetXaxis()->GetXmax())
739  : new TProfile(newEfficMEName.c_str(),
740  efficMETitle.c_str(),
741  hReco->GetXaxis()->GetNbins(),
742  hReco->GetXaxis()->GetXbins()->GetArray());
743 
744  efficHist->GetXaxis()->SetTitle(hSim->GetXaxis()->GetTitle());
745  efficHist->GetYaxis()->SetTitle(hSim->GetYaxis()->GetTitle());
746 
747  for (int i = 1; i <= hReco->GetNbinsX(); i++) {
748  const double nReco = hReco->GetBinContent(i);
749  const double nSim = hSim->GetBinContent(i);
750 
751  if (!std::string(hSim->GetXaxis()->GetBinLabel(i)).empty())
752  efficHist->GetXaxis()->SetBinLabel(i, hSim->GetXaxis()->GetBinLabel(i));
753 
754  if (nSim == 0 or nReco < 0 or nReco > nSim)
755  continue;
756  const double effVal = nReco / nSim;
757  const double errLo = TEfficiency::ClopperPearson(nSim, nReco, 0.683, false);
758  const double errUp = TEfficiency::ClopperPearson(nSim, nReco, 0.683, true);
759  const double errVal = (effVal - errLo > errUp - effVal) ? effVal - errLo : errUp - effVal;
760  efficHist->SetBinContent(i, effVal);
761  efficHist->SetBinEntries(i, 1);
762  efficHist->SetBinError(i, std::hypot(effVal, errVal));
763  }
764  ibooker.bookProfile(newEfficMEName, efficHist);
765  delete efficHist;
766  }
767 
768  else {
769  TH1* efficHist = (TH1*)hSim->Clone(newEfficMEName.c_str());
770  efficHist->SetTitle(efficMETitle.c_str());
771 
772  // Here is where you have trouble --- you need
773  // to understand what type of hist you have.
774 
775  ME* efficME = nullptr;
776 
777  // Parse the class name
778  // This works, but there might be a better way
779  TClass* myHistClass = efficHist->IsA();
780  TString histClassName = myHistClass->GetName();
781 
782  if (histClassName == "TH1F") {
783  efficME = ibooker.book1D(newEfficMEName, (TH1F*)efficHist);
784  } else if (histClassName == "TH2F") {
785  efficME = ibooker.book2D(newEfficMEName, (TH2F*)efficHist);
786  } else if (histClassName == "TH3F") {
787  efficME = ibooker.book3D(newEfficMEName, (TH3F*)efficHist);
788  }
789 
790  delete efficHist;
791 
792  if (!efficME) {
793  LogInfo("DQMGenericClient") << "computeEfficiency() : "
794  << "Cannot book effic-ME from the DQM\n";
795  return;
796  }
797 
798  // Update: 2009-9-16 slaunwhj
799  // call the most generic efficiency function
800  // works up to 3-d histograms
801 
802  generic_eff(hSim, hReco, efficME, type);
803 
804  // const int nBin = efficME->getNbinsX();
805  // for(int bin = 0; bin <= nBin; ++bin) {
806  // const float nSim = simME ->getBinContent(bin);
807  // const float nReco = recoME->getBinContent(bin);
808  // float eff =0;
809  // if (type=="fake")eff = nSim ? 1-nReco/nSim : 0.;
810  // else eff= nSim ? nReco/nSim : 0.;
811  // const float err = nSim && eff <= 1 ? sqrt(eff*(1-eff)/nSim) : 0.;
812  // efficME->setBinContent(bin, eff);
813  // efficME->setBinError(bin, err);
814  // }
815  efficME->setEntries(simME->getEntries());
816  }
817 
818  // Global efficiency
819  if (makeGlobalEffPlot_) {
820  ME* globalEfficME = igetter.get(efficDir + "/globalEfficiencies");
821  if (!globalEfficME)
822  globalEfficME = ibooker.book1D("globalEfficiencies", "Global efficiencies", 1, 0, 1);
823  if (!globalEfficME) {
824  LogInfo("DQMGenericClient") << "computeEfficiency() : "
825  << "Cannot book globalEffic-ME from the DQM\n";
826  return;
827  }
828  globalEfficME->setEfficiencyFlag();
829  TH1F* hGlobalEffic = globalEfficME->getTH1F();
830  if (!hGlobalEffic) {
831  LogInfo("DQMGenericClient") << "computeEfficiency() : "
832  << "Cannot create TH1F from ME, globalEfficME\n";
833  return;
834  }
835 
836  const float nSimAll = hSim->GetEntries();
837  const float nRecoAll = hReco->GetEntries();
838  float efficAll = 0;
840  efficAll = nSimAll ? nRecoAll / nSimAll : 0;
841  else if (type == EfficType::fakerate)
842  efficAll = nSimAll ? 1 - nRecoAll / nSimAll : 0;
843  float errorAll = 0;
844  if (type == EfficType::simpleratio) {
845  if (nSimAll) {
846  const float x = nRecoAll / nSimAll;
847  errorAll = std::sqrt(1.f / nSimAll * x * (1 + x));
848  }
849  } else
850  errorAll = nSimAll && efficAll < 1 ? sqrt(efficAll * (1 - efficAll) / nSimAll) : 0;
851 
852  const int iBin = hGlobalEffic->Fill(newEfficMEName.c_str(), 0);
853  hGlobalEffic->SetBinContent(iBin, efficAll);
854  hGlobalEffic->SetBinError(iBin, errorAll);
855  }
856 }
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::EventIDconst &, edm::Timestampconst & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
Definition: Activities.doc:12
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:32
virtual bool dirExists(std::string const &path) const
Definition: DQMStore.cc:730
uint16_t size_type
Definition: ME.h:11
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:322
T sqrt(T t)
Definition: SSEVec.h:19
virtual MonitorElement * get(std::string const &fullpath) const
Definition: DQMStore.cc:673
Log< level::Info, false > LogInfo
unsigned int verbose_
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:177
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX, FUNC onbooking=NOOP())
Definition: DQMStore.h:98
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:290
void generic_eff(TH1 *denom, TH1 *numer, MonitorElement *efficiencyHist, const EfficType type=EfficType::efficiency)
void DQMGenericClient::computeProfile ( DQMStore::IBooker ibooker,
DQMStore::IGetter igetter,
const std::string &  startDir,
const std::string &  profileMEName,
const std::string &  profileMETitle,
const std::string &  srcMEName 
)

Definition at line 935 of file DQMGenericClient.cc.

References dqm::implementation::IBooker::bookProfile(), dqm::implementation::NavigatorBase::cd(), dqm::implementation::IGetter::dirExists(), dqm::implementation::IGetter::get(), isWildcardUsed_, dqm::implementation::NavigatorBase::setCurrentFolder(), and verbose_.

Referenced by makeAllPlots().

940  {
941  if (!igetter.dirExists(startDir)) {
942  if (verbose_ >= 2 || (verbose_ == 1 && !isWildcardUsed_)) {
943  LogInfo("DQMGenericClient") << "computeProfile() : "
944  << "Cannot find sub-directory " << startDir << endl;
945  }
946  return;
947  }
948 
949  ibooker.cd();
950 
951  ME* srcME = igetter.get(startDir + "/" + srcMEName);
952  if (!srcME) {
953  if (verbose_ >= 2 || (verbose_ == 1 && !isWildcardUsed_)) {
954  LogInfo("DQMGenericClient") << "computeProfile() : "
955  << "No source ME '" << srcMEName << "' found\n";
956  }
957  return;
958  }
959 
960  TH2F* hSrc = srcME->getTH2F();
961  if (!hSrc) {
962  if (verbose_ >= 2 || (verbose_ == 1 && !isWildcardUsed_)) {
963  LogInfo("DQMGenericClient") << "computeProfile() : "
964  << "Cannot create TH2F from source-ME\n";
965  }
966  return;
967  }
968 
969  string profileDir = startDir;
970  string newProfileMEName = profileMEName;
971  string::size_type shiftPos;
972  if (string::npos != (shiftPos = profileMEName.rfind('/'))) {
973  profileDir += "/" + profileMEName.substr(0, shiftPos);
974  newProfileMEName.erase(0, shiftPos + 1);
975  }
976  ibooker.setCurrentFolder(profileDir);
977 
978  std::unique_ptr<TProfile> profile(hSrc->ProfileX()); // We own the pointer
979  profile->SetTitle(profileMETitle.c_str());
980  ibooker.bookProfile(profileMEName, profile.get()); // ibooker makes a copy
981 }
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:32
virtual bool dirExists(std::string const &path) const
Definition: DQMStore.cc:730
uint16_t size_type
Definition: ME.h:11
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:322
virtual MonitorElement * get(std::string const &fullpath) const
Definition: DQMStore.cc:673
Log< level::Info, false > LogInfo
unsigned int verbose_
void DQMGenericClient::computeResolution ( DQMStore::IBooker ibooker,
DQMStore::IGetter igetter,
const std::string &  startDir,
const std::string &  fitMEPrefix,
const std::string &  fitMETitlePrefix,
const std::string &  srcMEName 
)

Definition at line 858 of file DQMGenericClient.cc.

References dqm::implementation::IBooker::book1D(), dqm::implementation::NavigatorBase::cd(), dqm::implementation::IGetter::dirExists(), dqm::implementation::IGetter::get(), FitSlicesYTool::getFittedMeanWithError(), FitSlicesYTool::getFittedSigmaWithError(), isWildcardUsed_, dqmiolumiharvest::j, limitedFit(), resLimitedFit_, dqm::implementation::NavigatorBase::setCurrentFolder(), and verbose_.

Referenced by makeAllPlots().

863  {
864  if (!igetter.dirExists(startDir)) {
865  if (verbose_ >= 2 || (verbose_ == 1 && !isWildcardUsed_)) {
866  LogInfo("DQMGenericClient") << "computeResolution() : "
867  << "Cannot find sub-directory " << startDir << endl;
868  }
869  return;
870  }
871 
872  ibooker.cd();
873 
874  ME* srcME = igetter.get(startDir + "/" + srcName);
875  if (!srcME) {
876  if (verbose_ >= 2 || (verbose_ == 1 && !isWildcardUsed_)) {
877  LogInfo("DQMGenericClient") << "computeResolution() : "
878  << "No source ME '" << srcName << "' found\n";
879  }
880  return;
881  }
882 
883  TH2F* hSrc = srcME->getTH2F();
884  if (!hSrc) {
885  if (verbose_ >= 2 || (verbose_ == 1 && !isWildcardUsed_)) {
886  LogInfo("DQMGenericClient") << "computeResolution() : "
887  << "Cannot create TH2F from source-ME\n";
888  }
889  return;
890  }
891 
892  const int nBin = hSrc->GetNbinsX();
893 
894  string newDir = startDir;
895  string newPrefix = namePrefix;
896  string::size_type shiftPos;
897  if (string::npos != (shiftPos = namePrefix.rfind('/'))) {
898  newDir += "/" + namePrefix.substr(0, shiftPos);
899  newPrefix.erase(0, shiftPos + 1);
900  }
901 
902  ibooker.setCurrentFolder(newDir);
903 
904  float* lowedgesfloats = new float[nBin + 1];
905  ME* meanME;
906  ME* sigmaME;
907  if (hSrc->GetXaxis()->GetXbins()->GetSize()) {
908  for (int j = 0; j < nBin + 1; ++j)
909  lowedgesfloats[j] = (float)hSrc->GetXaxis()->GetXbins()->GetAt(j);
910  meanME = ibooker.book1D(newPrefix + "_Mean", titlePrefix + " Mean", nBin, lowedgesfloats);
911  sigmaME = ibooker.book1D(newPrefix + "_Sigma", titlePrefix + " Sigma", nBin, lowedgesfloats);
912  } else {
913  meanME = ibooker.book1D(
914  newPrefix + "_Mean", titlePrefix + " Mean", nBin, hSrc->GetXaxis()->GetXmin(), hSrc->GetXaxis()->GetXmax());
915  sigmaME = ibooker.book1D(
916  newPrefix + "_Sigma", titlePrefix + " Sigma", nBin, hSrc->GetXaxis()->GetXmin(), hSrc->GetXaxis()->GetXmax());
917  }
918 
919  if (meanME && sigmaME) {
920  meanME->setEfficiencyFlag();
921  sigmaME->setEfficiencyFlag();
922 
923  if (!resLimitedFit_) {
924  FitSlicesYTool fitTool(srcME);
925  fitTool.getFittedMeanWithError(meanME);
926  fitTool.getFittedSigmaWithError(sigmaME);
928  } else {
929  limitedFit(srcME, meanME, sigmaME);
930  }
931  }
932  delete[] lowedgesfloats;
933 }
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:32
virtual bool dirExists(std::string const &path) const
Definition: DQMStore.cc:730
uint16_t size_type
Definition: ME.h:11
virtual MonitorElement * get(std::string const &fullpath) const
Definition: DQMStore.cc:673
Log< level::Info, false > LogInfo
unsigned int verbose_
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX, FUNC onbooking=NOOP())
Definition: DQMStore.h:98
void limitedFit(MonitorElement *srcME, MonitorElement *meanME, MonitorElement *sigmaME)
void DQMGenericClient::dqmEndJob ( DQMStore::IBooker ,
DQMStore::IGetter  
)
inlineoverride

Definition at line 45 of file DQMGenericClient.cc.

45 {};
void DQMGenericClient::dqmEndLuminosityBlock ( DQMStore::IBooker ibooker,
DQMStore::IGetter igetter,
const edm::LuminosityBlock lumiSeg,
const edm::EventSetup c 
)
override

Definition at line 562 of file DQMGenericClient.cc.

References makeAllPlots(), and runOnEndLumi_.

565  {
566  if (runOnEndLumi_) {
567  makeAllPlots(ibooker, igetter);
568  }
569 }
void makeAllPlots(DQMStore::IBooker &, DQMStore::IGetter &)
void DQMGenericClient::dqmEndRun ( DQMStore::IBooker ibooker,
DQMStore::IGetter igetter,
edm::Run const &  ,
edm::EventSetup const &   
)
override

Definition at line 571 of file DQMGenericClient.cc.

References makeAllPlots(), Utilities::operator, outputFileName_, runOnEndJob_, dqm::implementation::DQMStore::save(), and theDQM.

574  {
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 }
void makeAllPlots(DQMStore::IBooker &, DQMStore::IGetter &)
std::string outputFileName_
DQM_DEPRECATED void save(std::string const &filename, std::string const &path="")
Definition: DQMStore.cc:784
void DQMGenericClient::findAllSubdirectories ( DQMStore::IBooker ibooker,
DQMStore::IGetter igetter,
std::string  dir,
std::set< std::string > *  myList,
const TString &  pattern = TString("") 
)
private

Definition at line 1193 of file DQMGenericClient.cc.

References dqm::implementation::NavigatorBase::cd(), dqm::implementation::IGetter::dirExists(), TrackerOfflineValidation_Dqm_cff::dirName, dqm::implementation::IGetter::getSubdirs(), and nonPerlWildcard_.

Referenced by makeAllPlots().

1197  {
1198  TString pattern = _pattern;
1199  if (!igetter.dirExists(dir)) {
1200  LogError("DQMGenericClient") << " DQMGenericClient::findAllSubdirectories ==> Missing folder " << dir << " !!!";
1201  return;
1202  }
1203  if (pattern != "") {
1204  if (pattern.Contains(nonPerlWildcard_))
1205  pattern.ReplaceAll("*", ".*");
1206  TPRegexp regexp(pattern);
1207  ibooker.cd(dir);
1208  vector<string> foundDirs = igetter.getSubdirs();
1209  for (vector<string>::const_iterator iDir = foundDirs.begin(); iDir != foundDirs.end(); ++iDir) {
1210  TString dirName = iDir->substr(iDir->rfind('/') + 1, iDir->length());
1211  if (dirName.Contains(regexp))
1212  findAllSubdirectories(ibooker, igetter, *iDir, myList);
1213  }
1214  }
1215  //std::cout << "Looking for directory " << dir ;
1216  else if (igetter.dirExists(dir)) {
1217  //std::cout << "... it exists! Inserting it into the list ";
1218  myList->insert(dir);
1219  //std::cout << "... now list has size " << myList->size() << std::endl;
1220  ibooker.cd(dir);
1221  findAllSubdirectories(ibooker, igetter, dir, myList, "*");
1222  } else {
1223  //std::cout << "... DOES NOT EXIST!!! Skip bogus dir" << std::endl;
1224 
1225  LogInfo("DQMGenericClient") << "Trying to find sub-directories of " << dir << " failed because " << dir
1226  << " does not exist";
1227  }
1228  return;
1229 }
virtual DQM_DEPRECATED std::vector< std::string > getSubdirs() const
Definition: DQMStore.cc:700
virtual bool dirExists(std::string const &path) const
Definition: DQMStore.cc:730
Log< level::Error, false > LogError
Log< level::Info, false > LogInfo
void findAllSubdirectories(DQMStore::IBooker &ibooker, DQMStore::IGetter &igetter, std::string dir, std::set< std::string > *myList, const TString &pattern)
void DQMGenericClient::generic_eff ( TH1 *  denom,
TH1 *  numer,
MonitorElement efficiencyHist,
const EfficType  type = EfficType::efficiency 
)
private

Definition at line 1231 of file DQMGenericClient.cc.

References validate-o2o-wbm::f, fakerate, LogDebug, funct::pow(), dqm::impl::MonitorElement::setBinContent(), dqm::impl::MonitorElement::setBinError(), dqm::impl::MonitorElement::setEfficiencyFlag(), simpleratio, and mathSSE::sqrt().

Referenced by computeEfficiency().

1231  {
1232  for (int iBinX = 1; iBinX < denom->GetNbinsX() + 1; iBinX++) {
1233  for (int iBinY = 1; iBinY < denom->GetNbinsY() + 1; iBinY++) {
1234  for (int iBinZ = 1; iBinZ < denom->GetNbinsZ() + 1; iBinZ++) {
1235  int globalBinNum = denom->GetBin(iBinX, iBinY, iBinZ);
1236 
1237  float numerVal = numer->GetBinContent(globalBinNum);
1238  float denomVal = denom->GetBinContent(globalBinNum);
1239 
1240  float effVal = 0;
1241 
1242  // fake eff is in use
1243  if (type == EfficType::fakerate) {
1244  effVal = denomVal ? (1 - numerVal / denomVal) : 0;
1245  } else {
1246  effVal = denomVal ? numerVal / denomVal : 0;
1247  }
1248 
1249  float errVal = 0;
1250  if (type == EfficType::simpleratio) {
1251  // errVal = denomVal ? 1.f/denomVal*effVal*(1+effVal) : 0;
1252  float numerErr = numer->GetBinError(globalBinNum);
1253  float denomErr = denom->GetBinError(globalBinNum);
1254  float denomsq = denomVal * denomVal;
1255  errVal = denomVal ? sqrt(pow(1.f / denomVal * numerErr, 2.0) + pow(numerVal / denomsq * denomErr, 2)) : 0;
1256  } else {
1257  errVal = (denomVal && (effVal <= 1)) ? sqrt(effVal * (1 - effVal) / denomVal) : 0;
1258  }
1259 
1260  LogDebug("DQMGenericClient") << "(iBinX, iBinY, iBinZ) = " << iBinX << ", " << iBinY << ", " << iBinZ
1261  << "), global bin = " << globalBinNum << "eff = " << numerVal << " / "
1262  << denomVal << " = " << effVal << " ... setting the error for that bin ... "
1263  << endl
1264  << endl;
1265 
1266  efficiencyHist->setBinContent(globalBinNum, effVal);
1267  efficiencyHist->setBinError(globalBinNum, errVal);
1268  efficiencyHist->setEfficiencyFlag();
1269  }
1270  }
1271  }
1272 
1273  //efficiencyHist->setMinimum(0.0);
1274  //efficiencyHist->setMaximum(1.0);
1275 }
T sqrt(T t)
Definition: SSEVec.h:19
virtual void setBinContent(int binx, double content)
set content of bin (1-D)
virtual void setBinError(int binx, double error)
set uncertainty on content of bin (1-D)
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:29
#define LogDebug(id)
void DQMGenericClient::limitedFit ( MonitorElement srcME,
MonitorElement meanME,
MonitorElement sigmaME 
)

Definition at line 1138 of file DQMGenericClient.cc.

References generateEDF::cont, submitPVValidationJobs::err, dqm::legacy::MonitorElement::getTH2F(), timingPdfMaker::histo, mps_fire::i, dqm::impl::MonitorElement::setBinContent(), and dqm::impl::MonitorElement::setBinError().

Referenced by computeResolution().

1138  {
1139  TH2F* histo = srcME->getTH2F();
1140 
1141  static int i = 0;
1142  i++;
1143 
1144  // Fit slices projected along Y from bins in X
1145  double cont_min = 100; //Minimum number of entries
1146  Int_t binx = histo->GetXaxis()->GetNbins();
1147 
1148  for (int i = 1; i <= binx; i++) {
1149  TString iString(i);
1150  TH1* histoY = histo->ProjectionY(" ", i, i);
1151  double cont = histoY->GetEntries();
1152 
1153  if (cont >= cont_min) {
1154  float minfit = histoY->GetMean() - histoY->GetRMS();
1155  float maxfit = histoY->GetMean() + histoY->GetRMS();
1156 
1157  TF1* fitFcn = new TF1(TString("g") + histo->GetName() + iString, "gaus", minfit, maxfit);
1158  double x1, x2;
1159  fitFcn->GetRange(x1, x2);
1160  //To avoid DQMGenericClient maintains state between fit calls
1161  fitFcn->SetParameters(histoY->Integral(), histoY->GetMean(), histoY->GetRMS());
1162 
1163  histoY->Fit(fitFcn, "QR0 SERIAL", "", x1, x2);
1164 
1165  // histoY->Fit(fitFcn->GetName(),"RME");
1166  double* par = fitFcn->GetParameters();
1167  const double* err = fitFcn->GetParErrors();
1168 
1169  meanME->setBinContent(i, par[1]);
1170  meanME->setBinError(i, err[1]);
1171  // meanME->setBinEntries(i, 1.);
1172  // meanME->setBinError(i,sqrt(err[1]*err[1]+par[1]*par[1]));
1173 
1174  sigmaME->setBinContent(i, par[2]);
1175  sigmaME->setBinError(i, err[2]);
1176  // sigmaME->setBinEntries(i, 1.);
1177  // sigmaME->setBinError(i,sqrt(err[2]*err[2]+par[2]*par[2]));
1178 
1179  if (fitFcn)
1180  delete fitFcn;
1181  if (histoY)
1182  delete histoY;
1183  } else {
1184  if (histoY)
1185  delete histoY;
1186  continue;
1187  }
1188  }
1189 }
virtual TH2F * getTH2F() const
tuple cont
load Luminosity info ##
Definition: generateEDF.py:628
virtual void setBinContent(int binx, double content)
set content of bin (1-D)
virtual void setBinError(int binx, double error)
set uncertainty on content of bin (1-D)
void DQMGenericClient::makeAllPlots ( DQMStore::IBooker ibooker,
DQMStore::IGetter igetter 
)
private

Definition at line 599 of file DQMGenericClient.cc.

References cdOptions_, computeEfficiency(), computeProfile(), computeResolution(), TrackerOfflineValidation_Dqm_cff::dirName, efficOptions_, findAllSubdirectories(), isWildcardUsed_, makeCumulativeDist(), makeNoFlowDist(), metacharacters_, noFlowOptions_, normalizeToEntries(), normOptions_, profileOptions_, resolOptions_, and subDirs_.

Referenced by dqmEndLuminosityBlock(), and dqmEndRun().

599  {
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 
660  for (vector<ResolOption>::const_iterator resolOption = resolOptions_.begin(); resolOption != resolOptions_.end();
661  ++resolOption) {
663  ibooker, igetter, dirName, resolOption->namePrefix, resolOption->titlePrefix, resolOption->srcName);
664  }
665 
666  for (const auto& profileOption : profileOptions_) {
667  computeProfile(ibooker, igetter, dirName, profileOption.name, profileOption.title, profileOption.srcName);
668  }
669  }
670 }
std::vector< EfficOption > efficOptions_
std::vector< ProfileOption > profileOptions_
vector< string > vstring
Definition: ExoticaDQM.cc:8
void makeCumulativeDist(DQMStore::IBooker &ibooker, DQMStore::IGetter &igetter, const std::string &startDir, const std::string &cdName, bool ascending=true)
uint16_t size_type
std::vector< ResolOption > resolOptions_
std::vector< std::string > subDirs_
void normalizeToEntries(DQMStore::IBooker &ibooker, DQMStore::IGetter &igetter, const std::string &startDir, const std::string &histName, const std::string &normHistName)
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)
void findAllSubdirectories(DQMStore::IBooker &ibooker, DQMStore::IGetter &igetter, std::string dir, std::set< std::string > *myList, const TString &pattern)
std::vector< CDOption > cdOptions_
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)
std::vector< NoFlowOption > noFlowOptions_
void computeProfile(DQMStore::IBooker &ibooker, DQMStore::IGetter &igetter, const std::string &startDir, const std::string &profileMEName, const std::string &profileMETitle, const std::string &srcMEName)
std::vector< NormOption > normOptions_
void DQMGenericClient::makeCumulativeDist ( DQMStore::IBooker ibooker,
DQMStore::IGetter igetter,
const std::string &  startDir,
const std::string &  cdName,
bool  ascending = true 
)

Definition at line 1046 of file DQMGenericClient.cc.

References dqm::implementation::NavigatorBase::cd(), hippyaddtobaddatafiles::cd(), dqm::implementation::IGetter::dirExists(), dqm::implementation::IGetter::get(), mps_fire::i, isWildcardUsed_, and verbose_.

Referenced by makeAllPlots().

1050  {
1051  if (!igetter.dirExists(startDir)) {
1052  if (verbose_ >= 2 || (verbose_ == 1 && !isWildcardUsed_)) {
1053  LogInfo("DQMGenericClient") << "makeCumulativeDist() : "
1054  << "Cannot find sub-directory " << startDir << endl;
1055  }
1056  return;
1057  }
1058 
1059  ibooker.cd();
1060 
1061  ME* element_cd = igetter.get(startDir + "/" + cdName);
1062 
1063  if (!element_cd) {
1064  if (verbose_ >= 2 || (verbose_ == 1 && !isWildcardUsed_)) {
1065  LogInfo("DQMGenericClient") << "makeCumulativeDist() : "
1066  << "No such element '" << cdName << "' found\n";
1067  }
1068  return;
1069  }
1070 
1071  TH1F* cd = element_cd->getTH1F();
1072 
1073  if (!cd) {
1074  if (verbose_ >= 2 || (verbose_ == 1 && !isWildcardUsed_)) {
1075  LogInfo("DQMGenericClient") << "makeCumulativeDist() : "
1076  << "Cannot create TH1F from ME\n";
1077  }
1078  return;
1079  }
1080 
1081  int n_bins = cd->GetNbinsX() + 1;
1082 
1083  if (ascending) {
1084  for (int i = 1; i <= n_bins; i++) {
1085  cd->SetBinContent(i, cd->GetBinContent(i) + cd->GetBinContent(i - 1));
1086  }
1087  } else {
1088  for (int i = n_bins - 1; i >= 0; i--) { // n_bins points to the overflow bin
1089  cd->SetBinContent(i, cd->GetBinContent(i) + cd->GetBinContent(i + 1));
1090  }
1091  }
1092 
1093  return;
1094 }
virtual bool dirExists(std::string const &path) const
Definition: DQMStore.cc:730
Definition: ME.h:11
virtual MonitorElement * get(std::string const &fullpath) const
Definition: DQMStore.cc:673
Log< level::Info, false > LogInfo
unsigned int verbose_
void DQMGenericClient::makeNoFlowDist ( DQMStore::IBooker ibooker,
DQMStore::IGetter igetter,
const std::string &  startDir,
const std::string &  cdName 
)

Definition at line 1096 of file DQMGenericClient.cc.

References dqm::implementation::NavigatorBase::cd(), dqm::implementation::IGetter::dirExists(), dqm::implementation::IGetter::get(), isWildcardUsed_, and verbose_.

Referenced by makeAllPlots().

1099  {
1100  if (!igetter.dirExists(startDir)) {
1101  if (verbose_ >= 2 || (verbose_ == 1 && !isWildcardUsed_)) {
1102  LogInfo("DQMGenericClient") << "makeNoFlowDist() : "
1103  << "Cannot find sub-directory " << startDir << endl;
1104  }
1105  return;
1106  }
1107 
1108  ibooker.cd();
1109 
1110  ME* element_noFlow = igetter.get(startDir + "/" + noFlowName);
1111 
1112  if (!element_noFlow) {
1113  if (verbose_ >= 2 || (verbose_ == 1 && !isWildcardUsed_)) {
1114  LogInfo("DQMGenericClient") << "makeNoFlowDist() : "
1115  << "No such element '" << noFlowName << "' found\n";
1116  }
1117  return;
1118  }
1119 
1120  TH1F* noFlow = element_noFlow->getTH1F();
1121 
1122  if (!noFlow) {
1123  if (verbose_ >= 2 || (verbose_ == 1 && !isWildcardUsed_)) {
1124  LogInfo("DQMGenericClient") << "makeNoFlowDist() : "
1125  << "Cannot create TH1F from ME\n";
1126  }
1127  return;
1128  }
1129 
1130  noFlow->AddBinContent(1, noFlow->GetBinContent(0));
1131  noFlow->SetBinContent(0, 0.);
1132 
1133  const auto lastBin = noFlow->GetNbinsX();
1134  noFlow->AddBinContent(lastBin, noFlow->GetBinContent(lastBin + 1));
1135  noFlow->SetBinContent(lastBin + 1, 0.);
1136 }
virtual bool dirExists(std::string const &path) const
Definition: DQMStore.cc:730
Definition: ME.h:11
virtual MonitorElement * get(std::string const &fullpath) const
Definition: DQMStore.cc:673
Log< level::Info, false > LogInfo
unsigned int verbose_
void DQMGenericClient::normalizeToEntries ( DQMStore::IBooker ibooker,
DQMStore::IGetter igetter,
const std::string &  startDir,
const std::string &  histName,
const std::string &  normHistName 
)

Definition at line 983 of file DQMGenericClient.cc.

References dqm::implementation::NavigatorBase::cd(), dqm::implementation::IGetter::dirExists(), dqm::implementation::IGetter::get(), gpuVertexFinder::hist, isWildcardUsed_, and verbose_.

Referenced by makeAllPlots().

987  {
988  if (!igetter.dirExists(startDir)) {
989  if (verbose_ >= 2 || (verbose_ == 1 && !isWildcardUsed_)) {
990  LogInfo("DQMGenericClient") << "normalizeToEntries() : "
991  << "Cannot find sub-directory " << startDir << endl;
992  }
993  return;
994  }
995 
996  ibooker.cd();
997 
998  ME* element = igetter.get(startDir + "/" + histName);
999  ME* normME = igetter.get(startDir + "/" + normHistName);
1000 
1001  if (!element) {
1002  if (verbose_ >= 2 || (verbose_ == 1 && !isWildcardUsed_)) {
1003  LogInfo("DQMGenericClient") << "normalizeToEntries() : "
1004  << "No such element '" << histName << "' found\n";
1005  }
1006  return;
1007  }
1008 
1009  if (!normME) {
1010  if (verbose_ >= 2 || (verbose_ == 1 && !isWildcardUsed_)) {
1011  LogInfo("DQMGenericClient") << "normalizeToEntries() : "
1012  << "No such element '" << normHistName << "' found\n";
1013  }
1014  return;
1015  }
1016 
1017  TH1F* hist = element->getTH1F();
1018  if (!hist) {
1019  if (verbose_ >= 2 || (verbose_ == 1 && !isWildcardUsed_)) {
1020  LogInfo("DQMGenericClient") << "normalizeToEntries() : "
1021  << "Cannot create TH1F from ME\n";
1022  }
1023  return;
1024  }
1025 
1026  TH1F* normHist = normME->getTH1F();
1027  if (!normHist) {
1028  if (verbose_ >= 2 || (verbose_ == 1 && !isWildcardUsed_)) {
1029  LogInfo("DQMGenericClient") << "normalizeToEntries() : "
1030  << "Cannot create TH1F from ME\n";
1031  }
1032  return;
1033  }
1034 
1035  const double entries = normHist->GetEntries();
1036  if (entries != 0) {
1037  hist->Scale(1. / entries);
1038  } else {
1039  LogInfo("DQMGenericClient") << "normalizeToEntries() : "
1040  << "Zero entries in histogram\n";
1041  }
1042 
1043  return;
1044 }
virtual bool dirExists(std::string const &path) const
Definition: DQMStore.cc:730
Definition: ME.h:11
virtual MonitorElement * get(std::string const &fullpath) const
Definition: DQMStore.cc:673
__shared__ Hist hist
Log< level::Info, false > LogInfo
unsigned int verbose_
void DQMGenericClient::removeMEIfBooked ( const std::string &  meName,
DQMStore::IGetter igetter 
)
private

Member Data Documentation

std::vector<CDOption> DQMGenericClient::cdOptions_
private

Definition at line 136 of file DQMGenericClient.cc.

Referenced by DQMGenericClient(), and makeAllPlots().

std::vector<EfficOption> DQMGenericClient::efficOptions_
private

Definition at line 132 of file DQMGenericClient.cc.

Referenced by DQMGenericClient(), and makeAllPlots().

bool DQMGenericClient::isWildcardUsed_
private
bool DQMGenericClient::makeGlobalEffPlot_
private

Definition at line 124 of file DQMGenericClient.cc.

Referenced by computeEfficiency(), and DQMGenericClient().

TPRegexp DQMGenericClient::metacharacters_
private

Definition at line 119 of file DQMGenericClient.cc.

Referenced by makeAllPlots().

std::vector<NoFlowOption> DQMGenericClient::noFlowOptions_
private

Definition at line 137 of file DQMGenericClient.cc.

Referenced by DQMGenericClient(), and makeAllPlots().

TPRegexp DQMGenericClient::nonPerlWildcard_
private

Definition at line 120 of file DQMGenericClient.cc.

Referenced by findAllSubdirectories().

std::vector<NormOption> DQMGenericClient::normOptions_
private

Definition at line 135 of file DQMGenericClient.cc.

Referenced by DQMGenericClient(), and makeAllPlots().

std::string DQMGenericClient::outputFileName_
private

Definition at line 130 of file DQMGenericClient.cc.

Referenced by dqmEndRun(), and DQMGenericClient().

std::vector<ProfileOption> DQMGenericClient::profileOptions_
private

Definition at line 134 of file DQMGenericClient.cc.

Referenced by DQMGenericClient(), and makeAllPlots().

bool DQMGenericClient::resLimitedFit_
private

Definition at line 126 of file DQMGenericClient.cc.

Referenced by computeResolution(), and DQMGenericClient().

std::vector<ResolOption> DQMGenericClient::resolOptions_
private

Definition at line 133 of file DQMGenericClient.cc.

Referenced by DQMGenericClient(), and makeAllPlots().

bool DQMGenericClient::runOnEndJob_
private

Definition at line 123 of file DQMGenericClient.cc.

Referenced by dqmEndRun(), and DQMGenericClient().

bool DQMGenericClient::runOnEndLumi_
private

Definition at line 122 of file DQMGenericClient.cc.

Referenced by dqmEndLuminosityBlock(), and DQMGenericClient().

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

Definition at line 129 of file DQMGenericClient.cc.

Referenced by DQMGenericClient(), and makeAllPlots().

DQMStore* DQMGenericClient::theDQM
private

Definition at line 128 of file DQMGenericClient.cc.

Referenced by dqmEndRun().

unsigned int DQMGenericClient::verbose_
private