@@ -114,10 +114,13 @@ void ClusterNativeHelper::Reader::init(const char* filename, const char* treenam
114114 LOG (ERROR) << " can not find tree " << mTreeName << " in file " << filename;
115115 return ;
116116 }
117+
118+ const bool singleBranch = mTree ->GetBranch (mDataBranchName .data ());
119+
117120 size_t nofDataBranches = 0 ;
118121 size_t nofMCBranches = 0 ;
119122 for (size_t sector = 0 ; sector < NSectors; ++sector) {
120- auto branchname = mDataBranchName + " _" + std::to_string (sector);
123+ auto branchname = singleBranch ? mDataBranchName : mDataBranchName + " _" + std::to_string (sector);
121124 TBranch* branch = mTree ->GetBranch (branchname.c_str ());
122125 if (branch) {
123126 TBranch* sizebranch = mTree ->GetBranch ((branchname + " Size" ).c_str ());
@@ -129,13 +132,16 @@ void ClusterNativeHelper::Reader::init(const char* filename, const char* treenam
129132 LOG (ERROR) << " can not find corresponding 'Size' branch for data branch " << branchname << " , skipping it" ;
130133 }
131134 }
132- branchname = mMCBranchName + " _" + std::to_string (sector);
135+ branchname = singleBranch ? mMCBranchName : mMCBranchName + " _" + std::to_string (sector);
133136 branch = mTree ->GetBranch (branchname.c_str ());
134137 if (branch) {
135- mSectorMCPtr [sector] = &mSectorMC [sector];
136138 branch->SetAddress (&mSectorMCPtr [sector]);
137139 ++nofMCBranches;
138140 }
141+
142+ if (singleBranch) {
143+ break ;
144+ }
139145 }
140146 LOG (INFO) << " reading " << nofDataBranches << " data branch(es) and " << nofMCBranches << " mc branch(es)" ;
141147}
@@ -163,18 +169,28 @@ void ClusterNativeHelper::Reader::clear()
163169int ClusterNativeHelper::Reader::fillIndex (ClusterNativeAccess& clusterIndex, std::unique_ptr<ClusterNative[]>& clusterBuffer,
164170 ConstMCLabelContainerViewWithBuffer& mcBuffer)
165171{
172+ std::vector<gsl::span<const char >> clustersTPC;
173+ std::vector<ConstMCLabelContainer> constMCLabelContainers;
174+ std::vector<ConstMCLabelContainerView> constMCLabelContainerViews;
175+
166176 for (size_t index = 0 ; index < mSectorRaw .size (); ++index) {
167- if (mSectorRaw [index] && mSectorRaw [index]->size () != mSectorRawSize [index]) {
168- LOG (ERROR) << " inconsistent raw size for sector " << index << " : " << mSectorRaw [index]->size () << " v.s. " << mSectorRawSize [index];
169- mSectorRaw [index]->clear ();
177+ if (mSectorRaw [index]) {
178+ if (mSectorRaw [index]->size () != mSectorRawSize [index]) {
179+ LOG (ERROR) << " inconsistent raw size for sector " << index << " : " << mSectorRaw [index]->size () << " v.s. " << mSectorRawSize [index];
180+ mSectorRaw [index]->clear ();
181+ } else {
182+ clustersTPC.emplace_back (mSectorRaw [index]->data (), mSectorRawSize [index]);
183+ }
184+ }
185+ if (mSectorMCPtr [index]) {
186+ auto & view = constMCLabelContainers.emplace_back ();
187+ mSectorMCPtr [index]->copyandflatten (view);
188+ constMCLabelContainerViews.emplace_back (view);
170189 }
171190 }
172- // after changing this ClusterNative transport format, this functionality needs
173- // to be adapted
174- throw std::runtime_error (" code path currently not supported" );
175- // int result = fillIndex(clusterIndex, clusterBuffer, mcBuffer, mSectorRaw, mSectorMC, [](auto&) { return true; });
176- // return result;
177- return 0 ;
191+
192+ int result = fillIndex (clusterIndex, clusterBuffer, mcBuffer, clustersTPC, constMCLabelContainerViews, [](auto &) { return true ; });
193+ return result;
178194}
179195
180196int ClusterNativeHelper::Reader::parseSector (const char * buffer, size_t size, gsl::span<ConstMCLabelContainerView const > const & mcinput, ClusterNativeAccess& clusterIndex,
0 commit comments