CMS 3D CMS Logo

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

DQMRootSource Class Reference

Inheritance diagram for DQMRootSource:
edm::InputSource edm::ProductRegistryHelper

List of all members.

Public Member Functions

 DQMRootSource (edm::ParameterSet const &, const edm::InputSourceDescription &)
virtual ~DQMRootSource ()

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)

Protected Member Functions

virtual void endLuminosityBlock (edm::LuminosityBlock &)
virtual void endRun (edm::Run &)

Private Member Functions

virtual void closeFile_ ()
 DQMRootSource (const DQMRootSource &)
virtual edm::InputSource::ItemType getNextItemType ()
const DQMRootSourceoperator= (const DQMRootSource &)
void readElements ()
virtual edm::EventPrincipalreadEvent_ ()
virtual boost::shared_ptr
< edm::FileBlock
readFile_ ()
virtual boost::shared_ptr
< edm::LuminosityBlockPrincipal
readLuminosityBlock_ (boost::shared_ptr< edm::LuminosityBlockPrincipal > lbCache)
virtual boost::shared_ptr
< edm::LuminosityBlockAuxiliary
readLuminosityBlockAuxiliary_ ()
void readNextItemType ()
virtual boost::shared_ptr
< edm::RunPrincipal
readRun_ (boost::shared_ptr< edm::RunPrincipal > rpCache)
virtual boost::shared_ptr
< edm::RunAuxiliary
readRunAuxiliary_ ()
void setupFile (unsigned int iIndex)

Private Attributes

edm::InputFileCatalog m_catalog
bool m_doNotReadRemainingPartsOfFileSinceFrameworkTerminating
std::auto_ptr< TFile > m_file
size_t m_fileIndex
std::vector
< edm::ProcessHistoryID
m_historyIDs
edm::JobReport::Token m_jrToken
bool m_justOpenedFileSoNeedToGenerateRunTransition
unsigned int m_lastSeenRun
edm::LuminosityBlockAuxiliary m_lumiAux
std::set< MonitorElement * > m_lumiElements
std::list< unsigned int >::iterator m_nextIndexItr
edm::InputSource::ItemType m_nextItemType
std::list< unsigned int > m_orderedIndices
std::list< unsigned int >::iterator m_presentIndexItr
edm::RunAuxiliary m_runAux
std::set< MonitorElement * > m_runElements
std::vector< RunLumiToRange > m_runlumiToRange
std::vector< boost::shared_ptr
< TreeReaderBase > > 
m_treeReaders
std::vector< TTree * > m_trees

Detailed Description

Definition at line 287 of file DQMRootSource.cc.


Constructor & Destructor Documentation

DQMRootSource::DQMRootSource ( edm::ParameterSet const &  iPSet,
const edm::InputSourceDescription iDesc 
)

Definition at line 369 of file DQMRootSource.cc.

References edm::InputFileCatalog::fileNames(), edm::InputSource::IsStop, kFloatIndex, kIntIndex, kStringIndex, kTH1DIndex, kTH1FIndex, kTH1SIndex, kTH2DIndex, kTH2FIndex, kTH2SIndex, kTH3FIndex, kTProfile2DIndex, kTProfileIndex, m_catalog, m_fileIndex, m_nextItemType, and m_treeReaders.

                                                                                                :
edm::InputSource(iPSet,iDesc),
m_catalog(iPSet.getUntrackedParameter<std::vector<std::string> >("fileNames"), 
          iPSet.getUntrackedParameter<std::string>("overrideCatalog")),
