CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 (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 () final
 Register any produced products. More...
 
- 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
< LuminosityBlockAuxiliary
luminosityBlockAuxiliary () 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...
 
std::shared_ptr
< ProductRegistry > & 
productRegistry ()
 
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
< LuminosityBlockAuxiliary
readLuminosityBlockAuxiliary ()
 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)
 
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
 
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)
 
 ~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::LuminosityBlockAuxiliary
readLuminosityBlockAuxiliary_ () override
 
void readNextItemType ()
 
void readRun_ (edm::RunPrincipal &rpCache) override
 
std::shared_ptr
< edm::RunAuxiliary
readRunAuxiliary_ () override
 

Private Attributes

edm::InputFileCatalog m_catalog
 
unsigned int m_currentIndex
 
std::vector< FileMetadatam_fileMetadatas
 
unsigned int m_filterOnRun
 
std::vector
< edm::LuminosityBlockRange
m_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
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::DQMRootSource ( edm::ParameterSet const &  iPSet,
const edm::InputSourceDescription iDesc 
)

Definition at line 409 of file DQMRootSource.cc.

410  : edm::PuttableSourceBase(iPSet, iDesc),
411  m_skipBadFiles(iPSet.getUntrackedParameter<bool>("skipBadFiles", false)),
412  m_filterOnRun(iPSet.getUntrackedParameter<unsigned int>("filterOnRun", 0)),
413  m_catalog(iPSet.getUntrackedParameter<std::vector<std::string>>("fileNames"),
414  iPSet.getUntrackedParameter<std::string>("overrideCatalog")),
415  m_lumisToProcess(iPSet.getUntrackedParameter<std::vector<edm::LuminosityBlockRange>>(
416  "lumisToProcess", std::vector<edm::LuminosityBlockRange>())),
417  m_rescope(std::map<std::string, MonitorElementData::Scope>{
418  {"", MonitorElementData::Scope::LUMI},
419  {"LUMI", MonitorElementData::Scope::LUMI},
420  {"RUN", MonitorElementData::Scope::RUN},
421  {"JOB", MonitorElementData::Scope::JOB}}[iPSet.getUntrackedParameter<std::string>("reScope", "JOB")]),
MonitorElementData::Scope m_rescope
unsigned int m_filterOnRun
edm::InputFileCatalog m_catalog
std::vector< edm::LuminosityBlockRange > m_lumisToProcess
DQMRootSource::DQMRootSource ( const DQMRootSource )
delete
DQMRootSource::~DQMRootSource ( )
override

Definition at line 451 of file DQMRootSource.cc.

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

451  {
452  for (auto& file : m_openFiles) {
453  if (file != nullptr && file->IsOpen()) {
454  file->Close();
455  logFileAction("Closed file", "");
456  }
457  }
458 }
void logFileAction(char const *msg, char const *fileName) const
std::vector< TFile * > m_openFiles

Member Function Documentation

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

Reimplemented from edm::PuttableSourceBase.

Definition at line 717 of file DQMRootSource.cc.

References eostools::move(), and edm::LuminosityBlock::put().

717  {
718  std::unique_ptr<DQMToken> product = std::make_unique<DQMToken>();
719  lumi.put(std::move(product), "DQMGenerationRecoLumi");
720 }
void put(std::unique_ptr< PROD > product)
Put a new product.
def move
Definition: eostools.py:511
void DQMRootSource::beginRun ( edm::Run run)
overrideprivatevirtual

Reimplemented from edm::PuttableSourceBase.

Definition at line 712 of file DQMRootSource.cc.

References eostools::move(), and edm::Run::put().

712  {
713  std::unique_ptr<DQMToken> product = std::make_unique<DQMToken>();
714  run.put(std::move(product), "DQMGenerationRecoRun");
715 }
def move
Definition: eostools.py:511
void put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Run.h:109
void DQMRootSource::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 386 of file DQMRootSource.cc.

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

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

Implements edm::InputSource.

Definition at line 464 of file DQMRootSource.cc.

References m_nextItemType.

464 { return m_nextItemType; }
edm::InputSource::ItemType m_nextItemType
bool DQMRootSource::isRunOrLumiTransition ( ) const
private

Definition at line 678 of file DQMRootSource.cc.

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

Referenced by readLuminosityBlock_(), and readRun_().

