CMS 3D CMS Logo

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

◆ EfficType

Enumerator
none 
efficiency 
fakerate 
simpleratio 

Definition at line 47 of file DQMGenericClient.cc.

Constructor & Destructor Documentation

◆ DQMGenericClient()

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

Definition at line 241 of file DQMGenericClient.cc.

References writedatasetfile::args, cdOptions_, efficiency, efficOptions_, postValidation_cfi::efficSet(), fakerate, isWildcardUsed_, makeGlobalEffPlot_, noFlowOptions_, none, normOptions_, runTheMatrix::opt, or, outputFileName_, profileOptions_, muonDTDigis_cfi::pset, resLimitedFit_, resolOptions_, runOnEndJob_, runOnEndLumi_, simpleratio, subDirs_, 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")
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")
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")
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")
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_
std::vector< ProfileOption > profileOptions_
vector< string > vstring
Definition: ExoticaDQM.cc:8
std::vector< ResolOption > resolOptions_
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
def efficSet(nameIn, titleIn, numeratorIn, denominatorIn, typeIn="eff")
std::string outputFileName_
Log< level::Info, false > LogInfo
unsigned int verbose_
std::vector< CDOption > cdOptions_
std::vector< NoFlowOption > noFlowOptions_
std::vector< NormOption > normOptions_

◆ ~DQMGenericClient()

DQMGenericClient::~DQMGenericClient ( )
inlineoverride

Definition at line 38 of file DQMGenericClient.cc.

38 {};

Member Function Documentation

◆ computeEfficiency()

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 677 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, 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().

685  {
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 }
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:36
virtual bool dirExists(std::string const &path) const
Definition: DQMStore.cc:747
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:399
T sqrt(T t)
Definition: SSEVec.h:19
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
double f[11][100]
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:212
virtual MonitorElement * get(std::string const &fullpath) const
Definition: DQMStore.cc:690
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:367
void generic_eff(TH1 *denom, TH1 *numer, MonitorElement *efficiencyHist, const EfficType type=EfficType::efficiency)

◆ computeProfile()

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 940 of file DQMGenericClient.cc.

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

Referenced by makeAllPlots().

945  {
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 }
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:36
virtual bool dirExists(std::string const &path) const
Definition: DQMStore.cc:747
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:399
Log< level::Info, false > LogInfo
unsigned int verbose_
virtual MonitorElement * get(std::string const &fullpath) const
Definition: DQMStore.cc:690

◆ computeResolution()

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 863 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(), postValidation_cfi::namePrefix, PFElectronDQMAnalyzer_cfi::nBin, resLimitedFit_, dqm::implementation::NavigatorBase::setCurrentFolder(), postValidation_cfi::srcName, L1TdeStage2uGMT_cff::titlePrefix, and verbose_.

Referenced by makeAllPlots().

868  {
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 }
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:36
virtual bool dirExists(std::string const &path) const
Definition: DQMStore.cc:747
uint16_t size_type
Definition: ME.h:11
Log< level::Info, false > LogInfo
unsigned int verbose_
virtual MonitorElement * get(std::string const &fullpath) const
Definition: DQMStore.cc:690
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)

◆ dqmEndJob()

void DQMGenericClient::dqmEndJob ( DQMStore::IBooker ,
DQMStore::IGetter  
)
inlineoverride

Definition at line 45 of file DQMGenericClient.cc.

45 {};

◆ dqmEndLuminosityBlock()

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 &)

◆ dqmEndRun()

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:801

◆ findAllSubdirectories()

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 1198 of file DQMGenericClient.cc.

References dqm::implementation::NavigatorBase::cd(), DeadROC_duringRun::dir, dqm::implementation::IGetter::dirExists(), TrackerOfflineValidation_Dqm_cff::dirName, dqm::implementation::IGetter::getSubdirs(), PatBasicFWLiteJetAnalyzer_Selector_cfg::myList, nonPerlWildcard_, topSingleLeptonDQM_PU_cfi::pattern, and fetchall_from_DQM_v2::regexp.

Referenced by makeAllPlots().

