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 | Protected Member Functions | Private Member Functions | Private Attributes
DQMRootSource Class Reference
Inheritance diagram for DQMRootSource:
edm::InputSource edm::ProductRegistryHelper

Public Member Functions

 DQMRootSource (edm::ParameterSet const &, const edm::InputSourceDescription &)
 
virtual ~DQMRootSource ()
 
- Public Member Functions inherited from edm::InputSource
boost::shared_ptr
< ActivityRegistry
actReg () const
 Accessor for Activity Registry. More...
 
void closeFile (boost::shared_ptr< FileBlock >)
 close current file More...
 
void doBeginJob ()
 Called by framework at beginning of job. More...
 
void doBeginLumi (LuminosityBlockPrincipal &lbp)
 Called by framework at beginning of lumi block. More...
 
void doBeginRun (RunPrincipal &rp)
 Called by framework at beginning of run. More...
 
void doEndJob ()
 Called by framework at end of job. More...
 
void doEndLumi (LuminosityBlockPrincipal &lbp)
 Called by framework at end of lumi block. More...
 
void doEndRun (RunPrincipal &rp)
 Called by framework at end of run. More...
 
void doPostForkReacquireResources (boost::shared_ptr< multicore::MessageReceiverForSource >)
 
void doPreForkReleaseResources ()
 Called by the framework before forking the process. More...
 
ProcessingController::ForwardState forwardState () const
 
bool goToEvent (EventID const &eventID)
 
 InputSource (ParameterSet const &, InputSourceDescription const &)
 Constructor. More...
 
void issueReports (EventID const &eventID)
 issue an event report More...
 
LuminosityBlockNumber_t luminosityBlock () const
 Accessor for current luminosity block number. More...
 
boost::shared_ptr
< LuminosityBlockAuxiliary
luminosityBlockAuxiliary () const
 Called by the framework to merge or insert lumi in principal cache. More...
 
int markLumi ()
 Mark lumi as read. More...
 
int markRun ()
 Mark run as read. More...
 
int maxEvents () const
 
int maxLuminosityBlocks () const
 
ModuleDescription const & moduleDescription () const
 Accessor for 'module' description. More...
 
ItemType nextItemType ()
 
bool const primary () const
 Accessor for primary input source flag. More...
 
ProcessConfiguration const & processConfiguration () const
 Accessor for Process Configuration. More...
 
std::string const & processGUID () const
 Accessor for global process identifier. More...
 
ProcessHistoryID const & processHistoryID () const
 Accessor for the input process history ID of the current run. More...
 
ProcessingMode processingMode () const
 RunsLumisAndEvents (default), RunsAndLumis, or Runs. More...
 
boost::shared_ptr
< ProductRegistry const > 
productRegistry () const
 Accessor for product registry. More...
 
bool randomAccess () const
 
void readAndCacheLumi ()
 Read next luminosity block. More...
 
void readAndCacheRun ()
 Read next run. More...
 
EventPrincipalreadEvent (boost::shared_ptr< LuminosityBlockPrincipal > lbCache)
 
EventPrincipalreadEvent (EventID const &)
 Read a specific event. More...
 
boost::shared_ptr< FileBlockreadFile ()
 Read next file. More...
 
boost::shared_ptr
< LuminosityBlockAuxiliary
readLuminosityBlockAuxiliary ()
 Read next luminosity block Auxilary. More...
 
boost::shared_ptr< RunAuxiliaryreadRunAuxiliary ()
 Read next run Auxiliary. More...
 
void registerProducts ()
 Register any produced products. More...
 
int remainingEvents () const
 
int remainingLuminosityBlocks () const
 
void repeat ()
 Reset the remaining number of events/lumis to the maximum number. More...
 
ProcessingController::ReverseState reverseState () const
 
void rewind ()
 Begin again at the first event. More...
 
RunNumber_t run () const
 Accessor for current run number. More...
 
boost::shared_ptr< RunAuxiliaryrunAuxiliary () const
 Called by the framework to merge or insert run in principal cache. More...
 
void setLuminosityBlockNumber_t (LuminosityBlockNumber_t lb)
 Set the luminosity block ID. More...
 
void setRunNumber (RunNumber_t r)
 Set the run number. More...
 
void skipEvents (int offset)
 
Timestamp const & timestamp () const
 Accessor for the current time, as seen by the input source. More...
 
void wakeUp ()
 Wake up the input source. More...
 
virtual ~InputSource ()
 Destructor. More...
 

Static Public Member Functions

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

Protected Member Functions

virtual void endLuminosityBlock (edm::LuminosityBlock &)
 
virtual void endRun (edm::Run &)
 
- Protected Member Functions inherited from edm::InputSource
void decreaseRemainingEventsBy (int iSkipped)
 
