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...
 
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 309 of file DQMRootSource.cc.

Constructor & Destructor Documentation

◆ DQMRootSource() [1/2]

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

Definition at line 408 of file DQMRootSource.cc.

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

◆ ~DQMRootSource()

DQMRootSource::~DQMRootSource ( )
override

Definition at line 450 of file DQMRootSource.cc.

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

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 709 of file DQMRootSource.cc.

709  {
710  std::unique_ptr<DQMToken> product = std::make_unique<DQMToken>();
711  lumi.put(std::move(product), "DQMGenerationRecoLumi");
712 }

References eostools::move().

◆ beginRun()

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

Reimplemented from edm::PuttableSourceBase.

Definition at line 704 of file DQMRootSource.cc.

704  {
705  std::unique_ptr<DQMToken> product = std::make_unique<DQMToken>();
706  run.put(std::move(product), "DQMGenerationRecoRun");
707 }

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

◆ fillDescriptions()

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

Definition at line 385 of file DQMRootSource.cc.

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

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

◆ getNextItemType()

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

Implements edm::InputSource.

Definition at line 463 of file DQMRootSource.cc.

463 { return m_nextItemType; }

References m_nextItemType.

◆ isRunOrLumiTransition()

bool DQMRootSource::isRunOrLumiTransition ( ) const
private

Definition at line 670 of file DQMRootSource.cc.

670  {
671  if (m_currentIndex == 0) {
672  return false;
673  }
674 
675  if (m_currentIndex > m_fileMetadatas.size() - 1) {
676  // We reached the end
677  return true;
678  }
679 
680  FileMetadata previousMetadata = m_fileMetadatas[m_currentIndex - 1];
681  FileMetadata metadata = m_fileMetadatas[m_currentIndex];
682 
683  return previousMetadata.m_run != metadata.m_run || previousMetadata.m_lumi != metadata.m_lumi;
684 }

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 714 of file DQMRootSource.cc.

714  {
715  if (m_filterOnRun != 0 && run != m_filterOnRun) {
716  return false;
717  }
718 
719  if (m_lumisToProcess.empty()) {
720  return true;
721  }
722 
723  for (edm::LuminosityBlockRange const& lumiToProcess : m_lumisToProcess) {
724  if (run >= lumiToProcess.startRun() && run <= lumiToProcess.endRun()) {
725  if (lumi >= lumiToProcess.startLumi() && lumi <= lumiToProcess.endLumi()) {
726  return true;
727  } else if (lumi == 0) {
728  return true;
729  }
730  }
731  }
732  return false;
733 }

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 735 of file DQMRootSource.cc.

735  {
736  edm::LogAbsolute("fileAction") << std::setprecision(0) << edm::TimeOfDay() << msg << fileName;
738 }

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 653 of file DQMRootSource.cc.

653  {
654  FileMetadata metadata = m_fileMetadatas[m_currentIndex];
655 
656  if (metadata.m_type != kNoTypesStored) {
657  std::shared_ptr<TreeReaderBase> reader = m_treeReaders[metadata.m_type];
658  TTree* tree = dynamic_cast<TTree*>(metadata.m_file->Get(kTypeNames[metadata.m_type]));
659  reader->setTree(tree);
660 
661  ULong64_t index = metadata.m_firstIndex;
662  ULong64_t endIndex = metadata.m_lastIndex + 1;
663 
664  for (; index != endIndex; ++index) {
665  reader->read(index, edm::Service<DQMStore>().operator->(), metadata.m_run, metadata.m_lumi);
666  }
667  }
668 }

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 651 of file DQMRootSource.cc.

651 {}

◆ readFile_()

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

Reimplemented from edm::InputSource.

Definition at line 466 of file DQMRootSource.cc.

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

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 612 of file DQMRootSource.cc.

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

References m_currentIndex, m_fileMetadatas, and TrackingMonitor_cfi::metadata.

◆ readNextItemType()

void DQMRootSource::readNextItemType ( )
private

Definition at line 686 of file DQMRootSource.cc.

686  {
687  if (m_currentIndex == 0) {
689  } else if (m_currentIndex > m_fileMetadatas.size() - 1) {
690  // We reached the end
692  } else {
693  FileMetadata previousMetadata = m_fileMetadatas[m_currentIndex - 1];
694  FileMetadata metadata = m_fileMetadatas[m_currentIndex];
695 
696  if (previousMetadata.m_run != metadata.m_run) {
698  } else if (previousMetadata.m_lumi != metadata.m_lumi) {
700  }
701  }
702 }

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 605 of file DQMRootSource.cc.

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

References m_currentIndex, m_fileMetadatas, and TrackingMonitor_cfi::metadata.

Member Data Documentation

◆ m_catalog

edm::InputFileCatalog DQMRootSource::m_catalog
private

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

Referenced by keepIt().

◆ m_lumisToProcess

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

Definition at line 362 of file DQMRootSource.cc.

Referenced by keepIt().

◆ m_nextItemType

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

Definition at line 365 of file DQMRootSource.cc.

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

◆ m_openFiles

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

Definition at line 372 of file DQMRootSource.cc.

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

◆ m_rescope

MonitorElementData::Scope DQMRootSource::m_rescope
private

Definition at line 363 of file DQMRootSource.cc.

◆ m_skipBadFiles

bool DQMRootSource::m_skipBadFiles
private

Definition at line 359 of file DQMRootSource.cc.

Referenced by readFile_().

◆ m_treeReaders

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

Definition at line 367 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:365
edm::LogAbsolute
Definition: MessageLogger.h:469
kLastIndex
static const char *const kLastIndex
Definition: format.h:66
DQMRootSource::keepIt
bool keepIt(edm::RunNumber_t, edm::LuminosityBlockNumber_t) const
Definition: DQMRootSource.cc:714
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:359
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:327
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::FileBlock
Definition: FileBlock.h:20
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:670
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:28
edm::ParameterSetDescription::addUntracked
ParameterDescriptionBase * addUntracked(U const &iLabel, T const &value)
Definition: ParameterSetDescription.h:100
edm::InputSource::processHistoryRegistry
ProcessHistoryRegistry const & processHistoryRegistry() const
Accessors for process history registry.
Definition: InputSource.h:155
edm::FlushMessageLog
void FlushMessageLog()
Definition: MessageLogger.cc:94
DQMRootSource::m_fileMetadatas
std::vector< FileMetadata > m_fileMetadatas
Definition: DQMRootSource.cc:374
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:367
DQMRootSource::m_catalog
edm::InputFileCatalog m_catalog
Definition: DQMRootSource.cc:361
DQMRootSource::m_lumisToProcess
std::vector< edm::LuminosityBlockRange > m_lumisToProcess
Definition: DQMRootSource.cc:362
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
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:26
kNIndicies
Definition: format.h:35
MonitorElementData::Kind::TH2S
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:372
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:686
DQMRootSource::m_rescope
MonitorElementData::Scope m_rescope
Definition: DQMRootSource.cc:363
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:370
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:360
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:437
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37
DQMRootSource::logFileAction
void logFileAction(char const *msg, char const *fileName) const
Definition: DQMRootSource.cc:735
DQMRootSource::readElements
void readElements()
Definition: DQMRootSource.cc:653
kRunBranch
static const char *const kRunBranch
Definition: format.h:59
edm::Timestamp
Definition: Timestamp.h:30