1202  {
1203  TString pattern = _pattern;
1204  if (!igetter.dirExists(dir)) {
1205  LogError("DQMGenericClient") << " DQMGenericClient::findAllSubdirectories ==> Missing folder " << dir << " !!!";
1206  return;
1207  }
1208  if (pattern != "") {
1209  if (pattern.Contains(nonPerlWildcard_))
1210  pattern.ReplaceAll("*", ".*");
1211  TPRegexp regexp(pattern);
1212  ibooker.cd(dir);
1213  vector<string> foundDirs = igetter.getSubdirs();
1214  for (vector<string>::const_iterator iDir = foundDirs.begin(); iDir != foundDirs.end(); ++iDir) {
1215  TString dirName = iDir->substr(iDir->rfind('/') + 1, iDir->length());
1216  if (dirName.Contains(regexp))
1217  findAllSubdirectories(ibooker, igetter, *iDir, myList);
1218  }
1219  }
1220  //std::cout << "Looking for directory " << dir ;
1221  else if (igetter.dirExists(dir)) {
1222  //std::cout << "... it exists! Inserting it into the list ";
1223  myList->insert(dir);
1224  //std::cout << "... now list has size " << myList->size() << std::endl;
1225  ibooker.cd(dir);
1226  findAllSubdirectories(ibooker, igetter, dir, myList, "*");
1227  } else {
1228  //std::cout << "... DOES NOT EXIST!!! Skip bogus dir" << std::endl;
1229 
1230  LogInfo("DQMGenericClient") << "Trying to find sub-directories of " << dir << " failed because " << dir
1231  << " does not exist";
1232  }
1233  return;
1234 }
virtual bool dirExists(std::string const &path) const
Definition: DQMStore.cc:747
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)
virtual DQM_DEPRECATED std::vector< std::string > getSubdirs() const
Definition: DQMStore.cc:717

◆ generic_eff()

void DQMGenericClient::generic_eff ( TH1 *  denom,
TH1 *  numer,
MonitorElement efficiencyHist,
const EfficType  type = EfficType::efficiency 
)
private

Definition at line 1236 of file DQMGenericClient.cc.

References makePileupJSON::denom, f, fakerate, LogDebug, funct::pow(), dqm::impl::MonitorElement::setBinContent(), dqm::impl::MonitorElement::setBinError(), dqm::impl::MonitorElement::setEfficiencyFlag(), simpleratio, and mathSSE::sqrt().

Referenced by computeEfficiency().

1236  {
1237  for (int iBinX = 1; iBinX < denom->GetNbinsX() + 1; iBinX++) {
1238  for (int iBinY = 1; iBinY < denom->GetNbinsY() + 1; iBinY++) {
1239  for (int iBinZ = 1; iBinZ < denom->GetNbinsZ() + 1; iBinZ++) {
1240  int globalBinNum = denom->GetBin(iBinX, iBinY, iBinZ);
1241 
1242  float numerVal = numer->GetBinContent(globalBinNum);
1243  float denomVal = denom->GetBinContent(globalBinNum);
1244 
1245  float effVal = 0;
1246 
1247  // fake eff is in use
1248  if (type == EfficType::fakerate) {
1249  effVal = denomVal ? (1 - numerVal / denomVal) : 0;
1250  } else {
1251  effVal = denomVal ? numerVal / denomVal : 0;
1252  }
1253 
1254  float errVal = 0;
1255  if (type == EfficType::simpleratio) {
1256  // errVal = denomVal ? 1.f/denomVal*effVal*(1+effVal) : 0;
1257  float numerErr = numer->GetBinError(globalBinNum);
1258  float denomErr = denom->GetBinError(globalBinNum);
1259  float denomsq = denomVal * denomVal;
1260  errVal = denomVal ? sqrt(pow(1.f / denomVal * numerErr, 2.0) + pow(numerVal / denomsq * denomErr, 2)) : 0;
1261  } else {
1262  errVal = (denomVal && (effVal <= 1)) ? sqrt(effVal * (1 - effVal) / denomVal) : 0;
1263  }
1264 
1265  LogDebug("DQMGenericClient") << "(iBinX, iBinY, iBinZ) = " << iBinX << ", " << iBinY << ", " << iBinZ
1266  << "), global bin = " << globalBinNum << "eff = " << numerVal << " / "
1267  << denomVal << " = " << effVal << " ... setting the error for that bin ... "
1268  << endl
1269  << endl;
1270 
1271  efficiencyHist->setBinContent(globalBinNum, effVal);
1272  efficiencyHist->setBinError(globalBinNum, errVal);
1273  efficiencyHist->setEfficiencyFlag();
1274  }
1275  }
1276  }
1277 
1278  //efficiencyHist->setMinimum(0.0);
1279  //efficiencyHist->setMaximum(1.0);
1280 }
T sqrt(T t)
Definition: SSEVec.h:19
double f[11][100]
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)

◆ limitedFit()

void DQMGenericClient::limitedFit ( MonitorElement srcME,
MonitorElement meanME,
MonitorElement sigmaME 
)

Definition at line 1143 of file DQMGenericClient.cc.

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

Referenced by computeResolution().

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

◆ makeAllPlots()

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(), dqm::implementation::IGetter::get(), isWildcardUsed_, makeCumulativeDist(), makeGlobalEffPlot_, makeNoFlowDist(), metacharacters_, noFlowOptions_, normalizeToEntries(), normOptions_, topSingleLeptonDQM_PU_cfi::pattern, profileOptions_, resolOptions_, PostProcessorHcalIsoTrack_cfi::subDir, 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  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 }
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_
Definition: ME.h:11
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)
virtual MonitorElement * get(std::string const &fullpath) const
Definition: DQMStore.cc:690
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_

