CMS 3D CMS Logo

Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes

DQMRootOutputModule Class Reference

Inheritance diagram for DQMRootOutputModule:
edm::OutputModule

List of all members.

Public Member Functions

 DQMRootOutputModule (edm::ParameterSet const &pset)
virtual ~DQMRootOutputModule ()

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)

Private Member Functions

virtual void beginRun (edm::RunPrincipal const &r)
virtual void finishEndFile ()
virtual bool isFileOpen () const
virtual void openFile (edm::FileBlock const &)
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
unsigned int m_filterOnRun
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

Detailed Description

Definition at line 175 of file DQMRootOutputModule.cc.


Constructor & Destructor Documentation

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

Definition at line 261 of file DQMRootOutputModule.cc.

                                                                   :
edm::OutputModule(pset),
m_fileName(pset.getUntrackedParameter<std::string>("fileName")),
m_logicalFileName(pset.getUntrackedParameter<std::string>("logicalFileName","")),
m_file(0),
m_treeHelpers(kNIndicies,boost::shared_ptr<TreeHelperBase>()),
m_presentHistoryIndex(0),
m_filterOnRun(pset.getUntrackedParameter<unsigned int>("filterOnRun",0)),
m_fullNameBufferPtr(&m_fullNameBuffer),
m_indicesTree(0)
{
}
DQMRootOutputModule::~DQMRootOutputModule ( ) [virtual]

Definition at line 279 of file DQMRootOutputModule.cc.

{
}

Member Function Documentation

void DQMRootOutputModule::beginRun ( edm::RunPrincipal const &  r) [private, virtual]

Reimplemented from edm::OutputModule.

Definition at line 457 of file DQMRootOutputModule.cc.

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

                                                                    {
  //std::cout << "DQMRootOutputModule::beginRun"<< std::endl;
  //The ProcessHistory for a lumi must be the same as its Run so we only need to 
  // record it at Run time
  edm::ProcessHistoryID id = iPrincipal.processHistoryID();
  std::vector<edm::ProcessHistoryID>::iterator itFind = std::find(m_seenHistories.begin(),m_seenHistories.end(),id);
  if(itFind == m_seenHistories.end()) {
    m_presentHistoryIndex = m_seenHistories.size();
    m_seenHistories.push_back(id);
  } else {
    m_presentHistoryIndex = itFind - m_seenHistories.begin();
  }
}
void DQMRootOutputModule::fillDescriptions ( edm::ConfigurationDescriptions descriptions) [static]

Reimplemented from edm::OutputModule.

Definition at line 546 of file DQMRootOutputModule.cc.

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

                                                                                {
  //The following says we do not know what parameters are allowed so do no validation
  // Please change this to state exactly what you do use, even if it is no parameters
  edm::ParameterSetDescription desc;
  desc.setUnknown();
  descriptions.addDefault(desc);

  //NOTE: when actually filling this in, do not forget to add a untracked PSet 'dataset'
  // which is used for bookkeeping by the DMWM
}
void DQMRootOutputModule::finishEndFile ( ) [private, virtual]

Reimplemented from edm::OutputModule.

Definition at line 530 of file DQMRootOutputModule.cc.

References m_file, and m_jrToken.

                                        {
  //std::cout << "DQMRootOutputModule::finishEndFile"<< std::endl;
  m_file->Write();
  m_file->Close();
  edm::Service<edm::JobReport> jr;
  jr->outputFileClosed(m_jrToken);
}
bool DQMRootOutputModule::isFileOpen ( ) const [private, virtual]

Reimplemented from edm::OutputModule.

Definition at line 299 of file DQMRootOutputModule.cc.

References m_file.

{
  return nullptr!=m_file.get();
}
void DQMRootOutputModule::openFile ( edm::FileBlock const &  ) [private, virtual]

Reimplemented from edm::OutputModule.

Definition at line 305 of file DQMRootOutputModule.cc.

References edm::createGlobalIdentifier(), edm::OutputModule::description(), 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, 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(), AlCaHLTBitMon_QueryRunRegistry::string, and diffTreeTool::tree.

