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)
 

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 671 of file DQMStoreStats.cc.

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

671  {
672 
673  //now read virtual memory size from proc folder
674  memoryHistoryVector_.push_back( readMemoryEntry() );
675 
676  if (runineventloop_) {
680  }
681 
682 }
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 629 of file DQMStoreStats.cc.

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

629  {
630 
633 
634  // access the proc/ folder for memory information
635  procFileName_ << "/proc/" << getpid() << "/status";
636 
637  // open for a test
638  std::ifstream procFile( procFileName_.str().c_str(), ios::in );
639 
640  if( procFile.good() ) {
642  }
643  else {
644  std::cerr << " [DQMStoreStats::beginJob] ** WARNING: could not open file: " << procFileName_.str() << std::endl;
645  std::cerr << " Total memory profile will not be available." << std::endl;
647  }
648 
649  procFile.close();
650 
651 }
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 663 of file DQMStoreStats.cc.

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

Reimplemented from edm::EDAnalyzer.

Definition at line 656 of file DQMStoreStats.cc.

656  {
657 }
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_, mode, nbinsglobal_, nbinssubsys_, 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() ));
205  break;
206  }
207  curr = curr->cd(path.substr( subfolderStringBegin, subfolderStringEnd-subfolderStringBegin ));
208  subfolderStringBegin = subfolderStringEnd+1;
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  }
224 
225  // get subfolder name (if there is one..)
226  if( path.size() == subsysStringEnd ) {
227  // no subfolders in subsystem, make dummy
228  DQMStoreStatsSubfolder aSubfolder;
229  aSubfolder.subfolderName_ = subsystemname; // <-- for tagging this case
230  dqmStoreStatsTopLevel.back().push_back( aSubfolder );
231  }
232 
233  else {
234 
235  // there is a subfolder, get its name
236  subfolderStringEnd = path.find( '/', subsysStringEnd + 1 );
237  if( std::string::npos == subfolderStringEnd ) subfolderStringEnd = path.size();
238 
239  // new subfolder?
240  if( path.substr( subsysStringEnd + 1, subfolderStringEnd - subsysStringEnd - 1 ) != subfoldername ) {
241  subfoldername = path.substr( subsysStringEnd + 1, subfolderStringEnd - subsysStringEnd - 1 );
242  DQMStoreStatsSubfolder aSubfolder;
243  aSubfolder.subfolderName_ = subfoldername;
244  dqmStoreStatsTopLevel.back().push_back( aSubfolder );
245  }
246 
247  }
248 
249  // shortcut
250  DQMStoreStatsSubfolder& currentSubfolder = dqmStoreStatsTopLevel.back().back();
251 
252  switch( (*it)->kind() ) {
253 
254  // one-dim ME
256  currentSubfolder.AddBinsF( (*it)->getNbinsX(), getEmptyMetric((*it)->getTH1F()->GetArray(), (*it)->getTH1F()->fN, 0, 0) );
257  curr->update( (*it)->getNbinsX(), getEmptyMetric((*it)->getTH1F()->GetArray(), (*it)->getTH1F()->fN, 0, 0), (*it)->getNbinsX()*sizeof( float ) );
258  break;
260  currentSubfolder.AddBinsS( (*it)->getNbinsX(), getEmptyMetric((*it)->getTH1S()->GetArray(), (*it)->getTH1S()->fN, 0, 0) );
261  curr->update( (*it)->getNbinsX(), getEmptyMetric((*it)->getTH1S()->GetArray(), (*it)->getTH1S()->fN, 0, 0), (*it)->getNbinsX()*sizeof( short ) );
262  break;
264  currentSubfolder.AddBinsD( (*it)->getNbinsX(), getEmptyMetric((*it)->getTH1D()->GetArray(), (*it)->getTH1D()->fN, 0, 0) );
265  curr->update( (*it)->getNbinsX(), getEmptyMetric((*it)->getTH1D()->GetArray(), (*it)->getTH1D()->fN, 0, 0), (*it)->getNbinsX()*sizeof( double ) );
266  break;
268  currentSubfolder.AddBinsD( (*it)->getNbinsX(), getEmptyMetric((*it)->getTProfile()->GetArray(), (*it)->getTProfile()->fN, 0, 0) );
269  curr->update( (*it)->getNbinsX(), getEmptyMetric((*it)->getTProfile()->GetArray(), (*it)->getTProfile()->fN, 0, 0), (*it)->getNbinsX()*sizeof( double ) );
270  break;
271 
272  // two-dim ME
274  currentSubfolder.AddBinsF( (*it)->getNbinsX() * (*it)->getNbinsY(), getEmptyMetric((*it)->getTH2F()->GetArray(), (*it)->getNbinsX()+2, (*it)->getNbinsY()+2, 0) );
275  curr->update( (*it)->getNbinsX() * (*it)->getNbinsY(), getEmptyMetric((*it)->getTH2F()->GetArray(), (*it)->getNbinsX()+2, (*it)->getNbinsY()+2, 0), (*it)->getNbinsX() * (*it)->getNbinsY()*sizeof(float) );
276  break;
278  currentSubfolder.AddBinsS( (*it)->getNbinsX() * (*it)->getNbinsY(), getEmptyMetric((*it)->getTH2S()->GetArray(), (*it)->getNbinsX()+2, (*it)->getNbinsY()+2, 0) );
279  curr->update( (*it)->getNbinsX() * (*it)->getNbinsY(), getEmptyMetric((*it)->getTH2S()->GetArray(), (*it)->getNbinsX()+2, (*it)->getNbinsY()+2, 0), (*it)->getNbinsX() * (*it)->getNbinsY()*sizeof(short) );
280  break;
282  currentSubfolder.AddBinsD( (*it)->getNbinsX() * (*it)->getNbinsY(), getEmptyMetric((*it)->getTH2D()->GetArray(), (*it)->getNbinsX()+2, (*it)->getNbinsY()+2, 0) );
283  curr->update( (*it)->getNbinsX() * (*it)->getNbinsY(), getEmptyMetric((*it)->getTH2D()->GetArray(), (*it)->getNbinsX()+2, (*it)->getNbinsY()+2, 0), (*it)->getNbinsX() * (*it)->getNbinsY()*sizeof(double) );
284  break;
286  currentSubfolder.AddBinsD( (*it)->getNbinsX() * (*it)->getNbinsY(), getEmptyMetric((*it)->getTProfile2D()->GetArray(), (*it)->getNbinsX()+2, (*it)->getNbinsY()+2, 0) );
287  curr->update( (*it)->getNbinsX() * (*it)->getNbinsY(), getEmptyMetric((*it)->getTProfile2D()->GetArray(), (*it)->getNbinsX()+2, (*it)->getNbinsY()+2, 0), (*it)->getNbinsX() * (*it)->getNbinsY()*sizeof(double) );
288  break;
289 
290  // three-dim ME
292  currentSubfolder.AddBinsF( (*it)->getNbinsX() * (*it)->getNbinsY() * (*it)->getNbinsZ(), getEmptyMetric( (*it)->getTH3F()->GetArray(), (*it)->getNbinsX()+2, (*it)->getNbinsY()+2, (*it)->getNbinsZ()+2 ) );
293  curr->update( (*it)->getNbinsX() * (*it)->getNbinsY() * (*it)->getNbinsZ(),
294  getEmptyMetric( (*it)->getTH3F()->GetArray(), (*it)->getNbinsX()+2, (*it)->getNbinsY()+2, (*it)->getNbinsZ()+2 ),
295  (*it)->getNbinsX() * (*it)->getNbinsY() * (*it)->getNbinsZ()*sizeof(float));
296  break;
297 
298  default: {}
299  // here we have a DQM_KIND_INVALID, DQM_KIND_INT, DQM_KIND_REAL or DQM_KIND_STRING
300  // which we don't care much about. Alternatively:
301 
302  // std::cerr << "[DQMStoreStats::calcstats] ** WARNING: monitor element of kind: "
303  // << (*it)->kind() << ", name: \"" << (*it)->getName() << "\"\n"
304  // << " in path: \"" << path << "\" not considered." << std::endl;
305  }
306  }
307 
309  calcIgProfDump(dbeFolder);
310 
311  // OUTPUT
312 
313  std::cout << endl;
314  std::cout << "===========================================================================================" << std::endl;
315  std::cout << "[DQMStoreStats::calcstats] -- Dumping stats results ";
316  if( mode == DQMStoreStats::considerAllME ) std::cout << "FOR ALL ME" << std::endl;
317  else if( mode == DQMStoreStats::considerOnlyLumiProductME ) std::cout << "FOR LUMI PRODUCTS ONLY" << std::endl;
318  std::cout << "===========================================================================================" << std::endl;
319  std::cout << endl;
320 
321  std::cout << "------------------------------------------------------------------------------------------" << std::endl;
322  std::cout << "Configuration:" << std::endl;
323  std::cout << "------------------------------------------------------------------------------------------" << std::endl;
324  std::cout << " > running ";
325  if (runonendrun_) std::cout << "on run end." << std::endl;
326  if (runonendlumi_) std::cout << "on lumi end." << std::endl;
327  if (runonendjob_) std::cout << "on job end." << std::endl;
328  if (runineventloop_) std::cout << "in event loop." << std::endl;
329  std::cout << " > pathNameMatch = \"" << pathnamematch_ << "\"" << std::endl;
330  std::cout << std::endl;
331 
332  // dump folder structure
333  std::cout << "------------------------------------------------------------------------------------------" << std::endl;
334  std::cout << "Top level folder tree:" << std::endl;
335  std::cout << "------------------------------------------------------------------------------------------" << std::endl;
336  for( DQMStoreStatsTopLevel::const_iterator it0 = dqmStoreStatsTopLevel.begin(); it0 < dqmStoreStatsTopLevel.end(); ++it0 ) {
337  std::cout << it0->subsystemName_ << " (subsystem)" << std::endl;
338 
339  for( DQMStoreStatsSubsystem::const_iterator it1 = it0->begin(); it1 < it0->end(); ++it1 ) {
340  std::cout << " |--> " << it1->subfolderName_ << " (subfolder)" << std::endl;
341  }
342 
343  }
344 
345  // dump mem/bin table
346 
347  unsigned int overallNHistograms = 0, overallNBins = 0, overallNEmptyBins = 0, overallNBytes = 0;
348 
349  std::cout << std::endl;
350  std::cout << "------------------------------------------------------------------------------------------" << std::endl;
351  std::cout << "Detailed ressource usage information ";
352  if( mode == DQMStoreStats::considerAllME ) std::cout << "FOR ALL ME" << std::endl;
353  else if( mode == DQMStoreStats::considerOnlyLumiProductME ) std::cout << "FOR LUMI PRODUCTS ONLY" << std::endl;
354  std::cout << "------------------------------------------------------------------------------------------" << std::endl;
355  std::cout << "subsystem/folder histograms bins Empty bins Empty/Total bins per MB kB per" << std::endl;
356  std::cout << " (total) (total) (total) histogram (total) histogram " << std::endl;
357  std::cout << "------------------------------------------------------------------------------------------" << std::endl;
358  for( DQMStoreStatsTopLevel::const_iterator it0 = dqmStoreStatsTopLevel.begin(); it0 < dqmStoreStatsTopLevel.end(); ++it0 ) {
359  std::cout << it0->subsystemName_ << std::endl;
360 
361  unsigned int nHistograms = 0, nBins = 0, nEmptyBins = 0, nBytes = 0;
362 
363  for( DQMStoreStatsSubsystem::const_iterator it1 = it0->begin(); it1 < it0->end(); ++it1 ) {
364 
365  // fixed-size working copy
366  std::string thisSubfolderName( it1->subfolderName_ );
367  if( thisSubfolderName.size() > 30 ) {
368  thisSubfolderName.resize( 30 );
369  thisSubfolderName.replace( thisSubfolderName.size() - 3, 3, 3, '.' );
370  }
371 
372  std::cout << " -> " << std::setw( 30 ) << std::left << thisSubfolderName;
373  std::cout << std::setw( 14 ) << std::right << it1->totalHistos_;
374  std::cout << std::setw( 14 ) << std::right << it1->totalBins_;
375  std::cout << std::setw( 14 ) << std::right << it1->totalEmptyBins_;
376  std::cout << std::setw( 14 ) << std::right << std::setprecision( 3 ) << (float)it1->totalEmptyBins_/(float)it1->totalBins_;
377 
378  // bins/histogram, need to catch nan if histos=0
379  if( it1->totalHistos_ ) {
380  std::cout << std::setw( 14 ) << std::right << std::setprecision( 3 ) << it1->totalBins_ / float( it1->totalHistos_ );
381  }
382  else std::cout << std::setw( 14 ) << std::right << "-";
383 
384  std::cout << std::setw( 14 ) << std::right << std::setprecision( 3 ) << it1->totalMemory_ / 1024. / 1024.;
385 
386  // mem/histogram, need to catch nan if histos=0
387  if( it1->totalHistos_ ) {
388  std::cout << std::setw( 14 ) << std::right << std::setprecision( 3 ) << it1->totalMemory_ / 1024. / it1->totalHistos_;
389  }
390  else std::cout << std::setw( 14 ) << std::right << "-";
391 
392  std::cout << std::endl;
393 
394  // collect totals
395  nHistograms += it1->totalHistos_;
396  nBins += it1->totalBins_;
397  nEmptyBins += it1->totalEmptyBins_;
398  nBytes += it1->totalMemory_;
399 
400  }
401 
402 
403 
404 
405  overallNHistograms += nHistograms;
406  overallNBins += nBins;
407  overallNEmptyBins += nEmptyBins;
408  overallNBytes += nBytes;
409 
410  // display totals
411  std::cout << " " << std::setw( 30 ) << std::left << "SUBSYSTEM TOTAL";
412  std::cout << std::setw( 14 ) << std::right << nHistograms;
413  std::cout << std::setw( 14 ) << std::right << nBins;
414  std::cout << std::setw( 14 ) << std::right << nEmptyBins;
415  std::cout << std::setw( 14 ) << std::right << (float)nEmptyBins/(float)nBins;
416  std::cout << std::setw( 14 ) << std::right << std::setprecision( 3 ) << nBins / float( nHistograms );
417  std::cout << std::setw( 14 ) << std::right << std::setprecision( 3 ) << nBytes / 1024. / 1000.;
418  std::cout << std::setw( 14 ) << std::right << std::setprecision( 3 ) << nBytes / 1024. / nHistograms;
419  std::cout << std::endl;
420 
421  std::cout << ".........................................................................................." << std::endl;
422 
423  }
424 
425 
426  // dump total
427  std::cout << std::endl;
428  std::cout << "------------------------------------------------------------------------------------------" << std::endl;
429  std::cout << "Grand total ";
430  if( mode == DQMStoreStats::considerAllME ) std::cout << "FOR ALL ME:" << std::endl;
431  else if( mode == DQMStoreStats::considerOnlyLumiProductME ) std::cout << "FOR LUMI PRODUCTS ONLY:" << std::endl;
432  std::cout << "------------------------------------------------------------------------------------------" << std::endl;
433  std::cout << "Number of subsystems: " << dqmStoreStatsTopLevel.size() << std::endl;
434  std::cout << "Total number of histograms: " << overallNHistograms << " with: " << overallNBins << " bins alltogether" << std::endl;
435  std::cout << "Total memory occupied by histograms (excl. overhead): " << overallNBytes / 1024. / 1000. << " MB" << std::endl;
436 
437 
438 
439  std::cout << endl;
440  std::cout << "===========================================================================================" << std::endl;
441  std::cout << "[DQMStoreStats::calcstats] -- End of output ";
442  if( mode == DQMStoreStats::considerAllME ) std::cout << "FOR ALL ME." << std::endl;
443  else if( mode == DQMStoreStats::considerOnlyLumiProductME ) std::cout << "FOR LUMI PRODUCTS ONLY." << std::endl;
444  std::cout << "===========================================================================================" << std::endl;
445  std::cout << endl;
446 
447  // Put together a simplified version of the complete dump that is
448  // sent to std::cout. Just dump the very basic information,
449  // i.e. summary for each folder, both for run and LS products.
450  if (dumpToFWJR_)
451  {
453  // Do not even try if the FWJR service is not available.
454  if (!jr.isAvailable())
455  return 0;
456  // Prepare appropriate map to store FWJR output.
457  std::map<std::string, std::string> jrInfo;
458  unsigned int overallNHistograms = 0, overallNBins = 0, overallNBytes = 0;
459 
460  jrInfo["Source"] = "DQMServices/Components";
461  jrInfo["FileClass"] = "DQMStoreStats";
462  if (runonendrun_)
463  jrInfo["DumpType"] = "EndRun";
464  if (runonendlumi_)
465  jrInfo["DumpType"] = "EndLumi";
466  if (runonendjob_)
467  jrInfo["DumpType"] = "EndJob";
468  if (runineventloop_)
469  jrInfo["DumpType"] = "EventLoop";
471  jrInfo["Type"] = "RunProduct";
473  jrInfo["Type"] = "LumiProduct";
474 
475 
476  jrInfo["pathNameMatch"] = pathnamematch_;
477 
478  for (DQMStoreStatsTopLevel::const_iterator it0 = dqmStoreStatsTopLevel.begin(); it0 < dqmStoreStatsTopLevel.end(); ++it0 )
479  {
480  unsigned int nHistograms = 0, nBins = 0, nEmptyBins = 0, nBytes = 0;
481  for( DQMStoreStatsSubsystem::const_iterator it1 = it0->begin(); it1 < it0->end(); ++it1 ) {
482  // collect totals
483  nHistograms += it1->totalHistos_;
484  nBins += it1->totalBins_;
485  nEmptyBins += it1->totalEmptyBins_;
486  nBytes += it1->totalMemory_;
487  }
488  overallNHistograms += nHistograms;
489  overallNBins += nBins;
490  overallNBytes += nBytes;
491  std::stringstream iss("");
492  iss << nHistograms;
493  jrInfo[it0->subsystemName_ + std::string("_h")] = iss.str();
494  iss.str("");iss<<nBins;
495  jrInfo[it0->subsystemName_ + std::string("_b")] = iss.str();
496  iss.str("");iss<<nEmptyBins;
497  jrInfo[it0->subsystemName_ + std::string("_be")] = iss.str();
498  iss.str("");iss<< ((float)nEmptyBins/(float)nBins);
499  jrInfo[it0->subsystemName_ + std::string("_fbe")] = iss.str();
500  iss.str("");iss<< ((float)nBins/(float)nHistograms);
501  jrInfo[it0->subsystemName_ + std::string("_b_h")] = iss.str();
502  iss.str("");iss<<nBytes / 1024. / 1024.;
503  jrInfo[it0->subsystemName_ + std::string("_MB")] = iss.str();
504  iss.str("");iss<<nBytes / 1024. / nHistograms;
505  jrInfo[it0->subsystemName_ + std::string("_Kb_h")] = iss.str();
506  }
507  jr->reportAnalysisFile("DQMStatsReport", jrInfo);
508  }
509 
510  return 0;
511 
512 }
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:1488
std::string subsystemName_
Definition: DQMStoreStats.h:61
return((rh^lh)&mask)
int path() const
Definition: HLTadd.h:3
Definition: ME.h:11
int calcstats(int)
std::string pathnamematch_
bool isAvailable() const
Definition: Service.h:47
static unsigned int getEmptyMetric(T *array, int lenx, int leny, int lenz)
int mode
Definition: AMPTWrapper.h:139
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:41
tuple size
Write out results.
void DQMStoreStats::dumpMemoryProfile ( void  )
private

Definition at line 519 of file DQMStoreStats.cc.

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

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

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

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

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

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

Definition at line 597 of file DQMStoreStats.cc.

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

Referenced by analyze().

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