CbmRoot
CbmRichRingSelectImpl.h
Go to the documentation of this file.
1 
10 #ifndef CBM_RICH_RING_SELECT_IMPL
11 #define CBM_RICH_RING_SELECT_IMPL
12 
13 #include <algorithm>
14 #include <cmath>
15 #include <iostream>
16 #include <vector>
17 
18 #include "CbmRichRingLight.h"
19 
29 private:
30  static const int kMAX_NOF_HITS = 100; // Maximum number of hits in ring
31 
32 public:
37  fAlpha.resize(kMAX_NOF_HITS);
38  fPhi.resize(kMAX_NOF_HITS);
39  };
40 
45 
51  int count = 0;
52  int nHits = ring->GetNofHits();
53  for (int iH = 0; iH < nHits; iH++) {
54  CbmRichHitLight hitRing = ring->GetHit(iH);
55  float rx = hitRing.fX - ring->GetCenterX();
56  float ry = hitRing.fY - ring->GetCenterY();
57  float r = sqrt(rx * rx + ry * ry) - ring->GetRadius();
58  if (r < 0.35f) count++;
59  }
60  return count;
61  }
62 
67  float GetAngle(CbmRichRingLight* ring) {
68  int nHits = ring->GetNofHits();
69  if (nHits > kMAX_NOF_HITS) return 0.2f;
70  if (nHits < 4) return 999.f;
71 
72  float Pi = 3.14159265;
73  float TwoPi = 2. * 3.14159265;
74  float xRing = ring->GetCenterX();
75  float yRing = ring->GetCenterY();
76  float xHit, yHit;
77 
78  for (int iH = 0; iH < nHits; iH++) {
79  CbmRichHitLight hit = ring->GetHit(iH);
80  xHit = hit.fX;
81  yHit = hit.fY;
82 
83  if (yHit - yRing == 0 || xHit - xRing == 0) continue;
84 
85  if (xHit > xRing) {
86  if (yHit > yRing) {
87  fAlpha[iH] = atan(fabs((yHit - yRing) / (xHit - xRing)));
88  } else {
89  fAlpha[iH] = TwoPi - atan(fabs((yHit - yRing) / (xHit - xRing)));
90  }
91  } else {
92  if (yHit > yRing) {
93  fAlpha[iH] = Pi - atan(fabs((yHit - yRing) / (xHit - xRing)));
94  } else {
95  fAlpha[iH] = Pi + atan(fabs((yHit - yRing) / (xHit - xRing)));
96  }
97  }
98  }
99 
100  sort(fAlpha.begin(), fAlpha.begin() + nHits);
101 
102  for (int i = 0; i < nHits - 1; i++)
103  fPhi[i] = fAlpha[i + 1] - fAlpha[i];
104  fPhi[nHits - 1] = TwoPi - fAlpha[nHits - 1] + fAlpha[0];
105  sort(fPhi.begin(), fPhi.begin() + nHits);
106 
107  float angle = fPhi[nHits - 1] + fPhi[nHits - 2] + fPhi[nHits - 3];
108 
109  return angle;
110  }
111 
112 protected:
113  std::vector<float> fAlpha;
114  std::vector<float> fPhi;
115 };
116 
117 
118 #endif
f
float f
Definition: L1/vectors/P4_F32vec4.h:24
CbmRichRingSelectImpl::CbmRichRingSelectImpl
CbmRichRingSelectImpl()
Standard constructor.
Definition: CbmRichRingSelectImpl.h:36
sqrt
friend F32vec4 sqrt(const F32vec4 &a)
Definition: L1/vectors/P4_F32vec4.h:41
i
int i
Definition: L1/vectors/P4_F32vec4.h:25
CbmRichRingSelectImpl::GetAngle
float GetAngle(CbmRichRingLight *ring)
Definition: CbmRichRingSelectImpl.h:67
CbmRichHitLight::fX
float fX
Definition: CbmRichRingLight.h:34
CbmRichRingSelectImpl::kMAX_NOF_HITS
static const int kMAX_NOF_HITS
Definition: CbmRichRingSelectImpl.h:30
CbmRichRingSelectImpl::fPhi
std::vector< float > fPhi
Definition: CbmRichRingSelectImpl.h:114
CbmRichRingLight::GetNofHits
int GetNofHits() const
Return number of hits in ring.
Definition: CbmRichRingLight.h:108
CbmRichRingLight::GetCenterY
float GetCenterY() const
Definition: CbmRichRingLight.h:160
CbmRichRingLight.h
CbmRichRingSelectImpl
Definition: CbmRichRingSelectImpl.h:28
xMath::Pi
double Pi()
Definition: xMath.h:5
CbmRichHitLight
Definition: CbmRichRingLight.h:14
CbmRichRingLight::GetRadius
float GetRadius() const
Definition: CbmRichRingLight.h:161
CbmRichRingSelectImpl::fAlpha
std::vector< float > fAlpha
Definition: CbmRichRingSelectImpl.h:113
CbmRichHitLight::fY
float fY
Definition: CbmRichRingLight.h:35
fabs
friend F32vec4 fabs(const F32vec4 &a)
Definition: L1/vectors/P4_F32vec4.h:60
CbmRichRingLight::GetHit
CbmRichHitLight GetHit(int ind)
Return hit by the index.
Definition: CbmRichRingLight.h:114
CbmRichRingSelectImpl::~CbmRichRingSelectImpl
~CbmRichRingSelectImpl()
Destructor.
Definition: CbmRichRingSelectImpl.h:44
CbmRichRingSelectImpl::GetNofHitsOnRingCircle
int GetNofHitsOnRingCircle(CbmRichRingLight *ring)
Definition: CbmRichRingSelectImpl.h:50
CbmRichRingLight::GetCenterX
float GetCenterX() const
Definition: CbmRichRingLight.h:159
CbmRichRingLight
Definition: CbmRichRingLight.h:39