EventPrincipal *const eventPrincipalCache ()
 
boost::shared_ptr
< LuminosityBlockPrincipal >
const 
luminosityBlockPrincipal () const
 
PrincipalCache const & principalCache () const
 
PrincipalCacheprincipalCache ()
 
ProductRegistryproductRegistryUpdate () const
 
void reset () const
 
void resetLuminosityBlockAuxiliary () const
 
void resetRunAuxiliary () const
 
boost::shared_ptr
< RunPrincipal > const 
runPrincipal () const
 
void setLuminosityBlockAuxiliary (LuminosityBlockAuxiliary *lbp)
 
void setLumiPrematurelyRead ()
 
void setRunAuxiliary (RunAuxiliary *rp)
 
void setRunPrematurelyRead ()
 
void setTimestamp (Timestamp const &theTime)
 To set the current time, as seen by the input source. More...
 
ItemType state () const
 

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
 

Additional Inherited Members

- Public Types inherited from edm::InputSource
enum  ItemType {
  IsInvalid, IsStop, IsFile, IsRun,
  IsLumi, IsEvent, IsRepeat
}
 
enum  ProcessingMode { Runs, RunsAndLumis, RunsLumisAndEvents }
 
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 

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.

369  :
370 edm::InputSource(iPSet,iDesc),
371 m_catalog(iPSet.getUntrackedParameter<std::vector<std::string> >("fileNames"),
372  iPSet.getUntrackedParameter<std::string>("overrideCatalog")),
374 m_fileIndex(0),
375 m_trees(kNIndicies,static_cast<TTree*>(0)),
376 m_treeReaders(kNIndicies,boost::shared_ptr<TreeReaderBase>()),
377 m_lastSeenRun(0),
380 {
381  if(m_fileIndex ==m_catalog.fileNames().size()) {
383  } else{
384  m_treeReaders[kIntIndex].reset(new TreeSimpleReader<Long64_t>());
385  m_treeReaders[kFloatIndex].reset(new TreeSimpleReader<double>());
386  m_treeReaders[kStringIndex].reset(new TreeObjectReader<std::string>());
387  m_treeReaders[kTH1FIndex].reset(new TreeObjectReader<TH1F>());
388  m_treeReaders[kTH1SIndex].reset(new TreeObjectReader<TH1S>());
389  m_treeReaders[kTH1DIndex].reset(new TreeObjectReader<TH1D>());
390  m_treeReaders[kTH2FIndex].reset(new TreeObjectReader<TH2F>());
391  m_treeReaders[kTH2SIndex].reset(new TreeObjectReader<TH2S>());
392  m_treeReaders[kTH2DIndex].reset(new TreeObjectReader<TH2D>());
393  m_treeReaders[kTH3FIndex].reset(new TreeObjectReader<TH3F>());
394  m_treeReaders[kTProfileIndex].reset(new TreeObjectReader<TProfile>());
395  m_treeReaders[kTProfile2DIndex].reset(new TreeObjectReader<TProfile2D>());
396  }
397 
398 }
edm::InputSource::ItemType m_nextItemType
bool m_doNotReadRemainingPartsOfFileSinceFrameworkTerminating
std::vector< boost::shared_ptr< TreeReaderBase > > m_treeReaders
bool m_justOpenedFileSoNeedToGenerateRunTransition
edm::InputFileCatalog m_catalog
std::vector< TTree * > m_trees
std::vector< std::string > const & fileNames() const
unsigned int m_lastSeenRun
DQMRootSource::~DQMRootSource ( )
virtual

Definition at line 405 of file DQMRootSource.cc.

406 {
407 }
DQMRootSource::DQMRootSource ( const DQMRootSource )
private

Member Function Documentation

void DQMRootSource::closeFile_ ( )
privatevirtual

Reimplemented from edm::InputSource.

Definition at line 579 of file DQMRootSource.cc.

References edm::JobReport::inputFileClosed(), m_doNotReadRemainingPartsOfFileSinceFrameworkTerminating, m_jrToken, m_orderedIndices, m_presentIndexItr, and readElements().

579  {
580  //std::cout <<"closeFile_"<<std::endl;
581  //when going from one file to the next the framework does not call
582  // 'endRun' or 'endLumi' until it looks to see if the other file contains
583  // a new run or lumi. If the other file doesn't then
585  while(m_presentIndexItr != m_orderedIndices.end()) {
586  readElements();
587  }
588  }
591 }
bool m_doNotReadRemainingPartsOfFileSinceFrameworkTerminating
edm::JobReport::Token m_jrToken
std::list< unsigned int >::iterator m_presentIndexItr
void inputFileClosed(Token fileToken)
Definition: JobReport.cc:517
std::list< unsigned int > m_orderedIndices
void DQMRootSource::endLuminosityBlock ( edm::LuminosityBlock iLumi)
protectedvirtual

