CMS 3D CMS Logo

List of all members | 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

Public Member Functions

 DQMRootSource (edm::ParameterSet const &, const edm::InputSourceDescription &)
 
 ~DQMRootSource () override
 
- Public Member Functions inherited from edm::PuttableSourceBase
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
 PuttableSourceBase (ParameterSet const &, InputSourceDescription const &)
 
void registerProducts () final
 Register any produced products. More...
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
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 > & branchIDListHelper ()
 
std::shared_ptr< BranchIDListHelper const > branchIDListHelper () const
 Accessors for branchIDListHelper. More...
 
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...
 
ProcessingController::ForwardState forwardState () const
 
bool goToEvent (EventID const &eventID)
 
 InputSource (InputSource const &)=delete
 
 InputSource (ParameterSet const &, InputSourceDescription const &)
 Constructor. More...
 
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...
 
InputSourceoperator= (InputSource const &)=delete
 
ProcessConfiguration const & processConfiguration () const
 Accessor for Process Configuration. More...
 
std::string const & processGUID () const
 Accessor for global process identifier. More...
 
ProcessHistoryRegistryprocessHistoryRegistry ()
 
ProcessHistoryRegistry const & processHistoryRegistry () const
 Accessors for process history registry. More...
 
ProcessingMode processingMode () const
 RunsLumisAndEvents (default), RunsAndLumis, or Runs. More...
 
std::shared_ptr< ProductRegistry > & productRegistry ()
 
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...
 
bool readEvent (EventPrincipal &ep, EventID const &, StreamContext &)
 Read a specific event. More...
 
void readEvent (EventPrincipal &ep, StreamContext &)
 Read next event. More...
 
std::unique_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...
 
bool readProcessBlock ()
 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)
 
std::shared_ptr< ThinnedAssociationsHelper > & thinnedAssociationsHelper ()
 
std::shared_ptr< ThinnedAssociationsHelper const > thinnedAssociationsHelper () const
 Accessors for thinnedAssociationsHelper. More...
 
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
 
 DQMRootSource (const DQMRootSource &)=delete
 
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
 
const DQMRootSourceoperator= (const DQMRootSource &)=delete
 
void readElements ()
 
void readEvent_ (edm::EventPrincipal &) override
 
std::unique_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< TFile * > m_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
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<class ProductType >
BranchAliasSetterT< ProductType > produces ()
 declare what type of product will make and with which optional label More...
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces ()
 
template<typename ProductType , Transition B>
BranchAliasSetterT< ProductType > produces ()
 
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)
 
template<Transition B>
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 (std::string instanceName)
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
ProducesCollector producesCollector ()
 
- Private Types inherited from DQMTTreeIO
typedef dqm::harvesting::DQMStore DQMStore
 
typedef dqm::harvesting::MonitorElement MonitorElement
 

Detailed Description

Definition at line 311 of file DQMRootSource.cc.

Constructor & Destructor Documentation

◆ DQMRootSource() [1/2]

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

Definition at line 410 of file DQMRootSource.cc.

