#include <DataFormats/FWLite/interface/ChainEvent.h>
Public Member Functions | |
bool | atEnd () const |
ChainEvent (const std::vector< std::string > &iFileNames) | |
const std::vector < edm::BranchDescription > & | getBranchDescriptions () const |
const std::string | getBranchNameFor (const std::type_info &, const char *, const char *, const char *) const |
void | getByLabel (const std::type_info &, const char *, const char *, const char *, void *) const |
This function should only be called by fwlite::Handle<>. | |
const std::vector< std::string > & | getProcessHistory () const |
edm::EventID | id () const |
bool | isValid () const |
operator bool () const | |
const ChainEvent & | operator++ () |
Long64_t | size () const |
const edm::Timestamp & | time () const |
const ChainEvent & | to (Long64_t iIndex) |
Go to the event at index iIndex. | |
const ChainEvent & | toBegin () |
Go to the very first Event. | |
virtual | ~ChainEvent () |
Static Public Member Functions | |
static void | throwProductNotFoundException (const std::type_info &, const char *, const char *, const char *) |
Private Member Functions | |
ChainEvent (const Event &) | |
void | findSizes () |
const ChainEvent & | operator= (const Event &) |
void | switchToFile (Long64_t) |
Private Attributes | |
std::vector< Long64_t > | accumulatedSize_ |
boost::shared_ptr< Event > | event_ |
Long64_t | eventIndex_ |
boost::shared_ptr< TFile > | file_ |
std::vector< std::string > | fileNames_ |
Definition at line 40 of file ChainEvent.h.
ChainEvent::ChainEvent | ( | const std::vector< std::string > & | iFileNames | ) |
Definition at line 34 of file ChainEvent.cc.
References accumulatedSize_, edm::poolNames::eventTreeName(), Exception, file_, it, switchToFile(), and tree.
00034 : 00035 fileNames_(iFileNames), 00036 file_(), 00037 event_(), 00038 eventIndex_(0), 00039 accumulatedSize_() 00040 { 00041 Long64_t summedSize=0; 00042 accumulatedSize_.reserve(iFileNames.size()); 00043 for(std::vector<std::string>::const_iterator it= iFileNames.begin(), 00044 itEnd = iFileNames.end(); 00045 it!=itEnd; 00046 ++it) { 00047 file_ = boost::shared_ptr<TFile>(TFile::Open(it->c_str())); 00048 TTree* tree = dynamic_cast<TTree*>(file_->Get(edm::poolNames::eventTreeName().c_str())); 00049 if(0==tree) { 00050 throw cms::Exception("NotEdmFile")<<"The file "<<*it<<" has no 'Events' TTree and therefore is not an EDM ROOT file"; 00051 } 00052 00053 summedSize += tree->GetEntries(); 00054 accumulatedSize_.push_back(summedSize); 00055 } 00056 switchToFile(0); 00057 }
ChainEvent::~ChainEvent | ( | ) | [virtual] |
fwlite::ChainEvent::ChainEvent | ( | const Event & | ) | [private] |
bool ChainEvent::atEnd | ( | ) | const |
Definition at line 201 of file ChainEvent.cc.
00202 { 00203 if (eventIndex_ == fileNames_.size()-1) { 00204 return event_->atEnd(); 00205 } 00206 return false; 00207 }
void fwlite::ChainEvent::findSizes | ( | ) | [private] |
const std::vector< edm::BranchDescription > & ChainEvent::getBranchDescriptions | ( | ) | const |
Definition at line 157 of file ChainEvent.cc.
00158 { 00159 return event_->getBranchDescriptions(); 00160 }
const std::string ChainEvent::getBranchNameFor | ( | const std::type_info & | iType, | |
const char * | iModule, | |||
const char * | iInstance, | |||
const char * | iProcess | |||
) | const |
Definition at line 148 of file ChainEvent.cc.
Referenced by fwlite::Handle< T >::getBranchNameFor().
00152 { 00153 return event_->getBranchNameFor(iType,iModule,iInstance,iProcess); 00154 }
void ChainEvent::getByLabel | ( | const std::type_info & | iType, | |
const char * | iModule, | |||
const char * | iInstance, | |||
const char * | iProcess, | |||
void * | iValue | |||
) | const |
This function should only be called by fwlite::Handle<>.
Definition at line 181 of file ChainEvent.cc.
Referenced by fwlite::Handle< T >::getByLabel().
00186 { 00187 event_->getByLabel(iType,iModule,iInstance,iProcess,iValue); 00188 }
const std::vector< std::string > & ChainEvent::getProcessHistory | ( | ) | const |
Definition at line 163 of file ChainEvent.cc.
00164 { 00165 return event_->getProcessHistory(); 00166 }
edm::EventID ChainEvent::id | ( | void | ) | const |
ChainEvent::operator bool | ( | ) | const |
const ChainEvent & ChainEvent::operator++ | ( | ) |
Definition at line 84 of file ChainEvent.cc.
00085 { 00086 if(eventIndex_ !=fileNames_.size()-1) { 00087 ++(*event_); 00088 if(event_->atEnd()) { 00089 switchToFile(++eventIndex_); 00090 } 00091 } else { 00092 if(*event_) { 00093 ++(*event_); 00094 } 00095 } 00096 return *this; 00097 }
const ChainEvent& fwlite::ChainEvent::operator= | ( | const Event & | ) | [private] |
Long64_t ChainEvent::size | ( | void | ) | const |
void ChainEvent::switchToFile | ( | Long64_t | iIndex | ) | [private] |
Definition at line 138 of file ChainEvent.cc.
Referenced by ChainEvent().
00139 { 00140 eventIndex_= iIndex; 00141 file_ = boost::shared_ptr<TFile>(TFile::Open(fileNames_[iIndex].c_str())); 00142 event_ = boost::shared_ptr<Event>( new Event(file_.get())); 00143 }
void ChainEvent::throwProductNotFoundException | ( | const std::type_info & | iType, | |
const char * | iModule, | |||
const char * | iInstance, | |||
const char * | iProcess | |||
) | [static] |
Definition at line 220 of file ChainEvent.cc.
00223 { 00224 Event::throwProductNotFoundException(iType,iModule,iInstance,iProcess); 00225 }
const edm::Timestamp & ChainEvent::time | ( | ) | const |
const ChainEvent & ChainEvent::to | ( | Long64_t | iIndex | ) |
Go to the event at index iIndex.
Definition at line 101 of file ChainEvent.cc.
00101 { 00102 if(iIndex > accumulatedSize_.back()) { 00103 //should throw exception 00104 return *this; 00105 } 00106 Long64_t offsetIndex = eventIndex_; 00107 bool incremented = false; 00108 while(iIndex > accumulatedSize_[offsetIndex] && offsetIndex != accumulatedSize_.size()) { 00109 ++offsetIndex; 00110 incremented = true; 00111 } 00112 if (incremented) { 00113 //we will have over shot 00114 --offsetIndex; 00115 } else { 00116 while(iIndex < accumulatedSize_[offsetIndex] && offsetIndex !=-1) { 00117 --offsetIndex; 00118 } 00119 } 00120 if(offsetIndex-1 != eventIndex_) { 00121 switchToFile(eventIndex_ = offsetIndex+1); 00122 } 00123 event_->to( iIndex - accumulatedSize_[offsetIndex]); 00124 return *this; 00125 }
const ChainEvent & ChainEvent::toBegin | ( | ) |
Go to the very first Event.
Definition at line 129 of file ChainEvent.cc.
00129 { 00130 if(eventIndex_ != 0) { 00131 switchToFile(0); 00132 } 00133 event_->toBegin(); 00134 return *this; 00135 }
std::vector<Long64_t> fwlite::ChainEvent::accumulatedSize_ [private] |
boost::shared_ptr<Event> fwlite::ChainEvent::event_ [private] |
Definition at line 93 of file ChainEvent.h.
Long64_t fwlite::ChainEvent::eventIndex_ [private] |
Definition at line 94 of file ChainEvent.h.
boost::shared_ptr<TFile> fwlite::ChainEvent::file_ [private] |
std::vector<std::string> fwlite::ChainEvent::fileNames_ [private] |
Definition at line 91 of file ChainEvent.h.