CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Types | Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes
DQMStoreStats Class Reference

#include <DQMStoreStats.h>

Inheritance diagram for DQMStoreStats:
edm::EDAnalyzer

Public Types

enum  statsMode { considerAllME = 0, considerOnlyLumiProductME = 1 }
 
- Public Types inherited from edm::EDAnalyzer
typedef EDAnalyzer ModuleType
 
typedef WorkerT< EDAnalyzerWorkerType
 

Public Member Functions

 DQMStoreStats (const edm::ParameterSet &)
 
 ~DQMStoreStats ()
 
- Public Member Functions inherited from edm::EDAnalyzer
 EDAnalyzer ()
 
std::string workerType () const
 
virtual ~EDAnalyzer ()
 

Protected Member Functions

void analyze (const edm::Event &e, const edm::EventSetup &c)
 
void beginJob ()
 
void beginLuminosityBlock (const edm::LuminosityBlock &lumiSeg, const edm::EventSetup &context)
 
void beginRun (const edm::Run &r, const edm::EventSetup &c)
 
void endJob ()
 
void endLuminosityBlock (const edm::LuminosityBlock &lumiSeg, const edm::EventSetup &c)
 
void endRun (const edm::Run &r, const edm::EventSetup &c)
 
- Protected Member Functions inherited from edm::EDAnalyzer
CurrentProcessingContext const * currentContext () const
 

Private Member Functions

void calcIgProfDump (Folder &)
 
int calcstats (int)
 
void dumpMemoryProfile (void)
 
void print ()
 
std::pair< unsigned int,
unsigned int > 
readMemoryEntry (void) 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::EDAnalyzer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &)
 

Detailed Description

DQMStoreStats itself

Definition at line 294 of file DQMStoreStats.h.

Member Enumeration Documentation

Enumerator
considerAllME 
considerOnlyLumiProductME 

Definition at line 299 of file DQMStoreStats.h.

Constructor & Destructor Documentation

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

Definition at line 52 of file DQMStoreStats.cc.

References dumpMemHistory_, dumpToFWJR_, funct::false, edm::ParameterSet::getUntrackedParameter(), parameters_, pathnamematch_, runineventloop_, runonendjob_, runonendlumi_, runonendrun_, startingTime_, statsdepth_, cond::rpcobgas::time, funct::true, and verbose_.

53  : subsystem_ (""),
54  subfolder_ (""),
55  nbinsglobal_ (0),
56  nbinssubsys_ (0),
57  nmeglobal_ (0),
58  nmesubsys_ (0),
59  maxbinsglobal_ (0),
60  maxbinssubsys_ (0),
61  maxbinsmeglobal_ (""),
62  maxbinsmesubsys_ (""),
63  statsdepth_ (1),
64  pathnamematch_ ("*"),
65  verbose_ (0)
66 {
67  parameters_ = ps;
68  pathnamematch_ = ps.getUntrackedParameter<std::string>( "pathNameMatch", pathnamematch_ );
69  statsdepth_ = ps.getUntrackedParameter<int>( "statsDepth", statsdepth_ );
70  verbose_ = ps.getUntrackedParameter<int>( "verbose", verbose_ );
71  dumpMemHistory_ = ps.getUntrackedParameter<bool>( "dumpMemoryHistory", false );
72  runonendrun_ = ps.getUntrackedParameter<bool>( "runOnEndRun", true );
73  runonendjob_ = ps.getUntrackedParameter<bool>( "runOnEndJob", false );
74  runonendlumi_ = ps.getUntrackedParameter<bool>( "runOnEndLumi", false );
75  runineventloop_ = ps.getUntrackedParameter<bool>( "runInEventLoop", false );
76  dumpToFWJR_ = ps.getUntrackedParameter<bool>( "dumpToFWJR", false );
77 
78  startingTime_ = time( 0 );
79 }
T getUntrackedParameter(std::string const &, T const &) const
time_t startingTime_
std::string subsystem_
std::string maxbinsmeglobal_
std::string pathnamematch_
std::string maxbinsmesubsys_
std::string subfolder_
edm::ParameterSet parameters_
DQMStoreStats::~DQMStoreStats ( )

Definition at line 81 of file DQMStoreStats.cc.

81  {
82 }

Member Function Documentation

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

Implements edm::EDAnalyzer.

Definition at line 672 of file DQMStoreStats.cc.

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

672  {
673 
674  //now read virtual memory size from proc folder
675  memoryHistoryVector_.push_back( readMemoryEntry() );
676 
677  if (runineventloop_) {
681  }
682 
683 }
std::vector< std::pair< time_t, unsigned int > > memoryHistoryVector_
int calcstats(int)
std::pair< unsigned int, unsigned int > readMemoryEntry(void) const
void dumpMemoryProfile(void)
void DQMStoreStats::beginJob ( void  )
protectedvirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 630 of file DQMStoreStats.cc.

References dtNoiseDBValidation_cfg::cerr, dbe_, recoMuon::in, isOpenProcFileSuccessful_, cppFunctionSkipper::operator, and procFileName_.

