|
|
Go to the documentation of this file.
73 TFile* currentFile = dynamic_cast<TFile*>(gROOT->GetListOfFiles()->Last());
74 if (
nullptr == currentFile) {
75 throw cms::Exception(
"FileNotFound") <<
"unable to find the TFile '" << gROOT->GetListOfFiles()->Last() <<
"'\n"
76 <<
"retrieved by calling 'gROOT->GetListOfFiles()->Last()'\n"
77 <<
"Please check the list of files.";
84 if (
nullptr == eventTree) {
88 <<
"'\n Please check that the file is a standard CMS ROOT format.\n"
89 <<
"If the above is not the file you expect then please open your data file after all other files.";
91 Long_t eventEntry = eventTree->GetReadEntry();
96 <<
"please call GetEntry for the 'Events' TTree for each event in order to make edm::Ref's work."
97 <<
"\n Also be sure to call 'SetAddress' for all Branches after calling the GetEntry.";
102 return getIt(branchID, eventEntry);
107 IdToBuffers::iterator itBuffer =
idToBuffers_.find(branchID);
117 buffer = &(itBuffer->second);
120 throw cms::Exception(
"NullBuffer") <<
"Found a null buffer which is supposed to hold the data item."
121 <<
"\n Please contact developers since this message should not happen.";
123 if (
nullptr ==
buffer->branch_) {
124 throw cms::Exception(
"NullBranch") <<
"The TBranch which should hold the data item is null."
125 <<
"\n Please contact the developers since this message should not happen.";
127 if (
buffer->eventEntry_ != eventEntry) {
132 void* address =
buffer->class_->New();
134 static TClass
const* edproductTClass = TClass::GetClass(
typeid(
edm::WrapperBase));
136 static_cast<edm::WrapperBase const*>(
buffer->class_->DynamicCast(edproductTClass, address,
true));
138 if (
nullptr ==
prod) {
140 <<
"' to a edm::WrapperBase."
141 <<
"Please contact developers since something is very wrong.";
143 buffer->address_ = address;
144 buffer->product_ = std::shared_ptr<edm::WrapperBase const>(
prod);
147 address = &(
buffer->address_);
148 buffer->branch_->SetAddress(address);
150 buffer->branch_->GetEntry(eventEntry);
151 buffer->eventEntry_ = eventEntry;
155 <<
"Calling GetEntry with index " << eventEntry <<
"for branch " <<
buffer->branch_->GetName() <<
" failed.";
158 return buffer->product_.get();
174 std::vector<edm::WrapperBase const*>& foundContainers,
175 std::vector<unsigned int>&
keys)
const {
193 return std::monostate{};
196 return std::monostate{};
206 if (
auto factory = std::get_if<edm::detail::GetThinnedKeyFromExceptionFactory>(&
ret)) {
207 return [
func = *factory]() {
209 ex.addContext(
"Calling BareRootProductGetter::getThinnedKeyFrom()");
216 ex.
addContext(
"Calling BareRootProductGetter::getThinnedKeyFrom()");
233 if (!
bool(classType)) {
235 <<
"\n Please make sure all the necessary libraries are available.";
239 TClass* rootClassType = TClass::GetClass(classType.typeInfo());
240 if (
nullptr == rootClassType) {
241 throw cms::Exception(
"MissingRootDictionary") <<
"could not find a ROOT dictionary for type '" <<
fullName <<
"'"
242 <<
"\n Please make sure all the necessary libraries are available.";
245 void* address = rootClassType->New();
247 static TClass
const* edproductTClass = TClass::GetClass(
typeid(
edm::WrapperBase));
249 static_cast<edm::WrapperBase const*>(rootClassType->DynamicCast(edproductTClass, address,
true));
250 if (
nullptr ==
prod) {
251 throw cms::Exception(
"FailedConversion") <<
"failed to convert a '" <<
fullName <<
"' to a edm::WrapperBase."
252 <<
"Please contact developers since something is very wrong.";
263 branch->SetAddress(address);
269 Long_t eventEntry)
const {
271 if (wrapperBase ==
nullptr) {
273 <<
"BareRootProductGetter::getThinnedAssociation, product ThinnedAssociation not found.\n";
277 <<
"BareRootProductGetter::getThinnedAssociation, product has wrong type, not a ThinnedAssociation.\n";
283 return thinnedAssociation;
std::optional< std::tuple< WrapperBase const *, unsigned int > > getThinnedProduct(ProductID const &pid, unsigned int key, ThinnedAssociationsHelper const &thinnedAssociationsHelper, F1 pidToBid, F2 getThinnedAssociation, F3 getByProductID)
ret
prodAgent to be discontinued
static TypeWithDict byName(std::string const &name)
std::string const & eventTreeName()
void addContext(std::string const &context)
~BareRootProductGetter() override
void getThinnedProducts(edm::ProductID const &, std::vector< edm::WrapperBase const * > &foundContainers, std::vector< unsigned int > &keys) const override
edm::OptionalThinnedKey getThinnedKeyFrom(edm::ProductID const &parent, unsigned int key, edm::ProductID const &thinned) const override
std::optional< std::tuple< edm::WrapperBase const *, unsigned int > > getThinnedProduct(edm::ProductID const &, unsigned int key) const override
const edm::BranchDescription & branchIDToBranch(const edm::BranchID &bid) const
static HepMC::HEPEVT_Wrapper wrapper
edm::BranchID productToBranchID(const edm::ProductID &pid)
TTree const * getEventTree() const
bool updateEvent(Long_t eventEntry)
bool updateFile(TFile *file)
std::variant< unsigned int, GetThinnedKeyFromExceptionFactory, std::monostate > getThinnedKeyFrom_implementation(ProductID const &parentID, BranchID const &parent, unsigned int key, ProductID const &thinnedID, BranchID thinned, ThinnedAssociationsHelper const &thinnedAssociationsHelper, F &&getThinnedAssociation)
edm::ThinnedAssociation const * getThinnedAssociation(edm::BranchID const &branchID, Long_t eventEntry) const
fwlite::BranchMapReader branchMap_
const edm::ThinnedAssociationsHelper & thinnedAssociationsHelper() const
std::type_info const & dynamicTypeInfo() const
edm::WrapperBase const * getIt(edm::ProductID const &) const override
Buffer * createNewBuffer(edm::BranchID const &) const
std::string const & branchName() const
std::string wrappedClassName(std::string const &iFullName)
std::variant< unsigned int, detail::GetThinnedKeyFromExceptionFactory, std::monostate > OptionalThinnedKey
TFile const * getFile() const
std::string const & className() const
void getThinnedProducts(ProductID const &pid, ThinnedAssociationsHelper const &thinnedAssociationsHelper, F1 pidToBid, F2 getThinnedAssociation, F3 getByProductID, std::vector< WrapperBase const * > &foundContainers, std::vector< unsigned int > &keys)