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

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

468  {
469  for (auto& file : m_openFiles) {
470  if (file.m_file && file.m_file->IsOpen()) {
471  logFileAction("Closed file", "");
472  }
473  }
474 }
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 746 of file DQMRootSource.cc.

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

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

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

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

References m_nextItemType.

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

Definition at line 707 of file DQMRootSource.cc.

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

Referenced by readLuminosityBlock_(), and readRun_().

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

References m_filterOnRun, and m_lumisToProcess.

Referenced by readFile_().

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

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

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

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

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

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

Reimplemented from edm::InputSource.

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

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

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

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

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

723  {
724  if (m_currentIndex == 0) {
726  } else if (m_currentIndex > m_fileMetadatas.size() - 1) {
727  // We reached the end
729  } else {
730  FileMetadata previousMetadata = m_fileMetadatas[m_currentIndex - 1];
731  FileMetadata metadata = m_fileMetadatas[m_currentIndex];
732 
733  if (previousMetadata.m_run != metadata.m_run) {
735  } else if (previousMetadata.m_lumi != metadata.m_lumi) {
737  }
738  }
739 }
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 650 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().

650  {
651  // Read elements of a current run.
652  do {
653  FileMetadata metadata = m_fileMetadatas[m_currentIndex];
654  if (metadata.m_lumi == 0) {
655  readElements();
656  }
657  m_currentIndex++;
658  } while (!isRunOrLumiTransition());
659 
661 
663  jr->reportInputRunNumber(rpCache.id().run());
665 }
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 635 of file DQMRootSource.cc.

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

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