CMS 3D CMS Logo

Public Member Functions | Private Member Functions | Private Attributes

fwlite::BranchMapReader Class Reference

#include <BranchMapReader.h>

List of all members.

Public Member Functions

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

Private Member Functions

std::auto_ptr
< internal::BMRStrategy
newStrategy (TFile *file, int fileVersion)

Private Attributes

int fileVersion_
std::auto_ptr
< internal::BMRStrategy
strategy_

Detailed Description

Definition at line 62 of file BranchMapReader.h.


Constructor & Destructor Documentation

BranchMapReader::BranchMapReader ( TFile *  file)

Definition at line 531 of file BranchMapReader.cc.

References Exception, getFileVersion(), newStrategy(), and strategy_.

                                            :
    fileVersion_(-1) {
  if(0==file) {
     throw cms::Exception("NoFile")<<"The TFile pointer is null";
  }
  strategy_ = newStrategy(file, getFileVersion(file));
}
fwlite::BranchMapReader::BranchMapReader ( ) [inline]

Definition at line 65 of file BranchMapReader.h.


Member Function Documentation

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

Definition at line 603 of file BranchMapReader.cc.

References strategy_.

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

                                       {
  return strategy_->getBranchDescriptions();
}
Long_t fwlite::BranchMapReader::getEventEntry ( ) const [inline]
TTree* fwlite::BranchMapReader::getEventTree ( ) const [inline]
TFile* fwlite::BranchMapReader::getFile ( ) const [inline]
TUUID fwlite::BranchMapReader::getFileUUID ( ) const [inline]

Definition at line 84 of file BranchMapReader.h.

References strategy_.

{ return strategy_->fileUUID_; }
int BranchMapReader::getFileVersion ( TFile *  file)

Definition at line 543 of file BranchMapReader.cc.

References edm::poolNames::fileFormatVersionBranchName(), fileVersion_, edm::poolNames::metaDataTreeName(), v, and edm::FileFormatVersion::value().

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

                                               {
  TTree* metaDataTree = dynamic_cast<TTree*>(file->Get(edm::poolNames::metaDataTreeName().c_str()));
  if(0==metaDataTree) {
    return 0;
  }

  edm::FileFormatVersion v;
  edm::FileFormatVersion* pV=&v;
  TBranch* bVer = metaDataTree->GetBranch(edm::poolNames::fileFormatVersionBranchName().c_str());
  bVer->SetAddress(&pV);
  bVer->GetEntry(0);
  fileVersion_ = v.value();
  return v.value();
}
int fwlite::BranchMapReader::getFileVersion ( ) const [inline]

Definition at line 78 of file BranchMapReader.h.

References fileVersion_.

Referenced by BranchMapReader(), and updateFile().

{ return  fileVersion_;}
Long_t fwlite::BranchMapReader::getLuminosityBlockEntry ( ) const [inline]

Definition at line 86 of file BranchMapReader.h.

References strategy_.

{ return strategy_->luminosityBlockEntry_; }
TTree* fwlite::BranchMapReader::getLuminosityBlockTree ( ) const [inline]

Definition at line 82 of file BranchMapReader.h.

References strategy_.

{ return strategy_->luminosityBlockTree_; }
Long_t fwlite::BranchMapReader::getRunEntry ( ) const [inline]

Definition at line 87 of file BranchMapReader.h.

References strategy_.

{ return strategy_->runEntry_; }
TTree* fwlite::BranchMapReader::getRunTree ( ) const [inline]

Definition at line 83 of file BranchMapReader.h.

References strategy_.

{ return strategy_->runTree_; }
std::auto_ptr< internal::BMRStrategy > BranchMapReader::newStrategy ( TFile *  file,
int  fileVersion 
) [private]

Definition at line 609 of file BranchMapReader.cc.

References alignCSCRings::s.

Referenced by BranchMapReader(), and updateFile().

                                                         {
  std::auto_ptr<internal::BMRStrategy> s;

  if(fileVersion >= 17) {
    s = std::auto_ptr<internal::BMRStrategy>(new internal::BranchMapReaderStrategyV17(file, fileVersion));
  } else if(fileVersion >= 11) {
    s = std::auto_ptr<internal::BMRStrategy>(new internal::BranchMapReaderStrategyV11(file, fileVersion));
  } else if(fileVersion >= 8) {
    s = std::auto_ptr<internal::BMRStrategy>(new internal::BranchMapReaderStrategyV8(file, fileVersion));
  } else if(fileVersion >= 7) {
    s = std::auto_ptr<internal::BMRStrategy>(new internal::BranchMapReaderStrategyV7(file, fileVersion));
  } else {
    s = std::auto_ptr<internal::BMRStrategy>(new internal::BranchMapReaderStrategyV1(file, fileVersion));
  }
  return s;
}
edm::BranchDescription const & BranchMapReader::productToBranch ( const edm::ProductID pid)

Definition at line 598 of file BranchMapReader.cc.

References strategy_.

Referenced by BareRootProductGetter::createNewBuffer(), and BareRootProductGetter::getIt().

                                                        {
  return strategy_->productToBranch(pid);
}
bool BranchMapReader::updateEvent ( Long_t  eventEntry)

Definition at line 558 of file BranchMapReader.cc.

References strategy_.

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

                                                 {
  return strategy_->updateEvent(newevent);
}
bool BranchMapReader::updateFile ( TFile *  file)

Definition at line 570 of file BranchMapReader.cc.

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

Referenced by BareRootProductGetter::getIt().

                                            {
  if(0 == strategy_.get()) {
    strategy_ = newStrategy(file, getFileVersion(file));
    return true;
  }

  TFile* currentFile(strategy_->currentFile_);
  bool isNew(file != currentFile);

  if(!isNew) {
    //could still have a new TFile which just happens to share the same memory address as the previous file
    //will assume that if the Event tree's address and UUID are the same as before then we do not have
    // to treat this like a new file
    TTree* eventTreeTemp = dynamic_cast<TTree*>(currentFile->Get(edm::poolNames::eventTreeName().c_str()));
    isNew = eventTreeTemp != strategy_->eventTree_ || strategy_->fileUUID_ != currentFile->GetUUID();
  }
  if(isNew) {
    int fileVersion = getFileVersion(file);
    if(fileVersion != strategy_->fileVersion_) {
      strategy_ = newStrategy(file, fileVersion);
    } else {
      strategy_->updateFile(file);
    }
  }
  return isNew;
}
bool BranchMapReader::updateLuminosityBlock ( Long_t  luminosityBlockEntry)

Definition at line 562 of file BranchMapReader.cc.

References strategy_.

                                                          {
  return strategy_->updateLuminosityBlock(newlumi);
}
bool BranchMapReader::updateRun ( Long_t  runEntry)

Definition at line 566 of file BranchMapReader.cc.

References strategy_.

                                             {
  return strategy_->updateRun(newRun);
}

Member Data Documentation

Definition at line 94 of file BranchMapReader.h.

Referenced by getFileVersion().