CbmRoot
Loading...
Searching...
No Matches
CbmRichRingSelectImpl.h
Go to the documentation of this file.
1/* Copyright (C) 2010-2012 UGiessen/JINR-LIT, Giessen/Dubna
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Semen Lebedev [committer] */
4
14#ifndef CBM_RICH_RING_SELECT_IMPL
15#define CBM_RICH_RING_SELECT_IMPL
16
17#include "CbmRichRingLight.h"
18
19#include <algorithm>
20#include <cmath>
21#include <iostream>
22#include <vector>
23
33 private:
34 static const int kMAX_NOF_HITS = 100; // Maximum number of hits in ring
35
36 public:
41 {
42 fAlpha.resize(kMAX_NOF_HITS);
43 fPhi.resize(kMAX_NOF_HITS);
44 };
45
50
56 {
57 int count = 0;
58 int nHits = ring->GetNofHits();
59 for (int iH = 0; iH < nHits; iH++) {
60 CbmRichHitLight hitRing = ring->GetHit(iH);
61 float rx = hitRing.fX - ring->GetCenterX();
62 float ry = hitRing.fY - ring->GetCenterY();
63 float r = sqrt(rx * rx + ry * ry) - ring->GetRadius();
64 if (r < 0.35f) count++;
65 }
66 return count;
67 }
68
74 {
75 int nHits = ring->GetNofHits();
76 if (nHits > kMAX_NOF_HITS) return 0.2f;
77 if (nHits < 4) return 999.f;
78
79 float Pi = 3.14159265;
80 float TwoPi = 2. * 3.14159265;
81 float xRing = ring->GetCenterX();
82 float yRing = ring->GetCenterY();
83 float xHit, yHit;
84
85 for (int iH = 0; iH < nHits; iH++) {
86 CbmRichHitLight hit = ring->GetHit(iH);
87 xHit = hit.fX;
88 yHit = hit.fY;
89
90 if (yHit - yRing == 0 || xHit - xRing == 0) continue;
91
92 if (xHit > xRing) {
93 if (yHit > yRing) {
94 fAlpha[iH] = atan(fabs((yHit - yRing) / (xHit - xRing)));
95 }
96 else {
97 fAlpha[iH] = TwoPi - atan(fabs((yHit - yRing) / (xHit - xRing)));
98 }
99 }
100 else {
101 if (yHit > yRing) {
102 fAlpha[iH] = Pi - atan(fabs((yHit - yRing) / (xHit - xRing)));
103 }
104 else {
105 fAlpha[iH] = Pi + atan(fabs((yHit - yRing) / (xHit - xRing)));
106 }
107 }
108 }
109
110 sort(fAlpha.begin(), fAlpha.begin() + nHits);
111
112 for (int i = 0; i < nHits - 1; i++)
113 fPhi[i] = fAlpha[i + 1] - fAlpha[i];
114 fPhi[nHits - 1] = TwoPi - fAlpha[nHits - 1] + fAlpha[0];
115 sort(fPhi.begin(), fPhi.begin() + nHits);
116
117 float angle = fPhi[nHits - 1] + fPhi[nHits - 2] + fPhi[nHits - 3];
118
119 return angle;
120 }
121
122 protected:
123 std::vector<float> fAlpha;
124 std::vector<float> fPhi;
125};
126
127
128#endif
friend fvec sqrt(const fvec &a)
float GetCenterX() const
float GetRadius() const
float GetCenterY() const
int GetNofHits() const
Return number of hits in ring.
CbmRichHitLight GetHit(int ind)
Return hit by the index.
std::vector< float > fPhi
int GetNofHitsOnRingCircle(CbmRichRingLight *ring)
std::vector< float > fAlpha
float GetAngle(CbmRichRingLight *ring)
CbmRichRingSelectImpl()
Standard constructor.