m_nextItemType(edm::InputSource::IsFile),
m_fileIndex(0),
m_trees(kNIndicies,static_cast<TTree*>(0)),
m_treeReaders(kNIndicies,boost::shared_ptr<TreeReaderBase>()),
m_lastSeenRun(0),
m_justOpenedFileSoNeedToGenerateRunTransition(false),
m_doNotReadRemainingPartsOfFileSinceFrameworkTerminating(false)
{
  if(m_fileIndex ==m_catalog.fileNames().size()) {
    m_nextItemType=edm::InputSource::IsStop;
  } else{
    m_treeReaders[kIntIndex].reset(new TreeSimpleReader<Long64_t>());
    m_treeReaders[kFloatIndex].reset(new TreeSimpleReader<double>());
    m_treeReaders[kStringIndex].reset(new TreeObjectReader<std::string>());
    m_treeReaders[kTH1FIndex].reset(new TreeObjectReader<TH1F>());
    m_treeReaders[kTH1SIndex].reset(new TreeObjectReader<TH1S>());
    m_treeReaders[kTH1DIndex].reset(new TreeObjectReader<TH1D>());
    m_treeReaders[kTH2FIndex].reset(new TreeObjectReader<TH2F>());
    m_treeReaders[kTH2SIndex].reset(new TreeObjectReader<TH2S>());
    m_treeReaders[kTH2DIndex].reset(new TreeObjectReader<TH2D>());
    m_treeReaders[kTH3FIndex].reset(new TreeObjectReader<TH3F>());
    m_treeReaders[kTProfileIndex].reset(new TreeObjectReader<TProfile>());
    m_treeReaders[kTProfile2DIndex].reset(new TreeObjectReader<TProfile2D>());
  }
  
}
DQMRootSource::~DQMRootSource ( ) [virtual]

Definition at line 405 of file DQMRootSource.cc.

{
}
DQMRootSource::DQMRootSource ( const DQMRootSource ) [private]

Member Function Documentation

void DQMRootSource::closeFile_ ( ) [private, virtual]

Reimplemented from edm::InputSource.

Definition at line 579 of file DQMRootSource.cc.

References m_doNotReadRemainingPartsOfFileSinceFrameworkTerminating, m_jrToken, m_orderedIndices, m_presentIndexItr, and readElements().

                          {
  //std::cout <<"closeFile_"<<std::endl;
  //when going from one file to the next the framework does not call
  // 'endRun' or 'endLumi' until it looks to see if the other file contains
  // a new run or lumi. If the other file doesn't then  
  if(not m_doNotReadRemainingPartsOfFileSinceFrameworkTerminating) {
    while(m_presentIndexItr != m_orderedIndices.end()) {
      readElements();
    }
  }
  edm::Service<edm::JobReport> jr;
  jr->inputFileClosed(m_jrToken);
}
void DQMRootSource::endLuminosityBlock ( edm::LuminosityBlock iLumi) [protected, virtual]

Reimplemented from edm::InputSource.

Definition at line 566 of file DQMRootSource.cc.

                                                           {
  //std::cout <<"DQMRootSource::endLumi"<<std::endl;
}
void DQMRootSource::endRun ( edm::Run iRun) [protected, virtual]

Reimplemented from edm::InputSource.

Definition at line 570 of file DQMRootSource.cc.

References m_doNotReadRemainingPartsOfFileSinceFrameworkTerminating.

                                 {
  //std::cout <<"DQMRootSource::endRun"<<std::endl;
  //NOTE: the framework will call endRun before closeFile in the case
  // where the frameworks is terminating
  m_doNotReadRemainingPartsOfFileSinceFrameworkTerminating=true;
}
void DQMRootSource::fillDescriptions ( edm::ConfigurationDescriptions descriptions) [static]

Reimplemented from edm::InputSource.

Definition at line 358 of file DQMRootSource.cc.

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

                                                                          {
  edm::ParameterSetDescription desc;
  desc.addUntracked<std::vector<std::string> >("fileNames")
    ->setComment("Names of files to be processed.");
  desc.addUntracked<std::string>("overrideCatalog",std::string())
    ->setComment("An alternate file catalog to use instead of the standard site one.");
  descriptions.addDefault(desc);
}
edm::InputSource::ItemType DQMRootSource::getNextItemType ( ) [private, virtual]

Implements edm::InputSource.

Definition at line 437 of file DQMRootSource.cc.

References m_nextItemType.

{
  //std::cout <<"getNextItemType "<<m_nextItemType<<std::endl;
  return m_nextItemType;
}
const DQMRootSource& DQMRootSource::operator= ( const DQMRootSource ) [private]
void DQMRootSource::readElements ( ) [private]

Definition at line 594 of file DQMRootSource.cc.

References kNoTypesStored, m_lumiElements, m_orderedIndices, m_presentIndexItr, m_runElements, m_runlumiToRange, and m_treeReaders.

