CbmRoot
Loading...
Searching...
No Matches
KfpV0Finder.h
Go to the documentation of this file.
1/* Copyright (C) 2025 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Sergei Zharko [committer] */
4
9
10#pragma once
11
12#include "CbmEventTriggers.h"
13#include "KFParticleTopoReconstructor.h"
14#include "global/RecoResults.h"
16
17#include <limits>
18#include <memory>
19
20
22{
25 class V0Finder {
26 public:
29 struct ParticleInfo {
30 double fMass{std::numeric_limits<double>::quiet_NaN()}; //< Estimated mass of the particle [GeV/c2]
31 double fDca{std::numeric_limits<double>::quiet_NaN()}; //< DCA to the origin [cm]
32 double fBeta{std::numeric_limits<double>::quiet_NaN()}; //< Speed of the particle [c]
33 double fQp{std::numeric_limits<double>::quiet_NaN()}; //< q/p of the particle [GeV^-1]
34 int32_t fPdg{V0Finder::kUndefPdg}; //< PDG code
35 int32_t fCharge{0}; //< Charge of the particle
36 bool fbSelected{false}; //< The track was selected
37 };
38
39 //* Framework and physical constants (public)
40 static constexpr double kPionMass{0.13957039};
41 static constexpr double kProtonMass{0.938272088};
42 static constexpr double kSpeedOfLight{29.9792458};
43 static constexpr int32_t kUndefPdg{-2};
44
46 V0Finder() = default;
47
49 V0Finder(const V0Finder&) = delete;
50
52 V0Finder(V0Finder&&) = delete;
53
55 ~V0Finder() = default;
56
58 V0Finder& operator=(const V0Finder&) = delete;
59
62
65 void AddDecayToReconstructionList(int pdg) { GetKFParticleFinder()->AddDecayToReconstructionList(pdg); }
66
69
71 const std::array<float, 3>& GetOrigin() const { return fOrigin; }
72
74 KFParticleFinder* GetKFParticleFinder() { return fpTopoReconstructor->GetKFParticleFinder(); }
75
77 const KFParticleFinder* GetKFParticleFinder() const { return fpTopoReconstructor->GetKFParticleFinder(); }
78
80 const std::vector<ParticleInfo>& GetParticleInfo() const { return fvParticleInfo; }
81
84 double GetSelectedT0() const { return fSelectedT0; }
85
87 const std::vector<uint32_t>& GetSelectedTrackIds() const { return fvSelectedTrackIds; }
88
90 const std::vector<double>& GetT0s() const { return fvT0s; }
91
93 const std::unique_ptr<KFParticleTopoReconstructor>& GetTopoReconstructor() const { return fpTopoReconstructor; }
94
96 const auto& GetTrackAssignedParams() const { return fvTrackParam; }
97
99 void Init();
100
102 CbmEventTriggers Process(const RecoResults& recoEvent);
103
106 void SetBmonPartitionIndex(int iPartition) { fBmonPartitionIndex = iPartition; }
107
109 void SetMinPionDca(double dca) { fMinPionDca = dca; }
110
113 void SetMinProtonDca(double dca) { fMinProtonDca = dca; }
114
119 // FIXME: for now origin is defined as the target center, later it can be changed
120 void SetOrigin(double x, double y, double z) { fOrigin = {float(x), float(y), float(z)}; }
121
126 void SetPionVelocityRange(double vMin, double vMax)
127 {
130 }
131
135 void SetProtonVelocityRange(double vMin, double vMax)
136 {
139 }
140
144
147 void SetQpAssignedUncertainty(double uncertainty) { fQpAssignedUncertainty = uncertainty; }
148
151 void SetTzeroOffset(double offset) { fTzeroOffset = offset; }
152
155 void SetLCut(float cut) { GetKFParticleFinder()->SetLCut(cut); }
156
159 void SetChiPrimaryCut2D(float cut) { GetKFParticleFinder()->SetChiPrimaryCut2D(cut); }
160
163 void SetChi2Cut2D(float cut) { GetKFParticleFinder()->SetChi2Cut2D(cut); }
164
167 void SetLdLCut2D(float cut) { GetKFParticleFinder()->SetLdLCut2D(cut); }
168
169 private:
177 /* clang-format off */
178 bool AssignMomentum(const PartitionedVector<tof::Hit>& tofHits,
179 const std::vector<RecoResults::HitId_t>& tofHitIds,
180 double t0,
181 ParticleInfo& pidInfo);
182 /* clang-format on */
183
187 void AssignPid(ParticleInfo& info);
188
191 void CollectDca(const RecoResults& recoEvent);
192
197 void CollectT0(gsl::span<const bmon::Hit> bmonHits);
198
203 double EstimateBeta(const tof::Hit& tofHit, double t0) const;
204
209 double EstimateDca(const sts::Hit& fst, const sts::Hit& snd) const;
210
216 bool FindV0Candidates(const RecoResults& recoEvent, double t0);
217
221
224 static KFVertex MakeKfpPrimaryVertex(const std::array<float, 3>& r);
225
230 bool SelectTrack(const ParticleInfo& particleInfo) const;
231
238 void SetKfpTrackParameters(KFPTrackVector& kfpTrkVector, uint32_t iKfpTrk, uint32_t iCaTrk,
239 const ca::Track::TrackParam_t& trkParam, const ParticleInfo& particleInfo) const;
240
241
242 //* Framework and physical constants (private)
243 static constexpr bool kUseAverageSpeed{false};
244
246
247 //* Different run-time cuts and flags (TODO: define in a config)
248 double fTzeroOffset{0.};
249 double fMinPionDca{1.5};
250 double fMinProtonDca{0.5};
252 double fMinBetaProton{0.};
253 double fMaxBetaProton{1.};
254 double fMinBetaPion{0.};
255 double fMaxBetaPion{1.};
257
258 //* Run-time variables, provided by framework
260
261 //* Temporary data arrays (NOTE: keep them here for QA)
262 std::array<float, 3> fOrigin{0.f, 0.f, 0.f};
263 std::vector<double> fvT0s;
264 std::vector<ParticleInfo> fvParticleInfo;
265 std::vector<uint32_t> fvSelectedTrackIds;
266 double fSelectedT0{std::numeric_limits<double>::quiet_NaN()};
267
269 std::vector<std::pair<ca::Track::TrackParam_t, ca::Track::TrackParam_t>> fvTrackParam;
270
271 //* Auxilary variables
272
274 std::unique_ptr<KFParticleTopoReconstructor> fpTopoReconstructor{std::make_unique<KFParticleTopoReconstructor>()};
275 };
276} // namespace cbm::algo::kfp
TClonesArray * tracks
A structure to store different triggers in parallel to the CbmEvent (implementation)
A monitor for the V0Finder.
A structure for reconstructed results: digi-events, hits and tracks.
Class to store different triggers for a given event.
A vector that is partitioned into multiple subvectors.
TrackParam classes of different types.
A V0-finding algorithm.
Definition KfpV0Finder.h:25
const std::unique_ptr< KFParticleTopoReconstructor > & GetTopoReconstructor() const
Accessor to topology reconstructor.
Definition KfpV0Finder.h:93
double EstimateBeta(const tof::Hit &tofHit, double t0) const
Estimates speed of particle, using TOF measurement.
static constexpr bool kUseAverageSpeed
If an average speed of tof hits is used.
const V0FinderMonitorData_t & GetEventMonitor() const
Gets monitor data.
Definition KfpV0Finder.h:68
double fMinProtonDca
Minimum DCA to PV for protons.
void InitTrackParamVectors(const ca::Vector< ca::Track > &tracks)
Initializes copies of track parameter vectors.
V0Finder(const V0Finder &)=delete
Copy constructor.
void SetLdLCut2D(float cut)
Sets cut on for 2-daughter decays.
~V0Finder()=default
Destructor.
V0Finder(V0Finder &&)=delete
Move constructor.
void SetChiPrimaryCut2D(float cut)
Sets cut on of each track for 2-daughter decays.
CbmEventTriggers Process(const RecoResults &recoEvent)
Processes a reconstructed data sample, returns a collection of fired triggers.
const std::array< float, 3 > & GetOrigin() const
Gets origin.
Definition KfpV0Finder.h:71
void SetKfpTrackParameters(KFPTrackVector &kfpTrkVector, uint32_t iKfpTrk, uint32_t iCaTrk, const ca::Track::TrackParam_t &trkParam, const ParticleInfo &particleInfo) const
Sets KFP track parameters.
const std::vector< ParticleInfo > & GetParticleInfo() const
Gets a vector of particle info.
Definition KfpV0Finder.h:80
double fQpAssignedUncertainty
Assigned relative uncertainty for q/p estimation.
static constexpr int32_t kUndefPdg
PDG for tracks, which PID cannot be inferred.
Definition KfpV0Finder.h:43
double fTzeroOffset
Offset for T0.
bool SelectTrack(const ParticleInfo &particleInfo) const
Applies selection cut on the track.
V0Finder()=default
Default constructor.
std::vector< std::pair< ca::Track::TrackParam_t, ca::Track::TrackParam_t > > fvTrackParam
A copy of track parameters (first, last)
double fMinPionDca
Minimum DCA to PV for pions.
void SetMinPionDca(double dca)
void AddDecayToReconstructionList(int pdg)
Adds particle to reconstruction list.
Definition KfpV0Finder.h:65
void SetTzeroOffset(double offset)
Sets an offset to t0.
V0Finder & operator=(V0Finder &&)=delete
Move assignment operator.
std::array< float, 3 > fOrigin
Coordinates of origin [cm].
double fMinBetaPion
Minimal proton velocity (beta) [c].
void SetPrimaryAssignedPdg(int pdg)
Sets the assigned PDG for primary particles.
void SetBmonPartitionIndex(int iPartition)
Sets an address of a reference BMON diamond.
double EstimateDca(const sts::Hit &fst, const sts::Hit &snd) const
Estimate DCA of a track to origin.
double GetSelectedT0() const
Gets selected t0.
Definition KfpV0Finder.h:84
void SetLCut(float cut)
Sets cut on the distance to the primary vertex from the decay vertex.
KFParticleFinder * GetKFParticleFinder()
Mutable access to the KfParticleFinder of the run topology reconstructor.
Definition KfpV0Finder.h:74
const std::vector< uint32_t > & GetSelectedTrackIds() const
Gets indices of selected tracks.
Definition KfpV0Finder.h:87
int fBmonPartitionIndex
Index of selected partition in BMON hit vector.
bool AssignMomentum(const PartitionedVector< tof::Hit > &tofHits, const std::vector< RecoResults::HitId_t > &tofHitIds, double t0, ParticleInfo &pidInfo)
Assigns momentum based on the TOF measurement.
std::vector< double > fvT0s
Found t0s [ns] (in event)
void AssignPid(ParticleInfo &info)
Assigns PID info based on the estimated DCA.
double fSelectedT0
A t0 value selected by the lambda-finder.
int fPrimaryAssignedPdg
Assigned PDG hypothesis for primary particles.
std::vector< uint32_t > fvSelectedTrackIds
IDs of selected tracks (in event)
void SetOrigin(double x, double y, double z)
Sets origin.
double fMaxBetaPion
Maximal proton velocity (beta) [c].
void SetQpAssignedUncertainty(double uncertainty)
Assignes an uncertainty to the momentum measurement.
double fMaxBetaProton
Maximal proton velocity (beta) [c].
V0Finder & operator=(const V0Finder &)=delete
Copy assignment operator.
const auto & GetTrackAssignedParams() const
Gets track parameters.
Definition KfpV0Finder.h:96
double fMinBetaProton
Minimal proton velocity (beta) [c].
void SetMinProtonDca(double dca)
Sets minimal proton DCA to primary vertex.
void SetProtonVelocityRange(double vMin, double vMax)
Sets proton velocity range.
void SetChi2Cut2D(float cut)
Sets cut on for 2-daughter decays.
static KFVertex MakeKfpPrimaryVertex(const std::array< float, 3 > &r)
Makes a KF vertex.
V0FinderMonitorData_t fEventMonitor
Main monitor data instance.
void SetPionVelocityRange(double vMin, double vMax)
Sets minimal pion DCA to primary vertex.
std::vector< ParticleInfo > fvParticleInfo
PID info of tracks (in event)
const std::vector< double > & GetT0s() const
Gets found t0s.
Definition KfpV0Finder.h:90
void Init()
Initializes the instance (called in the beginning of the run)
std::unique_ptr< KFParticleTopoReconstructor > fpTopoReconstructor
An instance of the topology reconstructor.
static constexpr double kProtonMass
Proton mass [GeV/c2].
Definition KfpV0Finder.h:41
const KFParticleFinder * GetKFParticleFinder() const
Constant access to the KfParticleFinder of the run topology reconstructor.
Definition KfpV0Finder.h:77
static constexpr double kSpeedOfLight
Speed of light [cm/ns].
Definition KfpV0Finder.h:42
static constexpr double kPionMass
Pion mass [GeV/c2].
Definition KfpV0Finder.h:40
@ FindV0Candidates
V0-finder procedure for a given t0.
@ CollectT0
Collecting T0s.
@ CollectDca
Estimating DCAs.
A structure to keep temporary PID information for tracks.
Definition KfpV0Finder.h:29