CMS 3D CMS Logo

List of all members | Classes | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes
DQMRootSource Class Reference
Inheritance diagram for DQMRootSource:
edm::PuttableSourceBase DQMTTreeIO edm::InputSource edm::ProducerBase edm::ProductRegistryHelper

Classes

struct  OpenFileInfo
 

Public Member Functions

 DQMRootSource (edm::ParameterSet const &, const edm::InputSourceDescription &)
 
 DQMRootSource (const DQMRootSource &)=delete
 
const DQMRootSourceoperator= (const DQMRootSource &)=delete
 
 ~DQMRootSource () override
 
- Public Member Functions inherited from edm::PuttableSourceBase
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
PuttableSourceBaseoperator= (const PuttableSourceBase &)=delete
 
 PuttableSourceBase (ParameterSet const &, InputSourceDescription const &)
 
 PuttableSourceBase (const PuttableSourceBase &)=delete
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
void registerProducts () final
 Register any produced products. More...
 
void resolvePutIndicies (BranchType iBranchType, ModuleToResolverIndicies const &iIndicies, std::string const &moduleLabel)
 
- Public Member Functions inherited from edm::InputSource
std::shared_ptr< ActivityRegistryactReg () const
 Accessor for Activity Registry. More...
 
std::shared_ptr< BranchIDListHelper const > branchIDListHelper () const
 Accessors for branchIDListHelper. More...
 
std::shared_ptr< BranchIDListHelper > & branchIDListHelper ()
 
void closeFile (FileBlock *, bool cleaningUpAfterException)
 close current file More...
 
void doBeginJob ()
 Called by framework at beginning of job. More...
 
void doEndJob ()
 Called by framework at end of job. More...
 
void fillProcessBlockHelper ()
 Fill the ProcessBlockHelper with info for the current file. More...
 
ProcessingController::ForwardState forwardState () const
 
bool goToEvent (EventID const &eventID)
 
 InputSource (ParameterSet const &, InputSourceDescription const &)
 Constructor. More...
 
 InputSource (InputSource const &)=delete
 
void issueReports (EventID const &eventID, StreamID streamID)
 issue an event report More...
 
LuminosityBlockNumber_t luminosityBlock () const
 Accessor for current luminosity block number. More...
 
std::shared_ptr< LuminosityBlockAuxiliaryluminosityBlockAuxiliary () const
 Called by the framework to merge or insert lumi in principal cache. More...
 
int maxEvents () const
 
int maxLuminosityBlocks () const
 
ModuleDescription const & moduleDescription () const
 Accessor for 'module' description. More...
 
ItemType nextItemType ()
 Advances the source to the next item. More...
 
bool nextProcessBlock (ProcessBlockPrincipal &)
 Next process block, return false if there is none, sets the processName in the principal. More...
 
InputSourceoperator= (InputSource const &)=delete
 
std::shared_ptr< ProcessBlockHelper const > processBlockHelper () const
 Accessors for processBlockHelper. More...
 
std::shared_ptr< ProcessBlockHelper > & processBlockHelper ()
 
ProcessConfiguration const & processConfiguration () const
 Accessor for Process Configuration. More...
 
std::string const & processGUID () const
 Accessor for global process identifier. More...
 
ProcessHistoryRegistry const & processHistoryRegistry () const
 Accessors for process history registry. More...
 
ProcessHistoryRegistryprocessHistoryRegistry ()
 
ProcessingMode processingMode () const
 RunsLumisAndEvents (default), RunsAndLumis, or Runs. More...
 
std::shared_ptr< ProductRegistry const > productRegistry () const
 Accessors for product registry. More...
 
bool randomAccess () const
 
void readAndMergeLumi (LuminosityBlockPrincipal &lbp)
 Read next luminosity block (same as a prior lumi) More...
 
void readAndMergeRun (RunPrincipal &rp)
 Read next run (same as a prior run) More...
 
void readEvent (EventPrincipal &ep, StreamContext &)
 Read next event. More...
 
bool readEvent (EventPrincipal &ep, EventID const &, StreamContext &)
 Read a specific event. More...
 
std::shared_ptr< FileBlockreadFile ()
 Read next file. More...
 
void readLuminosityBlock (LuminosityBlockPrincipal &lumiPrincipal, HistoryAppender &historyAppender)
 Read next luminosity block (new lumi) More...
 
std::shared_ptr< LuminosityBlockAuxiliaryreadLuminosityBlockAuxiliary ()
 Read next luminosity block Auxilary. More...
 
void readProcessBlock (ProcessBlockPrincipal &)
 Read next process block. More...
 
void readRun (RunPrincipal &runPrincipal, HistoryAppender &historyAppender)
 Read next run (new run) More...
 
std::shared_ptr< RunAuxiliaryreadRunAuxiliary ()
 Read next run Auxiliary. More...
 
ProcessHistoryID const & reducedProcessHistoryID () const
 
int remainingEvents () const
 
int remainingLuminosityBlocks () const
 
void repeat ()
 Reset the remaining number of events/lumis to the maximum number. More...
 
