#include <FWCore/Framework/interface/DataViewImpl.h>
Public Types | |
typedef std::vector< std::pair < EDProduct *, ConstBranchDescription const * > > | ProductPtrVec |
Public Member Functions | |
DataViewImpl (Principal &pcpl, ModuleDescription const &md, BranchType const &branchType) | |
template<typename PROD> | |
bool | get (SelectorBase const &, Handle< PROD > &result) const |
template<typename PROD> | |
bool | getByLabel (InputTag const &tag, Handle< PROD > &result) const |
same as above, but using the InputTag class | |
template<typename PROD> | |
bool | getByLabel (std::string const &label, std::string const &productInstanceName, Handle< PROD > &result) const |
template<typename PROD> | |
bool | getByLabel (std::string const &label, Handle< PROD > &result) const |
template<typename PROD> | |
bool | getByType (Handle< PROD > &result) const |
template<typename PROD> | |
void | getMany (SelectorBase const &, std::vector< Handle< PROD > > &results) const |
template<typename PROD> | |
void | getManyByType (std::vector< Handle< PROD > > &results) const |
DataViewImpl const & | me () const |
ProcessHistory const & | processHistory () const |
size_t | size () const |
~DataViewImpl () | |
Protected Types | |
typedef std::vector< BasicHandle > | BasicHandleVec |
Protected Member Functions | |
BasicHandle | get_ (TypeID const &tid, SelectorBase const &) const |
ConstBranchDescription const & | getBranchDescription (TypeID const &type, std::string const &productInstanceName) const |
BasicHandle | getByLabel_ (TypeID const &tid, std::string const &label, std::string const &productInstanceName, std::string const &processName) const |
BasicHandle | getByLabel_ (TypeID const &tid, std::string const &label, std::string const &productInstanceName) const |
BasicHandle | getByType_ (TypeID const &tid) const |
void | getMany_ (TypeID const &tid, SelectorBase const &sel, BasicHandleVec &results) const |
void | getManyByType_ (TypeID const &tid, BasicHandleVec &results) const |
int | getMatchingSequence_ (TypeID const &typeID, SelectorBase const &selector, BasicHandleVec &results, bool stopIfProcessHasMatch) const |
int | getMatchingSequenceByLabel_ (TypeID const &typeID, std::string const &label, std::string const &productInstanceName, std::string const &processName, BasicHandleVec &results, bool stopIfProcessHasMatch) const |
int | getMatchingSequenceByLabel_ (TypeID const &typeID, std::string const &label, std::string const &productInstanceName, BasicHandleVec &results, bool stopIfProcessHasMatch) const |
Principal const & | principal () const |
Principal & | principal () |
EDProductGetter const * | prodGetter () const |
ProductPtrVec const & | putProducts () const |
ProductPtrVec & | putProducts () |
ProductPtrVec const & | putProductsWithoutParents () const |
ProductPtrVec & | putProductsWithoutParents () |
Private Member Functions | |
DataViewImpl (DataViewImpl const &) | |
DataViewImpl const & | operator= (DataViewImpl const &) |
Private Attributes | |
BranchType const | branchType_ |
ModuleDescription const & | md_ |
Principal & | principal_ |
ProductPtrVec | putProducts_ |
ProductPtrVec | putProductsWithoutParents_ |
Definition at line 116 of file DataViewImpl.h.
typedef std::vector<BasicHandle> edm::DataViewImpl::BasicHandleVec [protected] |
Definition at line 178 of file DataViewImpl.h.
typedef std::vector<std::pair<EDProduct*, ConstBranchDescription const *> > edm::DataViewImpl::ProductPtrVec |
Definition at line 163 of file DataViewImpl.h.
DataViewImpl::DataViewImpl | ( | Principal & | pcpl, | |
ModuleDescription const & | md, | |||
BranchType const & | branchType | |||
) |
Definition at line 16 of file DataViewImpl.cc.
00018 : 00019 putProducts_(), 00020 principal_(pcpl), 00021 md_(md), 00022 branchType_(branchType) 00023 { }
DataViewImpl::~DataViewImpl | ( | ) |
Definition at line 29 of file DataViewImpl.cc.
References edm::for_all().
00029 { 00030 // anything left here must be the result of a failure 00031 // let's record them as failed attempts in the event principal 00032 for_all(putProducts_, deleter()); 00033 }
edm::DataViewImpl::DataViewImpl | ( | DataViewImpl const & | ) | [private] |
bool DataViewImpl::get | ( | SelectorBase const & | sel, | |
Handle< PROD > & | result | |||
) | const [inline] |
Reimplemented in edm::Event.
Definition at line 351 of file DataViewImpl.h.
References edm::Handle< T >::clear(), edm::convert_handle(), edm::BasicHandle::failedToGet(), and PROD.
00353 { 00354 result.clear(); 00355 BasicHandle bh = this->get_(TypeID(typeid(PROD)),sel); 00356 convert_handle(bh, result); // throws on conversion error 00357 if (bh.failedToGet()) { 00358 return false; 00359 } 00360 return true; 00361 }
BasicHandle DataViewImpl::get_ | ( | TypeID const & | tid, | |
SelectorBase const & | sel | |||
) | const [protected] |
Definition at line 41 of file DataViewImpl.cc.
00042 { 00043 return principal_.getBySelector(tid, sel); 00044 }
ConstBranchDescription const & DataViewImpl::getBranchDescription | ( | TypeID const & | type, | |
std::string const & | productInstanceName | |||
) | const [protected] |
Definition at line 139 of file DataViewImpl.cc.
References edm::TypeID::friendlyClassName(), edm::errors::InsertFailure, it, md_, edm::ModuleDescription::moduleLabel(), and edm::ModuleDescription::processName().
00140 { 00141 std::string friendlyClassName = type.friendlyClassName(); 00142 BranchKey bk(friendlyClassName, md_.moduleLabel(), productInstanceName, md_.processName()); 00143 ProductRegistry::ConstProductList const& pl = principal_.productRegistry().constProductList(); 00144 ProductRegistry::ConstProductList::const_iterator it = pl.find(bk); 00145 if (it == pl.end()) { 00146 throw edm::Exception(edm::errors::InsertFailure) 00147 << "Illegal attempt to 'put' an unregistered product.\n" 00148 << "No product is registered for\n" 00149 << " process name: '" << bk.processName_ << "'\n" 00150 << " module label: '" << bk.moduleLabel_ << "'\n" 00151 << " product friendly class name: '" << bk.friendlyClassName_ << "'\n" 00152 << " product instance name: '" << bk.productInstanceName_ << "'\n" 00153 00154 << "The ProductRegistry contains:\n" 00155 << principal_.productRegistry() 00156 << '\n'; 00157 } 00158 if(it->second.branchType() != branchType_) { 00159 throw edm::Exception(edm::errors::InsertFailure,"Not Registered") 00160 << "put: Problem found while adding product. " 00161 << "The product for (" 00162 << bk.friendlyClassName_ << "," 00163 << bk.moduleLabel_ << "," 00164 << bk.productInstanceName_ << "," 00165 << bk.processName_ 00166 << ")\n" 00167 << "is registered for a(n) " << it->second.branchType() 00168 << " instead of for a(n) " << branchType_ 00169 << ".\n"; 00170 } 00171 return it->second; 00172 }
bool DataViewImpl::getByLabel | ( | InputTag const & | tag, | |
Handle< PROD > & | result | |||
) | const [inline] |
same as above, but using the InputTag class
Reimplemented in edm::Event.
Definition at line 376 of file DataViewImpl.h.
References edm::Handle< T >::clear(), edm::convert_handle(), edm::BasicHandle::failedToGet(), edm::InputTag::instance(), edm::InputTag::label(), edm::InputTag::process(), and PROD.
00377 { 00378 result.clear(); 00379 if (tag.process().empty()) { 00380 return getByLabel(tag.label(), tag.instance(), result); 00381 } 00382 BasicHandle bh = this->getByLabel_(TypeID(typeid(PROD)), tag.label(), tag.instance(),tag.process()); 00383 convert_handle(bh, result); // throws on conversion error 00384 if (bh.failedToGet()) { 00385 return false; 00386 } 00387 return true; 00388 }
bool DataViewImpl::getByLabel | ( | std::string const & | label, | |
std::string const & | productInstanceName, | |||
Handle< PROD > & | result | |||
) | const [inline] |
Reimplemented in edm::Event.
Definition at line 393 of file DataViewImpl.h.
References edm::Handle< T >::clear(), edm::convert_handle(), edm::BasicHandle::failedToGet(), and PROD.
00396 { 00397 result.clear(); 00398 BasicHandle bh = this->getByLabel_(TypeID(typeid(PROD)), label, productInstanceName); 00399 convert_handle(bh, result); // throws on conversion error 00400 if (bh.failedToGet()) { 00401 return false; 00402 } 00403 return true; 00404 }
bool DataViewImpl::getByLabel | ( | std::string const & | label, | |
Handle< PROD > & | result | |||
) | const [inline] |
Reimplemented in edm::Event.
Definition at line 366 of file DataViewImpl.h.
References edm::Handle< T >::clear().
Referenced by AlpgenExtractor::beginRun(), LHEWriter::beginRun(), edm::MadGraphProducer::beginRun(), LHEProducer::beginRun(), and GenEventRunInfoProducer::produce().
00368 { 00369 result.clear(); 00370 return getByLabel(label, std::string(), result); 00371 }
BasicHandle DataViewImpl::getByLabel_ | ( | TypeID const & | tid, | |
std::string const & | label, | |||
std::string const & | productInstanceName, | |||
std::string const & | processName | |||
) | const [protected] |
Definition at line 63 of file DataViewImpl.cc.
00067 { 00068 return principal_.getByLabel(tid, label, productInstanceName, processName); 00069 }
BasicHandle DataViewImpl::getByLabel_ | ( | TypeID const & | tid, | |
std::string const & | label, | |||
std::string const & | productInstanceName | |||
) | const [protected] |
Definition at line 47 of file DataViewImpl.cc.
00050 { 00051 return principal_.getByLabel(tid, label, productInstanceName); 00052 }
Reimplemented in edm::Event.
Definition at line 444 of file DataViewImpl.h.
References edm::Handle< T >::clear(), edm::convert_handle(), edm::BasicHandle::failedToGet(), and PROD.
Referenced by EDMtoMEConverter::convert().
00445 { 00446 result.clear(); 00447 BasicHandle bh = this->getByType_(TypeID(typeid(PROD))); 00448 convert_handle(bh, result); // throws on conversion error 00449 if (bh.failedToGet()) { 00450 return false; 00451 } 00452 return true; 00453 }
BasicHandle DataViewImpl::getByType_ | ( | TypeID const & | tid | ) | const [protected] |
Definition at line 72 of file DataViewImpl.cc.
00073 { 00074 return principal_.getByType(tid); 00075 }
void DataViewImpl::getMany | ( | SelectorBase const & | sel, | |
std::vector< Handle< PROD > > & | results | |||
) | const [inline] |
Reimplemented in edm::Event.
Definition at line 409 of file DataViewImpl.h.
References edm::convert_handle(), end, it, PROD, edm::es::products(), HLT_VtxMuL3::result, and bookConverter::results.
00411 { 00412 BasicHandleVec bhv; 00413 this->getMany_(TypeID(typeid(PROD)), sel, bhv); 00414 00415 // Go through the returned handles; for each element, 00416 // 1. create a Handle<PROD> and 00417 // 00418 // This function presents an exception safety difficulty. If an 00419 // exception is thrown when converting a handle, the "got 00420 // products" record will be wrong. 00421 // 00422 // Since EDProducers are not allowed to use this function, 00423 // the problem does not seem too severe. 00424 // 00425 // Question: do we even need to keep track of the "got products" 00426 // for this function, since it is *not* to be used by EDProducers? 00427 std::vector<Handle<PROD> > products; 00428 00429 typename BasicHandleVec::const_iterator it = bhv.begin(); 00430 typename BasicHandleVec::const_iterator end = bhv.end(); 00431 00432 while (it != end) { 00433 Handle<PROD> result; 00434 convert_handle(*it, result); // throws on conversion error 00435 products.push_back(result); 00436 ++it; 00437 } 00438 results.swap(products); 00439 }
void DataViewImpl::getMany_ | ( | TypeID const & | tid, | |
SelectorBase const & | sel, | |||
BasicHandleVec & | results | |||
) | const [protected] |
Definition at line 55 of file DataViewImpl.cc.
00058 { 00059 principal_.getMany(tid, sel, results); 00060 }
void DataViewImpl::getManyByType | ( | std::vector< Handle< PROD > > & | results | ) | const [inline] |
Reimplemented in edm::Event.
Definition at line 458 of file DataViewImpl.h.
References edm::convert_handle(), end, it, PROD, edm::es::products(), HLT_VtxMuL3::result, and bookConverter::results.
Referenced by GlobalHitsProdHistStripper::endRun().
00459 { 00460 BasicHandleVec bhv; 00461 this->getManyByType_(TypeID(typeid(PROD)), bhv); 00462 00463 // Go through the returned handles; for each element, 00464 // 1. create a Handle<PROD> and 00465 // 00466 // This function presents an exception safety difficulty. If an 00467 // exception is thrown when converting a handle, the "got 00468 // products" record will be wrong. 00469 // 00470 // Since EDProducers are not allowed to use this function, 00471 // the problem does not seem too severe. 00472 // 00473 // Question: do we even need to keep track of the "got products" 00474 // for this function, since it is *not* to be used by EDProducers? 00475 std::vector<Handle<PROD> > products; 00476 00477 typename BasicHandleVec::const_iterator it = bhv.begin(); 00478 typename BasicHandleVec::const_iterator end = bhv.end(); 00479 00480 while (it != end) { 00481 Handle<PROD> result; 00482 convert_handle(*it, result); // throws on conversion error 00483 products.push_back(result); 00484 ++it; 00485 } 00486 results.swap(products); 00487 }
void DataViewImpl::getManyByType_ | ( | TypeID const & | tid, | |
BasicHandleVec & | results | |||
) | const [protected] |
Definition at line 78 of file DataViewImpl.cc.
00080 { 00081 principal_.getManyByType(tid, results); 00082 }
int DataViewImpl::getMatchingSequence_ | ( | TypeID const & | typeID, | |
SelectorBase const & | selector, | |||
BasicHandleVec & | results, | |||
bool | stopIfProcessHasMatch | |||
) | const [protected] |
Definition at line 85 of file DataViewImpl.cc.
00089 { 00090 return principal_.getMatchingSequence(typeID, 00091 selector, 00092 results, 00093 stopIfProcessHasMatch); 00094 }
int DataViewImpl::getMatchingSequenceByLabel_ | ( | TypeID const & | typeID, | |
std::string const & | label, | |||
std::string const & | productInstanceName, | |||
std::string const & | processName, | |||
BasicHandleVec & | results, | |||
bool | stopIfProcessHasMatch | |||
) | const [protected] |
Definition at line 114 of file DataViewImpl.cc.
References n, and EgammaValidation_Zee_cff::sel.
00120 { 00121 edm::Selector sel(edm::ModuleLabelSelector(label) && 00122 edm::ProductInstanceNameSelector(productInstanceName) && 00123 edm::ProcessNameSelector(processName) ); 00124 00125 int n = principal_.getMatchingSequence(typeID, 00126 sel, 00127 results, 00128 stopIfProcessHasMatch); 00129 return n; 00130 }
int DataViewImpl::getMatchingSequenceByLabel_ | ( | TypeID const & | typeID, | |
std::string const & | label, | |||
std::string const & | productInstanceName, | |||
BasicHandleVec & | results, | |||
bool | stopIfProcessHasMatch | |||
) | const [protected] |
Definition at line 97 of file DataViewImpl.cc.
References n, and EgammaValidation_Zee_cff::sel.
00102 { 00103 edm::Selector sel(edm::ModuleLabelSelector(label) && 00104 edm::ProductInstanceNameSelector(productInstanceName)); 00105 00106 int n = principal_.getMatchingSequence(typeID, 00107 sel, 00108 results, 00109 stopIfProcessHasMatch); 00110 return n; 00111 }
DataViewImpl const& edm::DataViewImpl::me | ( | ) | const [inline] |
DataViewImpl const& edm::DataViewImpl::operator= | ( | DataViewImpl const & | ) | [private] |
Principal const& edm::DataViewImpl::principal | ( | ) | const [inline, protected] |
Principal& edm::DataViewImpl::principal | ( | ) | [inline, protected] |
ProcessHistory const & DataViewImpl::processHistory | ( | ) | const |
Definition at line 133 of file DataViewImpl.cc.
Referenced by RawDataCollectorModule::produce().
00134 { 00135 return principal_.processHistory(); 00136 }
EDProductGetter const * DataViewImpl::prodGetter | ( | ) | const [protected] |
Definition at line 175 of file DataViewImpl.cc.
00175 { 00176 return principal_.prodGetter(); 00177 }
ProductPtrVec const& edm::DataViewImpl::putProducts | ( | ) | const [inline, protected] |
Definition at line 170 of file DataViewImpl.h.
References putProducts_.
00170 {return putProducts_;}
ProductPtrVec& edm::DataViewImpl::putProducts | ( | ) | [inline, protected] |
Definition at line 169 of file DataViewImpl.h.
References putProducts_.
00169 {return putProducts_;}
ProductPtrVec const& edm::DataViewImpl::putProductsWithoutParents | ( | ) | const [inline, protected] |
Definition at line 173 of file DataViewImpl.h.
References putProductsWithoutParents_.
00173 {return putProductsWithoutParents_;}
ProductPtrVec& edm::DataViewImpl::putProductsWithoutParents | ( | ) | [inline, protected] |
Definition at line 172 of file DataViewImpl.h.
References putProductsWithoutParents_.
00172 {return putProductsWithoutParents_;}
size_t DataViewImpl::size | ( | void | ) | const |
Definition at line 36 of file DataViewImpl.cc.
00036 { 00037 return putProducts_.size() + principal_.size(); 00038 }
BranchType const edm::DataViewImpl::branchType_ [private] |
Definition at line 266 of file DataViewImpl.h.
ModuleDescription const& edm::DataViewImpl::md_ [private] |
Definition at line 263 of file DataViewImpl.h.
Principal& edm::DataViewImpl::principal_ [private] |
ProductPtrVec edm::DataViewImpl::putProducts_ [private] |