PandaRoot
PndLmdSensorAligner.h
Go to the documentation of this file.
1 /*
2  * PndLmdSensorAligner.h
3  *
4  * Created on: May 6, 2015
5  * Author: Roman Klasen, roklasen@uni-mainz.de or klasen@kph.uni-mainz.de
6  *
7  * This class gets HitPairs from PndLmdAlignManager and generates transformation matrices for ONE overlapping area.
8  * It works in cm and gives the matrix between sensors, so the hit pairs MUST have valid x, y and z coordinates
9  * in cm.
10  *
11  * One SensorAligner is responsible for one overlapping area alone, so 360 aligners are needed for the entire detector.
12  * Therefore, only the PndLmdAlignManager should interact with this class.
13  */
14 
15 #ifndef LMD_LMDSENSORALIGNMENT_PNDLMDSENSORALIGNER_H_
16 #define LMD_LMDSENSORALIGNMENT_PNDLMDSENSORALIGNER_H_
17 
18 #include "PndLmdHitPair.h"
19 
20 #include <string>
21 #include <vector>
22 
23 #include <matrix.h>
24 
25 // forward declarations so we can use a reference to these objects here
26 class PndLmdAlignManager;
27 
29 
30  private:
31  friend class PndLmdAlignQA;
32  friend class PndLmdAlignManager;
33 
34  bool forceInstant, debug;
35  unsigned int maxNoOfPairs, numberOfPairs, lastNoOfPairs, dim;
36  std::string inputFilename;
37  int _moduleID, overlapID;
38  unsigned int nonSanePairs, skippedPairs, swappedPairs, verbose;
39 
40  std::vector<std::vector<double>> simplePairs;
41 
42  bool inCentimeters, success, zIsTimestamp;
43 
44  void printPairSpread(int what = 0);
45  void transformPair(Matrix &trafoMatrix, std::vector<double> &pair);
46  std::vector<double> getPairSpread(int what = 0);
47 
48  bool zeroValCheck();
49 
50  // the manager which contains this SensorAligner
51  PndLmdAlignManager *superManager;
52 
53  // FIXME: in the future, return a TGeoHMatrix
54  Matrix resultMatrix;
55 
56  public:
59  virtual ~PndLmdSensorAligner();
60 
61  // every constructor should call this, also resets aligner (even though that never happens in normal use)
62  void init();
63 
64  // add simplified pair, for size and performance reasons, return false if aligner has enough pairs, return true if successful
65  bool addSimplePair(const PndLmdHitPair &pair);
66 
67  // TODO: these two functions belong in the manager, not the aligner
68  bool writePairsToBinary(const std::string directory);
69  bool readPairsFromBinary(const std::string directory);
70 
71  // set how many pairs the aligner should use, if higher than available in file, it will use all available
72  // set 0 for all
73  void setMaximumNumberOfHitPairs(Int_t maxPairs)
74  {
75  if (maxPairs > 0) {
76  maxNoOfPairs = maxPairs;
77  simplePairs.reserve(maxPairs);
78  }
79  }
80 
83 
84  bool check();
85 
86  void clearPairs();
87 
88  // deactivate iterative part
89  void setForceInstant(Bool_t instant) { forceInstant = instant; }
90 
91  void setModuleID(Int_t ID) { _moduleID = ID; }
92  int getModuleID() { return _moduleID; }
94  {
95  // usually, simplePairs contains all pairs, but if it gets cleared,
96  // the info is lost, so we save the number of pairs somewhere else.
97  int sPairs = simplePairs.size();
98  if (sPairs > 0) {
99  return sPairs;
100  } else {
101  return lastNoOfPairs;
102  }
103  }
104 
105  void applyDynamicCut(double percent = 5.0);
106 
107  void calculateMatrix();
108 
109  int getOverlapId() const { return overlapID; }
110 
111  void setOverlapId(Int_t overlapId) { overlapID = overlapId; }
112 
113  const Matrix &getResultMatrix() const { return resultMatrix; }
114 
115  // true in cm, false in pixels
116  void setInCentimeters(bool value) { inCentimeters = value; }
117 
118  bool successful() { return success; }
119 
120  void setZasTimetamp(bool value) { zIsTimestamp = value; }
121 
122  void verboseLevel(int level) { verbose = level; }
123 
124  void setManager(PndLmdAlignManager *manager) { superManager = manager; }
125 
126  unsigned int getDim() const { return dim; }
127 
128  void setDim(unsigned int value) { dim = value; }
129 };
130 
131 #endif /* LMD_LMDSENSORALIGNMENT_PNDLMDSENSORALIGNER_H_ */
Matrix transformToSensorOne()
bool writePairsToBinary(const std::string directory)
unsigned int getDim() const
void verboseLevel(int level)
void setModuleID(Int_t ID)
void setOverlapId(Int_t overlapId)
bool addSimplePair(const PndLmdHitPair &pair)
void setMaximumNumberOfHitPairs(Int_t maxPairs)
void applyDynamicCut(double percent=5.0)
const Matrix & getResultMatrix() const
Matrix transformToLmdLocal()
void setInCentimeters(bool value)
void setDim(unsigned int value)
void setZasTimetamp(bool value)
void setManager(PndLmdAlignManager *manager)
Definition: matrix.h:50
void setForceInstant(Bool_t instant)
virtual ~PndLmdSensorAligner()
bool readPairsFromBinary(const std::string directory)