411  : edm::PuttableSourceBase(iPSet, iDesc),
412  m_skipBadFiles(iPSet.getUntrackedParameter<bool>("skipBadFiles", false)),
413  m_filterOnRun(iPSet.getUntrackedParameter<unsigned int>("filterOnRun", 0)),
414  m_catalog(iPSet.getUntrackedParameter<std::vector<std::string>>("fileNames"),
415  iPSet.getUntrackedParameter<std::string>("overrideCatalog")),
416  m_lumisToProcess(iPSet.getUntrackedParameter<std::vector<edm::LuminosityBlockRange>>(
417  "lumisToProcess", std::vector<edm::LuminosityBlockRange>())),
418  m_rescope(std::map<std::string, MonitorElementData::Scope>{
419  {"", MonitorElementData::Scope::LUMI},
420  {"LUMI", MonitorElementData::Scope::LUMI},
421  {"RUN", MonitorElementData::Scope::RUN},
422  {"JOB", MonitorElementData::Scope::JOB}}[iPSet.getUntrackedParameter<std::string>("reScope", "JOB")]),
424  m_treeReaders(kNIndicies, std::shared_ptr<TreeReaderBase>()),
425  m_currentIndex(0),
426  m_openFiles(std::vector<TFile*>()),
427  m_fileMetadatas(std::vector<FileMetadata>()) {
429 
430  if (m_catalog.fileNames(0).empty()) {
432  } else {
433  m_treeReaders[kIntIndex].reset(new TreeSimpleReader<Long64_t>(MonitorElementData::Kind::INT, m_rescope));
434  m_treeReaders[kFloatIndex].reset(new TreeSimpleReader<double>(MonitorElementData::Kind::REAL, m_rescope));
436  m_treeReaders[kTH1FIndex].reset(new TreeObjectReader<TH1F>(MonitorElementData::Kind::TH1F, m_rescope));
437  m_treeReaders[kTH1SIndex].reset(new TreeObjectReader<TH1S>(MonitorElementData::Kind::TH1S, m_rescope));
438  m_treeReaders[kTH1DIndex].reset(new TreeObjectReader<TH1D>(MonitorElementData::Kind::TH1D, m_rescope));
439  m_treeReaders[kTH2FIndex].reset(new TreeObjectReader<TH2F>(MonitorElementData::Kind::TH2F, m_rescope));
440  m_treeReaders[kTH2SIndex].reset(new TreeObjectReader<TH2S>(MonitorElementData::Kind::TH2S, m_rescope));
441  m_treeReaders[kTH2DIndex].reset(new TreeObjectReader<TH2D>(MonitorElementData::Kind::TH2D, m_rescope));
442  m_treeReaders[kTH3FIndex].reset(new TreeObjectReader<TH3F>(MonitorElementData::Kind::TH3F, m_rescope));
443  m_treeReaders[kTProfileIndex].reset(new TreeObjectReader<TProfile>(MonitorElementData::Kind::TPROFILE, m_rescope));
445  new TreeObjectReader<TProfile2D>(MonitorElementData::Kind::TPROFILE2D, m_rescope));
446  }
447 
448  produces<DQMToken, edm::Transition::BeginRun>("DQMGenerationRecoRun");
449  produces<DQMToken, edm::Transition::BeginLuminosityBlock>("DQMGenerationRecoLumi");
450 }

◆ ~DQMRootSource()

DQMRootSource::~DQMRootSource ( )
override

Definition at line 452 of file DQMRootSource.cc.

452  {
453  for (auto& file : m_openFiles) {
454  if (file != nullptr && file->IsOpen()) {
455  file->Close();
456  logFileAction("Closed file", "");
457  }
458  }
459 }

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

◆ DQMRootSource() [2/2]

DQMRootSource::DQMRootSource ( const DQMRootSource )
privatedelete

Member Function Documentation

◆ beginLuminosityBlock()

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

Reimplemented from edm::PuttableSourceBase.

Definition at line 718 of file DQMRootSource.cc.

718  {
719  std::unique_ptr<DQMToken> product = std::make_unique<DQMToken>();
720  lumi.put(std::move(product), "DQMGenerationRecoLumi");
721 }

References eostools::move().

◆ beginRun()

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

Reimplemented from edm::PuttableSourceBase.

Definition at line 713 of file DQMRootSource.cc.

713  {
714  std::unique_ptr<DQMToken> product = std::make_unique<DQMToken>();
715  run.put(std::move(product), "DQMGenerationRecoRun");
716 }

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

◆ fillDescriptions()

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

Definition at line 387 of file DQMRootSource.cc.

387  {
389  desc.addUntracked<std::vector<std::string>>("fileNames")->setComment("Names of files to be processed.");
390  desc.addUntracked<unsigned int>("filterOnRun", 0)->setComment("Just limit the process to the selected run.");
391  desc.addUntracked<std::string>("reScope", "JOB")
392  ->setComment(
393  "Accumulate histograms more coarsely."
394  " Options: \"\": keep unchanged, \"RUN\": turn LUMI histograms into RUN histograms, \"JOB\": turn everything "
395  "into JOB histograms.");
396  desc.addUntracked<bool>("skipBadFiles", false)->setComment("Skip the file if it is not valid");
397  desc.addUntracked<std::string>("overrideCatalog", std::string())
398  ->setComment("An alternate file catalog to use instead of the standard site one.");
399  std::vector<edm::LuminosityBlockRange> defaultLumis;
400  desc.addUntracked<std::vector<edm::LuminosityBlockRange>>("lumisToProcess", defaultLumis)
401  ->setComment("Skip any lumi inside the specified run:lumi range.");
402 
403  descriptions.addDefault(desc);
404 }

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

