-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathDetectorConstruction.cc
1215 lines (1001 loc) · 66.1 KB
/
DetectorConstruction.cc
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
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// DetectorConstruction.cc
// Developer : Chao Peng, Chao Gu
// History:
// Aug 2012, C. Peng, Original version.
// Jan 2017, C. Gu, Rewrite with ROOT support.
// Mar 2017, C. Gu, Add DRad configuration.
//
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
#include "DetectorConstruction.hh"
#include "CalorimeterSD.hh"
#include "CheckScatteringSD.hh"
#include "DetectorMessenger.hh"
#include "StandardDetectorSD.hh"
#include "StepRecordSD.hh"
#include "TrackingDetectorSD.hh"
#include "TROOT.h"
#include "TError.h"
#include "TObject.h"
#include "G4Element.hh"
#include "G4Isotope.hh"
#include "G4Material.hh"
#include "G4NistManager.hh"
#include "G4Box.hh"
#include "G4LogicalVolume.hh"
#include "G4LogicalVolumeStore.hh"
#include "G4Polycone.hh"
#include "G4Polyhedra.hh"
#include "G4PVParameterised.hh"
#include "G4PVPlacement.hh"
#include "G4RotationMatrix.hh"
#include "G4Sphere.hh"
#include "G4SubtractionSolid.hh"
#include "G4Tubs.hh"
#include "G4UnionSolid.hh"
#include "G4UserLimits.hh"
#include "G4VPhysicalVolume.hh"
#include "G4VSolid.hh"
#include "G4VUserDetectorConstruction.hh"
#include "G4SDManager.hh"
#include "G4Colour.hh"
#include "G4PhysicalConstants.hh"
#include "G4SystemOfUnits.hh"
#include "G4String.hh"
#include "G4VisAttributes.hh"
#include <cmath>
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
DetectorConstruction::DetectorConstruction(G4String conf) : G4VUserDetectorConstruction(), fConfig(conf)
{
if (fConfig != "prad" && fConfig != "drad" && fConfig != "test")
fConfig = "prad";
fVisAtts.clear();
fWorldSizeXY = 150.0 * cm;
fWorldSizeZ = 600.0 * cm;
fTargetCenter = -300.0 * cm + 89.0 * mm; // PRad survey
fTargetR = 14.5 * cm;
fTargetHalfL = 2.75 * cm;
fTargetMat = "D2Gas";
fTargetDensityRatio = 1.0;
fRecoilDetNSeg = 20;
fRecoilDetCenter = fTargetCenter;
fRecoilDetR = 13.5 * cm;
fRecoilDetHalfL = 2.6 * cm;
fRecoilDetL1Thickness = 200 * um;
fRecoilDetL2Thickness = 300 * um;
fDownChamberCenter = fTargetCenter + 74.0 * mm + 71.0 * cm / 2.0;
fVacBoxCenter = fTargetCenter + 74.0 * mm + 71.0 * cm + 425.17 * cm / 2.0;
fGEMCenter[0] = 217.5 * cm;
fGEMCenter[1] = 257.5 * cm;
fSciPlaneCenter = 262.5 * cm;
fCrystalSurf = 295.0 * cm;
fExtDensityRatio = 1.0;
if (fConfig == "drad") {
fTargetSDOn = false;
fRecoilDetSDOn = true;
fGEMSDOn = true;
fSciPlaneSDOn = true;
fHyCalSDOn = true;
fVirtualSDOn = false;
} else {
fTargetSDOn = false;
fRecoilDetSDOn = false;
fGEMSDOn = true;
fSciPlaneSDOn = false;
fHyCalSDOn = true;
fVirtualSDOn = false;
}
fAttenuationLG = 0.0;
fReflectanceLG = 1.0;
detectorMessenger = new DetectorMessenger(this);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
DetectorConstruction::~DetectorConstruction()
{
delete detectorMessenger;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4VPhysicalVolume *DetectorConstruction::Construct()
{
// Define materials
DefineMaterials();
// Define volumes
if (fConfig == "drad")
return DefineDRadVolumes();
else if (fConfig == "test")
return DefineTestVolumes();
else
return DefinePRadVolumes();
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void DetectorConstruction::ConstructSDandField()
{
if (fConfig == "drad")
DefineDRadSDs();
else if (fConfig == "test")
DefineTestSDs();
else
DefinePRadSDs();
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void DetectorConstruction::DefineMaterials()
{
G4String symbol;
G4int z, n;
G4double a;
G4double density;
G4int ncomponents, natoms;
G4double fractionmass;
G4NistManager *pNM = G4NistManager::Instance();
// Define elements from NIST material table
G4Element *H = pNM->FindOrBuildElement(z = 1);
G4Element *He = pNM->FindOrBuildElement(z = 2);
G4Element *C = pNM->FindOrBuildElement(z = 6);
G4Element *N = pNM->FindOrBuildElement(z = 7);
G4Element *O = pNM->FindOrBuildElement(z = 8);
G4Element *F = pNM->FindOrBuildElement(z = 9);
G4Element *Na = pNM->FindOrBuildElement(z = 11);
G4Element *Al = pNM->FindOrBuildElement(z = 13);
G4Element *Si = pNM->FindOrBuildElement(z = 14);
G4Element *P = pNM->FindOrBuildElement(z = 15);
G4Element *S = pNM->FindOrBuildElement(z = 16);
G4Element *Ar = pNM->FindOrBuildElement(z = 18);
G4Element *K = pNM->FindOrBuildElement(z = 19);
G4Element *Cr = pNM->FindOrBuildElement(z = 24);
G4Element *Mn = pNM->FindOrBuildElement(z = 25);
G4Element *Fe = pNM->FindOrBuildElement(z = 26);
G4Element *Ni = pNM->FindOrBuildElement(z = 28);
G4Element *Cu = pNM->FindOrBuildElement(z = 29);
G4Element *Zn = pNM->FindOrBuildElement(z = 30);
G4Element *As = pNM->FindOrBuildElement(z = 33);
G4Element *W = pNM->FindOrBuildElement(z = 74);
G4Element *Pb = pNM->FindOrBuildElement(z = 82);
// Define isotopes
G4Isotope *H2 = new G4Isotope("H2", z = 1, n = 2, a = 2.0141 * g / mole);
G4Element *D = new G4Element("Deuterium", symbol = "D", ncomponents = 1);
D->AddIsotope(H2, 1.0);
// Define materials
// Space Vacuum
G4Material *Galaxy = new G4Material("Galaxy", density = universe_mean_density, ncomponents = 1, kStateGas, 0.1 * kelvin, 1.0e-19 * pascal);
Galaxy->AddElement(H, fractionmass = 1.0);
fVisAtts[Galaxy->GetName()] = new G4VisAttributes(G4VisAttributes::Invisible);
// Air
G4Material *Air = new G4Material("Air", density = 1.292 * mg / cm3, ncomponents = 2);
Air->AddElement(N, fractionmass = 0.7);
Air->AddElement(O, fractionmass = 0.3);
fVisAtts[Air->GetName()] = new G4VisAttributes(G4VisAttributes::Invisible);
// Air vacuum of 1.e-6 torr at room temperature, 1 atmosphere = 760 torr
G4Material *Vacuum = new G4Material("Vacuum", density = 1.0e-6 / 760.0 * 1.292 * mg / cm3, ncomponents = 1, kStateGas, STP_Temperature, 1.0e-6 / 760.0 * atmosphere);
Vacuum->AddMaterial(Air, fractionmass = 1.0);
fVisAtts[Vacuum->GetName()] = new G4VisAttributes(G4VisAttributes::Invisible);
// Hydrogen Gas (T = 19.5 K, P = 470 mTorr)
G4Material *H2Gas = new G4Material("H2Gas", density = fTargetDensityRatio * 0.47 / 760.0 * 273.15 / 19.5 * 0.08988 * mg / cm3, ncomponents = 1, kStateGas, 19.5 * kelvin, fTargetDensityRatio * 0.47 / 760.0 * atmosphere);
H2Gas->AddElement(H, natoms = 2);
fVisAtts[H2Gas->GetName()] = new G4VisAttributes(G4Colour::Cyan());
// Deuteron Gas
G4Material *D2Gas = new G4Material("D2Gas", density = fTargetDensityRatio * 0.47 / 760.0 * 273.15 / 19.5 * 0.1796 * mg / cm3, ncomponents = 1, kStateGas, 19.5 * kelvin, fTargetDensityRatio * 0.47 / 760.0 * atmosphere);
D2Gas->AddElement(D, natoms = 2);
fVisAtts[D2Gas->GetName()] = new G4VisAttributes(G4Colour::Cyan());
// Copper C101
G4Material *Copper = new G4Material("Copper", density = fExtDensityRatio * 8.92 * g / cm3, ncomponents = 1);
Copper->AddElement(Cu, natoms = 1);
fVisAtts[Copper->GetName()] = new G4VisAttributes(G4Colour::Brown());
G4Material *Copper0d2 = new G4Material("Copper0.2", Copper->GetDensity() * 0.2, Copper);
fVisAtts[Copper0d2->GetName()] = new G4VisAttributes(G4Colour::Brown());
G4Material *Copper0d75 = new G4Material("Copper0.75", Copper->GetDensity() * 0.75, Copper);
fVisAtts[Copper0d75->GetName()] = new G4VisAttributes(G4Colour::Brown());
G4Material *Copper0d8 = new G4Material("Copper0.8", Copper->GetDensity() * 0.8, Copper);
fVisAtts[Copper0d8->GetName()] = new G4VisAttributes(G4Colour::Brown());
// Kapton
G4Material *Kapton = new G4Material("Kapton", density = fExtDensityRatio * 1.42 * g / cm3, ncomponents = 4);
Kapton->AddElement(H, fractionmass = 0.0273);
Kapton->AddElement(C, fractionmass = 0.7213);
Kapton->AddElement(N, fractionmass = 0.0765);
Kapton->AddElement(O, fractionmass = 0.1749);
fVisAtts[Kapton->GetName()] = new G4VisAttributes(G4Colour::Brown());
G4Material *Kapton0d2 = new G4Material("Kapton0.2", Kapton->GetDensity() * 0.2, Kapton);
fVisAtts[Kapton0d2->GetName()] = new G4VisAttributes(G4Colour::Brown());
G4Material *Kapton0d8 = new G4Material("Kapton0.8", Kapton->GetDensity() * 0.8, Kapton);
fVisAtts[Kapton0d8->GetName()] = new G4VisAttributes(G4Colour::Brown());
// Silicon
G4Material *Silicon = new G4Material("Silicon", density = 2.329 * g / cm3, ncomponents = 1);
Silicon->AddElement(Si, natoms = 1);
fVisAtts[Silicon->GetName()] = new G4VisAttributes(G4Colour::Green());
// Aluminum
G4Material *Aluminum = new G4Material("Aluminum", density = fExtDensityRatio * 2.700 * g / cm3, ncomponents = 1);
Aluminum->AddElement(Al, natoms = 1);
fVisAtts[Aluminum->GetName()] = new G4VisAttributes(G4Colour::Grey());
// Tedlar
G4Material *Tedlar = new G4Material("Tedlar", density = 1.545 * g / cm3, ncomponents = 3);
Tedlar->AddElement(H, natoms = 3);
Tedlar->AddElement(C, natoms = 2);
Tedlar->AddElement(F, natoms = 1);
fVisAtts[Tedlar->GetName()] = new G4VisAttributes(G4Colour::Grey());
// Stainless Steel
G4Material *SSteel = new G4Material("SSteel", density = fExtDensityRatio * 7.9 * g / cm3, ncomponents = 9);
SSteel->AddElement(C, fractionmass = 0.0007);
SSteel->AddElement(Si, fractionmass = 0.01);
SSteel->AddElement(Mn, fractionmass = 0.02);
SSteel->AddElement(Ni, fractionmass = 0.09);
SSteel->AddElement(P, fractionmass = 0.00045);
SSteel->AddElement(S, fractionmass = 0.00015);
SSteel->AddElement(Cr, fractionmass = 0.18);
SSteel->AddElement(N, fractionmass = 0.0011);
SSteel->AddElement(Fe, fractionmass = 0.6976);
fVisAtts[SSteel->GetName()] = new G4VisAttributes(G4Colour::Grey());
// Nickel
G4Material *Nickel = new G4Material("Nickel", density = fExtDensityRatio * 8.908 * g / cm3, ncomponents = 1);
Nickel->AddElement(Ni, natoms = 1);
fVisAtts[Nickel->GetName()] = new G4VisAttributes(G4Colour::Black());
// GEM Frame G10
G4Material *NemaG10 = new G4Material("NemaG10", density = fExtDensityRatio * 1.700 * g / cm3, ncomponents = 4);
NemaG10->AddElement(Si, natoms = 1);
NemaG10->AddElement(O, natoms = 2);
NemaG10->AddElement(C, natoms = 3);
NemaG10->AddElement(H, natoms = 3);
fVisAtts[NemaG10->GetName()] = new G4VisAttributes(G4Colour::Brown());
// Ar/CO2 Gas
G4Material *CO2 = new G4Material("CO2", density = fExtDensityRatio * 1.842e-3 * g / cm3, ncomponents = 2);
CO2->AddElement(C, natoms = 1);
CO2->AddElement(O, natoms = 2);
G4Material *ArCO2 = new G4Material("ArCO2", density = fExtDensityRatio * 1.715e-3 * g / cm3, ncomponents = 2);
ArCO2->AddElement(Ar, fractionmass = 0.7);
ArCO2->AddMaterial(CO2, fractionmass = 0.3);
fVisAtts[ArCO2->GetName()] = new G4VisAttributes(G4Colour::Yellow());
// He Gas
G4Material *HeGas = new G4Material("HeGas", density = fExtDensityRatio * 0.1786e-3 * g / cm3, ncomponents = 1);
HeGas->AddElement(He, natoms = 1);
fVisAtts[HeGas->GetName()] = new G4VisAttributes(G4Colour::Cyan());
// Scintillator EJ204
G4Material *EJ204 = new G4Material("EJ204", density = fExtDensityRatio * 1.032 * g / cm3, ncomponents = 2);
EJ204->AddElement(H, natoms = 521);
EJ204->AddElement(C, natoms = 474);
fVisAtts[EJ204->GetName()] = new G4VisAttributes(G4Colour::Green());
// Rohacell 31 IG
G4Material *Rohacell = new G4Material("Rohacell", density = fExtDensityRatio * 0.023 * g / cm3, ncomponents = 3);
Rohacell->AddElement(C, natoms = 5);
Rohacell->AddElement(H, natoms = 8);
Rohacell->AddElement(O, natoms = 2);
fVisAtts[Rohacell->GetName()] = new G4VisAttributes(G4Colour::Grey());
// Tungsten
G4Material *Tungsten = new G4Material("Tungsten", density = 19.25 * g / cm3, ncomponents = 1);
Tungsten->AddElement(W, natoms = 1);
fVisAtts[Tungsten->GetName()] = new G4VisAttributes(G4Colour::Black());
// Polyester (3M VM-2000 reflector)
G4Material *Polyester = new G4Material("Polyester", density = 1.37 * g / cm3, ncomponents = 3);
Polyester->AddElement(C, natoms = 10);
Polyester->AddElement(H, natoms = 8);
Polyester->AddElement(O, natoms = 4);
fVisAtts[Polyester->GetName()] = new G4VisAttributes(G4VisAttributes::Invisible);
// Brass
G4Material *Brass = new G4Material("Brass", density = 8.53 * g / cm3, ncomponents = 2);
Brass->AddElement(Cu, fractionmass = 0.7);
Brass->AddElement(Zn, fractionmass = 0.3);
fVisAtts[Brass->GetName()] = new G4VisAttributes(G4Color::Brown());
// PbWO4 Crystal
G4Material *PbWO4 = new G4Material("PbWO4", density = 8.280 * g / cm3, ncomponents = 3);
PbWO4->AddElement(Pb, natoms = 1);
PbWO4->AddElement(W, natoms = 1);
PbWO4->AddElement(O, natoms = 4);
fVisAtts[PbWO4->GetName()] = new G4VisAttributes(G4Colour::Blue());
// Silica
G4Material *SiO2 = new G4Material("SiO2", density = 2.200 * g / cm3, ncomponents = 2);
SiO2->AddElement(Si, natoms = 1);
SiO2->AddElement(O, natoms = 2);
fVisAtts[SiO2->GetName()] = new G4VisAttributes(G4Colour::Green());
// Lead Glass
G4Material *PbO = new G4Material("PbO", density = 9.530 * g / cm3, ncomponents = 2);
PbO->AddElement(Pb, natoms = 1);
PbO->AddElement(O, natoms = 1);
G4Material *K2O = new G4Material("K2O", density = 2.320 * g / cm3, ncomponents = 2);
K2O->AddElement(K, natoms = 2);
K2O->AddElement(O, natoms = 1);
G4Material *Na2O = new G4Material("Na2O", density = 2.270 * g / cm3, ncomponents = 2);
Na2O->AddElement(Na, natoms = 2);
Na2O->AddElement(O, natoms = 1);
G4Material *As2O3 = new G4Material("As2O3", density = 3.738 * g / cm3, ncomponents = 2);
As2O3->AddElement(As, natoms = 2);
As2O3->AddElement(O, natoms = 3);
G4Material *PbGlass = new G4Material("PbGlass", density = 3.86 * g / cm3, ncomponents = 5);
PbGlass->AddMaterial(PbO, fractionmass = 0.5080);
PbGlass->AddMaterial(SiO2, fractionmass = 0.4170);
PbGlass->AddMaterial(K2O, fractionmass = 0.0422);
PbGlass->AddMaterial(Na2O, fractionmass = 0.0278);
PbGlass->AddMaterial(As2O3, fractionmass = 0.0050);
fVisAtts[PbGlass->GetName()] = new G4VisAttributes(G4Colour::Blue());
// Virtual Detector Material
G4Material *VirtualDetM = new G4Material("VirtualDetM", density = universe_mean_density, ncomponents = 1, kStateGas, 0.1 * kelvin, 1.0e-19 * pascal);
VirtualDetM->AddElement(H, fractionmass = 1.0);
fVisAtts[VirtualDetM->GetName()] = new G4VisAttributes(G4Colour::Cyan());
// Print out material table
G4cout << *(G4Material::GetMaterialTable()) << G4endl;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4VPhysicalVolume *DetectorConstruction::DefinePRadVolumes()
{
G4Material *DefaultM = G4Material::GetMaterial("Galaxy");
G4Material *TargetM = G4Material::GetMaterial("H2Gas");
G4Material *TargetCellM = G4Material::GetMaterial("Copper");
G4Material *TargetWindowM = G4Material::GetMaterial("Kapton");
G4Material *UCollimatorM = G4Material::GetMaterial("Nickel");
G4Material *VacuumTubeM = G4Material::GetMaterial("SSteel");
G4Material *VirtualDetM = G4Material::GetMaterial("VirtualDetM");
// World
G4VSolid *solidWorld = new G4Box("WorldS", fWorldSizeXY, fWorldSizeXY, fWorldSizeZ);
G4LogicalVolume *logicWorld = new G4LogicalVolume(solidWorld, DefaultM, "WorldLV");
G4VPhysicalVolume *physiWorld = new G4PVPlacement(0, G4ThreeVector(0, 0, 0), logicWorld, "World", 0, false, 0);
// Target
// Target Container
G4VSolid *solidTargetCon = new G4Box("TargetContainerS", 3.5 * cm, 3.5 * cm, 2.1 * cm);
G4LogicalVolume *logicTargetCon = new G4LogicalVolume(solidTargetCon, DefaultM, "TargetContainerLV");
new G4PVPlacement(0, G4ThreeVector(0, 0, fTargetCenter), logicTargetCon, "Target Container", logicWorld, false, 0);
// Target material
G4double TargetR = 25.0 * mm;
G4double TargetHalfL = 20.0 * mm;
G4VSolid *solidTarget = new G4Tubs("TargetS", 0, TargetR, TargetHalfL, 0, twopi);
G4LogicalVolume *logicTarget = new G4LogicalVolume(solidTarget, TargetM, "TargetLV");
new G4PVPlacement(0, G4ThreeVector(0, 0, 0), logicTarget, "Target Material", logicTargetCon, false, 0);
// Target cell
G4double CellXY = 3.5 * cm;
G4Box *CellBox = new G4Box("CellBox", CellXY, CellXY, TargetHalfL);
G4Tubs *CellTube = new G4Tubs("CellTube", 0, TargetR, TargetHalfL + 1.0 * mm, 0, twopi);
G4SubtractionSolid *solidCell = new G4SubtractionSolid("TargetCellS", CellBox, CellTube);
G4LogicalVolume *logicCell = new G4LogicalVolume(solidCell, TargetCellM, "TargetCellLV");
new G4PVPlacement(0, G4ThreeVector(0, 0, 0), logicCell, "Target Cell", logicTargetCon, false, 0);
// Target cell windows
G4double CellApertureR = 2.0 * mm;
G4double CellWinThickness = 7.5 * um;
G4Box *CellWinBox = new G4Box("CellWinBox", CellXY, CellXY, CellWinThickness / 2.0);
G4Tubs *CellWinTube = new G4Tubs("CellWinTube", 0, CellApertureR, CellWinThickness + 1.0 * mm, 0, twopi);
G4SubtractionSolid *solidCellWin = new G4SubtractionSolid("TargetWindowS", CellWinBox, CellWinTube);
G4LogicalVolume *logicCellWin = new G4LogicalVolume(solidCellWin, TargetWindowM, "TargetWindowLV");
new G4PVPlacement(0, G4ThreeVector(0, 0, -TargetHalfL - CellWinThickness / 2.0), logicCellWin, "Target Window", logicTargetCon, false, 0);
new G4PVPlacement(0, G4ThreeVector(0, 0, +TargetHalfL + CellWinThickness / 2.0), logicCellWin, "Target Window", logicTargetCon, false, 1);
// Upstream collimator
// Dimension from PRad beam line drawing (search PRad in JLab drawing database)
G4double UCollimatorHalfL = 11.8 * 2.54 / 2.0 * cm;
G4double UCollimatorOR = 3.9 * 2.54 / 2.0 * cm;
G4double UCollimatorIR = 12.7 * mm / 2.0;
G4double UCollimatorCenter = fTargetCenter - 2.03 * m + UCollimatorHalfL;
G4VSolid *solidUCollimator = new G4Tubs("UCollimatorS", UCollimatorIR, UCollimatorOR, UCollimatorHalfL, 0, twopi);
G4LogicalVolume *logicUCollimator = new G4LogicalVolume(solidUCollimator, UCollimatorM, "UCollimatorLV");
new G4PVPlacement(0, G4ThreeVector(0, 0, UCollimatorCenter), logicUCollimator, "Upstream Collimator", logicWorld, false, 0);
// Upstream beam pipe
// Dimension from PRad target drawings and PRad beam line drawings
G4double UBeamPipeIR = 1.87 * 2.54 / 2.0 * cm;
G4double UBeamPipeOR = 2.0 * 2.54 / 2.0 * cm;
G4double UBeamPipeHalfL = 0.79 * m;
G4double UBeamPipeOffset = 0.105 * m;
G4double UBeamPipeCenter = fTargetCenter - UBeamPipeOffset - UBeamPipeHalfL - 4 * cm; // subtract 4cm for target length
G4VSolid *solidUBeamPipe = new G4Tubs("UBeamPipeS", UBeamPipeIR, UBeamPipeOR, UBeamPipeHalfL, 0, 2 * pi);
G4LogicalVolume *logicUBeamPipe = new G4LogicalVolume(solidUBeamPipe, VacuumTubeM, "UBeamPipeLV");
new G4PVPlacement(0, G4ThreeVector(0, 0, UBeamPipeCenter), logicUBeamPipe, "Upstream Beam Pipe", logicWorld, false, 0);
AddVaccumBox(logicWorld);
// Center of two GEM should be at -3000.0 + 89.0 + (5226.16 + 5186.45) / 2 + 4.6525 = 2299.9575 mm // (5226.16 + 5186.45) / 2 from Weizhi
fGEMCenter[0] = 229.99575 * cm;
AddGEM(logicWorld, 0, false);
// The crystal surface should be at -3000.0 + 89.0 + 5646.15 = 2735.15 mm // 5646.15 from Weizhi
fCrystalSurf = 273.515 * cm; // Surface of the PWO
AddHyCal(logicWorld);
// Virtual Detector
G4double VirtualDetR = 50.0 * cm;
G4double VirtualDetZ = 0.1 * mm;
G4VSolid *solidVirtualDet = new G4Tubs("VirtualDetS", 0, VirtualDetR, VirtualDetZ / 2.0, 0, twopi);
G4LogicalVolume *logicVirtualDet = new G4LogicalVolume(solidVirtualDet, VirtualDetM, "VirtualDetLV");
new G4PVPlacement(0, G4ThreeVector(0, 0, fTargetCenter + 60 * mm), logicVirtualDet, "Virtual Detector", logicWorld, false, 0);
G4LogicalVolumeStore *pLogicalVolume = G4LogicalVolumeStore::GetInstance();
for (unsigned long i = 0; i < pLogicalVolume->size(); i++)
(*pLogicalVolume)[i]->SetVisAttributes(fVisAtts[(*pLogicalVolume)[i]->GetMaterial()->GetName()]);
// Always return the physical World
return physiWorld;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void DetectorConstruction::DefinePRadSDs()
{
if (fTargetSDOn) {
CheckScatteringSD *TargetSD = new CheckScatteringSD("TargetSD", "TG");
G4SDManager::GetSDMpointer()->AddNewDetector(TargetSD);
SetSensitiveDetector("TargetLV", TargetSD);
}
if (fGEMSDOn) {
TrackingDetectorSD *GEMSD = new TrackingDetectorSD("GEMSD", "GEM");
G4SDManager::GetSDMpointer()->AddNewDetector(GEMSD);
SetSensitiveDetector("GEM0CathodeLV", GEMSD);
}
if (fHyCalSDOn) {
CalorimeterSD *HyCalSD = new CalorimeterSD("HyCalSD", "HC", "database/pwo_attenuation.dat");
HyCalSD->SetAttenuationLG(fAttenuationLG);
G4SDManager::GetSDMpointer()->AddNewDetector(HyCalSD);
for (int i = 0; i < 1152; i++)
SetSensitiveDetector(Form("PbWO4Absorber%04dLV", i), HyCalSD);
for (int i = 0; i < 576; i++)
SetSensitiveDetector(Form("PbGlassAbsorber%04dLV", i), HyCalSD);
}
if (fVirtualSDOn) {
StandardDetectorSD *VirtualSD = new StandardDetectorSD("VirtualSD", "VD");
G4SDManager::GetSDMpointer()->AddNewDetector(VirtualSD);
SetSensitiveDetector("VirtualDetLV", VirtualSD);
}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4VPhysicalVolume *DetectorConstruction::DefineDRadVolumes()
{
G4Material *DefaultM = G4Material::GetMaterial("Galaxy");
G4Material *TargetM = G4Material::GetMaterial("D2Gas");
if (fTargetMat == "H2Gas" || fTargetMat == "hydrogen")
TargetM = G4Material::GetMaterial("H2Gas");
G4Material *TargetCellM = G4Material::GetMaterial("Kapton");
G4Material *TargetWindowM = G4Material::GetMaterial("Kapton");
G4Material *RecoilDetectorM = G4Material::GetMaterial("Silicon");
G4Material *RecoilDetCoverM = G4Material::GetMaterial("SiO2");
G4Material *HeBagM = G4Material::GetMaterial("HeGas");
G4Material *ScintillatorPlaneM = G4Material::GetMaterial("EJ204");
// World
G4VSolid *solidWorld = new G4Box("WorldS", fWorldSizeXY, fWorldSizeXY, fWorldSizeZ);
G4LogicalVolume *logicWorld = new G4LogicalVolume(solidWorld, DefaultM, "WorldLV");
G4VPhysicalVolume *physiWorld = new G4PVPlacement(0, G4ThreeVector(0, 0, 0), logicWorld, "World", 0, false, 0);
// Target
G4double CellXY = 15.0 * cm;
// Target Container
G4VSolid *solidTargetCon = new G4Box("TargetContainerS", CellXY + 0.1 * cm, CellXY + 0.1 * cm, fTargetHalfL + 0.1 * cm);
G4LogicalVolume *logicTargetCon = new G4LogicalVolume(solidTargetCon, DefaultM, "TargetContainerLV");
new G4PVPlacement(0, G4ThreeVector(0, 0, fTargetCenter), logicTargetCon, "Target Container", logicWorld, false, 0);
// Target material
G4VSolid *solidTarget = new G4Tubs("TargetS", 0, fTargetR, fTargetHalfL, 0, twopi);
G4LogicalVolume *logicTarget = new G4LogicalVolume(solidTarget, TargetM, "TargetLV");
new G4PVPlacement(0, G4ThreeVector(0, 0, 0), logicTarget, "Target Material", logicTargetCon, false, 0);
// Target cell
G4Box *CellBox = new G4Box("CellBox", CellXY, CellXY, fTargetHalfL);
G4Tubs *CellTube = new G4Tubs("CellTube", 0, fTargetR, fTargetHalfL + 1.0 * mm, 0, twopi);
G4SubtractionSolid *solidCell = new G4SubtractionSolid("TargetCellS", CellBox, CellTube);
G4LogicalVolume *logicCell = new G4LogicalVolume(solidCell, TargetCellM, "TargetCellLV");
new G4PVPlacement(0, G4ThreeVector(0, 0, 0), logicCell, "Target Cell", logicTargetCon, false, 0);
// Target cell windows
G4double CellApertureR = 2.0 * mm;
G4double CellWinThickness = 7.5 * um;
G4Box *CellWinBox = new G4Box("CellWinBox", CellXY, CellXY, CellWinThickness / 2.0);
G4Tubs *CellWinTube = new G4Tubs("CellWinTube", 0, CellApertureR, CellWinThickness + 1.0 * mm, 0, twopi);
G4SubtractionSolid *solidCellWin = new G4SubtractionSolid("TargetWindowS", CellWinBox, CellWinTube);
G4LogicalVolume *logicCellWin = new G4LogicalVolume(solidCellWin, TargetWindowM, "TargetWindowLV");
new G4PVPlacement(0, G4ThreeVector(0, 0, -fTargetHalfL - CellWinThickness / 2.0), logicCellWin, "Target Window", logicTargetCon, false, 0);
new G4PVPlacement(0, G4ThreeVector(0, 0, +fTargetHalfL + CellWinThickness / 2.0), logicCellWin, "Target Window", logicTargetCon, false, 1);
// Recoil detector
G4double RecoilDetCenter = fRecoilDetCenter - fTargetCenter;
G4double CoverThickness = 0.5 * um;
G4double RecoilDetAng = twopi / fRecoilDetNSeg;
G4double RecoilDetL2OR = fRecoilDetR * cos(RecoilDetAng / 2.0);
G4double RecoilDetL2IRC = RecoilDetL2OR - fRecoilDetL2Thickness + CoverThickness;
G4double RecoilDetL2IR = RecoilDetL2OR - fRecoilDetL2Thickness;
G4double RecoilDetL1OR = RecoilDetL2IR;
G4double RecoilDetL1IRC = RecoilDetL1OR - fRecoilDetL1Thickness + CoverThickness;
G4double RecoilDetL1IR = RecoilDetL1OR - fRecoilDetL1Thickness;
G4double rInnerRDL2[] = {RecoilDetL2IRC, RecoilDetL2IRC};
G4double rOuterRDL2[] = {RecoilDetL2OR, RecoilDetL2OR};
G4double zPlaneRDL2[] = {-fRecoilDetHalfL, fRecoilDetHalfL};
G4VSolid *solidRecoilDet2 = new G4Polyhedra("RecoilDet2S", 0, twopi, fRecoilDetNSeg, 2, zPlaneRDL2, rInnerRDL2, rOuterRDL2);
G4double rInnerRDL2Cover[] = {RecoilDetL2IR, RecoilDetL2IR};
G4double rOuterRDL2Cover[] = {RecoilDetL2IRC, RecoilDetL2IRC};
G4double zPlaneRDL2Cover[] = {-fRecoilDetHalfL, fRecoilDetHalfL};
G4VSolid *solidRecoilDet2Cover = new G4Polyhedra("RecoilDet2CoverS", 0, twopi, fRecoilDetNSeg, 2, zPlaneRDL2Cover, rInnerRDL2Cover, rOuterRDL2Cover);
G4double rInnerRDL1[] = {RecoilDetL1IRC, RecoilDetL1IRC};
G4double rOuterRDL1[] = {RecoilDetL1OR, RecoilDetL1OR};
G4double zPlaneRDL1[] = {-fRecoilDetHalfL, fRecoilDetHalfL};
G4VSolid *solidRecoilDet1 = new G4Polyhedra("RecoilDet1S", 0, twopi, fRecoilDetNSeg, 2, zPlaneRDL1, rInnerRDL1, rOuterRDL1);
G4double rInnerRDL1Cover[] = {RecoilDetL1IR, RecoilDetL1IR};
G4double rOuterRDL1Cover[] = {RecoilDetL1IRC, RecoilDetL1IRC};
G4double zPlaneRDL1Cover[] = {-fRecoilDetHalfL, fRecoilDetHalfL};
G4VSolid *solidRecoilDet1Cover = new G4Polyhedra("RecoilDet1CoverS", 0, twopi, fRecoilDetNSeg, 2, zPlaneRDL1Cover, rInnerRDL1Cover, rOuterRDL1Cover);
G4LogicalVolume *logicRecoilDet1 = new G4LogicalVolume(solidRecoilDet1, RecoilDetectorM, "RecoilDet1LV");
G4LogicalVolume *logicRecoilDet1Cover = new G4LogicalVolume(solidRecoilDet1Cover, RecoilDetCoverM, "RecoilDet1CoverLV");
G4LogicalVolume *logicRecoilDet2 = new G4LogicalVolume(solidRecoilDet2, RecoilDetectorM, "RecoilDet2LV");
G4LogicalVolume *logicRecoilDet2Cover = new G4LogicalVolume(solidRecoilDet2Cover, RecoilDetCoverM, "RecoilDet2CoverLV");
new G4PVPlacement(0, G4ThreeVector(0, 0, RecoilDetCenter), logicRecoilDet1Cover, "Recoil Detector 1 Cover", logicTarget, false, 0);
new G4PVPlacement(0, G4ThreeVector(0, 0, RecoilDetCenter), logicRecoilDet1, "Recoil Detector 1", logicTarget, false, 0);
new G4PVPlacement(0, G4ThreeVector(0, 0, RecoilDetCenter), logicRecoilDet2Cover, "Recoil Detector 2 Cover", logicTarget, false, 1);
new G4PVPlacement(0, G4ThreeVector(0, 0, RecoilDetCenter), logicRecoilDet2, "Recoil Detector 2", logicTarget, false, 1);
AddVaccumBox(logicWorld);
AddGEM(logicWorld, 0, true);
AddGEM(logicWorld, 1, false);
// He bag (Only He gas for now)
G4Box *HeBagBox = new G4Box("HeBagBox", 1.0 * m, 1.0 * m, (fGEMCenter[1] - fGEMCenter[0] - 5.65 * cm) / 2.0);
G4Tubs *HeBagTube = new G4Tubs("HeBagTube", 0, 22.0 * mm, (fGEMCenter[1] - fGEMCenter[0] - 5.65 * cm + 1.0 * mm) / 2.0, 0, twopi);
G4SubtractionSolid *solidHeBag = new G4SubtractionSolid("HeBagS", HeBagBox, HeBagTube);
G4LogicalVolume *logicHeBag = new G4LogicalVolume(solidHeBag, HeBagM, "HeBagLV");
new G4PVPlacement(0, G4ThreeVector(0, 0, (fGEMCenter[0] + fGEMCenter[1]) / 2.0), logicHeBag, "He Bag", logicWorld, false, 0);
// Scintillator plane
G4double SciPlaneThickness = 5.0 * mm;
G4double SciPlaneHalfX = 75.0 * cm;
G4double SciPlaneHalfY = 75.0 * cm;
G4Box *SciPlaneBox = new G4Box("ScintillatorPlaneBox", SciPlaneHalfX, SciPlaneHalfY, SciPlaneThickness / 2.0);
G4Tubs *SciPlaneTube = new G4Tubs("ScintillatorPlaneTube", 0, 22.0 * mm, (SciPlaneThickness + 1.0 * mm) / 2.0, 0, twopi);
G4SubtractionSolid *solidSciPlane = new G4SubtractionSolid("ScintillatorPlaneS", SciPlaneBox, SciPlaneTube);
G4LogicalVolume *logicSciPlane = new G4LogicalVolume(solidSciPlane, ScintillatorPlaneM, "ScintillatorPlaneLV");
new G4PVPlacement(0, G4ThreeVector(0, 0, fSciPlaneCenter), logicSciPlane, "Scintillator Plane", logicWorld, false, 0);
AddHyCal(logicWorld);
G4LogicalVolumeStore *pLogicalVolume = G4LogicalVolumeStore::GetInstance();
for (unsigned long i = 0; i < pLogicalVolume->size(); i++)
(*pLogicalVolume)[i]->SetVisAttributes(fVisAtts[(*pLogicalVolume)[i]->GetMaterial()->GetName()]);
// Always return the physical World
return physiWorld;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void DetectorConstruction::DefineDRadSDs()
{
if (fRecoilDetSDOn) {
TrackingDetectorSD *RecoilDetSD = new TrackingDetectorSD("RecoilDetectorSD", "RD");
G4SDManager::GetSDMpointer()->AddNewDetector(RecoilDetSD);
SetSensitiveDetector("RecoilDet1LV", RecoilDetSD);
SetSensitiveDetector("RecoilDet2LV", RecoilDetSD);
}
if (fGEMSDOn) {
TrackingDetectorSD *GEMSD = new TrackingDetectorSD("GEMSD", "GEM");
G4SDManager::GetSDMpointer()->AddNewDetector(GEMSD);
SetSensitiveDetector("GEM0CathodeLV", GEMSD);
SetSensitiveDetector("GEM1CathodeLV", GEMSD);
}
if (fSciPlaneSDOn) {
StandardDetectorSD *SciPlaneSD = new StandardDetectorSD("ScintillatorPlaneSD", "SP");
G4SDManager::GetSDMpointer()->AddNewDetector(SciPlaneSD);
SetSensitiveDetector("ScintillatorPlaneLV", SciPlaneSD);
}
if (fHyCalSDOn) {
CalorimeterSD *HyCalSD = new CalorimeterSD("HyCalSD", "HC", "database/pwo_attenuation.dat");
HyCalSD->SetAttenuationLG(fAttenuationLG);
G4SDManager::GetSDMpointer()->AddNewDetector(HyCalSD);
for (int i = 0; i < 1152; i++)
SetSensitiveDetector(Form("PbWO4Absorber%04dLV", i), HyCalSD);
for (int i = 0; i < 576; i++)
SetSensitiveDetector(Form("PbGlassAbsorber%04dLV", i), HyCalSD);
}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4VPhysicalVolume *DetectorConstruction::DefineTestVolumes()
{
G4Material *DefaultM = G4Material::GetMaterial("Galaxy");
G4Material *TargetM = G4Material::GetMaterial("H2Gas");
G4Material *TargetCellM = G4Material::GetMaterial("Copper");
G4Material *TargetWindowM = G4Material::GetMaterial("Kapton");
G4Material *VirtualDetM = G4Material::GetMaterial("VirtualDetM");
// World
G4double WorldSizeXY = 10.0 * cm;
G4double WorldSizeZ = 100.0 * cm;
G4VSolid *solidWorld = new G4Box("WorldS", WorldSizeXY, WorldSizeXY, WorldSizeZ);
G4LogicalVolume *logicWorld = new G4LogicalVolume(solidWorld, DefaultM, "WorldLV");
G4VPhysicalVolume *physiWorld = new G4PVPlacement(0, G4ThreeVector(0, 0, 0), logicWorld, "World", 0, false, 0);
// Target
// Target Container
G4VSolid *solidTargetCon = new G4Box("TargetContainerS", 3.5 * cm, 3.5 * cm, 2.1 * cm);
G4LogicalVolume *logicTargetCon = new G4LogicalVolume(solidTargetCon, DefaultM, "TargetContainerLV");
new G4PVPlacement(0, G4ThreeVector(0, 0, 0), logicTargetCon, "Target Container", logicWorld, false, 0);
// Target material
G4double TargetR = 25.0 * mm;
G4double TargetHalfL = 20.0 * mm;
G4VSolid *solidTarget = new G4Tubs("TargetS", 0, TargetR, TargetHalfL, 0, twopi);
G4LogicalVolume *logicTarget = new G4LogicalVolume(solidTarget, TargetM, "TargetLV");
new G4PVPlacement(0, G4ThreeVector(0, 0, 0), logicTarget, "Target Material", logicTargetCon, false, 0);
//logicTarget->SetUserLimits(new G4UserLimits(0.5 * mm));
// Target cell
G4double CellXY = 3.5 * cm;
G4Box *CellBox = new G4Box("CellBox", CellXY, CellXY, TargetHalfL);
G4Tubs *CellTube = new G4Tubs("CellTube", 0, TargetR, TargetHalfL + 1.0 * mm, 0, twopi);
G4SubtractionSolid *solidCell = new G4SubtractionSolid("TargetCellS", CellBox, CellTube);
G4LogicalVolume *logicCell = new G4LogicalVolume(solidCell, TargetCellM, "TargetCellLV");
new G4PVPlacement(0, G4ThreeVector(0, 0, 0), logicCell, "Target Cell", logicTargetCon, false, 0);
// Target cell windows
G4double CellApertureR = 2.0 * mm;
G4double CellWinThickness = 7.5 * um;
G4Box *CellWinBox = new G4Box("CellWinBox", CellXY, CellXY, CellWinThickness / 2.0);
G4Tubs *CellWinTube = new G4Tubs("CellWinTube", 0, CellApertureR, CellWinThickness + 1.0 * mm, 0, twopi);
G4SubtractionSolid *solidCellWin = new G4SubtractionSolid("TargetWindowS", CellWinBox, CellWinTube);
G4LogicalVolume *logicCellWin = new G4LogicalVolume(solidCellWin, TargetWindowM, "TargetWindowLV");
new G4PVPlacement(0, G4ThreeVector(0, 0, -TargetHalfL - CellWinThickness / 2.0), logicCellWin, "Target Window", logicTargetCon, false, 0);
new G4PVPlacement(0, G4ThreeVector(0, 0, +TargetHalfL + CellWinThickness / 2.0), logicCellWin, "Target Window", logicTargetCon, false, 1);
// Virtual Detector
G4double VirtualDetZ = 0.1 * mm;
G4double VirtualDetL = 99.0 * cm;
G4double VirtualDetIR = (VirtualDetL - 20.0 * mm) * tan(0.5 / 180.0 * pi);
G4double VirtualDetOR = (VirtualDetL + 20.0 * mm) * tan(10.0 / 180.0 * pi);
G4VSolid *solidVirtualDet = new G4Tubs("VirtualDetS", VirtualDetIR, VirtualDetOR, VirtualDetZ, 0, twopi);
G4LogicalVolume *logicVirtualDet = new G4LogicalVolume(solidVirtualDet, VirtualDetM, "VirtualDetLV");
new G4PVPlacement(0, G4ThreeVector(0, 0, VirtualDetL), logicVirtualDet, "Virtual Detector", logicWorld, false, 0);
G4LogicalVolumeStore *pLogicalVolume = G4LogicalVolumeStore::GetInstance();
for (unsigned long i = 0; i < pLogicalVolume->size(); i++)
(*pLogicalVolume)[i]->SetVisAttributes(fVisAtts[(*pLogicalVolume)[i]->GetMaterial()->GetName()]);
return physiWorld;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void DetectorConstruction::DefineTestSDs()
{
StepRecordSD *TargetSD = new StepRecordSD("TargetSD", "TG");
G4SDManager::GetSDMpointer()->AddNewDetector(TargetSD);
SetSensitiveDetector("TargetLV", TargetSD);
StandardDetectorSD *VirtualSD = new StandardDetectorSD("VirtualSD", "VD");
G4SDManager::GetSDMpointer()->AddNewDetector(VirtualSD);
SetSensitiveDetector("VirtualDetLV", VirtualSD);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void DetectorConstruction::AddVaccumBox(G4LogicalVolume *mother)
{
G4Material *ChamberM = G4Material::GetMaterial("Aluminum");
G4Material *ChamberWindowM = G4Material::GetMaterial("Kapton");
G4Material *VacuumBoxM = G4Material::GetMaterial("Aluminum");
G4Material *VacuumTubeM = G4Material::GetMaterial("SSteel");
// Target chamber
// For now, only built the downstream chamber with window
// The downstream chamber window should locate at -3000.0 + 89.0 + 74.0 = -2837.0 mm
// The length of the downstream chamber is 381.7 mm
// The total length of the downstream chamber and the tube in total is 710.0 mm
// Here the downstream chamber and the tube are built together to be the new downstream chamber.
// So the center of this geometry should be at -2837.0 + 710.0 / 2 = -2482.0 mm
fDownChamberCenter = fTargetCenter + 74.0 * mm + 71.0 * cm / 2.0;
G4double DownChamberHalfL = 71.0 / 2.0 * cm;
G4double DownChamberUR = 8.00 * cm;
// Downstream chamber
G4double rInnerDC[] = {7.56 * cm, 7.56 * cm, 7.56 * cm, 7.56 * cm, 17.30 * cm, 17.30 * cm};
G4double rOuterDC[] = {8.00 * cm, 8.00 * cm, 17.78 * cm, 17.78 * cm, 17.78 * cm, 17.78 * cm};
G4double zPlaneDC[] = {0, 32.83 * cm, 32.83 * cm, 35.37 * cm, 35.37 * cm, 71.00 * cm};
G4VSolid *solidDownChamber = new G4Polycone("DownstreamChamberS", 0, twopi, 6, zPlaneDC, rInnerDC, rOuterDC);
G4LogicalVolume *logicDownChamber = new G4LogicalVolume(solidDownChamber, ChamberM, "DownstreamChamberLV");
new G4PVPlacement(0, G4ThreeVector(0, 0, fDownChamberCenter - DownChamberHalfL), logicDownChamber, "Downstream Chamber", mother, false, 0);
// Downstream chamber window
G4double DownChamberApertureR = 22.8 * mm;
G4double DownChamberWinThickness = 7.5 * um;
G4Tubs *solidDownChamberWin = new G4Tubs("DownstreamChamberWindowS", DownChamberApertureR, DownChamberUR, DownChamberWinThickness / 2.0, 0, twopi);
G4LogicalVolume *logicDownChamberWin = new G4LogicalVolume(solidDownChamberWin, ChamberWindowM, "DownstreamChamberWindowLV");
new G4PVPlacement(0, G4ThreeVector(0, 0, fDownChamberCenter - DownChamberHalfL - DownChamberWinThickness / 2.0), logicDownChamberWin, "Downstream Chamber Window", mother, false, 0);
// Vacuum box
// The length of the vacuum box is 4251.7 mm
// So the center of this geometry should be at -3000.0 + 89.0 + 74.0 + 710.0 + 2125.85 = -1.15 mm
fVacBoxCenter = fTargetCenter + 74.0 * mm + 71.0 * cm + 425.17 * cm / 2.0;
G4double VacBoxHalfL = 425.17 * cm / 2.0;
G4double VacBoxMaxR = 78.11 * cm;
G4double rInner2[] = {17.30 * cm, 17.30 * cm, 50.17 * cm, 50.17 * cm, 78.11 * cm, 78.11 * cm};
G4double rOuter2[] = {17.78 * cm, 17.78 * cm, 50.80 * cm, 50.80 * cm, 78.74 * cm, 78.74 * cm};
G4double zPlane2[] = {0, 6.8 * cm, 17.6 * cm, 215.3 * cm, 229.5 * cm, 425.17 * cm};
G4VSolid *solidVacBox = new G4Polycone("VacuumBoxS", 0, twopi, 6, zPlane2, rInner2, rOuter2);
G4LogicalVolume *logicVacBox = new G4LogicalVolume(solidVacBox, VacuumBoxM, "VacuumBoxLV");
new G4PVPlacement(0, G4ThreeVector(0, 0, fVacBoxCenter - VacBoxHalfL), logicVacBox, "Vacuum Box", mother, false, 0);
// Vacuum box window
G4double VacBoxWinFlangeOffset = 3.81 * cm;
G4double ArcDistance = 5.59 * cm;
G4double ArcEndR = (ArcDistance * ArcDistance + VacBoxMaxR * VacBoxMaxR) / (2 * ArcDistance);
G4double ArcEndThickness = 1.6 * mm;
G4double VacBoxWinApertureR = 3.0 * cm;
G4VSolid *solidVacBoxWin = new G4Sphere("VacuumBoxWindowS", ArcEndR - ArcEndThickness, ArcEndR, 0, twopi, pi - asin(VacBoxMaxR / ArcEndR), asin(VacBoxMaxR / ArcEndR) - asin((VacBoxWinApertureR + 0.1 * mm) / ArcEndR));
G4LogicalVolume *logicVacBoxWin = new G4LogicalVolume(solidVacBoxWin, VacuumBoxM, "VacuumBoxWindowLV");
new G4PVPlacement(0, G4ThreeVector(0, 0, fVacBoxCenter + VacBoxHalfL + ArcEndR - ArcDistance - VacBoxWinFlangeOffset), logicVacBoxWin, "Vacuum Box Window", mother, false, 0);
// Vacuum Tube
G4double VacTubeOR = 1.9 * cm;
G4double VacTubeIR = VacTubeOR - 0.12446 * cm; // 0.049 in = 0.12446 cm from Eugene
G4double VacTubeL = fWorldSizeZ - 10.0 * cm - fVacBoxCenter - VacBoxHalfL + ArcDistance;
G4VSolid *solidVacTube = new G4Tubs("VacuumTubeS", VacTubeIR, VacTubeOR, VacTubeL / 2.0, 0, twopi);
G4LogicalVolume *logicVacTube = new G4LogicalVolume(solidVacTube, VacuumTubeM, "VacuumTubeLV");
new G4PVPlacement(0, G4ThreeVector(0, 0, fWorldSizeZ - 10.0 * cm - VacTubeL / 2.0), logicVacTube, "Vacuum Tube", mother, false, 0);
// Flange on vacuum tube
G4double FlangeOR = VacBoxWinApertureR;
G4double FlangeIR = VacTubeOR;
G4double FlangeHalfL = 0.5 * cm;
G4VSolid *solidFlange = new G4Tubs("FlangeS", FlangeIR, FlangeOR, FlangeHalfL, 0, twopi);
G4LogicalVolume *logicFlange = new G4LogicalVolume(solidFlange, VacuumTubeM, "FlangeLV");
new G4PVPlacement(0, G4ThreeVector(0, 0, fVacBoxCenter + VacBoxHalfL - ArcDistance + FlangeHalfL), logicFlange, "Flange", mother, false, 0);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void DetectorConstruction::AddGEM(G4LogicalVolume *mother, int layerid, bool culess)
{
G4Material *DefaultM = G4Material::GetMaterial("Galaxy");
G4Material *GEMFrameM = G4Material::GetMaterial("NemaG10");
G4Material *GEMGasM = G4Material::GetMaterial("ArCO2");
G4Material *GEMFoilM = G4Material::GetMaterial("Kapton");
G4Material *GEMFoil0d2M = G4Material::GetMaterial("Kapton0.2");
G4Material *GEMFoil0d8M = G4Material::GetMaterial("Kapton0.8");
G4Material *GEMCuM = G4Material::GetMaterial("Copper");
G4Material *GEMCu0d2M = G4Material::GetMaterial("Copper0.2");
G4Material *GEMCu0d75M = G4Material::GetMaterial("Copper0.75");
G4Material *GEMCu0d8M = G4Material::GetMaterial("Copper0.8");
G4Material *GEMGlueM = G4Material::GetMaterial("Kapton"); // TODO: Add actual Glue material
// GEM
G4double GEMCenter = fGEMCenter[layerid];
G4double GEMGap = 3.971 * cm; // Gap between two GEM // 3.971 from Weizhi
G4double GEMHalfX = 55.04 * cm / 2.0;
G4double GEMHalfY = 122.88 * cm / 2.0;
G4double GEMHalfT = (15.0 * mm + 455.0 * um) / 2.0; // 2 * 25 + 5 + 50 (win) + 6 * 5 + 3 * 50 (foil) + 5 + 5 + 50 + 50 + 60 (readout)
if (culess) GEMHalfT = (15.0 * mm + 410.0 * um) / 2.0; // 2 * 25 + 50 (win) + 3 * 50 (foil) + 50 + 50 + 60 (readout)
G4double GEMSpacerWh = 0.3 * mm / 2.0;
G4double GEMSpacerWv = 0.5 * mm / 2.0;
G4double GEMSpacerT = (2.0 - 0.1) * mm;
G4double GEMHoleR = 2.2 * cm;
G4double GEMCenterHalfXY = 7.4 * cm / 2.0;
G4double GEMFrameWidth = 1.5 * cm;
G4double GEMCenterOffset = GEMHalfX + GEMFrameWidth - GEMCenterHalfXY;
// GEM Container
G4Box *GEMConBox = new G4Box(Form("GEM%dConBox", layerid), 1.0 * m, 1.0 * m, (GEMGap + 2.0 * GEMHalfT + 1.0 * mm) / 2.0);
G4Tubs *GEMConTube = new G4Tubs(Form("GEM%dConTube", layerid), 0, GEMHoleR, (GEMGap + 2.0 * GEMHalfT + 1.0 * mm) / 2.0 + 0.1 * mm, 0, twopi);
G4SubtractionSolid *solidGEMCon = new G4SubtractionSolid(Form("GEM%dContainerS", layerid), GEMConBox, GEMConTube);
G4LogicalVolume *logicGEMCon = new G4LogicalVolume(solidGEMCon, DefaultM, Form("GEM%dContainerLV", layerid));
new G4PVPlacement(0, G4ThreeVector(0, 0, GEMCenter), logicGEMCon, Form("GEM %d Container", layerid), mother, false, 2 * layerid);
// GEM
G4Box *GEMBox = new G4Box(Form("GEM%dBox", layerid), GEMHalfX + GEMFrameWidth, GEMHalfY + GEMFrameWidth * 2.0, GEMHalfT);
G4Tubs *GEMTube = new G4Tubs(Form("GEM%dTube", layerid), 0, GEMHoleR, GEMHalfT + 0.1 * mm, 0, twopi);
G4SubtractionSolid *solidGEM = new G4SubtractionSolid(Form("GEM%dS", layerid), GEMBox, GEMTube, 0, G4ThreeVector(-GEMCenterOffset, 0, 0));
G4LogicalVolume *logicGEM = new G4LogicalVolume(solidGEM, DefaultM, Form("GEM%dLV", layerid));
new G4PVPlacement(0, G4ThreeVector(GEMCenterOffset, 0, GEMGap / 2.0), logicGEM, Form("GEM %d L", layerid), logicGEMCon, false, 0);
G4RotationMatrix rmGEM;
rmGEM.rotateZ(180.0 * deg);
new G4PVPlacement(G4Transform3D(rmGEM, G4ThreeVector(-GEMCenterOffset, 0, -GEMGap / 2.0)), logicGEM, Form("GEM %d R", layerid), logicGEMCon, false, 1);
// GEM Gas
G4Box *GEMGasBox = new G4Box(Form("GEM%dGasBox", layerid), GEMHalfX, GEMHalfY, GEMHalfT);
G4Box *GEMSubBox = new G4Box(Form("GEM%dSubBox", layerid), GEMCenterHalfXY, GEMCenterHalfXY, GEMHalfT + 0.1 * mm);
G4SubtractionSolid *solidGEMGas = new G4SubtractionSolid(Form("GEM%dGasS", layerid), GEMGasBox, GEMSubBox, 0, G4ThreeVector(-GEMCenterOffset, 0, 0));
G4LogicalVolume *logicGEMGas = new G4LogicalVolume(solidGEMGas, GEMGasM, Form("GEM%dGasLV", layerid));
new G4PVPlacement(0, G4ThreeVector(0, 0, 0), logicGEMGas, Form("GEM %d Gas", layerid), logicGEM, false, 0);
// GEM Frame
G4Box *GEMFrameBox1 = new G4Box(Form("GEM%dFrameBox1", layerid), GEMHalfX + GEMFrameWidth, GEMHalfY + GEMFrameWidth * 2.0, GEMHalfT);
G4Box *GEMFrameBox2 = new G4Box(Form("GEM%dFrameBox2", layerid), GEMHalfX, GEMHalfY, GEMHalfT + 0.1 * mm);
G4SubtractionSolid *solidGEMFrame = new G4SubtractionSolid(Form("GEM%dFrameS", layerid), GEMFrameBox1, GEMFrameBox2);
G4LogicalVolume *logicGEMFrame = new G4LogicalVolume(solidGEMFrame, GEMFrameM, Form("GEM%dFrameLV", layerid));
new G4PVPlacement(0, G4ThreeVector(0, 0, 0), logicGEMFrame, Form("GEM %d Frame", layerid), logicGEM, false, 0);
G4Box *GEMPipeBox = new G4Box(Form("GEM%dPipeBox", layerid), GEMCenterHalfXY - GEMFrameWidth / 2.0, GEMCenterHalfXY, GEMHalfT);
G4SubtractionSolid *solidGEMPipe = new G4SubtractionSolid(Form("GEM%dPipeS", layerid), GEMPipeBox, GEMTube, 0, G4ThreeVector(-GEMFrameWidth / 2.0, 0, 0));
G4LogicalVolume *logicGEMPipe = new G4LogicalVolume(solidGEMPipe, GEMFrameM, Form("GEM%dPipeLV", layerid));
new G4PVPlacement(0, G4ThreeVector(-GEMCenterOffset + GEMFrameWidth / 2.0, 0, 0), logicGEMPipe, Form("GEM %d Pipe", layerid), logicGEM, false, 0);
// GEM Spacer
G4double GEMSpacerOffset = 91.3 * mm;
G4Box *GEMHSpacerBox1 = new G4Box(Form("GEM%dHSpacerBox1", layerid), GEMHalfX, GEMSpacerWh, GEMSpacerT / 2.0);
G4Box *GEMHSpacerBox2 = new G4Box(Form("GEM%dHSpacerBox2", layerid), GEMHalfX - GEMCenterHalfXY + GEMFrameWidth / 2.0, GEMSpacerWh, GEMSpacerT / 2.0);
G4Box *GEMVSpacerBox = new G4Box(Form("GEM%dVSpacerBox", layerid), GEMSpacerWv, GEMHalfY, GEMSpacerT / 2.0);
G4UnionSolid *GEMSpacerPiece1 = new G4UnionSolid(Form("GEM%dSpacerPiece1", layerid), GEMVSpacerBox, GEMHSpacerBox1, 0, G4ThreeVector(GEMSpacerOffset, 204.0 * mm, 0));
G4UnionSolid *GEMSpacerPiece2 = new G4UnionSolid(Form("GEM%dSpacerPiece2", layerid), GEMSpacerPiece1, GEMHSpacerBox1, 0, G4ThreeVector(GEMSpacerOffset, 409.3 * mm, 0));
G4UnionSolid *GEMSpacerPiece3 = new G4UnionSolid(Form("GEM%dSpacerPiece3", layerid), GEMSpacerPiece2, GEMHSpacerBox2, 0, G4ThreeVector(GEMSpacerOffset + GEMCenterHalfXY - GEMFrameWidth / 2.0, 0, 0));
G4UnionSolid *GEMSpacerPiece4 = new G4UnionSolid(Form("GEM%dSpacerPiece4", layerid), GEMSpacerPiece3, GEMHSpacerBox1, 0, G4ThreeVector(GEMSpacerOffset, -204.0 * mm, 0));
G4UnionSolid *GEMSpacerPiece5 = new G4UnionSolid(Form("GEM%dSpacerPiece5", layerid), GEMSpacerPiece4, GEMHSpacerBox1, 0, G4ThreeVector(GEMSpacerOffset, -409.3 * mm, 0));
G4UnionSolid *solidGEMSpacer = new G4UnionSolid(Form("GEM%dSpacerS", layerid), GEMSpacerPiece5, GEMVSpacerBox, 0, G4ThreeVector(GEMSpacerOffset * 2.0, 0, 0));
G4LogicalVolume *logicGEMSpacer = new G4LogicalVolume(solidGEMSpacer, GEMFrameM, Form("GEM%dSpacerLV", layerid));
// GEM Foil
G4double GEMWinT = 25.0 * um;
G4double GEMFoilT = 50.0 * um;
G4double GEMCuT = 5.0 * um;
G4double GEMGlueT = 60.0 * um;
G4Box *GEMWinBox = new G4Box(Form("GEM%dWinBox", layerid), GEMHalfX, GEMHalfY, GEMWinT / 2.0);
G4SubtractionSolid *solidGEMWin = new G4SubtractionSolid(Form("GEM%dWinS", layerid), GEMWinBox, GEMSubBox, 0, G4ThreeVector(-GEMCenterOffset, 0, 0));
G4LogicalVolume *logicGEMWin = new G4LogicalVolume(solidGEMWin, GEMFoilM, Form("GEM%dWinLV", layerid));
G4Box *GEMFoilBox = new G4Box(Form("GEM%dFoilBox", layerid), GEMHalfX, GEMHalfY, GEMFoilT / 2.0);
G4SubtractionSolid *solidGEMFoil = new G4SubtractionSolid(Form("GEM%dFoilS", layerid), GEMFoilBox, GEMSubBox, 0, G4ThreeVector(-GEMCenterOffset, 0, 0));
G4LogicalVolume *logicGEMFoil = new G4LogicalVolume(solidGEMFoil, GEMFoil0d8M, Form("GEM%dFoilLV", layerid));
G4LogicalVolume *logicGEMFoil80 = new G4LogicalVolume(solidGEMFoil, GEMFoil0d2M, Form("GEM%dFoil80LV", layerid));
G4LogicalVolume *logicGEMFoil350 = new G4LogicalVolume(solidGEMFoil, GEMFoilM, Form("GEM%dFoil350LV", layerid));
G4LogicalVolume *logicGEMCathode = new G4LogicalVolume(solidGEMFoil, GEMFoilM, Form("GEM%dCathodeLV", layerid));
G4Box *GEMCuBox = new G4Box(Form("GEM%dCuBox", layerid), GEMHalfX, GEMHalfY, GEMCuT / 2.0);
G4SubtractionSolid *solidGEMCu = new G4SubtractionSolid(Form("GEM%dCuS", layerid), GEMCuBox, GEMSubBox, 0, G4ThreeVector(-GEMCenterOffset, 0, 0));
G4LogicalVolume *logicGEMCu = new G4LogicalVolume(solidGEMCu, GEMCu0d8M, Form("GEM%dCuLV", layerid));
G4LogicalVolume *logicGEMCu80 = new G4LogicalVolume(solidGEMCu, GEMCu0d2M, Form("GEM%dCu80LV", layerid));
G4LogicalVolume *logicGEMCu350 = new G4LogicalVolume(solidGEMCu, GEMCu0d75M, Form("GEM%dCu350LV", layerid));
G4LogicalVolume *logicGEMCathodeCu = new G4LogicalVolume(solidGEMCu, GEMCuM, Form("GEM%dCathodeCuLV", layerid));
G4Box *GEMGlueBox = new G4Box(Form("GEM%dGlueBox", layerid), GEMHalfX, GEMHalfY, GEMGlueT / 2.0);
G4SubtractionSolid *solidGEMGlue = new G4SubtractionSolid(Form("GEM%dGlueS", layerid), GEMGlueBox, GEMSubBox, 0, G4ThreeVector(-GEMCenterOffset, 0, 0));
G4LogicalVolume *logicGEMGlue = new G4LogicalVolume(solidGEMGlue, GEMGlueM, Form("GEM%dGlueLV", layerid));
G4double zoff = -GEMHalfT;
new G4PVPlacement(0, G4ThreeVector(0, 0, zoff + GEMWinT / 2.0), logicGEMWin, Form("GEM %d Window", layerid), logicGEMGas, false, 0);
zoff += GEMWinT;
new G4PVPlacement(0, G4ThreeVector(-GEMSpacerOffset, 0, zoff + GEMSpacerT / 2.0), logicGEMSpacer, Form("GEM %d Spacer", layerid), logicGEMGas, false, 0);
zoff += 3.0 * mm;
new G4PVPlacement(0, G4ThreeVector(0, 0, zoff + GEMFoilT / 2.0), logicGEMCathode, Form("GEM %d Cathode", layerid), logicGEMGas, false, 0);
zoff += GEMFoilT;
if (!culess) {
new G4PVPlacement(0, G4ThreeVector(0, 0, zoff + GEMCuT / 2.0), logicGEMCathodeCu, Form("GEM %d Copper", layerid), logicGEMGas, false, 0);
zoff += GEMCuT;
}
new G4PVPlacement(0, G4ThreeVector(-GEMSpacerOffset, 0, zoff + GEMSpacerT / 2.0), logicGEMSpacer, Form("GEM %d Spacer", layerid), logicGEMGas, false, 1);
zoff += 3.0 * mm;
if (!culess) {
new G4PVPlacement(0, G4ThreeVector(0, 0, zoff + GEMCuT / 2.0), logicGEMCu, Form("GEM %d Copper", layerid), logicGEMGas, false, 1);
zoff += GEMCuT;
}
new G4PVPlacement(0, G4ThreeVector(0, 0, zoff + GEMFoilT / 2.0), logicGEMFoil, Form("GEM %d Foil", layerid), logicGEMGas, false, 0);
zoff += GEMFoilT;
if (!culess) {
new G4PVPlacement(0, G4ThreeVector(0, 0, zoff + GEMCuT / 2.0), logicGEMCu, Form("GEM %d Copper", layerid), logicGEMGas, false, 2);
zoff += GEMCuT;
}
new G4PVPlacement(0, G4ThreeVector(-GEMSpacerOffset, 0, zoff + GEMSpacerT / 2.0), logicGEMSpacer, Form("GEM %d Spacer", layerid), logicGEMGas, false, 2);
zoff += 2.0 * mm;
if (!culess) {
new G4PVPlacement(0, G4ThreeVector(0, 0, zoff + GEMCuT / 2.0), logicGEMCu, Form("GEM %d Copper", layerid), logicGEMGas, false, 3);
zoff += GEMCuT;
}
new G4PVPlacement(0, G4ThreeVector(0, 0, zoff + GEMFoilT / 2.0), logicGEMFoil, Form("GEM %d Foil", layerid), logicGEMGas, false, 1);