@@ -47,6 +47,11 @@ class TTree;
4747namespace o2
4848{
4949
50+ namespace gpu
51+ {
52+ class GPUParam ;
53+ }
54+
5055namespace tpc
5156{
5257class VDriftCorrFact ;
@@ -101,15 +106,72 @@ struct UnbinnedResid {
101106 ClassDefNV (UnbinnedResid, 2 );
102107};
103108
109+ struct DetInfoResid { // detector info associated with residual
110+ uint32_t word = 0 ; // container interpreted in a different way depending on the detector type
111+ //
112+ // TPC view: qTot and qMax of the cluster
113+ uint16_t qTotTPC () const { return static_cast <uint16_t >(word & 0xFFFFu ); }
114+ uint16_t qMaxTPC () const { return static_cast <uint16_t >((word >> 16 ) & 0xFFFFu ); }
115+ void setTPC (uint16_t qTot, uint16_t qMax) { word = (static_cast <uint32_t >(qMax) << 16 ) | static_cast <uint32_t >(qTot); }
116+ //
117+ // TRD view: q0, q1, q2 + calibrated slope (truncated to in +-3.5 range)
118+ static constexpr uint32_t TRDQ0NB = 7 , TRDQ1NB = 7 , TRDQ2NB = 6 , TRDSlpNB = 12 ;
119+ static constexpr uint32_t TRDQ0Msk = (1 << TRDQ0NB) - 1 , TRDQ1Msk = (1 << TRDQ1NB) - 1 , TRDQ2Msk = ((1 << TRDQ2NB) - 1 ), TRDSlpMsk = (1 << TRDSlpNB) - 1 ;
120+ static constexpr float TRDMaxSlope = 3.5 , TRDSlope2Int = ((1 << TRDSlpNB) - 1 ) / (2 * TRDMaxSlope), TRDInt2Slope = 1 .f / TRDSlope2Int;
121+ uint16_t q0TRD () const { return static_cast <uint16_t >(word & TRDQ0Msk); }
122+ uint16_t q1TRD () const { return static_cast <uint16_t >((word >> TRDQ0NB) & TRDQ1Msk); }
123+ uint16_t q2TRD () const { return static_cast <uint16_t >((word >> (TRDQ0NB + TRDQ1NB)) & TRDQ2Msk); }
124+ float slopeTRD () const { return ((word >> (TRDQ0NB + TRDQ1NB + TRDQ2NB)) & TRDSlpMsk) * TRDInt2Slope - TRDMaxSlope; }
125+ void setTRD (uint8_t q0, uint8_t q1, uint8_t q2, float slope)
126+ {
127+ float rslope = (slope + TRDMaxSlope) * TRDSlope2Int;
128+ if (rslope < 0 .f ) {
129+ rslope = 0 ;
130+ } else if (rslope > TRDSlpMsk) {
131+ rslope = TRDSlpMsk;
132+ }
133+ uint32_t slpI = std::round (rslope);
134+ word = (static_cast <uint32_t >(slpI << (TRDQ0NB + TRDQ1NB + TRDQ2NB)) |
135+ static_cast <uint32_t >((q2 & TRDQ2Msk) << (TRDQ0NB + TRDQ1NB)) |
136+ static_cast <uint32_t >((q1 & TRDQ1Msk) << TRDQ0NB) |
137+ static_cast <uint32_t >(q0 & TRDQ0Msk));
138+ }
139+ //
140+ // TOF view (time difference in \mus wrt seeding ITS-TPC track)
141+ float timeTOF () const { return std::bit_cast<float >(word); }
142+ void setTOF (float t) { word = std::bit_cast<uint32_t >(t); }
143+ //
144+ // No info for ITS is stored
145+ //
146+ // PV view (time difference in \mus wrt contributing ITS-TPC track)
147+ float timePV () const { return std::bit_cast<float >(word); }
148+ void setPV (float t) { word = std::bit_cast<uint32_t >(t); }
149+
150+ ClassDefNV (DetInfoResid, 1 );
151+ };
152+
104153// / Structure for the information required to associate each residual with a given track type (ITS-TPC-TRD-TOF, etc)
105154struct TrackDataCompact {
106155 TrackDataCompact () = default ;
107- TrackDataCompact (uint32_t idx, uint8_t nRes, uint8_t source, uint8_t nextraRes = 0 ) : idxFirstResidual(idx), nResiduals(nRes), sourceId(source), nExtDetResid(nextraRes) {}
156+ TrackDataCompact (uint32_t idx, std::array< uint8_t , 4 > mlt, uint8_t nRes, uint8_t source, uint8_t nextraRes = 0 ) : idxFirstResidual(idx), multStack{mlt} , nResiduals(nRes), sourceId(source), nExtDetResid(nextraRes) {}
108157 uint32_t idxFirstResidual; // /< the index of the first residual from this track
158+ std::array<uint8_t , 4 > multStack{}; // multiplicity in the stack packed as asinh(x*0.05)/0.05
109159 uint8_t nResiduals; // /< total number of TPC residuals associated to this track
110160 uint8_t nExtDetResid = 0 ; // /< number of external detectors (wrt TPC) residuals stored, on top of clIdx.getEntries
111161 uint8_t sourceId; // /< source ID obtained from the global track ID
112- ClassDefNV (TrackDataCompact, 2 );
162+
163+ void setMultStack (float v, int stack)
164+ {
165+ uint32_t mltPacked = std::round (std::asinh (v * 0.05 ) / 0.05 );
166+ multStack[stack] = mltPacked < 0xff ? mltPacked : 0xff ;
167+ }
168+ float getMultStack (int stack) const
169+ {
170+ return std::sinh (multStack[stack] * 0.05 ) / 0.05 ;
171+ }
172+ float getMultStackPacked (int stack) const { return multStack[stack]; }
173+
174+ ClassDefNV (TrackDataCompact, 3 );
113175};
114176
115177// TODO add to UnbinnedResid::sec flag if cluster was used or not
@@ -149,11 +211,22 @@ struct TrackData {
149211 short TRDTrkltSlope[6 ] = {}; // /< TRD tracklet slope 0x7fff / param::MaxTRDSlope
150212 uint8_t nExtDetResid = 0 ; // /< number of external detectors (to TPC) residuals stored, on top of clIdx.getEntries
151213 o2::dataformats::RangeReference<> clIdx{}; // /< index of first cluster residual and total number of TPC cluster residuals of this track
152-
214+ std::array< uint8_t , 4 > multStack{}; // multiplicity in the stack packed as asinh(x*0.05)/0.05
153215 float getT0Error () const { return float (clAvailTOF); }
154216 bool isTOFAvail () const { return clAvailTOF != 0 ; }
155217
156- ClassDefNV (TrackData, 9 );
218+ void setMultStack (float v, int stack)
219+ {
220+ uint32_t mltPacked = std::round (std::asinh (v * 0.05 ) / 0.05 );
221+ multStack[stack] = mltPacked < 0xff ? mltPacked : 0xff ;
222+ }
223+ float getMultStack (int stack) const
224+ {
225+ return std::sinh (multStack[stack] * 0.05 ) / 0.05 ;
226+ }
227+ float getMultStackPacked (int stack) const { return multStack[stack]; }
228+
229+ ClassDefNV (TrackData, 10 );
157230};
158231
159232// / \class TrackInterpolation
@@ -268,6 +341,8 @@ class TrackInterpolation
268341 void diffToMA (const int np, const std::array<float , param::NPadRows>& y, std::array<float , param::NPadRows>& diffMA) const ;
269342
270343 // -------------------------------------- settings --------------------------------------------------
344+ void setNHBPerTF (int n) { mNHBPerTF = n; }
345+
271346 void setTPCVDrift (const o2::tpc::VDriftCorrFact& v);
272347
273348 // / Sets the flag if material correction should be applied when extrapolating the tracks
@@ -296,10 +371,13 @@ class TrackInterpolation
296371
297372 void setExtDetResid (bool v) { mExtDetResid = v; }
298373
299- int processTRDLayer (const o2::trd::TrackTRD& trkTRD, int iLayer, o2::track::TrackParCov& trkWork, std::array<float , 2 >* trkltTRDYZ = nullptr , std::array<float , 3 >* trkltTRDCov = nullptr , TrackData* trkData = nullptr );
374+ int processTRDLayer (const o2::trd::TrackTRD& trkTRD, int iLayer, o2::track::TrackParCov& trkWork, std::array<float , 2 >* trkltTRDYZ = nullptr ,
375+ std::array<float , 3 >* trkltTRDCov = nullptr , TrackData* trkData = nullptr ,
376+ o2::trd::Tracklet64* trk64 = nullptr , o2::trd::CalibratedTracklet* trkCalib = nullptr );
300377
301378 // --------------------------------- output ---------------------------------------------
302379 std::vector<UnbinnedResid>& getClusterResiduals () { return mClRes ; }
380+ std::vector<DetInfoResid>& getClusterResidualsDetInfo () { return mDetInfoRes ; }
303381 std::vector<TrackDataCompact>& getTrackDataCompact () { return mTrackDataCompact ; }
304382 std::vector<TrackDataExtended>& getTrackDataExtended () { return mTrackDataExtended ; }
305383 std::vector<TrackData>& getReferenceTracks () { return mTrackData ; }
@@ -308,8 +386,14 @@ class TrackInterpolation
308386
309387 private:
310388 static constexpr float sFloatEps {1 .e -7f }; // /< float epsilon for robust linear fitting
389+ static constexpr int NSTACKS = 4 ;
390+ static constexpr std::array<int , NSTACKS + 1 > STACKROWS{0 , 63 , 97 , 127 , 152 };
311391 // parameters + settings
312392 const SpacePointsCalibConfParam* mParams = nullptr ;
393+ std::shared_ptr<o2::gpu::GPUParam> mTPCParam = nullptr ;
394+ int mNHBPerTF = 32 ;
395+ int mNTPCOccBinLength = 16 ; // /< TPC occupancy bin length in TB
396+ float mNTPCOccBinLengthInv = 1 .f / 16 ; // /< its inverse
313397 float mTPCTimeBinMUS {.2f }; // /< TPC time bin duration in us
314398 float mTPCVDriftRef = -1 .; // /< TPC nominal drift speed in cm/microseconds
315399 float mTPCDriftTimeOffsetRef = 0 .; // /< TPC nominal (e.g. at the start of run) drift time bias in cm/mus
@@ -348,6 +432,7 @@ class TrackInterpolation
348432 std::vector<TrackDataCompact> mTrackDataCompact {}; // /< required to connect each residual to a global track
349433 std::vector<TrackDataExtended> mTrackDataExtended {}; // /< full tracking information for debugging
350434 std::vector<UnbinnedResid> mClRes {}; // /< residuals for each available TPC cluster of all tracks
435+ std::vector<DetInfoResid> mDetInfoRes {}; // /< packed detector info associated with each residual
351436 std::vector<TrackData> mTrackDataUnfiltered {}; // /< same as mTrackData, but for all tracks before outlier filtering
352437 std::vector<TPCClusterResiduals> mClResUnfiltered {}; // /< same as mClRes, but for all residuals before outlier filtering
353438
0 commit comments