Project
Loading...
Searching...
No Matches
TrackInterpolation.h
Go to the documentation of this file.
1// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3// All rights not expressly granted are reserved.
4//
5// This software is distributed under the terms of the GNU General Public
6// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7//
8// In applying this license CERN does not waive the privileges and immunities
9// granted to it by virtue of its status as an Intergovernmental Organization
10// or submit itself to any jurisdiction.
11
16
17#ifndef ALICEO2_TPC_TRACKINTERPOLATION_H_
18#define ALICEO2_TPC_TRACKINTERPOLATION_H_
19
20#include <gsl/span>
42#include "TRDBase/RecoParam.h"
43#include "TRDBase/Geometry.h"
44
45class TTree;
46
47namespace o2
48{
49
50namespace tpc
51{
52class VDriftCorrFact;
53
56 float dy{};
57 float dz{};
58 float y{};
59 float z{};
60 float snp{};
61 unsigned char sec{};
62 unsigned char dRow{};
64};
65
69 UnbinnedResid() = default;
70 UnbinnedResid(float dyIn, float dzIn, float tgSlpIn, float yIn, float zIn, unsigned char rowIn, unsigned char secIn, short chanIn = -1) : dy(static_cast<short>(dyIn * 0x7fff / param::MaxResid)),
71 dz(static_cast<short>(dzIn * 0x7fff / param::MaxResid)),
72 tgSlp(static_cast<short>(tgSlpIn * 0x7fff / param::MaxTgSlp)),
73 y(static_cast<short>(yIn * 0x7fff / param::MaxY)),
74 z(static_cast<short>(zIn * 0x7fff / param::MaxZ)),
75 row(rowIn),
76 sec(secIn),
77 channel(chanIn) {}
78 short dy{0};
79 short dz{0};
80 short tgSlp{0};
81 short y{0};
82 short z{0};
83 unsigned char row{0};
84 unsigned char sec{0};
85 short channel{-1};
86
87 bool isTPC() const { return row < constants::MAXGLOBALPADROW; }
88 bool isTRD() const { return row >= 160 && row < 166; }
89 bool isTOF() const { return row == 170; }
90 bool isITS() const { return row >= 180; }
91 int getDetID() const { return isTPC() ? 1 : (isITS() ? 0 : (isTRD() ? 2 : (isTOF() ? 3 : -1))); }
92 int getITSLayer() const { return row - 180; }
93 int getTRDLayer() const { return row - 170; }
94 float getAlpha() const;
95 float getX() const;
96
97 static void init(long timestamp = -1);
98 static void checkInitDone();
99 static bool gInitDone;
100
102};
103
106 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) {}
109 uint8_t nResiduals;
110 uint8_t nExtDetResid = 0;
111 uint8_t sourceId;
113};
114
115// TODO add to UnbinnedResid::sec flag if cluster was used or not
116// TODO add to TrackDataCompact::sourceId flag if track was used or not (if possible)
117
134
136struct TrackData {
139 float dEdxTPC{};
140 float chi2TPC{};
141 float chi2ITS{};
142 float chi2TRD{};
143 float deltaTOF{};
144
145 unsigned short nClsTPC{};
146 unsigned short nClsITS{};
147 unsigned short nTrkltsTRD{};
148 unsigned short clAvailTOF{};
149 short TRDTrkltSlope[6] = {};
150 uint8_t nExtDetResid = 0;
152
153 float getT0Error() const { return float(clAvailTOF); }
154 bool isTOFAvail() const { return clAvailTOF != 0; }
155
157};
158
164{
165 public:
167
170
171 // since this class has pointer members, we should explicitly delete copy and assignment operators
174
176 enum {
177 ExtOut = 0,
180 NIndices
181 };
182
184 struct CacheStruct {
185 std::array<float, NIndices> y{};
186 std::array<float, NIndices> z{};
187 std::array<float, NIndices> sy2{};
188 std::array<float, NIndices> szy{};
189 std::array<float, NIndices> sz2{};
190 std::array<float, NIndices> snp{};
191 float clY{0.f};
192 float clZ{0.f};
193 float clAngle{0.f};
194 unsigned short clAvailable{0};
195 unsigned char clSec{0};
196 };
197
199 struct TrackParams {
200 TrackParams() = default;
201 float qpt{0.f};
202 float tgl{0.f};
203 std::array<float, param::NPadRows> zTrk{};
204 std::array<float, param::NPadRows> xTrk{};
205 std::array<float, param::NPadRows> dy{};
206 std::array<float, param::NPadRows> dz{};
207 std::array<float, param::NPadRows> tglArr{};
208 std::bitset<param::NPadRows> flagRej{};
209 };
210
211 // -------------------------------------- processing functions --------------------------------------------------
212
215
218
221
224
226 bool isTrackSelected(const o2::track::TrackParCov& trk) const;
227
229 void process();
230
233 void extrapolateTrack(int iSeed);
234
237 void interpolateTrack(int iSeed);
238
240 void reset();
241
242 // -------------------------------------- outlier rejection --------------------------------------------------
243
248 bool validateTrack(const TrackData& trk, TrackParams& params, const std::vector<TPCClusterResiduals>& clsRes) const;
249
252 bool outlierFiltering(const TrackData& trk, TrackParams& params, const std::vector<TPCClusterResiduals>& clsRes) const;
253
256 float checkResiduals(const TrackData& trk, TrackParams& params, const std::vector<TPCClusterResiduals>& clsRes) const;
257
260 bool compareToHelix(const TrackData& trk, TrackParams& params, const std::vector<TPCClusterResiduals>& clsRes) const;
261
263 void diffToLocLine(const int np, int idxOffset, const std::array<float, param::NPadRows>& x, const std::array<float, param::NPadRows>& y, std::array<float, param::NPadRows>& diffY) const;
264
266 void diffToMA(const int np, const std::array<float, param::NPadRows>& y, std::array<float, param::NPadRows>& diffMA) const;
267
268 // -------------------------------------- settings --------------------------------------------------
270
272 void setMatCorr(MatCorrType matCorr) { mMatCorr = matCorr; }
273
275 void setMaxTracksPerTF(int n) { mMaxTracksPerTF = n; }
276
278 void setAddTracksForMapPerTF(int n) { mAddTracksForMapPerTF = n; }
279
281 void setDumpTrackPoints() { mDumpTrackPoints = true; }
282
284 void setITSClusterDictionary(const o2::itsmft::TopologyDictionary* dict) { mITSDict = dict; }
285
287 void setProcessSeeds() { mProcessSeeds = true; }
288
290 void setProcessITSTPConly() { mProcessITSTPConly = true; }
291
293 void setSqrtS(float s) { mSqrtS = s; }
294
295 void setExtDetResid(bool v) { mExtDetResid = v; }
296
297 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);
298
299 // --------------------------------- output ---------------------------------------------
300 std::vector<UnbinnedResid>& getClusterResiduals() { return mClRes; }
301 std::vector<TrackDataCompact>& getTrackDataCompact() { return mTrackDataCompact; }
302 std::vector<TrackDataExtended>& getTrackDataExtended() { return mTrackDataExtended; }
303 std::vector<TrackData>& getReferenceTracks() { return mTrackData; }
304 std::vector<TPCClusterResiduals>& getClusterResidualsUnfiltered() { return mClResUnfiltered; }
305 std::vector<TrackData>& getReferenceTracksUnfiltered() { return mTrackDataUnfiltered; }
306
307 private:
308 static constexpr float sFloatEps{1.e-7f};
309 // parameters + settings
310 const SpacePointsCalibConfParam* mParams = nullptr;
311 float mTPCTimeBinMUS{.2f};
312 float mTPCVDriftRef = -1.;
313 float mTPCDriftTimeOffsetRef = 0.;
314 float mSqrtS{13600.f};
315 MatCorrType mMatCorr{MatCorrType::USEMatCorrNONE};
316 int mMaxTracksPerTF{-1};
317 int mAddTracksForMapPerTF{0};
318 bool mDumpTrackPoints{false};
319 bool mExtDetResid{true};
320 bool mProcessSeeds{false};
321 bool mProcessITSTPConly{false};
322 o2::dataformats::GlobalTrackID::mask_t mSourcesConfigured;
323 o2::dataformats::GlobalTrackID::mask_t mSourcesConfiguredMap;
324 bool mSingleSourcesConfigured{true};
325
326 // input
327 const o2::globaltracking::RecoContainer* mRecoCont = nullptr;
328 std::vector<o2::dataformats::GlobalTrackID> mGIDs{};
329 std::vector<o2::globaltracking::RecoContainer::GlobalIDSet> mGIDtables{};
330 std::vector<float> mTrackTimes{};
331 std::vector<o2::track::TrackParCov> mSeeds{};
332 std::vector<int> mParentID{};
333 std::map<int, int> mTrackTypes;
334 std::array<std::vector<uint32_t>, 4> mTrackIndices;
335 gsl::span<const TPCClRefElem> mTPCTracksClusIdx;
336 const ClusterNativeAccess* mTPCClusterIdxStruct = nullptr;
337 // ITS specific input only needed for debugging
338 gsl::span<const int> mITSTrackClusIdx;
339 std::vector<o2::BaseCluster<float>> mITSClustersArray;
340 const o2::itsmft::TopologyDictionary* mITSDict = nullptr;
341
342 // output
343 std::vector<TrackData> mTrackData{};
344 std::vector<TrackDataCompact> mTrackDataCompact{};
345 std::vector<TrackDataExtended> mTrackDataExtended{};
346 std::vector<UnbinnedResid> mClRes{};
347 std::vector<TrackData> mTrackDataUnfiltered{};
348 std::vector<TPCClusterResiduals> mClResUnfiltered{};
349
350 // cache
351 std::array<CacheStruct, constants::MAXGLOBALPADROW> mCache{{}};
352 std::vector<o2::dataformats::GlobalTrackID> mGIDsSuccess;
353
354 // helpers
355 o2::trd::RecoParam mRecoParam;
356 o2::trd::Geometry* mGeoTRD;
357 std::unique_ptr<TPCFastTransform> mFastTransform{};
358 float mBz;
359 bool mInitDone{false};
360 size_t mRejectedResiduals{};
361
362 ClassDefNV(TrackInterpolation, 1);
363};
364
365} // namespace tpc
366
367} // namespace o2
368
369#endif
Wrapper container for different reconstructed object types.
Definition of the ITSMFT cluster.
Definition of the ClusterTopology class.
Definition of the TOF cluster.
Base track model for the Barrel, params only, w/o covariance.
Class to store event ID and index in the event for objects like track, cluster...
Global index for barrel track: provides provenance (detectors combination), index in respective array...
Class to store the output of the matching to TOF.
Class to refer to the 1st entry and N elements of some group in the continuous container.
Parameters used for TPC space point calibration.
class to create TPC fast transformation
Error parameterizations and helper functions for TRD reconstruction.
Definition of the ITS track.
Result of refitting TPC-ITS matched track.
Reference on ITS/MFT clusters set.
Cluster class for TOF.
Definition Cluster.h:37
TrackInterpolation(const TrackInterpolation &)=delete
void prepareInputTrackSample(const o2::globaltracking::RecoContainer &inp)
Prepare input track sample (not relying on CreateTracksVariadic functionality)
bool isInputTrackAccepted(const o2::dataformats::GlobalTrackID &gid, const o2::globaltracking::RecoContainer::GlobalIDSet &gidTable, const o2::dataformats::PrimaryVertex &pv) const
Check if input track passes configured cuts.
void diffToMA(const int np, const std::array< float, param::NPadRows > &y, std::array< float, param::NPadRows > &diffMA) const
For a given set of points, calculate their deviation from the moving average (build from the neighbou...
std::vector< TrackData > & getReferenceTracks()
void diffToLocLine(const int np, int idxOffset, const std::array< float, param::NPadRows > &x, const std::array< float, param::NPadRows > &y, std::array< float, param::NPadRows > &diffY) const
For a given set of points, calculate the differences from each point to the fitted lines from all oth...
std::vector< TrackData > & getReferenceTracksUnfiltered()
TrackInterpolation()=default
Default constructor.
@ ExtIn
extrapolation inwards of TRD/TOF track
@ NIndices
total number of indices (3)
@ Int
interpolation (mean positions of both extrapolations)
@ ExtOut
extrapolation outwards of ITS track
std::vector< TrackDataExtended > & getTrackDataExtended()
o2::dataformats::GlobalTrackID::Source findValidSource(const o2::dataformats::GlobalTrackID::mask_t mask, const o2::dataformats::GlobalTrackID::Source src) const
For given vertex track source which is not in mSourcesConfigured find the seeding source which is ena...
void setMatCorr(MatCorrType matCorr)
Sets the flag if material correction should be applied when extrapolating the tracks.
void setProcessSeeds()
Enable processing of seeds.
void setMaxTracksPerTF(int n)
Sets the maximum number of tracks to be processed (successfully) per TF.
std::vector< TrackDataCompact > & getTrackDataCompact()
float checkResiduals(const TrackData &trk, TrackParams &params, const std::vector< TPCClusterResiduals > &clsRes) const
void setAddTracksForMapPerTF(int n)
In addition to mMaxTracksPerTF up to the set number of additional tracks can be processed.
bool compareToHelix(const TrackData &trk, TrackParams &params, const std::vector< TPCClusterResiduals > &clsRes) const
std::vector< TPCClusterResiduals > & getClusterResidualsUnfiltered()
void process()
Main processing function.
void setITSClusterDictionary(const o2::itsmft::TopologyDictionary *dict)
Allow setting the ITS cluster dictionary from outside.
std::vector< UnbinnedResid > & getClusterResiduals()
TrackInterpolation & operator=(const TrackInterpolation &)=delete
void setDumpTrackPoints()
Enable full output.
void setTPCVDrift(const o2::tpc::VDriftCorrFact &v)
void setProcessITSTPConly()
Enable ITS-TPC only processing.
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)
void setSqrtS(float s)
Set the centre of mass energy required for pT downsampling Tsalis function.
bool isTrackSelected(const o2::track::TrackParCov &trk) const
Given the defined downsampling factor tsalisThreshold check if track is selected.
void reset()
Reset cache and output vectors.
bool outlierFiltering(const TrackData &trk, TrackParams &params, const std::vector< TPCClusterResiduals > &clsRes) const
void init(o2::dataformats::GlobalTrackID::mask_t src, o2::dataformats::GlobalTrackID::mask_t srcMap)
Initialize everything, set the requested track sources.
bool validateTrack(const TrackData &trk, TrackParams &params, const std::vector< TPCClusterResiduals > &clsRes) const
GLdouble n
Definition glcorearb.h:1982
GLint GLenum GLint x
Definition glcorearb.h:403
GLenum src
Definition glcorearb.h:1767
const GLdouble * v
Definition glcorearb.h:832
GLsizei GLsizei GLchar * source
Definition glcorearb.h:798
GLenum const GLfloat * params
Definition glcorearb.h:272
GLenum GLfloat param
Definition glcorearb.h:271
GLint GLuint mask
Definition glcorearb.h:291
GLdouble GLdouble GLdouble z
Definition glcorearb.h:843
constexpr int MAXGLOBALPADROW
Definition Constants.h:34
TrackParCovF TrackParCov
Definition Track.h:33
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
std::array< GTrackID, GTrackID::NSources > GlobalIDSet
Internal struct used to store the unbinned TPC cluster residuals with float values.
unsigned char dRow
distance to previous row in units of pad rows
ClassDefNV(TPCClusterResiduals, 4)
unsigned char sec
sector number 0..35
float snp
sin of the phi angle between padrow and track
Structure for the information required to associate each residual with a given track type (ITS-TPC-TR...
uint8_t nResiduals
total number of TPC residuals associated to this track
uint8_t sourceId
source ID obtained from the global track ID
uint8_t nExtDetResid
number of external detectors (wrt TPC) residuals stored, on top of clIdx.getEntries
uint32_t idxFirstResidual
the index of the first residual from this track
TrackDataCompact(uint32_t idx, uint8_t nRes, uint8_t source, uint8_t nextraRes=0)
ClassDefNV(TrackDataCompact, 2)
Heavy structure with track parameterizations + track points for debugging.
o2::dataformats::RangeReference clIdx
index of first cluster residual and total number of cluster residuals of this track
std::vector< o2::trd::CalibratedTracklet > clsTRD
the TRD space points (if available)
o2::dataformats::MatchInfoTOF matchTOF
TOF matching information.
o2::track::TrackPar trkOuter
refit of TRD and/or TOF points
o2::its::TrackITS trkITS
ITS seeding track.
uint8_t nExtDetResid
number of external detectors (to TPC) residuals stored, on top of clIdx.getEntries
o2::trd::TrackTRD trkTRD
TRD seeding track.
ClassDefNV(TrackDataExtended, 3)
std::vector< o2::trd::Tracklet64 > trkltTRD
attached TRD tracklets (if available)
o2::dataformats::GlobalTrackID gid
GID of the most global barrel track.
o2::tpc::TrackTPC trkTPC
TPC track (including dEdx information)
std::vector< o2::BaseCluster< float > > clsITS
attached ITS clusters
o2::tof::Cluster clsTOF
the TOF cluster (if available)
Structure filled for each track with track quality information and a vector with TPCClusterResiduals.
float chi2TRD
chi2 of TRD track
float dEdxTPC
TPC dEdx information.
ClassDefNV(TrackData, 9)
unsigned short nTrkltsTRD
number of attached TRD tracklets
unsigned short clAvailTOF
whether or not track seed has a matched TOF cluster, if so, gives the resolution of the T0 in ps
short TRDTrkltSlope[6]
TRD tracklet slope 0x7fff / param::MaxTRDSlope.
unsigned short nClsITS
number of attached ITS clusters
o2::dataformats::RangeReference clIdx
index of first cluster residual and total number of TPC cluster residuals of this track
float chi2TPC
chi2 of TPC track
unsigned short nClsTPC
number of attached TPC clusters
o2::dataformats::GlobalTrackID gid
global track ID for seeding track
float deltaTOF
TOFsignal - T0 - texp(PID), if T0 is available.
uint8_t nExtDetResid
number of external detectors (to TPC) residuals stored, on top of clIdx.getEntries
o2::track::TrackPar par
ITS track at inner TPC radius.
float chi2ITS
chi2 of ITS track
Structure for caching positions, covariances and angles for extrapolations from ITS and TRD/TOF and f...
Structure for on-the-fly re-calculated track parameters at the validation stage.
std::array< float, param::NPadRows > dz
std::array< float, param::NPadRows > tglArr
std::bitset< param::NPadRows > flagRej
std::array< float, param::NPadRows > dy
std::array< float, param::NPadRows > xTrk
std::array< float, param::NPadRows > zTrk
UnbinnedResid(float dyIn, float dzIn, float tgSlpIn, float yIn, float zIn, unsigned char rowIn, unsigned char secIn, short chanIn=-1)
unsigned char sec
TPC sector (0..35)
ClassDefNV(UnbinnedResid, 2)
unsigned char row
TPC pad row.
short tgSlp
tan of the phi angle between padrow and track
static void init(long timestamp=-1)
short channel
extra channel info (ITS chip ID, TRD chamber, TOF main pad within the sector)