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