CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes
DQMStoreStats Class Reference
Inheritance diagram for DQMStoreStats:
edm::one::EDAnalyzer< edm::one::WatchRuns, edm::one::WatchLuminosityBlocks > edm::one::EDAnalyzerBase edm::EDConsumerBase

Public Types

enum  statsMode { considerAllME = 0, considerOnlyLumiProductME = 1 }
 
- Public Types inherited from edm::one::EDAnalyzerBase
typedef EDAnalyzerBase ModuleType
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 

Public Member Functions

 DQMStoreStats (const edm::ParameterSet &)
 
 ~DQMStoreStats () override=default
 
- Public Member Functions inherited from edm::one::EDAnalyzer< edm::one::WatchRuns, edm::one::WatchLuminosityBlocks >
 EDAnalyzer ()=default
 
 EDAnalyzer (const EDAnalyzer &)=delete
 
SerialTaskQueueglobalLuminosityBlocksQueue () final
 
SerialTaskQueueglobalRunsQueue () final
 
const EDAnalyzeroperator= (const EDAnalyzer &)=delete
 
bool wantsGlobalLuminosityBlocks () const final
 
bool wantsGlobalRuns () const final
 
bool wantsInputProcessBlocks () const final
 
bool wantsProcessBlocks () const final
 
- Public Member Functions inherited from edm::one::EDAnalyzerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzerBase ()
 
ModuleDescription const & moduleDescription () const
 
bool wantsStreamLuminosityBlocks () const
 
bool wantsStreamRuns () const
 
 ~EDAnalyzerBase () override
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ESProxyIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESProxyIndex > const & esGetTokenIndicesVector (edm::Transition iTrans) const
 
std::vector< ESRecordIndex > const & esGetTokenRecordIndicesVector (edm::Transition iTrans) const
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::array< std::vector< ModuleDescription const *> *, NumBranchTypes > &modulesAll, std::vector< ModuleProcessName > &modulesInPreviousProcesses, ProductRegistry const &preg, std::map< std::string, ModuleDescription const *> const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void selectInputProcessBlocks (ProductRegistry const &productRegistry, ProcessBlockHelperBase const &processBlockHelperBase)
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProxyIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Protected Member Functions

void analyze (const edm::Event &e, const edm::EventSetup &c) override
 
void beginJob () override
 
void beginLuminosityBlock (const edm::LuminosityBlock &lumiSeg, const edm::EventSetup &c) override
 
void beginRun (const edm::Run &r, const edm::EventSetup &c) override
 
void endJob () override
 
void endLuminosityBlock (const edm::LuminosityBlock &lumiSeg, const edm::EventSetup &c) override
 
void endRun (const edm::Run &r, const edm::EventSetup &c) override
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< Bconsumes (edm::InputTag tag) noexcept
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<Transition Tr = Transition::Event>
constexpr auto esConsumes ()
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag)
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
void resetItemsToGetFrom (BranchType iType)
 

Private Member Functions

void calcIgProfDump (Folder &)
 
int calcstats (int)
 
void dumpMemoryProfile ()
 
void print ()
 
std::pair< unsigned int, unsigned int > readMemoryEntry () const
 

Private Attributes

DQMStoredbe_
 
bool dumpMemHistory_
 
bool dumpToFWJR_
 
bool isOpenProcFileSuccessful_
 
int maxbinsglobal_
 
std::string maxbinsmeglobal_
 
std::string maxbinsmesubsys_
 
int maxbinssubsys_
 
std::vector< std::pair< time_t, unsigned int > > memoryHistoryVector_
 
int nbinsglobal_
 
int nbinssubsys_
 
int nmeglobal_
 
int nmesubsys_
 
edm::ParameterSet parameters_
 
std::string pathnamematch_
 
std::stringstream procFileName_
 
bool runineventloop_
 
bool runonendjob_
 
bool runonendlumi_
 
bool runonendrun_
 
time_t startingTime_
 
int statsdepth_
 
std::string subfolder_
 
std::string subsystem_
 
int verbose_
 

Additional Inherited Members

- Static Public Member Functions inherited from edm::one::EDAnalyzerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 

Detailed Description

DQMStoreStats itself

Definition at line 312 of file DQMStoreStats.cc.

Member Enumeration Documentation

◆ statsMode

Enumerator
considerAllME 
considerOnlyLumiProductME 

Definition at line 317 of file DQMStoreStats.cc.

Constructor & Destructor Documentation

◆ DQMStoreStats()

DQMStoreStats::DQMStoreStats ( const edm::ParameterSet ps)

Definition at line 413 of file DQMStoreStats.cc.

References dumpMemHistory_, dumpToFWJR_, edm::ParameterSet::getUntrackedParameter(), parameters_, pathnamematch_, runineventloop_, runonendjob_, runonendlumi_, runonendrun_, startingTime_, statsdepth_, AlCaHLTBitMon_QueryRunRegistry::string, protons_cff::time, and verbose_.