Referenced by closeFile_(), readLuminosityBlock_(), and readRun_().

                            {
  edm::Service<DQMStore> store;
  RunLumiToRange runLumiRange = m_runlumiToRange[*m_presentIndexItr];
  bool shouldContinue = false;
  do {
    shouldContinue = false;
    if(runLumiRange.m_type == kNoTypesStored) {continue;}
    boost::shared_ptr<TreeReaderBase> reader = m_treeReaders[runLumiRange.m_type];
    for(ULong64_t index = runLumiRange.m_firstIndex, endIndex=runLumiRange.m_lastIndex+1;
    index != endIndex;
    ++index) {
      bool isLumi = runLumiRange.m_lumi !=0;
      MonitorElement* element = reader->read(index,*store,isLumi);
      if(isLumi) {
        //std::cout <<"  lumi element "<< element->getName()<<" "<<index<<std::endl;
        m_lumiElements.insert(element);
      } else {
        //std::cout <<"  run element "<< element->getName()<<" "<<index<<std::endl;
        m_runElements.insert(element);
      }
    }
    ++m_presentIndexItr;
    if(m_presentIndexItr != m_orderedIndices.end()) {
      //are there more parts to this same run/lumi?
      const RunLumiToRange nextRunLumiRange = m_runlumiToRange[*m_presentIndexItr];
      //continue to the next item if that item is either
      if( (nextRunLumiRange.m_run == runLumiRange.m_run) && 
          (nextRunLumiRange.m_lumi == runLumiRange.m_lumi) ) {
           shouldContinue= true;
           runLumiRange = nextRunLumiRange;
      } 
    }
  }while(shouldContinue);
}
edm::EventPrincipal * DQMRootSource::readEvent_ ( ) [private, virtual]

Implements edm::InputSource.

Definition at line 431 of file DQMRootSource.cc.

{
  return 0;
}
boost::shared_ptr< edm::FileBlock > DQMRootSource::readFile_ ( ) [private, virtual]

Reimplemented from edm::InputSource.

Definition at line 543 of file DQMRootSource.cc.

References edm::InputFileCatalog::fileNames(), edm::InputFileCatalog::logicalFileNames(), m_catalog, m_doNotReadRemainingPartsOfFileSinceFrameworkTerminating, m_file, m_fileIndex, m_jrToken, readNextItemType(), and setupFile().

                         {
  //std::cout <<"readFile_"<<std::endl;
  setupFile(m_fileIndex);
  ++m_fileIndex;
  readNextItemType();

  edm::Service<edm::JobReport> jr;
  m_jrToken = jr->inputFileOpened(m_catalog.fileNames()[m_fileIndex-1],
                                  m_catalog.logicalFileNames()[m_fileIndex-1],
                                  std::string(),
                                  std::string(),
                                  "DQMRootSource",
                                  "source",
                                  m_file->GetUUID().AsString(),//edm::createGlobalIdentifier(),
                                  std::vector<std::string>()
                                  );
  
  m_doNotReadRemainingPartsOfFileSinceFrameworkTerminating = false;
  return boost::shared_ptr<edm::FileBlock>(new edm::FileBlock);
}
boost::shared_ptr< edm::LuminosityBlockPrincipal > DQMRootSource::readLuminosityBlock_ ( boost::shared_ptr< edm::LuminosityBlockPrincipal lbCache) [private, virtual]

Reimplemented from edm::InputSource.

Definition at line 519 of file DQMRootSource.cc.

References m_lumiElements, m_presentIndexItr, m_runlumiToRange, readElements(), and readNextItemType().

{
  //NOTE: need to reset all lumi block elements at this point
  for(std::set<MonitorElement*>::iterator it = m_lumiElements.begin(), itEnd = m_lumiElements.end();
      it != itEnd;
      ++it) {
        //std::cout <<"RESETTING "<<(*it)->getName()<<std::endl;      
      (*it)->Reset();
  }
  readNextItemType();
  //std::cout <<"readLuminosityBlock_"<<std::endl;
  RunLumiToRange runLumiRange = m_runlumiToRange[*m_presentIndexItr];
  if(runLumiRange.m_run == lbCache->id().run() &&
     runLumiRange.m_lumi == lbCache->id().luminosityBlock()) {
       readElements();
  }
  
  edm::Service<edm::JobReport> jr;
  jr->reportInputLumiSection(lbCache->id().run(),lbCache->id().luminosityBlock());
  
  return lbCache;
}
boost::shared_ptr< edm::LuminosityBlockAuxiliary > DQMRootSource::readLuminosityBlockAuxiliary_ ( ) [private, virtual]

