CMS 3D CMS Logo

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

Public Member Functions

 DQMRootOutputModule (edm::ParameterSet const &pset)
 
virtual ~DQMRootOutputModule ()
 
- Public Member Functions inherited from edm::OutputModule
BranchChildren const & branchChildren () const
 
boost::array< bool,
NumBranchTypes > const & 
hasNewlyDroppedBranch () const
 
SelectionsArray const & keptProducts () const
 
int maxEvents () const
 
 OutputModule (ParameterSet const &pset)
 
std::string const & processName () const
 
int remainingEvents () const
 
bool selected (BranchDescription const &desc) const
 
void selectProducts ()
 
bool wantAllEvents () const
 
virtual ~OutputModule ()
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 
- Static Public Member Functions inherited from edm::OutputModule
static const std::string & baseType ()
 
static void fillDescription (ParameterSetDescription &desc)
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 

Private Member Functions

virtual void beginRun (edm::RunPrincipal const &r)
 
virtual void finishEndFile ()
 
virtual void startEndFile ()
 
virtual void write (edm::EventPrincipal const &e)
 
virtual void writeLuminosityBlock (edm::LuminosityBlockPrincipal const &)
 
virtual void writeRun (edm::RunPrincipal const &)
 

Private Attributes

ULong64_t m_beginTime
 
std::map< unsigned int,
unsigned int > 
m_dqmKindToTypeIndex
 
ULong64_t m_endTime
 
std::auto_ptr< TFile > m_file
 
std::string m_fileName
 
ULong64_t m_firstIndex
 
std::string m_fullNameBuffer
 
std::string * m_fullNameBufferPtr
 
TTree * m_indicesTree
 
edm::JobReport::Token m_jrToken
 
ULong64_t m_lastIndex
 
std::string m_logicalFileName
 
unsigned int m_lumi
 
unsigned int m_presentHistoryIndex
 
unsigned int m_run
 
std::vector
< edm::ProcessHistoryID
m_seenHistories
 
std::vector< boost::shared_ptr
< TreeHelperBase > > 
m_treeHelpers
 
unsigned int m_type
 

Additional Inherited Members

- Public Types inherited from edm::OutputModule
typedef OutputModule ModuleType
 
typedef OutputWorker WorkerType
 
- Protected Member Functions inherited from edm::OutputModule
CurrentProcessingContext const * currentContext () const
 
ModuleDescription const & description () const
 
void doBeginJob ()
 
bool doBeginLuminosityBlock (LuminosityBlockPrincipal const &lbp, EventSetup const &c, CurrentProcessingContext const *cpc)
 
bool doBeginRun (RunPrincipal const &rp, EventSetup const &c, CurrentProcessingContext const *cpc)
 
void doEndJob ()
 
bool doEndLuminosityBlock (LuminosityBlockPrincipal const &lbp, EventSetup const &c, CurrentProcessingContext const *cpc)
 
bool doEndRun (RunPrincipal const &rp, EventSetup const &c, CurrentProcessingContext const *cpc)
 
bool doEvent (EventPrincipal const &ep, EventSetup const &c, CurrentProcessingContext const *cpc)
 
Trig getTriggerResults (Event const &ep) const
 
Trig getTriggerResults (EventPrincipal const &ep) const
 
ParameterSetID selectorConfig () const
 

Detailed Description

Definition at line 174 of file DQMRootOutputModule.cc.

Constructor & Destructor Documentation

DQMRootOutputModule::DQMRootOutputModule ( edm::ParameterSet const &  pset)
explicit

Definition at line 255 of file DQMRootOutputModule.cc.