◆ getNextItemType()

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

Implements edm::InputSource.

Definition at line 465 of file DQMRootSource.cc.

465 { return m_nextItemType; }

References m_nextItemType.

◆ isRunOrLumiTransition()

bool DQMRootSource::isRunOrLumiTransition ( ) const
private

Definition at line 679 of file DQMRootSource.cc.

679  {
680  if (m_currentIndex == 0) {
681  return false;
682  }
683 
684  if (m_currentIndex > m_fileMetadatas.size() - 1) {
685  // We reached the end
686  return true;
687  }
688 
689  FileMetadata previousMetadata = m_fileMetadatas[m_currentIndex - 1];
690  FileMetadata metadata = m_fileMetadatas[m_currentIndex];
691 
692  return previousMetadata.m_run != metadata.m_run || previousMetadata.m_lumi != metadata.m_lumi;
693 }

References m_currentIndex, m_fileMetadatas, and TrackingMonitor_cfi::metadata.

Referenced by readLuminosityBlock_(), and readRun_().

◆ keepIt()

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

Definition at line 723 of file DQMRootSource.cc.

723  {
724  if (m_filterOnRun != 0 && run != m_filterOnRun) {
725  return false;
726  }
727 
728  if (m_lumisToProcess.empty()) {
729  return true;
730  }
731 
732  for (edm::LuminosityBlockRange const& lumiToProcess : m_lumisToProcess) {
733  if (run >= lumiToProcess.startRun() && run <= lumiToProcess.endRun()) {
734  if (lumi >= lumiToProcess.startLumi() && lumi <= lumiToProcess.endLumi()) {
735  return true;
736  } else if (lumi == 0) {
737  return true;
738  }
739  }
740  }
741  return false;
742 }

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

Referenced by readFile_().

◆ logFileAction()

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

Definition at line 744 of file DQMRootSource.cc.

744  {
745  edm::LogAbsolute("fileAction") << std::setprecision(0) << edm::TimeOfDay() << msg << fileName;
747 }

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

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

◆ operator=()

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

◆ readElements()

void DQMRootSource::readElements ( )
private

Definition at line 655 of file DQMRootSource.cc.

655  {
656  FileMetadata metadata = m_fileMetadatas[m_currentIndex];
657 
658  if (metadata.m_type != kNoTypesStored) {
659  std::shared_ptr<TreeReaderBase> reader = m_treeReaders[metadata.m_type];
660  TTree* tree = dynamic_cast<TTree*>(metadata.m_file->Get(kTypeNames[metadata.m_type]));
661  // The Reset() below screws up the tree, so we need to re-read it from file
662  // before use here.
663  tree->Refresh();
664 
665  reader->setTree(tree);
666 
667  ULong64_t index = metadata.m_firstIndex;
668  ULong64_t endIndex = metadata.m_lastIndex + 1;
669 
670  for (; index != endIndex; ++index) {
671  reader->read(index, edm::Service<DQMStore>().operator->(), metadata.m_run, metadata.m_lumi);
672  }
673  // Drop buffers in the TTree. This reduces memory consuption while the tree
674  // just sits there and waits for the next block to be read.
675  tree->Reset();
676  }
677 }

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

Referenced by readLuminosityBlock_(), and readRun_().

◆ readEvent_()

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

Implements edm::InputSource.

Definition at line 653 of file DQMRootSource.cc.

653 {}

◆ readFile_()

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

Reimplemented from edm::InputSource.

Definition at line 468 of file DQMRootSource.cc.