Implements edm::InputSource.

Definition at line 469 of file DQMRootSource.cc.

References m_historyIDs, m_lumiAux, m_nextIndexItr, m_orderedIndices, m_runlumiToRange, and edm::LuminosityBlockAuxiliary::setProcessHistoryID().

{
  //std::cout <<"readLuminosityBlockAuxiliary_"<<std::endl;
  assert(m_nextIndexItr != m_orderedIndices.end());
  const RunLumiToRange runLumiRange = m_runlumiToRange[*m_nextIndexItr];
  m_lumiAux = edm::LuminosityBlockAuxiliary(edm::LuminosityBlockID(runLumiRange.m_run,runLumiRange.m_lumi),
                                            edm::Timestamp(runLumiRange.m_beginTime),
                                            edm::Timestamp(runLumiRange.m_endTime));
  assert(m_historyIDs.size() > runLumiRange.m_historyIDIndex);
  //std::cout <<"lumi "<<m_lumiAux.beginTime().value()<<" "<<runLumiRange.m_beginTime<<std::endl;
  m_lumiAux.setProcessHistoryID(m_historyIDs[runLumiRange.m_historyIDIndex]);    
  
  return boost::shared_ptr<edm::LuminosityBlockAuxiliary>(new edm::LuminosityBlockAuxiliary(m_lumiAux));
}
void DQMRootSource::readNextItemType ( ) [private]

Definition at line 631 of file DQMRootSource.cc.

References edm::InputFileCatalog::fileNames(), edm::LuminosityBlockAuxiliary::id(), edm::RunAuxiliary::id(), edm::InputSource::IsFile, edm::InputSource::IsLumi, edm::InputSource::IsRun, edm::InputSource::IsStop, m_catalog, m_fileIndex, m_justOpenedFileSoNeedToGenerateRunTransition, m_lastSeenRun, m_lumiAux, m_nextIndexItr, m_nextItemType, m_orderedIndices, m_runAux, and m_runlumiToRange.

Referenced by readFile_(), readLuminosityBlock_(), and readRun_().

{
  //Do the work of actually figuring out where next to go
  RunLumiToRange runLumiRange = m_runlumiToRange[*m_nextIndexItr];
  if(m_nextItemType !=edm::InputSource::IsFile) {
    assert(m_nextIndexItr != m_orderedIndices.end());

    if(runLumiRange.m_lumi ==0) {
      //std::cout <<"reading run "<<runLumiRange.m_run<<std::endl;
      m_runAux.id() = edm::RunID(runLumiRange.m_run);    
    } else {
      if(m_nextItemType == edm::InputSource::IsRun) {
        //std::cout <<" proceeding with dummy run";
        m_nextItemType = edm::InputSource::IsLumi;
        return;
      }
      //std::cout <<"reading lumi "<<runLumiRange.m_run<<","<<runLumiRange.m_lumi<<std::endl;
      m_lumiAux.id() = edm::LuminosityBlockID(runLumiRange.m_run,runLumiRange.m_lumi);
    }
    ++m_nextIndexItr;
  } else {
    //NOTE: the following causes the iterator to move to before 'begin' but that is OK
    // since the first thing in the 'do while' loop is to advance the iterator which puts
    // us at the first entry in the file
    runLumiRange.m_run=0;
  } 
  
  bool shouldContinue = false;
  do {
    shouldContinue = false;
    if(m_nextIndexItr == m_orderedIndices.end()) {
      //go to next file
      m_nextItemType = edm::InputSource::IsFile;
      //std::cout <<"going to next file"<<std::endl;
      if(m_fileIndex == m_catalog.fileNames().size()) {
        m_nextItemType = edm::InputSource::IsStop;
      }       
      break;
    }
    const RunLumiToRange nextRunLumiRange = m_runlumiToRange[*m_nextIndexItr];
    //continue to the next item if that item is the same run or lumi as we just did
    if( (nextRunLumiRange.m_run == runLumiRange.m_run) && (
         nextRunLumiRange.m_lumi == runLumiRange.m_lumi) ) {
         shouldContinue= true;
         runLumiRange = nextRunLumiRange;
         ++m_nextIndexItr;
         //std::cout <<"  advancing " <<nextRunLumiRange.m_run<<" "<<nextRunLumiRange.m_lumi<<std::endl;
    } 
    
  } while(shouldContinue);
  
  if(m_nextIndexItr != m_orderedIndices.end()) {
    if(m_runlumiToRange[*m_nextIndexItr].m_lumi == 0 && (m_justOpenedFileSoNeedToGenerateRunTransition || m_lastSeenRun != m_runlumiToRange[*m_nextIndexItr].m_run) ) {
      m_nextItemType = edm::InputSource::IsRun;
      //std::cout <<"  next is run"<<std::endl;
    } else {
      if(m_runlumiToRange[*m_nextIndexItr].m_run != m_lastSeenRun || m_justOpenedFileSoNeedToGenerateRunTransition ) {
        //we have to create a dummy Run since we switched to a lumi in a new run
        //std::cout <<"  next is dummy run "<<m_justOpenedFileSoNeedToGenerateRunTransition<<std::endl;
        m_nextItemType = edm::InputSource::IsRun;
      } else {
        m_nextItemType = edm::InputSource::IsLumi;      
      }
    }
  }
}
boost::shared_ptr< edm::RunPrincipal > DQMRootSource::readRun_ ( boost::shared_ptr< edm::RunPrincipal rpCache) [private, virtual]

