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