414  : subsystem_(""),
415  subfolder_(""),
416  nbinsglobal_(0),
417  nbinssubsys_(0),
418  nmeglobal_(0),
419  nmesubsys_(0),
420  maxbinsglobal_(0),
421  maxbinssubsys_(0),
422  maxbinsmeglobal_(""),
423  maxbinsmesubsys_(""),
424  statsdepth_(1),
425  pathnamematch_(""),
426  verbose_(0) {
427  parameters_ = ps;
429  statsdepth_ = ps.getUntrackedParameter<int>("statsDepth", statsdepth_);
430  verbose_ = ps.getUntrackedParameter<int>("verbose", verbose_);
431  dumpMemHistory_ = ps.getUntrackedParameter<bool>("dumpMemoryHistory", false);
432  runonendrun_ = ps.getUntrackedParameter<bool>("runOnEndRun", true);
433  runonendjob_ = ps.getUntrackedParameter<bool>("runOnEndJob", false);
434  runonendlumi_ = ps.getUntrackedParameter<bool>("runOnEndLumi", false);
435  runineventloop_ = ps.getUntrackedParameter<bool>("runInEventLoop", false);
436  dumpToFWJR_ = ps.getUntrackedParameter<bool>("dumpToFWJR", false);
437 
438  startingTime_ = time(nullptr);
439 }
time_t startingTime_
T getUntrackedParameter(std::string const &, T const &) const
std::string subsystem_
std::string maxbinsmeglobal_
std::string pathnamematch_
std::string maxbinsmesubsys_
std::string subfolder_
edm::ParameterSet parameters_

◆ ~DQMStoreStats()

DQMStoreStats::~DQMStoreStats ( )
overridedefault

Member Function Documentation

◆ analyze()

void DQMStoreStats::analyze ( const edm::Event e,
const edm::EventSetup c 
)
overrideprotectedvirtual

Implements edm::one::EDAnalyzerBase.

Definition at line 1057 of file DQMStoreStats.cc.

References calcstats(), considerAllME, considerOnlyLumiProductME, dumpMemoryProfile(), memoryHistoryVector_, readMemoryEntry(), and runineventloop_.

1057  {
1058  //now read virtual memory size from proc folder
1059  memoryHistoryVector_.emplace_back(readMemoryEntry());
1060 
1061  if (runineventloop_) {
1065  }
1066 }
std::pair< unsigned int, unsigned int > readMemoryEntry() const
std::vector< std::pair< time_t, unsigned int > > memoryHistoryVector_
int calcstats(int)
void dumpMemoryProfile()

◆ beginJob()

void DQMStoreStats::beginJob ( void  )
overrideprotectedvirtual

Reimplemented from edm::one::EDAnalyzerBase.

Definition at line 1028 of file DQMStoreStats.cc.

References DMR_cfg::cerr, dbe_, recoMuon::in, isOpenProcFileSuccessful_, Utilities::operator, and procFileName_.

1028  {
1031 
1032  // access the proc/ folder for memory information
1033  procFileName_ << "/proc/" << getpid() << "/status";
1034 
1035  // open for a test
1036  std::ifstream procFile(procFileName_.str().c_str(), ios::in);
1037 
1038  if (procFile.good()) {
1040  } else {
1041  std::cerr << " [DQMStoreStats::beginJob] ** WARNING: could not open file: " << procFileName_.str() << std::endl;
1042  std::cerr << " Total memory profile will not be available." << std::endl;
1043  isOpenProcFileSuccessful_ = false;
1044  }
1045 
1046  procFile.close();
1047 }
DQMStore * dbe_
bool isOpenProcFileSuccessful_
std::stringstream procFileName_

◆ beginLuminosityBlock()

void DQMStoreStats::beginLuminosityBlock ( const edm::LuminosityBlock lumiSeg,
const edm::EventSetup c 
)
overrideprotected

Definition at line 1082 of file DQMStoreStats.cc.

1082 {}

◆ beginRun()

void DQMStoreStats::beginRun ( const edm::Run r,
const edm::EventSetup c 
)
overrideprotected

Definition at line 1052 of file DQMStoreStats.cc.

1052 {}

◆ calcIgProfDump()

void DQMStoreStats::calcIgProfDump ( Folder root)
private

Definition at line 441 of file DQMStoreStats.cc.

References Folder::children(), VIterator< Item >::CurrentItem(), VIterator< Item >::First(), cuy::ii, VIterator< Item >::IsDone(), Folder::mainrows(), VIterator< Item >::Next(), Folder::parents(), cms::cuda::stream, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by calcstats().

441  {
442  std::ofstream stream("dqm-bin-stats.sql");
443  stream << ""
444  " PRAGMA journal_mode=OFF;"
445  " PRAGMA count_changes=OFF;"
446  " DROP TABLE IF EXISTS files;"
447  " DROP TABLE IF EXISTS symbols;"
448  " DROP TABLE IF EXISTS mainrows;"
449  " DROP TABLE IF EXISTS children;"
450  " DROP TABLE IF EXISTS parents;"
451  " DROP TABLE IF EXISTS summary;"
452  " CREATE TABLE children ("
453  " self_id INTEGER CONSTRAINT self_exists REFERENCES mainrows(id),"
454  " parent_id INTEGER CONSTRAINT parent_exists REFERENCES mainrows(id),"
455  " from_parent_count INTEGER,"
456  " from_parent_calls INTEGER,"
457  " from_parent_paths INTEGER,"
458  " pct REAL"
459  " );"
460  " CREATE TABLE files ("
461  " id,"
462  " name TEXT"
463  " );"
464  " CREATE TABLE mainrows ("
465  " id INTEGER PRIMARY KEY,"
466  " symbol_id INTEGER CONSTRAINT symbol_id_exists REFERENCES symbols(id),"
467  " self_count INTEGER,"
468  " cumulative_count INTEGER,"
469  " kids INTEGER,"
470  " self_calls INTEGER,"
471  " total_calls INTEGER,"
472  " self_paths INTEGER,"
473  " total_paths INTEGER,"
474  " pct REAL"
475  " );"
476  " CREATE TABLE parents ("
477  " self_id INTEGER CONSTRAINT self_exists REFERENCES mainrows(id),"
478  " child_id INTEGER CONSTRAINT child_exists REFERENCES mainrows(id),"
479  " to_child_count INTEGER,"
480  " to_child_calls INTEGER,"
481  " to_child_paths INTEGER,"
482  " pct REAL"
483  " );"
484  " CREATE TABLE summary ("
485  " counter TEXT,"
486  " total_count INTEGER,"
487  " total_freq INTEGER,"
488  " tick_period REAL"
489  " );"
490  " CREATE TABLE symbols ("
491  " id,"
492  " name TEXT,"
493  " filename_id INTEGER CONSTRAINT file_id_exists REFERENCES files(id)"
494  " );"
495  " CREATE UNIQUE INDEX fileIndex ON files (id);"
496  " CREATE INDEX selfCountIndex ON mainrows(self_count);"
497  " CREATE UNIQUE INDEX symbolsIndex ON symbols (id);"
498  " CREATE INDEX totalCountIndex ON mainrows(cumulative_count);"
499  << std::endl;
500 
501  std::string sql_statement("");
502 
503  root.files(sql_statement);
504  root.symbols(sql_statement);
505  root.mainrows_cumulative(sql_statement);
506  root.summary(sql_statement);
507  VIterator<Folder*> subsystems = root.CreateIterator();
508  size_t ii = 0;
509  for (subsystems.First(); !subsystems.IsDone(); subsystems.Next(), ++ii) {
510  subsystems.CurrentItem()->mainrows(sql_statement);
511  subsystems.CurrentItem()->parents(sql_statement);
512  subsystems.CurrentItem()->children(sql_statement);
513  }
514  stream << sql_statement << std::endl;
515 }
uint32_t T const *__restrict__ uint32_t const *__restrict__ int32_t int Histo::index_type cudaStream_t stream
void mainrows(std::string &sql_statement)
Item CurrentItem() const override
void Next() override
ii
Definition: cuy.py:589
void parents(std::string &sql_statement)
bool IsDone() const override
void First() override
void children(std::string &sql_statement)