Reimplemented from edm::InputSource.

Definition at line 484 of file DQMRootSource.cc.

References m_justOpenedFileSoNeedToGenerateRunTransition, m_lastSeenRun, m_orderedIndices, m_presentIndexItr, m_runElements, m_runlumiToRange, readElements(), and readNextItemType().

{
  m_justOpenedFileSoNeedToGenerateRunTransition = false;
  unsigned int runID =rpCache->id().run();
  unsigned int lastRunID = m_lastSeenRun;
  m_lastSeenRun = runID;
  readNextItemType();
  //std::cout <<"readRun_"<<std::endl;
  
  //NOTE: need to reset all run elements at this point
  if(lastRunID != runID) {
    for(std::set<MonitorElement*>::iterator it = m_runElements.begin(), itEnd = m_runElements.end();
        it != itEnd;
        ++it) {
          //std::cout <<"RESETTING "<<(*it)->getName()<<std::endl;
          (*it)->Reset();        
    }
  }

  rpCache->addToProcessHistory();

  if(m_presentIndexItr != m_orderedIndices.end()) {
    RunLumiToRange runLumiRange = m_runlumiToRange[*m_presentIndexItr];
    //NOTE: it is possible to have an Run when all we have stored is lumis
    if(runLumiRange.m_lumi == 0 && 
       runLumiRange.m_run == rpCache->id().run()) {
      readElements();
    }
  }
  
  edm::Service<edm::JobReport> jr;
  jr->reportInputRunNumber(rpCache->id().run());
  return rpCache;
}
boost::shared_ptr< edm::RunAuxiliary > DQMRootSource::readRunAuxiliary_ ( ) [private, virtual]

Implements edm::InputSource.

Definition at line 443 of file DQMRootSource.cc.

References getHLTprescales::index, m_historyIDs, m_nextIndexItr, m_orderedIndices, m_runAux, m_runlumiToRange, and edm::RunAuxiliary::setProcessHistoryID().

{
  //std::cout <<"readRunAuxiliary_"<<std::endl;
  assert(m_nextIndexItr != m_orderedIndices.end());
  unsigned int index = *m_nextIndexItr;
  RunLumiToRange runLumiRange = m_runlumiToRange[index];
  //NOTE: this could be a lumi instead of the actual run. We need to find the time for the run
  // so we will scan forward
  while(runLumiRange.m_lumi !=0 && ++index<m_runlumiToRange.size()) {
    const RunLumiToRange& next = m_runlumiToRange[index];
    if(runLumiRange.m_run == next.m_run) {
      runLumiRange = next;
    } else {
      break;
    }
  }

  //NOTE: the setBeginTime and setEndTime functions of RunAuxiliary only work if the previous value was invalid
  // therefore we must copy
  m_runAux = edm::RunAuxiliary(runLumiRange.m_run,edm::Timestamp(runLumiRange.m_beginTime),edm::Timestamp(runLumiRange.m_endTime));
  assert(m_historyIDs.size() > runLumiRange.m_historyIDIndex);
  //std::cout <<"readRunAuxiliary_ "<<m_historyIDs[runLumiRange.m_historyIDIndex]<<std::endl;
  m_runAux.setProcessHistoryID(m_historyIDs[runLumiRange.m_historyIDIndex]);    
  return boost::shared_ptr<edm::RunAuxiliary>( new edm::RunAuxiliary(m_runAux) );
}
void DQMRootSource::setupFile ( unsigned int  iIndex) [private]

