BmnRoot
Loading...
Searching...
No Matches
BmnStripData.h
Go to the documentation of this file.
1#ifndef BMNSTRIPDATA_H
2#define BMNSTRIPDATA_H
3
4#include <TObject.h>
5#include <TString.h>
6#include <iostream>
7
8using std::vector;
9
27
28// Exeptions --------------------------------------------------------------------
30{
31 public:
32 StationSet_Exception(TString message) { std::cerr << "StationSet_Exception::" << message << "\n"; }
33};
34
36{
37 public:
38 Station_Exception(TString message) { std::cerr << "Station_Exception::" << message << "\n"; }
39};
40//------------------------------------------------------------------------------
41
42// Class: dead zone -------------------------------------------------------------
44{
45 private:
46 Int_t NPoints;
47 Double_t* XPoints; //[NPoints]
48 Double_t* YPoints; //[NPoints]
49
50 public:
52 : NPoints(0)
53 , XPoints(nullptr)
54 , YPoints(nullptr)
55 {}
56
57 DeadZoneOfStripLayer(Int_t n_points, Double_t* xpoints, Double_t* ypoints)
58 : NPoints(0)
59 , XPoints(0)
60 , YPoints(0)
61 {
62 if (n_points > 2) {
63 NPoints = n_points;
64 XPoints = new Double_t[NPoints];
65 YPoints = new Double_t[NPoints];
66 for (Int_t i = 0; i < NPoints; ++i) {
67 XPoints[i] = xpoints[i];
68 YPoints[i] = ypoints[i];
69 }
70 }
71 }
72
74 {
75 NPoints = obj.NPoints;
76 XPoints = new Double_t[NPoints];
77 YPoints = new Double_t[NPoints];
78 for (Int_t i = 0; i < NPoints; ++i) {
79 XPoints[i] = obj.XPoints[i];
80 YPoints[i] = obj.YPoints[i];
81 }
82 }
83
85 {
86 if (XPoints != nullptr)
87 delete[] XPoints;
88 if (YPoints != nullptr)
89 delete[] YPoints;
90 NPoints = obj.NPoints;
91 XPoints = new Double_t[NPoints];
92 YPoints = new Double_t[NPoints];
93 for (Int_t i = 0; i < NPoints; ++i) {
94 XPoints[i] = obj.XPoints[i];
95 YPoints[i] = obj.YPoints[i];
96 }
97 return *this;
98 }
99
101 {
102 if (XPoints != nullptr)
103 delete[] XPoints;
104 if (YPoints != nullptr)
105 delete[] YPoints;
106 }
107
108 // Set a new dead zone, the previous zone will be deleted
109 Bool_t SetDeadZone(Int_t n_points, Double_t* xpoints, Double_t* ypoints)
110 {
111 NPoints = 0;
112 if (XPoints != nullptr) {
113 delete[] XPoints;
114 XPoints = nullptr;
115 }
116 if (YPoints != nullptr) {
117 delete[] YPoints;
118 YPoints = nullptr;
119 }
120 if (n_points > 2) {
121 NPoints = n_points;
122 XPoints = new Double_t[NPoints];
123 YPoints = new Double_t[NPoints];
124 for (Int_t i = 0; i < NPoints; ++i) {
125 XPoints[i] = xpoints[i];
126 YPoints[i] = ypoints[i];
127 }
128 return true;
129 } else {
130 return false;
131 }
132 }
133
134 Bool_t IsInside(Double_t x, Double_t y)
135 {
136 // crossing number (count) algorithm
137 if (NPoints == 0)
138 return false;
139 Bool_t check_flag = false;
140 for (int i = 0, j = NPoints - 1; i < NPoints; j = i++) {
141
142 if ((((YPoints[i] <= y) && (y < YPoints[j])) || ((YPoints[j] <= y) && (y < YPoints[i])))
143 && (x > (XPoints[j] - XPoints[i]) * (y - YPoints[i]) / (YPoints[j] - YPoints[i]) + XPoints[i]))
144 check_flag = !check_flag;
145 }
146 return check_flag;
147 }
148
149 Int_t GetNPoints() { return NPoints; }
150
151 Double_t GetXPoint(Int_t index)
152 {
153 if (index >= 0 && index < NPoints) {
154 return XPoints[index];
155 } else {
156 return 0.0;
157 // cerr << "\nWARNING:DeadZoneOfStripLayer: out of range (x)\n";
158 // throw;
159 }
160 }
161
162 Double_t GetYPoint(Int_t index)
163 {
164 if (index >= 0 && index < NPoints) {
165 return YPoints[index];
166 } else {
167 return 0.0;
168 // cerr << "\nWARNING:DeadZoneOfStripLayer: out of range (y)\n";
169 // throw;
170 }
171 }
172};
173//------------------------------------------------------------------------------
174
175// Class: strip cluster ---------------------------------------------------------
176class StripCluster : public TObject
177{
178 public:
179 Double_t OriginPosition; // origin position of the center point
180 Double_t MeanPosition; // position of the cluster (after fitting)
181 Double_t TotalSignal; // total signal of the cluster
182 Double_t PositionResidual; // residual from the origin position
183 Bool_t IsCorrect; // correct or incorrect cluster (status)
184 Int_t Station;
185 Int_t Module;
186 Int_t Width;
187 Double_t Error;
188
189 // Cluster type: 0 - lower, 1 - upper
190 Int_t fType;
191
192 vector<Int_t> Strips;
193 vector<Double_t> Signals;
194
196 : TObject()
197 {
198 OriginPosition = 0.0;
199 MeanPosition = 0.0;
200 TotalSignal = 0.0;
201 PositionResidual = 0.0;
202 IsCorrect = kFALSE;
203 fType = -1;
204 Station = -1;
205 Module = -1;
206 Width = 0.0;
207 Error = 0.0;
208 }
209
210 void SetType(Int_t type) { fType = type; }
211 Int_t GetType() { return fType; }
212 Int_t GetWidth() { return Width; }
213 void SetWidth(Int_t w) { Width = w; }
214 Int_t GetStation() { return Station; }
215 void SetStation(Int_t st) { Station = st; }
216 Int_t GetModule() { return Module; }
217 void SetModule(Int_t m) { Module = m; }
218 void SetError(Double_t err) { Error = err; }
219 Double_t GetError() { return Error; }
220
221 StripCluster(Double_t orig_position, Double_t mean_position, Double_t total_signal)
222 : TObject()
223 , OriginPosition(orig_position)
224 , MeanPosition(mean_position)
225 , TotalSignal(total_signal)
226 {
227 PositionResidual = 0.0;
228 IsCorrect = kFALSE;
229 fType = -1;
230 Station = -1;
231 Module = -1;
232 Width = 0.0;
233 Error = 0.0;
234 }
235 // Add new strip in ascending order of strip number (if cluster has strip with such number - add signal to that
236 // strip)
237 void AddStrip(Int_t strip_num, Double_t strip_signal)
238 {
239 Bool_t StripNumExists = false;
240 size_t index;
241 for (index = 0; index < Strips.size(); ++index) {
242 if (Strips[index] == strip_num) {
243 StripNumExists = true;
244 break;
245 }
246 }
247 if (StripNumExists)
248 Signals[index] += strip_signal;
249 else {
250 vector<Int_t>::iterator strip_iter = Strips.end();
251 vector<Double_t>::iterator signal_iter = Signals.end();
252 for (size_t i = 0; i < Strips.size(); ++i) {
253 if (strip_num < Strips[i]) {
254 strip_iter = Strips.begin() + i;
255 signal_iter = Signals.begin() + i;
256 break;
257 }
258 }
259 Strips.insert(strip_iter, strip_num);
260 Signals.insert(signal_iter, strip_signal);
261 }
262 }
263
264 void Print()
265 {
266 printf("\nCLUSTER INFORMATION (#%d)\n", this->GetUniqueID());
267 if (fType == 0)
268 printf("TYPE: LOWER\n");
269 else if (fType == 1)
270 printf("TYPE: UPPER\n");
271 printf("Station: %d\n", Station);
272 printf("Module: %d\n", Module);
273 printf("Cluster width: %d\n", Width);
274 printf("Total cluster signal: %4.2f\n", TotalSignal);
275 printf("Strips: ");
276 for (auto it : Strips)
277 printf("%d ", it);
278 printf("\nSignals: ");
279 for (auto it : Signals)
280 printf("%4.2f ", it);
281 printf("\n");
282 }
283
284 void Clear()
285 {
286 Strips.clear();
287 Signals.clear();
288 OriginPosition = 0.0;
289 MeanPosition = 0.0;
290 TotalSignal = 0.0;
291 PositionResidual = 0.0;
292 IsCorrect = kFALSE;
293 fType = -1;
294 }
295 Int_t GetClusterSize() { return Strips.size(); }
296
298};
299
300#endif /* BMNSTRIPDATA_H */
int i
Definition P4_F32vec4.h:22
__m128 m
Definition P4_F32vec4.h:27
StripBorderPoint
StripNumberingDirection
StripLayerType
Bool_t SetDeadZone(Int_t n_points, Double_t *xpoints, Double_t *ypoints)
DeadZoneOfStripLayer(const DeadZoneOfStripLayer &obj)
DeadZoneOfStripLayer & operator=(const DeadZoneOfStripLayer &obj)
Double_t GetXPoint(Int_t index)
DeadZoneOfStripLayer(Int_t n_points, Double_t *xpoints, Double_t *ypoints)
Bool_t IsInside(Double_t x, Double_t y)
Double_t GetYPoint(Int_t index)
StationSet_Exception(TString message)
Station_Exception(TString message)
void SetStation(Int_t st)
Double_t TotalSignal
StripCluster(Double_t orig_position, Double_t mean_position, Double_t total_signal)
Int_t GetClusterSize()
Int_t GetType()
Double_t MeanPosition
ClassDef(StripCluster, 1)
Double_t Error
void SetWidth(Int_t w)
void AddStrip(Int_t strip_num, Double_t strip_signal)
void SetType(Int_t type)
Double_t PositionResidual
void SetModule(Int_t m)
Int_t GetModule()
Int_t GetWidth()
Int_t GetStation()
void SetError(Double_t err)
Double_t OriginPosition
Double_t GetError()
vector< Int_t > Strips
vector< Double_t > Signals
@ LeftTop
@ RightBottom
@ LeftBottom
@ RightTop
@ RightToLeft
@ LeftToRight
@ UpperStripLayer
@ LowerStripLayer