Loading...
Searching...
No Matches
Par03DetectorConstruction.cc
Go to the documentation of this file.
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//
29#include "Par03EMShowerModel.hh"
30
31#include "G4NistManager.hh"
32#include "G4Material.hh"
33#include "G4Box.hh"
34#include "G4Tubs.hh"
35#include "G4LogicalVolume.hh"
36#include "G4PVPlacement.hh"
37#include "G4PVReplica.hh"
38#include "G4VisAttributes.hh"
39#include "G4RunManager.hh"
40
41#include "G4SDManager.hh"
42
43#include "G4UnitsTable.hh"
44
45#include "G4Region.hh"
46#include "G4RegionStore.hh"
47
48//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
49
52{
54
55 G4NistManager* nistManager = G4NistManager::Instance();
56 fDetectorMaterial = nistManager->FindOrBuildMaterial("G4_Fe");
57}
58
59//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
60
62
63//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
64
66{
67 //--------- Material definition ---------
68 G4NistManager* nistManager = G4NistManager::Instance();
69 G4Material* air = nistManager->FindOrBuildMaterial("G4_AIR");
70
71 //--------- Derived dimensions ---------
72 G4double full2Pi = 2. * CLHEP::pi * rad;
73 G4double layerThickness = fDetectorLength / fNbOfLayers;
74 G4double cellPhi = full2Pi / fNbOfPhiCells;
75 G4double cellDR = fDetectorRadius / fNbOfRhoCells;
76
77 //--------- World ---------
78 auto fSolidWorld = new G4Box("World", // name
79 fWorldSize / 2., // half-width in X
80 fWorldSize / 2., // half-width in Y
81 fWorldSize / 2.); // half-width in Z
82 auto fLogicWorld = new G4LogicalVolume(fSolidWorld, // solid
83 air, // material
84 "World"); // name
85 auto fPhysicWorld = new G4PVPlacement(0, // no rotation
86 G4ThreeVector(), // at (0,0,0)
87 fLogicWorld, // logical volume
88 "World", // name
89 0, // mother volume
90 false, // not used
91 999, // copy number
92 true); // copy number
93
94 //--------- Detector envelope ---------
95 auto fSolidDetector = new G4Tubs("Detector", // name
96 0, // inner radius
97 fDetectorRadius, // outer radius
98 fDetectorLength / 2., // half-width in Z
99 0, // start angle
100 full2Pi); // delta angle
101 auto fLogicDetector = new G4LogicalVolume(fSolidDetector, // solid
102 fDetectorMaterial, // material
103 "Detector"); // name
104 new G4PVPlacement(
105 0, // no rotation
106 G4ThreeVector(0, 0,
107 fDetectorLength / 2), // detector face starts at (0,0,0)
108 fLogicDetector, // logical volume
109 "Detector", // name
110 fLogicWorld, // mother volume
111 false, // not used
112 99, // copy number
113 true); // check overlaps
114
115 // Region for fast simulation
116 auto detectorRegion = new G4Region("DetectorRegion");
117 detectorRegion->AddRootLogicalVolume(fLogicDetector);
118
119 //--------- Readout geometry ---------
120 // Layers (along z)
121 auto fSolidLayer = new G4Tubs("Layer", // name
122 0, // inner radius
123 fDetectorRadius, // outer radius
124 layerThickness / 2., // half-width in Z
125 0, // start angle
126 full2Pi); // delta angle
127 auto fLogicLayer = new G4LogicalVolume(fSolidLayer, // solid
128 air, // material
129 "Layer"); // name
130 if(fNbOfLayers > 1)
131 new G4PVReplica("Layer", // name
132 fLogicLayer, // logical volume
133 fLogicDetector, // mother volume
134 kZAxis, // axis of replication
135 fNbOfLayers, // number of replicas
136 layerThickness); // width of single replica
137 else
138 new G4PVPlacement(0, // no rotation
139 G4ThreeVector(), // place at centre of mother volume
140 fLogicLayer, // logical volume
141 "Layer", // name
142 fLogicDetector, // mother volume
143 false, // not used
144 0, // copy number
145 true); // check overlaps
146
147 // Layer segment (division in phi)
148 auto fSolidRow = new G4Tubs("Row", // name
149 0, // inner radius
150 fDetectorRadius, // outer radius
151 layerThickness / 2., // half-width in Z
152 0, // start angle
153 cellPhi); // delta angle
154
155 auto fLogicRow = new G4LogicalVolume(fSolidRow, // solid
156 air, // material
157 "Segment"); // name
158 if(fNbOfPhiCells > 1)
159 new G4PVReplica("Segment", // name
160 fLogicRow, // logical volume
161 fLogicLayer, // mother volume
162 kPhi, // axis of replication
163 fNbOfPhiCells, // number of replicas
164 cellPhi); // width of single replica
165 else
166 new G4PVPlacement(0, // no rotation
167 G4ThreeVector(), // place at centre of mother volume
168 fLogicRow, // logical volume
169 "Row", // name
170 fLogicLayer, // mother volume
171 false, // not used
172 0, // copy number
173 true); // check overlaps
174
175 // Final cells (segment slices in radius)
176 // No volume can be placed inside a radial replication
177 auto fSolidCell = new G4Tubs("Cell", // name
178 0, // inner radius
179 cellDR, // outer radius
180 layerThickness / 2., // half-width in Z
181 0, // start angle
182 cellPhi); // delta angle
183
184 fLogicCell = new G4LogicalVolume(fSolidCell, // solid
185 fDetectorMaterial, // material
186 "Cell"); // name
187 if(fNbOfRhoCells > 1)
188 new G4PVReplica("Cell", // name
189 fLogicCell, // logical volume
190 fLogicRow, // mother volume
191 kRho, // axis of replication
192 fNbOfRhoCells, // number of replicas
193 cellDR); // width of single replica
194 else
195 new G4PVPlacement(0, // no rotation
196 G4ThreeVector(), // place at centre of mother volume
197 fLogicCell, // logical volume
198 "Cell", // name
199 fLogicRow, // mother volume
200 false, // not used
201 0, // copy number
202 true); // check overlaps
203
204 //--------- Visualisation settings ---------
205 fLogicWorld->SetVisAttributes(G4VisAttributes::GetInvisible());
206 fLogicLayer->SetVisAttributes(G4VisAttributes::GetInvisible());
207 fLogicRow->SetVisAttributes(G4VisAttributes::GetInvisible());
208 G4VisAttributes attribs;
209 attribs.SetColour(G4Colour(0, 0, 1, 0.3));
210 attribs.SetForceSolid(true);
211 fLogicCell->SetVisAttributes(attribs);
212
213 Print();
214 return fPhysicWorld;
215}
216
217//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
218
220{
222 "sensitiveDetector", fNbOfLayers, fNbOfPhiCells, fNbOfRhoCells);
223 G4SDManager::GetSDMpointer()->AddNewDetector(caloSD);
224 SetSensitiveDetector(fLogicCell, caloSD);
225
226 auto detectorRegion =
227 G4RegionStore::GetInstance()->GetRegion("DetectorRegion");
228 new Par03EMShowerModel("model", detectorRegion);
229}
230
231//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
232
234{
235 G4cout << "\n------------------------------------------------------"
236 << "\n--- Detector material:\t" << fDetectorMaterial->GetName()
237 << "\n--- Detector length:\t" << G4BestUnit(fDetectorLength, "Length")
238 << "\n--- Detector radius:\t" << G4BestUnit(fDetectorRadius, "Length")
239 << "\n--- Number of layers:\t" << fNbOfLayers
240 << "\n--- Number of R-cells:\t" << fNbOfRhoCells
241 << "\n--- Number of phi-cells:\t" << fNbOfPhiCells << G4endl;
242 G4cout << "-----------------------------------------------------" << G4endl;
243}
244
245//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
246
248{
249 // search material by its name
250 G4Material* material = G4NistManager::Instance()->FindOrBuildMaterial(aName);
251 if(material)
252 fDetectorMaterial = material;
253 else
254 G4Exception("Par03DetectorConstruction::SetMaterial()", "InvalidSetup",
255 FatalException, ("Unknown material name: " + aName).c_str());
256 G4RunManager::GetRunManager()->PhysicsHasBeenModified();
257}
258
259//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
260
262{
263 // check if fits within world volume
264 if(aRadius >= fWorldSize / 2.)
265 G4Exception("Par03DetectorConstruction::SetRadius()", "InvalidSetup",
266 FatalException,
267 ("Detector radius cannot be larger than the world size (" +
268 G4String(G4BestUnit(fWorldSize / 2., "Length")) + ")")
269 .c_str());
270 fDetectorRadius = aRadius;
271}
272//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
273
275{
276 // check if fits within world volume
277 if(aLength >= fWorldSize / 2.)
278 G4Exception("Par03DetectorConstruction::SetLength()", "InvalidSetup",
279 FatalException,
280 ("Detector length cannot be larger than the world size (" +
281 G4String(G4BestUnit(fWorldSize / 2., "Length")) + ")")
282 .c_str());
283 fDetectorLength = aLength;
284}
G4double fDetectorRadius
Radius of the cylindrical detector.
G4int fNbOfRhoCells
Number of cells along radius.
virtual ~Par03DetectorConstruction()
G4Material * fDetectorMaterial
Material of the detector.
G4int fNbOfPhiCells
Number of cells in azimuthal angle.
virtual G4VPhysicalVolume * Construct() final
Par03DetectorMessenger * fDetectorMessenger
Messenger that allows to modify geometry.
G4int fNbOfLayers
Number of layers = slices along z axis.
G4double fDetectorLength
Length of the cylindrical detector (along z axis)
void SetMaterial(const G4String &aMaterial)
G4double fWorldSize
World size (in each X, Y, Z dimension)
G4LogicalVolume * fLogicCell
Logical volume of replicated cell.
Example fast simulation model for EM showers.

Applications | User Support | Publications | Collaboration