std::pair< SharedResourcesAcquirer *, std::recursive_mutex * > resourceSharedWithDelayedReader ()
 Returns nullptr if no resource shared between the Source and a DelayedReader. More...
 
ProcessingController::ReverseState reverseState () const
 
void rewind ()
 Begin again at the first event. More...
 
RunNumber_t run () const
 Accessor for current run number. More...
 
std::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)
 
void switchTo (std::shared_ptr< ProductRegistry > iOther)
 switch to a different ProductRegistry. More...
 
std::shared_ptr< ThinnedAssociationsHelper const > thinnedAssociationsHelper () const
 Accessors for thinnedAssociationsHelper. More...
 
std::shared_ptr< ThinnedAssociationsHelper > & thinnedAssociationsHelper ()
 
Timestamp const & timestamp () const
 Accessor for the current time, as seen by the input source. More...
 
virtual ~InputSource () noexcept(false)
 Destructor. More...
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
std::vector< edm::ProductResolverIndex > const & indiciesForPutProducts (BranchType iBranchType) const
 
 ProducerBase ()
 
std::vector< edm::ProductResolverIndex > const & putTokenIndexToProductResolverIndex () const
 
std::vector< bool > const & recordProvenanceList () const
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription const &)> registrationCallback () const
 used by the fwk to register list of products More...
 
void resolvePutIndicies (BranchType iBranchType, ModuleToResolverIndicies const &iIndicies, std::string const &moduleLabel)
 
TypeLabelList const & typeLabelList () const
 used by the fwk to register the list of products of this module More...
 
 ~ProducerBase () noexcept(false) override
 

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)
 
static void prevalidate (ConfigurationDescriptions &)
 

Private Member Functions

void beginLuminosityBlock (edm::LuminosityBlock &lumi) override
 
void beginRun (edm::Run &run) override
 
edm::InputSource::ItemType getNextItemType () override
 
bool isRunOrLumiTransition () const
 
bool keepIt (edm::RunNumber_t, edm::LuminosityBlockNumber_t) const
 
void logFileAction (char const *msg, char const *fileName) const
 
void readElements ()
 
void readEvent_ (edm::EventPrincipal &) override
 
std::shared_ptr< edm::FileBlockreadFile_ () override
 
void readLuminosityBlock_ (edm::LuminosityBlockPrincipal &lbCache) override
 
std::shared_ptr< edm::LuminosityBlockAuxiliaryreadLuminosityBlockAuxiliary_ () override
 
void readNextItemType ()
 
void readRun_ (edm::RunPrincipal &rpCache) override
 
std::shared_ptr< edm::RunAuxiliaryreadRunAuxiliary_ () override
 

Private Attributes

edm::InputFileCatalog m_catalog
 
unsigned int m_currentIndex
 
std::vector< FileMetadatam_fileMetadatas
 
unsigned int m_filterOnRun
 
std::vector< edm::LuminosityBlockRangem_lumisToProcess
 
edm::InputSource::ItemType m_nextItemType
 
std::vector< OpenFileInfom_openFiles
 
MonitorElementData::Scope m_rescope
 
bool m_skipBadFiles
 
std::vector< std::shared_ptr< TreeReaderBase > > m_treeReaders
 

Additional Inherited Members

- Public Types inherited from edm::InputSource
enum  ItemType {
  IsInvalid, IsStop, IsFile, IsRun,
  IsLumi, IsEvent, IsRepeat, IsSynchronize
}
 
enum  ProcessingMode { Runs, RunsAndLumis, RunsLumisAndEvents }
 
- Public Types inherited from edm::ProducerBase
template<typename T >
using BranchAliasSetterT = ProductRegistryHelper::BranchAliasSetterT< T >
 
using ModuleToResolverIndicies = std::unordered_multimap< std::string, std::tuple< edm::TypeID const *, const char *, edm::ProductResolverIndex > >
 
typedef ProductRegistryHelper::TypeLabelList TypeLabelList
 
- Public Attributes inherited from edm::InputSource
signalslot::Signal< void(StreamContext const &, ModuleCallingContext const &)> postEventReadFromSourceSignal_
 
signalslot::Signal< void(StreamContext const &, ModuleCallingContext const &)> preEventReadFromSourceSignal_
 
- Protected Member Functions inherited from edm::PuttableSourceBase
void beginJob () override
 Begin protected makes it easier to do template programming. More...
 
- Protected Member Functions inherited from edm::InputSource
void decreaseRemainingEventsBy (int iSkipped)
 
bool eventCached () const
 
bool newLumi () const
 
bool newRun () const
 
ProcessHistoryRegistryprocessHistoryRegistryForUpdate ()
 
ProductRegistryproductRegistryUpdate ()
 
void reset () const
 
void resetEventCached ()
 
void resetLuminosityBlockAuxiliary (bool isNewLumi=true) const
 
void resetNewLumi ()
 
void resetNewRun ()
 
void resetRunAuxiliary (bool isNewRun=true) const
 
void setEventCached ()
 Called by the framework to merge or ached() const {return eventCached_;}. More...
 