678  {
679  if (m_currentIndex == 0) {
680  return false;
681  }
682 
683  if (m_currentIndex > m_fileMetadatas.size() - 1) {
684  // We reached the end
685  return true;
686  }
687 
688  FileMetadata previousMetadata = m_fileMetadatas[m_currentIndex - 1];
689  FileMetadata metadata = m_fileMetadatas[m_currentIndex];
690 
691  return previousMetadata.m_run != metadata.m_run || previousMetadata.m_lumi != metadata.m_lumi;
692 }
unsigned int m_currentIndex
std::vector< FileMetadata > m_fileMetadatas
bool DQMRootSource::keepIt ( edm::RunNumber_t  run,
edm::LuminosityBlockNumber_t  lumi 
) const
private

Definition at line 722 of file DQMRootSource.cc.

References m_filterOnRun, and m_lumisToProcess.

Referenced by readFile_().

722  {
723  if (m_filterOnRun != 0 && run != m_filterOnRun) {
724  return false;
725  }
726 
727  if (m_lumisToProcess.empty()) {
728  return true;
729  }
730 
731  for (edm::LuminosityBlockRange const& lumiToProcess : m_lumisToProcess) {
732  if (run >= lumiToProcess.startRun() && run <= lumiToProcess.endRun()) {
733  if (lumi >= lumiToProcess.startLumi() && lumi <= lumiToProcess.endLumi()) {
734  return true;
735  } else if (lumi == 0) {
736  return true;
737  }
738  }
739  }
740  return false;
741 }
unsigned int m_filterOnRun
RunNumber_t run() const
Accessor for current run number.
Definition: InputSource.cc:457
list lumi
Definition: dqmdumpme.py:53
std::vector< edm::LuminosityBlockRange > m_lumisToProcess
void DQMRootSource::logFileAction ( char const *  msg,
char const *  fileName 
) const
private

Definition at line 743 of file DQMRootSource.cc.

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

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

743  {
744  edm::LogAbsolute("fileAction") << std::setprecision(0) << edm::TimeOfDay() << msg << fileName;
746 }
void FlushMessageLog()
tuple msg
Definition: mps_check.py:285
Log< level::System, true > LogAbsolute
const DQMRootSource& DQMRootSource::operator= ( const DQMRootSource )
delete
void DQMRootSource::readElements ( )
private

Definition at line 654 of file DQMRootSource.cc.

References kNoTypesStored, kTypeNames, m_currentIndex, DQMTTreeIO::FileMetadata::m_file, m_fileMetadatas, DQMTTreeIO::FileMetadata::m_firstIndex, DQMTTreeIO::FileMetadata::m_lastIndex, DQMTTreeIO::FileMetadata::m_lumi, DQMTTreeIO::FileMetadata::m_run, m_treeReaders, DQMTTreeIO::FileMetadata::m_type, Utilities::operator, DQM::reader, and MainPageGenerator::tree.

Referenced by readLuminosityBlock_(), and readRun_().

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

Implements edm::InputSource.

Definition at line 652 of file DQMRootSource.cc.

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

Reimplemented from edm::InputSource.

Definition at line 467 of file DQMRootSource.cc.

References cms::Exception::addAdditionalInfo(), cms::Exception::addContext(), cms::Exception::additionalInfo(), cms::cuda::assert(), alignCSCRings::e, mergeVDriftHistosByStation::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(), DQMTTreeIO::FileMetadata::m_beginTime, m_catalog, DQMTTreeIO::FileMetadata::m_endTime, DQMTTreeIO::FileMetadata::m_file, m_fileMetadatas, DQMTTreeIO::FileMetadata::m_firstIndex, DQMTTreeIO::FileMetadata::m_lastIndex, DQMTTreeIO::FileMetadata::m_lumi, m_nextItemType, m_openFiles, DQMTTreeIO::FileMetadata::m_run, m_skipBadFiles, DQMTTreeIO::FileMetadata::m_type, GetRecoTauVFromDQM_MC_cff::next, edm::InputSource::run(), alignCSCRings::s, edm::threadLocalException::setException(), and groupFilesInBlocks::temp.

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

Reimplemented from edm::InputSource.

Definition at line 638 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().

638  {
639  // Read elements of a current lumi.
640  do {
641  readElements();
642  m_currentIndex++;
643  } while (!isRunOrLumiTransition());
644 
646 
648  jr->reportInputLumiSection(lbCache.id().run(), lbCache.id().luminosityBlock());
650 }
ProcessHistoryRegistry const & processHistoryRegistry() const
Accessors for process history registry.
Definition: InputSource.h:140
void readNextItemType()
void fillLuminosityBlockPrincipal(ProcessHistory const *processHistory, DelayedReader *reader=nullptr)
ProcessHistoryID const & processHistoryID() const
LuminosityBlockAuxiliary const & aux() const
unsigned int m_currentIndex
void reportInputLumiSection(unsigned int run, unsigned int lumiSectId)
Definition: JobReport.cc:465
RunNumber_t run() const
bool isRunOrLumiTransition() const
LuminosityBlockNumber_t luminosityBlock() const
std::shared_ptr< edm::LuminosityBlockAuxiliary > DQMRootSource::readLuminosityBlockAuxiliary_ ( )
overrideprivatevirtual