◆ calcstats()

int DQMStoreStats::calcstats ( int  mode = DQMStoreStats::considerAllME)
private

do the stats here and produce output;

mode is coded in DQMStoreStats::statMode enum (select subsets of ME, e.g. those with getLumiFlag() == true)

Definition at line 523 of file DQMStoreStats.cc.

References DQMStoreStatsSubfolder::AddBinsD(), DQMStoreStatsSubfolder::AddBinsF(), DQMStoreStatsSubfolder::AddBinsI(), DQMStoreStatsSubfolder::AddBinsS(), calcIgProfDump(), Folder::cd(), considerAllME, considerOnlyLumiProductME, gather_cfg::cout, dbe_, dumpToFWJR_, dqmMemoryStats::float, dqm::implementation::IGetter::getAllContents(), getEmptyMetric(), createfilelist::int, edm::Service< T >::isAvailable(), maxbinsglobal_, maxbinssubsys_, ALCARECOPromptCalibProdSiPixelAli0T_cff::mode, seedmultiplicitymonitor_newtracking_cfi::nBins, nbinsglobal_, nbinssubsys_, castor_dqm_sourceclient_file_cfg::path, pathnamematch_, edm::JobReport::reportAnalysisFile(), runineventloop_, runonendjob_, runonendlumi_, runonendrun_, AlCaHLTBitMon_QueryRunRegistry::string, DQMStoreStatsSubfolder::subfolderName_, DQMStoreStatsSubsystem::subsystemName_, MonitorElementData::TH1D, MonitorElementData::TH1F, MonitorElementData::TH1I, MonitorElementData::TH1S, MonitorElementData::TH2D, MonitorElementData::TH2F, MonitorElementData::TH2I, MonitorElementData::TH2S, MonitorElementData::TH3F, MonitorElementData::TPROFILE, MonitorElementData::TPROFILE2D, and Folder::update().

Referenced by analyze(), endJob(), endLuminosityBlock(), and endRun().

