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"
42
43// from FIT
45
46namespace o2
47{
48namespace tpc
49{
50class VDriftCorrFact;
51}
52
53namespace globaltracking
54{
55class RecoContainer;
56}
57
58namespace dataformats
59{
60template <typename TruthElement>
62}
63
64namespace globaltracking
65{
66
71 float zMin = 0; // min possible Z of this track
72 float zMax = 0; // max possible Z of this track
74 TrackLocTPCITS(const o2::track::TrackParCov& src, int tch, int tid) : o2::track::TrackParCov(src), source(tch, tid) {}
75 TrackLocTPCITS() = default;
76 ClassDefNV(TrackLocTPCITS, 1); // RS TODO: is this class needed?
77};
78
80{
81 using Geo = o2::tof::Geo;
86 using matchTrack = std::pair<o2::track::TrackParCov, timeEst>;
88
89 public:
91 void run(const o2::globaltracking::RecoContainer& inp, unsigned long firstTForbit = 0);
92
94 {
95 mIsCosmics = true;
96 mSpaceTolerance = 150;
97 mTimeTolerance = 50e3;
98 }
99
100 void setHighPurity(bool value = true) { mSetHighPurity = value; }
101
103 void print() const;
104 void printCandidatesTOF() const;
105
107 void setTimeTolerance(float val) { mTimeTolerance = val; }
109 float getTimeTolerance() const { return mTimeTolerance; }
111 void setExtraTimeToleranceTRD(float val) { mExtraTimeToleranceTRD = val; }
113 float getExtraTimeToleranceTRD() const { return mExtraTimeToleranceTRD; }
114
116 void setSpaceTolerance(float val) { mSpaceTolerance = val; }
118 float getSpaceTolerance() const { return mSpaceTolerance; }
119
121 void setSigmaTimeCut(float val) { mSigmaTimeCut = val; }
123 float getSigmaTimeCut() const { return mSigmaTimeCut; }
124
125 enum DebugFlagTypes : UInt_t {
126 MatchTreeAll = 0x1 << 1,
127 };
129 bool isDebugFlag(UInt_t flags) const { return mDBGFlags & flags; }
130
132 UInt_t getDebugFlags() const { return mDBGFlags; }
133
135 void setDebugFlag(UInt_t flag, bool on = true);
136
138 void setDebugTreeFileName(std::string name)
139 {
140 if (!name.empty()) {
141 mDebugTreeFileName = name;
142 }
143 }
144
145 std::vector<o2::dataformats::MatchInfoTOF>& getMatchedTrackVector(trkType index) { return mMatchedTracks[index]; }
146 std::vector<o2::dataformats::CalibInfoTOF>& getCalibVector() { return mCalibInfoTOF; }
147
148 std::vector<o2::dataformats::MatchInfoTOFReco>& getMatchedTracksPair(int sec) { return mMatchedTracksPairsSec[sec]; }
149
150 std::vector<o2::MCCompLabel>& getMatchedTOFLabelsVector(trkType index) { return mOutTOFLabels[index]; }
151
153 void setTPCCorrMaps(const o2::gpu::TPCFastTransformPOD* maph, float lumi);
154
155 void setFIT(bool value = true) { mIsFIT = value; }
156 static int findFITIndex(int bc, const gsl::span<const o2::ft0::RecPoints>& FITRecPoints, unsigned long firstOrbit);
157
158 void checkRefitter();
159 bool makeConstrainedTPCTrack(int matchedID, o2::dataformats::TrackTPCTOF& trConstr);
160
162 template <typename MtcInfo, typename MCInfo, typename CTrack>
163 void makeConstrainedTPCTracks(MtcInfo& mtcCont, MCInfo& MCCont, CTrack& trcCont)
164 {
165 auto nmatch = getMatchedTrackVector(o2::dataformats::MatchInfoTOFReco::TrackType::TPC).size(); // preliminary matches
166 mtcCont.reserve(nmatch);
167 trcCont.reserve(nmatch);
168 if (mMCTruthON) {
169 MCCont.reserve(nmatch);
170 }
172
175 int nconstrained = 0;
176 for (unsigned i = 0; i < nmatch; i++) {
177 auto& ctr = trcCont.emplace_back();
178 if (makeConstrainedTPCTrack(i, ctr)) {
179 mtcCont.push_back(info[i]);
180 if (mMCTruthON) {
181 MCCont.push_back(mclabs[i]);
182 }
183 nconstrained++;
184 } else {
185 trcCont.pop_back();
186 }
187 }
188 }
189
190 void setTS(unsigned long creationTime) { mTimestamp = creationTime; }
191 unsigned long getTS() const { return mTimestamp; }
192
193 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);
194 static void printGrouping(const std::vector<o2::dataformats::MatchInfoTOFReco>& origin, const std::vector<std::vector<o2::dataformats::MatchInfoTOFReco>>& grouped);
195
196 void storeMatchable(bool val = true) { mStoreMatchable = val; }
197
198 void setNlanes(int lanes) { mNlanes = lanes; }
199
200 private:
201 bool prepareFITData();
202 int prepareInteractionTimes();
203 bool prepareTPCData();
204 void propagateTPCTracks(int sec);
205 void propagateConstrTracks(int sec);
206 void addTPCSeed(const o2::tpc::TrackTPC& _tr, o2::dataformats::GlobalTrackID srcGID, float time0, float terr);
207 void addITSTPCSeed(const o2::dataformats::TrackTPCITS& _tr, o2::dataformats::GlobalTrackID srcGID, float time0, float terr);
208 void addTRDSeed(const o2::trd::TrackTRD& _tr, o2::dataformats::GlobalTrackID srcGID, float time0, float terr);
209 void addConstrainedSeed(o2::track::TrackParCov& trc, o2::dataformats::GlobalTrackID srcGID, o2::track::TrackLTIntegral intLT0, timeEst timeMUS);
210 // void addTPCTRDSeed(const o2::track::TrackParCov& _tr, o2::dataformats::GlobalTrackID srcGID, int tpcID);
211 // void addITSTPCTRDSeed(const o2::track::TrackParCov& _tr, o2::dataformats::GlobalTrackID srcGID, int tpcID);
212 bool prepareTOFClusters();
213
214 void doMatching(int sec);
215 void doMatchingForTPC(int sec);
216 void selectBestMatches(int sec);
217 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);
218 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);
219 bool propagateToRefX(o2::track::TrackParCov& trc, float xRef /*in cm*/, float stepInCm /*in cm*/, o2::track::TrackLTIntegral& intLT);
220 bool propagateToRefXWithoutCov(const o2::track::TrackParCov& trc, float xRef /*in cm*/, float stepInCm /*in cm*/, float bz);
221 bool propagateToRefXWithoutCov(const o2::track::TrackParCov& trc, float xRef /*in cm*/, float stepInCm /*in cm*/, float bz, float pos[3]);
222 void updateTL(o2::track::TrackLTIntegral& intLT, float deltal);
223
224 void updateTimeDependentParams();
225
226 static bool mHasFillScheme;
227 static bool mFillScheme[o2::constants::lhc::LHCMaxBunches];
228
229 //================================================================
230
231 // Data members
232 const o2::globaltracking::RecoContainer* mRecoCont = nullptr;
233 o2::InteractionRecord mStartIR{0, 0};
234
235 int mNlanes = 3;
236
237 // TOF matching params (work in progress)
238 const MatchTOFParams* mMatchParams = nullptr;
239
240 // for derived class
241 int mCurrTracksTreeEntry = 0;
242
243 float mXRef = Geo::RMIN;
244
245 bool mMCTruthON = false;
246
248 float mTPCVDriftRef = -1.;
249 float mTPCVDriftCorrFact = 1.;
250 float mTPCVDrift = -1.;
251 float mTPCDriftTimeOffset = 0;
252
253 float mBz = 0;
254 float mMaxInvPt = 999.;
255
256 // to be done later
257 float mTPCTBinMUS = 0.;
258 float mTPCTBinMUSInv = 0.;
259 float mTPCBin2Z = 0.;
260
261 bool mIsCosmics = false;
262 float mTimeTolerance = 1e3;
263 float mExtraTimeToleranceTRD = 500E3;
264 float mSpaceTolerance = 10;
265 float mSigmaTimeCut = 3;
266
267 bool mIsFIT = false;
268 bool mIsITSTPCused = false;
269 bool mIsTPCused = false;
270 bool mIsTPCTRDused = false;
271 bool mIsITSTPCTRDused = false;
272 bool mSetHighPurity = false;
273 bool mStoreMatchable = false;
274
275 unsigned long mTimestamp = 0;
276
277 unsigned long mFirstTForbit = 0;
278
279 // from ruben
280 gsl::span<const o2::tpc::TrackTPC> mTPCTracksArray;
281
283 // since this info is provided by external device
284 // std::vector<o2::dataformats::TrackTPCITS> mITSTPCTracksArrayInp; ///< input tracks
285 gsl::span<const Cluster> mTOFClustersArrayInp;
286
288 gsl::span<const o2::tpc::TPCClRefElem> mTPCTrackClusIdx;
289 gsl::span<const unsigned char> mTPCRefitterShMap;
290 gsl::span<const unsigned int> mTPCRefitterOccMap;
291 const o2::tpc::ClusterNativeAccess* mTPCClusterIdxStruct = nullptr;
292
293 const o2::gpu::TPCFastTransformPOD* mTPCCorrMaps = nullptr;
294 float mCTPLumi = {-1};
295 std::unique_ptr<o2::gpu::GPUO2InterfaceRefit> mTPCRefitter;
296
298
299 int mNotPropagatedToTOF[trkType::SIZE];
300
301 gsl::span<const o2::ft0::RecPoints> mFITRecPoints;
302
304
306 std::vector<matchTrack> mTracksWork[o2::constants::math::NSectors][trkType::SIZE];
307 std::vector<o2::MCCompLabel> mTracksLblWork[o2::constants::math::NSectors][trkType::SIZE];
308 std::vector<o2::track::TrackLTIntegral> mLTinfos[o2::constants::math::NSectors][trkType::SIZE];
309 std::vector<o2::dataformats::GlobalTrackID> mTrackGid[o2::constants::math::NSectors][trkType::SIZE];
311 std::array<std::vector<int>, o2::constants::math::NSectors> mTracksSectIndexCache[trkType::SIZE];
312 std::array<std::vector<int>, o2::constants::math::NSectors> mTracksSeed[trkType::SIZE];
313 std::vector<float> mVZtpcOnly[o2::constants::math::NSectors];
314
315 std::vector<float> mExtraTPCFwdTime[o2::constants::math::NSectors];
316 std::vector<Cluster> mTOFClusWork;
317 std::vector<int8_t> mSideTPC[o2::constants::math::NSectors];
318
320 std::array<std::vector<int>, o2::constants::math::NSectors> mTOFClusSectIndexCache;
321
323 std::vector<o2::dataformats::MatchInfoTOFReco> mMatchedTracksPairsSec[o2::constants::math::NSectors];
324
326 std::vector<o2::dataformats::CalibInfoTOF> mCalibInfoTOF;
327
329 //std::vector<o2::dataformats::MatchInfoTOF> mMatchedTracks;
330 std::vector<o2::dataformats::MatchInfoTOF> mMatchedTracks[trkType::SIZEALL]; // this is the output of the matching -> UNCONS, CONSTR
331 std::vector<o2::MCCompLabel> mOutTOFLabels[trkType::SIZEALL];
332
333 std::vector<int> mMatchedTracksIndex[o2::constants::math::NSectors][trkType::SIZE]; // vector of indexes of the tracks to be matched
334
335 int mNumOfClusters; // number of clusters to be matched
336 int* mMatchedClustersIndex = nullptr; //[mNumOfClusters]
337
338 std::unique_ptr<o2::utils::TreeStreamRedirector> mDBGOut;
339 UInt_t mDBGFlags = 0;
340 std::string mDebugTreeFileName = "dbg_matchTOF.root";
341
342 std::array<float, 5> mCovDiagInner{};
343 std::array<float, 5> mCovDiagOuter{};
344
346 static constexpr float MAXSNP = 0.85; // max snp of ITS or TPC track at xRef to be matched
347
348 TStopwatch mTimerTot;
349 TStopwatch mTimerMatchITSTPC;
350 TStopwatch mTimerMatchTPC;
351 TStopwatch mTimerDBG;
352 ClassDefNV(MatchTOF, 6);
353};
354} // namespace globaltracking
355} // namespace o2
356
357#endif
header::DataOrigin origin
Class to store the output of the matching to TOF for calibration.
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
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:113
bool isDebugFlag(UInt_t flags) const
get debug trees flags
Definition MatchTOF.h:129
void setExtraTimeToleranceTRD(float val)
get extra tolerance on trackTRD-TOF times comparison
Definition MatchTOF.h:111
void makeConstrainedTPCTracks(MtcInfo &mtcCont, MCInfo &MCCont, CTrack &trcCont)
Definition MatchTOF.h:163
void setTimeTolerance(float val)
get tolerance on track-TOF times comparison
Definition MatchTOF.h:107
void setSigmaTimeCut(float val)
get number of sigma used to do the matching
Definition MatchTOF.h:121
std::vector< o2::MCCompLabel > & getMatchedTOFLabelsVector(trkType index)
get vector of TOF labels of matched tracks
Definition MatchTOF.h:150
void setFIT(bool value=true)
Definition MatchTOF.h:155
std::vector< o2::dataformats::CalibInfoTOF > & getCalibVector()
Definition MatchTOF.h:146
std::vector< o2::dataformats::MatchInfoTOFReco > & getMatchedTracksPair(int sec)
Definition MatchTOF.h:148
@ MatchTreeAll
produce matching candidates tree for all candidates
Definition MatchTOF.h:126
void setDebugTreeFileName(std::string name)
Definition MatchTOF.h:138
void setHighPurity(bool value=true)
print settings
Definition MatchTOF.h:100
std::vector< o2::dataformats::MatchInfoTOF > & getMatchedTrackVector(trkType index)
Definition MatchTOF.h:145
void setTS(unsigned long creationTime)
Definition MatchTOF.h:190
void printCandidatesTOF() const
set time tolerance on track-TOF times comparison
Definition MatchTOF.cxx:279
float getSigmaTimeCut() const
Definition MatchTOF.h:123
void setTPCCorrMaps(const o2::gpu::TPCFastTransformPOD *maph, float lumi)
Definition MatchTOF.cxx:258
void storeMatchable(bool val=true)
Definition MatchTOF.h:196
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:318
unsigned long getTS() const
Definition MatchTOF.h:191
float getSpaceTolerance() const
set number of sigma used to do the matching
Definition MatchTOF.h:118
static void printGrouping(const std::vector< o2::dataformats::MatchInfoTOFReco > &origin, const std::vector< std::vector< o2::dataformats::MatchInfoTOFReco > > &grouped)
Definition MatchTOF.cxx:300
float getTimeTolerance() const
set extra time tolerance on trackTRD-TOF times comparison
Definition MatchTOF.h:109
UInt_t getDebugFlags() const
set or unset debug stream flag
Definition MatchTOF.h:132
void setNlanes(int lanes)
Definition MatchTOF.h:198
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:116
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:135
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:68
int matchID
entry (none if MinusOne) of TOF matchTOF struct in the mMatchesTOF
Definition MatchTOF.h:73
TrackLocTPCITS(const o2::track::TrackParCov &src, int tch, int tid)
Definition MatchTOF.h:74
o2::dataformats::EvIndex< int, int > source
track origin id
Definition MatchTOF.h:69
o2::math_utils::Bracket< float > timeBins
bracketing time-bins
Definition MatchTOF.h:70
LumiInfo lumi