References cms::Digest::digest(), MonitorElement::DQM_KIND_INT, MonitorElement::DQM_KIND_REAL, MonitorElement::DQM_KIND_STRING, 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, edm::ParameterSet::getParameter(), i, kBeginTimeBranch, kEndTimeBranch, kFirstIndex, kFloatIndex, kIndicesTree, kIntIndex, kLastIndex, kLumiBranch, kProcessHistoryIndexBranch, kRunBranch, kStringIndex, kTH1DIndex, kTH1FIndex, kTH1SIndex, kTH2DIndex, kTH2FIndex, kTH2SIndex, kTH3FIndex, kTProfile2DIndex, kTProfileIndex, kTypeBranch, kTypeNames, m_beginTime, m_dqmKindToTypeIndex, m_endTime, m_file, m_fileName, m_firstIndex, m_fullNameBufferPtr, m_indicesTree, m_jrToken, m_lastIndex, m_logicalFileName, m_lumi, m_presentHistoryIndex, m_run, m_treeHelpers, m_type, makeHelper(), edm::JobReport::outputFileOpened(), cms::MD5Result::toString(), and diffTreeTool::tree.

255  :
257 m_fileName(pset.getUntrackedParameter<std::string>("fileName")),
258 m_logicalFileName(pset.getUntrackedParameter<std::string>("logicalFileName","")),
259 m_file(0),
260 m_treeHelpers(kNIndicies,boost::shared_ptr<TreeHelperBase>()),
263 m_indicesTree(0)
264 {
265  //NOTE: I need to also set the I/O performance settings
266 
267  m_file = std::auto_ptr<TFile>(new TFile(m_fileName.c_str(),"CREATE",
268  "1" //This is the file format version number
269  ));
270 
272  cms::Digest branchHash;
275  std::string(),
276  "DQMRootOutputModule",
277  pset.getParameter<std::string>("@module_label"),
278  m_file->GetUUID().AsString(),
279  std::string(),
280  branchHash.digest().toString(),
281  std::vector<std::string>()
282  );
283 
284 
286  m_indicesTree->Branch(kRunBranch,&m_run);
287  m_indicesTree->Branch(kLumiBranch,&m_lumi);
291  m_indicesTree->Branch(kTypeBranch,&m_type);
294  m_indicesTree->SetDirectory(m_file.get());
295 
296  unsigned int i = 0;
297  for(std::vector<boost::shared_ptr<TreeHelperBase> >::iterator it = m_treeHelpers.begin(), itEnd = m_treeHelpers.end();
298  it != itEnd;
299  ++it,++i) {
300  //std::cout <<"making "<<kTypeNames[i]<<std::endl;
301  TTree* tree = new TTree(kTypeNames[i],kTypeNames[i]);
302  *it = boost::shared_ptr<TreeHelperBase>(makeHelper(i,tree,m_fullNameBufferPtr));
303  tree->SetDirectory(m_file.get()); //TFile takes ownership
304  }
305 
318 }
Token outputFileOpened(std::string const &physicalFileName, std::string const &logicalFileName, std::string const &catalog, std::string const &outputModuleClassName, std::string const &moduleLabel, std::string const &guid, std::string const &dataType, std::string const &branchHash, std::vector< std::string > const &branchNames)
Definition: JobReport.cc:528
int i
Definition: DBlmapReader.cc:9
static const char *const kRunBranch
Definition: format.h:42
static const char *const kTypeNames[]
Definition: format.h:29
static const char *const kIndicesTree
Definition: format.h:41
unsigned int m_presentHistoryIndex
static TreeHelperBase * makeHelper(unsigned int iTypeIndex, TTree *iTree, std::string *iFullNameBufferPtr)
static const char *const kFirstIndex
Definition: format.h:48
static const char *const kLumiBranch
Definition: format.h:43
MD5Result digest() const
Definition: Digest.cc:188
std::map< unsigned int, unsigned int > m_dqmKindToTypeIndex
std::auto_ptr< TFile > m_file
static const char *const kTypeBranch
Definition: format.h:47
static const char *const kProcessHistoryIndexBranch
Definition: format.h:44
static const char *const kEndTimeBranch
Definition: format.h:46
std::vector< boost::shared_ptr< TreeHelperBase > > m_treeHelpers
std::string * m_fullNameBufferPtr
static const char *const kLastIndex
Definition: format.h:49
std::string toString() const
Definition: Digest.cc:87
static const char *const kBeginTimeBranch
Definition: format.h:45
edm::JobReport::Token m_jrToken
DQMRootOutputModule::~DQMRootOutputModule ( )
virtual

