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 | // $Id: ExN05DetectorConstruction.cc,v 1.10 2006/11/03 17:58:49 mverderi Exp $ |
---|
28 | // GEANT4 tag $Name: $ |
---|
29 | // |
---|
30 | #include "ExN05DetectorConstruction.hh" |
---|
31 | #include "ExN05CalorimeterSD.hh" |
---|
32 | #include "ExN05EMShowerModel.hh" |
---|
33 | #include "ExN05PiModel.hh" |
---|
34 | |
---|
35 | #include "G4Material.hh" |
---|
36 | #include "G4MaterialTable.hh" |
---|
37 | #include "G4Element.hh" |
---|
38 | #include "G4ProductionCuts.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 "G4SDManager.hh" |
---|
46 | #include "G4VisAttributes.hh" |
---|
47 | #include "G4Colour.hh" |
---|
48 | |
---|
49 | |
---|
50 | ExN05DetectorConstruction::ExN05DetectorConstruction() |
---|
51 | {;} |
---|
52 | |
---|
53 | ExN05DetectorConstruction::~ExN05DetectorConstruction() |
---|
54 | {;} |
---|
55 | |
---|
56 | G4VPhysicalVolume* ExN05DetectorConstruction::Construct() |
---|
57 | { |
---|
58 | G4cout << "\nExN05DetectorConstruction....\n" << G4endl; |
---|
59 | |
---|
60 | //--------- Material definition --------- |
---|
61 | |
---|
62 | G4double a, iz, z, density; |
---|
63 | G4String name, symbol; |
---|
64 | G4int nel; |
---|
65 | |
---|
66 | a = 14.01*g/mole; |
---|
67 | G4Element* elN = new G4Element(name="Nitrogen", symbol="N", iz=7., a); |
---|
68 | a = 16.00*g/mole; |
---|
69 | G4Element* elO = new G4Element(name="Oxigen", symbol="O", iz=8., a); |
---|
70 | a = 126.9*g/mole; |
---|
71 | G4Element* elI = new G4Element(name="Iodine", symbol="I", iz=53., a); |
---|
72 | a = 132.9*g/mole; |
---|
73 | G4Element* elCs= new G4Element(name="Cesium", symbol="Cs", iz=55., a); |
---|
74 | |
---|
75 | |
---|
76 | density = 4.51*g/cm3; |
---|
77 | G4Material* CsI = new G4Material(name="CsI", density, nel = 2); |
---|
78 | CsI->AddElement(elI, .5); |
---|
79 | CsI->AddElement(elCs,.5); |
---|
80 | a = 4.0*g/mole; |
---|
81 | density = 0.1786e-03*g/cm3; |
---|
82 | G4Material* He = new G4Material(name="He", z=2., a, density); |
---|
83 | |
---|
84 | a = 55.85*g/mole; |
---|
85 | density = 7.87*g/cm3; |
---|
86 | G4Material* Fe = new G4Material(name="Fer", z=26., a, density); |
---|
87 | density = 1.29e-03*g/cm3; |
---|
88 | G4Material* Air = new G4Material(name="Air", density, nel=2); |
---|
89 | Air->AddElement(elN, .7); |
---|
90 | Air->AddElement(elO, .3); |
---|
91 | |
---|
92 | //--------- G4VSolid, G4LogicalVolume, G4VPhysicalVolume --------- |
---|
93 | |
---|
94 | //-------------- |
---|
95 | // World: |
---|
96 | //-------------- |
---|
97 | G4Box *WorldBox= new G4Box("WorldBox",400*cm, 400*cm, 400*cm); |
---|
98 | G4LogicalVolume *WorldLog=new G4LogicalVolume(WorldBox,Air, |
---|
99 | "WorldLogical", 0, 0, 0); |
---|
100 | G4PVPlacement *WorldPhys=new G4PVPlacement(0,G4ThreeVector(), |
---|
101 | "WorldPhysical", |
---|
102 | WorldLog, |
---|
103 | 0,false,0); |
---|
104 | // Size of detectors: |
---|
105 | G4double detectSize = 125*cm; |
---|
106 | |
---|
107 | //----------------------------- |
---|
108 | // "Drift Chamber": |
---|
109 | // Not used in parameterisation. |
---|
110 | //----------------------------- |
---|
111 | // -- Logical volume: |
---|
112 | G4Box *driftChamberBox |
---|
113 | = new G4Box("DriftChamberSolid", detectSize, detectSize, 40*cm); |
---|
114 | G4LogicalVolume *driftChamberLog |
---|
115 | = new G4LogicalVolume(driftChamberBox,He, |
---|
116 | "DriftChamberLogical", 0, 0, 0); |
---|
117 | // -- Placement: |
---|
118 | // G4PVPlacement *driftChamberPhys = |
---|
119 | new G4PVPlacement(0,G4ThreeVector(0., 0., 50*cm), |
---|
120 | "DriftChamberPhysical", |
---|
121 | driftChamberLog, |
---|
122 | WorldPhys,false,0); |
---|
123 | |
---|
124 | //-------------------------- |
---|
125 | // "Calorimeter": used in |
---|
126 | // parameterisation below |
---|
127 | //-------------------------- |
---|
128 | // -- Logical volume: |
---|
129 | G4Box *calorimeterBox |
---|
130 | = new G4Box("CalorimeterSolid", detectSize, detectSize, 20*cm); |
---|
131 | G4LogicalVolume *calorimeterLog = new G4LogicalVolume(calorimeterBox,Air, |
---|
132 | "CalorimeterLogical", 0, 0, 0); |
---|
133 | // -- Placement: |
---|
134 | G4PVPlacement *calorimeterPhys = new G4PVPlacement(0,G4ThreeVector(0., 0., 120*cm), |
---|
135 | "CalorimeterPhysical", |
---|
136 | calorimeterLog, |
---|
137 | WorldPhys,false,0); |
---|
138 | |
---|
139 | //-------------------------------------- |
---|
140 | // The calorimeter is filled with |
---|
141 | // crystals: |
---|
142 | //-------------------------------------- |
---|
143 | // -- Logical volume: |
---|
144 | G4double CrystalX = 2.5*cm; |
---|
145 | G4double CrystalY = CrystalX; |
---|
146 | G4double CrystalZ = 20*cm; |
---|
147 | G4Box *CrystalSolid = new G4Box("CrystalSolid", CrystalX, CrystalY, CrystalZ); |
---|
148 | theCrystalLog = new G4LogicalVolume(CrystalSolid,CsI, |
---|
149 | "CrystalLogical", 0, 0, 0); |
---|
150 | |
---|
151 | G4String tName1("Crystal"); // Allow all target physicals to share |
---|
152 | // same name (delayed copy) |
---|
153 | |
---|
154 | // -- and placements inside the calorimeter: |
---|
155 | G4PVPlacement *crystalPhys; |
---|
156 | G4int copyNo=0; |
---|
157 | G4double xTlate, yTlate; |
---|
158 | G4int nX = 48; |
---|
159 | G4int nY = 48; |
---|
160 | for (G4int j = 0; j < nY; j++) |
---|
161 | { |
---|
162 | yTlate = -detectSize + 3*CrystalY + j*2*CrystalY; |
---|
163 | for (G4int i = 0; i < nX; i++) |
---|
164 | { |
---|
165 | xTlate = -detectSize + 3*CrystalX + i*2*CrystalX; |
---|
166 | crystalPhys = new G4PVPlacement(0,G4ThreeVector(xTlate,yTlate,0*cm), |
---|
167 | tName1, |
---|
168 | theCrystalLog, |
---|
169 | calorimeterPhys,false,copyNo++); |
---|
170 | } |
---|
171 | } |
---|
172 | |
---|
173 | |
---|
174 | //-------------------------- |
---|
175 | // "Hadron Calorimeter": used |
---|
176 | // in parameterisation with |
---|
177 | // a parallel geometry |
---|
178 | //-------------------------- |
---|
179 | // -- Logical volume: |
---|
180 | G4Box *hadCaloBox |
---|
181 | = new G4Box("HadCaloSolid", detectSize, detectSize, 50*cm); |
---|
182 | G4LogicalVolume *hadCaloLog = new G4LogicalVolume(hadCaloBox,Air, |
---|
183 | "HadCaloLogical", 0, 0, 0); |
---|
184 | // -- Placement: |
---|
185 | G4PVPlacement *hadCaloPhys = new G4PVPlacement(0,G4ThreeVector(0., 0., 200*cm), |
---|
186 | "HadCaloPhysical", |
---|
187 | hadCaloLog, |
---|
188 | WorldPhys,false,0); |
---|
189 | |
---|
190 | //-------------------------------------- |
---|
191 | // The calorimeter is filled with |
---|
192 | // towers: |
---|
193 | //-------------------------------------- |
---|
194 | // -- Logical volume: |
---|
195 | G4double TowerX = 5*cm; |
---|
196 | G4double TowerY = TowerX; |
---|
197 | G4double TowerZ = 45*cm; |
---|
198 | G4Box *TowerSolid = new G4Box("TowerSolid", TowerX, TowerY, TowerZ); |
---|
199 | theTowerLog = new G4LogicalVolume(TowerSolid,Fe, |
---|
200 | "TowerLogical", 0, 0, 0); |
---|
201 | |
---|
202 | G4String tName2("Tower"); |
---|
203 | |
---|
204 | // -- and placements inside the calorimeter: |
---|
205 | G4PVPlacement *towerPhys; |
---|
206 | copyNo=0; |
---|
207 | G4int nXhad = 23; |
---|
208 | G4int nYhad = 23; |
---|
209 | for (G4int jj = 0; jj < nYhad; jj++) |
---|
210 | { |
---|
211 | yTlate = -detectSize + 3*TowerY + jj*2*TowerY; |
---|
212 | for (G4int i = 0; i < nXhad; i++) |
---|
213 | { |
---|
214 | xTlate = -detectSize + 3*TowerX + i*2*TowerX; |
---|
215 | towerPhys |
---|
216 | = new G4PVPlacement(0,G4ThreeVector(xTlate,yTlate,0*cm), |
---|
217 | tName2, |
---|
218 | theTowerLog, |
---|
219 | hadCaloPhys,false,copyNo++); |
---|
220 | } |
---|
221 | } |
---|
222 | |
---|
223 | |
---|
224 | //--------- Sensitive detector ------------------------------------- |
---|
225 | G4SDManager* SDman = G4SDManager::GetSDMpointer(); |
---|
226 | G4String calorimeterSDname = "ExN05/Calorimeter"; |
---|
227 | ExN05CalorimeterSD* CalorimeterSD = new ExN05CalorimeterSD( calorimeterSDname, nX*nY, "CalCollection" ); |
---|
228 | SDman->AddNewDetector( CalorimeterSD ); |
---|
229 | theCrystalLog->SetSensitiveDetector(CalorimeterSD); |
---|
230 | |
---|
231 | G4String hadCalorimeterSDname = "ExN05/HadronCalorimeter"; |
---|
232 | ExN05CalorimeterSD* HadCalorimeterSD = new ExN05CalorimeterSD( hadCalorimeterSDname, nXhad*nYhad, "HadCollection" ); |
---|
233 | SDman->AddNewDetector( HadCalorimeterSD ); |
---|
234 | theTowerLog->SetSensitiveDetector(HadCalorimeterSD); |
---|
235 | |
---|
236 | //------------------ Parameterisation Models -------------------------- |
---|
237 | // -- Makes the calorimeterLog volume becoming a G4Region: |
---|
238 | G4Region* caloRegion = new G4Region("EM_calo_region"); |
---|
239 | caloRegion->AddRootLogicalVolume(calorimeterLog); |
---|
240 | std::vector<double> cuts; cuts.push_back(1.0*mm);cuts.push_back(1.0*mm);cuts.push_back(1.0*mm); |
---|
241 | caloRegion->SetProductionCuts(new G4ProductionCuts()); |
---|
242 | caloRegion->GetProductionCuts()->SetProductionCuts(cuts); |
---|
243 | // builds a model and sets it to the envelope of the calorimeter: |
---|
244 | new ExN05EMShowerModel("emShowerModel",caloRegion); |
---|
245 | // -- uncomment for seeing warning message with /param/showSetup command new ExN05PiModel(caloRegion); |
---|
246 | |
---|
247 | // ---------------- Makes had. calo a region too ------------------ |
---|
248 | G4Region* hadRegion = new G4Region("HAD_calo_region"); |
---|
249 | hadRegion->AddRootLogicalVolume(hadCaloLog); |
---|
250 | cuts.clear(); |
---|
251 | cuts.push_back(1.0*cm);cuts.push_back(1.0*cm);cuts.push_back(1.0*cm); |
---|
252 | hadRegion->SetProductionCuts(new G4ProductionCuts()); |
---|
253 | hadRegion->GetProductionCuts()->SetProductionCuts(cuts); |
---|
254 | |
---|
255 | //--------- Visualization attributes ------------------------------- |
---|
256 | WorldLog->SetVisAttributes(G4VisAttributes::Invisible); |
---|
257 | |
---|
258 | G4VisAttributes * driftchamberTubeVisAtt |
---|
259 | = new G4VisAttributes(G4Colour(0.0,1.0,0.0)); |
---|
260 | driftchamberTubeVisAtt->SetForceWireframe(true); |
---|
261 | driftChamberLog->SetVisAttributes(driftchamberTubeVisAtt); |
---|
262 | |
---|
263 | G4VisAttributes * calorimeterBoxVisAtt |
---|
264 | = new G4VisAttributes(G4Colour(0.0,0.0,1.0)); |
---|
265 | calorimeterBoxVisAtt->SetForceWireframe(true); |
---|
266 | calorimeterLog->SetVisAttributes(calorimeterBoxVisAtt); |
---|
267 | |
---|
268 | G4VisAttributes * crystalVisAtt |
---|
269 | = new G4VisAttributes(G4Colour(1.0,0.0,0.0)); |
---|
270 | crystalVisAtt->SetForceWireframe(true); |
---|
271 | theCrystalLog->SetVisAttributes(crystalVisAtt); |
---|
272 | |
---|
273 | G4VisAttributes * hadCaloBoxVisAtt |
---|
274 | = new G4VisAttributes(G4Colour(1.0,0.0,1.0)); |
---|
275 | hadCaloBoxVisAtt->SetForceWireframe(true); |
---|
276 | hadCaloLog->SetVisAttributes(hadCaloBoxVisAtt); |
---|
277 | |
---|
278 | G4VisAttributes * towerVisAtt |
---|
279 | = new G4VisAttributes(G4Colour(0.5,0.0,1.0)); |
---|
280 | towerVisAtt->SetForceWireframe(true); |
---|
281 | theTowerLog->SetVisAttributes(towerVisAtt); |
---|
282 | |
---|
283 | //------------------------------------------------------------------ |
---|
284 | |
---|
285 | |
---|
286 | //----------------------- |
---|
287 | // Returns the pointer to |
---|
288 | // the physical world: |
---|
289 | //----------------------- |
---|
290 | return WorldPhys; |
---|
291 | } |
---|
292 | |
---|