FairShip
Loading...
Searching...
No Matches
Tracklet.cxx
Go to the documentation of this file.
1// SPDX-License-Identifier: LGPL-3.0-or-later
2// SPDX-FileCopyrightText: Copyright CERN for the benefit of the SHiP
3// Collaboration
4
5#include "Tracklet.h"
6
7#include <unordered_map>
8
9#include "strawtubesHit.h"
10#include "strawtubesPoint.h"
11
12// ----- Default constructor -------------------------------------------
13Tracklet::Tracklet() : flag(0) {}
14
15// ----- Constructor with indices -------------------------------------------
16Tracklet::Tracklet(Int_t fl, const std::vector<unsigned int>& indices)
17 : aTracklet(indices), flag(fl) {}
18
19// ----- Constructor with hits -------------------------------------------
20Tracklet::Tracklet(Int_t fl, const std::vector<strawtubesHit>& hits,
21 const std::vector<strawtubesHit>& container)
22 : flag(fl) {
23 aTracklet.reserve(hits.size());
24 for (const auto& hit : hits) {
25 // Find index of hit in container by comparing addresses
26 for (size_t i = 0; i < container.size(); ++i) {
27 if (&container[i] == &hit) {
28 aTracklet.push_back(static_cast<unsigned int>(i));
29 break;
30 }
31 }
32 }
33}
34
35// ----- Destructor ----------------------------------------------------
37// -------------------------------------------------------------------------
38
39Int_t Tracklet::link2MCTrack(std::vector<strawtubesPoint>* strawPoints,
40 Float_t min) {
41 Int_t nTot = aTracklet.size();
42 std::unordered_map<int, int> MC;
43 Int_t trackID = -1;
44 for (std::vector<int>::size_type i = 0; i != aTracklet.size(); i++) {
45 trackID = (*strawPoints)[aTracklet[i]].GetTrackID();
46 MC[trackID] += 1. / nTot;
47 if (MC[trackID] > min) {
48 break;
49 }
50 }
51 return trackID;
52}
Int_t link2MCTrack(std::vector< strawtubesPoint > *strawPoints, Float_t min)
Definition: Tracklet.cxx:39
~Tracklet() override
Definition: Tracklet.cxx:36
Tracklet()
Definition: Tracklet.cxx:13
std::vector< unsigned int > aTracklet
list of indices
Definition: Tracklet.h:50