Definition at line 325 of file DQMRootOutputModule.cc.

326 {
327 }

Member Function Documentation

void DQMRootOutputModule::beginRun ( edm::RunPrincipal const &  r)
privatevirtual

Reimplemented from edm::OutputModule.

Definition at line 426 of file DQMRootOutputModule.cc.

References spr::find(), m_presentHistoryIndex, m_seenHistories, and edm::Principal::processHistoryID().

426  {
427  //The ProcessHistory for a lumi must be the same as its Run so we only need to
428  // record it at Run time
429  edm::ProcessHistoryID id = iPrincipal.processHistoryID();
430  std::vector<edm::ProcessHistoryID>::iterator itFind = std::find(m_seenHistories.begin(),m_seenHistories.end(),id);
431  if(itFind == m_seenHistories.end()) {
433  m_seenHistories.push_back(id);
434  } else {
435  m_presentHistoryIndex = itFind - m_seenHistories.begin();
436  }
437 }
unsigned int m_presentHistoryIndex
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:7
std::vector< edm::ProcessHistoryID > m_seenHistories
void DQMRootOutputModule::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 512 of file DQMRootOutputModule.cc.

References edm::ConfigurationDescriptions::addDefault(), and edm::ParameterSetDescription::setUnknown().

512  {
513  //The following says we do not know what parameters are allowed so do no validation
514  // Please change this to state exactly what you do use, even if it is no parameters
516  desc.setUnknown();
517  descriptions.addDefault(desc);
518 
519  //NOTE: when actually filling this in, do not forget to add a untracked PSet 'dataset'
520  // which is used for bookkeeping by the DMWM
521 }
void addDefault(ParameterSetDescription const &psetDescription)
void DQMRootOutputModule::finishEndFile ( )
privatevirtual

Reimplemented from edm::OutputModule.

Definition at line 497 of file DQMRootOutputModule.cc.

References m_file, m_jrToken, and edm::JobReport::outputFileClosed().

497  {
498  m_file->Write();
499  m_file->Close();
502 }
void outputFileClosed(Token fileToken)
Definition: JobReport.cc:567
std::auto_ptr< TFile > m_file
edm::JobReport::Token m_jrToken
void DQMRootOutputModule::startEndFile ( )
privatevirtual

Reimplemented from edm::OutputModule.

Definition at line 439 of file DQMRootOutputModule.cc.

References edm::ProcessHistory::begin(), edm::detail::ThreadSafeRegistry< KEY, T, E >::begin(), edm::ProcessHistory::end(), edm::detail::ThreadSafeRegistry< KEY, T, E >::end(), edm::detail::ThreadSafeRegistry< KEY, T, E >::getMapped(), getHLTprescales::index, edm::detail::ThreadSafeRegistry< KEY, T, E >::instance(), kMetaDataDirectory, kParameterSetBranch, kParameterSetTree, kPHIndexBranch, kProcessConfigurationParameterSetIDBranch, kProcessConfigurationPassID, kProcessConfigurationProcessNameBranch, kProcessConfigurationReleaseVersion, kProcessHistoryTree, m_file, m_seenHistories, and edm::OutputModule::processName().