◆ makeCumulativeDist()

void DQMGenericClient::makeCumulativeDist ( DQMStore::IBooker ibooker,
DQMStore::IGetter igetter,
const std::string &  startDir,
const std::string &  cdName,
bool  ascending = true 
)

Definition at line 1051 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().

1055  {
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 }
virtual bool dirExists(std::string const &path) const
Definition: DQMStore.cc:747
Definition: ME.h:11
Log< level::Info, false > LogInfo
unsigned int verbose_
virtual MonitorElement * get(std::string const &fullpath) const
Definition: DQMStore.cc:690

◆ makeNoFlowDist()

void DQMGenericClient::makeNoFlowDist ( DQMStore::IBooker ibooker,
DQMStore::IGetter igetter,
const std::string &  startDir,
const std::string &  cdName 
)

Definition at line 1101 of file DQMGenericClient.cc.

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

Referenced by makeAllPlots().

1104  {
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 }
virtual bool dirExists(std::string const &path) const
Definition: DQMStore.cc:747
Definition: ME.h:11
Log< level::Info, false > LogInfo
unsigned int verbose_
virtual MonitorElement * get(std::string const &fullpath) const
Definition: DQMStore.cc:690

◆ normalizeToEntries()

void DQMGenericClient::normalizeToEntries ( DQMStore::IBooker ibooker,
DQMStore::IGetter igetter,
const std::string &  startDir,
const std::string &  histName,
const std::string &  normHistName 
)

Definition at line 988 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().

992  {
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 }
virtual bool dirExists(std::string const &path) const
Definition: DQMStore.cc:747
Definition: ME.h:11
__shared__ Hist hist
Log< level::Info, false > LogInfo
unsigned int verbose_
virtual MonitorElement * get(std::string const &fullpath) const
Definition: DQMStore.cc:690

◆ removeMEIfBooked()

void DQMGenericClient::removeMEIfBooked ( const std::string &  meName,
DQMStore::IGetter igetter 
)
private

Member Data Documentation

◆ cdOptions_

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

Definition at line 136 of file DQMGenericClient.cc.

Referenced by DQMGenericClient(), and makeAllPlots().

◆ efficOptions_

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

Definition at line 132 of file DQMGenericClient.cc.

Referenced by DQMGenericClient(), and makeAllPlots().

◆ isWildcardUsed_

bool DQMGenericClient::isWildcardUsed_
private

◆ makeGlobalEffPlot_

bool DQMGenericClient::makeGlobalEffPlot_
private

Definition at line 124 of file DQMGenericClient.cc.

Referenced by computeEfficiency(), DQMGenericClient(), and makeAllPlots().

◆ metacharacters_

TPRegexp DQMGenericClient::metacharacters_
private

Definition at line 119 of file DQMGenericClient.cc.

Referenced by makeAllPlots().

◆ noFlowOptions_

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

Definition at line 137 of file DQMGenericClient.cc.

Referenced by DQMGenericClient(), and makeAllPlots().

◆ nonPerlWildcard_

TPRegexp DQMGenericClient::nonPerlWildcard_
private

Definition at line 120 of file DQMGenericClient.cc.

Referenced by findAllSubdirectories().

◆ normOptions_

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

Definition at line 135 of file DQMGenericClient.cc.

Referenced by DQMGenericClient(), and makeAllPlots().

◆ outputFileName_

std::string DQMGenericClient::outputFileName_
private

Definition at line 130 of file DQMGenericClient.cc.

Referenced by dqmEndRun(), and DQMGenericClient().

◆ profileOptions_

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

Definition at line 134 of file DQMGenericClient.cc.

Referenced by DQMGenericClient(), and makeAllPlots().

◆ resLimitedFit_

bool DQMGenericClient::resLimitedFit_
private

Definition at line 126 of file DQMGenericClient.cc.

Referenced by computeResolution(), and DQMGenericClient().

◆ resolOptions_

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

Definition at line 133 of file DQMGenericClient.cc.

Referenced by DQMGenericClient(), and makeAllPlots().

◆ runOnEndJob_

bool DQMGenericClient::runOnEndJob_
private

Definition at line 123 of file DQMGenericClient.cc.

Referenced by dqmEndRun(), and DQMGenericClient().

◆ runOnEndLumi_

bool DQMGenericClient::runOnEndLumi_
private

Definition at line 122 of file DQMGenericClient.cc.

Referenced by dqmEndLuminosityBlock(), and DQMGenericClient().

◆ subDirs_

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

Definition at line 129 of file DQMGenericClient.cc.

Referenced by DQMGenericClient(), and makeAllPlots().

◆ theDQM

DQMStore* DQMGenericClient::theDQM
private

Definition at line 128 of file DQMGenericClient.cc.

Referenced by dqmEndRun().

◆ verbose_

unsigned int DQMGenericClient::verbose_
private