BmnRoot 26.10.0-233-gb9bbe585
Software framework of the BM@N experiment
Loading...
Searching...
No Matches
BmnVSPModule.cxx
Go to the documentation of this file.
1#include "BmnVSPModule.h"
2
3#include "TF1.h"
4#include "TH1F.h"
5#include "TMath.h"
6#include "TRandom.h"
7
8#include <iostream>
9
10using namespace TMath;
11using namespace std;
12
14{
15
16 Verbosity = true;
17
19 ModuleThickness = 0.03; // cm
20 XMinModule = 0.0;
21 XMaxModule = 0.0;
22 YMinModule = 0.0;
23 YMaxModule = 0.0;
24}
25
27{
28
29 Verbosity = true;
30
31 ZStartModulePosition = z_start_pos;
32 ModuleThickness = 0.03; // cm
33 XMinModule = 0.0;
34 XMaxModule = 0.0;
35 YMinModule = 0.0;
36 YMaxModule = 0.0;
37}
38
40
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, mc_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 Int_t n_layers_the_same_id = 0;
88 for (size_t ilayer = 0; ilayer < StripLayers.size(); ++ilayer) {
89 if ((StripLayers[ilayer].GetZoneID() == zone_id)) {
90 if (StripLayers[ilayer].SetStripSignal(strip_num, signal))
91 n_layers_the_same_id++;
92 }
93 }
94 return (Bool_t)n_layers_the_same_id;
95}
96
98{
99 Int_t n_layers_the_same_id = 0;
100 for (size_t ilayer = 0; ilayer < StripLayers.size(); ++ilayer) {
101 if ((StripLayers[ilayer].GetZoneID() == zone_id)) {
102 if (StripLayers[ilayer].AddStripSignal(strip_num, signal))
103 n_layers_the_same_id++;
104 }
105 }
106 return (Bool_t)n_layers_the_same_id;
107}
108
110{
111 Int_t n_layers_the_same_id = 0;
112 for (size_t ilayer = 0; ilayer < StripLayers.size(); ++ilayer) {
113 if ((StripLayers[ilayer].GetZoneID() == zone_id)) {
114 if (StripLayers[ilayer].SetStripMatch(strip_num, mc_match))
115 n_layers_the_same_id++;
116 }
117 }
118 return (Bool_t)n_layers_the_same_id;
119}
120
122{
123 Int_t n_layers_the_same_id = 0;
124 for (size_t ilayer = 0; ilayer < StripLayers.size(); ++ilayer) {
125 if ((StripLayers[ilayer].GetZoneID() == zone_id)) {
126 if (StripLayers[ilayer].AddLinkToStripMatch(strip_num, weight, mc_num))
127 n_layers_the_same_id++;
128 }
129 }
130 return (Bool_t)n_layers_the_same_id;
131}
132
134{
135 Int_t n_layers_the_same_id = 0;
136 for (size_t ilayer = 0; ilayer < StripLayers.size(); ++ilayer) {
137 if ((StripLayers[ilayer].GetZoneID() == zone_id)) {
138 if (StripLayers[ilayer].SetStripDigitNumberMatch(strip_num, digit_num_match))
139 n_layers_the_same_id++;
140 }
141 }
142 return (Bool_t)n_layers_the_same_id;
143}
144
146 Int_t strip_num,
147 Double_t weight,
148 Int_t digit_num)
149{
150 Int_t n_layers_the_same_id = 0;
151 for (size_t ilayer = 0; ilayer < StripLayers.size(); ++ilayer) {
152 if ((StripLayers[ilayer].GetZoneID() == zone_id)) {
153 if (StripLayers[ilayer].AddLinkToStripDigitNumberMatch(strip_num, weight, digit_num))
154 n_layers_the_same_id++;
155 }
156 }
157 return (Bool_t)n_layers_the_same_id;
158}
159
161{
162 if (layer_num >= 0 && layer_num < (Int_t)StripLayers.size()) {
163 return StripLayers[layer_num].GetStripSignal(strip_num);
164 }
165 return -1;
166}
167
169{
170 if (layer_num >= 0 && layer_num < (Int_t)StripLayers.size()) {
171 return StripLayers[layer_num].GetStripMatch(strip_num);
172 }
173 return BmnMatch();
174}
175
177{
178 if (layer_num >= 0 && layer_num < (Int_t)StripLayers.size()) {
179 return StripLayers[layer_num].GetStripDigitNumberMatch(strip_num);
180 }
181 return BmnMatch();
182}
183
185{
186 Int_t first_strip = 1E6;
187
188 for (size_t ilayer = 0; ilayer < StripLayers.size(); ++ilayer) {
189 if ((StripLayers[ilayer].GetZoneID() == zone_id)) {
190 Int_t first_strip_curr_layer = StripLayers[ilayer].GetFirstStripNumber();
191 if (first_strip > first_strip_curr_layer)
192 first_strip = first_strip_curr_layer;
193 }
194 }
195 return first_strip;
196}
197
199{
200 Int_t last_strip = 0;
201
202 for (size_t ilayer = 0; ilayer < StripLayers.size(); ++ilayer) {
203 if ((StripLayers[ilayer].GetZoneID() == zone_id)) {
204 Int_t last_strip_curr_layer = StripLayers[ilayer].GetLastStripNumber();
205 if (last_strip < last_strip_curr_layer)
206 last_strip = last_strip_curr_layer;
207 }
208 }
209 return last_strip;
210}
211
213{
214 for (size_t ilayer = 0; ilayer < StripLayers.size(); ++ilayer) {
215 if ((StripLayers[ilayer].GetZoneID() == zone_id)) {
216 if (strip_num >= StripLayers[ilayer].GetFirstStripNumber()
217 && strip_num <= StripLayers[ilayer].GetLastStripNumber())
218 {
219 return StripLayers[ilayer].GetStripSignal(strip_num);
220 }
221 }
222 }
223 return -1;
224}
225
227{
228 for (size_t ilayer = 0; ilayer < StripLayers.size(); ++ilayer) {
229 if ((StripLayers[ilayer].GetZoneID() == zone_id)) {
230 if (strip_num >= StripLayers[ilayer].GetFirstStripNumber()
231 && strip_num <= StripLayers[ilayer].GetLastStripNumber())
232 {
233 return StripLayers[ilayer].GetStripMatch(strip_num);
234 }
235 }
236 }
237 return BmnMatch();
238}
239
241{
242 for (size_t ilayer = 0; ilayer < StripLayers.size(); ++ilayer) {
243 if ((StripLayers[ilayer].GetZoneID() == zone_id)) {
244 if (strip_num >= StripLayers[ilayer].GetFirstStripNumber()
245 && strip_num <= StripLayers[ilayer].GetLastStripNumber())
246 {
247 return StripLayers[ilayer].GetStripDigitNumberMatch(strip_num);
248 }
249 }
250 }
251 return BmnMatch();
252}
253
255{
256 for (size_t ilayer = 0; ilayer < StripLayers.size(); ++ilayer)
257 StripLayers[ilayer].ResetLayer();
258
260
264}
265
267{
268
269 for (size_t ilayer = 0; ilayer < StripLayers.size(); ++ilayer) {
270 if (StripLayers[ilayer].IsPointInsideStripLayer(x, y))
271 return true;
272 }
273 return false;
274}
275
277{
278 Double_t coord_eps = 0.01; // 100 um
279 if (((z > ZStartModulePosition) || (fabs(z - ZStartModulePosition) < coord_eps))
281 || (fabs(z - (ZStartModulePosition + ModuleThickness))) < coord_eps))
282 {
283 if (IsPointInsideModule(x, y))
284 return true;
285 }
286 return false;
287}
288
290{
291 Double_t coord_eps = 0.01; // 100 um
292 if (((z > ZStartModulePosition) || (fabs(z - ZStartModulePosition) < coord_eps))
294 || (fabs(z - (ZStartModulePosition + ModuleThickness))) < coord_eps))
295 {
296 return true;
297 }
298 return false;
299}
300
301// Add a single point without smearing
303 Double_t y,
304 Double_t z,
305 Double_t px,
306 Double_t py,
307 Double_t pz,
308 Double_t signal,
309 Int_t refID)
310{
311
312 // Effective XY position at the middle of the detector thickness (dz/2) -----
313
314 // Distance from entry point (x,y,z) to the midde of the detector (along z-axis)
315 Double_t z_dist_mid = ModuleThickness * 0.5;
316 Double_t vector_coeff_mid = fabs(z_dist_mid / pz); // for middle point
317
318 Double_t x_vec_from_in_to_mid = vector_coeff_mid * px;
319 Double_t y_vec_from_in_to_mid = vector_coeff_mid * py;
320 // Double_t z_vec_from_in_to_mid = vector_coeff_mid*pz;
321
322 // Middle point coordinates (x_mid, y_mid, z_mid)
323 Double_t x_mid = x + x_vec_from_in_to_mid;
324 Double_t y_mid = y + y_vec_from_in_to_mid;
325 // Double_t z_mid = z + z_vec_from_in_to_mid;
326 //--------------------------------------------------------------------------
327
328 if (IsPointInsideModule(x, y)) {
329
330 size_t n_strip_layers = StripLayers.size();
331
332 // Add a signal to the strips layers ------------------------------------
333 for (size_t ilayer = 0; ilayer < n_strip_layers; ++ilayer) {
334 if (!StripLayers[ilayer].IsPointInsideStripLayer(x_mid, y_mid))
335 continue;
336
337 Double_t strip_pos = StripLayers[ilayer].ConvertPointToStripPosition(x_mid, y_mid);
338 Int_t zone_id = StripLayers[ilayer].GetZoneID();
339
340 AddStripSignalInLayerByZoneId(zone_id, (Int_t)strip_pos, signal);
341
342 // strip match
343 AddStripMatchInLayerByZoneId(zone_id, (Int_t)strip_pos, signal, refID);
344 }
345 //----------------------------------------------------------------------
346
347 RealPointsX.push_back(x);
348 RealPointsY.push_back(y);
349 RealPointsMC.push_back(refID);
350
351 return true;
352 } else {
353 if (Verbosity)
354 cerr << "WARNING: BmnVSPModule::AddRealPointSimple(): Point (" << x << " : " << y
355 << ") is out of the readout plane or inside a dead zone\n";
356 return false;
357 }
358}
359
360// Add single point with Gaussian smearing
362 Double_t y,
363 Double_t z,
364 Double_t px,
365 Double_t py,
366 Double_t pz,
367 Double_t signal,
368 Int_t refID)
369{
370
371 if (IsPointInsideModule(x, y)) {
372
373 if (signal <= 0.0)
374 signal = 1e-16;
375
376 Double_t AvalancheRadius = 0.01; // cm
377
378 Double_t radius = AvalancheRadius;
379 if (radius <= 0.0)
380 return false;
381
382 // AZ-260322 gRandom->SetSeed(0);
383
384 Int_t cycle_cnt = 0;
385 while (true) {
386 radius = gRandom->Gaus(AvalancheRadius, 0.005);
387 if (radius > AvalancheRadius / 2.0 && radius < AvalancheRadius * 2.0 && radius > 0.0)
388 break;
389 cycle_cnt++;
390
391 if (cycle_cnt > 5) {
392 radius = AvalancheRadius;
393 break;
394 }
395 }
396
397 // Make strip cluster in each strip layer -------------------------------
398 Int_t n_strip_layers = StripLayers.size();
399 vector<StripCluster> cluster_layers(n_strip_layers, StripCluster());
400
401 for (Int_t ilayer = 0; ilayer < n_strip_layers; ++ilayer) {
402 if (!StripLayers[ilayer].IsPointInsideStripLayer(x, y))
403 continue;
404 cluster_layers[ilayer] = MakeCluster(ilayer, x, y, signal, radius);
405 }
406 //----------------------------------------------------------------------
407
408 // Add the correct clusters to the strip layers -------------------------
409 for (Int_t ilayer = 0; ilayer < n_strip_layers; ++ilayer) {
410 for (size_t ielement = 0; ielement < cluster_layers[ilayer].Strips.size(); ++ielement) {
411 Int_t strip_num = cluster_layers[ilayer].Strips.at(ielement);
412 Double_t strip_signal = cluster_layers[ilayer].Signals.at(ielement);
413 Int_t zone_id = StripLayers[ilayer].GetZoneID();
414 AddStripSignalInLayerByZoneId(zone_id, strip_num, strip_signal);
415 }
416 }
417 //----------------------------------------------------------------------
418
419 // Fill strip matches ---------------------------------------------------
420 for (Int_t ilayer = 0; ilayer < n_strip_layers; ++ilayer) {
421 for (size_t ielement = 0; ielement < cluster_layers[ilayer].Strips.size(); ++ielement) {
422 Int_t strip_num = cluster_layers[ilayer].Strips.at(ielement);
423 Double_t strip_signal = cluster_layers[ilayer].Signals.at(ielement);
424 Int_t zone_id = StripLayers[ilayer].GetZoneID();
425 AddStripMatchInLayerByZoneId(zone_id, strip_num, strip_signal, refID);
426 }
427 }
428 //----------------------------------------------------------------------
429
430 RealPointsX.push_back(x);
431 RealPointsY.push_back(y);
432 RealPointsMC.push_back(refID);
433
434 return true;
435 } else {
436 if (Verbosity)
437 cerr << "WARNING: BmnVSPModule::AddRealPointFullOne(): Point (" << x << " : " << y << " : " << z
438 << ") is out of the readout plane or inside a dead zone\n";
439 return false;
440 }
441}
442
443// Add single point with Gaussian smearing + taking into account particle track incline
445 Double_t y,
446 Double_t z,
447 Double_t px,
448 Double_t py,
449 Double_t pz,
450 Double_t signal,
451 Int_t refID)
452{
453
454 // Effective XY position at the middle of the detector thickness (dz/2) -----
455
456 // Distance from entry point (x,y,z) to the midde of the detector (along z-axis)
457 Double_t z_dist_mid = ModuleThickness * 0.5;
458 Double_t vector_coeff_mid = fabs(z_dist_mid / pz); // for middle point
459
460 Double_t x_vec_from_in_to_mid = vector_coeff_mid * px;
461 Double_t y_vec_from_in_to_mid = vector_coeff_mid * py;
462 // Double_t z_vec_from_in_to_mid = vector_coeff_mid*pz_loc;
463
464 // Middle point coordinates (x_mid, y_mid, z_mid)
465 Double_t x_mid = x + x_vec_from_in_to_mid;
466 Double_t y_mid = y + y_vec_from_in_to_mid;
467 // Double_t z_mid = z_loc + z_vec_from_in_to_mid;
468 //--------------------------------------------------------------------------
469
470 if (IsPointInsideModule(x, y)) {
471
472 if (signal <= 0.0)
473 signal = 1e-16;
474
475 Double_t AvalancheRadius = 0.015; // cm
476
477 Double_t radius = AvalancheRadius;
478 if (radius <= 0.0)
479 return false;
480
481 // AZ-260322 gRandom->SetSeed(0);
482
483 Int_t cycle_cnt = 0;
484 while (true) {
485 radius = gRandom->Gaus(AvalancheRadius, 0.005);
486 if (radius > AvalancheRadius / 2.0 && radius < AvalancheRadius * 2.0 && radius > 0.0)
487 break;
488 cycle_cnt++;
489
490 if (cycle_cnt > 5) {
491 radius = AvalancheRadius;
492 break;
493 }
494 }
495
496 // Make strip cluster in each strip layer -------------------------------
497 Int_t n_strip_layers = StripLayers.size();
498 vector<StripCluster> cluster_layers(n_strip_layers, StripCluster());
499
500 for (Int_t ilayer = 0; ilayer < n_strip_layers; ++ilayer) {
501 if (!StripLayers[ilayer].IsPointInsideStripLayer(x_mid, y_mid))
502 continue;
503 cluster_layers[ilayer] = MakeCluster(ilayer, x_mid, y_mid, signal, radius);
504 }
505 //----------------------------------------------------------------------
506
507 // Add the correct clusters to the strip layers -------------------------
508 for (Int_t ilayer = 0; ilayer < n_strip_layers; ++ilayer) {
509 for (size_t ielement = 0; ielement < cluster_layers[ilayer].Strips.size(); ++ielement) {
510 Int_t strip_num = cluster_layers[ilayer].Strips.at(ielement);
511 Double_t strip_signal = cluster_layers[ilayer].Signals.at(ielement);
512 Int_t zone_id = StripLayers[ilayer].GetZoneID();
513 AddStripSignalInLayerByZoneId(zone_id, strip_num, strip_signal);
514 }
515 }
516 //----------------------------------------------------------------------
517
518 // Fill strip matches ---------------------------------------------------
519 for (Int_t ilayer = 0; ilayer < n_strip_layers; ++ilayer) {
520 for (size_t ielement = 0; ielement < cluster_layers[ilayer].Strips.size(); ++ielement) {
521 Int_t strip_num = cluster_layers[ilayer].Strips.at(ielement);
522 Double_t strip_signal = cluster_layers[ilayer].Signals.at(ielement);
523 Int_t zone_id = StripLayers[ilayer].GetZoneID();
524 AddStripMatchInLayerByZoneId(zone_id, strip_num, strip_signal, refID);
525 }
526 }
527 //----------------------------------------------------------------------
528
529 RealPointsX.push_back(x);
530 RealPointsY.push_back(y);
531 RealPointsMC.push_back(refID);
532
533 return true;
534 } else {
535 if (Verbosity)
536 cerr << "WARNING: BmnVSPModule::AddRealPointFullOne(): Point (" << x << " : " << y << " : " << z
537 << ") is out of the readout plane or inside a dead zone\n";
538 return false;
539 }
540}
541
543 Double_t y,
544 Double_t z,
545 Double_t px,
546 Double_t py,
547 Double_t pz,
548 Double_t signal,
549 Int_t refID)
550{
551
552 // Parameters of the signal simulation of one charge carrier (electron or hole)
553 // Double_t chargedCarrierCloudRadius = 0.005; //Signal radius (not diameter!) for ONE STEP (cm) ~50 micron (for
554 // large step)
555 Double_t chargedCarrierCloudRadius = gRandom->Uniform(
556 0.0001, 0.0005); // Signal radius (not diameter!) for ONE STEP (cm) 1-5 micron (for small step)
557 Double_t step = 0.0010; // simulation step (is not mean collision dist. for semiconductors!)
558 //--------------------------------------------------------------------------
559
560 if (IsPointInsideModule(x, y)) {
561
562 // Distance from entry point (x,y,z) to exit point (along z-axis)
563 Double_t z_distance_from_in_to_out;
564
565 // Condition: track direction along z-axis
566 if (pz > 0.0) {
567 z_distance_from_in_to_out = ModuleThickness - (z - ZStartModulePosition);
568 } else {
569 z_distance_from_in_to_out = z - ZStartModulePosition;
570 }
571
572 // Condition: track distance along z-axis must be not zero
573 if (z_distance_from_in_to_out <= 0.0) {
574 if (Verbosity)
575 cerr << "WARNING: BmnVSPModule::AddRealPointFull(): Point (" << x << " : " << y << " : " << z
576 << ") has a track with an incorrect length\n";
577 return false;
578 }
579
580 // Scale coefficient of the track vector (the path from entry point to exit point)
581 Double_t vector_coeff = fabs(z_distance_from_in_to_out / pz);
582
583 // Components of the track vector
584 Double_t x_vec_from_in_to_out = vector_coeff * px;
585 Double_t y_vec_from_in_to_out = vector_coeff * py;
586 Double_t z_vec_from_in_to_out = vector_coeff * pz;
587
588 // Exit point coordinates (x_out, y_out, z_out)
589 Double_t x_out = x + x_vec_from_in_to_out;
590 Double_t y_out = y + y_vec_from_in_to_out;
591 // Double_t z_out = z_loc + z_vec_from_in_to_out;
592
593 // Check if the exit point is outside the module then calculate new x_out, y_out, z_out values
594 // Condition: x-coordinate of the exit point is inside the module
595 if (x_out < XMinModule || x_out > XMaxModule) {
596 if (x_out < XMinModule)
597 x_out = XMinModule;
598 if (x_out > XMaxModule)
599 x_out = XMaxModule;
600
601 x_vec_from_in_to_out = x_out - x;
602 vector_coeff = x_vec_from_in_to_out / px;
603
604 y_vec_from_in_to_out = vector_coeff * py;
605 z_vec_from_in_to_out = vector_coeff * pz;
606
607 y_out = y + y_vec_from_in_to_out;
608 // z_out = z_loc + z_vec_from_in_to_out;
609 }
610 // Condition: y-coordinate of the exit point is inside the module
611 if (y_out < YMinModule || y_out > YMaxModule) {
612 if (y_out < YMinModule)
613 y_out = YMinModule;
614 if (y_out > YMaxModule)
615 y_out = YMaxModule;
616
617 y_vec_from_in_to_out = y_out - y;
618 vector_coeff = y_vec_from_in_to_out / py;
619
620 x_vec_from_in_to_out = vector_coeff * px;
621 z_vec_from_in_to_out = vector_coeff * pz;
622
623 x_out = x + x_vec_from_in_to_out;
624 // z_out = z + z_vec_from_in_to_out;
625 }
626 //----------------------------------------------------------------------
627
628 // Common track length (Fix: a square root!)
629 Double_t track_length =
630 std::sqrt((x_vec_from_in_to_out) * (x_vec_from_in_to_out) + (y_vec_from_in_to_out) * (y_vec_from_in_to_out)
631 + (z_vec_from_in_to_out) * (z_vec_from_in_to_out));
632
633 Double_t current_length = 0.0; // traversed length (counter)
634 Double_t current_length_ratio = 0.0; // ratio of the traversed length to common track length (counter)
635
636 Int_t collisions_cnt = 0; // total collision counter
637 Double_t current_step = 0.0; // current distance between two collision points
638
639 // Collection of collision points
640 std::vector<CollPoint> collision_points;
641
642 while (current_length < track_length) {
643
644 // current_step = rand.Exp(step);
645 current_step = step;
646 current_length += current_step;
647
648 if (current_length > track_length)
649 break;
650
651 current_length_ratio = current_length / track_length;
652
653 Double_t current_x = x + current_length_ratio * x_vec_from_in_to_out;
654 Double_t current_y = y + current_length_ratio * y_vec_from_in_to_out;
655 Double_t current_z = z + current_length_ratio * z_vec_from_in_to_out;
656
657 collision_points.push_back(CollPoint(current_x, current_y, current_z));
658 collisions_cnt++;
659 }
660 //----------------------------------------------------------------------
661
662 if (signal <= 0.0)
663 signal = 0;
664
665 Int_t n_collisions = collision_points.size();
666 Double_t signal_per_step = signal / n_collisions;
667
668 for (Int_t icollpoint = 0; icollpoint < n_collisions; ++icollpoint) {
669
670 // generate the current signal radius on strips for the current charged carrier
671 Double_t current_radius = chargedCarrierCloudRadius;
672 if (chargedCarrierCloudRadius <= 0.0) {
673 if (Verbosity)
674 cerr << "WARNING: BmnVSPModule::AddRealPointFull(): incorrect chargedCarrierCloudRadius!\n";
675 return false;
676 }
677
678 Double_t current_x = collision_points[icollpoint].x;
679 Double_t current_y = collision_points[icollpoint].y;
680
681 Int_t n_strip_layers = GetNStripLayers();
682
683 for (Int_t ilayer = 0; ilayer < n_strip_layers; ++ilayer) {
684 if (!StripLayers[ilayer].IsPointInsideStripLayer(current_x, current_y))
685 continue;
686
687 Double_t pitch = StripLayers[ilayer].GetPitch();
688 Double_t radius_in_strips = current_radius / pitch;
689 Int_t zone_id = StripLayers[ilayer].GetZoneID();
690
691 Int_t first_strip_in_layer = StripLayers[ilayer].GetFirstStripNumber();
692 Int_t last_strip_in_layer = StripLayers[ilayer].GetLastStripNumber();
693
694 Double_t central_strip_pos = StripLayers[ilayer].ConvertPointToStripPosition(current_x, current_y);
695 Double_t left_strip_pos = central_strip_pos - radius_in_strips;
696 Double_t right_strip_pos = central_strip_pos + radius_in_strips;
697
698 // cout << " layer: " << ilayer << "\n";
699 // cout << " current_x = " << current_x << "\n";
700 // cout << " current_y = " << current_y << "\n";
701 // cout << " central_strip_pos = " << central_strip_pos << "\n";
702
703 Double_t central_strip_signal = signal_per_step;
704 Double_t left_strip_signal = 0.0;
705 Double_t right_strip_signal = 0.0;
706
707 Double_t central_strip_fraction = 1.0;
708 Double_t left_strip_fraction = 0.0;
709 Double_t right_strip_fraction = 0.0;
710
711 // calculate signal fraction for the left neighbour strip
712 if ((Int_t)left_strip_pos != (Int_t)central_strip_pos) {
713 if (left_strip_pos >= first_strip_in_layer) {
714 left_strip_fraction = (Int_t)central_strip_pos - left_strip_pos;
715 if (left_strip_fraction > 1.0)
716 left_strip_fraction = 1.0;
717 }
718 }
719 // calculate signal fraction for the right neighbour strip
720 if ((Int_t)right_strip_pos != (Int_t)central_strip_pos) {
721 if (right_strip_pos < (last_strip_in_layer + 1)) {
722 right_strip_fraction = right_strip_pos - (Int_t)(central_strip_pos + 1);
723 if (right_strip_fraction > 1.0)
724 right_strip_fraction = 1.0;
725 }
726 }
727
728 // signal for the triplet strips (one central and two possible neighbour strips)
729 central_strip_signal = signal_per_step * central_strip_fraction
730 / (central_strip_fraction + left_strip_fraction + right_strip_fraction);
731 left_strip_signal = signal_per_step * left_strip_fraction
732 / (central_strip_fraction + left_strip_fraction + right_strip_fraction);
733 right_strip_signal = signal_per_step * right_strip_fraction
734 / (central_strip_fraction + left_strip_fraction + right_strip_fraction);
735
736 AddStripSignalInLayerByZoneId(zone_id, (Int_t)central_strip_pos, central_strip_signal);
737 if (left_strip_signal > 0.0)
738 AddStripSignalInLayerByZoneId(zone_id, (Int_t)left_strip_pos, left_strip_signal);
739 if (right_strip_signal > 0.0)
740 AddStripSignalInLayerByZoneId(zone_id, (Int_t)right_strip_pos, right_strip_signal);
741
742 // strip match
743 AddStripMatchInLayerByZoneId(zone_id, (Int_t)central_strip_pos, central_strip_signal, refID);
744 if (left_strip_signal > 0.0)
745 AddStripMatchInLayerByZoneId(zone_id, (Int_t)left_strip_pos, left_strip_signal, refID);
746 if (right_strip_signal > 0.0)
747 AddStripMatchInLayerByZoneId(zone_id, (Int_t)right_strip_pos, right_strip_signal, refID);
748 }
749 }
750
751 RealPointsX.push_back(x);
752 RealPointsY.push_back(y);
753 RealPointsMC.push_back(refID);
754
755 return true;
756 } else {
757 if (Verbosity)
758 cerr << "WARNING: BmnVSPModule::AddRealPointFull(): Point (" << x << " : " << y << " : " << z
759 << ") is out of the readout plane or inside a dead zone\n";
760 return false;
761 }
762}
763
765 Double_t xcoord,
766 Double_t ycoord,
767 Double_t signal,
768 Double_t radius)
769{
770
771 Double_t ClusterDistortion = 0.0; // signal variation (0.1 is 10%)
772
773 Double_t Gain = 1.0;
774
775 StripCluster cluster;
776
777 if (radius <= 0.0)
778 return cluster;
779
780 Double_t Pitch = StripLayers[layer_num].GetPitch();
781
782 Double_t RadiusInZones = radius / Pitch;
783 Double_t Sigma = RadiusInZones / 3.33;
784
785 TF1 gausF("gausF", "gaus", -4 * Sigma, 4 * Sigma);
786 gausF.SetParameter(0, 1.0); // constant (altitude)
787 gausF.SetParameter(1, 0.0); // mean (center position)
788 gausF.SetParameter(2, Sigma); // sigma
789
790 Double_t SCluster = gausF.Integral(-4 * Sigma, 4 * Sigma); // square of the one side distribution (more exactly)
791
792 TRandom rand(0);
793 Double_t var_level = ClusterDistortion; // signal variation (0.1 is 10%)
794
795 Int_t NStripsInLayer = StripLayers[layer_num].GetNStrips();
796 Int_t FirstStripInLayer = StripLayers[layer_num].GetFirstStripNumber();
797 Int_t LastStripInLayer = StripLayers[layer_num].GetLastStripNumber();
798
799 if (NStripsInLayer == 0)
800 return cluster;
801
802 Double_t CenterZonePos = StripLayers[layer_num].ConvertPointToStripPosition(xcoord, ycoord);
803
804 if (CenterZonePos < FirstStripInLayer || CenterZonePos >= LastStripInLayer + 1)
805 return cluster;
806
807 gausF.SetParameter(1, CenterZonePos);
808 Double_t total_signal = 0.0;
809
810 Double_t LeftZonePos = CenterZonePos - RadiusInZones;
811 Double_t RightZonePos = CenterZonePos + RadiusInZones;
812 Double_t OutLeftBorder = 0.0;
813 Double_t OutRightBorder = 0.0;
814
815 if (LeftZonePos < FirstStripInLayer) {
816 OutLeftBorder = LeftZonePos;
817 LeftZonePos = FirstStripInLayer;
818 }
819 if (RightZonePos < FirstStripInLayer) {
820 OutRightBorder = RightZonePos;
821 RightZonePos = FirstStripInLayer;
822 }
823 if (LeftZonePos >= LastStripInLayer + 1) {
824 OutLeftBorder = LeftZonePos;
825 LeftZonePos = LastStripInLayer + 1 - 0.001;
826 }
827 if (RightZonePos >= LastStripInLayer + 1) {
828 OutRightBorder = RightZonePos;
829 RightZonePos = LastStripInLayer + 1 - 0.001;
830 }
831
832 Double_t h = 0.0;
833 Double_t dist = 0.0;
834
835 // avalanche is inside of the one strip
836 if ((Int_t)LeftZonePos == (Int_t)RightZonePos) {
837
838 Int_t NumCurrentZone = (Int_t)LeftZonePos;
839
840 h = RightZonePos - LeftZonePos;
841 if (h < 0.0)
842 h = 0.0;
843
844 Double_t xp = LeftZonePos + dist;
845 Double_t S = gausF.Integral(xp, xp + h);
846 Double_t Energy = (signal * Gain) * (S / SCluster);
847 Energy += rand.Gaus(0.0, var_level * Energy);
848 if (Energy < 0.0)
849 Energy = 0.0;
850
851 if (NumCurrentZone >= FirstStripInLayer && NumCurrentZone < LastStripInLayer + 1 && Energy > 0.0) {
852 cluster.AddStrip(NumCurrentZone, Energy);
853 total_signal += Energy;
854 }
855
856 dist += h;
857
858 } else {
859 // left border strip
860 Int_t NumCurrentZone = (Int_t)LeftZonePos;
861
862 h = ((Int_t)LeftZonePos + 1) - LeftZonePos;
863 if (h < 0.0)
864 h = 0.0;
865
866 Double_t xp = LeftZonePos + dist;
867 Double_t S = gausF.Integral(xp, xp + h);
868 Double_t Energy = (signal * Gain) * (S / SCluster);
869 Energy += rand.Gaus(0.0, var_level * Energy);
870 if (Energy < 0.0)
871 Energy = 0.0;
872
873 if (NumCurrentZone >= FirstStripInLayer && NumCurrentZone < LastStripInLayer + 1 && Energy > 0.0) {
874 cluster.AddStrip(NumCurrentZone, Energy);
875 total_signal += Energy;
876 }
877
878 dist += h;
879
880 // inner strips
881 for (Int_t i = (Int_t)LeftZonePos + 1; i < (Int_t)RightZonePos; ++i) {
882
883 NumCurrentZone = i;
884
885 h = 1.0;
886
887 xp = LeftZonePos + dist;
888 S = gausF.Integral(xp, xp + h);
889 Energy = (signal * Gain) * (S / SCluster);
890 Energy += rand.Gaus(0.0, var_level * Energy);
891 if (Energy < 0.0)
892 Energy = 0.0;
893
894 if (NumCurrentZone >= FirstStripInLayer && NumCurrentZone < LastStripInLayer + 1 && Energy > 0.0) {
895 cluster.AddStrip(NumCurrentZone, Energy);
896 total_signal += Energy;
897 }
898
899 dist += h;
900 }
901 // right border strip
902 NumCurrentZone = (Int_t)RightZonePos;
903
904 h = RightZonePos - (Int_t)RightZonePos;
905 if (h < 0.0)
906 h = 0.0;
907
908 xp = LeftZonePos + dist;
909 S = gausF.Integral(xp, xp + h);
910 Energy = (signal * Gain) * (S / SCluster);
911 Energy += rand.Gaus(0.0, var_level * Energy);
912 if (Energy < 0.0)
913 Energy = 0.0;
914
915 if (NumCurrentZone >= FirstStripInLayer && NumCurrentZone < LastStripInLayer + 1 && Energy > 0.0) {
916 cluster.AddStrip(NumCurrentZone, Energy);
917 total_signal += Energy;
918 }
919
920 dist += h;
921 }
922
923 if (cluster.GetClusterSize() <= 0) {
924 return cluster;
925 }
926
927 // find the mean value of the avalanche position (fitting by gaus function)
928 Double_t mean_fit_pos = 0.0;
929
930 Int_t NOutLeftBins = 0;
931 Int_t NOutRightBins = 0;
932 if (OutLeftBorder != 0.0) {
933 NOutLeftBins = (Int_t)(fabs(OutLeftBorder)) + 1;
934 }
935 if (OutRightBorder != 0.0) {
936 NOutRightBins = (Int_t)(OutRightBorder - RightZonePos) + 1;
937 }
938
939 Int_t begin_strip_num = cluster.Strips.at(0);
940 Int_t last_strip_num = cluster.Strips.at(cluster.GetClusterSize() - 1);
941 Int_t nstrips = last_strip_num - begin_strip_num + 1;
942
943 TH1F hist("hist_for_fit", "hist_for_fit", nstrips + NOutLeftBins + NOutRightBins, begin_strip_num - NOutLeftBins,
944 last_strip_num + 1 + NOutRightBins);
945 Int_t hist_index = 0;
946
947 for (Int_t i = 0; i < cluster.GetClusterSize(); ++i) {
948 Double_t value = cluster.Signals.at(i);
949 hist.SetBinContent(hist_index + 1 + NOutLeftBins, value);
950 hist_index++;
951 }
952
953 // on the left border
954 if (NOutLeftBins > 0.0) {
955 Double_t first = OutLeftBorder;
956 Double_t last = (Int_t)OutLeftBorder;
957 Double_t S = gausF.Integral(first, last);
958 Double_t Energy = (signal * Gain) * (S / SCluster);
959 Energy += rand.Gaus(0.0, var_level * Energy);
960 if (Energy < 0.0)
961 Energy = 0.0;
962 Double_t value = Energy;
963 hist.SetBinContent(1, value);
964 dist = 0.0;
965
966 for (Int_t i = 1; i < NOutLeftBins; ++i) {
967 h = 1.0;
968 first = (Int_t)OutLeftBorder + dist;
969 last = first + h;
970 S = gausF.Integral(first, last);
971 Energy = (signal * Gain) * (S / SCluster);
972 Energy += rand.Gaus(0.0, var_level * Energy);
973 if (Energy < 0.0)
974 Energy = 0.0;
975 value = Energy;
976 hist.SetBinContent(1 + i, value);
977 dist += h;
978 }
979 }
980
981 // on the right border
982 if (NOutRightBins > 0.0) {
983 dist = 0.0;
984 for (Int_t i = hist_index; i < hist_index + NOutRightBins - 1; ++i) {
985 h = 1.0;
986 Double_t first = NStripsInLayer + dist;
987 Double_t last = first + h;
988 Double_t S = gausF.Integral(first, last);
989 Double_t Energy = (signal * Gain) * (S / SCluster);
990 Energy += rand.Gaus(0.0, var_level * Energy);
991 if (Energy < 0.0)
992 Energy = 0.0;
993 Double_t value = Energy;
994 hist.SetBinContent(1 + i, value);
995 dist += h;
996 }
997
998 Double_t first = (Int_t)OutRightBorder;
999 Double_t last = first + (OutRightBorder - (Int_t)OutRightBorder);
1000 Double_t S = gausF.Integral(first, last);
1001 Double_t Energy = (signal * Gain) * (S / SCluster);
1002 Energy += rand.Gaus(0.0, var_level * Energy);
1003 if (Energy < 0.0)
1004 Energy = 0.0;
1005 Double_t value = Energy;
1006 hist.SetBinContent(hist_index + NOutRightBins, value);
1007 }
1008
1009 TF1* gausFitFunction = 0;
1010 TString fit_params = "WQ0";
1011
1012#ifdef DRAW_REAL_CLUSTER_HISTOGRAMS
1013 fit_params = "WQ";
1014#endif
1015
1016 if (nstrips > 1) {
1017 hist.Fit("gaus", fit_params); // Q - quit mode (without information on the screen); 0 - not draw
1018 gausFitFunction = hist.GetFunction("gaus");
1019 if (gausFitFunction) {
1020 mean_fit_pos = gausFitFunction->GetParameter(1);
1021 } else {
1022 mean_fit_pos = hist.GetMean();
1023 }
1024 } else {
1025 mean_fit_pos = hist.GetMean();
1026 }
1027
1028 cluster.MeanPosition = mean_fit_pos;
1029 cluster.TotalSignal = total_signal;
1030 cluster.PositionResidual = mean_fit_pos - CenterZonePos; // residual between mean and origin positions (lower
1031 // cluster): residual = finded(current) - orig(average)
1032
1033 cluster.IsCorrect = true; // set correct status of the cluster
1034 return cluster;
1035}
1036
1038{
1039
1042
1043 size_t n_strip_layers = StripLayers.size();
1044
1045 // Find strip clusters and hits in the strip layers -------------------------
1046 for (size_t ilayer = 0; ilayer < n_strip_layers; ++ilayer)
1047 StripLayers[ilayer].FindClustersAndStripHits();
1048
1049 map<Int_t, Bool_t> UsageStatus_LowerClusters;
1050 map<Int_t, Bool_t> UsageStatus_UpperClusters;
1051
1052 // Saving all unique id marks of clusters in a module
1053 for (size_t ilayer = 0; ilayer < n_strip_layers; ++ilayer) {
1054 for (Int_t i_strip_hit = 0; i_strip_hit < StripLayers[ilayer].GetNStripHits(); ++i_strip_hit) {
1055 StripCluster cluster = StripLayers[ilayer].GetStripClusters()[i_strip_hit];
1056 if (cluster.GetType() == LowerStripLayer)
1057 UsageStatus_LowerClusters[cluster.GetUniqueID()] = false;
1058 if (cluster.GetType() == UpperStripLayer)
1059 UsageStatus_UpperClusters[cluster.GetUniqueID()] = false;
1060 }
1061 }
1062
1063 for (size_t ilayer = 0; ilayer < n_strip_layers; ++ilayer) {
1064 for (size_t jlayer = ilayer + 1; jlayer < n_strip_layers; ++jlayer) {
1065 // cout << "(i-layer : j-layer) = ( " << ilayer << " : " << jlayer << " )\n";
1066
1067 if (StripLayers[ilayer].GetType() == StripLayers[jlayer].GetType())
1068 continue;
1069
1070 Double_t iAngleRad = StripLayers[ilayer].GetAngleRad();
1071 Double_t jAngleRad = StripLayers[jlayer].GetAngleRad();
1072
1073 if (Abs(iAngleRad - jAngleRad) < 0.01)
1074 continue;
1075
1076 Double_t i_PiOver2MinusAngleRad = PiOver2() - iAngleRad;
1077 Double_t j_PiOver2MinusAngleRad = PiOver2() - jAngleRad;
1078
1079 for (Int_t i_strip_hit = 0; i_strip_hit < StripLayers[ilayer].GetNStripHits(); ++i_strip_hit) {
1080 for (Int_t j_strip_hit = 0; j_strip_hit < StripLayers[jlayer].GetNStripHits(); ++j_strip_hit) {
1081
1082 Double_t iStripHitPos = StripLayers[ilayer].GetStripHitPos(i_strip_hit);
1083 Double_t jStripHitPos = StripLayers[jlayer].GetStripHitPos(j_strip_hit);
1084
1085 Double_t iStripHitError = StripLayers[ilayer].GetStripHitError(i_strip_hit);
1086 Double_t jStripHitError = StripLayers[jlayer].GetStripHitError(j_strip_hit);
1087
1088 Double_t xcoord;
1089 Double_t ycoord;
1090
1091 if (Abs(iAngleRad) >= 0.01 && Abs(jAngleRad) >= 0.01) {
1092
1093 Double_t iB = StripLayers[ilayer].CalculateStripEquationB(iStripHitPos);
1094 Double_t jB = StripLayers[jlayer].CalculateStripEquationB(jStripHitPos);
1095
1096 xcoord = (jB - iB) / (Tan(i_PiOver2MinusAngleRad) - Tan(j_PiOver2MinusAngleRad));
1097 ycoord = Tan(i_PiOver2MinusAngleRad) * xcoord + iB;
1098 } else {
1099 if (Abs(iAngleRad) < 0.01) {
1100
1101 if (StripLayers[ilayer].GetStripNumberingOrder() == LeftToRight) {
1102 xcoord = StripLayers[ilayer].GetXLeftStripBorderPoint()
1103 + (iStripHitPos - StripLayers[ilayer].GetFirstStripNumber())
1104 * StripLayers[ilayer].GetPitch();
1105 } else {
1106 xcoord = StripLayers[ilayer].GetXRightStripBorderPoint()
1107 - (iStripHitPos - StripLayers[ilayer].GetFirstStripNumber())
1108 * StripLayers[ilayer].GetPitch();
1109 }
1110
1111 Double_t jB = StripLayers[jlayer].CalculateStripEquationB(jStripHitPos);
1112 ycoord = Tan(j_PiOver2MinusAngleRad) * xcoord + jB;
1113 }
1114
1115 if (Abs(jAngleRad) < 0.01) {
1116
1117 if (StripLayers[jlayer].GetStripNumberingOrder() == LeftToRight) {
1118 xcoord = StripLayers[jlayer].GetXLeftStripBorderPoint()
1119 + (jStripHitPos - StripLayers[jlayer].GetFirstStripNumber())
1120 * StripLayers[jlayer].GetPitch();
1121 } else {
1122 xcoord = StripLayers[jlayer].GetXRightStripBorderPoint()
1123 - (jStripHitPos - StripLayers[jlayer].GetFirstStripNumber())
1124 * StripLayers[jlayer].GetPitch();
1125 }
1126
1127 Double_t iB = StripLayers[ilayer].CalculateStripEquationB(iStripHitPos);
1128 ycoord = Tan(i_PiOver2MinusAngleRad) * xcoord + iB;
1129 }
1130 }
1131
1132 // check: a point belongs to both strip layers together
1133 if (StripLayers[ilayer].IsPointInsideStripLayer(xcoord, ycoord)
1134 && StripLayers[jlayer].IsPointInsideStripLayer(xcoord, ycoord))
1135 {
1136
1137 IntersectionPointsX.push_back(xcoord);
1138 IntersectionPointsY.push_back(ycoord);
1139
1140 // Intersection (x,y)-errors from the strip-errors ------
1141 Double_t AngleIntersecRad = Abs(iAngleRad - jAngleRad);
1142
1143 // a rhomb zone is the intersection of the strip errors
1144 Double_t RhombSide1 = (iStripHitError * StripLayers[ilayer].GetPitch()) / Sin(AngleIntersecRad);
1145 Double_t RhombSide2 = (jStripHitError * StripLayers[jlayer].GetPitch()) / Sin(AngleIntersecRad);
1146
1147 // x-strip error
1148 Double_t xerr1 = Sin(Abs(jAngleRad)) * RhombSide1;
1149 Double_t xerr2 = Sin(Abs(iAngleRad)) * RhombSide2;
1150 Double_t xcoord_err = xerr1 + xerr2;
1151
1152 // y-strip error
1153 Double_t yerr1 = Cos(Abs(jAngleRad)) * RhombSide1;
1154 Double_t yerr2 = Cos(Abs(iAngleRad)) * RhombSide2;
1155 Double_t ycoord_err = yerr1 + yerr2;
1156
1157 IntersectionPointsXErrors.push_back(xcoord_err);
1158 IntersectionPointsYErrors.push_back(ycoord_err);
1159 //------------------------------------------------------
1160
1161 // intersection MC-matching -----------------------------
1162 BmnMatch iStripMatch = StripLayers[ilayer].GetStripMatch((Int_t)iStripHitPos);
1163 BmnMatch jStripMatch = StripLayers[jlayer].GetStripMatch((Int_t)jStripHitPos);
1164
1165 BmnMatch intersection_match;
1166 intersection_match.AddLink(iStripMatch);
1167 intersection_match.AddLink(jStripMatch);
1168
1169 IntersectionPointMatches.push_back(intersection_match);
1170 //------------------------------------------------------
1171
1172 // intersection digit number matching -------------------
1173 BmnMatch iStripDigitNumberMatch =
1174 StripLayers[ilayer].GetStripDigitNumberMatch((Int_t)iStripHitPos);
1175 BmnMatch jStripDigitNumberMatch =
1176 StripLayers[jlayer].GetStripDigitNumberMatch((Int_t)jStripHitPos);
1177
1178 BmnMatch intersection_digit_num_match;
1179 intersection_digit_num_match.AddLink(iStripDigitNumberMatch);
1180 intersection_digit_num_match.AddLink(jStripDigitNumberMatch);
1181
1182 IntersectionPointDigitNumberMatches.push_back(intersection_digit_num_match);
1183 //------------------------------------------------------
1184
1185 // Additional information about the intersection --------
1186 // cluster size (number strips) in both strip layers for each intersection
1187 Int_t iLayerClusterSize = StripLayers[ilayer].GetStripHitClusterSize(i_strip_hit);
1188 Int_t jLayerClusterSize = StripLayers[jlayer].GetStripHitClusterSize(j_strip_hit);
1189
1190 // strip position in both strip layers for each intersection
1191 Double_t iLayerStripPosition = StripLayers[ilayer].ConvertPointToStripPosition(xcoord, ycoord);
1192 Double_t jLayerStripPosition = StripLayers[jlayer].ConvertPointToStripPosition(xcoord, ycoord);
1193
1194 if (StripLayers[ilayer].GetType() == LowerStripLayer) {
1195 IntersectionPoints_LowerLayerClusterSize.push_back(iLayerClusterSize);
1196 IntersectionPoints_UpperLayerClusterSize.push_back(jLayerClusterSize);
1197 IntersectionPoints_LowerLayerStripPosition.push_back(iLayerStripPosition);
1198 IntersectionPoints_UpperLayerStripPosition.push_back(jLayerStripPosition);
1200 StripLayers[ilayer].GetStripHitTotalSignal(i_strip_hit));
1202 StripLayers[jlayer].GetStripHitTotalSignal(j_strip_hit));
1203 LowerClusters.push_back(StripLayers[ilayer].GetStripClusters().at(i_strip_hit));
1204 UpperClusters.push_back(StripLayers[jlayer].GetStripClusters().at(j_strip_hit));
1205 UsageStatus_LowerClusters
1206 [StripLayers[ilayer].GetStripClusters()[i_strip_hit].GetUniqueID()] = true;
1207 UsageStatus_UpperClusters
1208 [StripLayers[jlayer].GetStripClusters()[j_strip_hit].GetUniqueID()] = true;
1209 } else {
1210 IntersectionPoints_LowerLayerClusterSize.push_back(jLayerClusterSize);
1211 IntersectionPoints_UpperLayerClusterSize.push_back(iLayerClusterSize);
1212 IntersectionPoints_LowerLayerStripPosition.push_back(jLayerStripPosition);
1213 IntersectionPoints_UpperLayerStripPosition.push_back(iLayerStripPosition);
1215 StripLayers[jlayer].GetStripHitTotalSignal(j_strip_hit));
1217 StripLayers[ilayer].GetStripHitTotalSignal(i_strip_hit));
1218 LowerClusters.push_back(StripLayers[jlayer].GetStripClusters().at(j_strip_hit));
1219 UpperClusters.push_back(StripLayers[ilayer].GetStripClusters().at(i_strip_hit));
1220 UsageStatus_LowerClusters
1221 [StripLayers[jlayer].GetStripClusters()[j_strip_hit].GetUniqueID()] = true;
1222 UsageStatus_UpperClusters
1223 [StripLayers[ilayer].GetStripClusters()[i_strip_hit].GetUniqueID()] = true;
1224 }
1225 //------------------------------------------------------
1226 }
1227 }
1228 }
1229 }
1230 }
1231
1232 // for(auto it : UsageStatus_UpperClusters) {
1233 // if(it.second == false) cout << " upper_cluster[" << it.first << "] = " << it.second << "\n";
1234 //}
1235
1236 for (auto it : UsageStatus_LowerClusters) {
1237 // if(it.second == false) cout << " lower_cluster[" << it.first << "] = " << it.second << "\n";
1238
1239 if (it.second == false) {
1240
1241 for (size_t ilayer = 0; ilayer < n_strip_layers; ++ilayer) {
1242 if (StripLayers[ilayer].GetType() != LowerStripLayer)
1243 continue;
1244
1245 for (size_t icluster = 0; icluster < StripLayers[ilayer].GetStripClusters().size(); ++icluster) {
1246 StripCluster cluster = StripLayers[ilayer].GetStripClusters()[icluster];
1247
1248 if ((Int_t)cluster.GetUniqueID() != it.first)
1249 continue;
1250
1251 Double_t xcoord;
1252 Double_t ycoord;
1253
1254 if (StripLayers[ilayer].GetStripNumberingOrder() == LeftToRight) {
1255 xcoord = StripLayers[ilayer].GetXLeftStripBorderPoint()
1256 + cluster.MeanPosition * StripLayers[ilayer].GetPitch();
1257 } else {
1258 xcoord = StripLayers[ilayer].GetXRightStripBorderPoint()
1259 - cluster.MeanPosition * StripLayers[ilayer].GetPitch();
1260 }
1261
1262 ycoord = (StripLayers[ilayer].GetYMinLayer() + StripLayers[ilayer].GetYMaxLayer()) * 0.5;
1263
1264 Double_t xerr = cluster.Error * StripLayers[ilayer].GetPitch();
1265 Double_t yerr = StripLayers[ilayer].GetYSize() * 0.5;
1266
1267 // cout << " low_cluster[" << icluster << "]:\n";
1268 // cout << " ID = " << cluster.GetUniqueID() << "\n";
1269 // cout << " xcoord = " << xcoord << "\n";
1270 // cout << " xmin = " << StripLayers[ilayer].GetXMinLayer() << ", xmax = " <<
1271 // StripLayers[ilayer].GetXMaxLayer() << "\n"; cout << " ycoord = " << ycoord << "\n"; cout << "
1272 // ymin = " << StripLayers[ilayer].GetYMinLayer() << ", ymax = " <<
1273 // StripLayers[ilayer].GetYMaxLayer() << "\n"; cout << " xerr = " << xerr << "\n"; cout << " yerr
1274 // = " << yerr << "\n"; cout << "\n";
1275
1276 PseudoIntersectionsX.push_back(xcoord);
1277 PseudoIntersectionsY.push_back(ycoord);
1278
1279 PseudoIntersectionsXErrors.push_back(xerr);
1280 PseudoIntersectionsYErrors.push_back(yerr);
1281
1284
1286 StripLayers[ilayer].ConvertPointToStripPosition(xcoord, ycoord));
1288
1291
1292 PseudoIntersectionMatches.push_back(
1293 StripLayers[ilayer].GetStripMatch((Int_t)cluster.MeanPosition)); // mc-match
1294 PseudoIntersectionDigitNumberMatches.push_back(StripLayers[ilayer].GetStripDigitNumberMatch(
1295 (Int_t)cluster.MeanPosition)); // digit number matches
1296
1297 LowerClusters_PseudoIntersections.push_back(cluster);
1299 StripCluster()); // empty cluster with default parameters
1300 }
1301 }
1302 }
1303 }
1304}
1305
1306// need for a separated test (find x,y intersection coords from strip positions)
1308 Double_t& y,
1309 Double_t strip_pos_layerA,
1310 Double_t strip_pos_layerB,
1311 Int_t layerA_index,
1312 Int_t layerB_index)
1313{
1314
1315 Int_t ilayer = layerA_index;
1316 Int_t jlayer = layerB_index;
1317
1318 if (StripLayers[ilayer].GetType() == StripLayers[jlayer].GetType())
1319 return false;
1320
1321 Double_t iAngleRad = StripLayers[ilayer].GetAngleRad();
1322 Double_t jAngleRad = StripLayers[jlayer].GetAngleRad();
1323
1324 if (Abs(iAngleRad - jAngleRad) < 0.01)
1325 return false;
1326
1327 Double_t i_PiOver2MinusAngleRad = PiOver2() - iAngleRad;
1328 Double_t j_PiOver2MinusAngleRad = PiOver2() - jAngleRad;
1329
1330 Double_t iStripHitPos = strip_pos_layerA;
1331 Double_t jStripHitPos = strip_pos_layerB;
1332
1333 Double_t xcoord;
1334 Double_t ycoord;
1335
1336 if (Abs(iAngleRad) >= 0.01 && Abs(jAngleRad) >= 0.01) {
1337
1338 Double_t iB = StripLayers[ilayer].CalculateStripEquationB(iStripHitPos);
1339 Double_t jB = StripLayers[jlayer].CalculateStripEquationB(jStripHitPos);
1340
1341 xcoord = (jB - iB) / (Tan(i_PiOver2MinusAngleRad) - Tan(j_PiOver2MinusAngleRad));
1342 ycoord = Tan(i_PiOver2MinusAngleRad) * xcoord + iB;
1343 } else {
1344
1345 if (Abs(iAngleRad) < 0.01) {
1346
1347 if (StripLayers[ilayer].GetStripNumberingOrder() == LeftToRight) {
1348 xcoord = StripLayers[ilayer].GetXLeftStripBorderPoint()
1349 + (iStripHitPos - StripLayers[ilayer].GetFirstStripNumber()) * StripLayers[ilayer].GetPitch();
1350 } else {
1351 xcoord = StripLayers[ilayer].GetXRightStripBorderPoint()
1352 - (iStripHitPos - StripLayers[ilayer].GetFirstStripNumber()) * StripLayers[ilayer].GetPitch();
1353 }
1354
1355 Double_t jB = StripLayers[jlayer].CalculateStripEquationB(jStripHitPos);
1356 ycoord = Tan(j_PiOver2MinusAngleRad) * xcoord + jB;
1357 }
1358
1359 if (Abs(jAngleRad) < 0.01) {
1360
1361 if (StripLayers[jlayer].GetStripNumberingOrder() == LeftToRight) {
1362 xcoord = StripLayers[jlayer].GetXLeftStripBorderPoint()
1363 + (jStripHitPos - StripLayers[jlayer].GetFirstStripNumber()) * StripLayers[jlayer].GetPitch();
1364 } else {
1365 xcoord = StripLayers[jlayer].GetXRightStripBorderPoint()
1366 - (jStripHitPos - StripLayers[jlayer].GetFirstStripNumber()) * StripLayers[jlayer].GetPitch();
1367 }
1368
1369 Double_t iB = StripLayers[ilayer].CalculateStripEquationB(iStripHitPos);
1370 ycoord = Tan(i_PiOver2MinusAngleRad) * xcoord + iB;
1371 }
1372 }
1373
1374 // check: a point belongs to both strip layers together
1375 if (StripLayers[ilayer].IsPointInsideStripLayer(xcoord, ycoord)
1376 && StripLayers[jlayer].IsPointInsideStripLayer(xcoord, ycoord))
1377 {
1378 return true;
1379 }
1380
1381 return false;
1382}
1383
1401
1419
1421{
1422
1423 if (StripLayers.size() == 0)
1424 return;
1425
1426 XMinModule = 1.0E+10;
1427 XMaxModule = -1.0E+10;
1428 YMinModule = 1.0E+10;
1429 YMaxModule = -1.0E+10;
1430
1431 for (size_t ilayer = 0; ilayer < StripLayers.size(); ++ilayer) {
1432 if (StripLayers[ilayer].GetXMinLayer() < XMinModule)
1433 XMinModule = StripLayers[ilayer].GetXMinLayer();
1434 if (StripLayers[ilayer].GetXMaxLayer() > XMaxModule)
1435 XMaxModule = StripLayers[ilayer].GetXMaxLayer();
1436 if (StripLayers[ilayer].GetYMinLayer() < YMinModule)
1437 YMinModule = StripLayers[ilayer].GetYMinLayer();
1438 if (StripLayers[ilayer].GetYMaxLayer() > YMaxModule)
1439 YMaxModule = StripLayers[ilayer].GetYMaxLayer();
1440 }
1441
1442 return;
1443}
vector< Double_t > dist(vector< Double_t > qp, Double_t mu)
Definition BmnMath.cxx:869
@ LeftToRight
@ UpperStripLayer
@ LowerStripLayer
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
void AddLink(const BmnMatch &match)
Definition BmnMatch.cxx:40
Bool_t AddStripSignalInLayer(Int_t layer_num, Int_t strip_num, Double_t signal)
vector< Double_t > RealPointsMC
Bool_t AddRealPointFullOne_WithIncline(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 > PseudoIntersections_LowerLayerStripPosition
Double_t ModuleThickness
Bool_t SetStripSignalInLayerByZoneId(Int_t zone_id, Int_t strip_num, Double_t signal)
Bool_t SetStripMatchInLayerByZoneId(Int_t zone_id, Int_t strip_num, BmnMatch mc_match)
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)
BmnMatch GetStripDigitNumberMatchInLayer(Int_t layer_num, Int_t strip_num)
void ResetPseudoIntersections()
Bool_t SetStripMatchInLayer(Int_t layer_num, Int_t strip_num, BmnMatch mc_match)
BmnMatch GetStripDigitNumberMatchInZone(Int_t zone_id, Int_t strip_num)
vector< Double_t > PseudoIntersectionsX
BmnMatch GetStripMatchInLayer(Int_t layer_num, Int_t strip_num)
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)
void ResetIntersectionPoints()
vector< Int_t > IntersectionPoints_LowerLayerClusterSize
vector< Double_t > PseudoIntersections_UpperLayerStripTotalSignal
Bool_t IsPointInsideZThickness(Double_t z)
Double_t YMaxModule
vector< Double_t > IntersectionPoints_UpperLayerStripPosition
vector< Double_t > RealPointsX
vector< StripCluster > LowerClusters
vector< Double_t > IntersectionPointsY
Int_t GetLastStripInZone(Int_t zone_id)
Double_t YMinModule
vector< Double_t > IntersectionPointsX
Bool_t IsPointInsideModule(Double_t x, Double_t y)
vector< StripCluster > UpperClusters
Bool_t AddRealPointFull(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< BmnMatch > IntersectionPointMatches
Bool_t SetStripSignalInLayer(Int_t layer_num, Int_t strip_num, Double_t signal)
Bool_t AddStripDigitNumberMatchInLayerByZoneId(Int_t zone_id, Int_t strip_num, Double_t weight, Int_t digit_num)
vector< Int_t > PseudoIntersections_UpperLayerClusterSize
Double_t ZStartModulePosition
vector< Double_t > IntersectionPoints_UpperLayerStripTotalSignal
vector< Int_t > IntersectionPoints_UpperLayerClusterSize
vector< BmnMatch > PseudoIntersectionMatches
BmnMatch GetStripMatchInZone(Int_t zone_id, Int_t strip_num)
virtual ~BmnVSPModule()
Double_t GetZPositionRegistered()
Double_t GetStripSignalInZone(Int_t zone_id, Int_t strip_num)
vector< Double_t > IntersectionPointsYErrors
vector< Double_t > PseudoIntersectionsY
vector< Double_t > IntersectionPointsXErrors
vector< Double_t > PseudoIntersectionsXErrors
vector< Double_t > RealPointsY
Bool_t SetStripDigitNumberMatchInLayer(Int_t layer_num, Int_t strip_num, BmnMatch digit_num_match)
StripCluster MakeCluster(Int_t layer_num, Double_t xcoord, Double_t ycoord, Double_t signal, Double_t radius)
Double_t XMaxModule
Bool_t SetStripDigitNumberMatchInLayerByZoneId(Int_t zone_id, Int_t strip_num, BmnMatch digit_num_match)
void CalculateStripHitIntersectionPoints()
vector< BmnVSPLayer > StripLayers
void DefineModuleBorders()
void ResetModuleData()
vector< StripCluster > UpperClusters_PseudoIntersections
vector< BmnMatch > PseudoIntersectionDigitNumberMatches
vector< StripCluster > LowerClusters_PseudoIntersections
Bool_t AddStripMatchInLayerByZoneId(Int_t zone_id, Int_t strip_num, Double_t weight, Int_t mc_num)
vector< Double_t > PseudoIntersectionsYErrors
Int_t GetNStripLayers()
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)
Int_t GetFirstStripInZone(Int_t zone_id)
Bool_t AddStripSignalInLayerByZoneId(Int_t zone_id, Int_t strip_num, Double_t signal)
vector< Double_t > IntersectionPoints_LowerLayerStripTotalSignal
vector< BmnMatch > IntersectionPointDigitNumberMatches
vector< Double_t > IntersectionPoints_LowerLayerStripPosition
vector< Int_t > PseudoIntersections_LowerLayerClusterSize
vector< Double_t > PseudoIntersections_UpperLayerStripPosition
vector< Double_t > PseudoIntersections_LowerLayerStripTotalSignal
Double_t XMinModule
Double_t GetStripSignalInLayer(Int_t layer_num, Int_t strip_num)
void AddStripLayer(BmnVSPLayer strip_layer)
void ResetRealPoints()
Double_t TotalSignal
Int_t GetClusterSize()
vector< Int_t > Strips
Int_t GetType()
Double_t MeanPosition
Double_t Error
void AddStrip(Int_t strip_num, Double_t strip_signal)
Double_t PositionResidual
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)