Reimplemented from edm::InputSource.

Definition at line 566 of file DQMRootSource.cc.

566  {
567  //std::cout <<"DQMRootSource::endLumi"<<std::endl;
568 }
void DQMRootSource::endRun ( edm::Run iRun)
protectedvirtual

Reimplemented from edm::InputSource.

Definition at line 570 of file DQMRootSource.cc.

References m_doNotReadRemainingPartsOfFileSinceFrameworkTerminating.

570  {
571  //std::cout <<"DQMRootSource::endRun"<<std::endl;
572  //NOTE: the framework will call endRun before closeFile in the case
573  // where the frameworks is terminating
575 }
bool m_doNotReadRemainingPartsOfFileSinceFrameworkTerminating
void DQMRootSource::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 358 of file DQMRootSource.cc.

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

358  {
360  desc.addUntracked<std::vector<std::string> >("fileNames")
361  ->setComment("Names of files to be processed.");
362  desc.addUntracked<std::string>("overrideCatalog",std::string())
363  ->setComment("An alternate file catalog to use instead of the standard site one.");
364  descriptions.addDefault(desc);
365 }
ParameterDescriptionBase * addUntracked(U const &iLabel, T const &value)
void addDefault(ParameterSetDescription const &psetDescription)
edm::InputSource::ItemType DQMRootSource::getNextItemType ( )
privatevirtual

Implements edm::InputSource.

Definition at line 437 of file DQMRootSource.cc.

References m_nextItemType.

438 {
439  //std::cout <<"getNextItemType "<<m_nextItemType<<std::endl;
440  return m_nextItemType;
441 }
edm::InputSource::ItemType 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_().

594  {
596  RunLumiToRange runLumiRange = m_runlumiToRange[*m_presentIndexItr];
597  bool shouldContinue = false;
598  do {
599  shouldContinue = false;
600  if(runLumiRange.m_type == kNoTypesStored) {continue;}
601  boost::shared_ptr<TreeReaderBase> reader = m_treeReaders[runLumiRange.m_type];
602  for(ULong64_t index = runLumiRange.m_firstIndex, endIndex=runLumiRange.m_lastIndex+1;
603  index != endIndex;
604  ++index) {
605  bool isLumi = runLumiRange.m_lumi !=0;
606  MonitorElement* element = reader->read(index,*store,isLumi);
607  if(isLumi) {
608  //std::cout <<" lumi element "<< element->getName()<<" "<<index<<std::endl;
609  m_lumiElements.insert(element);
610  } else {
611  //std::cout <<" run element "<< element->getName()<<" "<<index<<std::endl;
612  m_runElements.insert(element);
613  }
614  }
616  if(m_presentIndexItr != m_orderedIndices.end()) {
617  //are there more parts to this same run/lumi?
618  const RunLumiToRange nextRunLumiRange = m_runlumiToRange[*m_presentIndexItr];
619  //continue to the next item if that item is either
620  if( (nextRunLumiRange.m_run == runLumiRange.m_run) &&
621  (nextRunLumiRange.m_lumi == runLumiRange.m_lumi) ) {
622  shouldContinue= true;
623  runLumiRange = nextRunLumiRange;
624  }
625  }
626  }while(shouldContinue);
627 }
std::vector< boost::shared_ptr< TreeReaderBase > > m_treeReaders
std::set< MonitorElement * > m_lumiElements
std::list< unsigned int >::iterator m_presentIndexItr
std::set< MonitorElement * > m_runElements
std::vector< RunLumiToRange > m_runlumiToRange
std::list< unsigned int > m_orderedIndices
edm::EventPrincipal * DQMRootSource::readEvent_ ( )
privatevirtual

Implements edm::InputSource.

Definition at line 431 of file DQMRootSource.cc.

432 {
433  return 0;
434 }
boost::shared_ptr< edm::FileBlock > DQMRootSource::readFile_ ( )
privatevirtual

Reimplemented from edm::InputSource.

Definition at line 543 of file DQMRootSource.cc.

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