void setLuminosityBlockAuxiliary (LuminosityBlockAuxiliary *lbp)
 
void setNewLumi ()
 
void setNewRun ()
 
void setRunAuxiliary (RunAuxiliary *rp)
 
void setTimestamp (Timestamp const &theTime)
 To set the current time, as seen by the input source. More...
 
virtual void skip (int offset)
 
ItemType state () const
 
- Protected Member Functions inherited from edm::ProducerBase
template<Transition Tr = Transition::Event>
auto produces (std::string instanceName) noexcept
 declare what type of product will make and with which optional label More...
 
template<Transition B>
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
template<BranchType B>
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
template<typename ProductType , Transition B>
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<class ProductType >
BranchAliasSetterT< ProductType > produces ()
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces ()
 
template<class ProductType >
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<typename ProductType , Transition B>
BranchAliasSetterT< ProductType > produces ()
 
template<Transition Tr = Transition::Event>
auto produces () noexcept
 
ProducesCollector producesCollector ()
 
- Private Types inherited from DQMTTreeIO
typedef dqm::harvesting::DQMStore DQMStore
 
typedef dqm::harvesting::MonitorElement MonitorElement
 

Detailed Description

Definition at line 317 of file DQMRootSource.cc.

Constructor & Destructor Documentation

◆ DQMRootSource() [1/2]

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

Definition at line 430 of file DQMRootSource.cc.

431  : edm::PuttableSourceBase(iPSet, iDesc),
432  m_skipBadFiles(iPSet.getUntrackedParameter<bool>("skipBadFiles", false)),
433  m_filterOnRun(iPSet.getUntrackedParameter<unsigned int>("filterOnRun", 0)),
434  m_catalog(iPSet.getUntrackedParameter<std::vector<std::string>>("fileNames"),
435  iPSet.getUntrackedParameter<std::string>("overrideCatalog")),
436  m_lumisToProcess(iPSet.getUntrackedParameter<std::vector<edm::LuminosityBlockRange>>(
437  "lumisToProcess", std::vector<edm::LuminosityBlockRange>())),
438  m_rescope(std::map<std::string, MonitorElementData::Scope>{
439  {"", MonitorElementData::Scope::LUMI},
440  {"LUMI", MonitorElementData::Scope::LUMI},
441  {"RUN", MonitorElementData::Scope::RUN},
442  {"JOB", MonitorElementData::Scope::JOB}}[iPSet.getUntrackedParameter<std::string>("reScope", "JOB")]),
444  m_treeReaders(kNIndicies, std::shared_ptr<TreeReaderBase>()),
445  m_currentIndex(0),
446  m_openFiles(std::vector<OpenFileInfo>()),
447  m_fileMetadatas(std::vector<FileMetadata>()) {
449 
450  if (m_catalog.fileNames(0).empty()) {
452  } else {
453  m_treeReaders[kIntIndex].reset(new TreeSimpleReader<Long64_t>(MonitorElementData::Kind::INT, m_rescope));
454  m_treeReaders[kFloatIndex].reset(new TreeSimpleReader<double>(MonitorElementData::Kind::REAL, m_rescope));
456  m_treeReaders[kTH1FIndex].reset(new TreeObjectReader<TH1F>(MonitorElementData::Kind::TH1F, m_rescope));
457  m_treeReaders[kTH1SIndex].reset(new TreeObjectReader<TH1S>(MonitorElementData::Kind::TH1S, m_rescope));
458  m_treeReaders[kTH1DIndex].reset(new TreeObjectReader<TH1D>(MonitorElementData::Kind::TH1D, m_rescope));
459  m_treeReaders[kTH1IIndex].reset(new TreeObjectReader<TH1I>(MonitorElementData::Kind::TH1I, m_rescope));
460  m_treeReaders[kTH2FIndex].reset(new TreeObjectReader<TH2F>(MonitorElementData::Kind::TH2F, m_rescope));
461  m_treeReaders[kTH2SIndex].reset(new TreeObjectReader<TH2S>(MonitorElementData::Kind::TH2S, m_rescope));
462  m_treeReaders[kTH2DIndex].reset(new TreeObjectReader<TH2D>(MonitorElementData::Kind::TH2D, m_rescope));
463  m_treeReaders[kTH2IIndex].reset(new TreeObjectReader<TH2I>(MonitorElementData::Kind::TH2I, m_rescope));
464  m_treeReaders[kTH3FIndex].reset(new TreeObjectReader<TH3F>(MonitorElementData::Kind::TH3F, m_rescope));
465  m_treeReaders[kTProfileIndex].reset(new TreeObjectReader<TProfile>(MonitorElementData::Kind::TPROFILE, m_rescope));
467  new TreeObjectReader<TProfile2D>(MonitorElementData::Kind::TPROFILE2D, m_rescope));
468  }
469 
470  produces<DQMToken, edm::Transition::BeginRun>("DQMGenerationRecoRun");
471  produces<DQMToken, edm::Transition::BeginLuminosityBlock>("DQMGenerationRecoLumi");
472 }
edm::InputSource::ItemType m_nextItemType
std::vector< std::string > fileNames(unsigned iCatalog) const
MonitorElementData::Scope m_rescope
std::vector< OpenFileInfo > m_openFiles
unsigned int m_filterOnRun
unsigned int m_currentIndex
edm::InputFileCatalog m_catalog
std::vector< std::shared_ptr< TreeReaderBase > > m_treeReaders
std::vector< edm::LuminosityBlockRange > m_lumisToProcess
std::vector< EventRange > & sortAndRemoveOverlaps(std::vector< EventRange > &eventRange)
Definition: EventRange.cc:98
std::vector< FileMetadata > m_fileMetadatas