Definition at line 699 of file DQMRootSource.cc.

References cmsPerfCommons::configs, cms::Digest::digest(), edm::InputFileCatalog::fileNames(), i, edm::ProcessHistory::id(), getHLTprescales::index, edm::detail::ThreadSafeRegistry< KEY, T, E >::insertMapped(), edm::detail::ThreadSafeRegistry< KEY, T, E >::instance(), kBeginTimeBranch, kEndTimeBranch, kFirstIndex, kIndicesTree, kLastIndex, kLumiBranch, kMetaDataDirectoryAbsolute, kNIndicies, kParameterSetBranch, kParameterSetTree, kPHIndexBranch, kProcessConfigurationParameterSetIDBranch, kProcessConfigurationPassID, kProcessConfigurationProcessNameBranch, kProcessConfigurationReleaseVersion, kProcessHistoryIndexBranch, kProcessHistoryTree, kRunBranch, kTypeBranch, kTypeNames, m_catalog, m_file, m_historyIDs, m_justOpenedFileSoNeedToGenerateRunTransition, m_nextIndexItr, m_orderedIndices, m_presentIndexItr, m_runlumiToRange, m_treeReaders, m_trees, and cond::rpcobtemp::temp.

Referenced by readFile_().

{
  
  m_file = std::auto_ptr<TFile>(TFile::Open(m_catalog.fileNames()[iIndex].c_str()));
  
  //Check file format version, which is encoded in the Title of the TFile
  assert(0==strcmp(m_file->GetTitle(),"1"));
  
  //Get meta Data
  TDirectory* metaDir = m_file->GetDirectory(kMetaDataDirectoryAbsolute);
  assert(0!=metaDir);
  TTree* parameterSetTree = dynamic_cast<TTree*>(metaDir->Get(kParameterSetTree));
  assert(0!=parameterSetTree);
  
  edm::pset::Registry* psr = edm::pset::Registry::instance();
  assert(0!=psr);
  {
    std::string blob;
    std::string* pBlob = &blob;
    parameterSetTree->SetBranchAddress(kParameterSetBranch,&pBlob);
    for(unsigned int index = 0; index != parameterSetTree->GetEntries();++index) {
      parameterSetTree->GetEntry(index);
      cms::Digest dg(blob);
      edm::ParameterSetID psID(dg.digest().toString());
      edm::ParameterSet temp(blob,psID);
    } 
  }

  {
    TTree* processHistoryTree = dynamic_cast<TTree*>(metaDir->Get(kProcessHistoryTree));
    assert(0!=processHistoryTree);
    unsigned int phIndex = 0;
    processHistoryTree->SetBranchAddress(kPHIndexBranch,&phIndex);
    std::string processName;
    std::string* pProcessName = &processName;
    processHistoryTree->SetBranchAddress(kProcessConfigurationProcessNameBranch,&pProcessName);
    std::string parameterSetIDBlob;
    std::string* pParameterSetIDBlob = &parameterSetIDBlob;
    processHistoryTree->SetBranchAddress(kProcessConfigurationParameterSetIDBranch,&pParameterSetIDBlob);
    std::string releaseVersion;
    std::string* pReleaseVersion = &releaseVersion;
    processHistoryTree->SetBranchAddress(kProcessConfigurationReleaseVersion,&pReleaseVersion);
    std::string passID;
    std::string* pPassID = &passID;
    processHistoryTree->SetBranchAddress(kProcessConfigurationPassID,&pPassID);

    edm::ProcessConfigurationRegistry* pcr = edm::ProcessConfigurationRegistry::instance();
    assert(0!=pcr);
    edm::ProcessHistoryRegistry* phr = edm::ProcessHistoryRegistry::instance();
    assert(0!=phr);
    std::vector<edm::ProcessConfiguration> configs;
    configs.reserve(5);
    for(unsigned int i=0; i != processHistoryTree->GetEntries(); ++i) {
      processHistoryTree->GetEntry();
      if(phIndex==0) {
        if(not configs.empty()) {
          edm::ProcessHistory ph(configs);
          m_historyIDs.push_back(ph.id());
          phr->insertMapped(ph);
        }
        configs.clear();
      }
      edm::ParameterSetID psetID(parameterSetIDBlob);
      edm::ProcessConfiguration pc(processName, psetID,releaseVersion,passID);
      pcr->insertMapped(pc);
      configs.push_back(pc);
    }
    if(not configs.empty()) {
      edm::ProcessHistory ph(configs);
      m_historyIDs.push_back(ph.id());
      phr->insertMapped( ph);
      //std::cout <<"inserted "<<ph.id()<<std::endl;
    }
  }
  
  //Setup the indices
  TTree* indicesTree = dynamic_cast<TTree*>(m_file->Get(kIndicesTree));
  assert(0!=indicesTree);
  
  m_runlumiToRange.clear();
  m_runlumiToRange.reserve(indicesTree->GetEntries());
  m_orderedIndices.clear();

  RunLumiToRange temp;
  indicesTree->SetBranchAddress(kRunBranch,&temp.m_run);
  indicesTree->SetBranchAddress(kLumiBranch,&temp.m_lumi);
  indicesTree->SetBranchAddress(kBeginTimeBranch,&temp.m_beginTime);
  indicesTree->SetBranchAddress(kEndTimeBranch,&temp.m_endTime);
  indicesTree->SetBranchAddress(kProcessHistoryIndexBranch,&temp.m_historyIDIndex);
  indicesTree->SetBranchAddress(kTypeBranch,&temp.m_type);
  indicesTree->SetBranchAddress(kFirstIndex,&temp.m_firstIndex);
  indicesTree->SetBranchAddress(kLastIndex,&temp.m_lastIndex);

  //Need to reorder items since if there was a merge done the same  Run and/or Lumi can appear multiple times
  // but we want to process them all at once
  
  //We use a std::list for m_orderedIndices since inserting into the middle of a std::list does not 
  // disrupt the iterators to already existing entries
  
  //The Map is used to see if a Run/Lumi pair has appeared before
  typedef std::map<std::pair<unsigned int, unsigned int>, std::list<unsigned int>::iterator > RunLumiToLastEntryMap;
  RunLumiToLastEntryMap runLumiToLastEntryMap;
  
  //Need to group all lumis for the same run together and move the run entry to the beginning
  typedef std::map<unsigned int, std::pair<std::list<unsigned int>::iterator,std::list<unsigned int>::iterator> > RunToFirstLastEntryMap;
  RunToFirstLastEntryMap runToFirstLastEntryMap;
  
  for(Long64_t index = 0; index != indicesTree->GetEntries();++index) {
    indicesTree->GetEntry(index);
    //std::cout <<"read r:"<<temp.m_run<<" l:"<<temp.m_lumi<<" b:"<<temp.m_beginTime<<" e:"<<temp.m_endTime<<std::endl;
    m_runlumiToRange.push_back(temp);
    
    std::pair<unsigned int, unsigned int> runLumi(temp.m_run,temp.m_lumi);
    
    RunLumiToLastEntryMap::iterator itFind = runLumiToLastEntryMap.find(runLumi);
    if(itFind == runLumiToLastEntryMap.end()) {
      //does not already exist

      //does the run for this already exist?
      std::list<unsigned int>::iterator itLastOfRun = m_orderedIndices.end();
      RunToFirstLastEntryMap::iterator itRunFirstLastEntryFind = runToFirstLastEntryMap.find(temp.m_run);
      bool needNewEntryInRunFirstLastEntryMap = true;
      if(itRunFirstLastEntryFind != runToFirstLastEntryMap.end()) {
        needNewEntryInRunFirstLastEntryMap=false;
        if(temp.m_lumi!=0) {
          //lumis go to the end
          itLastOfRun = itRunFirstLastEntryFind->second.second;
          //we want to insert after this one so must advanced the iterator
          ++itLastOfRun;
        } else {
          //runs go at the beginning
          itLastOfRun = itRunFirstLastEntryFind->second.first;
        }
      } 
      
      std::list<unsigned int>::iterator iter = m_orderedIndices.insert(itLastOfRun,index);
      runLumiToLastEntryMap[runLumi]=iter;
      if(needNewEntryInRunFirstLastEntryMap) {
        runToFirstLastEntryMap[temp.m_run]=std::make_pair(iter,iter);
      } else {
        if(temp.m_lumi!=0) {
          //lumis go at end
          runToFirstLastEntryMap[temp.m_run].second = iter;
        } else {
          //since we haven't yet seen this run/lumi combination it means we haven't yet seen
          // a run so we can put this first
          runToFirstLastEntryMap[temp.m_run].first = iter;
        }
      }
    } else {
      //We need to do a merge since the run/lumi already appeared. Put it after the existing entry
      //std::cout <<" found a second instance of "<<runLumi.first<<" "<<runLumi.second<<" at "<<index<<std::endl;
      std::list<unsigned int>::iterator itNext = itFind->second;
      ++itNext;
      std::list<unsigned int>::iterator iter = m_orderedIndices.insert(itNext,index);
      RunToFirstLastEntryMap::iterator itRunFirstLastEntryFind = runToFirstLastEntryMap.find(temp.m_run);
      if(itRunFirstLastEntryFind->second.second == itFind->second) {
        //if the previous one was the last in the run, we need to update to make this one the last
        itRunFirstLastEntryFind->second.second = iter;
      }
      itFind->second = iter;
    }
  }
  m_nextIndexItr = m_orderedIndices.begin();
  m_presentIndexItr = m_orderedIndices.begin();
  
  if(m_nextIndexItr != m_orderedIndices.end()) {
    for( size_t index = 0; index < kNIndicies; ++index) {
      m_trees[index] = dynamic_cast<TTree*>(m_file->Get(kTypeNames[index]));
      assert(0!=m_trees[index]);
      m_treeReaders[index]->setTree(m_trees[index]);
    }
  }
  //After a file open, the framework expects to see a new 'IsRun'
  //m_lastSeenRun = 0;
  m_justOpenedFileSoNeedToGenerateRunTransition=true;
}