630  {
631 
634 
635  // access the proc/ folder for memory information
636  procFileName_ << "/proc/" << getpid() << "/status";
637 
638  // open for a test
639  std::ifstream procFile( procFileName_.str().c_str(), ios::in );
640 
641  if( procFile.good() ) {
643  }
644  else {
645  std::cerr << " [DQMStoreStats::beginJob] ** WARNING: could not open file: " << procFileName_.str() << std::endl;
646  std::cerr << " Total memory profile will not be available." << std::endl;
648  }
649 
650  procFile.close();
651 
652 }
DQMStore * dbe_
bool isOpenProcFileSuccessful_
std::stringstream procFileName_
void DQMStoreStats::beginLuminosityBlock ( const edm::LuminosityBlock lumiSeg,
const edm::EventSetup context 
)
protectedvirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 664 of file DQMStoreStats.cc.

665  {
666 }
void DQMStoreStats::beginRun ( const edm::Run r,
const edm::EventSetup c 
)
protectedvirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 657 of file DQMStoreStats.cc.

657  {
658 }
void DQMStoreStats::calcIgProfDump ( Folder root)
private

Definition at line 84 of file DQMStoreStats.cc.

References Folder::children(), Folder::CreateIterator(), VIterator< Item >::CurrentItem(), Folder::files(), VIterator< Item >::First(), VIterator< Item >::IsDone(), Folder::mainrows(), Folder::mainrows_cumulative(), VIterator< Item >::Next(), Folder::parents(), Folder::summary(), and Folder::symbols().

Referenced by calcstats().

85 {
86  std::ofstream stream("dqm-bin-stats.sql");
87  stream << ""
88 " PRAGMA journal_mode=OFF;"
89 " PRAGMA count_changes=OFF;"
90 " DROP TABLE IF EXISTS files;"
91 " DROP TABLE IF EXISTS symbols;"
92 " DROP TABLE IF EXISTS mainrows;"
93 " DROP TABLE IF EXISTS children;"
94 " DROP TABLE IF EXISTS parents;"
95 " DROP TABLE IF EXISTS summary;"
96 " CREATE TABLE children ("
97 " self_id INTEGER CONSTRAINT self_exists REFERENCES mainrows(id),"
98 " parent_id INTEGER CONSTRAINT parent_exists REFERENCES mainrows(id),"
99 " from_parent_count INTEGER,"
100 " from_parent_calls INTEGER,"
101 " from_parent_paths INTEGER,"
102 " pct REAL"
103 " );"
104 " CREATE TABLE files ("
105 " id,"
106 " name TEXT"
107 " );"
108 " CREATE TABLE mainrows ("
109 " id INTEGER PRIMARY KEY,"
110 " symbol_id INTEGER CONSTRAINT symbol_id_exists REFERENCES symbols(id),"
111 " self_count INTEGER,"
112 " cumulative_count INTEGER,"
113 " kids INTEGER,"
114 " self_calls INTEGER,"
115 " total_calls INTEGER,"
116 " self_paths INTEGER,"
117 " total_paths INTEGER,"
118 " pct REAL"
119 " );"
120 " CREATE TABLE parents ("
121 " self_id INTEGER CONSTRAINT self_exists REFERENCES mainrows(id),"
122 " child_id INTEGER CONSTRAINT child_exists REFERENCES mainrows(id),"
123 " to_child_count INTEGER,"
124 " to_child_calls INTEGER,"
125 " to_child_paths INTEGER,"
126 " pct REAL"
127 " );"
128 " CREATE TABLE summary ("
129 " counter TEXT,"
130 " total_count INTEGER,"
131 " total_freq INTEGER,"
132 " tick_period REAL"
133 " );"
134 " CREATE TABLE symbols ("
135 " id,"
136 " name TEXT,"
137 " filename_id INTEGER CONSTRAINT file_id_exists REFERENCES files(id)"
138 " );"
139 " CREATE UNIQUE INDEX fileIndex ON files (id);"
140 " CREATE INDEX selfCountIndex ON mainrows(self_count);"
141 " CREATE UNIQUE INDEX symbolsIndex ON symbols (id);"
142 " CREATE INDEX totalCountIndex ON mainrows(cumulative_count);" << std::endl;
143 
144  std::string sql_statement("");
145 
146  root.files(sql_statement);
147  root.symbols(sql_statement);
148  root.mainrows_cumulative(sql_statement);
149  root.summary(sql_statement);
150  VIterator<Folder *> subsystems = root.CreateIterator() ;
151  size_t ii=0;
152  for(subsystems.First() ; !subsystems.IsDone() ; subsystems.Next(), ++ii)
153  {
154  subsystems.CurrentItem()->mainrows(sql_statement);
155  subsystems.CurrentItem()->parents(sql_statement);
156  subsystems.CurrentItem()->children(sql_statement);
157  }
158  stream << sql_statement << std::endl;
159 }
virtual void First()
Definition: DQMStoreStats.h:91
virtual bool IsDone() const
Definition: DQMStoreStats.h:96
void mainrows_cumulative(std::string &sql_statement)
VIterator< Folder * > CreateIterator()
void summary(std::string &sql_statement)
void mainrows(std::string &sql_statement)
void files(std::string &sql_statement)
virtual void Next()
Definition: DQMStoreStats.h:92
virtual Item CurrentItem() const
void parents(std::string &sql_statement)
void children(std::string &sql_statement)
void symbols(std::string &sql_statement)
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 167 of file DQMStoreStats.cc.