543  {
544  //std::cout <<"readFile_"<<std::endl;
546  ++m_fileIndex;
548 
552  std::string(),
553  std::string(),
554  "DQMRootSource",
555  "source",
556  m_file->GetUUID().AsString(),//edm::createGlobalIdentifier(),
557  std::vector<std::string>()
558  );
559 
561  return boost::shared_ptr<edm::FileBlock>(new edm::FileBlock);
562 }
bool m_doNotReadRemainingPartsOfFileSinceFrameworkTerminating
edm::JobReport::Token m_jrToken
void readNextItemType()
Token inputFileOpened(std::string const &physicalFileName, std::string const &logicalFileName, std::string const &catalog, std::string const &inputType, std::string const &inputSourceClassName, std::string const &moduleLabel, std::string const &guid, std::vector< std::string > const &branchNames)
Definition: JobReport.cc:470
edm::InputFileCatalog m_catalog
std::auto_ptr< TFile > m_file
std::vector< std::string > const & logicalFileNames() const
std::vector< std::string > const & fileNames() const
void setupFile(unsigned int iIndex)
boost::shared_ptr< edm::LuminosityBlockPrincipal > DQMRootSource::readLuminosityBlock_ ( boost::shared_ptr< edm::LuminosityBlockPrincipal lbCache)
privatevirtual

Reimplemented from edm::InputSource.

Definition at line 519 of file DQMRootSource.cc.

References m_lumiElements, m_presentIndexItr, m_runlumiToRange, readElements(), readNextItemType(), and edm::JobReport::reportInputLumiSection().

520 {
521  //NOTE: need to reset all lumi block elements at this point
522  for(std::set<MonitorElement*>::iterator it = m_lumiElements.begin(), itEnd = m_lumiElements.end();
523  it != itEnd;
524  ++it) {
525  //std::cout <<"RESETTING "<<(*it)->getName()<<std::endl;
526  (*it)->Reset();
527  }
529  //std::cout <<"readLuminosityBlock_"<<std::endl;
530  RunLumiToRange runLumiRange = m_runlumiToRange[*m_presentIndexItr];
531  if(runLumiRange.m_run == lbCache->id().run() &&
532  runLumiRange.m_lumi == lbCache->id().luminosityBlock()) {
533  readElements();
534  }
535 
537  jr->reportInputLumiSection(lbCache->id().run(),lbCache->id().luminosityBlock());
538 
539  return lbCache;
540 }
void readNextItemType()
std::set< MonitorElement * > m_lumiElements
std::list< unsigned int >::iterator m_presentIndexItr
std::vector< RunLumiToRange > m_runlumiToRange
void reportInputLumiSection(unsigned int run, unsigned int lumiSectId)
Definition: JobReport.cc:625
boost::shared_ptr< edm::LuminosityBlockAuxiliary > DQMRootSource::readLuminosityBlockAuxiliary_ ( )
privatevirtual

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().

470 {
471  //std::cout <<"readLuminosityBlockAuxiliary_"<<std::endl;
472  assert(m_nextIndexItr != m_orderedIndices.end());
473  const RunLumiToRange runLumiRange = m_runlumiToRange[*m_nextIndexItr];
474  m_lumiAux = edm::LuminosityBlockAuxiliary(edm::LuminosityBlockID(runLumiRange.m_run,runLumiRange.m_lumi),
475  edm::Timestamp(runLumiRange.m_beginTime),
476  edm::Timestamp(runLumiRange.m_endTime));
477  assert(m_historyIDs.size() > runLumiRange.m_historyIDIndex);
478  //std::cout <<"lumi "<<m_lumiAux.beginTime().value()<<" "<<runLumiRange.m_beginTime<<std::endl;
479  m_lumiAux.setProcessHistoryID(m_historyIDs[runLumiRange.m_historyIDIndex]);
480 
481  return boost::shared_ptr<edm::LuminosityBlockAuxiliary>(new edm::LuminosityBlockAuxiliary(m_lumiAux));
482 }
std::vector< RunLumiToRange > m_runlumiToRange
edm::LuminosityBlockAuxiliary m_lumiAux
std::vector< edm::ProcessHistoryID > m_historyIDs
std::list< unsigned int > m_orderedIndices
void setProcessHistoryID(ProcessHistoryID const &phid)
std::list< unsigned int >::iterator m_nextIndexItr
void DQMRootSource::readNextItemType ( )
private

Definition at line 631 of file DQMRootSource.cc.

References edm::InputFileCatalog::fileNames(), edm::RunAuxiliary::id(), edm::LuminosityBlockAuxiliary::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_().