523  {
525  nbinsglobal_ = 0;
526  nbinssubsys_ = 0;
527  maxbinsglobal_ = 0;
528  maxbinssubsys_ = 0;
529  std::string path = "";
530  std::string subsystemname = "";
531  std::string subfoldername = "";
532  size_t subsysStringEnd = 0, subfolderStringBegin = 0, subfolderStringEnd = 0;
533 
534  std::vector<MonitorElement*> melist;
536 
537  Folder dbeFolder("root");
538  DQMStoreStatsTopLevel dqmStoreStatsTopLevel;
539 
540  // loop all ME
541  for (auto& it : melist) {
542  // consider only ME with getLumiFlag() == true ?
543  if (mode == DQMStoreStats::considerOnlyLumiProductME && !(it->getLumiFlag()))
544  continue;
545 
546  // figure out subsystem/subfolder names
547  const std::string& path = it->getPathname();
548 
549  subfolderStringBegin = 0;
550  Folder* curr = &dbeFolder;
551  while (true) {
552  subfolderStringEnd = path.find('/', subfolderStringBegin);
553  if (std::string::npos == subfolderStringEnd) {
554  curr = curr->cd(path.substr(subfolderStringBegin, path.size() - subfolderStringBegin));
555  break;
556  }
557  curr = curr->cd(path.substr(subfolderStringBegin, subfolderStringEnd - subfolderStringBegin));
558  subfolderStringBegin = ++subfolderStringEnd < path.size() ? subfolderStringEnd : path.size();
559  }
560 
561  // protection against ghost ME with empty paths
562  if (path.empty())
563  continue;
564 
565  subsysStringEnd = path.find('/', 0);
566  if (std::string::npos == subsysStringEnd)
567  subsysStringEnd = path.size(); // no subfolder
568 
569  // new subsystem?
570  if (path.substr(0, subsysStringEnd) != subsystemname) {
571  DQMStoreStatsSubsystem aSubsystem;
572  subsystemname = path.substr(0, subsysStringEnd);
573  aSubsystem.subsystemName_ = subsystemname;
574  dqmStoreStatsTopLevel.push_back(aSubsystem);
575  subfoldername = "";
576  }
577 
578  // get subfolder name (if there is one..)
579  if (path.size() == subsysStringEnd) {
580  // no subfolders in subsystem, make dummy
581  DQMStoreStatsSubfolder aSubfolder;
582  aSubfolder.subfolderName_ = subsystemname; // <-- for tagging this case
583  dqmStoreStatsTopLevel.back().push_back(aSubfolder);
584  }
585 
586  else {
587  // there is a subfolder, get its name
588  subfolderStringEnd = path.find('/', subsysStringEnd + 1);
589  if (std::string::npos == subfolderStringEnd)
590  subfolderStringEnd = path.size();
591 
592  // new subfolder?
593  if (path.substr(subsysStringEnd + 1, subfolderStringEnd - subsysStringEnd - 1) != subfoldername) {
594  subfoldername = path.substr(subsysStringEnd + 1, subfolderStringEnd - subsysStringEnd - 1);
595  DQMStoreStatsSubfolder aSubfolder;
596  aSubfolder.subfolderName_ = subfoldername;
597  dqmStoreStatsTopLevel.back().push_back(aSubfolder);
598  }
599  }
600 
601  // shortcut
602  DQMStoreStatsSubfolder& currentSubfolder = dqmStoreStatsTopLevel.back().back();
603 
604  switch (it->kind()) {
605  // one-dim ME
607  currentSubfolder.AddBinsF(it->getNbinsX(), getEmptyMetric(it->getTH1F()->GetArray(), it->getTH1F()->fN, 0, 0));
608  curr->update(it->getNbinsX(),
609  getEmptyMetric(it->getTH1F()->GetArray(), it->getTH1F()->fN, 0, 0),
610  it->getNbinsX() * sizeof(float));
611  break;
613  currentSubfolder.AddBinsS(it->getNbinsX(), getEmptyMetric(it->getTH1S()->GetArray(), it->getTH1S()->fN, 0, 0));
614  curr->update(it->getNbinsX(),
615  getEmptyMetric(it->getTH1S()->GetArray(), it->getTH1S()->fN, 0, 0),
616  it->getNbinsX() * sizeof(short));
617  break;
619  currentSubfolder.AddBinsD(it->getNbinsX(), getEmptyMetric(it->getTH1D()->GetArray(), it->getTH1D()->fN, 0, 0));
620  curr->update(it->getNbinsX(),
621  getEmptyMetric(it->getTH1D()->GetArray(), it->getTH1D()->fN, 0, 0),
622  it->getNbinsX() * sizeof(double));
623  break;
625  currentSubfolder.AddBinsI(it->getNbinsX(), getEmptyMetric(it->getTH1I()->GetArray(), it->getTH1I()->fN, 0, 0));
626  curr->update(it->getNbinsX(),
627  getEmptyMetric(it->getTH1I()->GetArray(), it->getTH1I()->fN, 0, 0),
628  it->getNbinsX() * sizeof(int));
629  break;
631  currentSubfolder.AddBinsD(it->getNbinsX(),
632  getEmptyMetric(it->getTProfile()->GetArray(), it->getTProfile()->fN, 0, 0));
633  curr->update(it->getNbinsX(),
634  getEmptyMetric(it->getTProfile()->GetArray(), it->getTProfile()->fN, 0, 0),
635  it->getNbinsX() * sizeof(double));
636  break;
637 
638  // two-dim ME
640  currentSubfolder.AddBinsF(
641  it->getNbinsX() * it->getNbinsY(),
642  getEmptyMetric(it->getTH2F()->GetArray(), it->getNbinsX() + 2, it->getNbinsY() + 2, 0));
643  curr->update(it->getNbinsX() * it->getNbinsY(),
644  getEmptyMetric(it->getTH2F()->GetArray(), it->getNbinsX() + 2, it->getNbinsY() + 2, 0),
645  it->getNbinsX() * it->getNbinsY() * sizeof(float));
646  break;
648  currentSubfolder.AddBinsS(
649  it->getNbinsX() * it->getNbinsY(),
650  getEmptyMetric(it->getTH2S()->GetArray(), it->getNbinsX() + 2, it->getNbinsY() + 2, 0));
651  curr->update(it->getNbinsX() * it->getNbinsY(),
652  getEmptyMetric(it->getTH2S()->GetArray(), it->getNbinsX() + 2, it->getNbinsY() + 2, 0),
653  it->getNbinsX() * it->getNbinsY() * sizeof(short));
654  break;
656  currentSubfolder.AddBinsD(
657  it->getNbinsX() * it->getNbinsY(),
658  getEmptyMetric(it->getTH2D()->GetArray(), it->getNbinsX() + 2, it->getNbinsY() + 2, 0));
659  curr->update(it->getNbinsX() * it->getNbinsY(),
660  getEmptyMetric(it->getTH2D()->GetArray(), it->getNbinsX() + 2, it->getNbinsY() + 2, 0),
661  it->getNbinsX() * it->getNbinsY() * sizeof(double));
662  break;
664  currentSubfolder.AddBinsI(
665  it->getNbinsX() * it->getNbinsY(),
666  getEmptyMetric(it->getTH2I()->GetArray(), it->getNbinsX() + 2, it->getNbinsY() + 2, 0));
667  curr->update(it->getNbinsX() * it->getNbinsY(),
668  getEmptyMetric(it->getTH2I()->GetArray(), it->getNbinsX() + 2, it->getNbinsY() + 2, 0),
669  it->getNbinsX() * it->getNbinsY() * sizeof(int));
670  break;
672  currentSubfolder.AddBinsD(
673  it->getNbinsX() * it->getNbinsY(),
674  getEmptyMetric(it->getTProfile2D()->GetArray(), it->getNbinsX() + 2, it->getNbinsY() + 2, 0));
675  curr->update(it->getNbinsX() * it->getNbinsY(),
676  getEmptyMetric(it->getTProfile2D()->GetArray(), it->getNbinsX() + 2, it->getNbinsY() + 2, 0),
677  it->getNbinsX() * it->getNbinsY() * sizeof(double));
678  break;
679 
680  // three-dim ME
682  currentSubfolder.AddBinsF(
683  it->getNbinsX() * it->getNbinsY() * it->getNbinsZ(),
684  getEmptyMetric(it->getTH3F()->GetArray(), it->getNbinsX() + 2, it->getNbinsY() + 2, it->getNbinsZ() + 2));
685  curr->update(
686  it->getNbinsX() * it->getNbinsY() * it->getNbinsZ(),
687  getEmptyMetric(it->getTH3F()->GetArray(), it->getNbinsX() + 2, it->getNbinsY() + 2, it->getNbinsZ() + 2),
688  it->getNbinsX() * it->getNbinsY() * it->getNbinsZ() * sizeof(float));
689  break;
690 
691  default: {
692  }
693  // here we have a DQM_KIND_INVALID, DQM_KIND_INT, DQM_KIND_REAL or DQM_KIND_STRING
694  // which we don't care much about. Alternatively:
695 
696  // std::cerr << "[DQMStoreStats::calcstats] ** WARNING: monitor element of kind: "
697  // << (*it)->kind() << ", name: \"" << (*it)->getName() << "\"\n"
698  // << " in path: \"" << path << "\" not considered." << std::endl;
699  }
700  }
701 
703  calcIgProfDump(dbeFolder);
704 
705  // OUTPUT
706 
707  std::cout << endl;
708  std::cout << "==========================================================================================="
709  << std::endl;
710  std::cout << "[DQMStoreStats::calcstats] -- Dumping stats results ";
712  std::cout << "FOR ALL ME" << std::endl;
714  std::cout << "FOR LUMI PRODUCTS ONLY" << std::endl;
715  std::cout << "==========================================================================================="
716  << std::endl;
717  std::cout << endl;
718 
719  std::cout << "------------------------------------------------------------------------------------------"
720  << std::endl;
721  std::cout << "Configuration:" << std::endl;
722  std::cout << "------------------------------------------------------------------------------------------"
723  << std::endl;
724  std::cout << " > running ";
725  if (runonendrun_)
726  std::cout << "on run end." << std::endl;
727  if (runonendlumi_)
728  std::cout << "on lumi end." << std::endl;
729  if (runonendjob_)
730  std::cout << "on job end." << std::endl;
731  if (runineventloop_)
732  std::cout << "in event loop." << std::endl;
733  std::cout << " > pathNameMatch = \"" << pathnamematch_ << "\"" << std::endl;
734  std::cout << std::endl;
735 
736  // dump folder structure
737  std::cout << "------------------------------------------------------------------------------------------"
738  << std::endl;
739  std::cout << "Top level folder tree:" << std::endl;
740  std::cout << "------------------------------------------------------------------------------------------"
741  << std::endl;
742  for (auto it0 = dqmStoreStatsTopLevel.begin(); it0 < dqmStoreStatsTopLevel.end(); ++it0) {
743  std::cout << it0->subsystemName_ << " (subsystem)" << std::endl;
744 
745  for (auto it1 = it0->begin(); it1 < it0->end(); ++it1) {
746  std::cout << " |--> " << it1->subfolderName_ << " (subfolder)" << std::endl;
747  }
748  }
749 
750  // dump mem/bin table
751 
752  unsigned int overallNHistograms = 0, overallNBins = 0, overallNBytes = 0;
753 
754  std::cout << std::endl;
755  std::cout << "------------------------------------------------------------------------------------------"
756  << std::endl;
757  std::cout << "Detailed ressource usage information ";
759  std::cout << "FOR ALL ME" << std::endl;
761  std::cout << "FOR LUMI PRODUCTS ONLY" << std::endl;
762  std::cout << "------------------------------------------------------------------------------------------"
763  << std::endl;
764  std::cout << "subsystem/folder histograms bins Empty bins Empty/Total "
765  "bins per MB kB per"
766  << std::endl;
767  std::cout << " (total) (total) (total) "
768  "histogram (total) histogram "
769  << std::endl;
770  std::cout << "------------------------------------------------------------------------------------------"
771  << std::endl;
772  for (auto it0 = dqmStoreStatsTopLevel.begin(); it0 < dqmStoreStatsTopLevel.end(); ++it0) {
773  std::cout << it0->subsystemName_ << std::endl;
774 
775  unsigned int nHistograms = 0, nBins = 0, nEmptyBins = 0, nBytes = 0;
776 
777  for (auto it1 = it0->begin(); it1 < it0->end(); ++it1) {
778  // fixed-size working copy
779  std::string thisSubfolderName(it1->subfolderName_);
780  if (thisSubfolderName.size() > 30) {
781  thisSubfolderName.resize(30);
782  thisSubfolderName.replace(thisSubfolderName.size() - 3, 3, 3, '.');
783  }
784 
785  std::cout << " -> " << std::setw(30) << std::left << thisSubfolderName;
786  std::cout << std::setw(14) << std::right << it1->totalHistos_;
787  std::cout << std::setw(14) << std::right << it1->totalBins_;
788  std::cout << std::setw(14) << std::right << it1->totalEmptyBins_;
789  std::cout << std::setw(14) << std::right << std::setprecision(3)
790  << (float)it1->totalEmptyBins_ / (float)it1->totalBins_;
791 
792  // bins/histogram, need to catch nan if histos=0
793  if (it1->totalHistos_) {
794  std::cout << std::setw(14) << std::right << std::setprecision(3) << it1->totalBins_ / float(it1->totalHistos_);
795  } else
796  std::cout << std::setw(14) << std::right << "-";
797 
798  std::cout << std::setw(14) << std::right << std::setprecision(3) << it1->totalMemory_ / 1024. / 1024.;
799 
800  // mem/histogram, need to catch nan if histos=0
801  if (it1->totalHistos_) {
802  std::cout << std::setw(14) << std::right << std::setprecision(3)
803  << it1->totalMemory_ / 1024. / it1->totalHistos_;
804  } else
805  std::cout << std::setw(14) << std::right << "-";
806 
807  std::cout << std::endl;
808 
809  // collect totals
810  nHistograms += it1->totalHistos_;
811  nBins += it1->totalBins_;
812  nEmptyBins += it1->totalEmptyBins_;
813  nBytes += it1->totalMemory_;
814  }
815 
816  overallNHistograms += nHistograms;
817  overallNBins += nBins;
818  overallNBytes += nBytes;
819 
820  // display totals
821  std::cout << " " << std::setw(30) << std::left << "SUBSYSTEM TOTAL";
822  std::cout << std::setw(14) << std::right << nHistograms;
823  std::cout << std::setw(14) << std::right << nBins;
824  std::cout << std::setw(14) << std::right << nEmptyBins;
825  std::cout << std::setw(14) << std::right << (float)nEmptyBins / (float)nBins;
826  std::cout << std::setw(14) << std::right << std::setprecision(3) << nBins / float(nHistograms);
827  std::cout << std::setw(14) << std::right << std::setprecision(3) << nBytes / 1024. / 1000.;
828  std::cout << std::setw(14) << std::right << std::setprecision(3) << nBytes / 1024. / nHistograms;
829  std::cout << std::endl;
830 
831  std::cout << ".........................................................................................."
832  << std::endl;
833  }
834 
835  // dump total
836  std::cout << std::endl;
837  std::cout << "------------------------------------------------------------------------------------------"
838  << std::endl;
839  std::cout << "Grand total ";
841  std::cout << "FOR ALL ME:" << std::endl;
843  std::cout << "FOR LUMI PRODUCTS ONLY:" << std::endl;
844  std::cout << "------------------------------------------------------------------------------------------"
845  << std::endl;
846  std::cout << "Number of subsystems: " << dqmStoreStatsTopLevel.size() << std::endl;
847  std::cout << "Total number of histograms: " << overallNHistograms << " with: " << overallNBins << " bins alltogether"
848  << std::endl;
849  std::cout << "Total memory occupied by histograms (excl. overhead): " << overallNBytes / 1024. / 1000. << " MB"
850  << std::endl;
851 
852  std::cout << endl;
853  std::cout << "==========================================================================================="
854  << std::endl;
855  std::cout << "[DQMStoreStats::calcstats] -- End of output ";
857  std::cout << "FOR ALL ME." << std::endl;
859  std::cout << "FOR LUMI PRODUCTS ONLY." << std::endl;
860  std::cout << "==========================================================================================="
861  << std::endl;
862  std::cout << endl;
863 
864  // Put together a simplified version of the complete dump that is
865  // sent to std::cout. Just dump the very basic information,
866  // i.e. summary for each folder, both for run and LS products.
867  if (dumpToFWJR_) {
869  // Do not even try if the FWJR service is not available.
870  if (!jr.isAvailable())
871  return 0;
872  // Prepare appropriate map to store FWJR output.
873  std::map<std::string, std::string> jrInfo;
874 
875  jrInfo["Source"] = "DQMServices/Components";
876  jrInfo["FileClass"] = "DQMStoreStats";
877  if (runonendrun_)
878  jrInfo["DumpType"] = "EndRun";
879  if (runonendlumi_)
880  jrInfo["DumpType"] = "EndLumi";
881  if (runonendjob_)
882  jrInfo["DumpType"] = "EndJob";
883  if (runineventloop_)
884  jrInfo["DumpType"] = "EventLoop";
886  jrInfo["Type"] = "RunProduct";
888  jrInfo["Type"] = "LumiProduct";
889 
890  jrInfo["pathNameMatch"] = pathnamematch_;
891 
892  for (auto it0 = dqmStoreStatsTopLevel.begin(); it0 < dqmStoreStatsTopLevel.end(); ++it0) {
893  unsigned int nHistograms = 0, nBins = 0, nEmptyBins = 0, nBytes = 0;
894  for (auto it1 = it0->begin(); it1 < it0->end(); ++it1) {
895  // collect totals
896  nHistograms += it1->totalHistos_;
897  nBins += it1->totalBins_;
898  nEmptyBins += it1->totalEmptyBins_;
899  nBytes += it1->totalMemory_;
900  }
901  std::stringstream iss("");
902  iss << nHistograms;
903  jrInfo[it0->subsystemName_ + std::string("_h")] = iss.str();
904  iss.str("");
905  iss << nBins;
906  jrInfo[it0->subsystemName_ + std::string("_b")] = iss.str();
907  iss.str("");
908  iss << nEmptyBins;
909  jrInfo[it0->subsystemName_ + std::string("_be")] = iss.str();
910  iss.str("");
911  iss << ((float)nEmptyBins / (float)nBins);
912  jrInfo[it0->subsystemName_ + std::string("_fbe")] = iss.str();
913  iss.str("");
914  iss << ((float)nBins / (float)nHistograms);
915  jrInfo[it0->subsystemName_ + std::string("_b_h")] = iss.str();
916  iss.str("");
917  iss << nBytes / 1024. / 1024.;
918  jrInfo[it0->subsystemName_ + std::string("_MB")] = iss.str();
919  iss.str("");
920  iss << nBytes / 1024. / nHistograms;
921  jrInfo[it0->subsystemName_ + std::string("_Kb_h")] = iss.str();
922  }
923  jr->reportAnalysisFile("DQMStatsReport", jrInfo);
924  }
925 
926  return 0;
927 }
std::string subfolderName_
DQMStore * dbe_
void AddBinsS(unsigned int nBins, unsigned int nEmptyBins)
void update(unsigned int bins, unsigned int empty, unsigned int memory)
void AddBinsD(unsigned int nBins, unsigned int nEmptyBins)
void AddBinsI(unsigned int nBins, unsigned int nEmptyBins)
std::string subsystemName_
virtual std::vector< dqm::harvesting::MonitorElement * > getAllContents(std::string const &path) const
Definition: DQMStore.cc:641
std::string pathnamematch_
static unsigned int getEmptyMetric(T *array, int lenx, int leny, int lenz)
Folder * cd(const std::string &name)
void AddBinsF(unsigned int nBins, unsigned int nEmptyBins)
void reportAnalysisFile(std::string const &fileName, std::map< std::string, std::string > const &fileData)
Definition: JobReport.cc:509
void calcIgProfDump(Folder &)
bool isAvailable() const
Definition: Service.h:40

