EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
CbmRichRingSelectImpl.h
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file CbmRichRingSelectImpl.h
1 
10 #ifndef CBM_RICH_RING_SELECT_IMPL
11 #define CBM_RICH_RING_SELECT_IMPL
12 
13 #include <iostream>
14 #include <vector>
15 #include <cmath>
16 #include <algorithm>
17 
18 #include "CbmRichRingLight.h"
19 
29 {
30 private:
31 
32  static const int kMAX_NOF_HITS = 100; // Maximum number of hits in ring
33 
34 public:
39  fAlpha(),
40  fPhi()
41  {
42  fAlpha.resize(kMAX_NOF_HITS);
43  fPhi.resize(kMAX_NOF_HITS);
44  };
45 
50 
56  CbmRichRingLight* ring)
57  {
58  int count = 0;
59  int nHits = ring->GetNofHits();
60  for (int iH = 0; iH < nHits; iH++) {
61  CbmRichHitLight hitRing = ring->GetHit(iH);
62  float rx = hitRing.fX - ring->GetCenterX();
63  float ry = hitRing.fY - ring->GetCenterY();
64  float r = sqrt(rx * rx + ry * ry) - ring->GetRadius();
65  if (r < 0.35f) count++;
66  }
67  return count;
68  }
69 
74  float GetAngle(
75  CbmRichRingLight* ring)
76  {
77  int nHits = ring->GetNofHits();
78  if (nHits > kMAX_NOF_HITS) return 0.2f;
79  if (nHits < 4) return 999.f;
80 
81  float Pi = 3.14159265;
82  float TwoPi = 2.*3.14159265;
83  float xRing = ring->GetCenterX();
84  float yRing = ring->GetCenterY();
85  float xHit, yHit;
86 
87  for(int iH = 0; iH < nHits; iH++){
88  CbmRichHitLight hit = ring->GetHit(iH);
89  xHit = hit.fX;
90  yHit = hit.fY;
91 
92  if (yHit-yRing == 0 || xHit-xRing == 0) continue;
93 
94  if(xHit > xRing){
95  if (yHit > yRing){
96  fAlpha[iH] = atan(fabs((yHit-yRing)/(xHit-xRing)));
97  } else{
98  fAlpha[iH] = TwoPi - atan(fabs((yHit-yRing)/(xHit-xRing)));
99  }
100  }else {
101  if (yHit > yRing){
102  fAlpha[iH] = Pi - atan(fabs((yHit-yRing)/(xHit-xRing)));
103  }else {
104  fAlpha[iH] = Pi + atan(fabs((yHit-yRing)/(xHit-xRing)));
105  }
106  }
107  }
108 
109  sort(fAlpha.begin(),fAlpha.begin()+nHits);
110 
111  for(int i = 0; i < nHits-1; i++) fPhi[i] = fAlpha[i+1] - fAlpha[i];
112  fPhi[nHits-1] = TwoPi - fAlpha[nHits-1] + fAlpha[0];
113  sort(fPhi.begin(),fPhi.begin()+nHits);
114 
115  float angle = fPhi[nHits-1]+fPhi[nHits-2]+fPhi[nHits-3];
116 
117  return angle;
118  }
119 
120 protected:
121  std::vector<float> fAlpha;
122  std::vector<float> fPhi;
123 };
124 
125 
126 #endif