CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
fwlite::BranchMapReader Class Reference

#include <BranchMapReader.h>

Public Member Functions

const edm::BranchDescriptionbranchIDToBranch (const edm::BranchID &bid) const
 
const edm::BranchListIndexesbranchListIndexes () const
 
 BranchMapReader ()
 
 BranchMapReader (TFile *file)
 
const std::vector< edm::BranchDescription > & getBranchDescriptions ()
 
Long_t getEventEntry () const
 
TTree * getEventTree ()
 
TTree const * getEventTree () const
 
TFile * getFile ()
 
TFile const * getFile () const
 
TUUID getFileUUID () const
 
int getFileVersion () const
 
int getFileVersion (TFile *file)
 
Long_t getLuminosityBlockEntry () const
 
TTree * getLuminosityBlockTree ()
 
TTree const * getLuminosityBlockTree () const
 
Long_t getRunEntry () const
 
TTree * getRunTree ()
 
TTree const * getRunTree () const
 
const edm::BranchDescriptionproductToBranch (const edm::ProductID &pid)
 
edm::BranchID productToBranchID (const edm::ProductID &pid)
 
const edm::ThinnedAssociationsHelperthinnedAssociationsHelper () const
 
bool updateEvent (Long_t eventEntry)
 
bool updateFile (TFile *file)
 
bool updateLuminosityBlock (Long_t luminosityBlockEntry)
 
bool updateRun (Long_t runEntry)
 

Private Member Functions

std::unique_ptr< internal::BMRStrategynewStrategy (TFile *file, int fileVersion)
 

Private Attributes

int fileVersion_
 
std::unique_ptr< internal::BMRStrategystrategy_
 

Detailed Description

Definition at line 70 of file BranchMapReader.h.

Constructor & Destructor Documentation

◆ BranchMapReader() [1/2]

BranchMapReader::BranchMapReader ( TFile *  file)

Definition at line 578 of file BranchMapReader.cc.

578  : fileVersion_(-1) {
579  if (nullptr == file) {
580  throw cms::Exception("NoFile") << "The TFile pointer is null";
581  }
583  }

References Exception, FrontierConditions_GlobalTag_cff::file, getFileVersion(), newStrategy(), and strategy_.

◆ BranchMapReader() [2/2]

fwlite::BranchMapReader::BranchMapReader ( )
inline

Definition at line 73 of file BranchMapReader.h.

73 : strategy_(nullptr), fileVersion_(0) {}

Member Function Documentation

◆ branchIDToBranch()

const edm::BranchDescription& fwlite::BranchMapReader::branchIDToBranch ( const edm::BranchID bid) const
inline

Definition at line 86 of file BranchMapReader.h.

86  {
87  return strategy_->branchIDToBranch(bid);
88  }

References strategy_.

Referenced by BareRootProductGetter::createNewBuffer().

◆ branchListIndexes()

const edm::BranchListIndexes& fwlite::BranchMapReader::branchListIndexes ( ) const
inline

Definition at line 105 of file BranchMapReader.h.

105  {
106  strategy_->updateMap();
107  return strategy_->branchListIndexes();
108  }

References strategy_.

◆ getBranchDescriptions()

std::vector< edm::BranchDescription > const & BranchMapReader::getBranchDescriptions ( )

Definition at line 641 of file BranchMapReader.cc.

641  {
642  return strategy_->getBranchDescriptions();
643  }

References strategy_.

Referenced by fwlite::Event::getBranchDescriptions().

◆ getEventEntry()

Long_t fwlite::BranchMapReader::getEventEntry ( ) const
inline

◆ getEventTree() [1/2]

TTree* fwlite::BranchMapReader::getEventTree ( )
inline

Definition at line 95 of file BranchMapReader.h.

95 { return strategy_->eventTree_; }

References strategy_.

◆ getEventTree() [2/2]

TTree const* fwlite::BranchMapReader::getEventTree ( ) const
inline

◆ getFile() [1/2]

TFile* fwlite::BranchMapReader::getFile ( )
inline

Definition at line 93 of file BranchMapReader.h.

93 { return strategy_->currentFile_; }

References strategy_.

◆ getFile() [2/2]

TFile const* fwlite::BranchMapReader::getFile ( ) const
inline

◆ getFileUUID()

TUUID fwlite::BranchMapReader::getFileUUID ( ) const
inline

