80 if (tinfo.globalRunNumberChanged && mUseIRFrames) {
83 auto rlim = ccdb.getRunDuration(tinfo.runNumber);
84 long ts = (rlim.first + rlim.second) / 2;
87 mROFBiasInBC = alpideParam.roFrameBiasInBC;
88 mROFLengthInBC = alpideParam.roFrameLengthInBC;
92 mROFBiasInBC = alpideParam.roFrameBiasInBC;
93 mROFLengthInBC = alpideParam.roFrameLengthInBC;
97 gsl::span<const o2::dataformats::IRFrame> irFrames{};
99 irFrames = pc.
inputs().
get<gsl::span<o2::dataformats::IRFrame>>(
"driverInfo");
102 auto ent = mTree->GetReadEntry();
105 if (ent >= mTree->GetEntries()) {
110 LOG(info) << mDetName <<
"DigitReader has no entry to read, sending empty output";
111 for (uint32_t iLayer = 0; iLayer < mLayers; ++iLayer) {
117 noLabels.flatten_to(sharedlabels);
118 pc.
outputs().
snapshot(
Output{Origin,
"DIGITSMC2ROF", iLayer}, std::vector<o2::itsmft::MC2ROFRecord>{});
131 mTree->GetEntry(ent);
132 for (uint32_t iLayer = 0; iLayer < mLayers; ++iLayer) {
133 LOG(info) << mDetName <<
"DigitReader" << ((mDoStaggering) ? std::format(
": {}", iLayer) :
"") <<
" pushes " << mDigROFRec[iLayer]->
size() <<
" ROFRecords, " << mDigits[iLayer]->size() <<
" digits at entry " << ent;
138 mPLabels[iLayer]->copyandflatten(sharedlabels);
139 delete mPLabels[iLayer];
140 mPLabels[iLayer] =
nullptr;
142 static std::vector<o2::itsmft::MC2ROFRecord> dummyMC2ROF;
150 std::vector<o2::itsmft::PhysTrigger> dummyTrig;
153 if (mTree->GetReadEntry() + 1 >= mTree->GetEntries()) {
159 std::vector<o2::itsmft::Digit> digitsSel;
160 std::vector<o2::itsmft::GBTCalibData> calibSel;
161 std::vector<o2::itsmft::ROFRecord> digROFRecSel;
164 if (irFrames.size()) {
170 const auto irMin = irfSel.
getIRFrames().front().getMin();
171 const auto irMax = irfSel.
getIRFrames().back().getMax();
172 LOGP(info,
"Selecting IRFrame {}-{}", irMin.asString(), irMax.asString());
173 while (ent < mTree->GetEntries()) {
175 if (ent > mTree->GetReadEntry()) {
178 mPLabels[0] =
nullptr;
179 mConstLabels[0].clear();
180 mTree->SetBranchAddress(mDigitMCTruthBranchName.c_str(), &mPLabels[0]);
182 mTree->GetEntry(ent);
184 mPLabels[0]->copyandflatten(mConstLabels[0]);
186 mPLabels[0] =
nullptr;
189 std::vector<int> rofOld2New;
190 rofOld2New.resize(mDigROFRec[0]->
size(), -1);
192 if (mDigROFRec[0]->front().getBCData() <= irMax && (mDigROFRec[0]->back().getBCData() + mROFLengthInBC - 1) >= irMin) {
193 for (
int irof = 0; irof < (
int)mDigROFRec[0]->
size(); irof++) {
194 const auto& rof = mDigROFRec[0]->at(irof);
195 if (irfSel.
check({rof.getBCData(), rof.getBCData() + mROFLengthInBC - 1}) != -1) {
196 rofOld2New[irof] = (
int)digROFRecSel.size();
197 LOGP(
debug,
"Adding selected ROF {}", rof.getBCData().asString());
198 digROFRecSel.push_back(rof);
199 int offs = digitsSel.size();
200 digROFRecSel.back().setFirstEntry(offs);
201 std::copy(mDigits[0]->begin() + rof.getFirstEntry(), mDigits[0]->begin() + rof.getFirstEntry() + rof.getNEntries(), std::back_inserter(digitsSel));
202 for (
int id = 0;
id < rof.getNEntries();
id++) {
203 digitLabelsSel.
addElements(
id + offs, mConstLabels[0].getLabels(
id + rof.getFirstEntry()));
205 if (mCalib.size() >=
size_t((irof + 1) * mNRUs)) {
206 std::copy(mCalib.begin() + irof * mNRUs, mCalib.begin() + (irof + 1) * mNRUs, std::back_inserter(calibSel));
211 if (mDigROFRec[0]->back().getBCData() + mROFLengthInBC - 1 < irMax) {
224 std::vector<o2::itsmft::PhysTrigger> dummyTrig;
232 if (!irFrames.size() || irFrames.back().isLast()) {
242 mTree.reset(
nullptr);
243 mFile.reset(TFile::Open(
filename.c_str()));
244 if (!mFile || mFile->IsZombie()) {
245 throw std::runtime_error(std::format(
"Cannot open {}",
filename));
247 mTree.reset((TTree*)mFile->Get(mDigTreeName.c_str()));
249 throw std::runtime_error(std::format(
"Tree {} not found in {}", mDigTreeName,
filename));
251 for (uint32_t iLayer = 0; iLayer < mLayers; ++iLayer) {
252 setBranchAddress(mDigitROFBranchName, mDigROFRec[iLayer], iLayer);
253 setBranchAddress(mDigitBranchName, mDigits[iLayer], iLayer);
255 if (!mTree->GetBranch(getBranchName(mDigitMCTruthBranchName, iLayer).c_str())) {
256 throw std::runtime_error(
"MC data requested but not found in the tree");
258 if (!mPLabels[iLayer]) {
259 setBranchAddress(mDigitMCTruthBranchName, mPLabels[iLayer], iLayer);
264 if (!mTree->GetBranch(mCalibBranchName.c_str())) {
265 throw std::runtime_error(
"GBT calibration data requested but not found in the tree");
267 setBranchAddress(mCalibBranchName, mCalibPtr);
269 LOG(info) <<
"Loaded tree from " <<
filename <<
" with " << mTree->GetEntries() <<
" entries";