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