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
36 if (fpQa->IsActive()) {
37 fpQa->fphPairDeltaT->Fill(time2 - time1);
38 }
39
40 if (time2 < time1) {
41 result.second.errTracksUnsorted++;
42 continue;
43 }
44 result.second.numTrackPairs++;
45 if (time2 - time1 > config.PairDeltaT_max()) break;
46 result.second.numTrackPairsAfterTimeCut++;
47
48 // Check PCA cuts
49 auto [zVertex, dist] = CalcPCA(trackIter1->fParPV, trackIter2->fParPV);
50 if (fpQa->IsActive()) {
51 fpQa->fphPairZVertex->Fill(zVertex);
52 fpQa->fphPairDca->Fill(dist);
53 }
54
55 if (dist < config.PairDist_max()) {
56 result.second.numTrackPairsAfterDistCut++;
57 if (zVertex >= config.PairZ_min() && zVertex <= config.PairZ_max()) {
58 result.second.numTrackPairsAfterZCut++;
59 double tVertex = 0.5 * (time1 + time2);
60 result.first.push_back(tVertex);
61 }
62 }
63 }
64 }
65
66 result.second.time = xpu::pop_timer();
67 L_(info) << "V0Trigger: tracks " << tracks.size() << ", unsorted " << result.second.errTracksUnsorted
68 << ", used tracks " << numTracksUsed << ", track pairs " << result.second.numTrackPairs
69 << ", after time cut " << result.second.numTrackPairsAfterTimeCut << ", after dist cut "
70 << result.second.numTrackPairsAfterDistCut << ", after z cut " << result.second.numTrackPairsAfterZCut;
71 return result;
72 };
73
74
75 std::pair<double, double> V0Trigger::CalcPCA(const TrackParam& track1, const TrackParam& track2) const
76 {
77
78 // Start point and direction of first track at z = 0
79 const double ax = track1.GetX() - track1.GetTx() * track1.GetZ();
80 const double ay = track1.GetY() - track1.GetTy() * track1.GetZ();
81 const double ux = track1.GetTx();
82 const double uy = track1.GetTy();
83
84 // Start point and direction of second track at z = 0
85 const double bx = track2.GetX() - track2.GetTx() * track2.GetZ();
86 const double by = track2.GetY() - track2.GetTy() * track2.GetZ();
87 const double vx = track2.GetTx();
88 const double vy = track2.GetTy();
89
90 // Difference vectors
91 const double cx = ax - bx;
92 const double cy = ay - by;
93 const double wx = ux - vx;
94 const double wy = uy - vy;
95
96 // z coordinate at closest approach in the x-y plane
97 const double z = -1. * (cx * wx + cy * wy) / (wx * wx + wy * wy);
98
99 // Distance at closest approach in the x-y plane
100 const double dx = cx + z * wx;
101 const double dy = cy + z * wy;
102 const double dist = sqrt(dx * dx + dy * dy);
103
104 return std::make_pair(z, dist);
105 }
106
107
108 bool V0Trigger::Select(const Track& track, const V0TriggerConfig& config) const
109 {
110
111 // Minimum z at first measurement
112 if (!(track.fParFirst.Z() >= config.TrackStartZ_min())) return false;
113
114 // Maximum z at first measurement
115 if (!(track.fParFirst.Z() <= config.TrackStartZ_max())) return false;
116
117 // Minimum z at last measurement
118 if (!(track.fParLast.Z() >= config.TrackEndZ_min())) return false;
119
120 // Reject primaries
121 if (IsPrimary(track.fParPV, config)) return false;
122
123 return true;
124 };
125
126 bool V0Trigger::IsPrimary(const TrackParam& track, const V0TriggerConfig& config) const
127 {
128
129 // x coordinate of impact at target
130 if (track.X() < config.TrackImpactX_min()) return false;
131 if (track.X() > config.TrackImpactX_max()) return false;
132
133 // y coordinate of impact at target
134 if (track.Y() < config.TrackImpactY_min()) return false;
135 if (track.Y() > config.TrackImpactY_max()) return false;
136
137 return true;
138 }
139
140
141 std::string V0Trigger::ToString() const
142 {
143 std::stringstream out;
144 out << "--- Using V0Trigger ---";
145 return out.str();
146 }
147
148
149} // 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.
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.
std::pair< std::vector< double >, V0TriggerMoniData > Result
Definition V0Trigger.h:46
bool Select(const Track &track, const V0TriggerConfig &config) const
Check track cuts.
std::shared_ptr< V0TriggerQa > fpQa
Definition V0Trigger.h:97
std::pair< double, double > CalcPCA(const TrackParam &track1, const TrackParam &track2) const
Calculation of closest approach of two tracks (straight lines)
Definition V0Trigger.cxx:75
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].
TrackParam classes of different types.