◆ dumpMemoryProfile()

void DQMStoreStats::dumpMemoryProfile ( )
private

Definition at line 932 of file DQMStoreStats.cc.

References gather_cfg::cout, dumpMemHistory_, isOpenProcFileSuccessful_, memoryHistoryVector_, download_sqlite_cfg::outputFile, and startingTime_.

Referenced by analyze(), endJob(), endLuminosityBlock(), and endRun().

932  {
933  std::cout << std::endl;
934  std::cout << "------------------------------------------------------------------------------------------"
935  << std::endl;
936  std::cout << "Memory profile:" << std::endl;
937  std::cout << "------------------------------------------------------------------------------------------"
938  << std::endl;
939 
940  // determine virtual memory maximum
941  std::pair<time_t, unsigned int> maxItem(0, 0);
942  for (auto it = memoryHistoryVector_.begin(); it < memoryHistoryVector_.end(); ++it) {
943  if (it->second > maxItem.second) {
944  maxItem = *it;
945  }
946  }
947 
948  std::stringstream rootOutputFileName;
949  rootOutputFileName << "dqmStoreStats_memProfile_" << getpid() << ".root";
950 
951  // dump memory history to root file
953  TFile outputFile(rootOutputFileName.str().c_str(), "RECREATE");
954 
955  int aTime;
956  float aMb;
957 
958  TTree memHistoryTree("dqmstorestats_memhistory", "memory history");
959  memHistoryTree.Branch("seconds", &aTime, "seconds/I");
960  memHistoryTree.Branch("megabytes", &aMb, "megabytes/F");
961  for (auto it = memoryHistoryVector_.begin(); it < memoryHistoryVector_.end(); ++it) {
962  aTime = it->first - startingTime_;
963  aMb = it->second / 1000.;
964  memHistoryTree.Fill();
965  }
966 
967  outputFile.Write();
968  outputFile.Close();
969  }
970 
971  std::cout << "Approx. maximum total virtual memory size of job: ";
973  std::cout << maxItem.second / 1000. << " MB (reached " << maxItem.first - startingTime_
974  << " sec. after constructor called)," << std::endl;
975  std::cout << " memory history written to: " << rootOutputFileName.str() << " (" << memoryHistoryVector_.size()
976  << " samples)" << std::endl;
977  } else {
978  std::cout << "(could not be determined)" << std::endl;
979  }
980 
981  std::cout << std::endl << std::endl;
982 }
std::vector< std::pair< time_t, unsigned int > > memoryHistoryVector_
time_t startingTime_
bool isOpenProcFileSuccessful_

