Loading...
Searching...
No Matches
Par04ParallelFullWorld.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//
26
27// User Classes
31
32// G4 Classes
33#include "G4NistManager.hh"
34#include "G4Material.hh"
35#include "G4ThreeVector.hh"
36#include "G4PVPlacement.hh"
37#include "G4PVReplica.hh"
38#include "G4VPhysicalVolume.hh"
39#include "G4LogicalVolume.hh"
40#include "G4Tubs.hh"
41#include "G4SDManager.hh"
42#include "G4VisAttributes.hh"
43#include "G4Colour.hh"
44#include "G4SystemOfUnits.hh"
45#include "G4AutoDelete.hh"
46#include "globals.hh"
47#include "G4UnitsTable.hh"
48
49
50//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
51
53 const Par04DetectorConstruction* aMassDetector)
54 :G4VUserParallelWorld(aWorldName), fMassDetector(aMassDetector) {
57}
58
59//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
60
62
63//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
64
66{
67 // In parallel world material does not matter
68 G4Material* dummy = nullptr;
69
70 // Build parallel geometry:
71 auto parallelLogicalVolume = GetWorld()->GetLogicalVolume();
72
73 G4double detectorInnerRadius = fMassDetector->GetInnerRadius();
74 G4double detectorLength = fMassDetector->GetLength();
75 G4double fullLayerThickness = fMassDetector->GetAbsorberThickness(0)
77 G4double sensitiveLayerOffset = 0;
80 else
81 sensitiveLayerOffset = fMassDetector->GetAbsorberThickness(0);
84
85 fNbOfLayers = fMassDetector->GetNbOfLayers(); // Get an updated value
86 G4double detectorRadius = fNbOfLayers * fullLayerThickness;
87 G4double detectorOuterRadius = detectorInnerRadius + detectorRadius;
88 G4double rowThickness = detectorLength / fNbOfRows;
89 G4double full2Pi = 2.* CLHEP::pi * rad;
90 Print();
91
92 // Insert cells to create a readout structure that contains both passive and active materials
93 // Mostly a copy from the detector construction
94 auto solidDetector = new G4Tubs("Detector", // name
95 detectorInnerRadius, // inner radius
96 detectorOuterRadius, // outer radius
97 detectorLength / 2., // half-width in Z
98 0, // start angle
99 full2Pi); // delta angle
100 auto logicDetector = new G4LogicalVolume(solidDetector, // solid
101 dummy, // material
102 "Detector"); // name
103 new G4PVPlacement(0, // no rotation
104 G4ThreeVector(0, 0, 0), // detector centre at (0,0,0)
105 logicDetector, // logical volume
106 "Detector", // name
107 parallelLogicalVolume, // mother volume
108 false, // not used
109 9999, // copy number
110 true); // check overlaps
111
112
113 //--------- Detector cylinder (division along z axis) ---------
114 auto solidRow = new G4Tubs("Row", detectorInnerRadius, detectorOuterRadius, rowThickness / 2.,
115 0, full2Pi);
116
117 auto logicRow = new G4LogicalVolume(solidRow, dummy, "Row");
118 if (fNbOfRows > 1)
119 new G4PVReplica("Row",
120 logicRow,
121 logicDetector,
122 kZAxis,
123 fNbOfRows,
124 rowThickness);
125 else
126 new G4PVPlacement(0,
127 G4ThreeVector(),
128 logicRow,
129 "Row",
130 logicDetector,
131 false,
132 0);
133
134 //--------- Detector slices (division in azimuthal angle) ---------
135 G4double cellPhi = full2Pi / fNbOfSlices;
136 auto solidSlice = new G4Tubs("Slice", detectorInnerRadius, detectorOuterRadius, rowThickness/2,
137 0, cellPhi);
138 auto logicSlice = new G4LogicalVolume(solidSlice,
139 dummy,
140 "Slice");
141 if(fNbOfLayers>1 && fullLayerThickness == fLayerThickness) {
142 new G4PVReplica("Slice",
143 logicSlice,
144 logicRow,
145 kPhi,
147 cellPhi,
148 -cellPhi);
149 } else {
150 // full simulation readout, cannot use replica because of gaps between absorbers
151 for (int iSlice = 0; iSlice<fNbOfSlices; iSlice++) {
152 auto rotation = new G4RotationMatrix();
153 rotation->setPhi((iSlice+0.5)*cellPhi);
154 new G4PVPlacement(rotation,
155 G4ThreeVector(),
156 logicSlice,
157 "Slice_"+std::to_string(iSlice),
158 logicRow,
159 false,
160 iSlice);
161 }
162 }
163
164 //--------- Detector cells (division along radial axis) ---------
165 G4VisAttributes attribs;
166 attribs.SetColour(G4Colour(0, 1, 0, 0.1));
167 attribs.SetForceSolid(true);
168 if(fNbOfLayers>1 && fullLayerThickness == fLayerThickness) {
169 auto solidCell = new G4Tubs("Cell", detectorInnerRadius + sensitiveLayerOffset,
170 detectorInnerRadius + sensitiveLayerOffset + fLayerThickness,
171 rowThickness/2, 0, cellPhi);
172 fLogicalCell.push_back(new G4LogicalVolume(solidCell, dummy, "Cell_0"));
173 new G4PVReplica("Cell",
174 fLogicalCell.back(),
175 logicSlice,
176 kRho,
179 detectorInnerRadius);
180 } else {
181 // full simulation readout, cannot use replica because of gaps between absorbers
182 for (int iLayer = 0; iLayer<fNbOfLayers; iLayer++) {
183 auto solidCell = new G4Tubs("Cell_"+std::to_string(iLayer),
184 detectorInnerRadius + iLayer * fullLayerThickness
185 + sensitiveLayerOffset,
186 detectorInnerRadius + iLayer * fullLayerThickness
187 + sensitiveLayerOffset + fLayerThickness,
188 rowThickness/2, 0, cellPhi);
189 fLogicalCell.push_back(new G4LogicalVolume(solidCell, dummy, "Cell_"+std::to_string(iLayer)));
190 fLogicalCell.back()->SetVisAttributes(attribs);
191 new G4PVPlacement(0,
192 G4ThreeVector(),
193 fLogicalCell.back(),
194 "Cell_"+std::to_string(iLayer),
195 logicSlice,
196 false,
197 iLayer);
198 }
199 }
200 Print();
201}
202
203//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
204
206{
207 // -- sensitive detectors:
208 G4SDManager* SDman = G4SDManager::GetSDMpointer();
211 SDman->AddNewDetector(caloSD);
212 for(const auto& logicalCell: fLogicalCell)
213 logicalCell->SetSensitiveDetector(caloSD);
214}
215
216//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
217
219 G4cout << "\n------------------------------------------------------"
220 << "\n Readout geometry with physics layout is set in parallel geometry:\t"
221 << "\n Cylindrical detector is divided along radius (layers), phi (slices), and z (rows)."
222 << "\n Number of layers is determined by number of layers set in detector construction. "
223 << "\n- Number of layers: " << fNbOfLayers << "\n------- Number of slices: " << fNbOfSlices
224 << "\n- Number of rows: " << fNbOfRows;
225 G4cout << "\n Readout will collect energy for full simulation.\n------- Therefore thickness is "
226 << "only a thickness of sensitive absorbers = " << G4BestUnit(fLayerThickness, "Length")
227 << "\n-----------------------------------------------------" << G4endl;
228}
G4double GetLength() const
Get length of the cylindrical detector (along z-axis)
G4double GetAbsorberThickness(const std::size_t aLayer) const
Get thickness of the layer.
G4int GetNbOfLayers() const
Get number of layers.
G4double GetInnerRadius() const
Get inner radius of the cylindrical detector.
G4bool GetAbsorberSensitivity(const std::size_t aLayer) const
Get sensitivity of the layer.
Par04ParallelMessenger * fParallelMessenger
Messenger that allows to modify geometry.
std::vector< G4LogicalVolume * > fLogicalCell
const Par04DetectorConstruction * fMassDetector
Par04ParallelFullWorld(G4String aWorldName, const Par04DetectorConstruction *aMassDetector)
virtual void Construct() final
virtual void ConstructSD() final

Applications | User Support | Publications | Collaboration