Definition at line 100 of file BranchMapReader.h.

100 { return strategy_->fileUUID_; }

References strategy_.

◆ getFileVersion() [1/2]

int fwlite::BranchMapReader::getFileVersion ( ) const
inline

Definition at line 90 of file BranchMapReader.h.

90 { return fileVersion_; }

References fileVersion_.

Referenced by BranchMapReader(), and updateFile().

◆ getFileVersion() [2/2]

int BranchMapReader::getFileVersion ( TFile *  file)

Definition at line 589 of file BranchMapReader.cc.

589  {
590  TTree* metaDataTree = dynamic_cast<TTree*>(file->Get(edm::poolNames::metaDataTreeName().c_str()));
591  if (nullptr == metaDataTree) {
592  return 0;
593  }
594 
596  edm::FileFormatVersion* pV = &v;
597  TBranch* bVer = metaDataTree->GetBranch(edm::poolNames::fileFormatVersionBranchName().c_str());
598  bVer->SetAddress(&pV);
599  bVer->GetEntry(0);
600  fileVersion_ = v.value();
601  return v.value();
602  }

References FrontierConditions_GlobalTag_cff::file, edm::poolNames::fileFormatVersionBranchName(), fileVersion_, edm::poolNames::metaDataTreeName(), and findQualityFiles::v.

Referenced by fwlite::Event::Event().

◆ getLuminosityBlockEntry()

Long_t fwlite::BranchMapReader::getLuminosityBlockEntry ( ) const
inline

Definition at line 102 of file BranchMapReader.h.

102 { return strategy_->luminosityBlockEntry_; }

References strategy_.

◆ getLuminosityBlockTree() [1/2]

TTree* fwlite::BranchMapReader::getLuminosityBlockTree ( )
inline

Definition at line 97 of file BranchMapReader.h.

97 { return strategy_->luminosityBlockTree_; }

References strategy_.

◆ getLuminosityBlockTree() [2/2]

TTree const* fwlite::BranchMapReader::getLuminosityBlockTree ( ) const
inline

Definition at line 96 of file BranchMapReader.h.

96 { return strategy_->luminosityBlockTree_; }

References strategy_.

◆ getRunEntry()

Long_t fwlite::BranchMapReader::getRunEntry ( ) const
inline

Definition at line 103 of file BranchMapReader.h.

103 { return strategy_->runEntry_; }

References strategy_.

◆ getRunTree() [1/2]

TTree* fwlite::BranchMapReader::getRunTree ( )
inline

Definition at line 99 of file BranchMapReader.h.

99 { return strategy_->runTree_; }

References strategy_.

◆ getRunTree() [2/2]

TTree const* fwlite::BranchMapReader::getRunTree ( ) const
inline

Definition at line 98 of file BranchMapReader.h.

98 { return strategy_->runTree_; }

References strategy_.

◆ newStrategy()

std::unique_ptr< internal::BMRStrategy > BranchMapReader::newStrategy ( TFile *  file,
int  fileVersion 
)
private

Definition at line 645 of file BranchMapReader.cc.

645  {
646  std::unique_ptr<internal::BMRStrategy> s;
647 
648  if (fileVersion >= 17) {
649  s = std::make_unique<internal::BranchMapReaderStrategyV17>(file, fileVersion);
650  } else if (fileVersion >= 11) {
651  s = std::make_unique<internal::BranchMapReaderStrategyV11>(file, fileVersion);
652  } else if (fileVersion >= 8) {
653  s = std::make_unique<internal::BranchMapReaderStrategyV8>(file, fileVersion);
654  } else if (fileVersion >= 7) {
655  s = std::make_unique<internal::BranchMapReaderStrategyV7>(file, fileVersion);
656  } else {
657  s = std::make_unique<internal::BranchMapReaderStrategyV1>(file, fileVersion);
658  }
659  return s;
660  }

References FrontierConditions_GlobalTag_cff::file, and alignCSCRings::s.

Referenced by BranchMapReader(), and updateFile().

◆ productToBranch()

edm::BranchDescription const & BranchMapReader::productToBranch ( const edm::ProductID pid)

Definition at line 637 of file BranchMapReader.cc.

637  {
638  return strategy_->productToBranch(pid);
639  }

References strategy_.

◆ productToBranchID()

edm::BranchID fwlite::BranchMapReader::productToBranchID ( const edm::ProductID pid)
inline

