72 TFile* currentFile =
dynamic_cast<TFile*
>(gROOT->GetListOfFiles()->Last());
73 if (
nullptr == currentFile) {
74 throw cms::Exception(
"FileNotFound") <<
"unable to find the TFile '" << gROOT->GetListOfFiles()->Last() <<
"'\n" 75 <<
"retrieved by calling 'gROOT->GetListOfFiles()->Last()'\n" 76 <<
"Please check the list of files.";
83 if (
nullptr == eventTree) {
87 <<
"'\n Please check that the file is a standard CMS ROOT format.\n" 88 <<
"If the above is not the file you expect then please open your data file after all other files.";
90 Long_t eventEntry = eventTree->GetReadEntry();
95 <<
"please call GetEntry for the 'Events' TTree for each event in order to make edm::Ref's work." 96 <<
"\n Also be sure to call 'SetAddress' for all Branches after calling the GetEntry.";
101 return getIt(branchID, eventEntry);
106 IdToBuffers::iterator itBuffer =
idToBuffers_.find(branchID);
112 if (
nullptr == buffer) {
116 buffer = &(itBuffer->second);
118 if (
nullptr == buffer) {
119 throw cms::Exception(
"NullBuffer") <<
"Found a null buffer which is supposed to hold the data item." 120 <<
"\n Please contact developers since this message should not happen.";
122 if (
nullptr == buffer->
branch_) {
123 throw cms::Exception(
"NullBranch") <<
"The TBranch which should hold the data item is null." 124 <<
"\n Please contact the developers since this message should not happen.";
131 void* address = buffer->
class_->New();
133 static TClass
const* edproductTClass = TClass::GetClass(
typeid(
edm::WrapperBase));
137 if (
nullptr == prod) {
139 <<
"' to a edm::WrapperBase." 140 <<
"Please contact developers since something is very wrong.";
143 buffer->
product_ = std::shared_ptr<edm::WrapperBase const>(
prod);
147 buffer->
branch_->SetAddress(address);
149 buffer->
branch_->GetEntry(eventEntry);
154 <<
"Calling GetEntry with index " << eventEntry <<
"for branch " << buffer->
branch_->GetName() <<
" failed.";
168 for (
auto associatedBranches = thinnedAssociationsHelper.
parentBegin(parent),
169 iEnd = thinnedAssociationsHelper.
parentEnd(parent);
170 associatedBranches != iEnd;
171 ++associatedBranches) {
174 if (thinnedAssociation ==
nullptr)
181 unsigned int thinnedIndex = 0;
190 if (thinnedCollection ==
nullptr) {
194 if (thinnedFromRecursiveCall !=
nullptr) {
196 return thinnedFromRecursiveCall;
202 return thinnedCollection;
208 std::vector<edm::WrapperBase const*>& foundContainers,
209 std::vector<unsigned int>&
keys)
const {
217 for (
auto associatedBranches = thinnedAssociationsHelper.
parentBegin(parent),
218 iEnd = thinnedAssociationsHelper.
parentEnd(parent);
219 associatedBranches != iEnd;
220 ++associatedBranches) {
223 if (thinnedAssociation ==
nullptr)
230 unsigned int nKeys = keys.size();
232 std::vector<unsigned int> thinnedIndexes(nKeys, doNotLookForThisIndex);
234 for (
unsigned k = 0;
k < nKeys; ++
k) {
236 if (foundContainers[
k] !=
nullptr)
239 if (keys[
k] == doNotLookForThisIndex)
256 if (thinnedCollection ==
nullptr) {
260 for (
unsigned k = 0;
k < nKeys; ++
k) {
261 if (foundContainers[
k] ==
nullptr)
263 if (thinnedIndexes[
k] == doNotLookForThisIndex)
265 keys[
k] = thinnedIndexes[
k];
268 for (
unsigned k = 0;
k < nKeys; ++
k) {
269 if (thinnedIndexes[
k] == doNotLookForThisIndex)
271 keys[
k] = thinnedIndexes[
k];
272 foundContainers[
k] = thinnedCollection;
283 if (
nullptr == branch) {
290 if (!
bool(classType)) {
291 throw cms::Exception(
"MissingDictionary") <<
"could not find dictionary for type '" << fullName <<
"'" 292 <<
"\n Please make sure all the necessary libraries are available.";
296 TClass* rootClassType = TClass::GetClass(classType.typeInfo());
297 if (
nullptr == rootClassType) {
298 throw cms::Exception(
"MissingRootDictionary") <<
"could not find a ROOT dictionary for type '" << fullName <<
"'" 299 <<
"\n Please make sure all the necessary libraries are available.";
302 void* address = rootClassType->New();
304 static TClass
const* edproductTClass = TClass::GetClass(
typeid(
edm::WrapperBase));
306 static_cast<edm::WrapperBase const*
>(rootClassType->DynamicCast(edproductTClass, address,
true));
307 if (
nullptr == prod) {
308 throw cms::Exception(
"FailedConversion") <<
"failed to convert a '" << fullName <<
"' to a edm::WrapperBase." 309 <<
"Please contact developers since something is very wrong.";
314 Buffer b(prod, branch, address, rootClassType);
320 branch->SetAddress(address);
326 Long_t eventEntry)
const {
328 if (wrapperBase ==
nullptr) {
330 <<
"BareRootProductGetter::getThinnedAssociation, product ThinnedAssociation not found.\n";
334 <<
"BareRootProductGetter::getThinnedAssociation, product has wrong type, not a ThinnedAssociation.\n";
340 return thinnedAssociation;
std::string const & branchName() const
~BareRootProductGetter() override
std::type_info const & dynamicTypeInfo() const
edm::propagate_const< TClass * > class_
bool updateEvent(Long_t eventEntry)
TFile const * getFile() const
bool updateFile(TFile *file)
edm::WrapperBase const * getIt(edm::ProductID const &) const override
const edm::BranchDescription & branchIDToBranch(const edm::BranchID &bid) const
static TypeWithDict byName(std::string const &name)
std::vector< ThinnedAssociationBranches >::const_iterator parentEnd(BranchID const &) const
std::string const & className() const
edm::ThinnedAssociation const * getThinnedAssociation(edm::BranchID const &branchID, Long_t eventEntry) const
void getThinnedProducts(edm::ProductID const &, std::vector< edm::WrapperBase const * > &foundContainers, std::vector< unsigned int > &keys) const override
TTree const * getEventTree() const
ProductID const & thinnedCollectionID() const
const edm::ThinnedAssociationsHelper & thinnedAssociationsHelper() const
std::string wrappedClassName(std::string const &iFullName)
edm::propagate_const< TBranch * > branch_
std::vector< ThinnedAssociationBranches >::const_iterator parentBegin(BranchID const &) const
Buffer * createNewBuffer(edm::BranchID const &) const
edm::WrapperBase const * getThinnedProduct(edm::ProductID const &, unsigned int &key) const override
std::string const & eventTreeName()
fwlite::BranchMapReader branchMap_
ProductID const & parentCollectionID() const
bool hasParentIndex(unsigned int parentIndex, unsigned int &thinnedIndex) const
std::shared_ptr< edm::WrapperBase const > product_
edm::BranchID productToBranchID(const edm::ProductID &pid)
static HepMC::HEPEVT_Wrapper wrapper