{
  //NOTE: I need to also set the I/O performance settings
  
  m_file = std::auto_ptr<TFile>(new TFile(m_fileName.c_str(),"RECREATE",
                                "1" //This is the file format version number
                                ));  
  
  edm::Service<edm::JobReport> jr;
  cms::Digest branchHash;
  m_jrToken = jr->outputFileOpened(m_fileName,
                                   m_logicalFileName,
                                   std::string(),
                                   "DQMRootOutputModule",
                                   description().moduleLabel(),
                                   edm::createGlobalIdentifier(),
                                   std::string(),
                                   branchHash.digest().toString(),
                                   std::vector<std::string>()
    );


  m_indicesTree = new TTree(kIndicesTree,kIndicesTree);
  m_indicesTree->Branch(kRunBranch,&m_run);
  m_indicesTree->Branch(kLumiBranch,&m_lumi);
  m_indicesTree->Branch(kProcessHistoryIndexBranch,&m_presentHistoryIndex);
  m_indicesTree->Branch(kBeginTimeBranch,&m_beginTime);
  m_indicesTree->Branch(kEndTimeBranch,&m_endTime);
  m_indicesTree->Branch(kTypeBranch,&m_type);
  m_indicesTree->Branch(kFirstIndex,&m_firstIndex);
  m_indicesTree->Branch(kLastIndex,&m_lastIndex);
  m_indicesTree->SetDirectory(m_file.get());
  
  unsigned int i = 0;
  for(std::vector<boost::shared_ptr<TreeHelperBase> >::iterator it = m_treeHelpers.begin(), itEnd = m_treeHelpers.end();
  it != itEnd;
  ++it,++i) {
    //std::cout <<"making "<<kTypeNames[i]<<std::endl;
    TTree* tree = new TTree(kTypeNames[i],kTypeNames[i]);
    *it = boost::shared_ptr<TreeHelperBase>(makeHelper(i,tree,m_fullNameBufferPtr));
    tree->SetDirectory(m_file.get()); //TFile takes ownership
  }
  
  m_dqmKindToTypeIndex[MonitorElement::DQM_KIND_INT]=kIntIndex;
  m_dqmKindToTypeIndex[MonitorElement::DQM_KIND_REAL]=kFloatIndex;
  m_dqmKindToTypeIndex[MonitorElement::DQM_KIND_STRING]=kStringIndex;
  m_dqmKindToTypeIndex[MonitorElement::DQM_KIND_TH1F]=kTH1FIndex;
  m_dqmKindToTypeIndex[MonitorElement::DQM_KIND_TH1S]=kTH1SIndex;
  m_dqmKindToTypeIndex[MonitorElement::DQM_KIND_TH1D]=kTH1DIndex;
  m_dqmKindToTypeIndex[MonitorElement::DQM_KIND_TH2F]=kTH2FIndex;
  m_dqmKindToTypeIndex[MonitorElement::DQM_KIND_TH2S]=kTH2SIndex;
  m_dqmKindToTypeIndex[MonitorElement::DQM_KIND_TH2D]=kTH2DIndex;
  m_dqmKindToTypeIndex[MonitorElement::DQM_KIND_TH3F]=kTH3FIndex;
  m_dqmKindToTypeIndex[MonitorElement::DQM_KIND_TPROFILE]=kTProfileIndex;
  m_dqmKindToTypeIndex[MonitorElement::DQM_KIND_TPROFILE2D]=kTProfile2DIndex;
}
void DQMRootOutputModule::startEndFile ( ) [private, virtual]

Reimplemented from edm::OutputModule.