632 {
633  //Do the work of actually figuring out where next to go
634  RunLumiToRange runLumiRange = m_runlumiToRange[*m_nextIndexItr];
636  assert(m_nextIndexItr != m_orderedIndices.end());
637 
638  if(runLumiRange.m_lumi ==0) {
639  //std::cout <<"reading run "<<runLumiRange.m_run<<std::endl;
640  m_runAux.id() = edm::RunID(runLumiRange.m_run);
641  } else {
643  //std::cout <<" proceeding with dummy run";
645  return;
646  }
647  //std::cout <<"reading lumi "<<runLumiRange.m_run<<","<<runLumiRange.m_lumi<<std::endl;
648  m_lumiAux.id() = edm::LuminosityBlockID(runLumiRange.m_run,runLumiRange.m_lumi);
649  }
650  ++m_nextIndexItr;
651  } else {
652  //NOTE: the following causes the iterator to move to before 'begin' but that is OK
653  // since the first thing in the 'do while' loop is to advance the iterator which puts
654  // us at the first entry in the file
655  runLumiRange.m_run=0;
656  }
657 
658  bool shouldContinue = false;
659  do {
660  shouldContinue = false;
661  if(m_nextIndexItr == m_orderedIndices.end()) {
662  //go to next file
664  //std::cout <<"going to next file"<<std::endl;
665  if(m_fileIndex == m_catalog.fileNames().size()) {
667  }
668  break;
669  }
670  const RunLumiToRange nextRunLumiRange = m_runlumiToRange[*m_nextIndexItr];
671  //continue to the next item if that item is the same run or lumi as we just did
672  if( (nextRunLumiRange.m_run == runLumiRange.m_run) && (
673  nextRunLumiRange.m_lumi == runLumiRange.m_lumi) ) {
674  shouldContinue= true;
675  runLumiRange = nextRunLumiRange;
676  ++m_nextIndexItr;
677  //std::cout <<" advancing " <<nextRunLumiRange.m_run<<" "<<nextRunLumiRange.m_lumi<<std::endl;
678  }
679 
680  } while(shouldContinue);
681 
682  if(m_nextIndexItr != m_orderedIndices.end()) {
685  //std::cout <<" next is run"<<std::endl;
686  } else {
688  //we have to create a dummy Run since we switched to a lumi in a new run
689  //std::cout <<" next is dummy run "<<m_justOpenedFileSoNeedToGenerateRunTransition<<std::endl;
691  } else {
693  }
694  }
695  }
696 }
edm::InputSource::ItemType m_nextItemType
edm::RunAuxiliary m_runAux
RunID const & id() const
Definition: RunAuxiliary.h:37
std::vector< RunLumiToRange > m_runlumiToRange
edm::LuminosityBlockAuxiliary m_lumiAux
bool m_justOpenedFileSoNeedToGenerateRunTransition
edm::InputFileCatalog m_catalog
std::list< unsigned int > m_orderedIndices
std::vector< std::string > const & fileNames() const
std::list< unsigned int >::iterator m_nextIndexItr
unsigned int m_lastSeenRun
LuminosityBlockID const & id() const
boost::shared_ptr< edm::RunPrincipal > DQMRootSource::readRun_ ( boost::shared_ptr< edm::RunPrincipal rpCache)
privatevirtual

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(), readNextItemType(), and edm::JobReport::reportInputRunNumber().

485 {
487  unsigned int runID =rpCache->id().run();
488  unsigned int lastRunID = m_lastSeenRun;
489  m_lastSeenRun = runID;
491  //std::cout <<"readRun_"<<std::endl;
492 
493  //NOTE: need to reset all run elements at this point
494  if(lastRunID != runID) {
495  for(std::set<MonitorElement*>::iterator it = m_runElements.begin(), itEnd = m_runElements.end();
496  it != itEnd;
497  ++it) {
498  //std::cout <<"RESETTING "<<(*it)->getName()<<std::endl;
499  (*it)->Reset();
500  }
501  }
502 
503  rpCache->addToProcessHistory();
504 
505  if(m_presentIndexItr != m_orderedIndices.end()) {
506  RunLumiToRange runLumiRange = m_runlumiToRange[*m_presentIndexItr];
507  //NOTE: it is possible to have an Run when all we have stored is lumis
508  if(runLumiRange.m_lumi == 0 &&
509  runLumiRange.m_run == rpCache->id().run()) {
510  readElements();
511  }
512  }
513 
515  jr->reportInputRunNumber(rpCache->id().run());
516  return rpCache;
517 }
void readNextItemType()
std::list< unsigned int >::iterator m_presentIndexItr
std::set< MonitorElement * > m_runElements
std::vector< RunLumiToRange > m_runlumiToRange
bool m_justOpenedFileSoNeedToGenerateRunTransition
std::list< unsigned int > m_orderedIndices
void reportInputRunNumber(unsigned int run)
Definition: JobReport.cc:634
unsigned int m_lastSeenRun
boost::shared_ptr< edm::RunAuxiliary > DQMRootSource::readRunAuxiliary_ ( )
privatevirtual

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().