References DQMStoreStatsSubfolder::AddBinsD(), DQMStoreStatsSubfolder::AddBinsF(), DQMStoreStatsSubfolder::AddBinsS(), calcIgProfDump(), Folder::cd(), considerAllME, considerOnlyLumiProductME, gather_cfg::cout, dbe_, MonitorElement::DQM_KIND_TH1D, MonitorElement::DQM_KIND_TH1F, MonitorElement::DQM_KIND_TH1S, MonitorElement::DQM_KIND_TH2D, MonitorElement::DQM_KIND_TH2F, MonitorElement::DQM_KIND_TH2S, MonitorElement::DQM_KIND_TH3F, MonitorElement::DQM_KIND_TPROFILE, MonitorElement::DQM_KIND_TPROFILE2D, dumpToFWJR_, getEmptyMetric(), DQMStore::getMatchingContents(), edm::Service< T >::isAvailable(), maxbinsglobal_, maxbinssubsys_, alignBH_cfg::mode, nbinsglobal_, nbinssubsys_, scaleCards::path, pathnamematch_, edm::JobReport::reportAnalysisFile(), runineventloop_, runonendjob_, runonendlumi_, runonendrun_, DQMStoreStatsSubfolder::subfolderName_, DQMStoreStatsSubsystem::subsystemName_, and Folder::update().

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