◆ endJob()

void DQMStoreStats::endJob ( void  )
overrideprotectedvirtual

◆ endLuminosityBlock()

void DQMStoreStats::endLuminosityBlock ( const edm::LuminosityBlock lumiSeg,
const edm::EventSetup c 
)
overrideprotected

◆ endRun()

void DQMStoreStats::endRun ( const edm::Run r,
const edm::EventSetup c 
)
overrideprotected

◆ print()

void DQMStoreStats::print ( void  )
private

Definition at line 987 of file DQMStoreStats.cc.

References gather_cfg::cout, maxbinsmesubsys_, maxbinssubsys_, nbinssubsys_, nmesubsys_, subfolder_, and subsystem_.

987  {
988  // subsystem info printout
989  std::cout << " ---------- " << subsystem_ << " ---------- " << std::endl;
990  std::cout << " " << subfolder_ << ": ";
991  std::cout << nmesubsys_ << " histograms with " << nbinssubsys_ << " bins. ";
992  if (nmesubsys_ > 0)
993  std::cout << nbinssubsys_ / nmesubsys_ << " bins/histogram ";
994  std::cout << std::endl;
995  std::cout << " Largest histogram: " << maxbinsmesubsys_ << " with " << maxbinssubsys_ << " bins." << std::endl;
996 }
std::string subsystem_
std::string maxbinsmesubsys_
std::string subfolder_

