Project
Loading...
Searching...
No Matches
MatchTOF.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
15
16#ifndef ALICEO2_GLOBTRACKING_MATCHTOF_
17#define ALICEO2_GLOBTRACKING_MATCHTOF_
18
19#include <Rtypes.h>
20#include <array>
21#include <vector>
22#include <string>
23#include <gsl/span>
24#include <TStopwatch.h>
34#include "TOFBase/Geo.h"
40#include "TPCFastTransform.h"
44
45// from FIT
47
48namespace o2
49{
50namespace tpc
51{
52class VDriftCorrFact;
53}
54
55namespace globaltracking
56{
57class RecoContainer;
58}
59
60namespace dataformats
61{
62template <typename TruthElement>
64}
65
66namespace globaltracking
67{
68
73 float zMin = 0; // min possible Z of this track
74 float zMax = 0; // max possible Z of this track
76 TrackLocTPCITS(const o2::track::TrackParCov& src, int tch, int tid) : o2::track::TrackParCov(src), source(tch, tid) {}
77 TrackLocTPCITS() = default;
78 ClassDefNV(TrackLocTPCITS, 1); // RS TODO: is this class needed?
79};
80
82{
83 using Geo = o2::tof::Geo;
88 using matchTrack = std::pair<o2::track::TrackParCov, timeEst>;
90
91 public:
93 void run(const o2::globaltracking::RecoContainer& inp, unsigned long firstTForbit = 0);
94
96 {
97 mIsCosmics = true;
98 mSpaceTolerance = 150;
99 mTimeTolerance = 50e3;
100 }
101
102 void setHighPurity(bool value = true) { mSetHighPurity = value; }
103
105 void print() const;
106 void printCandidatesTOF() const;
107
109 void setTimeTolerance(float val) { mTimeTolerance = val; }
111 float getTimeTolerance() const { return mTimeTolerance; }
113 void setExtraTimeToleranceTRD(float val) { mExtraTimeToleranceTRD = val; }
115 float getExtraTimeToleranceTRD() const { return mExtraTimeToleranceTRD; }
116
118 void setSpaceTolerance(float val) { mSpaceTolerance = val; }
120 float getSpaceTolerance() const { return mSpaceTolerance; }
121
123 void setSigmaTimeCut(float val) { mSigmaTimeCut = val; }
125 float getSigmaTimeCut() const { return mSigmaTimeCut; }
126
127 enum DebugFlagTypes : UInt_t {
128 MatchTreeAll = 0x1 << 1,
129 };
131 bool isDebugFlag(UInt_t flags) const { return mDBGFlags & flags; }
132
134 UInt_t getDebugFlags() const { return mDBGFlags; }
135
137 void setDebugFlag(UInt_t flag, bool on = true);
138
140 void setDebugTreeFileName(std::string name)
141 {
142 if (!name.empty()) {
143 mDebugTreeFileName = name;
144 }
145 }
146
147 std::vector<o2::dataformats::MatchInfoTOF>& getMatchedTrackVector(trkType index) { return mMatchedTracks[index]; }
148 std::vector<o2::dataformats::CalibInfoTOF>& getCalibVector() { return mCalibInfoTOF; }
149
150 std::vector<o2::dataformats::MatchInfoTOFReco>& getMatchedTracksPair(int sec) { return mMatchedTracksPairsSec[sec]; }
151
152 std::vector<o2::MCCompLabel>& getMatchedTOFLabelsVector(trkType index) { return mOutTOFLabels[index]; }
153
156
157 void setFIT(bool value = true) { mIsFIT = value; }
158 static int findFITIndex(int bc, const gsl::span<const o2::ft0::RecPoints>& FITRecPoints, unsigned long firstOrbit);
159
160 void checkRefitter();
161 bool makeConstrainedTPCTrack(int matchedID, o2::dataformats::TrackTPCTOF& trConstr);
162
164 template <typename MtcInfo, typename MCInfo, typename CTrack>
165 void makeConstrainedTPCTracks(MtcInfo& mtcCont, MCInfo& MCCont, CTrack& trcCont)
166 {
167 auto nmatch = getMatchedTrackVector(o2::dataformats::MatchInfoTOFReco::TrackType::TPC).size(); // preliminary matches
168 mtcCont.reserve(nmatch);
169 trcCont.reserve(nmatch);
170 if (mMCTruthON) {
171 MCCont.reserve(nmatch);
172 }
174
177 int nconstrained = 0;
178 for (unsigned i = 0; i < nmatch; i++) {
179 auto& ctr = trcCont.emplace_back();
180 if (makeConstrainedTPCTrack(i, ctr)) {
181 mtcCont.push_back(info[i]);
182 if (mMCTruthON) {
183 MCCont.push_back(mclabs[i]);
184 }
185 nconstrained++;
186 } else {
187 trcCont.pop_back();
188 }
189 }
190 }
191
192 void setTS(unsigned long creationTime) { mTimestamp = creationTime; }
193 unsigned long getTS() const { return mTimestamp; }
194
195 static void groupingMatch(const std::vector<o2::dataformats::MatchInfoTOFReco>& origin, std::vector<std::vector<o2::dataformats::MatchInfoTOFReco>>& grouped, std::vector<std::vector<int>>& firstEls, std::vector<std::vector<int>>& secondEls);
196 static void printGrouping(const std::vector<o2::dataformats::MatchInfoTOFReco>& origin, const std::vector<std::vector<o2::dataformats::MatchInfoTOFReco>>& grouped);
197
198 void storeMatchable(bool val = true) { mStoreMatchable = val; }
199
200 void setNlanes(int lanes) { mNlanes = lanes; }
201
202 private:
203 bool prepareFITData();
204 int prepareInteractionTimes();
205 bool prepareTPCData();
206 void propagateTPCTracks(int sec);
207 void propagateConstrTracks(int sec);
208 void addTPCSeed(const o2::tpc::TrackTPC& _tr, o2::dataformats::GlobalTrackID srcGID, float time0, float terr);
209 void addITSTPCSeed(const o2::dataformats::TrackTPCITS& _tr, o2::dataformats::GlobalTrackID srcGID, float time0, float terr);
210 void addTRDSeed(const o2::trd::TrackTRD& _tr, o2::dataformats::GlobalTrackID srcGID, float time0, float terr);
211 void addConstrainedSeed(o2::track::TrackParCov& trc, o2::dataformats::GlobalTrackID srcGID, o2::track::TrackLTIntegral intLT0, timeEst timeMUS);
212 // void addTPCTRDSeed(const o2::track::TrackParCov& _tr, o2::dataformats::GlobalTrackID srcGID, int tpcID);
213 // void addITSTPCTRDSeed(const o2::track::TrackParCov& _tr, o2::dataformats::GlobalTrackID srcGID, int tpcID);
214 bool prepareTOFClusters();
215
216 void doMatching(int sec);
217 void doMatchingForTPC(int sec);
218 void selectBestMatches(int sec);
219 void BestMatches(std::vector<o2::dataformats::MatchInfoTOFReco>& matchedTracksPairs, std::vector<o2::dataformats::MatchInfoTOF>* matchedTracks, std::vector<int>* matchedTracksIndex, int* matchedClustersIndex, const gsl::span<const o2::ft0::RecPoints>& FITRecPoints, const std::vector<Cluster>& TOFClusWork, const std::vector<matchTrack>* TracksWork, std::vector<o2::dataformats::CalibInfoTOF>& CalibInfoTOF, unsigned long Timestamp, bool MCTruthON, const o2::dataformats::MCTruthContainer<o2::MCCompLabel>* TOFClusLabels, const std::vector<o2::MCCompLabel>* TracksLblWork, std::vector<o2::MCCompLabel>* OutTOFLabels, float calibMaxChi2);
220 void BestMatchesHP(std::vector<o2::dataformats::MatchInfoTOFReco>& matchedTracksPairs, std::vector<o2::dataformats::MatchInfoTOF>* matchedTracks, std::vector<int>* matchedTracksIndex, int* matchedClustersIndex, const gsl::span<const o2::ft0::RecPoints>& FITRecPoints, const std::vector<Cluster>& TOFClusWork, std::vector<o2::dataformats::CalibInfoTOF>& CalibInfoTOF, unsigned long Timestamp, bool MCTruthON, const o2::dataformats::MCTruthContainer<o2::MCCompLabel>* TOFClusLabels, const std::vector<o2::MCCompLabel>* TracksLblWork, std::vector<o2::MCCompLabel>* OutTOFLabels);
221 bool propagateToRefX(o2::track::TrackParCov& trc, float xRef /*in cm*/, float stepInCm /*in cm*/, o2::track::TrackLTIntegral& intLT);
222 bool propagateToRefXWithoutCov(const o2::track::TrackParCov& trc, float xRef /*in cm*/, float stepInCm /*in cm*/, float bz);
223 bool propagateToRefXWithoutCov(const o2::track::TrackParCov& trc, float xRef /*in cm*/, float stepInCm /*in cm*/, float bz, float pos[3]);
224 void updateTL(o2::track::TrackLTIntegral& intLT, float deltal);
225
226 void updateTimeDependentParams();
227
228 static bool mHasFillScheme;
229 static bool mFillScheme[o2::constants::lhc::LHCMaxBunches];
230
231 //================================================================
232
233 // Data members
234 const o2::globaltracking::RecoContainer* mRecoCont = nullptr;
235 o2::InteractionRecord mStartIR{0, 0};
236
237 int mNlanes = 3;
238
239 // TOF matching params (work in progress)
240 const MatchTOFParams* mMatchParams = nullptr;
241
242 // for derived class
243 int mCurrTracksTreeEntry = 0;
244
245 float mXRef = Geo::RMIN;
246
247 bool mMCTruthON = false;
248
250 float mTPCVDriftRef = -1.;
251 float mTPCVDriftCorrFact = 1.;
252 float mTPCVDrift = -1.;
253 float mTPCDriftTimeOffset = 0;
254
255 float mBz = 0;
256 float mMaxInvPt = 999.;
257
258 // to be done later
259 float mTPCTBinMUS = 0.;
260 float mTPCTBinMUSInv = 0.;
261 float mTPCBin2Z = 0.;
262
263 bool mIsCosmics = false;
264 float mTimeTolerance = 1e3;
265 float mExtraTimeToleranceTRD = 500E3;
266 float mSpaceTolerance = 10;
267 float mSigmaTimeCut = 3;
268
269 bool mIsFIT = false;
270 bool mIsITSTPCused = false;
271 bool mIsTPCused = false;
272 bool mIsTPCTRDused = false;
273 bool mIsITSTPCTRDused = false;
274 bool mSetHighPurity = false;
275 bool mStoreMatchable = false;
276
277 unsigned long mTimestamp = 0;
278
279 unsigned long mFirstTForbit = 0;
280
281 // from ruben
282 gsl::span<const o2::tpc::TrackTPC> mTPCTracksArray;
283
285 // since this info is provided by external device
286 // std::vector<o2::dataformats::TrackTPCITS> mITSTPCTracksArrayInp; ///< input tracks
287 gsl::span<const Cluster> mTOFClustersArrayInp;
288
290 gsl::span<const o2::tpc::TPCClRefElem> mTPCTrackClusIdx;
291 gsl::span<const unsigned char> mTPCRefitterShMap;
292 gsl::span<const unsigned int> mTPCRefitterOccMap;
293 const o2::tpc::ClusterNativeAccess* mTPCClusterIdxStruct = nullptr;
294
295 o2::gpu::CorrectionMapsHelper* mTPCCorrMapsHelper = nullptr;
296 std::unique_ptr<o2::gpu::GPUO2InterfaceRefit> mTPCRefitter;
297
299
300 int mNotPropagatedToTOF[trkType::SIZE];
301
302 gsl::span<const o2::ft0::RecPoints> mFITRecPoints;
303
305
307 std::vector<matchTrack> mTracksWork[o2::constants::math::NSectors][trkType::SIZE];
308 std::vector<o2::MCCompLabel> mTracksLblWork[o2::constants::math::NSectors][trkType::SIZE];
309 std::vector<o2::track::TrackLTIntegral> mLTinfos[o2::constants::math::NSectors][trkType::SIZE];
310 std::vector<o2::dataformats::GlobalTrackID> mTrackGid[o2::constants::math::NSectors][trkType::SIZE];
312 std::array<std::vector<int>, o2::constants::math::NSectors> mTracksSectIndexCache[trkType::SIZE];
313 std::array<std::vector<int>, o2::constants::math::NSectors> mTracksSeed[trkType::SIZE];
314 std::vector<float> mVZtpcOnly[o2::constants::math::NSectors];
315
316 std::vector<float> mExtraTPCFwdTime[o2::constants::math::NSectors];
317 std::vector<Cluster> mTOFClusWork;
318 std::vector<int8_t> mSideTPC[o2::constants::math::NSectors];
319
321 std::array<std::vector<int>, o2::constants::math::NSectors> mTOFClusSectIndexCache;
322
324 std::vector<o2::dataformats::MatchInfoTOFReco> mMatchedTracksPairsSec[o2::constants::math::NSectors];
325
327 std::vector<o2::dataformats::CalibInfoTOF> mCalibInfoTOF;
328
330 //std::vector<o2::dataformats::MatchInfoTOF> mMatchedTracks;
331 std::vector<o2::dataformats::MatchInfoTOF> mMatchedTracks[trkType::SIZEALL]; // this is the output of the matching -> UNCONS, CONSTR
332 std::vector<o2::MCCompLabel> mOutTOFLabels[trkType::SIZEALL];
333
334 std::vector<int> mMatchedTracksIndex[o2::constants::math::NSectors][trkType::SIZE]; // vector of indexes of the tracks to be matched
335
336 int mNumOfClusters; // number of clusters to be matched
337 int* mMatchedClustersIndex = nullptr; //[mNumOfClusters]
338
339 std::unique_ptr<o2::utils::TreeStreamRedirector> mDBGOut;
340 UInt_t mDBGFlags = 0;
341 std::string mDebugTreeFileName = "dbg_matchTOF.root";
342
343 std::array<float, 5> mCovDiagInner{};
344 std::array<float, 5> mCovDiagOuter{};
345
347 static constexpr float MAXSNP = 0.85; // max snp of ITS or TPC track at xRef to be matched
348
349 TStopwatch mTimerTot;
350 TStopwatch mTimerMatchITSTPC;
351 TStopwatch mTimerMatchTPC;
352 TStopwatch mTimerDBG;
353 ClassDefNV(MatchTOF, 6);
354};
355} // namespace globaltracking
356} // namespace o2
357
358#endif
Class to store the output of the matching to TOF for calibration.
Helper class to access correction maps.
Definition of the TOF cluster.
particle ids, masses, names class definition
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...
uint64_t bc
Definition RawEventData.h:5
Definition of the FIT RecPoints class.
int32_t i
Global index for barrel track: provides provenance (detectors combination), index in respective array...
Class to temporary store the output of the matching to TOF in reconstruction.
Configurable params for TOF matching.
Class to perform TPC ITS matching.
uint16_t pos
Definition RawData.h:3
o2::track::TrackParCov TrackParCov
Definition Recon.h:39
Definition of TPCFastTransform class.
Result of refitting TPC-ITS matched track.
Result of refitting TPC with TOF match constraint.
void setTPCVDrift(const o2::tpc::VDriftCorrFact &v)
Definition MatchTOF.cxx:249
float getExtraTimeToleranceTRD() const
set space tolerance on track-TOF times comparison // this in the old AliRoot was the TOF matching win...
Definition MatchTOF.h:115
bool isDebugFlag(UInt_t flags) const
get debug trees flags
Definition MatchTOF.h:131
void setExtraTimeToleranceTRD(float val)
get extra tolerance on trackTRD-TOF times comparison
Definition MatchTOF.h:113
void makeConstrainedTPCTracks(MtcInfo &mtcCont, MCInfo &MCCont, CTrack &trcCont)
Definition MatchTOF.h:165
void setTimeTolerance(float val)
get tolerance on track-TOF times comparison
Definition MatchTOF.h:109
void setSigmaTimeCut(float val)
get number of sigma used to do the matching
Definition MatchTOF.h:123
std::vector< o2::MCCompLabel > & getMatchedTOFLabelsVector(trkType index)
get vector of TOF labels of matched tracks
Definition MatchTOF.h:152
void setFIT(bool value=true)
Definition MatchTOF.h:157
std::vector< o2::dataformats::CalibInfoTOF > & getCalibVector()
Definition MatchTOF.h:148
void setTPCCorrMaps(o2::gpu::CorrectionMapsHelper *maph)
Definition MatchTOF.cxx:258
std::vector< o2::dataformats::MatchInfoTOFReco > & getMatchedTracksPair(int sec)
Definition MatchTOF.h:150
@ MatchTreeAll
produce matching candidates tree for all candidates
Definition MatchTOF.h:128
void setDebugTreeFileName(std::string name)
Definition MatchTOF.h:140
void setHighPurity(bool value=true)
print settings
Definition MatchTOF.h:102
std::vector< o2::dataformats::MatchInfoTOF > & getMatchedTrackVector(trkType index)
Definition MatchTOF.h:147
void setTS(unsigned long creationTime)
Definition MatchTOF.h:192
void printCandidatesTOF() const
set time tolerance on track-TOF times comparison
Definition MatchTOF.cxx:278
float getSigmaTimeCut() const
Definition MatchTOF.h:125
void storeMatchable(bool val=true)
Definition MatchTOF.h:198
void run(const o2::globaltracking::RecoContainer &inp, unsigned long firstTForbit=0)
< perform matching for provided input
Definition MatchTOF.cxx:67
void setDebugFlag(UInt_t flag, bool on=true)
set the name of output debug file
static void groupingMatch(const std::vector< o2::dataformats::MatchInfoTOFReco > &origin, std::vector< std::vector< o2::dataformats::MatchInfoTOFReco > > &grouped, std::vector< std::vector< int > > &firstEls, std::vector< std::vector< int > > &secondEls)
Definition MatchTOF.cxx:317
unsigned long getTS() const
Definition MatchTOF.h:193
float getSpaceTolerance() const
set number of sigma used to do the matching
Definition MatchTOF.h:120
static void printGrouping(const std::vector< o2::dataformats::MatchInfoTOFReco > &origin, const std::vector< std::vector< o2::dataformats::MatchInfoTOFReco > > &grouped)
Definition MatchTOF.cxx:299
float getTimeTolerance() const
set extra time tolerance on trackTRD-TOF times comparison
Definition MatchTOF.h:111
UInt_t getDebugFlags() const
set or unset debug stream flag
Definition MatchTOF.h:134
void setNlanes(int lanes)
Definition MatchTOF.h:200
static int findFITIndex(int bc, const gsl::span< const o2::ft0::RecPoints > &FITRecPoints, unsigned long firstOrbit)
void setSpaceTolerance(float val)
get tolerance on track-TOF times comparison
Definition MatchTOF.h:118
bool makeConstrainedTPCTrack(int matchedID, o2::dataformats::TrackTPCTOF &trConstr)
populate externally provided container by TOF-time-constrained TPC tracks
Cluster class for TOF.
Definition Cluster.h:37
TOF geo parameters (only statics)
Definition Geo.h:28
static constexpr Float_t RMIN
Definition Geo.h:133
GLenum src
Definition glcorearb.h:1767
const GLdouble * v
Definition glcorearb.h:832
GLuint index
Definition glcorearb.h:781
GLuint const GLchar * name
Definition glcorearb.h:781
GLsizei GLsizei GLchar * source
Definition glcorearb.h:798
GLsizei const GLfloat * value
Definition glcorearb.h:819
GLuint GLfloat * val
Definition glcorearb.h:1582
GLbitfield flags
Definition glcorearb.h:1570
constexpr int LHCMaxBunches
constexpr int NSectors
constexpr int MinusOne
TrackParCovF TrackParCov
Definition Track.h:33
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
< original track in the currently loaded TPC-ITS reco output
Definition MatchTOF.h:70
int matchID
entry (none if MinusOne) of TOF matchTOF struct in the mMatchesTOF
Definition MatchTOF.h:75
TrackLocTPCITS(const o2::track::TrackParCov &src, int tch, int tid)
Definition MatchTOF.h:76
o2::dataformats::EvIndex< int, int > source
track origin id
Definition MatchTOF.h:71
o2::math_utils::Bracket< float > timeBins
bracketing time-bins
Definition MatchTOF.h:72