CbmRoot
Loading...
Searching...
No Matches
V0Trigger.cxx
Go to the documentation of this file.
1/* Copyright (C) 2021 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Volker Friese [committer], Dominik Smith */
4
6
8
9#include <iterator>
10#include <sstream>
11
12#include <xpu/host.h>
13
14namespace cbm::algo::evbuild
15{
16
17
19 {
20
21 xpu::push_timer("V0Trigger");
22 xpu::t_add_bytes(tracks.size() * sizeof(cbm::algo::ca::Track));
23
24
25 Result result;
26
27 size_t numTracksUsed = 0;
28 for (auto trackIter1 = tracks.begin(); trackIter1 != tracks.end(); trackIter1++) {
29 if (!Select(*trackIter1, config)) continue;
30 numTracksUsed++;
31 for (auto trackIter2 = std::next(trackIter1); trackIter2 != tracks.end(); trackIter2++) {
32 if (!Select(*trackIter2, config)) continue;
33
34 // Check track time difference
35 float time1 = trackIter1->fParPV.GetTime();
36 float time2 = trackIter2->fParPV.GetTime();
37
38 if (fpQa->IsActive()) {
39 fpQa->fphPairDeltaT->Fill(time2 - time1);
40 }
41
42 if (time2 < time1) {
43 result.second.errTracksUnsorted++;
44 continue;
45 }
46 result.second.numTrackPairs++;
47 if (time2 - time1 > config.PairDeltaT_max()) break;
48 result.second.numTrackPairsAfterTimeCut++;
49
50 // Check PCA cuts
51 auto [zVertex, dist] = CalcPCA(trackIter1->fParPV, trackIter2->fParPV);
52 if (fpQa->IsActive()) {
53 fpQa->fphPairZVertex->Fill(zVertex);
54 fpQa->fphPairDca->Fill(dist);
55 }
56
57 if (dist < config.PairDist_max()) {
58 result.second.numTrackPairsAfterDistCut++;
59 if (zVertex >= config.PairZ_min() && zVertex <= config.PairZ_max()) {
60 result.second.numTrackPairsAfterZCut++;
61 double tVertex = 0.5 * (time1 + time2);
62 result.first.push_back(tVertex);
63 if (fpQa->IsActive()) {
64 fpQa->fphSelPairDeltaT->Fill(time2 - time1);
65 fpQa->fphSelPairZVertex->Fill(zVertex);
66 fpQa->fphSelPairDca->Fill(dist);
67 }
68 }
69 }
70 }
71 }
72
73 result.second.time = xpu::pop_timer();
74 L_(info) << "V0Trigger: tracks " << tracks.size() << ", unsorted " << result.second.errTracksUnsorted
75 << ", used tracks " << numTracksUsed << ", track pairs " << result.second.numTrackPairs
76 << ", after time cut " << result.second.numTrackPairsAfterTimeCut << ", after dist cut "
77 << result.second.numTrackPairsAfterDistCut << ", after z cut " << result.second.numTrackPairsAfterZCut;
78 return result;
79 };
80
81
82 std::pair<double, double> V0Trigger::CalcPCA(const TrackParam& track1, const TrackParam& track2) const
83 {
84
85 // Start point and direction of first track at z = 0
86 const double ax = track1.GetX() - track1.GetTx() * track1.GetZ();
87 const double ay = track1.GetY() - track1.GetTy() * track1.GetZ();
88 const double ux = track1.GetTx();
89 const double uy = track1.GetTy();
90
91 // Start point and direction of second track at z = 0
92 const double bx = track2.GetX() - track2.GetTx() * track2.GetZ();
93 const double by = track2.GetY() - track2.GetTy() * track2.GetZ();
94 const double vx = track2.GetTx();
95 const double vy = track2.GetTy();
96
97 // Difference vectors
98 const double cx = ax - bx;
99 const double cy = ay - by;
100 const double wx = ux - vx;
101 const double wy = uy - vy;
102
103 // z coordinate at closest approach in the x-y plane
104 const double z = -1. * (cx * wx + cy * wy) / (wx * wx + wy * wy);
105
106 // Distance at closest approach in the x-y plane
107 const double dx = cx + z * wx;
108 const double dy = cy + z * wy;
109 const double dist = sqrt(dx * dx + dy * dy);
110
111 return std::make_pair(z, dist);
112 }
113
114
115 bool V0Trigger::Select(const Track& track, const V0TriggerConfig& config) const
116 {
117
118 // Minimum z at first measurement
119 if (!(track.fParFirst.Z() >= config.TrackStartZ_min())) return false;
120
121 // Maximum z at first measurement
122 if (!(track.fParFirst.Z() <= config.TrackStartZ_max())) return false;
123
124 // Minimum z at last measurement
125 if (!(track.fParLast.Z() >= config.TrackEndZ_min())) return false;
126
127 // Reject primaries
128 if (IsPrimary(track.fParPV, config)) return false;
129
130 return true;
131 };
132
133 bool V0Trigger::IsPrimary(const TrackParam& track, const V0TriggerConfig& config) const
134 {
135
136 // x coordinate of impact at target
137 if (track.X() < config.TrackImpactX_min()) return false;
138 if (track.X() > config.TrackImpactX_max()) return false;
139
140 // y coordinate of impact at target
141 if (track.Y() < config.TrackImpactY_min()) return false;
142 if (track.Y() > config.TrackImpactY_max()) return false;
143
144 return true;
145 }
146
147
148 std::string V0Trigger::ToString() const
149 {
150 std::stringstream out;
151 out << "--- Using V0Trigger ---";
152 return out.str();
153 }
154
155
156} // namespace cbm::algo::evbuild
#define L_(level)
TClonesArray * tracks
friend fvec sqrt(const fvec &a)
Class representing an output track in the CA tracking algorithm.
Definition CaTrack.h:28
TrackParam_t fParFirst
Track parameters on the first station.
Definition CaTrack.h:48
TrackParam_t fParPV
Track parameters in the primary vertex.
Definition CaTrack.h:50
TrackParam_t fParLast
Track parameters on the last station.
Definition CaTrack.h:49
Configuration of the V0 trigger class (trigger on displaced vertices)
double TrackImpactY_min() const
Minimum y of track impact in target plane.
double TrackImpactX_max() const
Maximum x of track impact in target plane.
double PairDist_max() const
Maximum distance at closest approach.
double TrackImpactY_max() const
Maximum y of track impact in target plane.
double PairDeltaT_max() const
Maximum time difference of tracks.
double PairZ_max() const
Maximum z of PCA.
double TrackEndZ_min() const
Minimum z at last track measurement.
double TrackStartZ_min() const
Minimum z at first track measurement.
double TrackStartZ_max() const
Maximum z at first track measurement.
double PairZ_min() const
Minimum z of PCA.
double TrackImpactX_min() const
Minimum x of track impact in target plane.
cbm::algo::ca::Vector< cbm::algo::ca::Track > TrackVector
Definition V0Trigger.h:48
cbm::algo::kf::TrackParamS TrackParam
Definition V0Trigger.h:49
bool Select(const Track &track, const V0TriggerConfig &config) const
Check track cuts.
std::pair< std::vector< double >, V0TriggerMoniData > Result
Definition V0Trigger.h:46
std::shared_ptr< V0TriggerQa > fpQa
Definition V0Trigger.h:97
cbm::algo::ca::Track Track
Definition V0Trigger.h:47
std::pair< double, double > CalcPCA(const TrackParam &track1, const TrackParam &track2) const
Calculation of closest approach of two tracks (straight lines)
Definition V0Trigger.cxx:82
Result operator()(const TrackVector &tracks, const V0TriggerConfig &config) const
Execution.
Definition V0Trigger.cxx:18
bool IsPrimary(const TrackParam &track, const V0TriggerConfig &config) const
Check if track is a priomary.
std::string ToString() const
Info to string.
T GetTy() const
Gets slope along y-axis.
T GetZ() const
Gets z position [cm].
T X() const
Gets x position [cm].
T GetTx() const
Gets slope along x-axis.
T Y() const
Gets y position [cm].
T Z() const
Gets z position [cm].
T GetY() const
Gets y position [cm].
T GetX() const
Gets x position [cm].