Member Data Documentation

Definition at line 325 of file DQMRootSource.cc.

Referenced by DQMRootSource(), readFile_(), readNextItemType(), and setupFile().

Definition at line 341 of file DQMRootSource.cc.

Referenced by closeFile_(), endRun(), and readFile_().

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

Definition at line 334 of file DQMRootSource.cc.

Referenced by readFile_(), and setupFile().

size_t DQMRootSource::m_fileIndex [private]

Definition at line 330 of file DQMRootSource.cc.

Referenced by DQMRootSource(), readFile_(), and readNextItemType().

Definition at line 344 of file DQMRootSource.cc.

Referenced by readLuminosityBlockAuxiliary_(), readRunAuxiliary_(), and setupFile().

Definition at line 346 of file DQMRootSource.cc.

Referenced by closeFile_(), and readFile_().

Definition at line 340 of file DQMRootSource.cc.

Referenced by readNextItemType(), readRun_(), and setupFile().

unsigned int DQMRootSource::m_lastSeenRun [private]

Definition at line 339 of file DQMRootSource.cc.

Referenced by readNextItemType(), and readRun_().

Definition at line 327 of file DQMRootSource.cc.

Referenced by readLuminosityBlockAuxiliary_(), and readNextItemType().

Definition at line 342 of file DQMRootSource.cc.