439  {
440  //fill in the meta data
441  m_file->cd();
442  TDirectory* metaDataDirectory = m_file->mkdir(kMetaDataDirectory);
443 
444 
445  //Write out the Process History
446  TTree* processHistoryTree = new TTree(kProcessHistoryTree,kProcessHistoryTree);
447  processHistoryTree->SetDirectory(metaDataDirectory);
448 
449  unsigned int index = 0;
450  processHistoryTree->Branch(kPHIndexBranch,&index);
451  std::string processName;
452  processHistoryTree->Branch(kProcessConfigurationProcessNameBranch,&processName);
453  std::string parameterSetID;
454  processHistoryTree->Branch(kProcessConfigurationParameterSetIDBranch,&parameterSetID);
455  std::string releaseVersion;
456  processHistoryTree->Branch(kProcessConfigurationReleaseVersion,&releaseVersion);
457  std::string passID;
458  processHistoryTree->Branch(kProcessConfigurationPassID,&passID);
459 
461  assert(0!=phr);
462  for(std::vector<edm::ProcessHistoryID>::iterator it = m_seenHistories.begin(), itEnd = m_seenHistories.end();
463  it !=itEnd;
464  ++it) {
465  const edm::ProcessHistory* history = phr->getMapped(*it);
466  assert(0!=history);
467  index = 0;
468  for(edm::ProcessHistory::collection_type::const_iterator itPC = history->begin(), itPCEnd = history->end();
469  itPC != itPCEnd;
470  ++itPC,++index) {
471  processName = itPC->processName();
472  releaseVersion = itPC->releaseVersion();
473  passID = itPC->passID();
474  parameterSetID = itPC->parameterSetID().compactForm();
475  processHistoryTree->Fill();
476  }
477  }
478 
479  //Store the ParameterSets
480  TTree* parameterSetsTree = new TTree(kParameterSetTree,kParameterSetTree);
481  parameterSetsTree->SetDirectory(metaDataDirectory);
482  std::string blob;
483  parameterSetsTree->Branch(kParameterSetBranch,&blob);
484 
486  assert(0!=psr);
487  for(edm::pset::Registry::const_iterator it = psr->begin(), itEnd = psr->end();
488  it != itEnd;
489  ++it) {
490  blob.clear();
491  it->second.toString(blob);
492  parameterSetsTree->Fill();
493  }
494 
495 }
const_iterator begin() const
static const char *const kProcessHistoryTree
Definition: format.h:55
std::string const & processName() const
Definition: OutputModule.h:55
bool getMapped(key_type const &k, value_type &result) const
static const char *const kPHIndexBranch
Definition: format.h:56
static const char *const kParameterSetBranch
Definition: format.h:63
static const char *const kMetaDataDirectory
Definition: format.h:53
std::auto_ptr< TFile > m_file
collection_type::const_iterator const_iterator
static const char *const kParameterSetTree
Definition: format.h:62
static const char *const kProcessConfigurationPassID
Definition: format.h:60
static const char *const kProcessConfigurationReleaseVersion
Definition: format.h:59
static const char *const kProcessConfigurationProcessNameBranch
Definition: format.h:57
const_iterator end() const
static ThreadSafeRegistry * instance()
static const char *const kProcessConfigurationParameterSetIDBranch
Definition: format.h:58
std::vector< edm::ProcessHistoryID > m_seenHistories
void DQMRootOutputModule::write ( edm::EventPrincipal const &  e)
privatevirtual

Implements edm::OutputModule.

Definition at line 345 of file DQMRootOutputModule.cc.

345  {
346 
347 }
void DQMRootOutputModule::writeLuminosityBlock ( edm::LuminosityBlockPrincipal const &  iLumi)
privatevirtual

Implements edm::OutputModule.

Definition at line 349 of file DQMRootOutputModule.cc.

References edm::LuminosityBlockPrincipal::beginTime(), edm::LuminosityBlockPrincipal::endTime(), DQMStore::getAllContents(), edm::LuminosityBlockPrincipal::id(), kNoTypesStored, m_beginTime, m_dqmKindToTypeIndex, m_endTime, m_firstIndex, m_indicesTree, m_lastIndex, m_lumi, m_run, m_treeHelpers, m_type, edm::JobReport::reportLumiSection(), edm::LuminosityBlockID::run(), edm::LuminosityBlockID::value(), and edm::Timestamp::value().