◆ readMemoryEntry()

std::pair< unsigned int, unsigned int > DQMStoreStats::readMemoryEntry ( ) const
private

read virtual memory size from /proc/<pid>/status file

Definition at line 1001 of file DQMStoreStats.cc.

References recoMuon::in, isOpenProcFileSuccessful_, procFileName_, AlCaHLTBitMon_QueryRunRegistry::string, and protons_cff::time.

Referenced by analyze().

1001  {
1002  // see if initial test reading was successful
1004  std::ifstream procFile(procFileName_.str().c_str(), ios::in);
1005 
1006  std::string readBuffer("");
1007  unsigned int memSize = 0;
1008 
1009  // scan procfile
1010  while (!procFile.eof()) {
1011  procFile >> readBuffer;
1012  if (std::string("VmSize:") == readBuffer) {
1013  procFile >> memSize;
1014  break;
1015  }
1016  }
1017 
1018  procFile.close();
1019  return std::pair<time_t, unsigned int>(time(nullptr), memSize);
1020  }
1021 
1022  return std::pair<time_t, unsigned int>(0, 0);
1023 }
bool isOpenProcFileSuccessful_
std::stringstream procFileName_

Member Data Documentation

◆ dbe_

DQMStore* DQMStoreStats::dbe_
private

Definition at line 346 of file DQMStoreStats.cc.