167  {
168 
170  nbinsglobal_ = 0;
171  nbinssubsys_ = 0;
172  maxbinsglobal_ = 0;
173  maxbinssubsys_ = 0;
174  std::string path = "";
175  std::string subsystemname = "";
176  std::string subfoldername = "";
177  size_t subsysStringEnd = 0, subfolderStringBegin = 0, subfolderStringEnd = 0;
178 
179 
180  std::vector<MonitorElement*> melist;
182 
183  Folder dbeFolder("root");
184  DQMStoreStatsTopLevel dqmStoreStatsTopLevel;
185 
186  // loop all ME
187  typedef std::vector <MonitorElement*>::iterator meIt;
188  for(meIt it = melist.begin(); it != melist.end(); ++it) {
189 
190  // consider only ME with getLumiFlag() == true ?
192  !( (*it)->getLumiFlag() ) ) continue;
193 
194  // figure out subsystem/subfolder names
195  std::string path = (*it)->getPathname();
196 
197  subfolderStringBegin = 0;
198  Folder * curr = &dbeFolder;
199  while(1)
200  {
201  subfolderStringEnd = path.find( '/', subfolderStringBegin );
202  if( std::string::npos == subfolderStringEnd )
203  {
204  curr = curr->cd(path.substr( subfolderStringBegin, path.size()-subfolderStringBegin ));
205  break;
206  }
207  curr = curr->cd(path.substr( subfolderStringBegin, subfolderStringEnd-subfolderStringBegin ));
208  subfolderStringBegin = ++subfolderStringEnd < path.size() ? subfolderStringEnd : path.size();
209  }
210 
211  // protection against ghost ME with empty paths
212  if( 0 == path.size() ) continue;
213 
214  subsysStringEnd = path.find( '/', 0 );
215  if( std::string::npos == subsysStringEnd ) subsysStringEnd = path.size(); // no subfolder
216 
217  // new subsystem?
218  if( path.substr( 0, subsysStringEnd ) != subsystemname ) {
219  DQMStoreStatsSubsystem aSubsystem;
220  subsystemname = path.substr( 0, subsysStringEnd );
221  aSubsystem.subsystemName_ = subsystemname;
222  dqmStoreStatsTopLevel.push_back( aSubsystem );
223  subfoldername = "";
224  }
225 
226  // get subfolder name (if there is one..)
227  if( path.size() == subsysStringEnd ) {
228  // no subfolders in subsystem, make dummy
229  DQMStoreStatsSubfolder aSubfolder;
230  aSubfolder.subfolderName_ = subsystemname; // <-- for tagging this case
231  dqmStoreStatsTopLevel.back().push_back( aSubfolder );
232  }
233 
234  else {
235 
236  // there is a subfolder, get its name
237  subfolderStringEnd = path.find( '/', subsysStringEnd + 1 );
238  if( std::string::npos == subfolderStringEnd ) subfolderStringEnd = path.size();
239 
240  // new subfolder?
241  if( path.substr( subsysStringEnd + 1, subfolderStringEnd - subsysStringEnd - 1 ) != subfoldername ) {
242  subfoldername = path.substr( subsysStringEnd + 1, subfolderStringEnd - subsysStringEnd - 1 );
243  DQMStoreStatsSubfolder aSubfolder;
244  aSubfolder.subfolderName_ = subfoldername;
245  dqmStoreStatsTopLevel.back().push_back( aSubfolder );
246  }
247 
248  }
249 
250  // shortcut
251  DQMStoreStatsSubfolder& currentSubfolder = dqmStoreStatsTopLevel.back().back();
252 
253  switch( (*it)->kind() ) {
254 
255  // one-dim ME
257  currentSubfolder.AddBinsF( (*it)->getNbinsX(), getEmptyMetric((*it)->getTH1F()->GetArray(), (*it)->getTH1F()->fN, 0, 0) );
258  curr->update( (*it)->getNbinsX(), getEmptyMetric((*it)->getTH1F()->GetArray(), (*it)->getTH1F()->fN, 0, 0), (*it)->getNbinsX()*sizeof( float ) );
259  break;
261  currentSubfolder.AddBinsS( (*it)->getNbinsX(), getEmptyMetric((*it)->getTH1S()->GetArray(), (*it)->getTH1S()->fN, 0, 0) );
262  curr->update( (*it)->getNbinsX(), getEmptyMetric((*it)->getTH1S()->GetArray(), (*it)->getTH1S()->fN, 0, 0), (*it)->getNbinsX()*sizeof( short ) );
263  break;
265  currentSubfolder.AddBinsD( (*it)->getNbinsX(), getEmptyMetric((*it)->getTH1D()->GetArray(), (*it)->getTH1D()->fN, 0, 0) );
266  curr->update( (*it)->getNbinsX(), getEmptyMetric((*it)->getTH1D()->GetArray(), (*it)->getTH1D()->fN, 0, 0), (*it)->getNbinsX()*sizeof( double ) );
267  break;
269  currentSubfolder.AddBinsD( (*it)->getNbinsX(), getEmptyMetric((*it)->getTProfile()->GetArray(), (*it)->getTProfile()->fN, 0, 0) );
270  curr->update( (*it)->getNbinsX(), getEmptyMetric((*it)->getTProfile()->GetArray(), (*it)->getTProfile()->fN, 0, 0), (*it)->getNbinsX()*sizeof( double ) );
271  break;
272 
273  // two-dim ME
275  currentSubfolder.AddBinsF( (*it)->getNbinsX() * (*it)->getNbinsY(), getEmptyMetric((*it)->getTH2F()->GetArray(), (*it)->getNbinsX()+2, (*it)->getNbinsY()+2, 0) );
276  curr->update( (*it)->getNbinsX() * (*it)->getNbinsY(), getEmptyMetric((*it)->getTH2F()->GetArray(), (*it)->getNbinsX()+2, (*it)->getNbinsY()+2, 0), (*it)->getNbinsX() * (*it)->getNbinsY()*sizeof(float) );
277  break;
279  currentSubfolder.AddBinsS( (*it)->getNbinsX() * (*it)->getNbinsY(), getEmptyMetric((*it)->getTH2S()->GetArray(), (*it)->getNbinsX()+2, (*it)->getNbinsY()+2, 0) );
280  curr->update( (*it)->getNbinsX() * (*it)->getNbinsY(), getEmptyMetric((*it)->getTH2S()->GetArray(), (*it)->getNbinsX()+2, (*it)->getNbinsY()+2, 0), (*it)->getNbinsX() * (*it)->getNbinsY()*sizeof(short) );
281  break;
283  currentSubfolder.AddBinsD( (*it)->getNbinsX() * (*it)->getNbinsY(), getEmptyMetric((*it)->getTH2D()->GetArray(), (*it)->getNbinsX()+2, (*it)->getNbinsY()+2, 0) );
284  curr->update( (*it)->getNbinsX() * (*it)->getNbinsY(), getEmptyMetric((*it)->getTH2D()->GetArray(), (*it)->getNbinsX()+2, (*it)->getNbinsY()+2, 0), (*it)->getNbinsX() * (*it)->getNbinsY()*sizeof(double) );
285  break;
287  currentSubfolder.AddBinsD( (*it)->getNbinsX() * (*it)->getNbinsY(), getEmptyMetric((*it)->getTProfile2D()->GetArray(), (*it)->getNbinsX()+2, (*it)->getNbinsY()+2, 0) );
288  curr->update( (*it)->getNbinsX() * (*it)->getNbinsY(), getEmptyMetric((*it)->getTProfile2D()->GetArray(), (*it)->getNbinsX()+2, (*it)->getNbinsY()+2, 0), (*it)->getNbinsX() * (*it)->getNbinsY()*sizeof(double) );
289  break;
290 
291  // three-dim ME
293  currentSubfolder.AddBinsF( (*it)->getNbinsX() * (*it)->getNbinsY() * (*it)->getNbinsZ(), getEmptyMetric( (*it)->getTH3F()->GetArray(), (*it)->getNbinsX()+2, (*it)->getNbinsY()+2, (*it)->getNbinsZ()+2 ) );
294  curr->update( (*it)->getNbinsX() * (*it)->getNbinsY() * (*it)->getNbinsZ(),
295  getEmptyMetric( (*it)->getTH3F()->GetArray(), (*it)->getNbinsX()+2, (*it)->getNbinsY()+2, (*it)->getNbinsZ()+2 ),
296  (*it)->getNbinsX() * (*it)->getNbinsY() * (*it)->getNbinsZ()*sizeof(float));
297  break;
298 
299  default: {}
300  // here we have a DQM_KIND_INVALID, DQM_KIND_INT, DQM_KIND_REAL or DQM_KIND_STRING
301  // which we don't care much about. Alternatively:
302 
303  // std::cerr << "[DQMStoreStats::calcstats] ** WARNING: monitor element of kind: "
304  // << (*it)->kind() << ", name: \"" << (*it)->getName() << "\"\n"
305  // << " in path: \"" << path << "\" not considered." << std::endl;
306  }
307  }
308 
310  calcIgProfDump(dbeFolder);
311 
312  // OUTPUT
313 
314  std::cout << endl;
315  std::cout << "===========================================================================================" << std::endl;
316  std::cout << "[DQMStoreStats::calcstats] -- Dumping stats results ";
317  if( mode == DQMStoreStats::considerAllME ) std::cout << "FOR ALL ME" << std::endl;
318  else if( mode == DQMStoreStats::considerOnlyLumiProductME ) std::cout << "FOR LUMI PRODUCTS ONLY" << std::endl;
319  std::cout << "===========================================================================================" << std::endl;
320  std::cout << endl;
321 
322  std::cout << "------------------------------------------------------------------------------------------" << std::endl;
323  std::cout << "Configuration:" << std::endl;
324  std::cout << "------------------------------------------------------------------------------------------" << std::endl;
325  std::cout << " > running ";
326  if (runonendrun_) std::cout << "on run end." << std::endl;
327  if (runonendlumi_) std::cout << "on lumi end." << std::endl;
328  if (runonendjob_) std::cout << "on job end." << std::endl;
329  if (runineventloop_) std::cout << "in event loop." << std::endl;
330  std::cout << " > pathNameMatch = \"" << pathnamematch_ << "\"" << std::endl;
331  std::cout << std::endl;
332 
333  // dump folder structure
334  std::cout << "------------------------------------------------------------------------------------------" << std::endl;
335  std::cout << "Top level folder tree:" << std::endl;
336  std::cout << "------------------------------------------------------------------------------------------" << std::endl;
337  for( DQMStoreStatsTopLevel::const_iterator it0 = dqmStoreStatsTopLevel.begin(); it0 < dqmStoreStatsTopLevel.end(); ++it0 ) {
338  std::cout << it0->subsystemName_ << " (subsystem)" << std::endl;
339 
340  for( DQMStoreStatsSubsystem::const_iterator it1 = it0->begin(); it1 < it0->end(); ++it1 ) {
341  std::cout << " |--> " << it1->subfolderName_ << " (subfolder)" << std::endl;
342  }
343 
344  }
345 
346  // dump mem/bin table
347 
348  unsigned int overallNHistograms = 0, overallNBins = 0, overallNEmptyBins = 0, overallNBytes = 0;
349 
350  std::cout << std::endl;
351  std::cout << "------------------------------------------------------------------------------------------" << std::endl;
352  std::cout << "Detailed ressource usage information ";
353  if( mode == DQMStoreStats::considerAllME ) std::cout << "FOR ALL ME" << std::endl;
354  else if( mode == DQMStoreStats::considerOnlyLumiProductME ) std::cout << "FOR LUMI PRODUCTS ONLY" << std::endl;
355  std::cout << "------------------------------------------------------------------------------------------" << std::endl;
356  std::cout << "subsystem/folder histograms bins Empty bins Empty/Total bins per MB kB per" << std::endl;
357  std::cout << " (total) (total) (total) histogram (total) histogram " << std::endl;
358  std::cout << "------------------------------------------------------------------------------------------" << std::endl;
359  for( DQMStoreStatsTopLevel::const_iterator it0 = dqmStoreStatsTopLevel.begin(); it0 < dqmStoreStatsTopLevel.end(); ++it0 ) {
360  std::cout << it0->subsystemName_ << std::endl;
361 
362  unsigned int nHistograms = 0, nBins = 0, nEmptyBins = 0, nBytes = 0;
363 
364  for( DQMStoreStatsSubsystem::const_iterator it1 = it0->begin(); it1 < it0->end(); ++it1 ) {
365 
366  // fixed-size working copy
367  std::string thisSubfolderName( it1->subfolderName_ );
368  if( thisSubfolderName.size() > 30 ) {
369  thisSubfolderName.resize( 30 );
370  thisSubfolderName.replace( thisSubfolderName.size() - 3, 3, 3, '.' );
371  }
372 
373  std::cout << " -> " << std::setw( 30 ) << std::left << thisSubfolderName;
374  std::cout << std::setw( 14 ) << std::right << it1->totalHistos_;
375  std::cout << std::setw( 14 ) << std::right << it1->totalBins_;
376  std::cout << std::setw( 14 ) << std::right << it1->totalEmptyBins_;
377  std::cout << std::setw( 14 ) << std::right << std::setprecision( 3 ) << (float)it1->totalEmptyBins_/(float)it1->totalBins_;
378 
379  // bins/histogram, need to catch nan if histos=0
380  if( it1->totalHistos_ ) {
381  std::cout << std::setw( 14 ) << std::right << std::setprecision( 3 ) << it1->totalBins_ / float( it1->totalHistos_ );
382  }
383  else std::cout << std::setw( 14 ) << std::right << "-";
384 
385  std::cout << std::setw( 14 ) << std::right << std::setprecision( 3 ) << it1->totalMemory_ / 1024. / 1024.;
386 
387  // mem/histogram, need to catch nan if histos=0
388  if( it1->totalHistos_ ) {
389  std::cout << std::setw( 14 ) << std::right << std::setprecision( 3 ) << it1->totalMemory_ / 1024. / it1->totalHistos_;
390  }
391  else std::cout << std::setw( 14 ) << std::right << "-";
392 
393  std::cout << std::endl;
394 
395  // collect totals
396  nHistograms += it1->totalHistos_;
397  nBins += it1->totalBins_;
398  nEmptyBins += it1->totalEmptyBins_;
399  nBytes += it1->totalMemory_;
400 
401  }
402 
403 
404 
405 
406  overallNHistograms += nHistograms;
407  overallNBins += nBins;
408  overallNEmptyBins += nEmptyBins;
409  overallNBytes += nBytes;
410 
411  // display totals
412  std::cout << " " << std::setw( 30 ) << std::left << "SUBSYSTEM TOTAL";
413  std::cout << std::setw( 14 ) << std::right << nHistograms;
414  std::cout << std::setw( 14 ) << std::right << nBins;
415  std::cout << std::setw( 14 ) << std::right << nEmptyBins;
416  std::cout << std::setw( 14 ) << std::right << (float)nEmptyBins/(float)nBins;
417  std::cout << std::setw( 14 ) << std::right << std::setprecision( 3 ) << nBins / float( nHistograms );
418  std::cout << std::setw( 14 ) << std::right << std::setprecision( 3 ) << nBytes / 1024. / 1000.;
419  std::cout << std::setw( 14 ) << std::right << std::setprecision( 3 ) << nBytes / 1024. / nHistograms;
420  std::cout << std::endl;
421 
422  std::cout << ".........................................................................................." << std::endl;
423 
424  }
425 
426 
427  // dump total
428  std::cout << std::endl;
429  std::cout << "------------------------------------------------------------------------------------------" << std::endl;
430  std::cout << "Grand total ";
431  if( mode == DQMStoreStats::considerAllME ) std::cout << "FOR ALL ME:" << std::endl;
432  else if( mode == DQMStoreStats::considerOnlyLumiProductME ) std::cout << "FOR LUMI PRODUCTS ONLY:" << std::endl;
433  std::cout << "------------------------------------------------------------------------------------------" << std::endl;
434  std::cout << "Number of subsystems: " << dqmStoreStatsTopLevel.size() << std::endl;
435  std::cout << "Total number of histograms: " << overallNHistograms << " with: " << overallNBins << " bins alltogether" << std::endl;
436  std::cout << "Total memory occupied by histograms (excl. overhead): " << overallNBytes / 1024. / 1000. << " MB" << std::endl;
437 
438 
439 
440  std::cout << endl;
441  std::cout << "===========================================================================================" << std::endl;
442  std::cout << "[DQMStoreStats::calcstats] -- End of output ";
443  if( mode == DQMStoreStats::considerAllME ) std::cout << "FOR ALL ME." << std::endl;
444  else if( mode == DQMStoreStats::considerOnlyLumiProductME ) std::cout << "FOR LUMI PRODUCTS ONLY." << std::endl;
445  std::cout << "===========================================================================================" << std::endl;
446  std::cout << endl;
447 
448  // Put together a simplified version of the complete dump that is
449  // sent to std::cout. Just dump the very basic information,
450  // i.e. summary for each folder, both for run and LS products.
451  if (dumpToFWJR_)
452  {
454  // Do not even try if the FWJR service is not available.
455  if (!jr.isAvailable())
456  return 0;
457  // Prepare appropriate map to store FWJR output.
458  std::map<std::string, std::string> jrInfo;
459  unsigned int overallNHistograms = 0, overallNBins = 0, overallNBytes = 0;
460 
461  jrInfo["Source"] = "DQMServices/Components";
462  jrInfo["FileClass"] = "DQMStoreStats";
463  if (runonendrun_)
464  jrInfo["DumpType"] = "EndRun";
465  if (runonendlumi_)
466  jrInfo["DumpType"] = "EndLumi";
467  if (runonendjob_)
468  jrInfo["DumpType"] = "EndJob";
469  if (runineventloop_)
470  jrInfo["DumpType"] = "EventLoop";
472  jrInfo["Type"] = "RunProduct";
474  jrInfo["Type"] = "LumiProduct";
475 
476 
477  jrInfo["pathNameMatch"] = pathnamematch_;
478 
479  for (DQMStoreStatsTopLevel::const_iterator it0 = dqmStoreStatsTopLevel.begin(); it0 < dqmStoreStatsTopLevel.end(); ++it0 )
480  {
481  unsigned int nHistograms = 0, nBins = 0, nEmptyBins = 0, nBytes = 0;
482  for( DQMStoreStatsSubsystem::const_iterator it1 = it0->begin(); it1 < it0->end(); ++it1 ) {
483  // collect totals
484  nHistograms += it1->totalHistos_;
485  nBins += it1->totalBins_;
486  nEmptyBins += it1->totalEmptyBins_;
487  nBytes += it1->totalMemory_;
488  }
489  overallNHistograms += nHistograms;
490  overallNBins += nBins;
491  overallNBytes += nBytes;
492  std::stringstream iss("");
493  iss << nHistograms;
494  jrInfo[it0->subsystemName_ + std::string("_h")] = iss.str();
495  iss.str("");iss<<nBins;
496  jrInfo[it0->subsystemName_ + std::string("_b")] = iss.str();
497  iss.str("");iss<<nEmptyBins;
498  jrInfo[it0->subsystemName_ + std::string("_be")] = iss.str();
499  iss.str("");iss<< ((float)nEmptyBins/(float)nBins);
500  jrInfo[it0->subsystemName_ + std::string("_fbe")] = iss.str();
501  iss.str("");iss<< ((float)nBins/(float)nHistograms);
502  jrInfo[it0->subsystemName_ + std::string("_b_h")] = iss.str();
503  iss.str("");iss<<nBytes / 1024. / 1024.;
504  jrInfo[it0->subsystemName_ + std::string("_MB")] = iss.str();
505  iss.str("");iss<<nBytes / 1024. / nHistograms;
506  jrInfo[it0->subsystemName_ + std::string("_Kb_h")] = iss.str();
507  }
508  jr->reportAnalysisFile("DQMStatsReport", jrInfo);
509  }
510 
511  return 0;
512 
513 }
std::string subfolderName_
Definition: DQMStoreStats.h:44
DQMStore * dbe_
void AddBinsS(unsigned int nBins, unsigned int nEmptyBins)
Definition: DQMStoreStats.h:50
void update(unsigned int bins, unsigned int empty, unsigned int memory)
Definition: vlib.h:187
void AddBinsD(unsigned int nBins, unsigned int nEmptyBins)
Definition: DQMStoreStats.h:51
std::vector< MonitorElement * > getMatchingContents(const std::string &pattern, lat::Regexp::Syntax syntaxType=lat::Regexp::Wildcard) const
Definition: DQMStore.cc:1691
std::string subsystemName_
Definition: DQMStoreStats.h:61
MB
Load tools to build workspace.
Definition: ME.h:11
int calcstats(int)
list path
Definition: scaleCards.py:51
std::string pathnamematch_
bool isAvailable() const
Definition: Service.h:47
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)
Definition: DQMStoreStats.h:49
void calcIgProfDump(Folder &)
perl if(1 lt scalar(@::datatypes))
Definition: edlooper.cc:31
tuple cout
Definition: gather_cfg.py:121
tuple size
Write out results.
void DQMStoreStats::dumpMemoryProfile ( void  )
private

