-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathconstruction_1scint_cc
149 lines (116 loc) · 5.24 KB
/
construction_1scint_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
#include "construction.hh"
MyDetectorConstruction::MyDetectorConstruction()
{
fMessenger = new G4GenericMessenger(this, "/detector/", "Detector Construction");
// change the number of photosensors in one column
fMessenger->DeclareProperty("nCols", nCols, "Number of columns");
// change the number of photosensors in one row
fMessenger->DeclareProperty("nRows", nRows, "Number of rows");
// add the possibility to choose between the two types of detector: cherenkov or scintillator
fMessenger->DeclareProperty("isCherenkov", isCherenkov, "Toggle Cherenkov setup");
fMessenger->DeclareProperty("isScintillator", isScintillator, "Toggle Scintillator setup");
DefineMaterials();
// initial values
nCols = 100;
nRows = 100;
xWorld = 0.5 * m;
yWorld = 0.5 * m;
zWorld = 0.5 * m;
isCherenkov = false;
isScintillator = true;
}
MyDetectorConstruction::~MyDetectorConstruction()
{
}
void MyDetectorConstruction::DefineMaterials()
{
// create instance of nist to use already definer materials
G4NistManager *nist = G4NistManager::Instance();
// define aerogelm as new material: name, density, no. of components
SiO2 = new G4Material("SiO2", 2.201 * g / cm3, 2);
SiO2->AddElement(nist->FindOrBuildElement("Si"), 1);
SiO2->AddElement(nist->FindOrBuildElement("O"), 2);
// Define water
H2O = new G4Material("H2O", 1.000 * g / cm3, 2);
H2O->AddElement(nist->FindOrBuildElement("H"), 2);
H2O->AddElement(nist->FindOrBuildElement("O"), 1);
// carbon
C = nist->FindOrBuildElement("C");
// Aerogel from defined elements
Aerogel = new G4Material("Aerogel", 0.200 * g / cm3, 3);
Aerogel->AddMaterial(SiO2, 62.5 * perCent);
Aerogel->AddMaterial(H2O, 37.4 * perCent);
Aerogel->AddElement(C, 0.1 * perCent);
// add refractive index of the material for aerogel
G4double energy[2] = {1.239841939 * eV / 0.9, 1.239841939 * eV / 0.2};
G4double rindexAerogel[2] = {1.1, 1.1};
G4double rindexWorld[2] = {1.0, 1.0};
G4MaterialPropertiesTable *mptAerogel = new G4MaterialPropertiesTable();
mptAerogel->AddProperty("RINDEX", energy, rindexAerogel, 2);
// define material for world
worldMat = nist->FindOrBuildMaterial("G4_AIR");
// SAME FOR WORLD - refractive index
G4MaterialPropertiesTable *mptWorld = new G4MaterialPropertiesTable();
mptWorld->AddProperty("RINDEX", energy, rindexWorld, 2);
Aerogel->SetMaterialPropertiesTable(mptAerogel);
worldMat->SetMaterialPropertiesTable(mptWorld);
Na = nist->FindOrBuildElement("Na");
I = nist->FindOrBuildElement("I");
NaI = new G4Material("NaI", 3.67 * g / cm3, 2);
NaI->AddElement(Na, 1);
NaI->AddElement(I, 1);
}
void MyDetectorConstruction::ConstructCherenkov()
{
// Create detector
solidRadiator = new G4Box("solidRadiator", 0.4 * m, 0.4 * m, 0.01 * m);
// logical volume
logicRadiator = new G4LogicalVolume(solidRadiator, Aerogel, "logicRadiator");
// use radiator as scoring volume
fScoringVolume = logicRadiator;
// physical volume
physRadiator = new G4PVPlacement(0, G4ThreeVector(0., 0., 0.25 * m), logicRadiator, "physRadiator", logicWorld, false, 0, true);
// define 100 photosensors
// solid
solidDetector = new G4Box("solidDetector", xWorld / nRows, yWorld / nCols, 0.01 * m);
// logical
logicDetector = new G4LogicalVolume(solidDetector, worldMat, "logicalDetector");
// physical - in this case we have to create an array, so it's different:
for (G4int i = 0; i < nRows; i++)
{
for (G4int j = 0; j < nCols; j++)
{
physDetector = new G4PVPlacement(0, G4ThreeVector(-0.5 * m + (i + 0.5) * m / nRows, -0.5 * m + (j + 0.5) * m / nCols, 0.49 * m), logicDetector, "physDetector", logicWorld, false, j + i * nCols, true);
}
}
}
void MyDetectorConstruction::ConstructScintillator()
{
solidScintillator = new G4Tubs("solidScintillator", 10 * cm, 20 * cm, 30 * cm, 0 * deg, 360 * deg);
logicScintillator = new G4LogicalVolume(solidScintillator, NaI, "logicalScintillator");
// use scintillator as scoring volume
fScoringVolume = logicScintillator;
physScintillator = new G4PVPlacement(0, G4ThreeVector(0., 0., 0.), logicScintillator, "physScintillator", logicWorld, false, 0, true);
}
G4VPhysicalVolume *MyDetectorConstruction::Construct()
{
// define solid (first step)
solidWorld = new G4Box("solidWorld", xWorld, yWorld, zWorld);
// define logical volume (Second step)
logicWorld = new G4LogicalVolume(solidWorld, worldMat, "logicWorld");
// define physical volume: volume placement
//(0: no rotation, x, y, z: (0,0,0)placed at axes origin), logic volume, name, mother volume: 0, boolean operations: false, copy number (to insert volume several times), true: check for overlaps)
physWorld = new G4PVPlacement(0, G4ThreeVector(0., 0., 0.), logicWorld, "physWorld", 0, false, 0, true);
if (isCherenkov)
ConstructCherenkov();
if (isScintillator)
ConstructScintillator();
// return mother volume
return physWorld;
}
void MyDetectorConstruction::ConstructSDandField()
{
MySensitiveDetector *sensDet = new MySensitiveDetector("SensitiveDetector");
if (isCherenkov)
logicDetector->SetSensitiveDetector(sensDet);
}