349  {
350  edm::Service<DQMStore> dstore;
351  m_run=iLumi.id().run();
352  m_lumi = iLumi.id().value();
353  m_beginTime = iLumi.beginTime().value();
354  m_endTime = iLumi.endTime().value();
355 
356  std::vector<MonitorElement *> items(dstore->getAllContents(""));
357  for(std::vector<MonitorElement*>::iterator it = items.begin(), itEnd=items.end();
358  it!=itEnd;
359  ++it) {
360  if((*it)->getLumiFlag()) {
361  std::map<unsigned int,unsigned int>::iterator itFound = m_dqmKindToTypeIndex.find((*it)->kind());
362  assert(itFound !=m_dqmKindToTypeIndex.end());
363  m_treeHelpers[itFound->second]->fill(*it);
364  }
365  }
366  //Now store the relationship between run/lumi and indices in the other TTrees
367  bool storedLumiIndex = false;
368  unsigned int typeIndex = 0;
369  for(std::vector<boost::shared_ptr<TreeHelperBase> >::iterator it = m_treeHelpers.begin(), itEnd = m_treeHelpers.end();
370  it != itEnd;
371  ++it,++typeIndex) {
372  if((*it)->wasFilled()) {
373  m_type = typeIndex;
374  (*it)->getRangeAndReset(m_firstIndex,m_lastIndex);
375  storedLumiIndex = true;
376  m_indicesTree->Fill();
377  }
378  }
379  if(not storedLumiIndex) {
380  //need to record lumis even if we stored no MonitorElements since some later DQM modules
381  // look to see what lumis were processed
383  m_firstIndex=0;
384  m_lastIndex=0;
385  m_indicesTree->Fill();
386  }
387 
390 }
std::vector< MonitorElement * > getAllContents(const std::string &path) const
Definition: DQMStore.cc:1469
std::map< unsigned int, unsigned int > m_dqmKindToTypeIndex
std::vector< boost::shared_ptr< TreeHelperBase > > m_treeHelpers
void reportLumiSection(unsigned int run, unsigned int lumiSectId)
Definition: JobReport.cc:620
void DQMRootOutputModule::writeRun ( edm::RunPrincipal const &  iRun)
privatevirtual

Implements edm::OutputModule.

Definition at line 392 of file DQMRootOutputModule.cc.

References edm::RunPrincipal::beginTime(), edm::RunPrincipal::endTime(), DQMStore::getAllContents(), edm::RunPrincipal::id(), m_beginTime, m_dqmKindToTypeIndex, m_endTime, m_firstIndex, m_indicesTree, m_lastIndex, m_lumi, m_run, m_treeHelpers, m_type, edm::JobReport::reportRunNumber(), edm::RunID::run(), and edm::Timestamp::value().

392  {
393  edm::Service<DQMStore> dstore;
394  m_run=iRun.id().run();
395  m_lumi = 0;
396  m_beginTime = iRun.beginTime().value();
397  m_endTime = iRun.endTime().value();
398 
399  std::vector<MonitorElement *> items(dstore->getAllContents(""));
400  for(std::vector<MonitorElement*>::iterator it = items.begin(), itEnd=items.end();
401  it!=itEnd;
402  ++it) {
403  if(not (*it)->getLumiFlag()) {
404  std::map<unsigned int,unsigned int>::iterator itFound = m_dqmKindToTypeIndex.find((*it)->kind());
405  assert (itFound !=m_dqmKindToTypeIndex.end());
406  m_treeHelpers[itFound->second]->fill(*it);
407  }
408  }
409 
410  //Now store the relationship between run/lumi and indices in the other TTrees
411  unsigned int typeIndex = 0;
412  for(std::vector<boost::shared_ptr<TreeHelperBase> >::iterator it = m_treeHelpers.begin(), itEnd = m_treeHelpers.end();
413  it != itEnd;
414  ++it,++typeIndex) {
415  if((*it)->wasFilled()) {
416  m_type = typeIndex;
417  (*it)->getRangeAndReset(m_firstIndex,m_lastIndex);
418  m_indicesTree->Fill();
419  }
420  }
421 
423  jr->reportRunNumber(m_run);
424 }
std::vector< MonitorElement * > getAllContents(const std::string &path) const
Definition: DQMStore.cc:1469
std::map< unsigned int, unsigned int > m_dqmKindToTypeIndex
std::vector< boost::shared_ptr< TreeHelperBase > > m_treeHelpers
void reportRunNumber(unsigned int run)
Definition: JobReport.cc:630