◆ DQMRootSource() [2/2]

DQMRootSource::DQMRootSource ( const DQMRootSource )
delete

◆ ~DQMRootSource()

DQMRootSource::~DQMRootSource ( )
override

Definition at line 474 of file DQMRootSource.cc.

References geometryDiff::file, logFileAction(), and m_openFiles.

474  {
475  for (auto& file : m_openFiles) {
476  if (file.m_file && file.m_file->IsOpen()) {
477  logFileAction("Closed file", "");
478  }
479  }
480 }
std::vector< OpenFileInfo > m_openFiles
void logFileAction(char const *msg, char const *fileName) const

Member Function Documentation

◆ beginLuminosityBlock()

void DQMRootSource::beginLuminosityBlock ( edm::LuminosityBlock lumi)
overrideprivatevirtual

Reimplemented from edm::PuttableSourceBase.

Definition at line 752 of file DQMRootSource.cc.

References eostools::move().

752  {
753  std::unique_ptr<DQMToken> product = std::make_unique<DQMToken>();
754  lumi.put(std::move(product), "DQMGenerationRecoLumi");
755 }
def move(src, dest)
Definition: eostools.py:511

◆ beginRun()

void DQMRootSource::beginRun ( edm::Run run)
overrideprivatevirtual

Reimplemented from edm::PuttableSourceBase.

Definition at line 747 of file DQMRootSource.cc.

References eostools::move(), and edm::InputSource::run().

747  {
748  std::unique_ptr<DQMToken> product = std::make_unique<DQMToken>();
749  run.put(std::move(product), "DQMGenerationRecoRun");
750 }
RunNumber_t run() const
Accessor for current run number.
Definition: InputSource.cc:457
def move(src, dest)
Definition: eostools.py:511

◆ fillDescriptions()

void DQMRootSource::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 407 of file DQMRootSource.cc.

References edm::ConfigurationDescriptions::addDefault(), submitPVResolutionJobs::desc, and AlCaHLTBitMon_QueryRunRegistry::string.

407  {
409  desc.addUntracked<std::vector<std::string>>("fileNames")->setComment("Names of files to be processed.");
410  desc.addUntracked<unsigned int>("filterOnRun", 0)->setComment("Just limit the process to the selected run.");
411  desc.addUntracked<std::string>("reScope", "JOB")
412  ->setComment(
413  "Accumulate histograms more coarsely."
414  " Options: \"\": keep unchanged, \"RUN\": turn LUMI histograms into RUN histograms, \"JOB\": turn everything "
415  "into JOB histograms.");
416  desc.addUntracked<bool>("skipBadFiles", false)->setComment("Skip the file if it is not valid");
417  desc.addUntracked<std::string>("overrideCatalog", std::string())
418  ->setComment("An alternate file catalog to use instead of the standard site one.");
419  std::vector<edm::LuminosityBlockRange> defaultLumis;
420  desc.addUntracked<std::vector<edm::LuminosityBlockRange>>("lumisToProcess", defaultLumis)
421  ->setComment("Skip any lumi inside the specified run:lumi range.");
422 
423  descriptions.addDefault(desc);
424 }
void addDefault(ParameterSetDescription const &psetDescription)

◆ getNextItemType()

edm::InputSource::ItemType DQMRootSource::getNextItemType ( )
overrideprivatevirtual

Implements edm::InputSource.

Definition at line 486 of file DQMRootSource.cc.

References m_nextItemType.

486 { return m_nextItemType; }
edm::InputSource::ItemType m_nextItemType

◆ isRunOrLumiTransition()

bool DQMRootSource::isRunOrLumiTransition ( ) const
private

Definition at line 713 of file DQMRootSource.cc.

References m_currentIndex, m_fileMetadatas, DQMTTreeIO::FileMetadata::m_lumi, DQMTTreeIO::FileMetadata::m_run, and OccupancyTask_cfi::metadata.

Referenced by readLuminosityBlock_(), and readRun_().

713  {
714  if (m_currentIndex == 0) {
715  return false;
716  }
717 
718  if (m_currentIndex > m_fileMetadatas.size() - 1) {
719  // We reached the end
720  return true;
721  }
722 
723  FileMetadata previousMetadata = m_fileMetadatas[m_currentIndex - 1];
724  FileMetadata metadata = m_fileMetadatas[m_currentIndex];
725 
726  return previousMetadata.m_run != metadata.m_run || previousMetadata.m_lumi != metadata.m_lumi;
727 }
unsigned int m_currentIndex
std::vector< FileMetadata > m_fileMetadatas