444 {
445  //std::cout <<"readRunAuxiliary_"<<std::endl;
446  assert(m_nextIndexItr != m_orderedIndices.end());
447  unsigned int index = *m_nextIndexItr;
448  RunLumiToRange runLumiRange = m_runlumiToRange[index];
449  //NOTE: this could be a lumi instead of the actual run. We need to find the time for the run
450  // so we will scan forward
451  while(runLumiRange.m_lumi !=0 && ++index<m_runlumiToRange.size()) {
452  const RunLumiToRange& next = m_runlumiToRange[index];
453  if(runLumiRange.m_run == next.m_run) {
454  runLumiRange = next;
455  } else {
456  break;
457  }
458  }
459 
460  //NOTE: the setBeginTime and setEndTime functions of RunAuxiliary only work if the previous value was invalid
461  // therefore we must copy
462  m_runAux = edm::RunAuxiliary(runLumiRange.m_run,edm::Timestamp(runLumiRange.m_beginTime),edm::Timestamp(runLumiRange.m_endTime));
463  assert(m_historyIDs.size() > runLumiRange.m_historyIDIndex);
464  //std::cout <<"readRunAuxiliary_ "<<m_historyIDs[runLumiRange.m_historyIDIndex]<<std::endl;
465  m_runAux.setProcessHistoryID(m_historyIDs[runLumiRange.m_historyIDIndex]);
466  return boost::shared_ptr<edm::RunAuxiliary>( new edm::RunAuxiliary(m_runAux) );
467 }
edm::RunAuxiliary m_runAux
std::vector< RunLumiToRange > m_runlumiToRange
std::vector< edm::ProcessHistoryID > m_historyIDs
std::list< unsigned int > m_orderedIndices
std::list< unsigned int >::iterator m_nextIndexItr
void setProcessHistoryID(ProcessHistoryID const &phid)
Definition: RunAuxiliary.h:36
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, cond::rpcobtemp::temp, and cms::MD5Result::toString().

Referenced by readFile_().

