EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
CbmRichRing.cxx
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file CbmRichRing.cxx
1 /* $Id: CbmRichRing.cxx,v 1.8 2006/09/13 14:51:28 hoehne Exp $*/
2 
3 /* History of CVS commits:
4  *
5  * $Log: CbmRichRing.cxx,v $
6  * Revision 1.8 2006/09/13 14:51:28 hoehne
7  * two variables (Selection2D, SelectionNN) added in which values between 0 and 1 are stored for fake rejection
8  * ReconstructedFlag removed
9  *
10  * Revision 1.7 2006/08/11 14:03:57 hoehne
11  * move SetUncertainty and GetUncertainty to SetChi2 and GetChi2
12  *
13  * Revision 1.6 2006/07/12 06:27:54 hoehne
14  * new functions: SetDistance and GetDistance added which set/ give the distance between ring center and track attached to this
15  * ring
16  *
17  * Revision 1.5 2006/02/23 11:24:10 hoehne
18  * RecFlag added (Simeon Lebedev)
19  *
20  * Revision 1.4 2006/01/23 11:40:13 hoehne
21  * MCMotherID added
22  *
23  * Revision 1.3 2006/01/19 10:40:06 hoehne
24  * restructured according to new RinfFinder Class:
25  * array of hits belonging to a certain ring added
26  *
27  *
28  *
29  */
30 
31 
32 // -------------------------------------------------------------------------
33 // ----- CbmRichRing source file -----
34 // ----- Created 05/07/04 by A. Soloviev <solovjev@cv.jinr.ru> -----
35 // -------------------------------------------------------------------------
36 
37 
38 #include "CbmRichRing.h"
39 //#include "CbmRichHit.h"
40 
41 # include "TMath.h"
42 
43 # include <iostream>
44 # include <cmath>
45 
46 using std::cout;
47 using std::sqrt;
48 using std::fabs;
49 using std::atan;
50 
51 // ----- Default constructor -------------------------------------------
53  : TObject(),
54  fHitCollection(),
55  fAPar(0.),
56  fBPar(0.),
57  fCPar(0.),
58  fDPar(0.),
59  fEPar(0.),
60  fFPar(0.),
61  fCenterX(0.),
62  fCenterY(0.),
63  fRadius(0.),
64  fAaxis(0.),
65  fBaxis(0.),
66  fAaxisCor(0.),
67  fBaxisCor(0.),
68  fPhi(0.),
69  fTrackID(-1),
70  fDistance(99.),
71  fChi2(0.),
72  fAngle(0.),
73  fNofHitsOnRing(-1),
74  fSelectionNN(-1.),
75  fRecFlag(0)
76 {
77  fHitCollection.reserve(40);
78 }
79 // -------------------------------------------------------------------------
80 
81 
82 // ----- Standard constructor ------------------------------------------
84  Float_t y,
85  Float_t r )
86  : TObject(),
87  fHitCollection(),
88  fAPar(0.),
89  fBPar(0.),
90  fCPar(0.),
91  fDPar(0.),
92  fEPar(0.),
93  fFPar(0.),
94  fCenterX(x),
95  fCenterY(y),
96  fRadius(r),
97  fAaxis(0.),
98  fBaxis(0.),
99  fAaxisCor(0.),
100  fBaxisCor(0.),
101  fPhi(0.),
102  fTrackID(-1),
103  fDistance(99.),
104  fChi2(0.),
105  fAngle(0.),
106  fNofHitsOnRing(-1),
107  fSelectionNN(-1.),
108  fRecFlag(0)
109 {
110  fHitCollection.reserve(40);
111 }
112 // -------------------------------------------------------------------------
113 
114 
115 // ----- Destructor ----------------------------------------------------
117 {
118  fHitCollection.clear();
119 }
120 // -------------------------------------------------------------------------
121 
122 void CbmRichRing::SetXYABPhi(Double_t x, Double_t y,
123  Double_t a, Double_t b,
124  Double_t phi)
125 {
126  fCenterX = x;
127  fCenterY = y;
128  fAaxis = a;
129  fBaxis = b;
130  fPhi = phi;
131 }
132 
133 Bool_t CbmRichRing::RemoveHit(UShort_t hitId)
134 {
135  //Int_t nofHits = fHitCollection.size();
136  std::vector<UShort_t>::iterator it;
137  for (it = fHitCollection.begin(); it!=fHitCollection.end(); it++){
138  if (hitId == *it){
139  fHitCollection.erase(it);
140  return true;
141  }
142  }
143  return false;
144 }
145 
146 Double_t CbmRichRing::GetXF1() const
147 {
148  Double_t c = sqrt(fAaxis*fAaxis - fBaxis*fBaxis);
149  Double_t xc = c*cos(fabs(fPhi));
150 
151  return fCenterX+xc;
152 }
153 
154 Double_t CbmRichRing::GetYF1() const
155 {
156  Double_t c = sqrt(fAaxis*fAaxis - fBaxis*fBaxis);
157  Double_t yc = c*sin(fabs(fPhi));
158  if (fPhi >=0){
159  return fCenterY+yc;
160  }else{
161  return fCenterY-yc;
162  }
163 }
164 
165 Double_t CbmRichRing::GetXF2() const
166 {
167  Double_t c = sqrt(fAaxis*fAaxis - fBaxis*fBaxis);
168  Double_t xc = c*cos(fabs(fPhi));
169 
170  return fCenterX-xc;
171 }
172 
173 Double_t CbmRichRing::GetYF2() const
174 {
175  Double_t c = sqrt(fAaxis*fAaxis - fBaxis*fBaxis);
176  Double_t yc = c*sin(fabs(fPhi));
177  if (fPhi >=0){
178  return fCenterY-yc;
179  }else{
180  return fCenterY+yc;
181  }
182 }
183 
185  cout << " Ring parameters: " <<
186  " Aaxis = " << GetAaxis() <<
187  ", Baxis = " << GetBaxis() <<
188  ", Phi = " << GetPhi() <<
189  ", CenterX = " << GetCenterX() <<
190  ", CenterY = " << GetCenterY() <<
191  ", Radius = " << GetRadius() <<
192  ", NofHits = " << GetNofHits() <<
193  ", RadialPosition = " << GetRadialPosition() <<
194  ", Chi2 = " << GetChi2() <<
195  ", RingTrackDistance = "<< GetDistance() <<
196  ", Angle() = " << GetAngle() <<
197  ", NofHitsOnRing = " << GetNofHitsOnRing() << std::endl;
198 }
199 
201 {
202  if (fCenterY > 0.f) {
203  return sqrt(fCenterX*fCenterX + (fCenterY-110.f)*(fCenterY-110.f));
204  } else {
205  return sqrt(fCenterX*fCenterX + (fCenterY+110.f)*(fCenterY+110.f));
206  }
207 }
208 
210  /* if (fCenterY > 0){
211  return atan((100 - fCenterY) / (0 - fCenterX));
212  } else {
213  return atan((-100 - fCenterY) / (0 - fCenterX));
214  }*/
215 
216  if( fCenterX > 0 && fCenterY > 0 ){
217  return atan(fabs((100 - fCenterY) / (0 - fCenterX)));
218  }
219  if( fCenterX < 0 && fCenterY > 0 ){
220  return TMath::Pi() - atan(fabs((100 - fCenterY) / (0 - fCenterX)));
221  }
222  if( fCenterX < 0 && fCenterY < 0 ){
223  return TMath::Pi() + atan(fabs((-100 - fCenterY) / (0 - fCenterX)));
224  }
225  if( fCenterX > 0 && fCenterY < 0 ){
226  return 2*TMath::Pi() - atan(fabs((-100 - fCenterY) / (0 - fCenterX)));
227  }
228 
229  return 999.;
230 }
231 //
232 //CbmRichRingLight* CbmRichRing::toLightRing()
233 //{
234 // CbmRichRingLight* rl = new CbmRichRingLight();
235 //
236 // for (int i = 0; i < this->GetNofHits(); i ++){
237 // rl->AddHit(this->GetHit(i));
238 // }
239 // rl->SetCenterX(this->GetCenterX());
240 // rl->SetCenterY(this->GetCenterY());
241 // rl->SetRadius(this->GetRadius());
242 // rl->SetAngle(this->GetAngle());
243 // rl->SetChi2(this->GetChi2());
244 // rl->SetNofHitsOnRing(this->GetNofHitsOnRing());
245 // rl->SetSelectionNN(this->GetSelectionNN());
246 // rl->SetRecFlag(this->GetRecFlag());
247 //
248 // return rl;
249 //}
250 
252