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