700 {
701 
702  m_file = std::auto_ptr<TFile>(TFile::Open(m_catalog.fileNames()[iIndex].c_str()));
703 
704  //Check file format version, which is encoded in the Title of the TFile
705  assert(0==strcmp(m_file->GetTitle(),"1"));
706 
707  //Get meta Data
708  TDirectory* metaDir = m_file->GetDirectory(kMetaDataDirectoryAbsolute);
709  assert(0!=metaDir);
710  TTree* parameterSetTree = dynamic_cast<TTree*>(metaDir->Get(kParameterSetTree));
711  assert(0!=parameterSetTree);
712 
714  assert(0!=psr);
715  {
716  std::string blob;
717  std::string* pBlob = &blob;
718  parameterSetTree->SetBranchAddress(kParameterSetBranch,&pBlob);
719  for(unsigned int index = 0; index != parameterSetTree->GetEntries();++index) {
720  parameterSetTree->GetEntry(index);
721  cms::Digest dg(blob);
722  edm::ParameterSetID psID(dg.digest().toString());
723  edm::ParameterSet temp(blob,psID);
724  }
725  }
726 
727  {
728  TTree* processHistoryTree = dynamic_cast<TTree*>(metaDir->Get(kProcessHistoryTree));
729  assert(0!=processHistoryTree);
730  unsigned int phIndex = 0;
731  processHistoryTree->SetBranchAddress(kPHIndexBranch,&phIndex);
732  std::string processName;
733  std::string* pProcessName = &processName;
734  processHistoryTree->SetBranchAddress(kProcessConfigurationProcessNameBranch,&pProcessName);
735  std::string parameterSetIDBlob;
736  std::string* pParameterSetIDBlob = &parameterSetIDBlob;
737  processHistoryTree->SetBranchAddress(kProcessConfigurationParameterSetIDBranch,&pParameterSetIDBlob);
738  std::string releaseVersion;
739  std::string* pReleaseVersion = &releaseVersion;
740  processHistoryTree->SetBranchAddress(kProcessConfigurationReleaseVersion,&pReleaseVersion);
741  std::string passID;
742  std::string* pPassID = &passID;
743  processHistoryTree->SetBranchAddress(kProcessConfigurationPassID,&pPassID);
744 
746  assert(0!=pcr);
748  assert(0!=phr);
749  std::vector<edm::ProcessConfiguration> configs;
750  configs.reserve(5);
751  for(unsigned int i=0; i != processHistoryTree->GetEntries(); ++i) {
752  processHistoryTree->GetEntry();
753  if(phIndex==0) {
754  if(not configs.empty()) {
755  edm::ProcessHistory ph(configs);
756  m_historyIDs.push_back(ph.id());
757  phr->insertMapped(ph);
758  }
759  configs.clear();
760  }
761  edm::ParameterSetID psetID(parameterSetIDBlob);
762  edm::ProcessConfiguration pc(processName, psetID,releaseVersion,passID);
763  pcr->insertMapped(pc);
764  configs.push_back(pc);
765  }
766  if(not configs.empty()) {
767  edm::ProcessHistory ph(configs);
768  m_historyIDs.push_back(ph.id());
769  phr->insertMapped( ph);
770  //std::cout <<"inserted "<<ph.id()<<std::endl;
771  }
772  }
773 
774  //Setup the indices
775  TTree* indicesTree = dynamic_cast<TTree*>(m_file->Get(kIndicesTree));
776  assert(0!=indicesTree);
777 
778  m_runlumiToRange.clear();
779  m_runlumiToRange.reserve(indicesTree->GetEntries());
780  m_orderedIndices.clear();
781 
782  RunLumiToRange temp;
783  indicesTree->SetBranchAddress(kRunBranch,&temp.m_run);
784  indicesTree->SetBranchAddress(kLumiBranch,&temp.m_lumi);
785  indicesTree->SetBranchAddress(kBeginTimeBranch,&temp.m_beginTime);
786  indicesTree->SetBranchAddress(kEndTimeBranch,&temp.m_endTime);
787  indicesTree->SetBranchAddress(kProcessHistoryIndexBranch,&temp.m_historyIDIndex);
788  indicesTree->SetBranchAddress(kTypeBranch,&temp.m_type);
789  indicesTree->SetBranchAddress(kFirstIndex,&temp.m_firstIndex);
790  indicesTree->SetBranchAddress(kLastIndex,&temp.m_lastIndex);
791 
792  //Need to reorder items since if there was a merge done the same Run and/or Lumi can appear multiple times
793  // but we want to process them all at once
794 
795  //We use a std::list for m_orderedIndices since inserting into the middle of a std::list does not
796  // disrupt the iterators to already existing entries
797 
798  //The Map is used to see if a Run/Lumi pair has appeared before
799  typedef std::map<std::pair<unsigned int, unsigned int>, std::list<unsigned int>::iterator > RunLumiToLastEntryMap;
800  RunLumiToLastEntryMap runLumiToLastEntryMap;
801 
802  //Need to group all lumis for the same run together and move the run entry to the beginning
803  typedef std::map<unsigned int, std::pair<std::list<unsigned int>::iterator,std::list<unsigned int>::iterator> > RunToFirstLastEntryMap;
804  RunToFirstLastEntryMap runToFirstLastEntryMap;
805 
806  for(Long64_t index = 0; index != indicesTree->GetEntries();++index) {
807  indicesTree->GetEntry(index);
808  //std::cout <<"read r:"<<temp.m_run<<" l:"<<temp.m_lumi<<" b:"<<temp.m_beginTime<<" e:"<<temp.m_endTime<<std::endl;
809  m_runlumiToRange.push_back(temp);
810 
811  std::pair<unsigned int, unsigned int> runLumi(temp.m_run,temp.m_lumi);
812 
813  RunLumiToLastEntryMap::iterator itFind = runLumiToLastEntryMap.find(runLumi);
814  if(itFind == runLumiToLastEntryMap.end()) {
815  //does not already exist
816 
817  //does the run for this already exist?
818  std::list<unsigned int>::iterator itLastOfRun = m_orderedIndices.end();
819  RunToFirstLastEntryMap::iterator itRunFirstLastEntryFind = runToFirstLastEntryMap.find(temp.m_run);
820  bool needNewEntryInRunFirstLastEntryMap = true;
821  if(itRunFirstLastEntryFind != runToFirstLastEntryMap.end()) {
822  needNewEntryInRunFirstLastEntryMap=false;
823  if(temp.m_lumi!=0) {
824  //lumis go to the end
825  itLastOfRun = itRunFirstLastEntryFind->second.second;
826  //we want to insert after this one so must advanced the iterator
827  ++itLastOfRun;
828  } else {
829  //runs go at the beginning
830  itLastOfRun = itRunFirstLastEntryFind->second.first;
831  }
832  }
833 
834  std::list<unsigned int>::iterator iter = m_orderedIndices.insert(itLastOfRun,index);
835  runLumiToLastEntryMap[runLumi]=iter;
836  if(needNewEntryInRunFirstLastEntryMap) {
837  runToFirstLastEntryMap[temp.m_run]=std::make_pair(iter,iter);
838  } else {
839  if(temp.m_lumi!=0) {
840  //lumis go at end
841  runToFirstLastEntryMap[temp.m_run].second = iter;
842  } else {
843  //since we haven't yet seen this run/lumi combination it means we haven't yet seen
844  // a run so we can put this first
845  runToFirstLastEntryMap[temp.m_run].first = iter;
846  }
847  }
848  } else {
849  //We need to do a merge since the run/lumi already appeared. Put it after the existing entry
850  //std::cout <<" found a second instance of "<<runLumi.first<<" "<<runLumi.second<<" at "<<index<<std::endl;
851  std::list<unsigned int>::iterator itNext = itFind->second;
852  ++itNext;
853  std::list<unsigned int>::iterator iter = m_orderedIndices.insert(itNext,index);
854  RunToFirstLastEntryMap::iterator itRunFirstLastEntryFind = runToFirstLastEntryMap.find(temp.m_run);
855  if(itRunFirstLastEntryFind->second.second == itFind->second) {
856  //if the previous one was the last in the run, we need to update to make this one the last
857  itRunFirstLastEntryFind->second.second = iter;
858  }
859  itFind->second = iter;
860  }
861  }
864 
865  if(m_nextIndexItr != m_orderedIndices.end()) {
866  for( size_t index = 0; index < kNIndicies; ++index) {
867  m_trees[index] = dynamic_cast<TTree*>(m_file->Get(kTypeNames[index]));
868  assert(0!=m_trees[index]);
869  m_treeReaders[index]->setTree(m_trees[index]);
870  }
871  }
872  //After a file open, the framework expects to see a new 'IsRun'
873  //m_lastSeenRun = 0;
875 }
int i
Definition: DBlmapReader.cc:9
static const char *const kProcessHistoryTree
Definition: format.h:55
static const char *const kRunBranch
Definition: format.h:42
static const char *const kTypeNames[]
Definition: format.h:29
std::vector< boost::shared_ptr< TreeReaderBase > > m_treeReaders
static const char *const kIndicesTree
Definition: format.h:41
static const char *const kFirstIndex
Definition: format.h:48
static const char *const kLumiBranch
Definition: format.h:43
std::list< unsigned int >::iterator m_presentIndexItr
bool insertMapped(value_type const &v)
static const char *const kPHIndexBranch
Definition: format.h:56
static const char *const kParameterSetBranch
Definition: format.h:63
std::vector< RunLumiToRange > m_runlumiToRange
std::vector< edm::ProcessHistoryID > m_historyIDs
bool m_justOpenedFileSoNeedToGenerateRunTransition
edm::InputFileCatalog m_catalog
static const char *const kParameterSetTree
Definition: format.h:62
std::list< unsigned int > m_orderedIndices
static const char *const kTypeBranch
Definition: format.h:47
std::auto_ptr< TFile > m_file
static const char *const kProcessHistoryIndexBranch
Definition: format.h:44
static const char *const kEndTimeBranch
Definition: format.h:46
std::vector< TTree * > m_trees
static const char *const kProcessConfigurationPassID
Definition: format.h:60
static const char *const kMetaDataDirectoryAbsolute
Definition: format.h:52
std::vector< std::string > const & fileNames() const
static const char *const kLastIndex
Definition: format.h:49
static const char *const kProcessConfigurationReleaseVersion
Definition: format.h:59
static const char *const kProcessConfigurationProcessNameBranch
Definition: format.h:57
static const char *const kBeginTimeBranch
Definition: format.h:45
std::list< unsigned int >::iterator m_nextIndexItr
static ThreadSafeRegistry * instance()
static const char *const kProcessConfigurationParameterSetIDBranch
Definition: format.h:58