Definition at line 520 of file DQMStoreStats.cc.

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

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

520  {
521 
522  std::cout << std::endl;
523  std::cout << "------------------------------------------------------------------------------------------" << std::endl;
524  std::cout << "Memory profile:" << std::endl;
525  std::cout << "------------------------------------------------------------------------------------------" << std::endl;
526 
527  // determine virtual memory maximum
528  std::pair<time_t, unsigned int> maxItem( 0, 0 );
529  for( std::vector<std::pair<time_t, unsigned int> >::const_iterator it = memoryHistoryVector_.begin();
530  it < memoryHistoryVector_.end(); ++it ) {
531  if( it->second > maxItem.second ) {
532  maxItem = *it;
533  }
534  }
535 
536  std::stringstream rootOutputFileName;
537  rootOutputFileName << "dqmStoreStats_memProfile_" << getpid() << ".root";
538 
539  // dump memory history to root file
541 
542  TFile outputFile( rootOutputFileName.str().c_str(), "RECREATE" );
543 
544  int aTime;
545  float aMb;
546 
547  TTree memHistoryTree( "dqmstorestats_memhistory", "memory history" );
548  memHistoryTree.Branch( "seconds", &aTime, "seconds/I" );
549  memHistoryTree.Branch( "megabytes", &aMb, "megabytes/F" );
550  for( std::vector<std::pair<time_t, unsigned int> >::const_iterator it = memoryHistoryVector_.begin();
551  it < memoryHistoryVector_.end(); ++it ) {
552  aTime = it->first - startingTime_;
553  aMb = it->second / 1000.;
554  memHistoryTree.Fill();
555  }
556 
557  outputFile.Write();
558  outputFile.Close();
559 
560  }
561 
562  std::cout << "Approx. maximum total virtual memory size of job: ";
564  std::cout << maxItem.second / 1000.
565  << " MB (reached " << maxItem.first - startingTime_ << " sec. after constructor called)," << std::endl;
566  std::cout << " memory history written to: " << rootOutputFileName.str() << " (" << memoryHistoryVector_.size() << " samples)" << std::endl;
567  } else {
568  std::cout << "(could not be determined)" << std::endl;
569  }
570 
571  std::cout << std::endl << std::endl;
572 
573 }
std::vector< std::pair< time_t, unsigned int > > memoryHistoryVector_
time_t startingTime_
bool isOpenProcFileSuccessful_
tuple cout
Definition: gather_cfg.py:121
void DQMStoreStats::endJob ( void  )
protectedvirtual
void DQMStoreStats::endLuminosityBlock ( const edm::LuminosityBlock lumiSeg,
const edm::EventSetup c 
)
protectedvirtual
void DQMStoreStats::endRun ( const edm::Run r,
const edm::EventSetup c 
)
protectedvirtual
void DQMStoreStats::print ( void  )
private