468  {
469  const int numFiles = m_catalog.fileNames(0).size();
470  m_openFiles.reserve(numFiles);
471 
472  for (auto& fileitem : m_catalog.fileCatalogItems()) {
473  TFile* file;
474  std::list<std::string> exInfo;
475  //loop over names of a file, each of them corresponds to a data catalog
476  bool isGoodFile(true);
477  //get all names of a file, each of them corresponds to a data catalog
478  const std::vector<std::string>& fNames = fileitem.fileNames();
479  for (std::vector<std::string>::const_iterator it = fNames.begin(); it != fNames.end(); ++it) {
480  // Try to open a file
481  try {
482  file = TFile::Open(it->c_str());
483 
484  // Exception will be trapped so we pull it out ourselves
485  std::exception_ptr e = edm::threadLocalException::getException();
486  if (e != std::exception_ptr()) {
487  edm::threadLocalException::setException(std::exception_ptr());
488  std::rethrow_exception(e);
489  }
490 
491  } catch (cms::Exception const& e) {
492  file = nullptr; // is there anything we need to free?
493  if (std::next(it) == fNames.end()) { //last name corresponding to the last data catalog to try
494  if (!m_skipBadFiles) {
496  ex.addContext("Opening DQM Root file");
497  ex << "\nInput file " << it->c_str() << " was not found, could not be opened, or is corrupted.\n";
498  //report previous exceptions when use other names to open file
499  for (auto const& s : exInfo)
500  ex.addAdditionalInfo(s);
501  throw ex;
502  }
503  isGoodFile = false;
504  }
505  // save in case of error when trying next name
506  for (auto const& s : e.additionalInfo())
507  exInfo.push_back(s);
508  }
509 
510  // Check if a file is usable
511  if (file && !file->IsZombie()) {
512  logFileAction("Successfully opened file ", it->c_str());
513  break;
514  } else {
515  if (std::next(it) == fNames.end()) {
516  if (!m_skipBadFiles) {
518  ex << "Input file " << it->c_str() << " could not be opened.\n";
519  ex.addContext("Opening DQM Root file");
520  //report previous exceptions when use other names to open file
521  for (auto const& s : exInfo)
522  ex.addAdditionalInfo(s);
523  throw ex;
524  }
525  isGoodFile = false;
526  }
527  if (file) {
528  delete file;
529  file = nullptr;
530  }
531  }
532  } //end loop over names of the file
533 
534  if (!isGoodFile && m_skipBadFiles)
535  continue;
536 
537  m_openFiles.insert(m_openFiles.begin(), file);
538 
539  // Check file format version, which is encoded in the Title of the TFile
540  if (strcmp(file->GetTitle(), "1") != 0) {
542  ex << "Input file " << fNames[0].c_str() << " does not appear to be a DQM Root file.\n";
543  }
544 
545  // Read metadata from the file
546  TTree* indicesTree = dynamic_cast<TTree*>(file->Get(kIndicesTree));
547  assert(indicesTree != nullptr);
548 
549  FileMetadata temp;
550  // Each line of metadata will be read into the coresponding fields of temp.
551  indicesTree->SetBranchAddress(kRunBranch, &temp.m_run);
552  indicesTree->SetBranchAddress(kLumiBranch, &temp.m_lumi);
553  indicesTree->SetBranchAddress(kBeginTimeBranch, &temp.m_beginTime);
554  indicesTree->SetBranchAddress(kEndTimeBranch, &temp.m_endTime);
555  indicesTree->SetBranchAddress(kTypeBranch, &temp.m_type);
556  indicesTree->SetBranchAddress(kFirstIndex, &temp.m_firstIndex);
557  indicesTree->SetBranchAddress(kLastIndex, &temp.m_lastIndex);
558 
559  for (Long64_t index = 0; index != indicesTree->GetEntries(); ++index) {
560  indicesTree->GetEntry(index);
561  temp.m_file = file;
562 
563  if (keepIt(temp.m_run, temp.m_lumi)) {
564  m_fileMetadatas.push_back(temp);
565  }
566  }
567 
568  } //end loop over files
569 
570  // Sort to make sure runs and lumis appear in sequential order
571  std::stable_sort(m_fileMetadatas.begin(), m_fileMetadatas.end());
572 
573  // If we have lumisections without matching runs, insert dummy runs here.
574  unsigned int run = 0;
575  auto toadd = std::vector<FileMetadata>();
576  for (auto& metadata : m_fileMetadatas) {
577  if (run < metadata.m_run && metadata.m_lumi != 0) {
578  // run transition and lumi transition at the same time!
579  FileMetadata dummy{}; // zero initialize
580  dummy.m_run = metadata.m_run;
581  dummy.m_lumi = 0;
582  dummy.m_type = kNoTypesStored;
583  toadd.push_back(dummy);
584  }
585  run = metadata.m_run;
586  }
587 
588  if (!toadd.empty()) {
589  // rather than trying to insert at the right places, just append and sort again.
590  m_fileMetadatas.insert(m_fileMetadatas.end(), toadd.begin(), toadd.end());
591  std::stable_sort(m_fileMetadatas.begin(), m_fileMetadatas.end());
592  }
593 
594  //for (auto& metadata : m_fileMetadatas)
595  // metadata.describe();
596 
597  // Stop if there's nothing to process. Otherwise start the run.
598  if (m_fileMetadatas.empty())
600  else
602 
603  // We have to return something but not sure why
604  return std::make_unique<edm::FileBlock>();
605 }

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

