Skip to content

Commit 514d29b

Browse files
miranov25claude
andcommitted
TPC TimeSeries: BC numbers of the vertex and of the closest TRD triggers
- vertex_bc: BC number (from the TF start, orbit firstTFOrbit) of the vertex time, for the same vertex as vertex_time. - trdTrigBCBefore/After: BC numbers of the closest TRD-triggered BCs at or before / at or after vertex_bc (-999999 if none or no vertex), so the TRD-in-collision estimators can be calibrated from raw BC numbers. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01YYeB7SW1TM7vU8qhVHiG61
1 parent 48a37e7 commit 514d29b

1 file changed

Lines changed: 31 additions & 0 deletions

File tree

‎Detectors/TPC/workflow/src/TPCTimeSeriesSpec.cxx‎

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -382,6 +382,7 @@ class TPCTimeSeries : public Task
382382
// TRD-triggered BCs of this TF: TRD is read out only at these BCs. Built once per TF; per entry only the triggers closest
383383
// to the collision are stored (trdTrigDBCBefore/After). Records with bc >= LHCMaxBunches are dropped, as in the AOD producer.
384384
mTRDTrigBCs.clear();
385+
mTRDTrigBCsInTF.clear();
385386
if (mUnbinnedWriter && !mTPCOnly && recoData.inputsTRD) {
386387
const auto trdTrig = recoData.getTRDTriggerRecords();
387388
mTRDTrigBCs.reserve(trdTrig.size());
@@ -427,6 +428,12 @@ class TPCTimeSeries : public Task
427428
if (mUnbinnedWriter) {
428429
mTPCTrackClIdx = pc.inputs().get<gsl::span<o2::tpc::TPCClRefElem>>("trackTPCClRefs");
429430
mFirstTFOrbit = processing_helpers::getFirstTForbit(pc);
431+
// TRD-triggered BCs as BC numbers from the TF start (orbit mFirstTFOrbit, bc 0), in the order of mTRDTrigBCs (sorted)
432+
const o2::InteractionRecord irTFStart(0, mFirstTFOrbit);
433+
mTRDTrigBCsInTF.reserve(mTRDTrigBCs.size());
434+
for (const auto& ir : mTRDTrigBCs) {
435+
mTRDTrigBCsInTF.push_back(static_cast<int>(ir.differenceInBC(irTFStart)));
436+
}
430437
}
431438

432439
// get local multiplicity - count neighbouring tracks
@@ -1237,6 +1244,7 @@ class TPCTimeSeries : public Task
12371244
bool mStoreFullTrackPar{false}; ///< experimental: store tpcOut/trdIn/tpcAtVtx as TrackPar (constant per job)
12381245
uint8_t mTRDInReadout{255}; ///< TRD in detector readout (GRPECS): 1 yes, 0 no, 255 unknown
12391246
std::vector<o2::InteractionRecord> mTRDTrigBCs; ///< TRD-triggered BCs of the current TF, sorted
1247+
std::vector<int> mTRDTrigBCsInTF; ///< the same BCs as BC numbers from the TF start (orbit mFirstTFOrbit)
12401248
std::vector<int> mNContributorsITS; ///< per vertex ID: ITS-only PV contributors (current TF)
12411249
std::vector<int> mNContributorsITSTPC; ///< per vertex ID: ITS-TPC PV contributors, TRD/TOF-matched included (current TF)
12421250
std::vector<int> mNContributorsTRD; ///< per vertex ID: ITS-TPC-TRD (and -TOF) PV contributors (current TF)
@@ -1585,6 +1593,25 @@ class TPCTimeSeries : public Task
15851593
}
15861594
}
15871595

1596+
// BC numbers from the TF start (orbit firstTFOrbit, bc 0), for calibrating the two estimators: BC of the vertex time
1597+
// (same reference as vertex_time), and the closest TRD-triggered BCs at or before and at or after it (both equal to
1598+
// vertexBC if a trigger is at that BC). -999999 if no vertex or no such trigger in this TF.
1599+
int vertexBC = -999999;
1600+
int trdTrigBCBefore = -999999;
1601+
int trdTrigBCAfter = -999999;
1602+
if (vtxID >= 0) {
1603+
vertexBC = static_cast<int>(std::lround(vertex.getTimeStamp().getTimeStamp() / o2::constants::lhc::LHCBunchSpacingMUS));
1604+
const auto itBC = std::lower_bound(mTRDTrigBCsInTF.begin(), mTRDTrigBCsInTF.end(), vertexBC); // first trigger at or after vertexBC
1605+
if (itBC != mTRDTrigBCsInTF.end()) {
1606+
trdTrigBCAfter = *itBC;
1607+
}
1608+
if (itBC != mTRDTrigBCsInTF.end() && *itBC == vertexBC) {
1609+
trdTrigBCBefore = vertexBC;
1610+
} else if (itBC != mTRDTrigBCsInTF.begin()) {
1611+
trdTrigBCBefore = *(itBC - 1);
1612+
}
1613+
}
1614+
15881615
int typeSide = 2; // A- and C-Side cluster
15891616
if (trackFull.hasASideClustersOnly()) {
15901617
typeSide = 0;
@@ -1730,6 +1757,10 @@ class TPCTimeSeries : public Task
17301757
<< "vertex_nContributorsTRD=" << nContribTRD
17311758
<< "trdTrigDBCBefore=" << trdTrigDBCBefore
17321759
<< "trdTrigDBCAfter=" << trdTrigDBCAfter
1760+
// BC numbers from the TF start: vertex (from its time) and closest TRD triggers at or before / at or after it
1761+
<< "vertex_bc=" << vertexBC
1762+
<< "trdTrigBCBefore=" << trdTrigBCBefore
1763+
<< "trdTrigBCAfter=" << trdTrigBCAfter
17331764
<< "isNearestVertex=" << isNearestVtx
17341765
// tpc track properties
17351766
<< "pt=" << trkOrig.getPt()

0 commit comments

Comments
 (0)