Definition at line 580 of file DQMStoreStats.cc.

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

580  {
581  // subsystem info printout
582  std::cout << " ---------- " << subsystem_ << " ---------- " << std::endl;
583  std::cout << " " << subfolder_ << ": " ;
584  std::cout << nmesubsys_ << " histograms with "
585  << nbinssubsys_ << " bins. " ;
586  if (nmesubsys_ > 0) std::cout << nbinssubsys_/nmesubsys_ << " bins/histogram " ;
587  std::cout << std::endl;
588  std::cout << " Largest histogram: " << maxbinsmesubsys_ << " with " <<
589  maxbinssubsys_ << " bins." << std::endl;
590 }
std::string subsystem_
std::string maxbinsmesubsys_
std::string subfolder_
tuple cout
Definition: gather_cfg.py:121
std::pair< unsigned int, unsigned int > DQMStoreStats::readMemoryEntry ( void  ) const
private

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

Definition at line 598 of file DQMStoreStats.cc.

References recoMuon::in, isOpenProcFileSuccessful_, procFileName_, and cond::rpcobgas::time.

Referenced by analyze().

598  {
599 
600  // see if initial test reading was successful
602 
603  std::ifstream procFile( procFileName_.str().c_str(), ios::in );
604 
605  std::string readBuffer( "" );
606  unsigned int memSize = 0;
607 
608  // scan procfile
609  while( !procFile.eof() ) {
610  procFile >> readBuffer;
611  if( std::string( "VmSize:" ) == readBuffer ) {
612  procFile >> memSize;
613  break;
614  }
615  }
616 
617  procFile.close();
618  return std::pair<time_t, unsigned int>( time( 0 ), memSize );
619  }
620 
621  return std::pair<time_t, unsigned int>( 0, 0 );
622 
623 }
bool isOpenProcFileSuccessful_
std::stringstream procFileName_