◆ keepIt()

bool DQMRootSource::keepIt ( edm::RunNumber_t  run,
edm::LuminosityBlockNumber_t  lumi 
) const
private

Definition at line 757 of file DQMRootSource.cc.

References m_filterOnRun, m_lumisToProcess, and edm::InputSource::run().

Referenced by readFile_().

757  {
758  if (m_filterOnRun != 0 && run != m_filterOnRun) {
759  return false;
760  }
761 
762  if (m_lumisToProcess.empty()) {
763  return true;
764  }
765 
766  for (edm::LuminosityBlockRange const& lumiToProcess : m_lumisToProcess) {
767  if (run >= lumiToProcess.startRun() && run <= lumiToProcess.endRun()) {
768  if (lumi >= lumiToProcess.startLumi() && lumi <= lumiToProcess.endLumi()) {
769  return true;
770  } else if (lumi == 0) {
771  return true;
772  }
773  }
774  }
775  return false;
776 }
RunNumber_t run() const
Accessor for current run number.
Definition: InputSource.cc:457
unsigned int m_filterOnRun
std::vector< edm::LuminosityBlockRange > m_lumisToProcess

◆ logFileAction()

void DQMRootSource::logFileAction ( char const *  msg,
char const *  fileName 
) const
private

Definition at line 778 of file DQMRootSource.cc.

References MillePedeFileConverter_cfg::fileName, edm::FlushMessageLog(), and mps_check::msg.

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

778  {
779  edm::LogAbsolute("fileAction") << std::setprecision(0) << edm::TimeOfDay() << msg << fileName;
781 }
void FlushMessageLog()
tuple msg
Definition: mps_check.py:286
Log< level::System, true > LogAbsolute

◆ operator=()

const DQMRootSource& DQMRootSource::operator= ( const DQMRootSource )
delete

◆ readElements()

void DQMRootSource::readElements ( )
private

Definition at line 689 of file DQMRootSource.cc.

References kNoTypesStored, kTypeNames, m_currentIndex, m_fileMetadatas, m_treeReaders, OccupancyTask_cfi::metadata, Utilities::operator, and DQM::reader.

Referenced by readLuminosityBlock_(), and readRun_().

689  {
690  FileMetadata metadata = m_fileMetadatas[m_currentIndex];
691 
692  if (metadata.m_type != kNoTypesStored) {
693  std::shared_ptr<TreeReaderBase> reader = m_treeReaders[metadata.m_type];
694  TTree* tree = dynamic_cast<TTree*>(metadata.m_file->Get(kTypeNames[metadata.m_type]));
695  // The Reset() below screws up the tree, so we need to re-read it from file
696  // before use here.
697  tree->Refresh();
698 
699  reader->setTree(tree);
700 
701  ULong64_t index = metadata.m_firstIndex;
702  ULong64_t endIndex = metadata.m_lastIndex + 1;
703 
704  for (; index != endIndex; ++index) {
705  reader->read(index, edm::Service<DQMStore>().operator->(), metadata.m_run, metadata.m_lumi);
706  }
707  // Drop buffers in the TTree. This reduces memory consuption while the tree
708  // just sits there and waits for the next block to be read.
709  tree->Reset();
710  }
711 }
static const char *const kTypeNames[]
Definition: format.h:41
reader
Definition: DQM.py:105
unsigned int m_currentIndex
std::vector< std::shared_ptr< TreeReaderBase > > m_treeReaders
Definition: tree.py:1
std::vector< FileMetadata > m_fileMetadatas

◆ readEvent_()

void DQMRootSource::readEvent_ ( edm::EventPrincipal )
overrideprivatevirtual

Implements edm::InputSource.

Definition at line 687 of file DQMRootSource.cc.

687 {}

◆ readFile_()

std::shared_ptr< edm::FileBlock > DQMRootSource::readFile_ ( )
overrideprivatevirtual

Reimplemented from edm::InputSource.

Definition at line 489 of file DQMRootSource.cc.

References cms::Exception::addAdditionalInfo(), cms::Exception::addContext(), cms::cuda::assert(), MillePedeFileConverter_cfg::e, geometryDiff::file, edm::InputFileCatalog::fileCatalogItems(), edm::InputFileCatalog::fileNames(), edm::errors::FileOpenError, edm::errors::FileReadError, edm::threadLocalException::getException(), edm::JobReport::inputFileOpened(), createfilelist::int, edm::InputSource::IsRun, edm::InputSource::IsStop, kBeginTimeBranch, kCmsGuid, keepIt(), kEndTimeBranch, kFirstIndex, kIndicesTree, kLastIndex, kLumiBranch, kNoTypesStored, kRunBranch, kTypeBranch, logFileAction(), m_catalog, m_fileMetadatas, m_nextItemType, m_openFiles, m_skipBadFiles, OccupancyTask_cfi::metadata, GetRecoTauVFromDQM_MC_cff::next, edm::InputSource::run(), alignCSCRings::s, edm::threadLocalException::setException(), AlCaHLTBitMon_QueryRunRegistry::string, groupFilesInBlocks::temp, and HcalDetIdTransform::transform().