Definition at line 471 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, instance, kMetaDataDirectory, kParameterSetBranch, kParameterSetTree, kPHIndexBranch, kProcessConfigurationParameterSetIDBranch, kProcessConfigurationPassID, kProcessConfigurationProcessNameBranch, kProcessConfigurationReleaseVersion, kProcessHistoryTree, m_file, m_seenHistories, edm::OutputModule::processName(), and AlCaHLTBitMon_QueryRunRegistry::string.

                                       {
  //std::cout << "DQMRootOutputModule::startEndFile"<< std::endl;
  //fill in the meta data
  m_file->cd();
  TDirectory* metaDataDirectory = m_file->mkdir(kMetaDataDirectory);


  //Write out the Process History
  TTree* processHistoryTree = new TTree(kProcessHistoryTree,kProcessHistoryTree);
  processHistoryTree->SetDirectory(metaDataDirectory);
  
  unsigned int index = 0;
  processHistoryTree->Branch(kPHIndexBranch,&index);
  std::string processName;
  processHistoryTree->Branch(kProcessConfigurationProcessNameBranch,&processName);
  std::string parameterSetID;
  processHistoryTree->Branch(kProcessConfigurationParameterSetIDBranch,&parameterSetID);
  std::string releaseVersion;
  processHistoryTree->Branch(kProcessConfigurationReleaseVersion,&releaseVersion);
  std::string passID;
  processHistoryTree->Branch(kProcessConfigurationPassID,&passID);

  edm::ProcessHistoryRegistry* phr = edm::ProcessHistoryRegistry::instance();
  assert(0!=phr);
  for(std::vector<edm::ProcessHistoryID>::iterator it = m_seenHistories.begin(), itEnd = m_seenHistories.end();
      it !=itEnd;
      ++it) {
    const edm::ProcessHistory* history = phr->getMapped(*it);
    assert(0!=history);
    index = 0;
    for(edm::ProcessHistory::collection_type::const_iterator itPC = history->begin(), itPCEnd = history->end();
        itPC != itPCEnd;
        ++itPC,++index) {
      processName = itPC->processName();
      releaseVersion = itPC->releaseVersion();
      passID = itPC->passID();
      parameterSetID = itPC->parameterSetID().compactForm();
      processHistoryTree->Fill();
    }
  }
  
  //Store the ParameterSets
  TTree* parameterSetsTree = new TTree(kParameterSetTree,kParameterSetTree);
  parameterSetsTree->SetDirectory(metaDataDirectory);
  std::string blob;
  parameterSetsTree->Branch(kParameterSetBranch,&blob);
  
  edm::pset::Registry* psr = edm::pset::Registry::instance();
  assert(0!=psr);
  for(edm::pset::Registry::const_iterator it = psr->begin(), itEnd = psr->end();
  it != itEnd;
  ++it) {
    blob.clear();
    it->second.toString(blob);
    parameterSetsTree->Fill();
  }
  
}
void DQMRootOutputModule::write ( edm::EventPrincipal const &  e) [private, virtual]

Implements edm::OutputModule.

Definition at line 364 of file DQMRootOutputModule.cc.

                                                   {
  
}
void DQMRootOutputModule::writeLuminosityBlock ( edm::LuminosityBlockPrincipal const &  iLumi) [private, virtual]

Implements edm::OutputModule.

Definition at line 368 of file DQMRootOutputModule.cc.

References edm::LuminosityBlockPrincipal::beginTime(), edm::LuminosityBlockPrincipal::endTime(), edm::LuminosityBlockPrincipal::id(), kNoTypesStored, m_beginTime, m_dqmKindToTypeIndex, m_endTime, m_filterOnRun, m_firstIndex, m_indicesTree, m_lastIndex, m_lumi, m_run, m_treeHelpers, and m_type.

                                                                                  {
  //std::cout << "DQMRootOutputModule::writeLuminosityBlock"<< std::endl;
  edm::Service<DQMStore> dstore;
  m_run=iLumi.id().run();
  m_lumi = iLumi.id().value();
  m_beginTime = iLumi.beginTime().value();
  m_endTime = iLumi.endTime().value();
  bool shouldWrite = (m_filterOnRun == 0 ||
                      (m_filterOnRun != 0 && m_filterOnRun == m_run));

  if (! shouldWrite)
    return;
  std::vector<MonitorElement *> items(dstore->getAllContents(""));
  for(std::vector<MonitorElement*>::iterator it = items.begin(), itEnd=items.end();
      it!=itEnd;
      ++it) {
    if((*it)->getLumiFlag()) {
      std::map<unsigned int,unsigned int>::iterator itFound = m_dqmKindToTypeIndex.find((*it)->kind());
      assert(itFound !=m_dqmKindToTypeIndex.end());
      m_treeHelpers[itFound->second]->fill(*it);
    }
  }
  //Now store the relationship between run/lumi and indices in the other TTrees
  bool storedLumiIndex = false;
  unsigned int typeIndex = 0;
  for(std::vector<boost::shared_ptr<TreeHelperBase> >::iterator it = m_treeHelpers.begin(), itEnd = m_treeHelpers.end();
      it != itEnd;
      ++it,++typeIndex) {
    if((*it)->wasFilled()) {
      m_type = typeIndex;
      (*it)->getRangeAndReset(m_firstIndex,m_lastIndex);
      storedLumiIndex = true;
      m_indicesTree->Fill();
    }
  }
  if(not storedLumiIndex) {
    //need to record lumis even if we stored no MonitorElements since some later DQM modules
    // look to see what lumis were processed
    m_type = kNoTypesStored;
    m_firstIndex=0;
    m_lastIndex=0;
    m_indicesTree->Fill();
  }
  
  edm::Service<edm::JobReport> jr;
  jr->reportLumiSection(m_run,m_lumi);
}
void DQMRootOutputModule::writeRun ( edm::RunPrincipal const &  iRun) [private, virtual]

