57 mLabels = std::make_unique<TTreeReaderValue<dataformats::MCTruthContainer<MCLabel>>>(mTreeReader,
"MIDDigitMCLabels");
64 ic.
options().
get<std::string>(
"mid-digit-infile"));
83 TTreeReader mTreeReader{};
84 TTreeReaderValue<std::vector<ROFRecord>> mRofs = {mTreeReader,
"MIDROFRecords"};
85 TTreeReaderValue<std::vector<ColumnData>> mDigits = {mTreeReader,
"MIDDigit"};
86 std::unique_ptr<TTreeReaderValue<dataformats::MCTruthContainer<MCLabel>>> mLabels{};
88 bool mUseIRFrames =
false;
90 void connectTree(std::string
filename)
93 if (!file ||
file->IsZombie()) {
94 throw std::invalid_argument(fmt::format(
"Opening file {} failed",
filename));
97 auto tree =
file->Get<TTree>(
"o2sim");
99 throw std::invalid_argument(fmt::format(
"Tree o2sim not found in {}",
filename));
101 mTreeReader.SetTree(
tree);
102 mTreeReader.Restart();
109 if (mTreeReader.GetEntries() == 0) {
110 LOG(info) <<
"digit tree has no entry, sending empty output";
122 if (!mTreeReader.Next()) {
123 throw std::invalid_argument(mTreeReader.fgEntryStatusText[mTreeReader.GetEntryStatus()]);
134 if (mTreeReader.GetCurrentEntry() + 1 >= mTreeReader.GetEntries()) {
142 std::vector<ROFRecord> rofs{};
143 std::vector<ColumnData>
digits{};
147 auto irFrames = pc.
inputs().
get<gsl::span<dataformats::IRFrame>>(
"driverInfo");
149 if (mTreeReader.GetEntries() == 0) {
152 LOG(info) <<
"digit tree has no entry, sending empty output";
153 }
else if (!irFrames.empty()) {
156 const auto irMin = irfSel.getIRFrames().front().getMin();
157 const auto irMax = irfSel.getIRFrames().back().getMax();
160 bool loadNextTF = mTreeReader.GetCurrentEntry() < 0;
164 if (loadNextTF && !mTreeReader.Next()) {
165 throw std::invalid_argument(mTreeReader.fgEntryStatusText[mTreeReader.GetEntryStatus()]);
169 if (!mRofs->empty() && mRofs->front().interactionRecord <= irMax &&
170 mRofs->back().interactionRecord >= irMin) {
171 for (
const auto& rof : *mRofs) {
172 if (irfSel.check(rof.interactionRecord) != -1) {
173 rofs.emplace_back(rof);
174 rofs.back().firstEntry =
digits.size();
175 rofs.back().nEntries = rof.nEntries;
176 digits.insert(
digits.end(), mDigits->begin() + rof.firstEntry, mDigits->begin() + rof.getEndIndex());
178 for (
auto idig = 0; idig < rof.nEntries; ++idig) {
179 labels.addElements(
labels.getIndexedSize(), (*mLabels)->getLabels(rof.firstEntry + idig));
187 if ((mRofs->empty() || mRofs->back().interactionRecord < irMax) &&
188 mTreeReader.GetCurrentEntry() + 1 < mTreeReader.GetEntries()) {
205 if (irFrames.empty() || irFrames.back().isLast()) {
ConfigParamRegistry const & options()
DataAllocator & outputs()
The data allocator is used to allocate memory for the output data.
InputRecord & inputs()
The inputs associated with this processing context.
ServiceRegistryRef services()
The services registry associated with this processing context.