Member Data Documentation

ULong64_t DQMRootOutputModule::m_beginTime
private

Definition at line 196 of file DQMRootOutputModule.cc.

Referenced by DQMRootOutputModule(), writeLuminosityBlock(), and writeRun().

std::map<unsigned int, unsigned int> DQMRootOutputModule::m_dqmKindToTypeIndex
private

Definition at line 203 of file DQMRootOutputModule.cc.

Referenced by DQMRootOutputModule(), writeLuminosityBlock(), and writeRun().

ULong64_t DQMRootOutputModule::m_endTime
private

Definition at line 197 of file DQMRootOutputModule.cc.

Referenced by DQMRootOutputModule(), writeLuminosityBlock(), and writeRun().

std::auto_ptr<TFile> DQMRootOutputModule::m_file
private

Definition at line 189 of file DQMRootOutputModule.cc.

Referenced by DQMRootOutputModule(), finishEndFile(), and startEndFile().

std::string DQMRootOutputModule::m_fileName
private

Definition at line 187 of file DQMRootOutputModule.cc.

Referenced by DQMRootOutputModule().

ULong64_t DQMRootOutputModule::m_firstIndex
private

Definition at line 198 of file DQMRootOutputModule.cc.

Referenced by DQMRootOutputModule(), writeLuminosityBlock(), and writeRun().

std::string DQMRootOutputModule::m_fullNameBuffer
private

Definition at line 201 of file DQMRootOutputModule.cc.

std::string* DQMRootOutputModule::m_fullNameBufferPtr
private

Definition at line 202 of file DQMRootOutputModule.cc.

Referenced by DQMRootOutputModule().

TTree* DQMRootOutputModule::m_indicesTree
private

Definition at line 204 of file DQMRootOutputModule.cc.

Referenced by DQMRootOutputModule(), writeLuminosityBlock(), and writeRun().

edm::JobReport::Token DQMRootOutputModule::m_jrToken
private

Definition at line 207 of file DQMRootOutputModule.cc.

Referenced by DQMRootOutputModule(), and finishEndFile().

ULong64_t DQMRootOutputModule::m_lastIndex
private

Definition at line 199 of file DQMRootOutputModule.cc.

Referenced by DQMRootOutputModule(), writeLuminosityBlock(), and writeRun().

std::string DQMRootOutputModule::m_logicalFileName
private

Definition at line 188 of file DQMRootOutputModule.cc.

Referenced by DQMRootOutputModule().

unsigned int DQMRootOutputModule::m_lumi
private

Definition at line 193 of file DQMRootOutputModule.cc.

Referenced by DQMRootOutputModule(), writeLuminosityBlock(), and writeRun().

unsigned int DQMRootOutputModule::m_presentHistoryIndex
private

Definition at line 195 of file DQMRootOutputModule.cc.

Referenced by beginRun(), and DQMRootOutputModule().

unsigned int DQMRootOutputModule::m_run
private

Definition at line 192 of file DQMRootOutputModule.cc.

Referenced by DQMRootOutputModule(), writeLuminosityBlock(), and writeRun().

std::vector<edm::ProcessHistoryID> DQMRootOutputModule::m_seenHistories
private

Definition at line 206 of file DQMRootOutputModule.cc.

Referenced by beginRun(), and startEndFile().

std::vector<boost::shared_ptr<TreeHelperBase> > DQMRootOutputModule::m_treeHelpers
private

Definition at line 190 of file DQMRootOutputModule.cc.

Referenced by DQMRootOutputModule(), writeLuminosityBlock(), and writeRun().

unsigned int DQMRootOutputModule::m_type
private

Definition at line 194 of file DQMRootOutputModule.cc.

Referenced by DQMRootOutputModule(), writeLuminosityBlock(), and writeRun().