Member Data Documentation

DQMStore* DQMStoreStats::dbe_
private

Definition at line 333 of file DQMStoreStats.h.

Referenced by beginJob(), and calcstats().

bool DQMStoreStats::dumpMemHistory_
private

Definition at line 360 of file DQMStoreStats.h.

Referenced by DQMStoreStats(), and dumpMemoryProfile().

bool DQMStoreStats::dumpToFWJR_
private

Definition at line 361 of file DQMStoreStats.h.

Referenced by calcstats(), and DQMStoreStats().

bool DQMStoreStats::isOpenProcFileSuccessful_
private

Definition at line 353 of file DQMStoreStats.h.

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

int DQMStoreStats::maxbinsglobal_
private

Definition at line 342 of file DQMStoreStats.h.

Referenced by calcstats().

std::string DQMStoreStats::maxbinsmeglobal_
private

Definition at line 344 of file DQMStoreStats.h.

std::string DQMStoreStats::maxbinsmesubsys_
private

Definition at line 345 of file DQMStoreStats.h.

Referenced by print().

int DQMStoreStats::maxbinssubsys_
private

Definition at line 343 of file DQMStoreStats.h.

Referenced by calcstats(), and print().

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

Definition at line 351 of file DQMStoreStats.h.

Referenced by analyze(), and dumpMemoryProfile().