◆ thinnedAssociationsHelper()

const edm::ThinnedAssociationsHelper& fwlite::BranchMapReader::thinnedAssociationsHelper ( ) const
inline

Definition at line 109 of file BranchMapReader.h.

109  {
110  return strategy_->thinnedAssociationsHelper();
111  }

References strategy_.

Referenced by BareRootProductGetter::getThinnedKeyFrom(), BareRootProductGetter::getThinnedProduct(), and BareRootProductGetter::getThinnedProducts().

◆ updateEvent()

bool BranchMapReader::updateEvent ( Long_t  eventEntry)

Definition at line 604 of file BranchMapReader.cc.

604 { return strategy_->updateEvent(newevent); }

References strategy_.

Referenced by fwlite::Event::Event(), BareRootProductGetter::getIt(), fwlite::Event::operator++(), fwlite::Event::to(), and fwlite::Event::toBegin().

◆ updateFile()

bool BranchMapReader::updateFile ( TFile *  file)

Definition at line 610 of file BranchMapReader.cc.

610  {
611  if (nullptr == strategy_.get()) {
613  return true;
614  }
615 
616  TFile* currentFile(strategy_->currentFile_);
617  bool isNew(file != currentFile);
618 
619  if (!isNew) {
620  //could still have a new TFile which just happens to share the same memory address as the previous file
621  //will assume that if the Event tree's address and UUID are the same as before then we do not have
622  // to treat this like a new file
623  TTree* eventTreeTemp = dynamic_cast<TTree*>(currentFile->Get(edm::poolNames::eventTreeName().c_str()));
624  isNew = eventTreeTemp != strategy_->eventTree_ || strategy_->fileUUID_ != currentFile->GetUUID();
625  }
626  if (isNew) {
627  int fileVersion = getFileVersion(file);
628  if (fileVersion != strategy_->fileVersion_) {
629  strategy_ = newStrategy(file, fileVersion);
630  } else {
631  strategy_->updateFile(file);
632  }
633  }
634  return isNew;
635  }

References edm::poolNames::eventTreeName(), FrontierConditions_GlobalTag_cff::file, getFileVersion(), newStrategy(), and strategy_.

Referenced by BareRootProductGetter::getIt().

◆ updateLuminosityBlock()

bool BranchMapReader::updateLuminosityBlock ( Long_t  luminosityBlockEntry)

Definition at line 606 of file BranchMapReader.cc.

606 { return strategy_->updateLuminosityBlock(newlumi); }

References strategy_.

◆ updateRun()

bool BranchMapReader::updateRun ( Long_t  runEntry)

Definition at line 608 of file BranchMapReader.cc.

608 { return strategy_->updateRun(newRun); }

References strategy_.

Member Data Documentation

◆ fileVersion_

int fwlite::BranchMapReader::fileVersion_
private

Definition at line 117 of file BranchMapReader.h.

Referenced by getFileVersion().

◆ strategy_

std::unique_ptr<internal::BMRStrategy> fwlite::BranchMapReader::strategy_
private
edm::poolNames::fileFormatVersionBranchName
std::string const & fileFormatVersionBranchName()
Definition: BranchType.cc:182
edm::poolNames::eventTreeName
std::string const & eventTreeName()
Definition: BranchType.cc:208
findQualityFiles.v
v
Definition: findQualityFiles.py:179
alignCSCRings.s
s
Definition: alignCSCRings.py:92
edm::FileFormatVersion
Definition: FileFormatVersion.h:7
FrontierConditions_GlobalTag_cff.file
file
Definition: FrontierConditions_GlobalTag_cff.py:13
fwlite::BranchMapReader::fileVersion_
int fileVersion_
Definition: BranchMapReader.h:117
fwlite::BranchMapReader::getFileVersion
int getFileVersion() const
Definition: BranchMapReader.h:90
edm::poolNames::metaDataTreeName
std::string const & metaDataTreeName()
Definition: BranchType.cc:152
Exception
Definition: hltDiff.cc:245
fwlite::BranchMapReader::newStrategy
std::unique_ptr< internal::BMRStrategy > newStrategy(TFile *file, int fileVersion)
Definition: BranchMapReader.cc:645
fwlite::BranchMapReader::strategy_
std::unique_ptr< internal::BMRStrategy > strategy_
Definition: BranchMapReader.h:116