Implements edm::InputSource.

Definition at line 613 of file DQMRootSource.cc.

References DQMTTreeIO::FileMetadata::m_beginTime, m_currentIndex, DQMTTreeIO::FileMetadata::m_endTime, m_fileMetadatas, DQMTTreeIO::FileMetadata::m_lumi, and DQMTTreeIO::FileMetadata::m_run.

613  {
614  FileMetadata metadata = m_fileMetadatas[m_currentIndex];
615  auto lumiAux = edm::LuminosityBlockAuxiliary(edm::LuminosityBlockID(metadata.m_run, metadata.m_lumi),
616  edm::Timestamp(metadata.m_beginTime),
617  edm::Timestamp(metadata.m_endTime));
618  return std::make_shared<edm::LuminosityBlockAuxiliary>(lumiAux);
619 }
unsigned int m_currentIndex
std::vector< FileMetadata > m_fileMetadatas
void DQMRootSource::readNextItemType ( )
private

Definition at line 694 of file DQMRootSource.cc.

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

Referenced by readLuminosityBlock_(), and readRun_().

694  {
695  if (m_currentIndex == 0) {
697  } else if (m_currentIndex > m_fileMetadatas.size() - 1) {
698  // We reached the end
700  } else {
701  FileMetadata previousMetadata = m_fileMetadatas[m_currentIndex - 1];
702  FileMetadata metadata = m_fileMetadatas[m_currentIndex];
703 
704  if (previousMetadata.m_run != metadata.m_run) {
706  } else if (previousMetadata.m_lumi != metadata.m_lumi) {
708  }
709  }
710 }
edm::InputSource::ItemType m_nextItemType
unsigned int m_currentIndex
std::vector< FileMetadata > m_fileMetadatas
void DQMRootSource::readRun_ ( edm::RunPrincipal rpCache)
overrideprivatevirtual

Reimplemented from edm::InputSource.

Definition at line 621 of file DQMRootSource.cc.

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

621  {
622  // Read elements of a current run.
623  do {
624  FileMetadata metadata = m_fileMetadatas[m_currentIndex];
625  if (metadata.m_lumi == 0) {
626  readElements();
627  }
628  m_currentIndex++;
629  } while (!isRunOrLumiTransition());
630 
632 
634  jr->reportInputRunNumber(rpCache.id().run());
636 }
void readNextItemType()
RunNumber_t run() const
Definition: RunID.h:36
void reportInputRunNumber(unsigned int run)
Definition: JobReport.cc:471
unsigned int m_currentIndex
bool isRunOrLumiTransition() const
RunID const & id() const
Definition: RunPrincipal.h:65
ProcessHistoryRegistry & processHistoryRegistryForUpdate()
Definition: InputSource.h:331
void fillRunPrincipal(ProcessHistoryRegistry const &processHistoryRegistry, DelayedReader *reader=nullptr)
Definition: RunPrincipal.cc:28
std::vector< FileMetadata > m_fileMetadatas
std::shared_ptr< edm::RunAuxiliary > DQMRootSource::readRunAuxiliary_ ( )
overrideprivatevirtual

Implements edm::InputSource.

Definition at line 606 of file DQMRootSource.cc.

References DQMTTreeIO::FileMetadata::m_beginTime, m_currentIndex, DQMTTreeIO::FileMetadata::m_endTime, m_fileMetadatas, and DQMTTreeIO::FileMetadata::m_run.

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

Member Data Documentation

edm::InputFileCatalog DQMRootSource::m_catalog
private

Definition at line 362 of file DQMRootSource.cc.

Referenced by readFile_().

unsigned int DQMRootSource::m_currentIndex
private
std::vector<FileMetadata> DQMRootSource::m_fileMetadatas
private
unsigned int DQMRootSource::m_filterOnRun
private

Definition at line 361 of file DQMRootSource.cc.

Referenced by keepIt().

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

Definition at line 363 of file DQMRootSource.cc.

Referenced by keepIt().

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

Definition at line 366 of file DQMRootSource.cc.

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

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

Definition at line 373 of file DQMRootSource.cc.

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

MonitorElementData::Scope DQMRootSource::m_rescope
private

Definition at line 364 of file DQMRootSource.cc.

bool DQMRootSource::m_skipBadFiles
private

Definition at line 360 of file DQMRootSource.cc.

Referenced by readFile_().

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

Definition at line 368 of file DQMRootSource.cc.

Referenced by readElements().