FairRoot/PandaRoot
PndLmdHitPair.cxx
Go to the documentation of this file.
1 //-----------------------------------------------------------
2 // File and Version Information:
3 // $Id$
4 //
5 // Description:
6 // Implementation of class PndLmdHitPair
7 // see PndLmdHitPair.h for details
8 //
9 // Environment:
10 // Software developed for the PANDA Detector at FAIR.
11 //
12 // Author List:
13 // Roman Klasen (HIM), roklasen@uni-mainz.de using template by Tobias Stockmanns (IKP - Juelich)
14 //
15 //
16 //-----------------------------------------------------------
17 
18 // Panda Headers ----------------------
19 
20 // This Class' Header ------------------
21 #include "PndLmdHitPair.h"
22 //#include "FairRootManager.h"
23 //#include "FairEventHeader.h"
24 
25 #include <algorithm>
26 #include <cmath>
27 #include <utility>
28 
29 #include <iostream>
30 
32 
34 
35 }
36 
38  if(_hit1==rhs._hit1 && _hit2 == rhs._hit2 && _id1 == rhs._id1 && _id2 == rhs._id2){
39  return true;
40  }
41  if(_hit1==rhs._hit2 && _hit2 == rhs._hit1 && _id1 == rhs._id2 && _id2 == rhs._id1){
42  return true;
43  }
44  return false;
45 }
46 
47 
49  std::cout << "=========== PndLmdHitPair::Print() ==========" << std::endl;
50  std::cout << "=hitPair= col1: " << _col1 << ", col2: " << _col2 << ", row1: " << _row1 << ", row2: ";
51  std::cout << _row2 << ", id1: " << _id1 << ", id2: " << _id2 << "\n moduleID: " << _moduleId << ", overlap ID: " << _overlapID << ", distance " << _distance << std::endl;
52  std::cout << "------ hit 1 ------ " << std::endl;
53  std::cout << "x: " << _hit1.x() << std::endl;
54  std::cout << "y: " << _hit1.y() << std::endl;
55  std::cout << "z: " << _hit1.z() << std::endl;
56  std::cout << "------ hit 2 ------ " << std::endl;
57  std::cout << "x: " << _hit2.x() << std::endl;
58  std::cout << "y: " << _hit2.y() << std::endl;
59  std::cout << "z: " << _hit2.z() << std::endl;
60 }
61 
62 /*
63  * checks this pair for decing errors.
64  * this does not apply any cuts, the PairFinderTask is responsible for that.
65  */
67 
68  bool colSane=false, rowSane=false, idsane=false, allVarsSet=false; //, distanceOk=false; //[R.K. 9/2018] unused
69  if(std::isinf(_col1) || std::isinf(_col2) || std::isnan(_col1) || std::isnan (_col2)){
70  colSane=false;
71  }
72  else{
73  colSane=true;
74  }
75  if(std::isinf(_row1) || std::isinf(_row2) || std::isnan(_row1) || std::isnan (_row2)){
76  rowSane=false;
77  }
78  else{
79  rowSane=true;
80  }
81  if(std::isinf(_id1) || std::isinf(_id2) || std::isnan(_id1) || std::isnan (_id2)){
82  idsane=false;
83  }
84  else{
85  idsane=true;
86  }
87 
88  //no row and col info, no valid pair
89  if(_row1 < 0 || _row2 < 0 || _col1 < 0 || _col2 < 0){
90  rowSane=false;
91  colSane=false;
92  return;
93  }
94 
95 // if(_id1 > -1 && _id2 > -1 && _moduleId > -1 && _overlapID > -1){
96 // allVarsSet = true;
97 // }
98 // else{
99 // allVarsSet = false;
100 // }
101 
102 // if(colSane && rowSane && idsane && allVarsSet){
103 // sane=true;
104 // checked = true;
105 // return;
106 // }
107  if(colSane && rowSane && idsane){
108  sane=true;
109  checked = true;
110  return;
111  }
112  else{
113  std::cerr << "colsane " << colSane << ", rowsane " << rowSane << ", idsane " << idsane << ", allVArsSet " << allVarsSet << std::endl;
114  }
115 }
116 
117 PndLmdHitPair::PndLmdHitPair(const TVector3& hit1, const TVector3& hit2, Int_t id1, Int_t id2) {
118  _row1 = _row2 = _col1 = _col2 = -1;
119  _hit1=hit1;
120  _hit2=hit2;
121  _id1=id1;
122  _id2=id2;
123  checked=false;
124  sane=false;
125  _moduleId=-1;
126  hit1present=true;
127  hit2present=true;
128  _distance = -1;
129  _overlapID = -1;
130 }
131 
132 PndLmdHitPair::PndLmdHitPair(Double_t col1, Double_t row1, Int_t id1, Double_t col2, Double_t row2, Int_t id2) {
133  _row1 = row1;
134  _row2 = row2;
135  _col1 = col1;
136  _col2 = col2;
137  _id1=id1;
138  _id2=id2;
139  checked=false;
140  sane=false;
141  _moduleId=-1;
142  hit1present=false;
143  hit2present=false;
144  _distance = -1;
145  _overlapID = -1;
146 }
147 
149  _id1 = _id2 = _row1 = _row2 = _col1 = _col2 = -1;
150  checked=false;
151  sane=false;
152  _moduleId=-1;
153  hit1present=false;
154  hit2present=false;
155  _distance = -1;
156  _overlapID = -1;
157 }
158 
159 bool PndLmdHitPair::hitSensors(Int_t first, Int_t second) {
160 
161  if(first == _id1){
162  if(second == _id2){
163  return true;
164  }
165  }
166  else if(first == _id2){
167  if(second == _id1){
168  return true;
169  }
170  }
171  return false;
172 }
173 
175 
176 // calculate absolute distance between hit1 and hit2, keeping the z distance of 250 present.
177  if(hit1present && hit2present){
178  TVector3 distV = _hit1 - _hit2;
179  _distance = distV.Mag();
180  }
181  else{
182  _distance = -1;
183  }
184 }
185 
187 
188  checked = false;
189  std::swap(_id1, _id2);
190  std::swap(_hit1, _hit2);
191  std::swap(_row1, _row2);
192  std::swap(_col1, _col2);
193 }
Double_t _col2
Definition: PndLmdHitPair.h:48
bool hitSensors(Int_t first, Int_t second)
Double_t _row1
Definition: PndLmdHitPair.h:48
ClassImp(PndLmdHitPair)
Double_t _distance
Definition: PndLmdHitPair.h:48
Double_t
Double_t _row2
Definition: PndLmdHitPair.h:48
TVector3 _hit1
Definition: PndLmdHitPair.h:49
void calculateDistance()
Double_t _col1
Definition: PndLmdHitPair.h:48
TVector3 _hit2
Definition: PndLmdHitPair.h:49
bool operator==(const PndLmdHitPair &rhs)
void PrintPair() const