BmnRoot 26.10.0-18-g4e3414f9
Software framework of the BM@N experiment
Loading...
Searching...
No Matches
BmnCSCModule.cxx
Go to the documentation of this file.
1#include "BmnCSCModule.h"
2
3#include "TF1.h"
4#include "TH1F.h"
5#include "TMath.h"
6#include "TRandom.h"
7
9{
10
11 Verbosity = true;
12
14
15 ModuleThickness = 0.76; // cm
16
17 XMinModule = 0.0;
18 XMaxModule = 0.0;
19 YMinModule = 0.0;
20 YMaxModule = 0.0;
21}
22
24{
25
26 Verbosity = true;
27
28 ZStartModulePosition = z_start_pos;
29
30 ModuleThickness = module_thick; // cm
31
32 XMinModule = 0.0;
33 XMaxModule = 0.0;
34 YMinModule = 0.0;
35 YMaxModule = 0.0;
36}
37
39
45
47{
48 StripLayers.push_back(strip_layer);
49
51}
52
54{
55 if (layer_num >= 0 && layer_num < (Int_t)StripLayers.size()) {
56 return StripLayers[layer_num].SetStripSignal(strip_num, signal);
57 }
58 return false;
59}
60
62{
63 if (layer_num >= 0 && layer_num < (Int_t)StripLayers.size()) {
64 return StripLayers[layer_num].AddStripSignal(strip_num, signal);
65 }
66 return false;
67}
68
70{
71 if (layer_num >= 0 && layer_num < (Int_t)StripLayers.size()) {
72 return StripLayers[layer_num].SetStripMatch(strip_num, strip_match);
73 }
74 return false;
75}
76
78{
79 if (layer_num >= 0 && layer_num < (Int_t)StripLayers.size()) {
80 return StripLayers[layer_num].SetStripDigitNumberMatch(strip_num, digit_num_match);
81 }
82 return false;
83}
84
86{
87 if (layer_num >= 0 && layer_num < (Int_t)StripLayers.size()) {
88 return StripLayers[layer_num].GetStripSignal(strip_num);
89 }
90 return -1;
91}
92
94{
95 if (layer_num >= 0 && layer_num < (Int_t)StripLayers.size()) {
96 return StripLayers[layer_num].GetStripMatch(strip_num);
97 }
98 return BmnMatch();
99}
100
102{
103 if (layer_num >= 0 && layer_num < (Int_t)StripLayers.size()) {
104 return StripLayers[layer_num].GetStripDigitNumberMatch(strip_num);
105 }
106 return BmnMatch();
107}
108
110{
111 for (size_t ilayer = 0; ilayer < StripLayers.size(); ++ilayer) {
112 StripLayers[ilayer].ResetLayer();
113 }
114
116
120}
121
123{
124 for (size_t ilayer = 0; ilayer < StripLayers.size(); ++ilayer) {
125 if (StripLayers[ilayer].IsPointInsideStripLayer(x, y))
126 return true;
127 }
128 return false;
129}
130
132{
133 Double_t coord_eps = 0.01; // 100 um
134 if (((z > ZStartModulePosition) || (fabs(z - ZStartModulePosition) < coord_eps))
136 || (fabs(z - (ZStartModulePosition + ModuleThickness))) < coord_eps))
137 {
138 if (IsPointInsideModule(x, y))
139 return true;
140 }
141 return false;
142}
143
145{
146 Double_t coord_eps = 0.01; // 100 um
147 if (((z > ZStartModulePosition) || (fabs(z - ZStartModulePosition) < coord_eps))
149 || (fabs(z - (ZStartModulePosition + ModuleThickness))) < coord_eps))
150 {
151 return true;
152 }
153 return false;
154}
155
156// Add single point with Gaussian smearing
158 Double_t y,
159 Double_t z,
160 Double_t px,
161 Double_t py,
162 Double_t pz,
163 Double_t signal,
164 Int_t refID)
165{
166
167 // Distance from entry point (x,y,z) to the midde of the detector (along z-axis)
168 Double_t z_dist_mid = ModuleThickness * 0.5;
169 Double_t vector_coeff_mid = fabs(z_dist_mid / pz); // for middle point
170
171 Double_t x_vec_from_in_to_mid = vector_coeff_mid * px;
172 Double_t y_vec_from_in_to_mid = vector_coeff_mid * py;
173 // Double_t z_vec_from_in_to_mid = vector_coeff_mid*pz;
174
175 // Middle point coordinates (x_mid, y_mid, z_mid)
176 Double_t x_mid = x + x_vec_from_in_to_mid;
177 Double_t y_mid = y + y_vec_from_in_to_mid;
178 // Double_t z_mid = z + z_vec_from_in_to_mid;
179 //--------------------------------------------------------------------------
180
181 if (IsPointInsideModule(x, y)) {
182
183 if (signal <= 0.0)
184 signal = 1e-16;
185
186 Double_t AvalancheRadius = 0.25; // cm, signal radius (not diameter!)
187
188 Double_t radius = AvalancheRadius;
189 if (radius <= 0.0)
190 return false;
191
192 Int_t cycle_cnt = 0;
193 while (true) {
194 radius = gRandom->Gaus(AvalancheRadius, 0.05);
195 if (radius > AvalancheRadius / 2.0 && radius < AvalancheRadius * 2.0 && radius > 0.0)
196 break;
197 cycle_cnt++;
198
199 if (cycle_cnt > 5) {
200 radius = AvalancheRadius;
201 break;
202 }
203 }
204
205 // Make strip cluster in each strip layer -------------------------------
206 Int_t n_strip_layers = StripLayers.size();
207 vector<StripCluster> cluster_layers(n_strip_layers, StripCluster());
208
209 for (Int_t ilayer = 0; ilayer < n_strip_layers; ++ilayer) {
210 if (!StripLayers[ilayer].IsPointInsideStripLayer(x_mid, y_mid))
211 continue;
212 cluster_layers[ilayer] = MakeCluster(ilayer, x_mid, y_mid, signal, radius);
213 }
214 //----------------------------------------------------------------------
215
216 // Add the correct clusters to the strip layers -------------------------
217 for (Int_t ilayer = 0; ilayer < n_strip_layers; ++ilayer) {
218 for (size_t ielement = 0; ielement < cluster_layers[ilayer].Strips.size(); ++ielement) {
219 Int_t strip_num = cluster_layers[ilayer].Strips.at(ielement);
220 Double_t strip_signal = cluster_layers[ilayer].Signals.at(ielement);
221 // Int_t zone_id = StripLayers[ilayer].GetZoneID();
222 StripLayers[ilayer].AddStripSignal(strip_num, strip_signal);
223 }
224 }
225 //----------------------------------------------------------------------
226
227 // Fill strip matches ---------------------------------------------------
228 for (Int_t ilayer = 0; ilayer < n_strip_layers; ++ilayer) {
229 for (size_t ielement = 0; ielement < cluster_layers[ilayer].Strips.size(); ++ielement) {
230 Int_t strip_num = cluster_layers[ilayer].Strips.at(ielement);
231 Double_t strip_signal = cluster_layers[ilayer].Signals.at(ielement);
232 // Int_t zone_id = StripLayers[ilayer].GetZoneID();
233 StripLayers[ilayer].AddLinkToStripMatch(strip_num, strip_signal / cluster_layers[ilayer].TotalSignal,
234 refID);
235 }
236 }
237 //----------------------------------------------------------------------
238
239 RealPointsX.push_back(x);
240 RealPointsY.push_back(y);
241 RealPointsMC.push_back(refID);
242
243 return true;
244 } else {
245 if (Verbosity)
246 cerr << "WARNING: BmnCSCModule::AddRealPointFullOne(): Point (" << x << " : " << y << " : " << z
247 << ") is out of the readout plane or inside a dead zone\n";
248 return false;
249 }
250}
251
252// Add single point without smearing and avalanch effects
254 Double_t y,
255 Double_t z,
256 Double_t px,
257 Double_t py,
258 Double_t pz,
259 Double_t signal,
260 Int_t refID)
261{
262
263 if (IsPointInsideModule(x, y)) {
264
265 Int_t n_strip_layers = StripLayers.size();
266
267 // Add a signal to the strips layers ------------------------------------
268 for (Int_t ilayer = 0; ilayer < n_strip_layers; ++ilayer) {
269
270 if (!StripLayers[ilayer].IsPointInsideStripLayer(x, y))
271 continue;
272
273 Double_t strip_pos = StripLayers[ilayer].ConvertPointToStripPosition(x, y);
274 StripLayers[ilayer].AddStripSignal((Int_t)strip_pos, signal);
275
276 // strip match
277 StripLayers[ilayer].AddLinkToStripMatch((Int_t)strip_pos, 1.0, refID);
278 }
279 //----------------------------------------------------------------------
280
281 RealPointsX.push_back(x);
282 RealPointsY.push_back(y);
283 RealPointsMC.push_back(refID);
284
285 return true;
286 } else {
287 if (Verbosity)
288 cerr << "WARNING: BmnCSCModule::AddRealPointSimple(): Point (" << x << " : " << y
289 << ") is out of the readout plane or inside a dead zone\n";
290 return false;
291 }
292}
293
295 Double_t xcoord,
296 Double_t ycoord,
297 Double_t signal,
298 Double_t radius)
299{
300
301 Double_t ClusterDistortion = 0.0; // signal variation (0.1 is 10%)
302
303 Double_t Gain = 1.0;
304
305 StripCluster cluster;
306
307 if (radius <= 0.0)
308 return cluster;
309
310 Double_t Pitch = StripLayers[layer_num].GetPitch();
311
312 Double_t RadiusInZones = radius / Pitch;
313 Double_t Sigma = RadiusInZones / 3.33;
314
315 TF1 gausF("gausF", "gaus", -4 * Sigma, 4 * Sigma);
316 gausF.SetParameter(0, 1.0); // constant (altitude)
317 gausF.SetParameter(1, 0.0); // mean (center position)
318 gausF.SetParameter(2, Sigma); // sigma
319
320 Double_t SCluster = gausF.Integral(-4 * Sigma, 4 * Sigma); // square of the one side distribution (more exactly)
321
322 TRandom rand(0);
323 Double_t var_level = ClusterDistortion; // signal variation (0.1 is 10%)
324
325 Int_t NStripsInLayer = StripLayers[layer_num].GetNStrips();
326
327 if (NStripsInLayer == 0)
328 return cluster;
329
330 Double_t CenterZonePos = StripLayers[layer_num].ConvertPointToStripPosition(xcoord, ycoord);
331
332 if (CenterZonePos < 0.0 || CenterZonePos >= NStripsInLayer)
333 return cluster;
334
335 gausF.SetParameter(1, CenterZonePos);
336 Double_t total_signal = 0.0;
337
338 Double_t LeftZonePos = CenterZonePos - RadiusInZones;
339 Double_t RightZonePos = CenterZonePos + RadiusInZones;
340 Double_t OutLeftBorder = 0.0;
341 Double_t OutRightBorder = 0.0;
342
343 if (LeftZonePos < 0.0) {
344 OutLeftBorder = LeftZonePos;
345 LeftZonePos = 0.0;
346 }
347 if (RightZonePos < 0.0) {
348 OutRightBorder = RightZonePos;
349 RightZonePos = 0.0;
350 }
351 if (LeftZonePos >= NStripsInLayer) {
352 OutLeftBorder = LeftZonePos;
353 LeftZonePos = NStripsInLayer - 0.001;
354 }
355 if (RightZonePos >= NStripsInLayer) {
356 OutRightBorder = RightZonePos;
357 RightZonePos = NStripsInLayer - 0.001;
358 }
359
360 Double_t h = 0.0;
361 Double_t dist = 0.0;
362
363 // avalanche is inside of the one strip
364 if ((Int_t)LeftZonePos == (Int_t)RightZonePos) {
365
366 Int_t NumCurrentZone = (Int_t)LeftZonePos;
367
368 h = RightZonePos - LeftZonePos;
369 if (h < 0.0)
370 h = 0.0;
371
372 Double_t xp = LeftZonePos + dist;
373 Double_t S = gausF.Integral(xp, xp + h);
374 Double_t Energy = (signal * Gain) * (S / SCluster);
375 Energy += rand.Gaus(0.0, var_level * Energy);
376 if (Energy < 0.0)
377 Energy = 0.0;
378
379 if (NumCurrentZone >= 0 && NumCurrentZone < NStripsInLayer && Energy > 0.0) {
380 cluster.AddStrip(NumCurrentZone, Energy);
381 total_signal += Energy;
382 }
383
384 dist += h;
385
386 } else {
387 // left border strip
388 Int_t NumCurrentZone = (Int_t)LeftZonePos;
389
390 h = ((Int_t)LeftZonePos + 1) - LeftZonePos;
391 if (h < 0.0)
392 h = 0.0;
393
394 Double_t xp = LeftZonePos + dist;
395 Double_t S = gausF.Integral(xp, xp + h);
396 Double_t Energy = (signal * Gain) * (S / SCluster);
397 Energy += rand.Gaus(0.0, var_level * Energy);
398 if (Energy < 0.0)
399 Energy = 0.0;
400
401 if (NumCurrentZone >= 0 && NumCurrentZone < NStripsInLayer && Energy > 0.0) {
402 cluster.AddStrip(NumCurrentZone, Energy);
403 total_signal += Energy;
404 }
405
406 dist += h;
407
408 // inner strips
409 for (Int_t i = (Int_t)LeftZonePos + 1; i < (Int_t)RightZonePos; ++i) {
410
411 NumCurrentZone = i;
412
413 h = 1.0;
414
415 xp = LeftZonePos + dist;
416 S = gausF.Integral(xp, xp + h);
417 Energy = (signal * Gain) * (S / SCluster);
418 Energy += rand.Gaus(0.0, var_level * Energy);
419 if (Energy < 0.0)
420 Energy = 0.0;
421
422 if (NumCurrentZone >= 0 && NumCurrentZone < NStripsInLayer && Energy > 0.0) {
423 cluster.AddStrip(NumCurrentZone, Energy);
424 total_signal += Energy;
425 }
426
427 dist += h;
428 }
429 // right border strip
430 NumCurrentZone = (Int_t)RightZonePos;
431
432 h = RightZonePos - (Int_t)RightZonePos;
433 if (h < 0.0)
434 h = 0.0;
435
436 xp = LeftZonePos + dist;
437 S = gausF.Integral(xp, xp + h);
438 Energy = (signal * Gain) * (S / SCluster);
439 Energy += rand.Gaus(0.0, var_level * Energy);
440 if (Energy < 0.0)
441 Energy = 0.0;
442
443 if (NumCurrentZone >= 0 && NumCurrentZone < NStripsInLayer && Energy > 0.0) {
444 cluster.AddStrip(NumCurrentZone, Energy);
445 total_signal += Energy;
446 }
447
448 dist += h;
449 }
450
451 if (cluster.GetClusterSize() <= 0) {
452 return cluster;
453 }
454
455 // find the mean value of the avalanche position (fitting by gaus function)
456 Double_t mean_fit_pos = 0.0;
457
458 Int_t NOutLeftBins = 0;
459 Int_t NOutRightBins = 0;
460 if (OutLeftBorder != 0.0) {
461 NOutLeftBins = (Int_t)(fabs(OutLeftBorder)) + 1;
462 }
463 if (OutRightBorder != 0.0) {
464 NOutRightBins = (Int_t)(OutRightBorder - RightZonePos) + 1;
465 }
466
467 Int_t begin_strip_num = cluster.Strips.at(0);
468 Int_t last_strip_num = cluster.Strips.at(cluster.GetClusterSize() - 1);
469 Int_t nstrips = last_strip_num - begin_strip_num + 1;
470
471 TH1F hist("hist_for_fit", "hist_for_fit", nstrips + NOutLeftBins + NOutRightBins, begin_strip_num - NOutLeftBins,
472 last_strip_num + 1 + NOutRightBins);
473 Int_t hist_index = 0;
474
475 for (Int_t i = 0; i < cluster.GetClusterSize(); ++i) {
476 Double_t value = cluster.Signals.at(i);
477 hist.SetBinContent(hist_index + 1 + NOutLeftBins, value);
478 hist_index++;
479 }
480
481 // on the left border
482 if (NOutLeftBins > 0.0) {
483 Double_t first = OutLeftBorder;
484 Double_t last = (Int_t)OutLeftBorder;
485 Double_t S = gausF.Integral(first, last);
486 Double_t Energy = (signal * Gain) * (S / SCluster);
487 Energy += rand.Gaus(0.0, var_level * Energy);
488 if (Energy < 0.0)
489 Energy = 0.0;
490 Double_t value = Energy;
491 hist.SetBinContent(1, value);
492 dist = 0.0;
493
494 for (Int_t i = 1; i < NOutLeftBins; ++i) {
495 h = 1.0;
496 first = (Int_t)OutLeftBorder + dist;
497 last = first + h;
498 S = gausF.Integral(first, last);
499 Energy = (signal * Gain) * (S / SCluster);
500 Energy += rand.Gaus(0.0, var_level * Energy);
501 if (Energy < 0.0)
502 Energy = 0.0;
503 value = Energy;
504 hist.SetBinContent(1 + i, value);
505 dist += h;
506 }
507 }
508
509 // on the right border
510 if (NOutRightBins > 0.0) {
511 dist = 0.0;
512 for (Int_t i = hist_index; i < hist_index + NOutRightBins - 1; ++i) {
513 h = 1.0;
514 Double_t first = NStripsInLayer + dist;
515 Double_t last = first + h;
516 Double_t S = gausF.Integral(first, last);
517 Double_t Energy = (signal * Gain) * (S / SCluster);
518 Energy += rand.Gaus(0.0, var_level * Energy);
519 if (Energy < 0.0)
520 Energy = 0.0;
521 Double_t value = Energy;
522 hist.SetBinContent(1 + i, value);
523 dist += h;
524 }
525
526 Double_t first = (Int_t)OutRightBorder;
527 Double_t last = first + (OutRightBorder - (Int_t)OutRightBorder);
528 Double_t S = gausF.Integral(first, last);
529 Double_t Energy = (signal * Gain) * (S / SCluster);
530 Energy += rand.Gaus(0.0, var_level * Energy);
531 if (Energy < 0.0)
532 Energy = 0.0;
533 Double_t value = Energy;
534 hist.SetBinContent(hist_index + NOutRightBins, value);
535 }
536
537 TF1* gausFitFunction = 0;
538 TString fit_params = "WQ0";
539
540#ifdef DRAW_REAL_CLUSTER_HISTOGRAMS
541 fit_params = "WQ";
542#endif
543
544 if (nstrips > 1) {
545 hist.Fit("gaus", fit_params); // Q - quit mode (without information on the screen); 0 - not draw
546 gausFitFunction = hist.GetFunction("gaus");
547 if (gausFitFunction) {
548 mean_fit_pos = gausFitFunction->GetParameter(1);
549 } else {
550 mean_fit_pos = hist.GetMean();
551 }
552 } else {
553 mean_fit_pos = hist.GetMean();
554 }
555
556 cluster.MeanPosition = mean_fit_pos;
557 cluster.TotalSignal = total_signal;
558 cluster.PositionResidual = mean_fit_pos - CenterZonePos; // residual between mean and origin positions (lower
559 // cluster): residual = finded(current) - orig(average)
560
561 cluster.IsCorrect = true; // set correct status of the cluster
562 return cluster;
563}
564
566{
567
570
571 Int_t n_strip_layers = StripLayers.size();
572
573 // Find strip clusters and hits in the strip layers -------------------------
574 for (Int_t ilayer = 0; ilayer < n_strip_layers; ++ilayer) {
575 StripLayers[ilayer].FindClustersAndStripHits();
576 }
577 //--------------------------------------------------------------------------
578
579 map<Int_t, Bool_t> UsageStatus_LowerClusters;
580 map<Int_t, Bool_t> UsageStatus_UpperClusters;
581
582 // Saving all unique id marks of clusters in a module
583 for (Int_t ilayer = 0; ilayer < n_strip_layers; ++ilayer) {
584 for (Int_t i_strip_hit = 0; i_strip_hit < StripLayers[ilayer].GetNStripHits(); ++i_strip_hit) {
585 StripCluster cluster = StripLayers[ilayer].GetStripClusters()[i_strip_hit];
586 if (cluster.GetType() == LowerStripLayer) {
587 UsageStatus_LowerClusters[cluster.GetUniqueID()] = false;
588 }
589 if (cluster.GetType() == UpperStripLayer) {
590 UsageStatus_UpperClusters[cluster.GetUniqueID()] = false;
591 }
592 }
593 }
594
595 for (Int_t ilayer = 0; ilayer < n_strip_layers; ++ilayer) {
596 for (Int_t jlayer = ilayer + 1; jlayer < n_strip_layers; ++jlayer) {
597 // cout << "(i-layer : j-layer) = ( " << ilayer << " : " << jlayer << " )\n";
598
599 if (StripLayers[ilayer].GetType() == StripLayers[jlayer].GetType())
600 continue;
601
602 Double_t iAngleRad = StripLayers[ilayer].GetAngleRad();
603 Double_t jAngleRad = StripLayers[jlayer].GetAngleRad();
604
605 if (Abs(iAngleRad - jAngleRad) < 0.01)
606 continue;
607
608 Double_t i_PiOver2MinusAngleRad = PiOver2() - iAngleRad;
609 Double_t j_PiOver2MinusAngleRad = PiOver2() - jAngleRad;
610
611 for (Int_t i_strip_hit = 0; i_strip_hit < StripLayers[ilayer].GetNStripHits(); ++i_strip_hit) {
612 for (Int_t j_strip_hit = 0; j_strip_hit < StripLayers[jlayer].GetNStripHits(); ++j_strip_hit) {
613
614 Double_t iStripHitPos = StripLayers[ilayer].GetStripHitPos(i_strip_hit);
615 Double_t jStripHitPos = StripLayers[jlayer].GetStripHitPos(j_strip_hit);
616
617 Double_t iStripHitError = StripLayers[ilayer].GetStripHitError(i_strip_hit);
618 Double_t jStripHitError = StripLayers[jlayer].GetStripHitError(j_strip_hit);
619
620 Double_t xcoord;
621 Double_t ycoord;
622
623 if (Abs(iAngleRad) >= 0.01 && Abs(jAngleRad) >= 0.01) {
624
625 Double_t iB = StripLayers[ilayer].CalculateStripEquationB(iStripHitPos);
626 Double_t jB = StripLayers[jlayer].CalculateStripEquationB(jStripHitPos);
627
628 xcoord = (jB - iB) / (Tan(i_PiOver2MinusAngleRad) - Tan(j_PiOver2MinusAngleRad));
629 ycoord = Tan(i_PiOver2MinusAngleRad) * xcoord + iB;
630 } else {
631
632 if (Abs(iAngleRad) < 0.01) {
633
634 if (StripLayers[ilayer].GetStripNumberingOrder() == LeftToRight) {
635 xcoord = StripLayers[ilayer].GetXLeftStripBorderPoint()
636 + iStripHitPos * StripLayers[ilayer].GetPitch();
637 } else {
638 xcoord = StripLayers[ilayer].GetXRightStripBorderPoint()
639 - iStripHitPos * StripLayers[ilayer].GetPitch();
640 }
641
642 Double_t jB = StripLayers[jlayer].CalculateStripEquationB(jStripHitPos);
643 ycoord = Tan(j_PiOver2MinusAngleRad) * xcoord + jB;
644 }
645
646 if (Abs(jAngleRad) < 0.01) {
647
648 if (StripLayers[jlayer].GetStripNumberingOrder() == LeftToRight) {
649 xcoord = StripLayers[jlayer].GetXLeftStripBorderPoint()
650 + jStripHitPos * StripLayers[jlayer].GetPitch();
651 } else {
652 xcoord = StripLayers[jlayer].GetXRightStripBorderPoint()
653 - jStripHitPos * StripLayers[jlayer].GetPitch();
654 }
655
656 Double_t iB = StripLayers[ilayer].CalculateStripEquationB(iStripHitPos);
657 ycoord = Tan(i_PiOver2MinusAngleRad) * xcoord + iB;
658 }
659 }
660
661 // check: a point belongs to both strip layers together
662 if (StripLayers[ilayer].IsPointInsideStripLayer(xcoord, ycoord)
663 && StripLayers[jlayer].IsPointInsideStripLayer(xcoord, ycoord))
664 {
665
666 IntersectionPointsX.push_back(xcoord);
667 IntersectionPointsY.push_back(ycoord);
668
669 // Intersection (x,y)-errors from the strip-errors ------
670 Double_t AngleIntersecRad = Abs(iAngleRad - jAngleRad);
671
672 // a rhomb zone is the intersection of the strip errors
673 Double_t RhombSide1 = (iStripHitError * StripLayers[ilayer].GetPitch()) / Sin(AngleIntersecRad);
674 Double_t RhombSide2 = (jStripHitError * StripLayers[jlayer].GetPitch()) / Sin(AngleIntersecRad);
675
676 // x-strip error
677 Double_t xerr1 = Sin(Abs(jAngleRad)) * RhombSide1;
678 Double_t xerr2 = Sin(Abs(iAngleRad)) * RhombSide2;
679 Double_t xcoord_err = xerr1 + xerr2;
680
681 // y-strip error
682 Double_t yerr1 = Cos(Abs(jAngleRad)) * RhombSide1;
683 Double_t yerr2 = Cos(Abs(iAngleRad)) * RhombSide2;
684 Double_t ycoord_err = yerr1 + yerr2;
685
686 IntersectionPointsXErrors.push_back(xcoord_err);
687 IntersectionPointsYErrors.push_back(ycoord_err);
688 //------------------------------------------------------
689
690 // intersection MC-matching -----------------------------
691 BmnMatch iStripMatch = StripLayers[ilayer].GetStripMatch((Int_t)iStripHitPos);
692 BmnMatch jStripMatch = StripLayers[jlayer].GetStripMatch((Int_t)jStripHitPos);
693
694 BmnMatch intersection_match;
695 intersection_match.AddLink(iStripMatch);
696 intersection_match.AddLink(jStripMatch);
697
698 IntersectionPointMatches.push_back(intersection_match);
699 //------------------------------------------------------
700
701 // intersection digit number matching -------------------
702 BmnMatch iStripDigitNumberMatch =
703 StripLayers[ilayer].GetStripDigitNumberMatch((Int_t)iStripHitPos);
704 BmnMatch jStripDigitNumberMatch =
705 StripLayers[jlayer].GetStripDigitNumberMatch((Int_t)jStripHitPos);
706
707 BmnMatch intersection_digit_num_match;
708 intersection_digit_num_match.AddLink(iStripDigitNumberMatch);
709 intersection_digit_num_match.AddLink(jStripDigitNumberMatch);
710
711 IntersectionPointDigitNumberMatches.push_back(intersection_digit_num_match);
712 //------------------------------------------------------
713
714 // Additional information about the intersection ------------
715 // cluster size (number strips) in both strip layers for each intersection
716 Int_t iLayerClusterSize = StripLayers[ilayer].GetStripHitClusterSize(i_strip_hit);
717 Int_t jLayerClusterSize = StripLayers[jlayer].GetStripHitClusterSize(j_strip_hit);
718
719 // strip position in both strip layers for each intersection
720 Double_t iLayerStripPosition = StripLayers[ilayer].ConvertPointToStripPosition(xcoord, ycoord);
721 Double_t jLayerStripPosition = StripLayers[jlayer].ConvertPointToStripPosition(xcoord, ycoord);
722
723 if (StripLayers[ilayer].GetType() == LowerStripLayer) {
724 IntersectionPoints_LowerLayerClusterSize.push_back(iLayerClusterSize);
725 IntersectionPoints_UpperLayerClusterSize.push_back(jLayerClusterSize);
726 IntersectionPoints_LowerLayerStripPosition.push_back(iLayerStripPosition);
727 IntersectionPoints_UpperLayerStripPosition.push_back(jLayerStripPosition);
729 StripLayers[ilayer].GetStripHitTotalSignal(i_strip_hit));
731 StripLayers[jlayer].GetStripHitTotalSignal(j_strip_hit));
732 LowerClusters.push_back(StripLayers[ilayer].GetStripClusters().at(i_strip_hit));
733 UpperClusters.push_back(StripLayers[jlayer].GetStripClusters().at(j_strip_hit));
734 UsageStatus_LowerClusters
735 [StripLayers[ilayer].GetStripClusters()[i_strip_hit].GetUniqueID()] = true;
736 UsageStatus_UpperClusters
737 [StripLayers[jlayer].GetStripClusters()[j_strip_hit].GetUniqueID()] = true;
738 } else {
739 IntersectionPoints_LowerLayerClusterSize.push_back(jLayerClusterSize);
740 IntersectionPoints_UpperLayerClusterSize.push_back(iLayerClusterSize);
741 IntersectionPoints_LowerLayerStripPosition.push_back(jLayerStripPosition);
742 IntersectionPoints_UpperLayerStripPosition.push_back(iLayerStripPosition);
744 StripLayers[jlayer].GetStripHitTotalSignal(j_strip_hit));
746 StripLayers[ilayer].GetStripHitTotalSignal(i_strip_hit));
747 LowerClusters.push_back(StripLayers[jlayer].GetStripClusters().at(j_strip_hit));
748 UpperClusters.push_back(StripLayers[ilayer].GetStripClusters().at(i_strip_hit));
749 UsageStatus_LowerClusters
750 [StripLayers[jlayer].GetStripClusters()[j_strip_hit].GetUniqueID()] = true;
751 UsageStatus_UpperClusters
752 [StripLayers[ilayer].GetStripClusters()[i_strip_hit].GetUniqueID()] = true;
753 }
754 //------------------------------------------------------
755 }
756 }
757 }
758 }
759 }
760
761 /*for(auto it : UsageStatus_UpperClusters) {
762 if(it.second == false) cout << " upper_cluster[" << it.first << "] = " << it.second << "\n";
763 }*/
764
765 for (auto it : UsageStatus_LowerClusters) {
766
767 // if(it.second == false) cout << " lower_cluster[" << it.first << "] = " << it.second << "\n";
768
769 if (it.second == false) {
770
771 for (Int_t ilayer = 0; ilayer < n_strip_layers; ++ilayer) {
772
773 if (StripLayers[ilayer].GetType() != LowerStripLayer)
774 continue;
775
776 for (size_t icluster = 0; icluster < StripLayers[ilayer].GetStripClusters().size(); ++icluster) {
777 StripCluster cluster = StripLayers[ilayer].GetStripClusters()[icluster];
778
779 if ((int)cluster.GetUniqueID() != it.first)
780 continue;
781
782 Double_t xcoord;
783 Double_t ycoord;
784
785 if (StripLayers[ilayer].GetStripNumberingOrder() == LeftToRight) {
786 xcoord = StripLayers[ilayer].GetXLeftStripBorderPoint()
787 + cluster.MeanPosition * StripLayers[ilayer].GetPitch();
788 } else {
789 xcoord = StripLayers[ilayer].GetXRightStripBorderPoint()
790 - cluster.MeanPosition * StripLayers[ilayer].GetPitch();
791 }
792
793 ycoord = (StripLayers[ilayer].GetYMinLayer() + StripLayers[ilayer].GetYMaxLayer()) * 0.5;
794
795 Double_t xerr = cluster.Error * StripLayers[ilayer].GetPitch();
796 Double_t yerr = StripLayers[ilayer].GetYSize() * 0.5;
797
798 // cout << " low_cluster[" << icluster << "]:\n";
799 // cout << " ID = " << cluster.GetUniqueID() << "\n";
800 // cout << " xcoord = " << xcoord << "\n";
801 // cout << " xmin = " << StripLayers[ilayer].GetXMinLayer() << ", xmax = " <<
802 // StripLayers[ilayer].GetXMaxLayer() << "\n"; cout << " ycoord = " << ycoord << "\n"; cout << "
803 // ymin = " << StripLayers[ilayer].GetYMinLayer() << ", ymax = " <<
804 // StripLayers[ilayer].GetYMaxLayer() << "\n"; cout << " xerr = " << xerr << "\n"; cout << " yerr
805 // = " << yerr << "\n"; cout << "\n";
806
807 PseudoIntersectionsX.push_back(xcoord);
808 PseudoIntersectionsY.push_back(ycoord);
809
810 PseudoIntersectionsXErrors.push_back(xerr);
811 PseudoIntersectionsYErrors.push_back(yerr);
812
815
817 StripLayers[ilayer].ConvertPointToStripPosition(xcoord, ycoord));
819
822
824 StripLayers[ilayer].GetStripMatch((Int_t)cluster.MeanPosition)); // mc-match
825 PseudoIntersectionDigitNumberMatches.push_back(StripLayers[ilayer].GetStripDigitNumberMatch(
826 (Int_t)cluster.MeanPosition)); // digit number matches
827
828 LowerClusters_PseudoIntersections.push_back(cluster);
830 StripCluster()); // empty cluster with default parameters
831 }
832 }
833 }
834 }
835}
836
837// need for a separated test (find x,y intersection coords from strip positions)
839 Double_t& y,
840 Double_t strip_pos_layerA,
841 Double_t strip_pos_layerB,
842 Int_t layerA_index,
843 Int_t layerB_index)
844{
845
846 Int_t ilayer = layerA_index;
847 Int_t jlayer = layerB_index;
848
849 if (StripLayers[ilayer].GetType() == StripLayers[jlayer].GetType())
850 return false;
851
852 Double_t iAngleRad = StripLayers[ilayer].GetAngleRad();
853 Double_t jAngleRad = StripLayers[jlayer].GetAngleRad();
854
855 if (Abs(iAngleRad - jAngleRad) < 0.01)
856 return false;
857
858 Double_t i_PiOver2MinusAngleRad = PiOver2() - iAngleRad;
859 Double_t j_PiOver2MinusAngleRad = PiOver2() - jAngleRad;
860
861 Double_t iStripHitPos = strip_pos_layerA;
862 Double_t jStripHitPos = strip_pos_layerB;
863
864 Double_t xcoord;
865 Double_t ycoord;
866
867 if (Abs(iAngleRad) >= 0.01 && Abs(jAngleRad) >= 0.01) {
868
869 Double_t iB = StripLayers[ilayer].CalculateStripEquationB(iStripHitPos);
870 Double_t jB = StripLayers[jlayer].CalculateStripEquationB(jStripHitPos);
871
872 xcoord = (jB - iB) / (Tan(i_PiOver2MinusAngleRad) - Tan(j_PiOver2MinusAngleRad));
873 ycoord = Tan(i_PiOver2MinusAngleRad) * xcoord + iB;
874 } else {
875
876 if (Abs(iAngleRad) < 0.01) {
877
878 if (StripLayers[ilayer].GetStripNumberingOrder() == LeftToRight) {
879 xcoord = StripLayers[ilayer].GetXLeftStripBorderPoint() + iStripHitPos * StripLayers[ilayer].GetPitch();
880 } else {
881 xcoord =
882 StripLayers[ilayer].GetXRightStripBorderPoint() - iStripHitPos * StripLayers[ilayer].GetPitch();
883 }
884
885 Double_t jB = StripLayers[jlayer].CalculateStripEquationB(jStripHitPos);
886 ycoord = Tan(j_PiOver2MinusAngleRad) * xcoord + jB;
887 }
888
889 if (Abs(jAngleRad) < 0.01) {
890
891 if (StripLayers[jlayer].GetStripNumberingOrder() == LeftToRight) {
892 xcoord = StripLayers[jlayer].GetXLeftStripBorderPoint() + jStripHitPos * StripLayers[jlayer].GetPitch();
893 } else {
894 xcoord =
895 StripLayers[jlayer].GetXRightStripBorderPoint() - jStripHitPos * StripLayers[jlayer].GetPitch();
896 }
897
898 Double_t iB = StripLayers[ilayer].CalculateStripEquationB(iStripHitPos);
899 ycoord = Tan(i_PiOver2MinusAngleRad) * xcoord + iB;
900 }
901 }
902
903 x = xcoord;
904 y = ycoord;
905
906 // check: a point belongs to both strip layers together
907 if (StripLayers[ilayer].IsPointInsideStripLayer(xcoord, ycoord)
908 && StripLayers[jlayer].IsPointInsideStripLayer(xcoord, ycoord))
909 {
910 return true;
911 }
912
913 return false;
914}
915
933
951
953{
954
955 if (StripLayers.size() == 0)
956 return;
957
958 XMinModule = 1.0E+10;
959 XMaxModule = -1.0E+10;
960 YMinModule = 1.0E+10;
961 YMaxModule = -1.0E+10;
962
963 for (size_t ilayer = 0; ilayer < StripLayers.size(); ++ilayer) {
964 if (StripLayers[ilayer].GetXMinLayer() < XMinModule)
965 XMinModule = StripLayers[ilayer].GetXMinLayer();
966 if (StripLayers[ilayer].GetXMaxLayer() > XMaxModule)
967 XMaxModule = StripLayers[ilayer].GetXMaxLayer();
968 if (StripLayers[ilayer].GetYMinLayer() < YMinModule)
969 YMinModule = StripLayers[ilayer].GetYMinLayer();
970 if (StripLayers[ilayer].GetYMaxLayer() > YMaxModule)
971 YMaxModule = StripLayers[ilayer].GetYMaxLayer();
972 }
973 return;
974}
vector< Double_t > dist(vector< Double_t > qp, Double_t mu)
Definition BmnMath.cxx:869
friend F32vec4 fabs(const F32vec4 &a)
Definition P4_F32vec4.h:52
int i
Definition P4_F32vec4.h:22
bool Bool_t
int Int_t
double Double_t
R__EXTERN TRandom * gRandom
@ LeftToRight
@ UpperStripLayer
@ LowerStripLayer
vector< Double_t > PseudoIntersections_UpperLayerStripTotalSignal
vector< BmnMatch > PseudoIntersectionMatches
vector< Double_t > RealPointsY
Bool_t AddRealPointFullOne(Double_t x, Double_t y, Double_t z, Double_t px, Double_t py, Double_t pz, Double_t signal, Int_t refID)
vector< Double_t > PseudoIntersectionsX
void DefineModuleBorders()
Bool_t SetStripDigitNumberMatchInLayer(Int_t layer_num, Int_t strip_num, BmnMatch digit_num_match)
vector< Double_t > PseudoIntersectionsY
virtual ~BmnCSCModule()
vector< BmnMatch > PseudoIntersectionDigitNumberMatches
void ResetRealPoints()
vector< StripCluster > LowerClusters_PseudoIntersections
vector< Double_t > PseudoIntersectionsXErrors
Double_t GetStripSignalInLayer(Int_t layer_num, Int_t strip_num)
vector< BmnCSCLayer > StripLayers
vector< Double_t > IntersectionPoints_UpperLayerStripTotalSignal
vector< Int_t > IntersectionPoints_LowerLayerClusterSize
Double_t ModuleThickness
Double_t XMinModule
Bool_t AddRealPointSimple(Double_t x, Double_t y, Double_t z, Double_t px, Double_t py, Double_t pz, Double_t signal, Int_t refID)
vector< Double_t > IntersectionPointsX
void ResetModuleData()
vector< Double_t > IntersectionPoints_LowerLayerStripTotalSignal
vector< Double_t > IntersectionPointsY
Double_t ZStartModulePosition
vector< Int_t > PseudoIntersections_UpperLayerClusterSize
BmnMatch GetStripMatchInLayer(Int_t layer_num, Int_t strip_num)
vector< StripCluster > UpperClusters
void CalculateStripHitIntersectionPoints()
Double_t GetZPositionRegistered()
BmnMatch GetStripDigitNumberMatchInLayer(Int_t layer_num, Int_t strip_num)
StripCluster MakeCluster(Int_t layer_num, Double_t xcoord, Double_t ycoord, Double_t signal, Double_t radius)
Double_t XMaxModule
Bool_t SetStripMatchInLayer(Int_t layer_num, Int_t strip_num, BmnMatch mc_match)
vector< Double_t > IntersectionPointsXErrors
Double_t YMaxModule
vector< BmnMatch > IntersectionPointDigitNumberMatches
vector< Double_t > IntersectionPoints_LowerLayerStripPosition
vector< Double_t > PseudoIntersections_LowerLayerStripTotalSignal
Bool_t AddStripSignalInLayer(Int_t layer_num, Int_t strip_num, Double_t signal)
vector< Double_t > PseudoIntersections_LowerLayerStripPosition
Bool_t IsPointInsideZThickness(Double_t z)
Bool_t IsPointInsideModule(Double_t x, Double_t y)
vector< Double_t > PseudoIntersections_UpperLayerStripPosition
void ResetIntersectionPoints()
void ResetPseudoIntersections()
Bool_t SetStripSignalInLayer(Int_t layer_num, Int_t strip_num, Double_t signal)
void AddStripLayer(BmnCSCLayer strip_layer)
vector< Double_t > IntersectionPoints_UpperLayerStripPosition
vector< Int_t > PseudoIntersections_LowerLayerClusterSize
vector< Double_t > RealPointsX
Double_t YMinModule
vector< Double_t > IntersectionPointsYErrors
vector< Double_t > PseudoIntersectionsYErrors
vector< StripCluster > UpperClusters_PseudoIntersections
Bool_t SearchIntersectionPoint(Double_t &x, Double_t &y, Double_t strip_pos_layerA, Double_t strip_pos_layerB, Int_t layerA_index, Int_t layerB_index)
vector< StripCluster > LowerClusters
vector< Double_t > RealPointsMC
vector< Int_t > IntersectionPoints_UpperLayerClusterSize
vector< BmnMatch > IntersectionPointMatches
void AddLink(const BmnMatch &match)
Definition BmnMatch.cxx:40
Double_t TotalSignal
Int_t GetClusterSize()
Int_t GetType()
Double_t MeanPosition
Double_t Error
void AddStrip(Int_t strip_num, Double_t strip_signal)
Double_t PositionResidual
vector< Int_t > Strips
vector< Double_t > Signals
virtual Double_t GetParameter(const TString &name) const
virtual Double_t Integral(Double_t a, Double_t b, Double_t epsrel=1.e-12)
virtual void SetParameter(const TString &name, Double_t value)
virtual Double_t GetMean(Int_t axis=1) const
virtual TFitResultPtr Fit(const char *formula, Option_t *option="", Option_t *goption="", Double_t xmin=0, Double_t xmax=0)
virtual void SetBinContent(Int_t bin, Double_t content)
virtual TF1 * GetFunction(const char *name) const
virtual UInt_t GetUniqueID() const
virtual Double_t Gaus(Double_t mean=0, Double_t sigma=1)
constexpr Double_t PiOver2()
constexpr Double_t Sigma()
Double_t Cos(Double_t)
Double_t Abs(Double_t d)
Double_t Sin(Double_t)
Double_t Tan(Double_t)