489  {
490  const int numFiles = m_catalog.fileNames(0).size();
491  m_openFiles.reserve(numFiles);
492 
493  for (auto& fileitem : m_catalog.fileCatalogItems()) {
494  TFile* file = nullptr;
495  std::string pfn;
496  std::string lfn;
497  std::list<std::string> exInfo;
498  //loop over names of a file, each of them corresponds to a data catalog
499  bool isGoodFile(true);
500  //get all names of a file, each of them corresponds to a data catalog
501  const std::vector<std::string>& fNames = fileitem.fileNames();
502  for (std::vector<std::string>::const_iterator it = fNames.begin(); it != fNames.end(); ++it) {
503  // Try to open a file
504  try {
505  file = TFile::Open(it->c_str());
506 
507  // Exception will be trapped so we pull it out ourselves
508  std::exception_ptr e = edm::threadLocalException::getException();
509  if (e != std::exception_ptr()) {
510  edm::threadLocalException::setException(std::exception_ptr());
511  std::rethrow_exception(e);
512  }
513 
514  } catch (cms::Exception const& e) {
515  file = nullptr; // is there anything we need to free?
516  if (std::next(it) == fNames.end()) { //last name corresponding to the last data catalog to try
517  if (!m_skipBadFiles) {
519  ex.addContext("Opening DQM Root file");
520  ex << "\nInput file " << *it << " was not found, could not be opened, or is corrupted.\n";
521  //report previous exceptions when use other names to open file
522  for (auto const& s : exInfo)
523  ex.addAdditionalInfo(s);
524  throw ex;
525  }
526  isGoodFile = false;
527  }
528  // save in case of error when trying next name
529  for (auto const& s : e.additionalInfo())
530  exInfo.push_back(s);
531  }
532 
533  // Check if a file is usable
534  if (file && !file->IsZombie()) {
535  logFileAction("Successfully opened file ", it->c_str());
536  pfn = *it;
537  lfn = fileitem.logicalFileName();
538  break;
539  } else {
540  if (std::next(it) == fNames.end()) {
541  if (!m_skipBadFiles) {
543  ex << "Input file " << *it << " could not be opened.\n";
544  ex.addContext("Opening DQM Root file");
545  //report previous exceptions when use other names to open file
546  for (auto const& s : exInfo)
547  ex.addAdditionalInfo(s);
548  throw ex;
549  }
550  isGoodFile = false;
551  }
552  if (file) {
553  delete file;
554  file = nullptr;
555  }
556  }
557  } //end loop over names of the file
558 
559  if (!file || (!isGoodFile && m_skipBadFiles))
560  continue;
561 
562  std::unique_ptr<std::string> guid{file->Get<std::string>(kCmsGuid)};
563  if (not guid) {
564  guid = std::make_unique<std::string>(file->GetUUID().AsString());
565  std::transform(guid->begin(), guid->end(), guid->begin(), (int (*)(int))std::toupper);
566  }
567 
569  auto jrToken = jr->inputFileOpened(
570  pfn, lfn, std::string(), std::string(), "DQMRootSource", "source", *guid, std::vector<std::string>());
571  m_openFiles.emplace_back(file, jrToken);
572 
573  // Check file format version, which is encoded in the Title of the TFile
574  if (strcmp(file->GetTitle(), "1") != 0) {
576  ex << "Input file " << fNames[0] << " does not appear to be a DQM Root file.\n";
577  }
578 
579  // Read metadata from the file
580  TTree* indicesTree = dynamic_cast<TTree*>(file->Get(kIndicesTree));
581  assert(indicesTree != nullptr);
582 
583  FileMetadata temp;
584  // Each line of metadata will be read into the coresponding fields of temp.
585  indicesTree->SetBranchAddress(kRunBranch, &temp.m_run);
586  indicesTree->SetBranchAddress(kLumiBranch, &temp.m_lumi);
587  indicesTree->SetBranchAddress(kBeginTimeBranch, &temp.m_beginTime);
588  indicesTree->SetBranchAddress(kEndTimeBranch, &temp.m_endTime);
589  indicesTree->SetBranchAddress(kTypeBranch, &temp.m_type);
590  indicesTree->SetBranchAddress(kFirstIndex, &temp.m_firstIndex);
591  indicesTree->SetBranchAddress(kLastIndex, &temp.m_lastIndex);
592 
593  for (Long64_t index = 0; index != indicesTree->GetEntries(); ++index) {
594  indicesTree->GetEntry(index);
595  temp.m_file = file;
596 
597  if (keepIt(temp.m_run, temp.m_lumi)) {
598  m_fileMetadatas.push_back(temp);
599  }
600  }
601 
602  } //end loop over files
603 
604  // Sort to make sure runs and lumis appear in sequential order
605  std::stable_sort(m_fileMetadatas.begin(), m_fileMetadatas.end());
606 
607  // If we have lumisections without matching runs, insert dummy runs here.
608  unsigned int run = 0;
609  auto toadd = std::vector<FileMetadata>();
610  for (auto& metadata : m_fileMetadatas) {
611  if (run < metadata.m_run && metadata.m_lumi != 0) {
612  // run transition and lumi transition at the same time!
613  FileMetadata dummy{}; // zero initialize
614  dummy.m_run = metadata.m_run;
615  dummy.m_lumi = 0;
616  dummy.m_type = kNoTypesStored;
617  toadd.push_back(dummy);
618  }
619  run = metadata.m_run;
620  }
621 
622  if (!toadd.empty()) {
623  // rather than trying to insert at the right places, just append and sort again.
624  m_fileMetadatas.insert(m_fileMetadatas.end(), toadd.begin(), toadd.end());
625  std::stable_sort(m_fileMetadatas.begin(), m_fileMetadatas.end());
626  }
627 
628  //for (auto& metadata : m_fileMetadatas)
629  // metadata.describe();
630 
631  // Stop if there's nothing to process. Otherwise start the run.
632  if (m_fileMetadatas.empty())
634  else
636 
637  // We have to return something but not sure why
638  return std::make_shared<edm::FileBlock>();
639 }
edm::InputSource::ItemType m_nextItemType
static const char *const kRunBranch
Definition: format.h:63
std::vector< std::string > fileNames(unsigned iCatalog) const
static const char *const kIndicesTree
Definition: format.h:62
RunNumber_t run() const
Accessor for current run number.
Definition: InputSource.cc:457
static const char *const kFirstIndex
Definition: format.h:69
std::vector< OpenFileInfo > m_openFiles
static const char *const kLumiBranch
Definition: format.h:64
assert(be >=bs)
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:331
edm::InputFileCatalog m_catalog
static const char *const kTypeBranch
Definition: format.h:68
static const char *const kEndTimeBranch
Definition: format.h:67
static const char *const kCmsGuid
Definition: format.h:73
static const char *const kLastIndex
Definition: format.h:70
void setException(std::exception_ptr e)
void logFileAction(char const *msg, char const *fileName) const
static const char *const kBeginTimeBranch
Definition: format.h:66
std::exception_ptr getException()
bool keepIt(edm::RunNumber_t, edm::LuminosityBlockNumber_t) const
std::vector< FileMetadata > m_fileMetadatas
std::vector< FileCatalogItem > const & fileCatalogItems() const
unsigned transform(const HcalDetId &id, unsigned transformCode)