Implements edm::OutputModule.

Definition at line 417 of file DQMRootOutputModule.cc.

References edm::RunPrincipal::beginTime(), edm::RunPrincipal::endTime(), edm::RunPrincipal::id(), m_beginTime, m_dqmKindToTypeIndex, m_endTime, m_filterOnRun, m_firstIndex, m_indicesTree, m_lastIndex, m_lumi, m_run, m_treeHelpers, and m_type.

                                                             {
  //std::cout << "DQMRootOutputModule::writeRun"<< std::endl;
  edm::Service<DQMStore> dstore;
  m_run=iRun.id().run();
  m_lumi = 0;
  m_beginTime = iRun.beginTime().value();
  m_endTime = iRun.endTime().value();
  bool shouldWrite = (m_filterOnRun == 0 ||
                      (m_filterOnRun != 0 && m_filterOnRun == m_run));

  if (! shouldWrite)
    return;

  std::vector<MonitorElement *> items(dstore->getAllContents(""));
  for(std::vector<MonitorElement*>::iterator it = items.begin(), itEnd=items.end();
      it!=itEnd;
      ++it) {
    if(not (*it)->getLumiFlag()) {
      std::map<unsigned int,unsigned int>::iterator itFound = m_dqmKindToTypeIndex.find((*it)->kind());
      assert  (itFound !=m_dqmKindToTypeIndex.end());
      m_treeHelpers[itFound->second]->fill(*it);
    }
  }
  
  //Now store the relationship between run/lumi and indices in the other TTrees
  unsigned int typeIndex = 0;
  for(std::vector<boost::shared_ptr<TreeHelperBase> >::iterator it = m_treeHelpers.begin(), itEnd = m_treeHelpers.end();
      it != itEnd;
      ++it,++typeIndex) {
    if((*it)->wasFilled()) {
      m_type = typeIndex;
      (*it)->getRangeAndReset(m_firstIndex,m_lastIndex);
      m_indicesTree->Fill();
    }
  }
  
  edm::Service<edm::JobReport> jr;
  jr->reportRunNumber(m_run);  
}

Member Data Documentation

ULong64_t DQMRootOutputModule::m_beginTime [private]

Definition at line 201 of file DQMRootOutputModule.cc.

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

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

Definition at line 209 of file DQMRootOutputModule.cc.

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

ULong64_t DQMRootOutputModule::m_endTime [private]

Definition at line 202 of file DQMRootOutputModule.cc.

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

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

Definition at line 194 of file DQMRootOutputModule.cc.

Referenced by finishEndFile(), isFileOpen(), openFile(), and startEndFile().

std::string DQMRootOutputModule::m_fileName [private]

Definition at line 192 of file DQMRootOutputModule.cc.

Referenced by openFile().

unsigned int DQMRootOutputModule::m_filterOnRun [private]

Definition at line 205 of file DQMRootOutputModule.cc.

Referenced by writeLuminosityBlock(), and writeRun().

ULong64_t DQMRootOutputModule::m_firstIndex [private]

Definition at line 203 of file DQMRootOutputModule.cc.

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

Definition at line 207 of file DQMRootOutputModule.cc.

Definition at line 208 of file DQMRootOutputModule.cc.

Referenced by openFile().

Definition at line 210 of file DQMRootOutputModule.cc.

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

Definition at line 213 of file DQMRootOutputModule.cc.

Referenced by finishEndFile(), and openFile().

ULong64_t DQMRootOutputModule::m_lastIndex [private]

Definition at line 204 of file DQMRootOutputModule.cc.

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

Definition at line 193 of file DQMRootOutputModule.cc.

Referenced by openFile().

unsigned int DQMRootOutputModule::m_lumi [private]

Definition at line 198 of file DQMRootOutputModule.cc.

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

Definition at line 200 of file DQMRootOutputModule.cc.

Referenced by beginRun(), and openFile().

unsigned int DQMRootOutputModule::m_run [private]

Definition at line 197 of file DQMRootOutputModule.cc.

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

Definition at line 212 of file DQMRootOutputModule.cc.

Referenced by beginRun(), and startEndFile().

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

Definition at line 195 of file DQMRootOutputModule.cc.

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

unsigned int DQMRootOutputModule::m_type [private]

Definition at line 199 of file DQMRootOutputModule.cc.

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