#include <IOPool/Input/src/PoolSource.h>
Public Member Functions | |
PoolSource (ParameterSet const &pset, InputSourceDescription const &desc) | |
virtual | ~PoolSource () |
Private Types | |
typedef input::EntryNumber | EntryNumber |
typedef boost::shared_ptr < RootFile > | RootFileSharedPtr |
Private Member Functions | |
virtual void | closeFile_ () |
virtual void | dropUnwantedBranches_ (std::vector< std::string > const &wantedBranches) |
virtual void | endJob () |
virtual ItemType | getNextItemType () |
virtual std::auto_ptr < EventPrincipal > | readEvent_ () |
virtual boost::shared_ptr < FileBlock > | readFile_ () |
virtual std::auto_ptr < EventPrincipal > | readIt (EventID const &id) |
virtual boost::shared_ptr < LuminosityBlockPrincipal > | readLuminosityBlock_ () |
virtual void | readMany_ (int number, EventPrincipalVector &result, EventID const &id, unsigned int fileSeqNumber) |
virtual void | readMany_ (int number, EventPrincipalVector &result) |
virtual void | readManyRandom_ (int number, EventPrincipalVector &result, unsigned int &fileSeqNumber) |
virtual boost::shared_ptr < RunPrincipal > | readRun_ () |
virtual void | rewind_ () |
virtual void | skip (int offset) |
Private Attributes | |
boost::array< std::vector < BranchID >, NumBranchTypes > | branchIDsToReplace_ |
boost::scoped_ptr < RootInputFileSequence > | primaryFileSequence_ |
RootServiceChecker | rootServiceChecker_ |
boost::scoped_ptr < RootInputFileSequence > | secondaryFileSequence_ |
Definition at line 30 of file PoolSource.h.
typedef input::EntryNumber edm::PoolSource::EntryNumber [private] |
Definition at line 39 of file PoolSource.h.
typedef boost::shared_ptr<RootFile> edm::PoolSource::RootFileSharedPtr [private] |
Definition at line 38 of file PoolSource.h.
edm::PoolSource::PoolSource | ( | ParameterSet const & | pset, | |
InputSourceDescription const & | desc | |||
) | [explicit] |
Definition at line 50 of file PoolSource.cc.
References begin, branchIDsToReplace_, empty, end, i, edm::InEvent, edm::InLumi, edm::InRun, it, edm::NumBranchTypes, edm::InputSource::primary(), primaryFileSequence_, secondaryFileSequence_, and size.
00050 : 00051 VectorInputSource(pset, desc), 00052 rootServiceChecker_(), 00053 primaryFileSequence_(new RootInputFileSequence(pset, *this, catalog(), primary())), 00054 secondaryFileSequence_(catalog(1).empty() ? 0 : new RootInputFileSequence(pset, *this, catalog(1), false)), 00055 branchIDsToReplace_() { 00056 if (secondaryFileSequence_) { 00057 boost::array<std::set<BranchID>, NumBranchTypes> idsToReplace; 00058 ProductRegistry::ProductList const& secondary = secondaryFileSequence_->fileProductRegistry().productList(); 00059 ProductRegistry::ProductList const& primary = primaryFileSequence_->fileProductRegistry().productList(); 00060 typedef ProductRegistry::ProductList::const_iterator const_iterator; 00061 for (const_iterator it = secondary.begin(), itEnd = secondary.end(); it != itEnd; ++it) { 00062 if (it->second.present()) idsToReplace[it->second.branchType()].insert(it->second.branchID()); 00063 } 00064 for (const_iterator it = primary.begin(), itEnd = primary.end(); it != itEnd; ++it) { 00065 if (it->second.present()) idsToReplace[it->second.branchType()].erase(it->second.branchID()); 00066 } 00067 if (idsToReplace[InEvent].empty() && idsToReplace[InLumi].empty() && idsToReplace[InRun].empty()) { 00068 secondaryFileSequence_.reset(); 00069 } 00070 else { 00071 for (int i = InEvent; i < NumBranchTypes; ++i) { 00072 branchIDsToReplace_[i].reserve(idsToReplace[i].size()); 00073 for (std::set<BranchID>::const_iterator it = idsToReplace[i].begin(), itEnd = idsToReplace[i].end(); 00074 it != itEnd; ++it) { 00075 branchIDsToReplace_[i].push_back(*it); 00076 } 00077 } 00078 } 00079 } 00080 }
edm::PoolSource::~PoolSource | ( | ) | [virtual] |
void edm::PoolSource::closeFile_ | ( | ) | [private, virtual] |
Reimplemented from edm::InputSource.
Definition at line 100 of file PoolSource.cc.
References primaryFileSequence_.
00100 { 00101 primaryFileSequence_->closeFile_(); 00102 }
void edm::PoolSource::dropUnwantedBranches_ | ( | std::vector< std::string > const & | wantedBranches | ) | [private, virtual] |
Implements edm::VectorInputSource.
Definition at line 213 of file PoolSource.cc.
References edm::InputSource::primary(), primaryFileSequence_, and secondaryFileSequence_.
00213 { 00214 assert (!secondaryFileSequence_); 00215 assert (!primary()); 00216 primaryFileSequence_->dropUnwantedBranches_(wantedBranches); 00217 }
Reimplemented from edm::InputSource.
Definition at line 85 of file PoolSource.cc.
References primaryFileSequence_, and secondaryFileSequence_.
00085 { 00086 if (secondaryFileSequence_) secondaryFileSequence_->endJob(); 00087 primaryFileSequence_->endJob(); 00088 }
InputSource::ItemType edm::PoolSource::getNextItemType | ( | ) | [private, virtual] |
Implements edm::InputSource.
Definition at line 178 of file PoolSource.cc.
References primaryFileSequence_.
00178 { 00179 return primaryFileSequence_->getNextItemType(); 00180 }
std::auto_ptr< EventPrincipal > edm::PoolSource::readEvent_ | ( | ) | [private, virtual] |
Implements edm::InputSource.
Definition at line 142 of file PoolSource.cc.
References branchIDsToReplace_, edm::checkConsistency(), empty, edm::InEvent, edm::errors::MismatchedInputFiles, primaryFileSequence_, and secondaryFileSequence_.
00142 { 00143 if (secondaryFileSequence_ && !branchIDsToReplace_[InEvent].empty()) { 00144 std::auto_ptr<EventPrincipal> primaryPrincipal = primaryFileSequence_->readEvent_(); 00145 std::auto_ptr<EventPrincipal> secondaryPrincipal = secondaryFileSequence_->readIt(primaryPrincipal->id(), primaryPrincipal->luminosityBlock(), true); 00146 if (secondaryPrincipal.get() != 0) { 00147 checkConsistency(*primaryPrincipal, *secondaryPrincipal); 00148 primaryPrincipal->recombine(*secondaryPrincipal, branchIDsToReplace_[InEvent]); 00149 } else { 00150 throw edm::Exception(errors::MismatchedInputFiles, "PoolSource::readEvent_") << 00151 primaryPrincipal->id() << " is not found in the secondary input files\n"; 00152 } 00153 return primaryPrincipal; 00154 } 00155 EventSourceSentry(*this); 00156 return primaryFileSequence_->readEvent_(); 00157 }
boost::shared_ptr< FileBlock > edm::PoolSource::readFile_ | ( | ) | [private, virtual] |
Reimplemented from edm::InputSource.
Definition at line 91 of file PoolSource.cc.
References primaryFileSequence_, and secondaryFileSequence_.
00091 { 00092 if (secondaryFileSequence_) { 00093 boost::shared_ptr<FileBlock> fb = primaryFileSequence_->readFile_(); 00094 fb->setNotFastCopyable(); 00095 return fb; 00096 } 00097 return primaryFileSequence_->readFile_(); 00098 }
std::auto_ptr< EventPrincipal > edm::PoolSource::readIt | ( | EventID const & | id | ) | [private, virtual] |
Reimplemented from edm::InputSource.
Definition at line 160 of file PoolSource.cc.
References branchIDsToReplace_, edm::checkConsistency(), edm::InEvent, edm::errors::MismatchedInputFiles, primaryFileSequence_, and secondaryFileSequence_.
00160 { 00161 if (secondaryFileSequence_) { 00162 std::auto_ptr<EventPrincipal> primaryPrincipal = primaryFileSequence_->readIt(id); 00163 std::auto_ptr<EventPrincipal> secondaryPrincipal = secondaryFileSequence_->readIt(id, primaryPrincipal->luminosityBlock(), true); 00164 if (secondaryPrincipal.get() != 0) { 00165 checkConsistency(*primaryPrincipal, *secondaryPrincipal); 00166 primaryPrincipal->recombine(*secondaryPrincipal, branchIDsToReplace_[InEvent]); 00167 } else { 00168 throw edm::Exception(errors::MismatchedInputFiles, "PoolSource::readIt") << 00169 primaryPrincipal->id() << " is not found in the secondary input files\n"; 00170 } 00171 return primaryPrincipal; 00172 } 00173 EventSourceSentry(*this); 00174 return primaryFileSequence_->readIt(id); 00175 }
boost::shared_ptr< LuminosityBlockPrincipal > edm::PoolSource::readLuminosityBlock_ | ( | ) | [private, virtual] |
Implements edm::InputSource.
Definition at line 123 of file PoolSource.cc.
References branchIDsToReplace_, edm::checkConsistency(), empty, edm::InLumi, edm::errors::MismatchedInputFiles, primaryFileSequence_, and secondaryFileSequence_.
00123 { 00124 if (secondaryFileSequence_ && !branchIDsToReplace_[InLumi].empty()) { 00125 boost::shared_ptr<LuminosityBlockPrincipal> primaryPrincipal = primaryFileSequence_->readLuminosityBlock_(); 00126 boost::shared_ptr<LuminosityBlockPrincipal> secondaryPrincipal = secondaryFileSequence_->readIt(primaryPrincipal->id()); 00127 if (secondaryPrincipal.get() != 0) { 00128 checkConsistency(*primaryPrincipal, *secondaryPrincipal); 00129 primaryPrincipal->recombine(*secondaryPrincipal, branchIDsToReplace_[InLumi]); 00130 } else { 00131 throw edm::Exception(errors::MismatchedInputFiles, "PoolSource::readLuminosityBlock_") 00132 << " Run " << primaryPrincipal->run() 00133 << " LuminosityBlock " << primaryPrincipal->luminosityBlock() 00134 << " is not found in the secondary input files\n"; 00135 } 00136 return primaryPrincipal; 00137 } 00138 return primaryFileSequence_->readLuminosityBlock_(); 00139 }
void edm::PoolSource::readMany_ | ( | int | number, | |
EventPrincipalVector & | result, | |||
EventID const & | id, | |||
unsigned int | fileSeqNumber | |||
) | [private, virtual] |
Definition at line 201 of file PoolSource.cc.
References primaryFileSequence_, and secondaryFileSequence_.
00201 { 00202 assert (!secondaryFileSequence_); 00203 primaryFileSequence_->readMany_(number, result, id, fileSeqNumber); 00204 }
void edm::PoolSource::readMany_ | ( | int | number, | |
EventPrincipalVector & | result | |||
) | [private, virtual] |
Definition at line 195 of file PoolSource.cc.
References primaryFileSequence_, and secondaryFileSequence_.
00195 { 00196 assert (!secondaryFileSequence_); 00197 primaryFileSequence_->readMany_(number, result); 00198 }
void edm::PoolSource::readManyRandom_ | ( | int | number, | |
EventPrincipalVector & | result, | |||
unsigned int & | fileSeqNumber | |||
) | [private, virtual] |
Definition at line 207 of file PoolSource.cc.
References primaryFileSequence_, and secondaryFileSequence_.
00207 { 00208 assert (!secondaryFileSequence_); 00209 primaryFileSequence_->readManyRandom_(number, result, fileSeqNumber); 00210 }
boost::shared_ptr< RunPrincipal > edm::PoolSource::readRun_ | ( | ) | [private, virtual] |
Implements edm::InputSource.
Definition at line 105 of file PoolSource.cc.
References branchIDsToReplace_, edm::checkConsistency(), empty, edm::InRun, edm::errors::MismatchedInputFiles, primaryFileSequence_, and secondaryFileSequence_.
00105 { 00106 if (secondaryFileSequence_ && !branchIDsToReplace_[InRun].empty()) { 00107 boost::shared_ptr<RunPrincipal> primaryPrincipal = primaryFileSequence_->readRun_(); 00108 boost::shared_ptr<RunPrincipal> secondaryPrincipal = secondaryFileSequence_->readIt(primaryPrincipal->id()); 00109 if (secondaryPrincipal.get() != 0) { 00110 checkConsistency(*primaryPrincipal, *secondaryPrincipal); 00111 primaryPrincipal->recombine(*secondaryPrincipal, branchIDsToReplace_[InRun]); 00112 } else { 00113 throw edm::Exception(errors::MismatchedInputFiles, "PoolSource::readRun_") 00114 << " Run " << primaryPrincipal->run() 00115 << " is not found in the secondary input files\n"; 00116 } 00117 return primaryPrincipal; 00118 } 00119 return primaryFileSequence_->readRun_(); 00120 }
void edm::PoolSource::rewind_ | ( | ) | [private, virtual] |
Reimplemented from edm::InputSource.
Definition at line 184 of file PoolSource.cc.
References primaryFileSequence_.
00184 { 00185 primaryFileSequence_->rewind_(); 00186 }
Reimplemented from edm::InputSource.
Definition at line 190 of file PoolSource.cc.
References primaryFileSequence_.
00190 { 00191 primaryFileSequence_->skip(offset); 00192 }
boost::array<std::vector<BranchID>, NumBranchTypes> edm::PoolSource::branchIDsToReplace_ [private] |
Definition at line 58 of file PoolSource.h.
Referenced by PoolSource(), readEvent_(), readIt(), readLuminosityBlock_(), and readRun_().
boost::scoped_ptr<RootInputFileSequence> edm::PoolSource::primaryFileSequence_ [private] |
Definition at line 56 of file PoolSource.h.
Referenced by closeFile_(), dropUnwantedBranches_(), endJob(), getNextItemType(), PoolSource(), readEvent_(), readFile_(), readIt(), readLuminosityBlock_(), readMany_(), readManyRandom_(), readRun_(), rewind_(), and skip().
Definition at line 55 of file PoolSource.h.
boost::scoped_ptr<RootInputFileSequence> edm::PoolSource::secondaryFileSequence_ [private] |
Definition at line 57 of file PoolSource.h.
Referenced by dropUnwantedBranches_(), endJob(), PoolSource(), readEvent_(), readFile_(), readIt(), readLuminosityBlock_(), readMany_(), readManyRandom_(), and readRun_().