◆ readLuminosityBlock_()

void DQMRootSource::readLuminosityBlock_ ( edm::LuminosityBlockPrincipal lbCache)
overrideprivatevirtual

Reimplemented from edm::InputSource.

Definition at line 673 of file DQMRootSource.cc.

References edm::LuminosityBlockPrincipal::aux(), edm::LuminosityBlockPrincipal::fillLuminosityBlockPrincipal(), edm::LuminosityBlockPrincipal::id(), isRunOrLumiTransition(), edm::LuminosityBlockID::luminosityBlock(), m_currentIndex, edm::LuminosityBlockAuxiliary::processHistoryID(), edm::InputSource::processHistoryRegistry(), readElements(), readNextItemType(), edm::JobReport::reportInputLumiSection(), and edm::LuminosityBlockID::run().

673  {
674  // Read elements of a current lumi.
675  do {
676  readElements();
677  m_currentIndex++;
678  } while (!isRunOrLumiTransition());
679 
681 
683  jr->reportInputLumiSection(lbCache.id().run(), lbCache.id().luminosityBlock());
685 }
LuminosityBlockNumber_t luminosityBlock() const
void readNextItemType()
void fillLuminosityBlockPrincipal(ProcessHistory const *processHistory, DelayedReader *reader=nullptr)
ProcessHistoryID const & processHistoryID() const
unsigned int m_currentIndex
void reportInputLumiSection(unsigned int run, unsigned int lumiSectId)
Definition: JobReport.cc:478
RunNumber_t run() const
bool isRunOrLumiTransition() const
ProcessHistoryRegistry const & processHistoryRegistry() const
Accessors for process history registry.
Definition: InputSource.h:139
LuminosityBlockAuxiliary const & aux() const

◆ readLuminosityBlockAuxiliary_()

std::shared_ptr< edm::LuminosityBlockAuxiliary > DQMRootSource::readLuminosityBlockAuxiliary_ ( )
overrideprivatevirtual

Implements edm::InputSource.

Definition at line 648 of file DQMRootSource.cc.

References m_currentIndex, m_fileMetadatas, and OccupancyTask_cfi::metadata.

648  {
649  FileMetadata metadata = m_fileMetadatas[m_currentIndex];
651  edm::Timestamp(metadata.m_beginTime),
652  edm::Timestamp(metadata.m_endTime));
653  return std::make_shared<edm::LuminosityBlockAuxiliary>(lumiAux);
654 }
unsigned int m_currentIndex
std::vector< FileMetadata > m_fileMetadatas

◆ readNextItemType()

void DQMRootSource::readNextItemType ( )
private

Definition at line 729 of file DQMRootSource.cc.

