forked from AliceO2Group/AliceO2
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSVertexer.h
More file actions
251 lines (226 loc) · 9 KB
/
SVertexer.h
File metadata and controls
251 lines (226 loc) · 9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
// All rights not expressly granted are reserved.
//
// This software is distributed under the terms of the GNU General Public
// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
//
// In applying this license CERN does not waive the privileges and immunities
// granted to it by virtue of its status as an Intergovernmental Organization
// or submit itself to any jurisdiction.
/// \file SVertexer.h
/// \brief Secondary vertex finder
/// \author ruben.shahoyan@cern.ch
#ifndef O2_S_VERTEXER_H
#define O2_S_VERTEXER_H
#define _DBGMC_SVERTEXER_
#include "gsl/span"
#include "DataFormatsCalibration/MeanVertexObject.h"
#include "DataFormatsGlobalTracking/RecoContainer.h"
#include "ReconstructionDataFormats/PrimaryVertex.h"
#include "ReconstructionDataFormats/V0.h"
#include "ReconstructionDataFormats/Cascade.h"
#include "ReconstructionDataFormats/Decay3Body.h"
#include "ReconstructionDataFormats/DecayNBodyIndex.h"
#include "ReconstructionDataFormats/VtxTrackIndex.h"
#include "ReconstructionDataFormats/VtxTrackRef.h"
#include "CommonDataFormat/RangeReference.h"
#include "DataFormatsTPC/ClusterNativeHelper.h"
#include "DCAFitter/DCAFitterN.h"
#include "DetectorsVertexing/SVertexerParams.h"
#include "DetectorsVertexing/SVertexHypothesis.h"
#include "StrangenessTracking/StrangenessTracker.h"
#include "DataFormatsTPC/TrackTPC.h"
#include <numeric>
#include <algorithm>
#include "GPUO2InterfaceRefit.h"
#include "TPCFastTransform.h"
#include "DataFormatsTPC/PIDResponse.h"
namespace o2
{
namespace tpc
{
class VDriftCorrFact;
}
namespace gpu
{
class CorrectionMapsHelper;
}
namespace vertexing
{
class SVertexer
{
public:
using GIndex = o2::dataformats::VtxTrackIndex;
using VRef = o2::dataformats::VtxTrackRef;
using PVertex = const o2::dataformats::PrimaryVertex;
using V0 = o2::dataformats::V0;
using V0Index = o2::dataformats::V0Index;
using Cascade = o2::dataformats::Cascade;
using CascadeIndex = o2::dataformats::CascadeIndex;
using Decay3Body = o2::dataformats::Decay3Body;
using Decay3BodyIndex = o2::dataformats::Decay3BodyIndex;
using RRef = o2::dataformats::RangeReference<int, int>;
using VBracket = o2::math_utils::Bracket<int>;
using PIDResponse = o2::tpc::PIDResponse;
enum HypV0 { Photon,
K0,
Lambda,
AntiLambda,
HyperTriton,
AntiHyperTriton,
Hyperhydrog4,
AntiHyperhydrog4,
NHypV0 };
enum HypCascade {
XiMinus,
OmegaMinus,
NHypCascade
};
enum Hyp3body {
H3L3body,
AntiH3L3body,
H4L3body,
AntiH4L3body,
He4L3body,
AntiHe4L3body,
He5L3body,
AntiHe5L3body,
NHyp3body
};
static constexpr int POS = 0, NEG = 1;
struct TrackCand : o2::track::TrackParCov {
GIndex gid{};
VBracket vBracket{};
float minR = 0; // track lowest point r
bool hasTPC = false;
int8_t nITSclu = -1;
bool compatibleProton = false; // dE/dx compatibility with proton hypothesis (FIXME: use better, uint8_t compat mask?)
bool hasITS() const
{
return nITSclu > 0;
}
};
SVertexer(bool enabCascades = true, bool enab3body = false) : mEnableCascades{enabCascades}, mEnable3BodyDecays{enab3body}
{
}
void setEnableCascades(bool v) { mEnableCascades = v; }
void setEnable3BodyDecays(bool v) { mEnable3BodyDecays = v; }
void init();
void process(const o2::globaltracking::RecoContainer& recoTracks, o2::framework::ProcessingContext& pc);
void produceOutput(o2::framework::ProcessingContext& pc);
int getNV0s() const { return mNV0s; }
int getNCascades() const { return mNCascades; }
int getN3Bodies() const { return mN3Bodies; }
int getNStrangeTracks() const { return mNStrangeTracks; }
auto& getMeanVertex() const { return mMeanVertex; }
void setMeanVertex(const o2::dataformats::MeanVertexObject* v)
{
if (v == nullptr) {
return;
}
mMeanVertex = v->getMeanVertex();
}
void setNThreads(int n);
int getNThreads() const { return mNThreads; }
void setUseMC(bool v) { mUseMC = v; }
bool getUseMC() const { return mUseMC; }
void setTPCTBin(int nbc)
{
// set TPC time bin in BCs
mMUS2TPCBin = 1.f / (nbc * o2::constants::lhc::LHCBunchSpacingMUS);
}
void setTPCVDrift(const o2::tpc::VDriftCorrFact& v);
void setTPCCorrMaps(o2::gpu::CorrectionMapsHelper* maph);
void setStrangenessTracker(o2::strangeness_tracking::StrangenessTracker* tracker) { mStrTracker = tracker; }
o2::strangeness_tracking::StrangenessTracker* getStrangenessTracker() { return mStrTracker; }
std::array<size_t, 3> getNFitterCalls() const;
void setSources(GIndex::mask_t src) { mSrc = src; }
private:
template <class TVI, class TCI, class T3I, class TR>
void extractPVReferences(const TVI& v0s, TR& vtx2V0Refs, const TCI& cascades, TR& vtx2CascRefs, const T3I& vtxs3, TR& vtx2body3Refs);
bool checkV0(const TrackCand& seed0, const TrackCand& seed1, int iP, int iN, int ithread);
int checkCascades(const V0Index& v0Idx, const V0& v0, float rv0, std::array<float, 3> pV0, float p2V0, int avoidTrackID, int posneg, VBracket v0vlist, int ithread);
int check3bodyDecays(const V0Index& v0Idx, const V0& v0, float rv0, std::array<float, 3> pV0, float p2V0, int avoidTrackID, int posneg, VBracket v0vlist, int ithread);
void setupThreads();
void buildT2V(const o2::globaltracking::RecoContainer& recoTracks);
void updateTimeDependentParams();
bool acceptTrack(const GIndex gid, const o2::track::TrackParCov& trc) const;
bool processTPCTrack(const o2::tpc::TrackTPC& trTPC, GIndex gid, int vtxid);
float correctTPCTrack(TrackCand& trc, const o2::tpc::TrackTPC& tTPC, float tmus, float tmusErr) const;
uint64_t getPairIdx(GIndex id1, GIndex id2) const
{
return (uint64_t(id1) << 32) | id2;
}
const o2::globaltracking::RecoContainer* mRecoCont = nullptr;
GIndex::mask_t mSrc{};
const o2::tpc::ClusterNativeAccess* mTPCClusterIdxStruct = nullptr; ///< struct holding the TPC cluster indices
gsl::span<const o2::tpc::TrackTPC> mTPCTracksArray; ///< input TPC tracks span
gsl::span<const o2::tpc::TPCClRefElem> mTPCTrackClusIdx; ///< input TPC track cluster indices span
gsl::span<const unsigned char> mTPCRefitterShMap; ///< externally set TPC clusters sharing map
gsl::span<const unsigned int> mTPCRefitterOccMap; ///< externally set TPC clusters occupancy map
o2::gpu::CorrectionMapsHelper* mTPCCorrMapsHelper = nullptr;
std::unique_ptr<o2::gpu::GPUO2InterfaceRefit> mTPCRefitter; ///< TPC refitter used for TPC tracks refit during the reconstruction
o2::strangeness_tracking::StrangenessTracker* mStrTracker = nullptr;
gsl::span<const PVertex> mPVertices;
std::vector<std::vector<V0>> mV0sTmp;
std::vector<std::vector<Cascade>> mCascadesTmp;
std::vector<std::vector<Decay3Body>> m3bodyTmp;
std::vector<std::vector<V0Index>> mV0sIdxTmp;
std::vector<std::vector<CascadeIndex>> mCascadesIdxTmp;
std::vector<std::vector<Decay3BodyIndex>> m3bodyIdxTmp;
std::array<std::vector<TrackCand>, 2> mTracksPool{}; // pools of positive and negative seeds sorted in min VtxID
std::array<std::vector<int>, 2> mVtxFirstTrack{}; // 1st pos. and neg. track of the pools for each vertex
o2::dataformats::VertexBase mMeanVertex{{0., 0., 0.}, {0.1 * 0.1, 0., 0.1 * 0.1, 0., 0., 6. * 6.}};
const SVertexerParams* mSVParams = nullptr;
std::array<SVertexHypothesis, NHypV0> mV0Hyps;
std::array<SVertexHypothesis, NHypCascade> mCascHyps;
std::array<SVertex3Hypothesis, NHyp3body> m3bodyHyps;
std::vector<DCAFitterN<2>> mFitterV0;
std::vector<DCAFitterN<2>> mFitterCasc;
std::vector<DCAFitterN<3>> mFitter3body;
#ifdef _DBGMC_SVERTEXER_
bool mWatchHit = false;
bool mWatchHitVtxOK = false;
std::string mWatchHitRep{};
o2::MCCompLabel mWatchLb;
std::vector<o2::MCCompLabel> mWatchLblVec;
bool checkLbl(o2::MCCompLabel& l) const
{
for (auto lb : mWatchLblVec) {
if (lb == l) {
return true;
}
}
return false;
}
#endif
PIDResponse mPIDresponse;
int mNThreads = 1;
int mNV0s = 0, mNCascades = 0, mN3Bodies = 0, mNStrangeTracks = 0;
float mBz = 0;
float mMinR2ToMeanVertex = 0;
float mMaxDCAXY2ToMeanVertex = 0;
float mMaxDCAXY2ToMeanVertexV0Casc = 0;
float mMaxDCAXY2ToMeanVertex3bodyV0 = 0;
float mMinR2DiffV0Casc = 0;
float mMaxR2ToMeanVertexCascV0 = 0;
float mMinPt2V0 = 1e-6;
float mMaxTgl2V0 = 2. * 2.;
float mMinPt2Casc = 1e-4;
float mMaxTgl2Casc = 2. * 2.;
float mMinPt23Body = 1e-4;
float mMaxTgl23Body = 2.f * 2.f;
float mMUS2TPCBin = 1.f / (8 * o2::constants::lhc::LHCBunchSpacingMUS);
float mTPCBin2Z = 0;
float mTPCVDrift = 0;
float mTPCVDriftCorrFact = 1.; ///< TPC nominal correction factort (wrt ref)
float mTPCVDriftRef = 0;
float mTPCDriftTimeOffset = 0; ///< drift time offset in mus
bool mEnableCascades = true;
bool mEnable3BodyDecays = false;
bool mUseMC = false;
};
} // namespace vertexing
} // namespace o2
#endif