PandaRoot
PndSttCATrackletGenerator.h
Go to the documentation of this file.
1 //****************************************************************************
2 //* This file is part of PandaRoot. *
3 //* *
4 //* PandaRoot is distributed under the terms of the *
5 //* GNU General Public License (GPL) version 3, *
6 //* copied verbatim in the file "LICENSE". *
7 //* *
8 //* Copyright (C) 2006 - 2024 FAIR GmbH and copyright holders of PandaRoot *
9 //* The copyright holders are listed in the file "COPYRIGHTHOLDERS". *
10 //* The authors are listed in the file "AUTHORS". *
11 //****************************************************************************
12 
13 /*
14  * PndSttCATrackletGenerator.h
15  *
16  * Created on: Jun 13, 2014
17  * Author: schumann
18  */
19 
20 #ifndef PNDSTTCATRACKLETGENERATOR_H_
21 #define PNDSTTCATRACKLETGENERATOR_H_
22 
23 #include "PndSttCAData.h"
24 #include "PndTrackCand.h"
25 #include "PndTrack.h"
26 #include "FairLink.h"
27 #include "MacrosForGPUComputing.h"
29 
30 class PndSttStrawMap;
31 class FairHit;
32 class PndSttSkewedHit;
33 
34 extern "C" int *EvaluateAllStates(int *, int *, int, int, int *);
35 
36 /*
37 struct TrackletInf_t {
38 
39  TrackletInf_t() :
40  numSkewed(0), startID(0), endID(0), maxID(0), straight(false), error(
41  0.0), numErrHits(0) {
42  }
43  ;
44  std::vector<int> hitIDs; // vector<hit-indices of STTHits of the tracklet>
45  int numSkewed; // number of skewed tubes
46  int startID; // tube-ID of the first tube of the tracklet
47  int endID; // tube-ID of the final tube of the tracklet
48  int maxID; // max tube-ID of all hits of the tracklet
49  bool straight;// indicates whether the tracklet runs straight from the center to border of the STT
50  double error; // sum of squared error
51  int numErrHits; // number of hits that deviate from circle by more than radius of a straw tube
52 
53  void Print() {
54  std::cout << "startId: " << startID << ", endId: " << endID
55  << ", maxId: " << maxID << ", straight: " << straight
56  << ", #hits: " << hitIDs.size() << ", numSkewed: " << numSkewed
57  << std::endl;
58  }
59  ;
60 };
61 
62 struct Combination_t {
63  std::set<int> tracklets; // status of combined tracklets
64  TrackletInf_t trackletInf; // information about the resulting tracklet
65 
66  void Print() {
67  std::cout << "combined tracklets: ";
68  for (std::set<int>::iterator it = tracklets.begin();
69  it != tracklets.end(); ++it) {
70  std::cout << *it << ", ";
71  }
72  std::cout << std::endl;
73  trackletInf.Print();
74  }
75 };
76 */
78  public:
80  : fTimeStamps(20), fBz(2.), fTUBE_RADIUS(0.5005), fDev_tubeNeighborings(nullptr), fHits(data->GetHits()), fCombinedSkewedHits(data->GetCombinedSkewedHits()),
81  fStrawMap(data->GetStrawMap()), fMapTubeIdToHit(data->GetMapTubeIdToHit()), fMapTubeIdToPos(data->GetMapTubeIdToPos()), fMapHitToFairLink(data->GetMapHitToFairLink()),
82  fHitNeighbors(data->GetHitNeighbors()), fSeparations(data->GetSeparations()), fUseGPU(false)
83  {
84  }
85 
87 
88  void SetDevTubeNeighboringsPointer(int *dev_pointer) { fDev_tubeNeighborings = dev_pointer; }
89 
90  void SetUseGPU(Bool_t val) { fUseGPU = val; }
91 
92  void FindTracks();
93 
94  /* For refitting all RiemanTracks with correctedHits (if available)*/
95  void RefitTracks();
96 
97  void PrintInfo();
98 
99  int GetNumPrimaryTracklets() { return fStartTracklets.size(); }
100 
101  /* Get TrackCands of start-tracklets (before combination)*/
102  std::vector<PndTrackCand> GetFirstTrackCands() { return fFirstTrackCand; };
103 
104  void SetBz(Double_t val) { fBz = val; };
105 
106  std::vector<Double_t> GetTimeStamps() { return fTimeStamps; };
107 
108  map<int, int> GetStates() const { return fStates; }
109  map<int, std::set<int>> GetMultiStates() const { return fMultiStates; }
110 
111  /* Method creates the tracklets by the means of a cellular automaton.*/
112  void GenerateTracklets();
113 
114  void GenerateClusters();
115 
116  private:
117  std::vector<Double_t> fTimeStamps;
118 
119  Double_t fBz;
120  double fTUBE_RADIUS;
121 
122  int *fDev_tubeNeighborings;
123  bool fUseGPU;
124 
125  std::vector<FairHit *> fHits;
126  std::multimap<int, PndSttSkewedHit *> fCombinedSkewedHits; //<(inner) Tube-ID of combined stt hits of skewed layers, corresponding hit>
127 
128  const PndSttStrawMap *fStrawMap = nullptr;
129  std::map<int, int> fMapTubeIdToHit;
130  std::map<int, TVector3> fMapTubeIdToPos;
131  std::map<int, FairLink> fMapHitToFairLink;
132 
133  map<int, vector<int>> fHitNeighbors;
134  map<int, vector<int>> fSeparations;
135 
136  map<int, int> fStates; // map<straw id, state id>
137  map<int, std::set<int>> fMultiStates; // map<straw id, set of neighboring state ids for straws with more than two neighbors
138 
139  map<int, TrackletInf_t> fStartTracklets; // map<state of start-tracklets (with more than 2 hits) generated by cellular automaton, TrackletInf>
140  map<int, TrackletInf_t> fShortTracklets; // set<state of tracklets with less than 3 hits>
141 
142  // for first step of trackfinding
143  std::vector<PndTrackCand> fFirstTrackCand; // for saving trackCands after the use of cellular automaton
144 
145  // for second step of trackfinding
146  std::vector<std::set<int>> fStateCombinations; // vector< set<state of start-tracklets that should be combined> >
147  std::vector<Combination_t> fCombinedData; // for storing combination of start-tracklets
148  std::vector<int> fTrackletsWithoutCombi; // state of tracklets that were not combined
149 
150  /* Method creates the tracklets by the means of a cellular automaton on the GPU.*/
151  void GenerateTrackletsGPU();
152 
153  /* Method update the states of each until no state change anymore.*/
154  void EvaluateState();
155 
156  /* Method update the states of each until no state change anymore. Generalization of EvaluateState()*/
157  void EvaluateState(int nNeighbors);
158 
159  /* Method update the states of tubes with more than two neighbors until no state changes anymore. */
160  void EvaluateMultiState();
161 
162  /* Method initialzises fStartTracklets with the states and trackletInf
163  * of the generated tracklets.*/
164  void InitStartTracklets();
165 
166  /* Method inserts a combination of states if not existing yet.*/
167  void InsertCombination(std::set<int> combination);
168 
169  /* Method for calculating the trackletInf for a combination of tracklets.*/
170  TrackletInf_t GetTrackletInf(std::set<int> tracklets);
171 
172  /* Method splits the start tracklets in uncombined and short tracklets*/
173  void SplitData();
174 
175  /* Method adds the unassigned hits and trackCands with 1 and 2 hits to an
176  * appropriate combination (if possible).*/
177  void AddRemainingHits();
178 
179  /* Methods adds the uncared hits with 3 and 4 hit-neighbors to the best combination
180  * of tracklets. If the nearest riemann-circle is found and the distance is
181  * smaller than the radius of a tube, the hit is added.*/
182  bool AddHitToBestCombi(int hitID);
183 
184  std::set<std::pair<int, int>> CreatePairCombis(int firstState, std::set<int> values);
185 
186  /* Method checks if a tubeID belongs to the end-tube of a tracklet.*/
187  bool IsEndTubeOfTracklet(int tubeID);
188 
189  ClassDef(PndSttCATrackletGenerator, 1);
190 };
191 
192 #endif /* PNDSTTCATRACKLETGENERATOR_H_ */
std::vector< Double_t > GetTimeStamps()
void SetDevTubeNeighboringsPointer(int *dev_pointer)
PndSttCATrackletGenerator(const PndSttCAData *data)
int * EvaluateAllStates(int *, int *, int, int, int *)
std::vector< PndTrackCand > GetFirstTrackCands()
map< int, std::set< int > > GetMultiStates() const
map< int, int > GetStates() const