◆ readLuminosityBlock_()

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

◆ readLuminosityBlockAuxiliary_()

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

Implements edm::InputSource.

Definition at line 614 of file DQMRootSource.cc.

614  {
615  FileMetadata metadata = m_fileMetadatas[m_currentIndex];
617  edm::Timestamp(metadata.m_beginTime),
618  edm::Timestamp(metadata.m_endTime));
619  return std::make_shared<edm::LuminosityBlockAuxiliary>(lumiAux);
620 }

References m_currentIndex, m_fileMetadatas, and TrackingMonitor_cfi::metadata.

◆ readNextItemType()

void DQMRootSource::readNextItemType ( )
private

Definition at line 695 of file DQMRootSource.cc.

695  {
696  if (m_currentIndex == 0) {
698  } else if (m_currentIndex > m_fileMetadatas.size() - 1) {
699  // We reached the end
701  } else {
702  FileMetadata previousMetadata = m_fileMetadatas[m_currentIndex - 1];
703  FileMetadata metadata = m_fileMetadatas[m_currentIndex];
704 
705  if (previousMetadata.m_run != metadata.m_run) {
707  } else if (previousMetadata.m_lumi != metadata.m_lumi) {
709  }
710  }
711 }

References edm::InputSource::IsLumi, edm::InputSource::IsRun, edm::InputSource::IsStop, m_currentIndex, m_fileMetadatas, m_nextItemType, and TrackingMonitor_cfi::metadata.

Referenced by readLuminosityBlock_(), and readRun_().

◆ readRun_()

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

◆ readRunAuxiliary_()

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

Implements edm::InputSource.

Definition at line 607 of file DQMRootSource.cc.

607  {
608  FileMetadata metadata = m_fileMetadatas[m_currentIndex];
609  auto runAux =
610  edm::RunAuxiliary(metadata.m_run, edm::Timestamp(metadata.m_beginTime), edm::Timestamp(metadata.m_endTime));
611  return std::make_shared<edm::RunAuxiliary>(runAux);
612 }

References m_currentIndex, m_fileMetadatas, and TrackingMonitor_cfi::metadata.

Member Data Documentation

◆ m_catalog

edm::InputFileCatalog DQMRootSource::m_catalog
private

Definition at line 363 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 362 of file DQMRootSource.cc.

Referenced by keepIt().

◆ m_lumisToProcess

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

Definition at line 364 of file DQMRootSource.cc.

Referenced by keepIt().

◆ m_nextItemType

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

Definition at line 367 of file DQMRootSource.cc.

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

◆ m_openFiles

std::vector<TFile*> DQMRootSource::m_openFiles
private

Definition at line 374 of file DQMRootSource.cc.

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

◆ m_rescope

MonitorElementData::Scope DQMRootSource::m_rescope
private

Definition at line 365 of file DQMRootSource.cc.

◆ m_skipBadFiles

bool DQMRootSource::m_skipBadFiles
private

Definition at line 361 of file DQMRootSource.cc.

Referenced by readFile_().

◆ m_treeReaders

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

Definition at line 369 of file DQMRootSource.cc.

Referenced by readElements().

