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
5#include "V0Trigger.h"
6
7#include <iterator>
8#include <sstream>
9
10#include <xpu/host.h>
11
12namespace cbm::algo::evbuild
13{
14
15
17 {
18
19 xpu::push_timer("V0Trigger");
20 xpu::t_add_bytes(tracks.size() * sizeof(cbm::algo::ca::Track));
21
22
23 Result result;
24
25 size_t numTracksUsed = 0;
26 for (auto trackIter1 = tracks.begin(); trackIter1 != tracks.end(); trackIter1++) {
27 if (!Select(*trackIter1, config)) continue;
28 numTracksUsed++;
29 for (auto trackIter2 = std::next(trackIter1); trackIter2 != tracks.end(); trackIter2++) {
30 if (!Select(*trackIter2, config)) continue;
31
32 // Check track time difference
33 float time1 = trackIter1->fParPV.GetTime();
34 float time2 = trackIter2->fParPV.GetTime();
35 if (time2 < time1) {
36 result.second.errTracksUnsorted++;
37 continue;
38 }
39 result.second.numTrackPairs++;
40 if (time2 - time1 > config.PairDeltaT_max()) break;
41 result.second.numTrackPairsAfterTimeCut++;
42
43 // Check PCA cuts
44 auto [zVertex, dist] = CalcPCA(trackIter1->fParPV, trackIter2->fParPV);
45 if (dist < config.PairDist_max()) {
46 result.second.numTrackPairsAfterDistCut++;
47 if (zVertex >= config.PairZ_min() && zVertex <= config.PairZ_max()) {
48 result.second.numTrackPairsAfterZCut++;
49 double tVertex = 0.5 * (time1 + time2);
50 result.first.push_back(tVertex);
51 }
52 }
53 }
54 }
55
56 result.second.time = xpu::pop_timer();
57 L_(info) << "V0Trigger: tracks " << tracks.size() << ", unsorted " << result.second.errTracksUnsorted
58 << ", used tracks " << numTracksUsed << ", track pairs " << result.second.numTrackPairs
59 << ", after time cut " << result.second.numTrackPairsAfterTimeCut << ", after dist cut "
60 << result.second.numTrackPairsAfterDistCut << ", after z cut " << result.second.numTrackPairsAfterZCut;
61 return result;
62 };
63
64
65 std::pair<double, double> V0Trigger::CalcPCA(const TrackParam& track1, const TrackParam& track2) const
66 {
67
68 // Start point and direction of first track at z = 0
69 const double ax = track1.GetX() - track1.GetTx() * track1.GetZ();
70 const double ay = track1.GetY() - track1.GetTy() * track1.GetZ();
71 const double ux = track1.GetTx();
72 const double uy = track1.GetTy();
73
74 // Start point and direction of second track at z = 0
75 const double bx = track2.GetX() - track2.GetTx() * track2.GetZ();
76 const double by = track2.GetY() - track2.GetTy() * track2.GetZ();
77 const double vx = track2.GetTx();
78 const double vy = track2.GetTy();
79
80 // Difference vectors
81 const double cx = ax - bx;
82 const double cy = ay - by;
83 const double wx = ux - vx;
84 const double wy = uy - vy;
85
86 // z coordinate at closest approach in the x-y plane
87 const double z = -1. * (cx * wx + cy * wy) / (wx * wx + wy * wy);
88
89 // Distance at closest approach in the x-y plane
90 const double dx = cx + z * wx;
91 const double dy = cy + z * wy;
92 const double dist = sqrt(dx * dx + dy * dy);
93
94 return std::make_pair(z, dist);
95 }
96
97
98 bool V0Trigger::Select(const Track& track, const V0TriggerConfig& config) const
99 {
100
101 // Minimum z at first measurement
102 if (!(track.fParFirst.Z() >= config.TrackStartZ_min())) return false;
103
104 // Maximum z at first measurement
105 if (!(track.fParFirst.Z() <= config.TrackStartZ_max())) return false;
106
107 // Minimum z at last measurement
108 if (!(track.fParLast.Z() >= config.TrackEndZ_min())) return false;
109
110 // Reject primaries
111 if (IsPrimary(track.fParPV, config)) return false;
112
113 return true;
114 };
115
116 bool V0Trigger::IsPrimary(const TrackParam& track, const V0TriggerConfig& config) const
117 {
118
119 // x coordinate of impact at target
120 if (track.X() < config.TrackImpactX_min()) return false;
121 if (track.X() > config.TrackImpactX_max()) return false;
122
123 // y coordinate of impact at target
124 if (track.Y() < config.TrackImpactY_min()) return false;
125 if (track.Y() > config.TrackImpactY_max()) return false;
126
127 return true;
128 }
129
130
131 std::string V0Trigger::ToString() const
132 {
133 std::stringstream out;
134 out << "--- Using V0Trigger ---";
135 return out.str();
136 }
137
138
139} // 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.
cbm::algo::kf::TrackParamS fParLast
Track parameters on the last station.
Definition CaTrack.h:47
cbm::algo::kf::TrackParamS fParPV
Track parameters in the primary vertex.
Definition CaTrack.h:48
cbm::algo::kf::TrackParamS fParFirst
Track parameters on the first station.
Definition CaTrack.h:46
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.
std::pair< std::vector< double >, V0TriggerMoniData > Result
Definition V0Trigger.h:45
bool Select(const Track &track, const V0TriggerConfig &config) const
Check track cuts.
Definition V0Trigger.cxx:98
std::pair< double, double > CalcPCA(const TrackParam &track1, const TrackParam &track2) const
Calculation of closest approach of two tracks (straight lines)
Definition V0Trigger.cxx:65
Result operator()(const TrackVector &tracks, const V0TriggerConfig &config) const
Execution.
Definition V0Trigger.cxx:16
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].