CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
List of all members | Classes | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes
DQMRootSource Class Reference
Inheritance diagram for DQMRootSource:
edm::PuttableSourceBase DQMTTreeIO edm::InputSource edm::ProducerBase edm::ProductRegistryHelper

Classes

struct  OpenFileInfo
 

Public Member Functions

 DQMRootSource (edm::ParameterSet const &, const edm::InputSourceDescription &)
 
 DQMRootSource (const DQMRootSource &)=delete
 
const DQMRootSourceoperator= (const DQMRootSource &)=delete
 
 ~DQMRootSource () override
 
- Public Member Functions inherited from edm::PuttableSourceBase
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
PuttableSourceBaseoperator= (const PuttableSourceBase &)=delete
 
 PuttableSourceBase (ParameterSet const &, InputSourceDescription const &)
 
 PuttableSourceBase (const PuttableSourceBase &)=delete
 
void registerProducts () 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< OpenFileInfom_openFiles
 
MonitorElementData::Scope m_rescope
 
bool m_skipBadFiles
 
std::vector< std::shared_ptr
< TreeReaderBase > > 
m_treeReaders
 

Additional Inherited Members

- Public Types inherited from edm::InputSource
enum  ItemType {
  IsInvalid, IsStop, IsFile, IsRun,
  IsLumi, IsEvent, IsRepeat, IsSynchronize
}
 
enum  ProcessingMode { Runs, RunsAndLumis, RunsLumisAndEvents }
 
- Public Types inherited from edm::ProducerBase
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 424 of file DQMRootSource.cc.