Referenced by beginJob(), and calcstats().

◆ dumpMemHistory_

bool DQMStoreStats::dumpMemHistory_
private

Definition at line 373 of file DQMStoreStats.cc.

Referenced by DQMStoreStats(), and dumpMemoryProfile().

◆ dumpToFWJR_

bool DQMStoreStats::dumpToFWJR_
private

Definition at line 374 of file DQMStoreStats.cc.

Referenced by calcstats(), and DQMStoreStats().

◆ isOpenProcFileSuccessful_

bool DQMStoreStats::isOpenProcFileSuccessful_
private

Definition at line 366 of file DQMStoreStats.cc.

Referenced by beginJob(), dumpMemoryProfile(), and readMemoryEntry().

◆ maxbinsglobal_

int DQMStoreStats::maxbinsglobal_
private

Definition at line 355 of file DQMStoreStats.cc.

Referenced by calcstats().

◆ maxbinsmeglobal_

std::string DQMStoreStats::maxbinsmeglobal_
private

Definition at line 357 of file DQMStoreStats.cc.

◆ maxbinsmesubsys_

std::string DQMStoreStats::maxbinsmesubsys_
private

Definition at line 358 of file DQMStoreStats.cc.

Referenced by print().

◆ maxbinssubsys_

int DQMStoreStats::maxbinssubsys_
private

Definition at line 356 of file DQMStoreStats.cc.

Referenced by calcstats(), and print().

◆ memoryHistoryVector_

std::vector<std::pair<time_t, unsigned int> > DQMStoreStats::memoryHistoryVector_
private

Definition at line 364 of file DQMStoreStats.cc.

Referenced by analyze(), and dumpMemoryProfile().

◆ nbinsglobal_

int DQMStoreStats::nbinsglobal_
private

Definition at line 351 of file DQMStoreStats.cc.

Referenced by calcstats().

◆ nbinssubsys_

int DQMStoreStats::nbinssubsys_
private

Definition at line 352 of file DQMStoreStats.cc.

Referenced by calcstats(), and print().

◆ nmeglobal_

int DQMStoreStats::nmeglobal_
private

Definition at line 353 of file DQMStoreStats.cc.

◆ nmesubsys_

int DQMStoreStats::nmesubsys_
private

Definition at line 354 of file DQMStoreStats.cc.

Referenced by print().

◆ parameters_

edm::ParameterSet DQMStoreStats::parameters_
private

◆ pathnamematch_

std::string DQMStoreStats::pathnamematch_
private

Definition at line 361 of file DQMStoreStats.cc.

Referenced by calcstats(), and DQMStoreStats().

◆ procFileName_

std::stringstream DQMStoreStats::procFileName_
private

Definition at line 367 of file DQMStoreStats.cc.

Referenced by beginJob(), and readMemoryEntry().

◆ runineventloop_

bool DQMStoreStats::runineventloop_
private

Definition at line 372 of file DQMStoreStats.cc.

Referenced by analyze(), calcstats(), and DQMStoreStats().

◆ runonendjob_

bool DQMStoreStats::runonendjob_
private

Definition at line 370 of file DQMStoreStats.cc.

Referenced by calcstats(), DQMStoreStats(), and endJob().

◆ runonendlumi_

bool DQMStoreStats::runonendlumi_
private

Definition at line 371 of file DQMStoreStats.cc.

Referenced by calcstats(), DQMStoreStats(), and endLuminosityBlock().

◆ runonendrun_

bool DQMStoreStats::runonendrun_
private

Definition at line 369 of file DQMStoreStats.cc.

Referenced by calcstats(), DQMStoreStats(), and endRun().

◆ startingTime_

time_t DQMStoreStats::startingTime_
private

Definition at line 365 of file DQMStoreStats.cc.

Referenced by DQMStoreStats(), and dumpMemoryProfile().

◆ statsdepth_

int DQMStoreStats::statsdepth_
private

Definition at line 360 of file DQMStoreStats.cc.

Referenced by DQMStoreStats().

◆ subfolder_

std::string DQMStoreStats::subfolder_
private

Definition at line 350 of file DQMStoreStats.cc.

Referenced by print().

◆ subsystem_

std::string DQMStoreStats::subsystem_
private

Definition at line 349 of file DQMStoreStats.cc.

Referenced by print().

◆ verbose_

int DQMStoreStats::verbose_
private

Definition at line 362 of file DQMStoreStats.cc.

Referenced by DQMStoreStats().