forked from ECCE-EIC/macros
-
Notifications
You must be signed in to change notification settings - Fork 0
/
G4_hFarFwdBeamLine_EIC.C
1415 lines (1294 loc) · 65.6 KB
/
G4_hFarFwdBeamLine_EIC.C
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#ifndef MACRO_G4HFARFWDBEAMLINE_EIC_C
#define MACRO_G4HFARFWDBEAMLINE_EIC_C
#include <GlobalVariables.C>
#include <g4detectors/BeamLineMagnetSubsystem.h>
#include <g4detectors/PHG4BlockSubsystem.h>
#include <g4detectors/PHG4ConeSubsystem.h>
#include <g4detectors/PHG4CylinderSubsystem.h>
#include <eicg4zdc/EICG4ZDCHitTree.h>
#include <eicg4zdc/EICG4ZDCNtuple.h>
#include <eicg4zdc/EICG4ZDCSubsystem.h>
#include <eicg4b0/EICG4B0Subsystem.h>
#include <eicg4b0ecal/EICG4B0ECALSubsystem.h>
#include <eicg4rp/EICG4RPSubsystem.h>
#include <eiceval/FarForwardEvaluator.h>
#include <g4main/PHG4Reco.h>
#include <TSystem.h>
#include <fun4all/Fun4AllServer.h>
R__LOAD_LIBRARY(libg4detectors.so)
float PosFlip(float pos);
float AngleFlip(float angle);
float MagFieldFlip(float Bfield);
// This creates the Enable Flag to be used in the main steering macro
namespace Enable
{
bool HFARFWD_MAGNETS = false;
bool HFARFWD_VIRTUAL_DETECTORS = false;
bool HFARFWD_PIPE = false;
bool HFARFWD_OVERLAPCHECK = false;
int HFARFWD_VERBOSITY = 0;
// Detector configuration options
bool ZDC_DISABLE_BLACKHOLE = false;
bool B0_DISABLE_HITPLANE = false;
bool B0_FULLHITPLANE = false;
bool B0_VAR_PIPE_HOLE = false;
bool B0_CIRCLE_PIPE_HOLE = false;
bool RP_DISABLE_HITPLANE = false;
bool B0ECALTOWERS = true; //Set to 'false' for nice PackMan views. Set 'true' for physics studies.
//enabled automatically in hFarFwdBeamLineInit(), unless overridden by user
bool HFARFWD_MAGNETS_IP6 = false;
bool HFARFWD_MAGNETS_IP8 = false;
//enabled automatically in hFarFwdBeamLineInit(), unless overridden by user
bool HFARFWD_VIRTUAL_DETECTORS_IP6 = false;
bool HFARFWD_VIRTUAL_DETECTORS_IP8 = false;
bool FFR_EVAL = false;
} // namespace Enable
namespace hFarFwdBeamLine
{
double starting_z = 500; //cm as center-forward interface
double enclosure_z_max = NAN;
double enclosure_r_max = NAN;
double enclosure_center = NAN;
PHG4CylinderSubsystem *hFarFwdBeamLineEnclosure(nullptr);
BeamLineMagnetSubsystem *B0Magnet = (nullptr);
double B0Magnet_x = NAN;
double B0Magnet_y = NAN;
double B0Magnet_z = NAN;
} // namespace hFarFwdBeamLine
void hFarFwdBeamLineInit()
{
Enable::HFARFWD_MAGNETS_IP6 |= Enable::HFARFWD_MAGNETS and Enable::IP6;
Enable::HFARFWD_MAGNETS_IP8 |= Enable::HFARFWD_MAGNETS and Enable::IP8;
Enable::HFARFWD_VIRTUAL_DETECTORS_IP6 |= Enable::HFARFWD_VIRTUAL_DETECTORS and Enable::IP6;
Enable::HFARFWD_VIRTUAL_DETECTORS_IP8 |= Enable::HFARFWD_VIRTUAL_DETECTORS and Enable::IP8;
if (Enable::HFARFWD_MAGNETS_IP6 && Enable::HFARFWD_MAGNETS_IP8)
{
cout << "You cannot have magnets for both IP6 and IP8 ON at the same time" << endl;
gSystem->Exit(1);
}
if (Enable::HFARFWD_MAGNETS_IP6)
{
hFarFwdBeamLine::enclosure_z_max = 4500.;
BlackHoleGeometry::min_z = std::min(BlackHoleGeometry::min_z, hFarFwdBeamLine::starting_z);
hFarFwdBeamLine::enclosure_r_max = 200.;
}
if (Enable::HFARFWD_MAGNETS_IP8)
{
hFarFwdBeamLine::enclosure_z_max = 4500.;
BlackHoleGeometry::min_z = std::min(BlackHoleGeometry::min_z, hFarFwdBeamLine::starting_z);
hFarFwdBeamLine::enclosure_r_max = 200.;
}
hFarFwdBeamLine::enclosure_center = 0.5 * (hFarFwdBeamLine::starting_z + hFarFwdBeamLine::enclosure_z_max);
BlackHoleGeometry::max_z = std::max(BlackHoleGeometry::max_z, hFarFwdBeamLine::enclosure_z_max);
BlackHoleGeometry::max_radius = std::max(BlackHoleGeometry::max_radius, hFarFwdBeamLine::enclosure_r_max);
}
void hFarFwdDefineMagnets(PHG4Reco *g4Reco)
{
bool overlapCheck = Enable::OVERLAPCHECK || Enable::HFARFWD_OVERLAPCHECK;
int verbosity = std::max(Enable::VERBOSITY, Enable::HFARFWD_VERBOSITY);
hFarFwdBeamLine::hFarFwdBeamLineEnclosure = new PHG4CylinderSubsystem("hFarFwdBeamLineEnclosure");
hFarFwdBeamLine::hFarFwdBeamLineEnclosure->set_double_param("place_z", hFarFwdBeamLine::enclosure_center);
hFarFwdBeamLine::hFarFwdBeamLineEnclosure->set_double_param("radius", 0);
hFarFwdBeamLine::hFarFwdBeamLineEnclosure->set_double_param("thickness", hFarFwdBeamLine::enclosure_r_max); // This is intentionally made large 25cm radius
hFarFwdBeamLine::hFarFwdBeamLineEnclosure->set_double_param("length", hFarFwdBeamLine::enclosure_z_max - hFarFwdBeamLine::starting_z);
hFarFwdBeamLine::hFarFwdBeamLineEnclosure->set_string_param("material", "G4_Galactic");
hFarFwdBeamLine::hFarFwdBeamLineEnclosure->set_color(.5, .5, .5, 0.2);
hFarFwdBeamLine::hFarFwdBeamLineEnclosure->OverlapCheck(overlapCheck);
hFarFwdBeamLine::hFarFwdBeamLineEnclosure->SetActive();
if (verbosity) hFarFwdBeamLine::hFarFwdBeamLineEnclosure->Verbosity(verbosity);
g4Reco->registerSubsystem(hFarFwdBeamLine::hFarFwdBeamLineEnclosure);
if (verbosity > 0)
{
std::cout << "hFarFwdBeamLine::hFarFwdBeamLineEnclosure CanBeMotherSubsystem = " << hFarFwdBeamLine::hFarFwdBeamLineEnclosure->CanBeMotherSubsystem() << std::endl;
}
string magFile;
if (Enable::HFARFWD_MAGNETS_IP6)
magFile = string(getenv("CALIBRATIONROOT")) + "/Beam/ip6_h_farFwdBeamLineMagnets_v2.0.dat";
else if (Enable::HFARFWD_MAGNETS_IP8)
magFile = string(getenv("CALIBRATIONROOT")) + "/Beam/ip8_35mrad_h_farFwdBeamLineMagnets.dat";
else
{
cout << " You have to enable either the IP6 or IP8 Magnet configuration to define magnets! " << endl;
gSystem->Exit(1);
}
// make magnet active volume if you want to study the hits
bool magnet_active = true;
int absorberactive = 0;
// if you insert numbers it only displays those magnets, do not comment out the set declaration
set<int> magnetlist;
//magnetlist.insert(7);
BeamLineMagnetSubsystem *bl = nullptr;
std::ifstream infile(magFile);
if (infile.is_open())
{
double biggest_z = 0.;
int imagnet = 0;
std::string line;
while (std::getline(infile, line))
{
if (!line.compare(0, 1, "B") ||
!line.compare(0, 1, "Q") ||
!line.compare(0, 1, "S"))
{
std::istringstream iss(line);
string magname;
double x;
double y;
double z;
double inner_radius_zin;
double inner_radius_zout;
double outer_magnet_diameter;
double length;
double angle;
double dipole_field_x;
double fieldgradient;
if (!(iss >> magname >> x >> y >> z >> inner_radius_zin >> inner_radius_zout >> outer_magnet_diameter >> length >> angle >> dipole_field_x >> fieldgradient))
{
cout << "could not decode " << line << endl;
gSystem->Exit(1);
}
else
{
//------------------------
//Select only the magnet component in the far forward region
if (z < 0.0)
continue;
string magtype;
if (inner_radius_zin != inner_radius_zout)
{
cout << "inner radius at front of magnet " << inner_radius_zin
<< " not equal radius at back of magnet " << inner_radius_zout
<< " needs change in code (replace tube by cone for beamline)" << endl;
gSystem->Exit(1);
}
if (verbosity > 0)
{
cout << endl
<< endl
<< "\tID number " << imagnet << endl;
cout << "magname: " << magname << endl;
cout << "x: " << x << endl;
cout << "y: " << y << endl;
cout << "z: " << z << endl;
cout << "inner_radius_zin: " << inner_radius_zin << endl;
cout << "inner_radius_zout: " << inner_radius_zout << endl;
cout << "outer_magnet_diameter: " << outer_magnet_diameter << endl;
cout << "length: " << length << endl;
cout << "angle: " << angle << endl;
cout << "dipole_field_x: " << dipole_field_x << endl;
cout << "fieldgradient: " << fieldgradient << endl;
}
if (!magname.compare(0, 1, "B"))
{
magtype = "DIPOLE";
}
else if (!magname.compare(0, 1, "Q"))
{
magtype = "QUADRUPOLE";
}
else if (!magname.compare(0, 1, "S"))
{
magtype = "SEXTUPOLE";
}
else
{
cout << "cannot decode magnet name " << magname << endl;
gSystem->Exit(1);
}
// convert to our units (cm, deg)
x *= 100.;
y *= 100.;
z *= 100.;
length *= 100.;
inner_radius_zin *= 100.;
outer_magnet_diameter *= 100.;
angle = (angle / TMath::Pi() * 180.) / 1000.; // given in mrad
//------------------------
// Linearly scaling down the magnetic field for lower energy proton
if( Enable::HFARFWD_ION_ENERGY != 275 ) {
float scaleFactor = Enable::HFARFWD_ION_ENERGY / 275. ;
dipole_field_x = dipole_field_x*scaleFactor;
fieldgradient = fieldgradient * scaleFactor;
}
if (magnetlist.empty() || magnetlist.find(imagnet) != magnetlist.end())
{
bl = new BeamLineMagnetSubsystem("BEAMLINEMAGNET", imagnet);
bl->set_double_param("field_y", MagFieldFlip(dipole_field_x));
bl->set_double_param("fieldgradient", MagFieldFlip(fieldgradient));
bl->set_string_param("magtype", magtype);
bl->set_double_param("length", length);
bl->set_double_param("place_x", PosFlip(x)); // relative position to mother vol.
bl->set_double_param("place_y", y); // relative position to mother vol.
bl->set_double_param("place_z", z - hFarFwdBeamLine::enclosure_center); // relative position to mother vol.
bl->set_double_param("field_global_position_x", PosFlip(x)); // abs. position to world for field manager
bl->set_double_param("field_global_position_y", y); // abs. position to world for field manager
bl->set_double_param("field_global_position_z", z); // abs. position to world for field manager
bl->set_double_param("rot_y", AngleFlip(angle));
bl->set_double_param("field_global_rot_y", AngleFlip(angle)); // abs. rotation to world for field manager
bl->set_double_param("inner_radius", inner_radius_zin);
bl->set_double_param("outer_radius", outer_magnet_diameter / 2.);
bl->SetActive(magnet_active);
bl->SetAbsorberActive();
bl->BlackHole();
bl->SetMotherSubsystem(hFarFwdBeamLine::hFarFwdBeamLineEnclosure);
if (absorberactive)
{
bl->SetAbsorberActive();
}
bl->OverlapCheck(overlapCheck);
bl->SuperDetector("BEAMLINEMAGNET");
if (verbosity) bl->Verbosity(verbosity);
g4Reco->registerSubsystem(bl);
// rag the B0 magnet
if (imagnet == 0)
{ //To tell the B0 Calorimeter the global coordinates of the B0 Magnet
hFarFwdBeamLine::B0Magnet = bl;
hFarFwdBeamLine::B0Magnet_x = PosFlip(x);
hFarFwdBeamLine::B0Magnet_y = y;
hFarFwdBeamLine::B0Magnet_z = z;
}
}
imagnet++;
if (fabs(z) + length > biggest_z)
{
biggest_z = fabs(z) + length;
}
}
}
}
infile.close();
}
}
void hFarFwdDefineDetectorsIP6(PHG4Reco *g4Reco)
{
bool overlapCheck = Enable::OVERLAPCHECK || Enable::HFARFWD_OVERLAPCHECK;
if (Enable::HFARFWD_VIRTUAL_DETECTORS_IP6 && Enable::HFARFWD_VIRTUAL_DETECTORS_IP8)
{
cout << "You cannot have detectors enabled for both IP6 and IP8 ON at the same time" << endl;
gSystem->Exit(1);
}
int verbosity = std::max(Enable::VERBOSITY, Enable::HFARFWD_VERBOSITY);
auto *detZDCsurrogate = new PHG4BlockSubsystem("zdcTruth");
const double detZDCsurrogate_size_z = 0.1;
detZDCsurrogate->SuperDetector("ZDCsurrogate");
detZDCsurrogate->set_double_param("place_x", PosFlip(-96.24));
detZDCsurrogate->set_double_param("place_y", 0);
detZDCsurrogate->set_double_param("place_z", 3700 - hFarFwdBeamLine::enclosure_center);
detZDCsurrogate->set_double_param("rot_y", AngleFlip(0.025 * TMath::RadToDeg()));
detZDCsurrogate->set_double_param("size_x", 60);
detZDCsurrogate->set_double_param("size_y", 60);
detZDCsurrogate->set_double_param("size_z", detZDCsurrogate_size_z);
detZDCsurrogate->set_string_param("material", "G4_Si");
detZDCsurrogate->SetActive();
detZDCsurrogate->set_color(1, 0, 0, 0.5);
detZDCsurrogate->OverlapCheck(overlapCheck);
if (!Enable::ZDC_DISABLE_BLACKHOLE) detZDCsurrogate->BlackHole();
if (verbosity) detZDCsurrogate->Verbosity(verbosity);
detZDCsurrogate->SetMotherSubsystem(hFarFwdBeamLine::hFarFwdBeamLineEnclosure);
g4Reco->registerSubsystem(detZDCsurrogate);
if (Enable::ZDC_DISABLE_BLACKHOLE)
{
EICG4ZDCSubsystem *detZDC = new EICG4ZDCSubsystem("EICG4ZDC");
detZDC->SetActive();
detZDC->set_double_param("place_z", 3700. + detZDCsurrogate_size_z - hFarFwdBeamLine::enclosure_center);
detZDC->set_double_param("place_x", PosFlip(-96.24));
detZDC->set_double_param("rot_y", AngleFlip(0.025));
detZDC->OverlapCheck(overlapCheck);
detZDC->SetMotherSubsystem(hFarFwdBeamLine::hFarFwdBeamLineEnclosure);
g4Reco->registerSubsystem(detZDC);
}
const int offMomDetNr = 2;
const double om_zCent[offMomDetNr] = {3450, 3650};
const double om_xCent[offMomDetNr] = {-162, -171};
for (int i = 0; i < offMomDetNr; i++)
{
auto *detOM = new PHG4BlockSubsystem(Form("offMomTruth_%d", i), i);
detOM->SuperDetector("offMomTruth");
detOM->set_double_param("place_x", PosFlip(om_xCent[i]));
detOM->set_double_param("place_y", 0);
detOM->set_double_param("place_z", om_zCent[i] - hFarFwdBeamLine::enclosure_center);
detOM->set_double_param("rot_y", AngleFlip(0.045 * TMath::RadToDeg()));
detOM->set_double_param("size_x", 50);
detOM->set_double_param("size_y", 35);
detOM->set_double_param("size_z", 0.03);
detOM->set_string_param("material", "G4_Si");
detOM->SetActive();
if (verbosity) detOM->Verbosity(verbosity);
detOM->OverlapCheck(overlapCheck);
detOM->SetMotherSubsystem(hFarFwdBeamLine::hFarFwdBeamLineEnclosure);
g4Reco->registerSubsystem(detOM);
}
//----------------------
// Roman Pots
//----------------------
if( ! Enable::RP_DISABLE_HITPLANE )
{
string paramFile = string(getenv("CALIBRATIONROOT")) + "/RomanPots/RP_parameters_IP6.dat";
int Nlayers = GetParameterFromFile <int> (paramFile, "Number_layers");
for( int layer = 0; layer < Nlayers; layer++ ) {
auto *detRP = new EICG4RPSubsystem( Form("rpTruth_%d", layer), layer );
detRP->SuperDetector( "rpTruth" );
detRP->set_double_param( "FFenclosure_center", hFarFwdBeamLine::enclosure_center );
detRP->set_int_param( "layerNumber", layer + 1 );
detRP->SetBeamConfig( (Enable::BEAM_COLLISION_SETTING).Data() );
detRP->SetIonBeamEnergy( Enable::HFARFWD_ION_ENERGY );
detRP->SetElectronBeamEnergy( Enable::HFARBWD_E_ENERGY );
detRP->SetParametersFromFile( paramFile );
detRP->OverlapCheck( overlapCheck );
detRP->SetMotherSubsystem( hFarFwdBeamLine::hFarFwdBeamLineEnclosure );
detRP->SetActive( true );
if( verbosity ) { detRP->Verbosity( verbosity ); }
g4Reco->registerSubsystem( detRP );
}
}
//---------------------------------
// B0 implementation
// Three choices: 1. Realistic detector; 2. Circulat plane; 3. hit plane with realistic detector goemetry
double b0tr_z = 0; //Subsystem position relative to B0 magnet (for iterator)
const int b0DetNr = 4;
const double b0Mag_zCent = 640;
const double b0Mag_zLen = 120;
const double b0tr[4]={10,40,70,100};
// const double b0tr[4]={10,45,80,115}; //Tracker layers when no ECAL
const double b0Cu_zLen = .2; //B0 dead material length
const double b0Si_zLen = .1; //B0 Si length
const double b0Ecal_zLen = 10; //B0 Ecal length
double pipe_hole_r = 3.5; //detector cut off for beam pipe
double pipe_hole = 2.5;
const double cable_hole = 2.0;
const double cable_x = -17.0;
double pipe_x = -1.; //pipe hole position
const double d_radius = 7.0; //detector cut off Packman
const double b0_radius = 19.0; //outer radius of B0-detector
const double b0_magradius = 20.0; //inner radius of B0-magnet
const double spanning_angle = 240; //spanning angle Packman
const double b0Ecal_z = 48;//B0 ECal position (relative to the B0-magnet)
double start_angle = 60; //start angle Packman
const double cross_angle = 0.025;
if (Enable::B0_DISABLE_HITPLANE) {
// Choice 1 realistic detector
// const double b0tr[4]={10,45,80,115};
//const double b0tr[4]={0,30,60,90};
//const double b0tr[5]={0,25,50,75,100};
cout << "Realistic B0"<<endl;
for (int i = 0; i < b0DetNr; i++)
{
if (Enable::B0_VAR_PIPE_HOLE){
pipe_hole = b0tr[i]*cross_angle;
pipe_x = - cross_angle*(b0Mag_zCent - b0Mag_zLen/2 + b0tr[i]/2) - hFarFwdBeamLine::B0Magnet_x;
}
else if (Enable::B0_CIRCLE_PIPE_HOLE){
pipe_hole = 0.1;
pipe_hole_r = pipe_hole_r + b0tr[b0DetNr-1]*cross_angle/2;
pipe_x = - cross_angle*(b0Mag_zCent - b0Mag_zLen/2 + b0tr[b0DetNr-1]/2) - hFarFwdBeamLine::B0Magnet_x;
}
else {
pipe_hole = b0tr[b0DetNr-1]*cross_angle;
pipe_x = - cross_angle*(b0Mag_zCent - b0Mag_zLen/2 + b0tr[b0DetNr-1]/2) - hFarFwdBeamLine::B0Magnet_x;
}
cout <<"Starting B0 Tracker layer "<<i+1<<endl;
cout <<"Pipe Hole: "<< pipe_hole<<"\t"<<pipe_x<<endl;
b0tr_z = b0tr[i] - b0Mag_zLen / 2;
auto *detB0 = new EICG4B0Subsystem(Form("b0Truth_%d", i), i);
detB0->SuperDetector(Form("b0Truth_%d", i));
detB0->set_double_param("place_x", 0);
detB0->set_double_param("place_y", 0);
// detB0->set_int_param("ispipe", 0); //for future pipe implementation
detB0->set_double_param("pipe_hole", pipe_hole);
detB0->set_double_param("cable_hole", cable_hole);
detB0->set_double_param("outer_radius", b0_radius);
detB0->set_double_param("d_radius", d_radius);
detB0->set_double_param("length", b0Si_zLen);
detB0->set_string_param("material", "G4_Si");
detB0->set_double_param("startAngle",start_angle);
detB0->set_double_param("spanningAngle",spanning_angle);
detB0->set_double_param("detid",i);
detB0->set_double_param("pipe_x", pipe_x);
detB0->set_double_param("pipe_y", 0);
detB0->set_double_param("pipe_z", 0);
detB0->set_double_param("pipe_hole_r", pipe_hole_r);
detB0->set_double_param("cable_x", cable_x);
detB0->set_double_param("cable_y", 0);
detB0->set_double_param("cable_z", 0);
detB0->set_double_param("place_z", b0tr_z); // relative to B0 magnet
detB0->SetActive(true);
if (verbosity)
detB0->Verbosity(verbosity);
detB0->OverlapCheck(overlapCheck);
detB0->SetMotherSubsystem(hFarFwdBeamLine::B0Magnet);
g4Reco->registerSubsystem(detB0);
// For B0 Tracking Implementation
if (Enable::B0TRACKING){
if (B0TRACKING::FastKalmanFilter)
{
B0TRACKING::FastKalmanFilter->add_phg4hits(string("G4HIT_") + Form("b0Truth_%d", i) , // const std::string& phg4hitsNames,
B0TrackFastSim::Vertical_Plane, // const DETECTOR_TYPE phg4dettype,
G4B0TRACKING::PositionResolution, // const float radres,
G4B0TRACKING::PositionResolution, // const float phires,
0, // const float lonres, *ignored in plane detector*
1, // const float eff,
0); // const float noise
B0TRACKING::FastKalmanFilter->add_zplane_state(Form("b0Truth_%d", i), b0Mag_zCent+b0tr_z);
B0TRACKING::FastKalmanFilterB0Track->add_phg4hits(string("G4HIT_") + Form("b0Truth_%d", i) , // const std::string& phg4hitsNames,
B0TrackFastSim::Vertical_Plane, // const DETECTOR_TYPE phg4dettype,
G4B0TRACKING::PositionResolution, // const float radres,
G4B0TRACKING::PositionResolution, // const float phires,
0, // const float lonres, *ignored in plane detector*
1, // const float eff,
0); // const float noise
B0TRACKING::FastKalmanFilterB0Track->add_zplane_state(Form("b0Truth_%d", i), b0Mag_zCent+b0tr_z);
B0TRACKING::B0ProjectionNames.insert(Form("b0Truth_%d", i));
}
}
auto *detB0e = new EICG4B0Subsystem(Form("b0Dead_%d", i), i);
detB0e->SuperDetector("b0Dead");
// detB0e->set_int_param("ispipe", 0); //for future pipe implementation
detB0e->set_double_param("pipe_hole", pipe_hole);
detB0e->set_double_param("place_x", 0);
detB0e->set_double_param("place_y", 0);
detB0e->set_double_param("d_radius", d_radius);
detB0e->set_double_param("pipe_x", pipe_x);
detB0e->set_double_param("pipe_y", 0);
detB0e->set_double_param("pipe_z", 0);
detB0e->set_double_param("pipe_hole_r", pipe_hole_r);
detB0e->set_double_param("cable_x", cable_x);
detB0e->set_double_param("cable_y", 0);
detB0e->set_double_param("cable_z", 0);
detB0e->set_double_param("outer_radius", b0_radius);
detB0e->set_double_param("length", b0Cu_zLen);
detB0e->set_string_param("material", "G4_Cu");
detB0e->set_double_param("detid",i);
detB0e->set_double_param("startAngle",start_angle);
detB0e->set_double_param("spanningAngle",spanning_angle);
detB0e->set_double_param("place_z", b0tr_z +(b0Cu_zLen+b0Si_zLen)/2) ; // relative to B0 magnet
detB0e->SetActive(false);
if (verbosity)
detB0e->Verbosity(verbosity);
detB0e->OverlapCheck(overlapCheck);
detB0e->SetMotherSubsystem(hFarFwdBeamLine::B0Magnet);
g4Reco->registerSubsystem(detB0e);
}
if (Enable::B0ECAL) {
pipe_hole = b0Mag_zLen*cross_angle;
pipe_x = - cross_angle*b0Mag_zCent - hFarFwdBeamLine::B0Magnet_x;
if (Enable::B0_CIRCLE_PIPE_HOLE){
pipe_hole = 0.1;
pipe_hole_r = pipe_hole_r + b0Mag_zLen*cross_angle/2;
}
cout <<"Starting B0 ECAL "<<endl;
cout <<"Pipe Hole: "<< pipe_hole<<"\t"<<pipe_x<<endl;
if (Enable::B0ECALTOWERS){ //Use this option to do physics studies
// pipe_x=-1.25;
// pipe_hole=3.0;
cout << hFarFwdBeamLine::B0Magnet_x<<endl;
ostringstream mapping_b0ecal;
mapping_b0ecal << getenv("CALIBRATIONROOT") << "/B0Ecal/mapping/B0ECAL_mapping_v2.txt"; // Specify the mapping file for B0 ECal Towers here
// mapping_b0ecal << "B0ECAL_mapping_v2.txt"; // Specify the mapping file for B0 ECal Towers here
//cout <<"Will use B0 mapping file "<< mapping_b0ecal.str()<<endl;
auto *B0Ecal = new EICG4B0ECALSubsystem("B0ECAL");
B0Ecal->SetTowerMappingFile(mapping_b0ecal.str());
B0Ecal->SuperDetector("B0ECAL");
B0Ecal->set_double_param("pipe_hole", pipe_hole);
B0Ecal->set_double_param("place_x", 0);
B0Ecal->set_double_param("place_y", 0);
B0Ecal->set_double_param("place_z", b0Ecal_z);
B0Ecal->set_double_param("pipe_x", pipe_x);
B0Ecal->set_double_param("pipe_y", 0);
B0Ecal->set_double_param("pipe_z", 0);
B0Ecal->set_double_param("pipe_hole_r", pipe_hole_r);
B0Ecal->set_double_param("cable_x", cable_x);
B0Ecal->set_double_param("cable_y", 0);
B0Ecal->set_double_param("cable_z", 0);
B0Ecal->set_double_param("length", b0Ecal_zLen);
B0Ecal->set_double_param("outer_radius", b0_radius);
B0Ecal->set_double_param("d_radius", d_radius);
B0Ecal->set_string_param("material", "G4_PbWO4");
B0Ecal->set_double_param("startAngle",start_angle);
B0Ecal->set_double_param("spanningAngle",spanning_angle);
B0Ecal->set_double_param("detid",0);
B0Ecal->set_double_param("global_x",hFarFwdBeamLine::B0Magnet_x);
B0Ecal->set_double_param("global_y",hFarFwdBeamLine::B0Magnet_y);
B0Ecal->set_double_param("global_z",hFarFwdBeamLine::B0Magnet_z);
B0Ecal->set_int_param("lightyield",1); //Note additional parameter for storing Light Yield in B0 Ecal
B0Ecal->SetActive(true);
if (verbosity)
B0Ecal->Verbosity(verbosity);
B0Ecal->OverlapCheck(overlapCheck);
B0Ecal->SetMotherSubsystem(hFarFwdBeamLine::B0Magnet);
g4Reco->registerSubsystem(B0Ecal);
}
else { //Use this option to have a circular packman-shape of the B0 ECal for plots.
auto *B0Ecal = new EICG4B0Subsystem(Form("b0Truth_%d", 2*b0DetNr), 2*b0DetNr);
B0Ecal->SuperDetector("b0Truth");
B0Ecal->set_double_param("pipe_hole", pipe_hole);
B0Ecal->set_double_param("place_x", 0);
B0Ecal->set_double_param("place_y", 0);
B0Ecal->set_double_param("place_z", b0Ecal_z);
B0Ecal->set_double_param("pipe_x", pipe_x);
B0Ecal->set_double_param("pipe_y", 0);
B0Ecal->set_double_param("pipe_z", 0);
B0Ecal->set_double_param("pipe_hole_r", pipe_hole_r);
B0Ecal->set_double_param("cable_x", cable_x);
B0Ecal->set_double_param("cable_y", 0);
B0Ecal->set_double_param("cable_z", 0);
B0Ecal->set_double_param("length", b0Ecal_zLen);
B0Ecal->set_double_param("outer_radius", b0_radius);
B0Ecal->set_double_param("d_radius", d_radius);
B0Ecal->set_string_param("material", "G4_PbWO4");
B0Ecal->set_double_param("startAngle",start_angle);
B0Ecal->set_double_param("spanningAngle",spanning_angle);
B0Ecal->set_double_param("detid",2*b0DetNr);
B0Ecal->SetActive(true);
if (verbosity)
B0Ecal->Verbosity(verbosity);
B0Ecal->OverlapCheck(overlapCheck);
B0Ecal->SetMotherSubsystem(hFarFwdBeamLine::B0Magnet);
g4Reco->registerSubsystem(B0Ecal);
}
auto *B0Ecale = new EICG4B0Subsystem(Form("b0Dead_%d", b0DetNr), b0DetNr); //B0 ECal dead layer is the same subsystem as other four dead layers
B0Ecale->SuperDetector("b0Dead");
// B0Ecale->set_int_param("ispipe", 0); //for future pipe implementation
B0Ecale->set_double_param("pipe_hole", pipe_hole);
B0Ecale->set_double_param("place_x", 0);
B0Ecale->set_double_param("place_y", 0);
B0Ecale->set_double_param("place_z", b0Ecal_z + (b0Ecal_zLen + b0Cu_zLen)/2);
B0Ecale->set_double_param("pipe_x", pipe_x);
B0Ecale->set_double_param("pipe_y", 0);
B0Ecale->set_double_param("pipe_z", 0);
B0Ecale->set_double_param("pipe_hole_r", pipe_hole_r);
B0Ecale->set_double_param("cable_x", cable_x);
B0Ecale->set_double_param("cable_y", 0);
B0Ecale->set_double_param("cable_z", 0);
B0Ecale->set_double_param("length", b0Cu_zLen);
B0Ecale->set_double_param("d_radius", d_radius);
B0Ecale->set_double_param("outer_radius", b0_radius);
B0Ecale->set_string_param("material", "G4_Cu");
B0Ecale->set_double_param("startAngle",start_angle);
B0Ecale->set_double_param("spanningAngle",spanning_angle);
B0Ecale->set_double_param("detid",b0DetNr+1);
//B0Ecale->SetActive(true);
B0Ecale->SetActive(false);
if (verbosity)
B0Ecale->Verbosity(verbosity);
B0Ecale->OverlapCheck(overlapCheck);
B0Ecale->SetMotherSubsystem(hFarFwdBeamLine::B0Magnet);
g4Reco->registerSubsystem(B0Ecale);
}
} else {
if (Enable::B0_FULLHITPLANE) {
// Choice 2 circular hit planes
cout << "Circular hit planes"<<endl;
for (int i = 0; i < b0DetNr; i++)
{
b0tr_z = b0tr[i] - b0Mag_zLen / 2;
auto *detB0 = new PHG4CylinderSubsystem(Form("b0Truth_%d", i), i);
detB0->SuperDetector("b0Truth");
//detB0->SuperDetector(Form("b0Truth_%d", i));
detB0->set_double_param("radius", 0);
detB0->set_double_param("thickness", 20);
detB0->set_double_param("length", 0.1);
detB0->set_string_param("material", "G4_Si");
detB0->set_double_param("place_z", b0tr_z); // relative to B0 magnet
detB0->SetActive(true);
if (verbosity) detB0->Verbosity(verbosity);
detB0->OverlapCheck(overlapCheck);
detB0->SetMotherSubsystem(hFarFwdBeamLine::B0Magnet);
g4Reco->registerSubsystem(detB0);
if (Enable::B0TRACKING){
if (B0TRACKING::FastKalmanFilter)
{
B0TRACKING::FastKalmanFilter->add_phg4hits(string("G4HIT_") + Form("b0Truth_%d", i) , // const std::string& phg4hitsNames,
B0TrackFastSim::Vertical_Plane, // const DETECTOR_TYPE phg4dettype,
G4B0TRACKING::PositionResolution, // const float radres,
G4B0TRACKING::PositionResolution, // const float phires,
0, // const float lonres, *ignored in plane detector*
1, // const float eff,
0); // const float noise
B0TRACKING::FastKalmanFilter->add_zplane_state(Form("b0Truth_%d", i), b0Mag_zCent+b0tr_z);
B0TRACKING::FastKalmanFilterB0Track->add_phg4hits(string("G4HIT_") + Form("b0Truth_%d", i) , // const std::string& phg4hitsNames,
B0TrackFastSim::Vertical_Plane, // const DETECTOR_TYPE phg4dettype,
G4B0TRACKING::PositionResolution, // const float radres,
G4B0TRACKING::PositionResolution, // const float phires,
0, // const float lonres, *ignored in plane detector*
1, // const float eff,
0); // const float noise
B0TRACKING::FastKalmanFilterB0Track->add_zplane_state(Form("b0Truth_%d", i), b0Mag_zCent+b0tr_z);
B0TRACKING::B0ProjectionNames.insert(Form("b0Truth_%d", i));
}
}
}
} else {
/// Fun4All default B0 planes
/// Choice 3 Hit planes with real detector geometry
cout << "Realistic hit planes"<<endl;
for (int i = 0; i < b0DetNr; i++) {
if (Enable::B0_VAR_PIPE_HOLE){
pipe_hole = b0tr[i]*cross_angle;
pipe_x = - cross_angle*(b0Mag_zCent - b0Mag_zLen/2 + b0tr[i]/2) - hFarFwdBeamLine::B0Magnet_x;
}
else if (Enable::B0_CIRCLE_PIPE_HOLE){
pipe_hole = 0.1;
pipe_hole_r = pipe_hole_r + b0tr[b0DetNr-1]*cross_angle/2;
pipe_x = - cross_angle*(b0Mag_zCent - b0Mag_zLen/2 + b0tr[b0DetNr-1]/2) - hFarFwdBeamLine::B0Magnet_x;
}
else {
pipe_hole = b0tr[b0DetNr-1]*cross_angle;
pipe_x = - cross_angle*(b0Mag_zCent - b0Mag_zLen/2 + b0tr[b0DetNr-1]/2) - hFarFwdBeamLine::B0Magnet_x;
}
cout <<"Starting B0 Tracker layer "<<i+1<<endl;
cout <<"Pipe Hole: "<< pipe_hole<<"\t"<<pipe_x<<endl;
b0tr_z = b0tr[i] - b0Mag_zLen / 2;
auto *detB0 = new EICG4B0Subsystem(Form("b0Truth_%d", i), i);
detB0->SuperDetector(Form("b0Truth_%d", i));
detB0->set_double_param("place_x", 0);
detB0->set_double_param("place_y", 0);
// detB0->set_int_param("ispipe", 0); //for future pipe implementation
detB0->set_double_param("pipe_hole", pipe_hole);
detB0->set_double_param("cable_hole", cable_hole);
detB0->set_double_param("outer_radius", b0_radius);
detB0->set_double_param("d_radius", d_radius);
detB0->set_double_param("length", b0Si_zLen);
detB0->set_string_param("material", "G4_Si");
detB0->set_double_param("startAngle",start_angle);
detB0->set_double_param("spanningAngle",spanning_angle);
detB0->set_double_param("detid",i);
detB0->set_double_param("pipe_x", pipe_x);
detB0->set_double_param("pipe_y", 0);
detB0->set_double_param("pipe_z", 0);
detB0->set_double_param("pipe_hole_r", pipe_hole_r);
detB0->set_double_param("cable_x", cable_x);
detB0->set_double_param("cable_y", 0);
detB0->set_double_param("cable_z", 0);
detB0->set_double_param("place_z", b0tr_z); // relative to B0 magnet
detB0->SetActive(true);
if (verbosity)
detB0->Verbosity(verbosity);
detB0->OverlapCheck(overlapCheck);
detB0->SetMotherSubsystem(hFarFwdBeamLine::B0Magnet);
g4Reco->registerSubsystem(detB0);
if (Enable::B0TRACKING){
if (B0TRACKING::FastKalmanFilter)
{
B0TRACKING::FastKalmanFilter->add_phg4hits(string("G4HIT_") + Form("b0Truth_%d", i) , // const std::string& phg4hitsNames,
B0TrackFastSim::Vertical_Plane, // const DETECTOR_TYPE phg4dettype,
G4B0TRACKING::PositionResolution, // const float radres,
G4B0TRACKING::PositionResolution, // const float phires,
0, // const float lonres, *ignored in plane detector*
1, // const float eff,
0); // const float noise
B0TRACKING::FastKalmanFilter->add_zplane_state(Form("b0Truth_%d", i), b0Mag_zCent+b0tr_z);
B0TRACKING::FastKalmanFilterB0Track->add_phg4hits(string("G4HIT_") + Form("b0Truth_%d", i) , // const std::string& phg4hitsNames,
B0TrackFastSim::Vertical_Plane, // const DETECTOR_TYPE phg4dettype,
G4B0TRACKING::PositionResolution, // const float radres,
G4B0TRACKING::PositionResolution, // const float phires,
0, // const float lonres, *ignored in plane detector*
1, // const float eff,
0); // const float noise
B0TRACKING::FastKalmanFilterB0Track->add_zplane_state(Form("b0Truth_%d", i), b0Mag_zCent+b0tr_z);
B0TRACKING::B0ProjectionNames.insert(Form("b0Truth_%d", i));
}
}
}
}
}
}
void hFarFwdDefineDetectorsIP8(PHG4Reco *g4Reco)
{
//--------------------------------------------------------
// The IP8 detector position is implemented by Wenliang Li ([email protected])
// on July 07, 2021
// Reference of this implementation: https://indico.bnl.gov/event/10974/contributions/51160/
bool overlapCheck = Enable::OVERLAPCHECK || Enable::HFARFWD_OVERLAPCHECK;
if (Enable::HFARFWD_VIRTUAL_DETECTORS_IP6 && Enable::HFARFWD_VIRTUAL_DETECTORS_IP8)
{
cout << "You cannot have detectors enabled for both IP6 and IP8 ON at the same time" << endl;
gSystem->Exit(1);
}
int verbosity = std::max(Enable::VERBOSITY, Enable::HFARFWD_VERBOSITY);
const int offMomDetNr = 2;
const double om_xCent[offMomDetNr] = {46, 49};
const double om_zCent[offMomDetNr] = {3250, 3450};
for (int i = 0; i < offMomDetNr; i++)
{
auto *detOM = new PHG4BlockSubsystem(Form("offMomTruth_%d", i), i);
detOM->SuperDetector("offMomTruth");
detOM->set_double_param("place_x", PosFlip(om_xCent[i]));
detOM->set_double_param("place_y", 0);
detOM->set_double_param("place_z", PosFlip(om_zCent[i] - hFarFwdBeamLine::enclosure_center));
detOM->set_double_param("rot_y", AngleFlip(-0.045 * TMath::RadToDeg()));
detOM->set_double_param("size_x", 40); // Original design specification
detOM->set_double_param("size_y", 35); // Original design specification
detOM->set_double_param("size_z", 0.03);
detOM->set_string_param("material", "G4_Si");
detOM->OverlapCheck(overlapCheck);
detOM->SetMotherSubsystem(hFarFwdBeamLine::hFarFwdBeamLineEnclosure);
detOM->SetActive();
detOM->set_color(0, 0, 1, 0.5);
if (verbosity) detOM->Verbosity(verbosity);
g4Reco->registerSubsystem(detOM);
}
auto *detZDCsurrogate = new PHG4BlockSubsystem("zdcTruth");
const double detZDCsurrogate_size_z = 0.1;
detZDCsurrogate->SuperDetector("ZDCsurrogate");
detZDCsurrogate->set_double_param("place_x", PosFlip(120));
detZDCsurrogate->set_double_param("place_y", 0);
detZDCsurrogate->set_double_param("place_z", 3350 - hFarFwdBeamLine::enclosure_center);
detZDCsurrogate->set_double_param("rot_y", AngleFlip(-0.035 * TMath::RadToDeg()));
detZDCsurrogate->set_double_param("size_x", 60);
detZDCsurrogate->set_double_param("size_y", 60);
detZDCsurrogate->set_double_param("size_z", detZDCsurrogate_size_z);
detZDCsurrogate->set_string_param("material", "G4_Si");
detZDCsurrogate->SetActive();
detZDCsurrogate->OverlapCheck(overlapCheck);
detZDCsurrogate->set_color(1, 0, 0, 0.5);
if (!Enable::ZDC_DISABLE_BLACKHOLE) detZDCsurrogate->BlackHole();
if (verbosity) detZDCsurrogate->Verbosity(verbosity);
detZDCsurrogate->SetMotherSubsystem(hFarFwdBeamLine::hFarFwdBeamLineEnclosure);
g4Reco->registerSubsystem(detZDCsurrogate);
if (Enable::ZDC_DISABLE_BLACKHOLE)
{
EICG4ZDCSubsystem *detZDC = new EICG4ZDCSubsystem("EICG4ZDC");
detZDC->SetActive();
detZDC->set_double_param("place_z", 3350. + detZDCsurrogate_size_z - hFarFwdBeamLine::enclosure_center);
detZDC->set_double_param("place_x", PosFlip(120.0));
detZDC->set_double_param("rot_y", AngleFlip(-0.035));
detZDC->SetMotherSubsystem(hFarFwdBeamLine::hFarFwdBeamLineEnclosure);
detZDC->OverlapCheck(overlapCheck);
g4Reco->registerSubsystem(detZDC);
}
//----------------------
// Roman Pots: Both sets before and near the secondary focus
//----------------------
if( ! Enable::RP_DISABLE_HITPLANE )
{
string paramFile = string(getenv("CALIBRATIONROOT")) + "/RomanPots/RP_parameters_IP8.dat";
int Nlayers = GetParameterFromFile <int> (paramFile, "Number_layers");
for( int layer = 0; layer < Nlayers; layer++ ) {
auto *detRP = new EICG4RPSubsystem( Form("rpTruth_%d", layer), layer );
detRP->SuperDetector( "rpTruth" );
detRP->set_double_param( "FFenclosure_center", hFarFwdBeamLine::enclosure_center );
detRP->set_int_param( "layerNumber", layer + 1 );
detRP->SetBeamConfig( (Enable::BEAM_COLLISION_SETTING).Data() );
detRP->SetIonBeamEnergy( Enable::HFARFWD_ION_ENERGY );
detRP->SetElectronBeamEnergy( Enable::HFARBWD_E_ENERGY );
detRP->SetParametersFromFile( paramFile );
detRP->OverlapCheck( overlapCheck );
detRP->SetMotherSubsystem( hFarFwdBeamLine::hFarFwdBeamLineEnclosure );
detRP->SetActive( true );
if( verbosity ) { detRP->Verbosity( verbosity ); }
g4Reco->registerSubsystem( detRP );
}
}
if (verbosity > 0)
{
std::cout << "B0Magnet can be mother = " << hFarFwdBeamLine::B0Magnet->CanBeMotherSubsystem() << std::endl;
}
/* const int b0DetNr = 4;
const double b0Mag_zCent = 610;
const double b0Mag_zLen = 120;
for (int i = 0; i < b0DetNr; i++)
{
auto *detB0 = new PHG4CylinderSubsystem(Form("b0Truth_%d", i), i);
detB0->SuperDetector("b0Truth");
detB0->set_double_param("radius", 0);
detB0->set_double_param("thickness", 20);
detB0->set_double_param("length", 0.1);
detB0->set_string_param("material", "G4_Si");
detB0->set_double_param("place_y", 0);
detB0->set_double_param("place_z", b0Mag_zLen / (b0DetNr + 1) * (i - b0DetNr / 2));
detB0->OverlapCheck(overlapCheck);
detB0->SetMotherSubsystem(hFarFwdBeamLine::B0Magnet);
detB0->SetActive(true);
if (verbosity)
detB0->Verbosity(verbosity);
g4Reco->registerSubsystem(detB0);
}*/
//---------------------------------
// B0 implementation
// Three choices: 1. Realistic detector; 2. Circulat plane; 3. hit plane with realistic detector goemetry
double b0tr_z = 0; //Subsystem position relative to B0 magnet (for iterator)
const int b0DetNr = 4;
const double b0Mag_zCent = 610;
const double b0Mag_zLen = 120;
const double b0tr[4]={10,40,70,100};
const double b0Cu_zLen = .2; //B0 dead material length
const double b0Si_zLen = .1; //B0 Si length
const double b0Ecal_zLen = 10; //B0 Ecal length
double pipe_hole_r = 3.5; //detector cut off for beam pipe
double pipe_hole = 2.5;
const double cable_hole = 2.0;
const double cable_x = 21.5;
double pipe_x = -1.; //pipe hole position
const double d_radius = 7.0; //detector cut off Packman
const double b0_radius = 23.5; //outer radius of B0-detector
const double b0_magradius = 24.5; //inner radius of B0-magnet
const double spanning_angle = 240; //spanning angle Packman
const double b0Ecal_z = 48;//B0 ECal position (relative to the B0-magnet)
double start_angle = -120; //start angle Packman
const double cross_angle = 0.035;
if (Enable::B0_DISABLE_HITPLANE) {
// Choice 1 realistic detector
// const double b0tr[4]={10,45,80,115};
//const double b0tr[4]={0,30,60,90};
//const double b0tr[5]={0,25,50,75,100};
cout << "Realistic B0"<<endl;
for (int i = 0; i < b0DetNr; i++)
{
if (Enable::B0_VAR_PIPE_HOLE){
pipe_hole = b0tr[i]*cross_angle;
pipe_x = cross_angle*(b0Mag_zCent - b0Mag_zLen/2 + b0tr[i]/2) - hFarFwdBeamLine::B0Magnet_x;
}
else if (Enable::B0_CIRCLE_PIPE_HOLE){
pipe_hole = 0.1;
pipe_hole_r = pipe_hole_r + b0tr[b0DetNr-1]*cross_angle/2;
pipe_x = cross_angle*(b0Mag_zCent - b0Mag_zLen/2 + b0tr[b0DetNr-1]/2) - hFarFwdBeamLine::B0Magnet_x;
}
else {
pipe_hole = b0tr[b0DetNr-1]*cross_angle;
pipe_x = cross_angle*(b0Mag_zCent - b0Mag_zLen/2 + b0tr[b0DetNr-1]/2) - hFarFwdBeamLine::B0Magnet_x;
}
cout <<"Starting B0 Tracker layer "<<i+1<<endl;
cout <<"Pipe Hole: "<< pipe_hole<<"\t"<<pipe_x<<endl;
b0tr_z = b0tr[i] - b0Mag_zLen / 2;
auto *detB0 = new EICG4B0Subsystem(Form("b0Truth_%d", i), i);
detB0->SuperDetector(Form("b0Truth_%d", i));
detB0->set_double_param("place_x", 0);
detB0->set_double_param("place_y", 0);
// detB0->set_int_param("ispipe", 0); //for future pipe implementation
detB0->set_double_param("pipe_hole", pipe_hole);
detB0->set_double_param("cable_hole", cable_hole);
detB0->set_double_param("outer_radius", b0_radius);
detB0->set_double_param("d_radius", d_radius);
detB0->set_double_param("length", b0Si_zLen);
detB0->set_string_param("material", "G4_Si");
detB0->set_double_param("startAngle",start_angle);
detB0->set_double_param("spanningAngle",spanning_angle);
detB0->set_double_param("detid",i);
detB0->set_double_param("pipe_x", pipe_x);
detB0->set_double_param("pipe_y", 0);
detB0->set_double_param("pipe_z", 0);
detB0->set_double_param("pipe_hole_r", pipe_hole_r);
detB0->set_double_param("cable_x", cable_x);
detB0->set_double_param("cable_y", 0);
detB0->set_double_param("cable_z", 0);
detB0->set_double_param("place_z", b0tr_z); // relative to B0 magnet
detB0->SetActive(true);
if (verbosity)
detB0->Verbosity(verbosity);
detB0->OverlapCheck(overlapCheck);
detB0->SetMotherSubsystem(hFarFwdBeamLine::B0Magnet);
g4Reco->registerSubsystem(detB0);
// For B0 Tracking Implementation
if (Enable::B0TRACKING){
if (B0TRACKING::FastKalmanFilter)
{
B0TRACKING::FastKalmanFilter->add_phg4hits(string("G4HIT_") + Form("b0Truth_%d", i) , // const std::string& phg4hitsNames,
B0TrackFastSim::Vertical_Plane, // const DETECTOR_TYPE phg4dettype,
G4B0TRACKING::PositionResolution, // const float radres,
G4B0TRACKING::PositionResolution, // const float phires,
0, // const float lonres, *ignored in plane detector*
1, // const float eff,
0); // const float noise
B0TRACKING::FastKalmanFilter->add_zplane_state(Form("b0Truth_%d", i), b0Mag_zCent+b0tr_z);
B0TRACKING::FastKalmanFilterB0Track->add_phg4hits(string("G4HIT_") + Form("b0Truth_%d", i) , // const std::string& phg4hitsNames,
B0TrackFastSim::Vertical_Plane, // const DETECTOR_TYPE phg4dettype,
G4B0TRACKING::PositionResolution, // const float radres,
G4B0TRACKING::PositionResolution, // const float phires,
0, // const float lonres, *ignored in plane detector*
1, // const float eff,
0); // const float noise
B0TRACKING::FastKalmanFilterB0Track->add_zplane_state(Form("b0Truth_%d", i), b0Mag_zCent+b0tr_z);
B0TRACKING::B0ProjectionNames.insert(Form("b0Truth_%d", i));
}
}
auto *detB0e = new EICG4B0Subsystem(Form("b0Dead_%d", i), i);
detB0e->SuperDetector("b0Dead");
// detB0e->set_int_param("ispipe", 0); //for future pipe implementation
detB0e->set_double_param("pipe_hole", pipe_hole);
detB0e->set_double_param("place_x", 0);
detB0e->set_double_param("place_y", 0);
detB0e->set_double_param("d_radius", d_radius);
detB0e->set_double_param("pipe_x", pipe_x);
detB0e->set_double_param("pipe_y", 0);
detB0e->set_double_param("pipe_z", 0);
detB0e->set_double_param("pipe_hole_r", pipe_hole_r);