Reconstructs tracks properties from track candidates.
159{
162 {
163
164 return StatusCode::SUCCESS;
165 }
166
167
168 std::list<const xAOD::AFPSiHitsCluster*> clustersInStation;
169 std::copy_if(
clusters->begin(),
clusters->end(), std::back_inserter(clustersInStation),
170 [this](auto cluster) { return cluster->stationID() == m_stationID; });
171
173
174
175
176 while (!clustersInStation.empty())
177 {
178
179 const auto *const initialCluster = clustersInStation.front();
180 clustersInStation.pop_front();
181
182
184
185
187 ATH_MSG_DEBUG(
"track candidate of size " << clusterOfClusters.size() <<
" did not pass selection.");
188 continue;
189 }
190
191 auto *
track = outputContainer->push_back(std::make_unique<xAOD::AFPTrack>());
192
193
195
196
197 for (const auto *const cluster : clusterOfClusters) {
198 ElementLink<xAOD::AFPSiHitsClusterContainer> clusterLink;
200 track->addCluster(clusterLink);
201 }
202
203 const int nClusters =
track->clusters().size();
204
205 if(nClusters>0)
206 {
207 track->setNClusters(nClusters);
208 }
209 else
210 {
212 outputContainer->pop_back();
213 continue;
214 }
215
216
219 double xSlope = 0.;
220 double ySlope = 0.;
222
223 if (nClusters == 1) {
224 x = (*(
track->clusters().at(0)))->xLocal();
225 y = (*(
track->clusters().at(0)))->yLocal();
226 }
227 else
228 {
229 std::vector<std::pair<double, double>> XZ;
230 std::vector<std::pair<double, double>> YZ;
231
232 for (
int i = 0;
i < nClusters;
i++) {
234
237 }
238
241
242 std::tie(
x, xSlope) = linregx;
243 std::tie(
y, ySlope) = linregy;
244
245 for (
int i = 0;
i < nClusters;
i++) {
247
248 const double z = cluster->
zLocal();
251
252 const double dx = cluster->
xLocal() - (
x + xSlope *
z);
253 const double dy = cluster->
yLocal() - (
y + ySlope *
z);
254
257 }
258 }
259
260
263 track->setXSlope(xSlope);
265 track->setYSlope(ySlope);
266 track->setZLocal(0.);
267
269
270 std::vector<int> clustersPlane{0, 0, 0, 0};
271 for (
const auto& cl :
track->clusters()) {
272 ++clustersPlane[(*cl)->pixelLayerID()];
273 }
274 auto HasNoClusters = [](
int n) {
return n == 0; };
275 track->setNHoles(std::count_if(clustersPlane.begin(), clustersPlane.end(), HasNoClusters));
276
277
279 <<
", y: " <<
track->yLocal() <<
", sx: " <<
track->xSlope()
280 <<
", sy: " <<
track->ySlope() <<
", chi2: " <<
track->chi2());
281 for (
auto&& cluster :
track->clusters())
282 {
283 ATH_MSG_DEBUG(
'\t' << (*cluster)->xLocal() <<
" " << (*cluster)->yLocal() <<
" " << (*cluster)->zLocal());
284 }
285 }
286
287 return StatusCode::SUCCESS;
288}
bool toContainedElement(BaseConstReference data, ElementType element, IProxyDict *sg=0)
Set from element pointer and a reference to the container (storable)
float zLocal() const
Cluster position along Z axis in station local coordinate system.
float yLocalErr() const
Uncertainty of cluster position along Y axis in station local coordinate system.
float xLocal() const
Cluster position along X axis in station local coordinate system.
float yLocal() const
Cluster position along Y axis in station local coordinate system.
float xLocalErr() const
Uncertainty of cluster position along X axis in station local coordinate system.
static constexpr int linReg
linear regression algorithm id=1
double chi2(TH1 *h0, TH1 *h1)
AFPSiHitsCluster_v1 AFPSiHitsCluster