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 (TFile *file)
 
 BranchMapReader ()
 
const std::vector< edm::BranchDescription > & getBranchDescriptions ()
 
Long_t getEventEntry () const
 
TTree const * getEventTree () const
 
TTree * getEventTree ()
 
TFile const * getFile () const
 
TFile * getFile ()
 
TUUID getFileUUID () const
 
int getFileVersion (TFile *file)
 
int getFileVersion () const
 
Long_t getLuminosityBlockEntry () const
 
TTree const * getLuminosityBlockTree () const
 
TTree * getLuminosityBlockTree ()
 
Long_t getRunEntry () const
 
TTree const * getRunTree () const
 
TTree * getRunTree ()
 
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.

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

578  : fileVersion_(-1) {
579  if (nullptr == file) {
580  throw cms::Exception("NoFile") << "The TFile pointer is null";
581  }
583  }
std::unique_ptr< internal::BMRStrategy > newStrategy(TFile *file, int fileVersion)
std::unique_ptr< internal::BMRStrategy > strategy_

◆ BranchMapReader() [2/2]

fwlite::BranchMapReader::BranchMapReader ( )
inline

Definition at line 73 of file BranchMapReader.h.

73 : strategy_(nullptr), fileVersion_(0) {}
std::unique_ptr< internal::BMRStrategy > strategy_

Member Function Documentation

◆ branchIDToBranch()

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

Definition at line 86 of file BranchMapReader.h.

References strategy_.

Referenced by BareRootProductGetterBase::createNewBuffer().

86  {
87  return strategy_->branchIDToBranch(bid);
88  }
std::unique_ptr< internal::BMRStrategy > strategy_

◆ branchListIndexes()

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

Definition at line 105 of file BranchMapReader.h.

References strategy_.

105  {
106  strategy_->updateMap();
107  return strategy_->branchListIndexes();
108  }
std::unique_ptr< internal::BMRStrategy > strategy_

◆ getBranchDescriptions()

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

Definition at line 644 of file BranchMapReader.cc.

References strategy_.

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

644  {
645  return strategy_->getBranchDescriptions();
646  }
std::unique_ptr< internal::BMRStrategy > strategy_

◆ getEventEntry()

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

◆ getEventTree() [1/2]

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

◆ getEventTree() [2/2]

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

Definition at line 95 of file BranchMapReader.h.

References strategy_.

95 { return strategy_->eventTree_; }
std::unique_ptr< internal::BMRStrategy > strategy_

◆ getFile() [1/2]

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

◆ getFile() [2/2]

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

Definition at line 93 of file BranchMapReader.h.

References strategy_.

93 { return strategy_->currentFile_; }
std::unique_ptr< internal::BMRStrategy > strategy_

◆ getFileUUID()

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

Definition at line 100 of file BranchMapReader.h.

References strategy_.

100 { return strategy_->fileUUID_; }
std::unique_ptr< internal::BMRStrategy > strategy_

◆ getFileVersion() [1/2]

int BranchMapReader::getFileVersion ( TFile *  file)

Definition at line 589 of file BranchMapReader.cc.

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

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

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  if (nullptr == bVer) {
599  return 0;
600  }
601  bVer->SetAddress(&pV);
602  bVer->GetEntry(0);
603  fileVersion_ = v.value();
604  return v.value();
605  }
std::string const & metaDataTreeName()
Definition: BranchType.cc:159
std::string const & fileFormatVersionBranchName()
Definition: BranchType.cc:189

◆ getFileVersion() [2/2]

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

Definition at line 90 of file BranchMapReader.h.

References fileVersion_.

Referenced by BranchMapReader(), and updateFile().

◆ getLuminosityBlockEntry()

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

Definition at line 102 of file BranchMapReader.h.

References strategy_.

102 { return strategy_->luminosityBlockEntry_; }
std::unique_ptr< internal::BMRStrategy > strategy_

◆ getLuminosityBlockTree() [1/2]

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

Definition at line 96 of file BranchMapReader.h.

References strategy_.

96 { return strategy_->luminosityBlockTree_; }
std::unique_ptr< internal::BMRStrategy > strategy_

◆ getLuminosityBlockTree() [2/2]

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

Definition at line 97 of file BranchMapReader.h.

References strategy_.

97 { return strategy_->luminosityBlockTree_; }
std::unique_ptr< internal::BMRStrategy > strategy_

◆ getRunEntry()

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

Definition at line 103 of file BranchMapReader.h.

References strategy_.

103 { return strategy_->runEntry_; }
std::unique_ptr< internal::BMRStrategy > strategy_

◆ getRunTree() [1/2]

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

Definition at line 98 of file BranchMapReader.h.

References strategy_.

98 { return strategy_->runTree_; }
std::unique_ptr< internal::BMRStrategy > strategy_

◆ getRunTree() [2/2]

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

Definition at line 99 of file BranchMapReader.h.

References strategy_.

99 { return strategy_->runTree_; }
std::unique_ptr< internal::BMRStrategy > strategy_

◆ newStrategy()

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

Definition at line 648 of file BranchMapReader.cc.

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

Referenced by BranchMapReader(), and updateFile().

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

◆ productToBranch()

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

Definition at line 640 of file BranchMapReader.cc.

References strategy_.

640  {
641  return strategy_->productToBranch(pid);
642  }
std::unique_ptr< internal::BMRStrategy > 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.

References strategy_.

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

109  {
110  return strategy_->thinnedAssociationsHelper();
111  }
std::unique_ptr< internal::BMRStrategy > strategy_

◆ updateEvent()

bool BranchMapReader::updateEvent ( Long_t  eventEntry)

Definition at line 607 of file BranchMapReader.cc.

References strategy_.

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

607 { return strategy_->updateEvent(newevent); }
std::unique_ptr< internal::BMRStrategy > strategy_

◆ updateFile()

bool BranchMapReader::updateFile ( TFile *  file)

Definition at line 613 of file BranchMapReader.cc.

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

Referenced by BareRootProductGetterBase::getIt().

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

◆ updateLuminosityBlock()

bool BranchMapReader::updateLuminosityBlock ( Long_t  luminosityBlockEntry)

Definition at line 609 of file BranchMapReader.cc.

References strategy_.

609 { return strategy_->updateLuminosityBlock(newlumi); }
std::unique_ptr< internal::BMRStrategy > strategy_

◆ updateRun()

bool BranchMapReader::updateRun ( Long_t  runEntry)

Definition at line 611 of file BranchMapReader.cc.

References strategy_.

611 { return strategy_->updateRun(newRun); }
std::unique_ptr< internal::BMRStrategy > 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