Member Data Documentation

edm::InputFileCatalog DQMRootSource::m_catalog
private

Definition at line 325 of file DQMRootSource.cc.

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

bool DQMRootSource::m_doNotReadRemainingPartsOfFileSinceFrameworkTerminating
private

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().

std::vector<edm::ProcessHistoryID> DQMRootSource::m_historyIDs
private

Definition at line 344 of file DQMRootSource.cc.

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

edm::JobReport::Token DQMRootSource::m_jrToken
private

Definition at line 346 of file DQMRootSource.cc.

Referenced by closeFile_(), and readFile_().

bool DQMRootSource::m_justOpenedFileSoNeedToGenerateRunTransition
private

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_().

edm::LuminosityBlockAuxiliary DQMRootSource::m_lumiAux
private

Definition at line 327 of file DQMRootSource.cc.

Referenced by readLuminosityBlockAuxiliary_(), and readNextItemType().

std::set<MonitorElement*> DQMRootSource::m_lumiElements
private

Definition at line 342 of file DQMRootSource.cc.

Referenced by readElements(), and readLuminosityBlock_().

std::list<unsigned int>::iterator DQMRootSource::m_nextIndexItr
private
edm::InputSource::ItemType DQMRootSource::m_nextItemType
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().

edm::RunAuxiliary DQMRootSource::m_runAux
private

Definition at line 326 of file DQMRootSource.cc.

Referenced by readNextItemType(), and readRunAuxiliary_().

std::set<MonitorElement*> DQMRootSource::m_runElements
private

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().