1 | // |
---|
2 | // ******************************************************************** |
---|
3 | // * License and Disclaimer * |
---|
4 | // * * |
---|
5 | // * The Geant4 software is copyright of the Copyright Holders of * |
---|
6 | // * the Geant4 Collaboration. It is provided under the terms and * |
---|
7 | // * conditions of the Geant4 Software License, included in the file * |
---|
8 | // * LICENSE and available at http://cern.ch/geant4/license . These * |
---|
9 | // * include a list of copyright holders. * |
---|
10 | // * * |
---|
11 | // * Neither the authors of this software system, nor their employing * |
---|
12 | // * institutes,nor the agencies providing financial support for this * |
---|
13 | // * work make any representation or warranty, express or implied, * |
---|
14 | // * regarding this software system or assume any liability for its * |
---|
15 | // * use. Please see the license in the file LICENSE and URL above * |
---|
16 | // * for the full disclaimer and the limitation of liability. * |
---|
17 | // * * |
---|
18 | // * This code implementation is the result of the scientific and * |
---|
19 | // * technical work of the GEANT4 collaboration. * |
---|
20 | // * By using, copying, modifying or distributing the software (or * |
---|
21 | // * any work based on the software) you agree to acknowledge its * |
---|
22 | // * use in resulting scientific publications, and indicate your * |
---|
23 | // * acceptance of all terms of the Geant4 Software license. * |
---|
24 | // ******************************************************************** |
---|
25 | // |
---|
26 | |
---|
27 | #include "ExN04DetectorConstruction.hh" |
---|
28 | #include "ExN04TrackerSD.hh" |
---|
29 | #include "ExN04CalorimeterSD.hh" |
---|
30 | #include "ExN04CalorimeterROGeometry.hh" |
---|
31 | #include "ExN04MuonSD.hh" |
---|
32 | #include "ExN04TrackerParametrisation.hh" |
---|
33 | #include "ExN04CalorimeterParametrisation.hh" |
---|
34 | #include "ExN04Field.hh" |
---|
35 | |
---|
36 | #include "G4Material.hh" |
---|
37 | #include "G4MaterialTable.hh" |
---|
38 | #include "G4Element.hh" |
---|
39 | #include "G4ElementTable.hh" |
---|
40 | #include "G4Box.hh" |
---|
41 | #include "G4Tubs.hh" |
---|
42 | #include "G4LogicalVolume.hh" |
---|
43 | #include "G4ThreeVector.hh" |
---|
44 | #include "G4PVPlacement.hh" |
---|
45 | #include "G4PVParameterised.hh" |
---|
46 | #include "G4Transform3D.hh" |
---|
47 | #include "G4RotationMatrix.hh" |
---|
48 | #include "G4FieldManager.hh" |
---|
49 | #include "G4TransportationManager.hh" |
---|
50 | #include "G4SDManager.hh" |
---|
51 | #include "G4VisAttributes.hh" |
---|
52 | #include "G4Colour.hh" |
---|
53 | |
---|
54 | ExN04DetectorConstruction::ExN04DetectorConstruction() |
---|
55 | { |
---|
56 | |
---|
57 | #include "ExN04DetectorParameterDef.icc" |
---|
58 | DefineMaterials(); |
---|
59 | |
---|
60 | } |
---|
61 | |
---|
62 | ExN04DetectorConstruction::~ExN04DetectorConstruction() |
---|
63 | {;} |
---|
64 | |
---|
65 | void ExN04DetectorConstruction::DefineMaterials() |
---|
66 | { |
---|
67 | //------------------------------------------------------------------------- |
---|
68 | // Materials |
---|
69 | //------------------------------------------------------------------------- |
---|
70 | |
---|
71 | G4double a, z, density; |
---|
72 | G4int nel; |
---|
73 | |
---|
74 | G4Element* H = new G4Element("Hydrogen", "H", z=1., a= 1.01*g/mole); |
---|
75 | G4Element* C = new G4Element("Carbon", "C", z=6., a= 12.01*g/mole); |
---|
76 | G4Element* N = new G4Element("Nitrogen", "N", z=7., a= 14.01*g/mole); |
---|
77 | G4Element* O = new G4Element("Oxygen", "O", z=8., a= 16.00*g/mole); |
---|
78 | |
---|
79 | Air = new G4Material("Air", density= 1.29*mg/cm3, nel=2); |
---|
80 | Air->AddElement(N, 70.*perCent); |
---|
81 | Air->AddElement(O, 30.*perCent); |
---|
82 | |
---|
83 | Lead = |
---|
84 | new G4Material("Lead", z=82., a= 207.19*g/mole, density= 11.35*g/cm3); |
---|
85 | |
---|
86 | Ar = |
---|
87 | new G4Material("ArgonGas",z=18., a= 39.95*g/mole, density=1.782*mg/cm3); |
---|
88 | |
---|
89 | Silicon = |
---|
90 | new G4Material("Silicon", z=14., a= 28.09*g/mole, density= 2.33*g/cm3); |
---|
91 | |
---|
92 | Scinti = new G4Material("Scintillator", density= 1.032*g/cm3, nel=2); |
---|
93 | Scinti->AddElement(C, 9); |
---|
94 | Scinti->AddElement(H, 10); |
---|
95 | } |
---|
96 | |
---|
97 | G4VPhysicalVolume* ExN04DetectorConstruction::Construct() |
---|
98 | { |
---|
99 | //------------------------------------------------------------------------- |
---|
100 | // Magnetic field |
---|
101 | //------------------------------------------------------------------------- |
---|
102 | |
---|
103 | static G4bool fieldIsInitialized = false; |
---|
104 | if(!fieldIsInitialized) |
---|
105 | { |
---|
106 | ExN04Field* myField = new ExN04Field; |
---|
107 | G4FieldManager* fieldMgr |
---|
108 | = G4TransportationManager::GetTransportationManager() |
---|
109 | ->GetFieldManager(); |
---|
110 | fieldMgr->SetDetectorField(myField); |
---|
111 | fieldMgr->CreateChordFinder(myField); |
---|
112 | fieldIsInitialized = true; |
---|
113 | } |
---|
114 | |
---|
115 | |
---|
116 | //------------------------------------------------------------------------- |
---|
117 | // Detector geometry |
---|
118 | //------------------------------------------------------------------------- |
---|
119 | |
---|
120 | //------------------------------ experimental hall |
---|
121 | G4Box * experimentalHall_box |
---|
122 | = new G4Box("expHall_b",expHall_x,expHall_y,expHall_z); |
---|
123 | G4LogicalVolume * experimentalHall_log |
---|
124 | = new G4LogicalVolume(experimentalHall_box,Air,"expHall_L",0,0,0); |
---|
125 | G4VPhysicalVolume * experimentalHall_phys |
---|
126 | = new G4PVPlacement(0,G4ThreeVector(),experimentalHall_log,"expHall_P", |
---|
127 | 0,false,0); |
---|
128 | G4VisAttributes* experimentalHallVisAtt |
---|
129 | = new G4VisAttributes(G4Colour(1.0,1.0,1.0)); |
---|
130 | experimentalHallVisAtt->SetForceWireframe(true); |
---|
131 | experimentalHall_log->SetVisAttributes(experimentalHallVisAtt); |
---|
132 | |
---|
133 | //------------------------------ tracker |
---|
134 | G4VSolid * tracker_tubs |
---|
135 | = new G4Tubs("trkTubs_tubs",trkTubs_rmin,trkTubs_rmax,trkTubs_dz, |
---|
136 | trkTubs_sphi,trkTubs_dphi); |
---|
137 | G4LogicalVolume * tracker_log |
---|
138 | = new G4LogicalVolume(tracker_tubs,Ar,"trackerT_L",0,0,0); |
---|
139 | // G4VPhysicalVolume * tracker_phys = |
---|
140 | new G4PVPlacement(0,G4ThreeVector(),tracker_log,"tracker_phys", |
---|
141 | experimentalHall_log,false,0); |
---|
142 | G4VisAttributes* tracker_logVisAtt |
---|
143 | = new G4VisAttributes(G4Colour(1.0,0.0,1.0)); |
---|
144 | tracker_logVisAtt->SetForceWireframe(true); |
---|
145 | tracker_log->SetVisAttributes(tracker_logVisAtt); |
---|
146 | |
---|
147 | //------------------------------ tracker layers |
---|
148 | // As an example for Parameterised volume |
---|
149 | // dummy values for G4Tubs -- modified by parameterised volume |
---|
150 | G4VSolid * trackerLayer_tubs |
---|
151 | = new G4Tubs("trackerLayer_tubs",trkTubs_rmin,trkTubs_rmax,trkTubs_dz, |
---|
152 | trkTubs_sphi,trkTubs_dphi); |
---|
153 | G4LogicalVolume * trackerLayer_log |
---|
154 | = new G4LogicalVolume(trackerLayer_tubs,Silicon,"trackerB_L",0,0,0); |
---|
155 | G4VPVParameterisation * trackerParam |
---|
156 | = new ExN04TrackerParametrisation; |
---|
157 | // dummy value : kXAxis -- modified by parameterised volume |
---|
158 | // G4VPhysicalVolume *trackerLayer_phys = |
---|
159 | new G4PVParameterised("trackerLayer_phys",trackerLayer_log,tracker_log, |
---|
160 | kXAxis, notrkLayers, trackerParam); |
---|
161 | G4VisAttributes* trackerLayer_logVisAtt |
---|
162 | = new G4VisAttributes(G4Colour(0.5,0.0,1.0)); |
---|
163 | trackerLayer_logVisAtt->SetForceWireframe(true); |
---|
164 | trackerLayer_log->SetVisAttributes(trackerLayer_logVisAtt); |
---|
165 | |
---|
166 | //------------------------------ calorimeter |
---|
167 | G4VSolid * calorimeter_tubs |
---|
168 | = new G4Tubs("calorimeter_tubs",caloTubs_rmin,caloTubs_rmax, |
---|
169 | caloTubs_dz,caloTubs_sphi,caloTubs_dphi); |
---|
170 | G4LogicalVolume * calorimeter_log |
---|
171 | = new G4LogicalVolume(calorimeter_tubs,Scinti,"caloT_L",0,0,0); |
---|
172 | // G4VPhysicalVolume * calorimeter_phys = |
---|
173 | new G4PVPlacement(0,G4ThreeVector(),calorimeter_log,"caloM_P", |
---|
174 | experimentalHall_log,false,0); |
---|
175 | G4VisAttributes* calorimeter_logVisATT |
---|
176 | = new G4VisAttributes(G4Colour(1.0,1.0,0.0)); |
---|
177 | calorimeter_logVisATT->SetForceWireframe(true); |
---|
178 | calorimeter_log->SetVisAttributes(calorimeter_logVisATT); |
---|
179 | |
---|
180 | //------------------------------- Lead layers |
---|
181 | // As an example for Parameterised volume |
---|
182 | // dummy values for G4Tubs -- modified by parameterised volume |
---|
183 | G4VSolid * caloLayer_tubs |
---|
184 | = new G4Tubs("caloLayer_tubs",caloRing_rmin,caloRing_rmax, |
---|
185 | caloRing_dz,caloRing_sphi,caloRing_dphi); |
---|
186 | G4LogicalVolume * caloLayer_log |
---|
187 | = new G4LogicalVolume(caloLayer_tubs,Lead,"caloR_L",0,0,0); |
---|
188 | G4VPVParameterisation * calorimeterParam |
---|
189 | = new ExN04CalorimeterParametrisation; |
---|
190 | // dummy value : kXAxis -- modified by parameterised volume |
---|
191 | // G4VPhysicalVolume * caloLayer_phys = |
---|
192 | new G4PVParameterised("caloLayer_phys",caloLayer_log,calorimeter_log, |
---|
193 | kXAxis, nocaloLayers, calorimeterParam); |
---|
194 | G4VisAttributes* caloLayer_logVisAtt |
---|
195 | = new G4VisAttributes(G4Colour(0.7,1.0,0.0)); |
---|
196 | caloLayer_logVisAtt->SetForceWireframe(true); |
---|
197 | caloLayer_log->SetVisAttributes(caloLayer_logVisAtt); |
---|
198 | |
---|
199 | //------------------------------ muon counters |
---|
200 | // As an example of CSG volumes with rotation |
---|
201 | G4VSolid * muoncounter_box |
---|
202 | = new G4Box("muoncounter_box",muBox_width,muBox_thick, |
---|
203 | muBox_length); |
---|
204 | G4LogicalVolume * muoncounter_log |
---|
205 | = new G4LogicalVolume(muoncounter_box,Scinti,"mucounter_L",0,0,0); |
---|
206 | G4VPhysicalVolume * muoncounter_phys; |
---|
207 | for(int i=0; i<nomucounter ; i++) |
---|
208 | { |
---|
209 | G4double phi, x, y, z; |
---|
210 | phi = 360.*deg/nomucounter*i; |
---|
211 | x = muBox_radius*std::sin(phi); |
---|
212 | y = muBox_radius*std::cos(phi); |
---|
213 | z = 0.*cm; |
---|
214 | G4RotationMatrix rm; |
---|
215 | rm.rotateZ(phi); |
---|
216 | muoncounter_phys |
---|
217 | = new G4PVPlacement(G4Transform3D(rm,G4ThreeVector(x,y,z)), |
---|
218 | muoncounter_log, "muoncounter_P", |
---|
219 | experimentalHall_log,false,i); |
---|
220 | } |
---|
221 | G4VisAttributes* muoncounter_logVisAtt |
---|
222 | = new G4VisAttributes(G4Colour(0.0,1.0,1.0)); |
---|
223 | muoncounter_logVisAtt->SetForceWireframe(true); |
---|
224 | muoncounter_log->SetVisAttributes(muoncounter_logVisAtt); |
---|
225 | |
---|
226 | //------------------------------------------------------------------ |
---|
227 | // Sensitive Detector |
---|
228 | //------------------------------------------------------------------ |
---|
229 | |
---|
230 | G4SDManager* SDman = G4SDManager::GetSDMpointer(); |
---|
231 | |
---|
232 | G4String trackerSDname = "/mydet/tracker"; |
---|
233 | ExN04TrackerSD * trackerSD = new ExN04TrackerSD(trackerSDname); |
---|
234 | SDman->AddNewDetector(trackerSD); |
---|
235 | trackerLayer_log->SetSensitiveDetector(trackerSD); |
---|
236 | |
---|
237 | G4String calorimeterSDname = "/mydet/calorimeter"; |
---|
238 | ExN04CalorimeterSD * calorimeterSD = new ExN04CalorimeterSD(calorimeterSDname); |
---|
239 | G4String ROgeometryName = "CalorimeterROGeom"; |
---|
240 | G4VReadOutGeometry* calRO = new ExN04CalorimeterROGeometry(ROgeometryName); |
---|
241 | calRO->BuildROGeometry(); |
---|
242 | calorimeterSD->SetROgeometry(calRO); |
---|
243 | SDman->AddNewDetector(calorimeterSD); |
---|
244 | calorimeter_log->SetSensitiveDetector(calorimeterSD); |
---|
245 | |
---|
246 | G4String muonSDname = "/mydet/muon"; |
---|
247 | ExN04MuonSD * muonSD = new ExN04MuonSD(muonSDname); |
---|
248 | SDman->AddNewDetector(muonSD); |
---|
249 | muoncounter_log->SetSensitiveDetector(muonSD); |
---|
250 | |
---|
251 | //------------------------------------------------------------------ |
---|
252 | // Digitizer modules |
---|
253 | //------------------------------------------------------------------ |
---|
254 | |
---|
255 | return experimentalHall_phys; |
---|
256 | } |
---|
257 | |
---|