Referenced by readElements(), and readLuminosityBlock_().

std::list<unsigned int>::iterator DQMRootSource::m_nextIndexItr [private]

Definition at line 328 of file DQMRootSource.cc.

Referenced by DQMRootSource(), getNextItemType(), and readNextItemType().

std::list<unsigned int> DQMRootSource::m_orderedIndices [private]
std::list<unsigned int>::iterator DQMRootSource::m_presentIndexItr [private]

Definition at line 332 of file DQMRootSource.cc.

Referenced by closeFile_(), readElements(), readLuminosityBlock_(), readRun_(), and setupFile().

Definition at line 326 of file DQMRootSource.cc.

Referenced by readNextItemType(), and readRunAuxiliary_().

Definition at line 343 of file DQMRootSource.cc.

Referenced by readElements(), and readRun_().

std::vector<RunLumiToRange> DQMRootSource::m_runlumiToRange [private]
std::vector<boost::shared_ptr<TreeReaderBase> > DQMRootSource::m_treeReaders [private]

Definition at line 336 of file DQMRootSource.cc.

Referenced by DQMRootSource(), readElements(), and setupFile().

std::vector<TTree*> DQMRootSource::m_trees [private]

Definition at line 335 of file DQMRootSource.cc.

Referenced by setupFile().