425  : edm::PuttableSourceBase(iPSet, iDesc),
426  m_skipBadFiles(iPSet.getUntrackedParameter<bool>("skipBadFiles", false)),
427  m_filterOnRun(iPSet.getUntrackedParameter<unsigned int>("filterOnRun", 0)),
428  m_catalog(iPSet.getUntrackedParameter<std::vector<std::string>>("fileNames"),
429  iPSet.getUntrackedParameter<std::string>("overrideCatalog")),
430  m_lumisToProcess(iPSet.getUntrackedParameter<std::vector<edm::LuminosityBlockRange>>(
431  "lumisToProcess", std::vector<edm::LuminosityBlockRange>())),
432  m_rescope(std::map<std::string, MonitorElementData::Scope>{
433  {"", MonitorElementData::Scope::LUMI},
434  {"LUMI", MonitorElementData::Scope::LUMI},
435  {"RUN", MonitorElementData::Scope::RUN},
436  {"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 466 of file DQMRootSource.cc.

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

466  {
467  for (auto& file : m_openFiles) {
468  if (file.m_file && file.m_file->IsOpen()) {
469  logFileAction("Closed file", "");
470  }
471  }
472 }
void logFileAction(char const *msg, char const *fileName) const
std::vector< OpenFileInfo > m_openFiles

Member Function Documentation

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

Reimplemented from edm::PuttableSourceBase.

Definition at line 744 of file DQMRootSource.cc.

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

744  {
745  std::unique_ptr<DQMToken> product = std::make_unique<DQMToken>();
746  lumi.put(std::move(product), "DQMGenerationRecoLumi");
747 }
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 739 of file DQMRootSource.cc.

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

739  {
740  std::unique_ptr<DQMToken> product = std::make_unique<DQMToken>();
741  run.put(std::move(product), "DQMGenerationRecoRun");
742 }
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 401 of file DQMRootSource.cc.

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

401  {
403  desc.addUntracked<std::vector<std::string>>("fileNames")->setComment("Names of files to be processed.");
404  desc.addUntracked<unsigned int>("filterOnRun", 0)->setComment("Just limit the process to the selected run.");
405  desc.addUntracked<std::string>("reScope", "JOB")
406  ->setComment(
407  "Accumulate histograms more coarsely."
408  " Options: \"\": keep unchanged, \"RUN\": turn LUMI histograms into RUN histograms, \"JOB\": turn everything "
409  "into JOB histograms.");
410  desc.addUntracked<bool>("skipBadFiles", false)->setComment("Skip the file if it is not valid");
411  desc.addUntracked<std::string>("overrideCatalog", std::string())
412  ->setComment("An alternate file catalog to use instead of the standard site one.");
413  std::vector<edm::LuminosityBlockRange> defaultLumis;
414  desc.addUntracked<std::vector<edm::LuminosityBlockRange>>("lumisToProcess", defaultLumis)
415  ->setComment("Skip any lumi inside the specified run:lumi range.");
416 
417  descriptions.addDefault(desc);
418 }
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 478 of file DQMRootSource.cc.

References m_nextItemType.

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

Definition at line 705 of file DQMRootSource.cc.

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

Referenced by readLuminosityBlock_(), and readRun_().

705  {
706  if (m_currentIndex == 0) {
707  return false;
708  }
709 
710  if (m_currentIndex > m_fileMetadatas.size() - 1) {
711  // We reached the end
712  return true;
713  }
714 
715  FileMetadata previousMetadata = m_fileMetadatas[m_currentIndex - 1];
716  FileMetadata metadata = m_fileMetadatas[m_currentIndex];
717 
718  return previousMetadata.m_run != metadata.m_run || previousMetadata.m_lumi != metadata.m_lumi;
719 }
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 749 of file DQMRootSource.cc.

References m_filterOnRun, and m_lumisToProcess.

Referenced by readFile_().

749  {
750  if (m_filterOnRun != 0 && run != m_filterOnRun) {
751  return false;
752  }
753 
754  if (m_lumisToProcess.empty()) {
755  return true;
756  }
757 
758  for (edm::LuminosityBlockRange const& lumiToProcess : m_lumisToProcess) {
759  if (run >= lumiToProcess.startRun() && run <= lumiToProcess.endRun()) {
760  if (lumi >= lumiToProcess.startLumi() && lumi <= lumiToProcess.endLumi()) {
761  return true;
762  } else if (lumi == 0) {
763  return true;
764  }
765  }
766  }
767  return false;
768 }
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 770 of file DQMRootSource.cc.

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

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

770  {
771  edm::LogAbsolute("fileAction") << std::setprecision(0) << edm::TimeOfDay() << msg << fileName;
773 }
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 681 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_().

681  {
682  FileMetadata metadata = m_fileMetadatas[m_currentIndex];
683 
684  if (metadata.m_type != kNoTypesStored) {
685  std::shared_ptr<TreeReaderBase> reader = m_treeReaders[metadata.m_type];
686  TTree* tree = dynamic_cast<TTree*>(metadata.m_file->Get(kTypeNames[metadata.m_type]));
687  // The Reset() below screws up the tree, so we need to re-read it from file
688  // before use here.
689  tree->Refresh();
690 
691  reader->setTree(tree);
692 
693  ULong64_t index = metadata.m_firstIndex;
694  ULong64_t endIndex = metadata.m_lastIndex + 1;
695 
696  for (; index != endIndex; ++index) {
697  reader->read(index, edm::Service<DQMStore>().operator->(), metadata.m_run, metadata.m_lumi);
698  }
699  // Drop buffers in the TTree. This reduces memory consuption while the tree
700  // just sits there and waits for the next block to be read.
701  tree->Reset();
702  }
703 }
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 679 of file DQMRootSource.cc.

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

Reimplemented from edm::InputSource.

Definition at line 481 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::JobReport::inputFileOpened(), edm::InputSource::IsRun, edm::InputSource::IsStop, kBeginTimeBranch, kCmsGuid, 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(), AlCaHLTBitMon_QueryRunRegistry::string, groupFilesInBlocks::temp, and HcalDetIdTransform::transform().

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

Reimplemented from edm::InputSource.

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

665  {
666  // Read elements of a current lumi.
667  do {
668  readElements();
669  m_currentIndex++;
670  } while (!isRunOrLumiTransition());
671 
673 
675  jr->reportInputLumiSection(lbCache.id().run(), lbCache.id().luminosityBlock());
677 }
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:466
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 640 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.

640  {
641  FileMetadata metadata = m_fileMetadatas[m_currentIndex];
642  auto lumiAux = edm::LuminosityBlockAuxiliary(edm::LuminosityBlockID(metadata.m_run, metadata.m_lumi),
643  edm::Timestamp(metadata.m_beginTime),
644  edm::Timestamp(metadata.m_endTime));
645  return std::make_shared<edm::LuminosityBlockAuxiliary>(lumiAux);
646 }
unsigned int m_currentIndex
std::vector< FileMetadata > m_fileMetadatas
void DQMRootSource::readNextItemType ( )
private

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

721  {
722  if (m_currentIndex == 0) {
724  } else if (m_currentIndex > m_fileMetadatas.size() - 1) {
725  // We reached the end
727  } else {
728  FileMetadata previousMetadata = m_fileMetadatas[m_currentIndex - 1];
729  FileMetadata metadata = m_fileMetadatas[m_currentIndex];
730 
731  if (previousMetadata.m_run != metadata.m_run) {
733  } else if (previousMetadata.m_lumi != metadata.m_lumi) {
735  }
736  }
737 }
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 648 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().

648  {
649  // Read elements of a current run.
650  do {
651  FileMetadata metadata = m_fileMetadatas[m_currentIndex];
652  if (metadata.m_lumi == 0) {
653  readElements();
654  }
655  m_currentIndex++;
656  } while (!isRunOrLumiTransition());
657 
659 
661  jr->reportInputRunNumber(rpCache.id().run());
663 }
void readNextItemType()
RunNumber_t run() const
Definition: RunID.h:36
void reportInputRunNumber(unsigned int run)
Definition: JobReport.cc:472
unsigned int m_currentIndex
bool isRunOrLumiTransition() const
RunID const & id() const
Definition: RunPrincipal.h:65
ProcessHistoryRegistry & processHistoryRegistryForUpdate()
Definition: InputSource.h:329
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 633 of file DQMRootSource.cc.

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

633  {
634  FileMetadata metadata = m_fileMetadatas[m_currentIndex];
635  auto runAux =
636  edm::RunAuxiliary(metadata.m_run, edm::Timestamp(metadata.m_beginTime), edm::Timestamp(metadata.m_endTime));
637  return std::make_shared<edm::RunAuxiliary>(runAux);
638 }
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<OpenFileInfo> DQMRootSource::m_openFiles
private

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