PandaRoot
PndSttHitCorrector.h
Go to the documentation of this file.
1 /*
2  * PndSttHitCorrector.h
3  *
4  * Created on: May 20, 2014
5  * Author: schumann
6  */
7 
8 #ifndef PNDSTTHITCORRECTOR_H_
9 #define PNDSTTHITCORRECTOR_H_
10 
12 #include "FairHit.h"
13 #include "FairLink.h"
14 #include "TMath.h"
15 
16 class PndSttStrawMap;
17 class PndSttGeometryMap;
18 class PndSttHit;
19 
21  public:
23  : fVerbose(0), fHits(data->GetHits()), fStrawMap(data->GetStrawMap()), fGeometryMap(data->GetGeometryMap()), fMapTubeIdToHit(data->GetMapTubeIdToHit()),
24  fHitNeighbors(data->GetHitNeighborsWithoutSkewed()), fSeparations(data->GetSeparationsWithoutSkewed()), fMinIsochrone(0.1), fIsochroneEquality(0.8),
25  fDeltaDiff(TMath::DegToRad() * 20), fMaxDiffBetweenAngles(TMath::DegToRad() * 15)
26  {
27  }
29  {
30  for (std::map<int, FairHit *>::iterator it = fCorrectedIsochrones.begin(); it != fCorrectedIsochrones.end(); ++it) {
31  delete (*it).second;
32  }
33  }
34 
35  void SetVerbose(Int_t verbose) { fVerbose = verbose; }
36 
37  void PrintTangentAngles();
38 
39  /* Method that calculates better hit-positions by means of the isochrones.*/
40  void CorrectHits();
41 
42  std::map<int, FairHit *> GetCorrectedHits() { return fCorrectedIsochrones; }
43 
44  private:
45  Int_t fVerbose;
46 
47  std::vector<FairHit *> fHits;
48  const PndSttStrawMap *fStrawMap;
49  const PndSttGeometryMap *fGeometryMap;
50  std::map<int, int> fMapTubeIdToHit;
51  std::map<int, std::vector<int>> fHitNeighbors;
52  std::map<int, std::vector<int>> fSeparations;
53 
54  std::map<int, std::set<double>> fTangentAngles; // map<tube-ID, tangent angle of isochrone (suitable for track)>
55  std::map<int, FairHit *> fCorrectedIsochrones; //< hit-index, corrected hit position>
56 
57  double fMinIsochrone; // Isochrone radius off which the corrected point is set to to the midpoint
58  double fIsochroneEquality; //
59  double fDeltaDiff; // max difference of angles (radian) for whom the average is taken
60  double fMaxDiffBetweenAngles; // up to this difference tangent angles are rated as equal
61 
62  /* Calculates angles of possible tangents between the isochrones of two hits*/
63  std::vector<double> CalculateTangentAngles(PndSttHit *tube1, PndSttHit *tube2);
64 
65  /* Method returns the tubeID of the hit-neighbor that lies in the middle of the other hit-neighbors
66  * of the given tube. Condition: the given tube has 3 hit-neighbors that are adjacent to each other
67  * (angles of 60 degree) */
68  int GetMiddleHitNeighbor(int tubeID);
69 
70  /* Method returns the tubeIDs of the neighbors, that form a straight line with the given tube.*/
71  std::pair<int, int> GetStraightNeighbors(int tubeID);
72 
73  /* Method searches for the best combination of angles (best match). Parameter: several vectors of angles.
74  * Each angle is compared with all angles of the other vectors. Based on the calculation of the classification
75  * 2 angles are returned maximally. */
76  std::set<double> GetBestCombinatedPhi(const std::vector<std::vector<double>> &angles);
77 
78  /* Method calculates the distances between the angles of all vectors. It returns the calculated differences
79  * and the smallest difference with the corresponding index-pair (for each pair of angles of different vectors)*/
80  void CalcDifferencesBetweenAngles(const std::vector<std::vector<double>> &angles, std::vector<std::vector<std::vector<double>>> &retDifferences,
81  std::vector<std::vector<double>> &retSmallestDiff, std::vector<std::vector<std::pair<int, int>>> &retPairsOfSmallest);
82 
83  /* Methods calculate the classification-values for the assessment of the smallest differences between the angles.
84  * classification-value = 1 - (smallest_diffrence / sum_of_all_smallest_diffrences). The higher the
85  * classification-value, the better the pair of angles. */
86  std::vector<std::vector<double>> CalcClassification(const std::vector<std::vector<double>> &smallestDiff);
87 
88  std::vector<std::vector<double>> CalcClassification(const std::vector<std::vector<std::vector<double>>> &differences);
89 
90  /* Method creates new FairHits (in fCorrectedIsochrones) based on the calculated tangent angles. (if available)*/
91  void CorrectIsochrones();
92 
93  void KeepBestAngle(int tubeID, double angle);
94 
95  double GetDiffBetweenAngles(double angle1, double angle2);
96 
97  double GetAverageOfAngles(double angle1, double angle2);
98 
99  double GetBestFittingAngle(double angle, std::set<double> anglesToTest);
100 
101  /* Method checks whether the tubes signal a hit and are neighbors.*/
102  bool AreHitNeihbors(int tubeID1, int tubeID2);
103 
104  /* Method checks if an unambiguous angle was calculated for the tube*/
105  bool HasUnambiguousAngle(int tubeID);
106 
107  ClassDef(PndSttHitCorrector, 1);
108 };
109 
110 #endif /* PNDSTTHITCORRECTOR_H_ */
std::map< int, FairHit * > GetCorrectedHits()
void SetVerbose(Int_t verbose)
PndSttHitCorrector(const PndSttCellTrackFinderData *data)