Project
Loading...
Searching...
No Matches
Track.cxx
Go to the documentation of this file.
1// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3// All rights not expressly granted are reserved.
4//
5// This software is distributed under the terms of the GNU General Public
6// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7//
8// In applying this license CERN does not waive the privileges and immunities
9// granted to it by virtue of its status as an Intergovernmental Organization
10// or submit itself to any jurisdiction.
11
16
17#include "MCHTracking/Track.h"
18
19#include <iostream>
20
21#include "Framework/Logger.h"
22
23namespace o2
24{
25namespace mch
26{
27
28using namespace std;
29
30//__________________________________________________________________________
31Track::Track(const Track& track)
32 : mParamAtClusters(track.mParamAtClusters),
33 mCurrentParam(nullptr),
34 mCurrentChamber(-1),
35 mConnected(track.mConnected),
36 mRemovable(track.mRemovable)
37{
39}
40
41//__________________________________________________________________________
43{
48
49 // find the iterator before which the new element will be constructed
50 auto itParam = mParamAtClusters.begin();
51 for (; itParam != mParamAtClusters.end(); ++itParam) {
52 if (cluster.getZ() >= itParam->getZ()) {
53 break;
54 }
55 }
56
57 // add the new track parameters
58 mParamAtClusters.emplace(itParam);
59 --itParam;
60 itParam->setZ(cluster.getZ());
61 itParam->setClusterPtr(&cluster);
62
63 return *itParam;
64}
65
66//__________________________________________________________________________
68{
72
73 const Cluster* cluster = param.getClusterPtr();
74 if (cluster == nullptr) {
75 LOG(error) << "The TrackParam must be associated with a cluster --> not added";
76 return;
77 }
78
79 // find the iterator before which the new element will be constructed
80 auto itParam = mParamAtClusters.begin();
81 for (; itParam != mParamAtClusters.end(); ++itParam) {
82 if (cluster->getZ() >= itParam->getZ()) {
83 break;
84 }
85 }
86
87 // add the new track parameters
88 mParamAtClusters.emplace(itParam, param);
89}
90
91//__________________________________________________________________________
92int Track::getNClustersInCommon(const Track& track, int stMin, int stMax) const
93{
96
97 int chMin = 2 * stMin;
98 int chMax = 2 * stMax + 1;
99 int nClustersInCommon(0);
100
101 for (const auto& param1 : *this) {
102
103 int ch1 = param1.getClusterPtr()->getChamberId();
104 if (ch1 < chMin || ch1 > chMax) {
105 continue;
106 }
107
108 for (const auto& param2 : track) {
109
110 int ch2 = param2.getClusterPtr()->getChamberId();
111 if (ch2 < chMin || ch2 > chMax) {
112 continue;
113 }
114
115 if (param1.getClusterPtr()->uid == param2.getClusterPtr()->uid) {
116 ++nClustersInCommon;
117 break;
118 }
119 }
120 }
121
122 return nClustersInCommon;
123}
124
125//__________________________________________________________________________
126bool Track::isBetter(const Track& track) const
127{
130 int nCl1 = this->getNClusters();
131 int nCl2 = track.getNClusters();
132 return ((nCl1 > nCl2) || ((nCl1 == nCl2) && (this->first().getTrackChi2() < track.first().getTrackChi2())));
133}
134
135//__________________________________________________________________________
136void Track::tagRemovableClusters(uint8_t requestedStationMask, bool request2ChInSameSt45)
137{
140
141 // count the number of clusters in each chamber and the number of chambers fired on stations 4 and 5
142 int nClusters[10] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
143 for (auto& param : *this) {
144 ++nClusters[param.getClusterPtr()->getChamberId()];
145 }
146 int nChFiredInSt4 = (nClusters[6] > 0) ? 1 : 0;
147 if (nClusters[7] > 0) {
148 ++nChFiredInSt4;
149 }
150 int nChFiredInSt5 = (nClusters[8] > 0) ? 1 : 0;
151 if (nClusters[9] > 0) {
152 ++nChFiredInSt5;
153 }
154 int nChFiredInSt45 = nChFiredInSt4 + nChFiredInSt5;
155
156 bool removable[10] = {false, false, false, false, false, false, false, false, false, false};
157
158 // for station 1, 2 and 3, there must be at least one cluster per requested station
159 for (int iCh = 0; iCh < 6; iCh += 2) {
160 if (nClusters[iCh] + nClusters[iCh + 1] > 1 || (requestedStationMask & (1 << (iCh / 2))) == 0) {
161 removable[iCh] = removable[iCh + 1] = true;
162 }
163 }
164
165 // for station 4 and 5, there must be at least one cluster per requested station and
166 // at least 2 chambers fired (on the same station or not depending on the requirement)
167 if (nChFiredInSt45 == 4) {
168 removable[6] = removable[7] = removable[8] = removable[9] = true;
169 } else if (nChFiredInSt45 == 3) {
170 if (nChFiredInSt4 == 2 && request2ChInSameSt45) {
171 removable[6] = (nClusters[6] > 1);
172 removable[7] = (nClusters[7] > 1);
173 } else if (nClusters[6] + nClusters[7] > 1 || (requestedStationMask & 0x8) == 0) {
174 removable[6] = removable[7] = true;
175 }
176 if (nChFiredInSt5 == 2 && request2ChInSameSt45) {
177 removable[8] = (nClusters[8] > 1);
178 removable[9] = (nClusters[9] > 1);
179 } else if (nClusters[8] + nClusters[9] > 1 || (requestedStationMask & 0x10) == 0) {
180 removable[8] = removable[9] = true;
181 }
182 } else {
183 for (int iCh = 6; iCh < 10; ++iCh) {
184 removable[iCh] = (nClusters[iCh] > 1);
185 }
186 }
187
188 // tag the removable clusters
189 for (auto& param : *this) {
190 param.setRemovable(removable[param.getClusterPtr()->getChamberId()]);
191 }
192}
193
194//__________________________________________________________________________
195void Track::setCurrentParam(const TrackParam& param, int chamber)
196{
198 if (mCurrentParam) {
199 *mCurrentParam = param;
200 } else {
201 mCurrentParam = std::make_unique<TrackParam>(param);
202 }
203 mCurrentParam->setClusterPtr(nullptr);
204 mCurrentChamber = chamber;
205}
206
207//__________________________________________________________________________
209{
211 if (!mCurrentParam) {
212 mCurrentParam = std::make_unique<TrackParam>();
213 }
214 return *mCurrentParam;
215}
216
217//__________________________________________________________________________
218void Track::print() const
219{
221 mParamAtClusters.front().print();
222 cout << "\tcurrent chamber = " << mCurrentChamber + 1 << " ; clusters = {";
223 for (const auto& param : *this) {
224 cout << param.getClusterPtr()->getIdAsString() << ", ";
225 }
226 cout << "}" << endl;
227}
228
229} // namespace mch
230} // namespace o2
Definition of the MCH track for internal use.
int nClusters
track parameters for internal use
Definition TrackParam.h:34
Double_t getTrackChi2() const
return the chi2 of the track when the associated cluster was attached
Definition TrackParam.h:130
track for internal use
Definition Track.h:33
TrackParam & createParamAtCluster(const Cluster &cluster)
Definition Track.cxx:42
Track()=default
void tagRemovableClusters(uint8_t requestedStationMask, bool request2ChInSameSt45)
Definition Track.cxx:136
bool isBetter(const Track &track) const
Definition Track.cxx:126
int getNClusters() const
Return the number of attached clusters.
Definition Track.h:44
void print() const
Definition Track.cxx:218
int getNClustersInCommon(const Track &track, int stMin=0, int stMax=4) const
Definition Track.cxx:92
const TrackParam & first() const
Return a reference to the track parameters at first cluster.
Definition Track.h:50
void removable(bool removable=true)
set the flag telling if this track should be deleted
Definition Track.h:95
TrackParam & getCurrentParam()
Definition Track.cxx:208
void setCurrentParam(const TrackParam &param, int chamber)
Definition Track.cxx:195
void addParamAtCluster(const TrackParam &param)
Definition Track.cxx:67
GLenum GLfloat param
Definition glcorearb.h:271
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
Defining DataPointCompositeObject explicitly as copiable.
cluster minimal structure
Definition Cluster.h:31
double getZ() const
Return the cluster position along z as double.
Definition Cluster.h:46
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"