References edm::InputSource::IsLumi, edm::InputSource::IsRun, edm::InputSource::IsStop, m_currentIndex, m_fileMetadatas, DQMTTreeIO::FileMetadata::m_lumi, m_nextItemType, DQMTTreeIO::FileMetadata::m_run, and OccupancyTask_cfi::metadata.

Referenced by readLuminosityBlock_(), and readRun_().

729  {
730  if (m_currentIndex == 0) {
732  } else if (m_currentIndex > m_fileMetadatas.size() - 1) {
733  // We reached the end
735  } else {
736  FileMetadata previousMetadata = m_fileMetadatas[m_currentIndex - 1];
737  FileMetadata metadata = m_fileMetadatas[m_currentIndex];
738 
739  if (previousMetadata.m_run != metadata.m_run) {
741  } else if (previousMetadata.m_lumi != metadata.m_lumi) {
743  }
744  }
745 }
edm::InputSource::ItemType m_nextItemType
unsigned int m_currentIndex
std::vector< FileMetadata > m_fileMetadatas

◆ readRun_()

void DQMRootSource::readRun_ ( edm::RunPrincipal rpCache)
overrideprivatevirtual

Reimplemented from edm::InputSource.

Definition at line 656 of file DQMRootSource.cc.

References edm::RunPrincipal::fillRunPrincipal(), edm::RunPrincipal::id(), isRunOrLumiTransition(), m_currentIndex, m_fileMetadatas, OccupancyTask_cfi::metadata, edm::InputSource::processHistoryRegistryForUpdate(), readElements(), readNextItemType(), edm::JobReport::reportInputRunNumber(), and edm::RunID::run().

656  {
657  // Read elements of a current run.
658  do {
659  FileMetadata metadata = m_fileMetadatas[m_currentIndex];
660  if (metadata.m_lumi == 0) {
661  readElements();
662  }
663  m_currentIndex++;
664  } while (!isRunOrLumiTransition());
665 
667 
669  jr->reportInputRunNumber(rpCache.id().run());
671 }
void readNextItemType()
void reportInputRunNumber(unsigned int run)
Definition: JobReport.cc:484
RunID const & id() const
Definition: RunPrincipal.h:65
unsigned int m_currentIndex
bool isRunOrLumiTransition() const
ProcessHistoryRegistry & processHistoryRegistryForUpdate()
Definition: InputSource.h:331
void fillRunPrincipal(ProcessHistoryRegistry const &processHistoryRegistry, DelayedReader *reader=nullptr)
Definition: RunPrincipal.cc:25
RunNumber_t run() const
Definition: RunID.h:26
std::vector< FileMetadata > m_fileMetadatas

◆ readRunAuxiliary_()

std::shared_ptr< edm::RunAuxiliary > DQMRootSource::readRunAuxiliary_ ( )
overrideprivatevirtual

Implements edm::InputSource.

Definition at line 641 of file DQMRootSource.cc.

References m_currentIndex, m_fileMetadatas, and OccupancyTask_cfi::metadata.

641  {
642  FileMetadata metadata = m_fileMetadatas[m_currentIndex];
643  auto runAux =
644  edm::RunAuxiliary(metadata.m_run, edm::Timestamp(metadata.m_beginTime), edm::Timestamp(metadata.m_endTime));
645  return std::make_shared<edm::RunAuxiliary>(runAux);
646 }
unsigned int m_currentIndex
std::vector< FileMetadata > m_fileMetadatas

Member Data Documentation

◆ m_catalog

edm::InputFileCatalog DQMRootSource::m_catalog
private

Definition at line 368 of file DQMRootSource.cc.

Referenced by readFile_().

◆ m_currentIndex

unsigned int DQMRootSource::m_currentIndex
private

◆ m_fileMetadatas

std::vector<FileMetadata> DQMRootSource::m_fileMetadatas
private

◆ m_filterOnRun

unsigned int DQMRootSource::m_filterOnRun
private

Definition at line 367 of file DQMRootSource.cc.

Referenced by keepIt().

◆ m_lumisToProcess

std::vector<edm::LuminosityBlockRange> DQMRootSource::m_lumisToProcess
private

Definition at line 369 of file DQMRootSource.cc.

Referenced by keepIt().

◆ m_nextItemType

edm::InputSource::ItemType DQMRootSource::m_nextItemType
private

Definition at line 372 of file DQMRootSource.cc.

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

◆ m_openFiles

std::vector<OpenFileInfo> DQMRootSource::m_openFiles
private

Definition at line 393 of file DQMRootSource.cc.

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

◆ m_rescope

MonitorElementData::Scope DQMRootSource::m_rescope
private

Definition at line 370 of file DQMRootSource.cc.

◆ m_skipBadFiles

bool DQMRootSource::m_skipBadFiles
private

Definition at line 366 of file DQMRootSource.cc.

Referenced by readFile_().

◆ m_treeReaders

std::vector<std::shared_ptr<TreeReaderBase> > DQMRootSource::m_treeReaders
private

Definition at line 374 of file DQMRootSource.cc.

Referenced by readElements().