int DQMStoreStats::nbinsglobal_
private

Definition at line 338 of file DQMStoreStats.h.

Referenced by calcstats().

int DQMStoreStats::nbinssubsys_
private

Definition at line 339 of file DQMStoreStats.h.

Referenced by calcstats(), and print().

int DQMStoreStats::nmeglobal_
private

Definition at line 340 of file DQMStoreStats.h.

int DQMStoreStats::nmesubsys_
private

Definition at line 341 of file DQMStoreStats.h.

Referenced by print().

edm::ParameterSet DQMStoreStats::parameters_
private
std::string DQMStoreStats::pathnamematch_
private

Definition at line 348 of file DQMStoreStats.h.

Referenced by calcstats(), and DQMStoreStats().

std::stringstream DQMStoreStats::procFileName_
private

Definition at line 354 of file DQMStoreStats.h.

Referenced by beginJob(), and readMemoryEntry().

bool DQMStoreStats::runineventloop_
private

Definition at line 359 of file DQMStoreStats.h.

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

bool DQMStoreStats::runonendjob_
private

Definition at line 357 of file DQMStoreStats.h.

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

bool DQMStoreStats::runonendlumi_
private

Definition at line 358 of file DQMStoreStats.h.

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

bool DQMStoreStats::runonendrun_
private

Definition at line 356 of file DQMStoreStats.h.

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

time_t DQMStoreStats::startingTime_
private

Definition at line 352 of file DQMStoreStats.h.

Referenced by DQMStoreStats(), and dumpMemoryProfile().

int DQMStoreStats::statsdepth_
private

Definition at line 347 of file DQMStoreStats.h.

Referenced by DQMStoreStats().

std::string DQMStoreStats::subfolder_
private

Definition at line 337 of file DQMStoreStats.h.

Referenced by print().

std::string DQMStoreStats::subsystem_
private

Definition at line 336 of file DQMStoreStats.h.

Referenced by print().

int DQMStoreStats::verbose_
private

Definition at line 349 of file DQMStoreStats.h.

Referenced by DQMStoreStats().