edm::RunPrincipal::id
RunID const & id() const
Definition: RunPrincipal.h:65
DQMRootSource::m_nextItemType
edm::InputSource::ItemType m_nextItemType
Definition: DQMRootSource.cc:367
kLastIndex
static const char *const kLastIndex
Definition: format.h:66
DQMRootSource::keepIt
bool keepIt(edm::RunNumber_t, edm::LuminosityBlockNumber_t) const
Definition: DQMRootSource.cc:723
kTProfileIndex
Definition: format.h:33
MonitorElementData::Kind::INT
edm::TimeOfDay
Definition: TimeOfDay.h:9
edm::RunID::run
RunNumber_t run() const
Definition: RunID.h:36
MonitorElementData::Kind::TH1S
edm::JobReport::reportInputLumiSection
void reportInputLumiSection(unsigned int run, unsigned int lumiSectId)
Definition: JobReport.cc:465
MonitorElementData::Kind::TH1F
DQMRootSource::m_skipBadFiles
bool m_skipBadFiles
Definition: DQMRootSource.cc:361
tree
Definition: tree.py:1
MonitorElementData::Kind::STRING
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
cms::cuda::assert
assert(be >=bs)
edm::InputFileCatalog::fileNames
std::vector< std::string > fileNames(unsigned iCatalog) const
Definition: InputFileCatalog.cc:26
edm::sortAndRemoveOverlaps
std::vector< EventRange > & sortAndRemoveOverlaps(std::vector< EventRange > &eventRange)
Definition: EventRange.cc:98
mps_check.msg
tuple msg
Definition: mps_check.py:285
edm::threadLocalException::getException
std::exception_ptr getException()
Definition: ExceptionPropagate.cc:7
MillePedeFileConverter_cfg.fileName
fileName
Definition: MillePedeFileConverter_cfg.py:32
kLumiBranch
static const char *const kLumiBranch
Definition: format.h:60
groupFilesInBlocks.temp
list temp
Definition: groupFilesInBlocks.py:142
edm::InputSource::processHistoryRegistryForUpdate
ProcessHistoryRegistry & processHistoryRegistryForUpdate()
Definition: InputSource.h:330
MonitorElementData::Kind::TH2D
edm::errors::FileOpenError
Definition: EDMException.h:49
Utilities.operator
operator
Definition: Utilities.py:24
edm::InputSource::IsRun
Definition: InputSource.h:78
edm::Exception
Definition: EDMException.h:77
edm::LuminosityBlockPrincipal::aux
LuminosityBlockAuxiliary const & aux() const
Definition: LuminosityBlockPrincipal.h:64
MonitorElementData::Kind::TH2F
edm::LuminosityBlockAuxiliary
Definition: LuminosityBlockAuxiliary.h:15
kTypeNames
static const char *const kTypeNames[]
Definition: format.h:39
alignCSCRings.s
s
Definition: alignCSCRings.py:92
DQMRootSource::isRunOrLumiTransition
bool isRunOrLumiTransition() const
Definition: DQMRootSource.cc:679
kNoTypesStored
Definition: format.h:36
DQM.reader
reader
Definition: DQM.py:105
kTH3FIndex
Definition: format.h:32
edm::threadLocalException::setException
void setException(std::exception_ptr e)
Definition: ExceptionPropagate.cc:6
edm::LuminosityBlockID
Definition: LuminosityBlockID.h:31
TrackingMonitor_cfi.metadata
metadata
Definition: TrackingMonitor_cfi.py:71
edm::JobReport::reportInputRunNumber
void reportInputRunNumber(unsigned int run)
Definition: JobReport.cc:471
kTypeBranch
static const char *const kTypeBranch
Definition: format.h:64
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::InputSource::IsFile
Definition: InputSource.h:78
edm::LuminosityBlockAuxiliary::processHistoryID
ProcessHistoryID const & processHistoryID() const
Definition: LuminosityBlockAuxiliary.h:32
edm::InputSource::processHistoryRegistry
ProcessHistoryRegistry const & processHistoryRegistry() const
Accessors for process history registry.
Definition: InputSource.h:158
edm::FlushMessageLog
void FlushMessageLog()
Definition: MessageLogger.cc:34
DQMRootSource::m_fileMetadatas
std::vector< FileMetadata > m_fileMetadatas
Definition: DQMRootSource.cc:376
kIntIndex
Definition: format.h:23
edm::InputSource::IsLumi
Definition: InputSource.h:78
kTH1FIndex
Definition: format.h:26
edm::LuminosityBlockPrincipal::fillLuminosityBlockPrincipal
void fillLuminosityBlockPrincipal(ProcessHistory const *processHistory, DelayedReader *reader=nullptr)
Definition: LuminosityBlockPrincipal.cc:16
DQMRootSource::m_treeReaders
std::vector< std::shared_ptr< TreeReaderBase > > m_treeReaders
Definition: DQMRootSource.cc:369
DQMRootSource::m_catalog
edm::InputFileCatalog m_catalog
Definition: DQMRootSource.cc:363
DQMRootSource::m_lumisToProcess
std::vector< edm::LuminosityBlockRange > m_lumisToProcess
Definition: DQMRootSource.cc:364
edm::Service
Definition: Service.h:30
FrontierConditions_GlobalTag_cff.file
file
Definition: FrontierConditions_GlobalTag_cff.py:13
edm::LuminosityBlockID::luminosityBlock
LuminosityBlockNumber_t luminosityBlock() const
Definition: LuminosityBlockID.h:42
edm::LogAbsolute
Log< level::System, true > LogAbsolute
Definition: MessageLogger.h:134
kStringIndex
Definition: format.h:25
kTH1SIndex
Definition: format.h:27
edm::InputSource::IsStop
Definition: InputSource.h:78
kTH2SIndex
Definition: format.h:30
kTH2FIndex
Definition: format.h:29
kEndTimeBranch
static const char *const kEndTimeBranch
Definition: format.h:63
MonitorElementData::Kind::TH1D
kTH2DIndex
Definition: format.h:31
edm::RunPrincipal::fillRunPrincipal
void fillRunPrincipal(ProcessHistoryRegistry const &processHistoryRegistry, DelayedReader *reader=nullptr)
Definition: RunPrincipal.cc:28
kNIndicies
Definition: format.h:35
MonitorElementData::Kind::TH2S
submitPVResolutionJobs.desc
string desc
Definition: submitPVResolutionJobs.py:251
eostools.move
def move(src, dest)
Definition: eostools.py:511
MonitorElementData::Kind::TPROFILE2D
MonitorElementData::Kind::TH3F
DQMRootSource::m_openFiles
std::vector< TFile * > m_openFiles
Definition: DQMRootSource.cc:374
kBeginTimeBranch
static const char *const kBeginTimeBranch
Definition: format.h:62
edm::LuminosityBlockPrincipal::id
LuminosityBlockID id() const
Definition: LuminosityBlockPrincipal.h:53
DQMRootSource::readNextItemType
void readNextItemType()
Definition: DQMRootSource.cc:695
DQMRootSource::m_rescope
MonitorElementData::Scope m_rescope
Definition: DQMRootSource.cc:365
edm::LuminosityBlockID::run
RunNumber_t run() const
Definition: LuminosityBlockID.h:41
AlignmentPI::index
index
Definition: AlignmentPayloadInspectorHelper.h:46
kFirstIndex
static const char *const kFirstIndex
Definition: format.h:65
kTH1DIndex
Definition: format.h:28
cms::Exception
Definition: Exception.h:70
kFloatIndex
Definition: format.h:24
dummy
Definition: DummySelector.h:38
kIndicesTree
static const char *const kIndicesTree
Definition: format.h:58
edm::PuttableSourceBase
Definition: PuttableSourceBase.h:30
edm::ConfigurationDescriptions::addDefault
void addDefault(ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:99
lumi
Definition: LumiSectionData.h:20
edm::errors::FileReadError
Definition: EDMException.h:50
MonitorElementData::Kind::TPROFILE
DQMRootSource::m_currentIndex
unsigned int m_currentIndex
Definition: DQMRootSource.cc:372
edm::InputFileCatalog::fileCatalogItems
std::vector< FileCatalogItem > const & fileCatalogItems() const
Definition: InputFileCatalog.h:39
MonitorElementData::Kind::REAL
DQMRootSource::m_filterOnRun
unsigned int m_filterOnRun
Definition: DQMRootSource.cc:362
kTProfile2DIndex
Definition: format.h:34
GetRecoTauVFromDQM_MC_cff.next
next
Definition: GetRecoTauVFromDQM_MC_cff.py:31
edm::LuminosityBlockRange
Definition: LuminosityBlockRange.h:32
edm::RunAuxiliary
Definition: RunAuxiliary.h:15
edm::InputSource::run
RunNumber_t run() const
Accessor for current run number.
Definition: InputSource.cc:439
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37
DQMRootSource::logFileAction
void logFileAction(char const *msg, char const *fileName) const
Definition: DQMRootSource.cc:744
DQMRootSource::readElements
void readElements()
Definition: DQMRootSource.cc:655
kRunBranch
static const char *const kRunBranch
Definition: format.h:59
edm::Timestamp
Definition: Timestamp.h:30