EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
CbmRichRingSelectImplLight.h
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file CbmRichRingSelectImplLight.h
1 /*
2  * CbmRichRingSelectImplLight.h
3  *
4  * Created on: 24.03.2010
5  * Author: slebedev
6  */
7 
8 #ifndef CBMRICHRINGSELECTIMPLLIGHT_H_
9 #define CBMRICHRINGSELECTIMPLLIGHT_H_
10 
11 #include <iostream>
12 #include <vector>
13 #include <cmath>
14 #include <algorithm>
15 
16 #include "CbmRichRingLight.h"
17 
19 {
20 public:
22 
24  kMAX_NOF_HITS = 100;
25  fAlpha.resize(kMAX_NOF_HITS);
26  fPhi.resize(kMAX_NOF_HITS);
27  };
29 
31  float GetAngle(CbmRichRingLight* ring);
32 protected:
33  std::vector<float> fAlpha;
34  std::vector<float> fPhi;
35 };
36 
37 
39 {
40  int count = 0;
41  int nHits = ring->GetNofHits();
42  for (int iH = 0; iH < nHits; iH++) {
43  CbmRichHitLight hitRing = ring->GetHit(iH);
44  float rx = hitRing.fX - ring->GetCenterX();
45  float ry = hitRing.fY - ring->GetCenterY();
46  float r = sqrt(rx * rx + ry * ry) - ring->GetRadius();
47  if (r < 0.35f) count++;
48  }
49  return count;
50 }
51 
53 {
54  register int nHits = ring->GetNofHits();
55  if (nHits > kMAX_NOF_HITS) return 0.2f;
56  if (nHits < 4) return 999.f;
57 
58  register float Pi = 3.14159265;
59  register float TwoPi = 2.*3.14159265;
60  register float xRing = ring->GetCenterX();
61  register float yRing = ring->GetCenterY();
62  register float xHit, yHit;
63 
64  for(int iH = 0; iH < nHits; iH++){
65  CbmRichHitLight hit = ring->GetHit(iH);
66  xHit = hit.fX;
67  yHit = hit.fY;
68 
69  if (yHit-yRing == 0 || xHit-xRing == 0) continue;
70 
71  if( xHit > xRing){
72  if (yHit > yRing){
73  fAlpha[iH] = atan(fabs((yHit-yRing)/(xHit-xRing)));
74  } else{
75  fAlpha[iH] = TwoPi - atan(fabs((yHit-yRing)/(xHit-xRing)));
76  }
77  }else {
78  if (yHit > yRing){
79  fAlpha[iH] = Pi - atan(fabs((yHit-yRing)/(xHit-xRing)));
80  }else {
81  fAlpha[iH] = Pi + atan(fabs((yHit-yRing)/(xHit-xRing)));
82  }
83  }
84  }
85 
86  sort(fAlpha.begin(),fAlpha.begin()+nHits);
87 
88  for(int i = 0; i < nHits-1; i++) fPhi[i] = fAlpha[i+1] - fAlpha[i];
89  fPhi[nHits-1] = TwoPi - fAlpha[nHits-1] + fAlpha[0];
90  sort(fPhi.begin(),fPhi.begin()+nHits);
91 
92  float angle = fPhi[nHits-1]+fPhi[nHits-2]+fPhi[nHits-3];
93 
94  return angle;
95 }
96 #endif /* CBMRICHRINGSELECTIMPLLIGHT_H_ */