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 ] [ 10.5 ] [ 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

Diff markup

Differences between /examples/extended/parameterisations/Par03/src/Par03DetectorConstruction.cc (Version 11.3.0) and /examples/extended/parameterisations/Par03/src/Par03DetectorConstruction.cc (Version 10.3)


  1 //                                                  1 
  2 // *******************************************    
  3 // * License and Disclaimer                       
  4 // *                                              
  5 // * The  Geant4 software  is  copyright of th    
  6 // * the Geant4 Collaboration.  It is provided    
  7 // * conditions of the Geant4 Software License    
  8 // * LICENSE and available at  http://cern.ch/    
  9 // * include a list of copyright holders.         
 10 // *                                              
 11 // * Neither the authors of this software syst    
 12 // * institutes,nor the agencies providing fin    
 13 // * work  make  any representation or  warran    
 14 // * regarding  this  software system or assum    
 15 // * use.  Please see the license in the file     
 16 // * for the full disclaimer and the limitatio    
 17 // *                                              
 18 // * This  code  implementation is the result     
 19 // * technical work of the GEANT4 collaboratio    
 20 // * By using,  copying,  modifying or  distri    
 21 // * any work based  on the software)  you  ag    
 22 // * use  in  resulting  scientific  publicati    
 23 // * acceptance of all terms of the Geant4 Sof    
 24 // *******************************************    
 25 //                                                
 26 #include "Par03DetectorConstruction.hh"           
 27                                                   
 28 #include "Par03DetectorMessenger.hh"              
 29 #include "Par03EMShowerModel.hh"                  
 30 #include "Par03SensitiveDetector.hh"              
 31                                                   
 32 #include "G4Box.hh"                               
 33 #include "G4LogicalVolume.hh"                     
 34 #include "G4Material.hh"                          
 35 #include "G4NistManager.hh"                       
 36 #include "G4PVPlacement.hh"                       
 37 #include "G4PVReplica.hh"                         
 38 #include "G4Region.hh"                            
 39 #include "G4RegionStore.hh"                       
 40 #include "G4RunManager.hh"                        
 41 #include "G4SDManager.hh"                         
 42 #include "G4Tubs.hh"                              
 43 #include "G4UnitsTable.hh"                        
 44 #include "G4VisAttributes.hh"                     
 45                                                   
 46 //....oooOO0OOooo........oooOO0OOooo........oo    
 47                                                   
 48 Par03DetectorConstruction::Par03DetectorConstr    
 49 {                                                 
 50   fDetectorMessenger = new Par03DetectorMessen    
 51                                                   
 52   G4NistManager* nistManager = G4NistManager::    
 53   fDetectorMaterial = nistManager->FindOrBuild    
 54 }                                                 
 55                                                   
 56 //....oooOO0OOooo........oooOO0OOooo........oo    
 57                                                   
 58 Par03DetectorConstruction::~Par03DetectorConst    
 59                                                   
 60 //....oooOO0OOooo........oooOO0OOooo........oo    
 61                                                   
 62 G4VPhysicalVolume* Par03DetectorConstruction::    
 63 {                                                 
 64   //--------- Material definition ---------       
 65   G4NistManager* nistManager = G4NistManager::    
 66   G4Material* air = nistManager->FindOrBuildMa    
 67                                                   
 68   //--------- Derived dimensions ---------        
 69   G4double full2Pi = 2. * CLHEP::pi * rad;        
 70   G4double layerThickness = fDetectorLength /     
 71   G4double cellPhi = full2Pi / fNbOfPhiCells;     
 72   G4double cellDR = fDetectorRadius / fNbOfRho    
 73                                                   
 74   //--------- World ---------                     
 75   auto fSolidWorld = new G4Box("World",  // na    
 76                                fWorldSize / 2.    
 77                                fWorldSize / 2.    
 78                                fWorldSize / 2.    
 79   auto fLogicWorld = new G4LogicalVolume(fSoli    
 80                                          air,     
 81                                          "Worl    
 82   auto fPhysicWorld = new G4PVPlacement(0,  //    
 83                                         G4Thre    
 84                                         fLogic    
 85                                         "World    
 86                                         0,  //    
 87                                         false,    
 88                                         999,      
 89                                         true);    
 90                                                   
 91   //--------- Detector envelope ---------         
 92   auto fSolidDetector = new G4Tubs("Detector",    
 93                                    0,  // inne    
 94                                    fDetectorRa    
 95                                    fDetectorLe    
 96                                    0,  // star    
 97                                    full2Pi);      
 98   auto fLogicDetector = new G4LogicalVolume(fS    
 99                                             fD    
100                                             "D    
101   new G4PVPlacement(0,  // no rotation            
102                     G4ThreeVector(0, 0,           
103                                   fDetectorLen    
104                     fLogicDetector,  // logica    
105                     "Detector",  // name          
106                     fLogicWorld,  // mother vo    
107                     false,  // not used           
108                     99,  // copy number           
109                     true);  // check overlaps     
110                                                   
111   // Region for fast simulation                   
112   auto detectorRegion = new G4Region("Detector    
113   detectorRegion->AddRootLogicalVolume(fLogicD    
114                                                   
115   //--------- Readout geometry ---------          
116   // Layers (along z)                             
117   auto fSolidLayer = new G4Tubs("Layer",  // n    
118                                 0,  // inner r    
119                                 fDetectorRadiu    
120                                 layerThickness    
121                                 0,  // start a    
122                                 full2Pi);  //     
123   auto fLogicLayer = new G4LogicalVolume(fSoli    
124                                          air,     
125                                          "Laye    
126   if (fNbOfLayers > 1)                            
127     new G4PVReplica("Layer",  // name             
128                     fLogicLayer,  // logical v    
129                     fLogicDetector,  // mother    
130                     kZAxis,  // axis of replic    
131                     fNbOfLayers,  // number of    
132                     layerThickness);  // width    
133   else                                            
134     new G4PVPlacement(0,  // no rotation          
135                       G4ThreeVector(),  // pla    
136                       fLogicLayer,  // logical    
137                       "Layer",  // name           
138                       fLogicDetector,  // moth    
139                       false,  // not used         
140                       0,  // copy number          
141                       true);  // check overlap    
142                                                   
143   // Layer segment (division in phi)              
144   auto fSolidRow = new G4Tubs("Row",  // name     
145                               0,  // inner rad    
146                               fDetectorRadius,    
147                               layerThickness /    
148                               0,  // start ang    
149                               cellPhi);  // de    
150                                                   
151   auto fLogicRow = new G4LogicalVolume(fSolidR    
152                                        air,  /    
153                                        "Segmen    
154   if (fNbOfPhiCells > 1)                          
155     new G4PVReplica("Segment",  // name           
156                     fLogicRow,  // logical vol    
157                     fLogicLayer,  // mother vo    
158                     kPhi,  // axis of replicat    
159                     fNbOfPhiCells,  // number     
160                     cellPhi);  // width of sin    
161   else                                            
162     new G4PVPlacement(0,  // no rotation          
163                       G4ThreeVector(),  // pla    
164                       fLogicRow,  // logical v    
165                       "Row",  // name             
166                       fLogicLayer,  // mother     
167                       false,  // not used         
168                       0,  // copy number          
169                       true);  // check overlap    
170                                                   
171   // Final cells (segment slices in radius)       
172   // No volume can be placed inside a radial r    
173   auto fSolidCell = new G4Tubs("Cell",  // nam    
174                                0,  // inner ra    
175                                cellDR,  // out    
176                                layerThickness     
177                                0,  // start an    
178                                cellPhi);  // d    
179                                                   
180   fLogicCell = new G4LogicalVolume(fSolidCell,    
181                                    fDetectorMa    
182                                    "Cell");  /    
183   if (fNbOfRhoCells > 1)                          
184     new G4PVReplica("Cell",  // name              
185                     fLogicCell,  // logical vo    
186                     fLogicRow,  // mother volu    
187                     kRho,  // axis of replicat    
188                     fNbOfRhoCells,  // number     
189                     cellDR);  // width of sing    
190   else                                            
191     new G4PVPlacement(0,  // no rotation          
192                       G4ThreeVector(),  // pla    
193                       fLogicCell,  // logical     
194                       "Cell",  // name            
195                       fLogicRow,  // mother vo    
196                       false,  // not used         
197                       0,  // copy number          
198                       true);  // check overlap    
199                                                   
200   //--------- Visualisation settings ---------    
201   fLogicWorld->SetVisAttributes(G4VisAttribute    
202   fLogicLayer->SetVisAttributes(G4VisAttribute    
203   fLogicRow->SetVisAttributes(G4VisAttributes:    
204   G4VisAttributes attribs;                        
205   attribs.SetColour(G4Colour(0, 0, 1, 0.3));      
206   attribs.SetForceSolid(true);                    
207   fLogicCell->SetVisAttributes(attribs);          
208                                                   
209   Print();                                        
210   return fPhysicWorld;                            
211 }                                                 
212                                                   
213 //....oooOO0OOooo........oooOO0OOooo........oo    
214                                                   
215 void Par03DetectorConstruction::ConstructSDand    
216 {                                                 
217   Par03SensitiveDetector* caloSD =                
218     new Par03SensitiveDetector("sensitiveDetec    
219   G4SDManager::GetSDMpointer()->AddNewDetector    
220   SetSensitiveDetector(fLogicCell, caloSD);       
221                                                   
222   auto detectorRegion = G4RegionStore::GetInst    
223   new Par03EMShowerModel("model", detectorRegi    
224 }                                                 
225                                                   
226 //....oooOO0OOooo........oooOO0OOooo........oo    
227                                                   
228 void Par03DetectorConstruction::Print() const     
229 {                                                 
230   G4cout << "\n-------------------------------    
231          << "\n--- Detector material:\t" << fD    
232          << "\n--- Detector length:\t" << G4Be    
233          << "\n--- Detector radius:\t" << G4Be    
234          << "\n--- Number of layers:\t" << fNb    
235          << fNbOfRhoCells << "\n--- Number of     
236   G4cout << "---------------------------------    
237 }                                                 
238                                                   
239 //....oooOO0OOooo........oooOO0OOooo........oo    
240                                                   
241 void Par03DetectorConstruction::SetMaterial(co    
242 {                                                 
243   // search material by its name                  
244   G4Material* material = G4NistManager::Instan    
245   if (material)                                   
246     fDetectorMaterial = material;                 
247   else                                            
248     G4Exception("Par03DetectorConstruction::Se    
249                 ("Unknown material name: " + a    
250   G4RunManager::GetRunManager()->PhysicsHasBee    
251 }                                                 
252                                                   
253 //....oooOO0OOooo........oooOO0OOooo........oo    
254                                                   
255 void Par03DetectorConstruction::SetRadius(G4do    
256 {                                                 
257   // check if fits within world volume            
258   if (aRadius >= fWorldSize / 2.)                 
259     G4Exception("Par03DetectorConstruction::Se    
260                 ("Detector radius cannot be la    
261                  + G4String(G4BestUnit(fWorldS    
262                   .c_str());                      
263   fDetectorRadius = aRadius;                      
264 }                                                 
265 //....oooOO0OOooo........oooOO0OOooo........oo    
266                                                   
267 void Par03DetectorConstruction::SetLength(G4do    
268 {                                                 
269   // check if fits within world volume            
270   if (aLength >= fWorldSize / 2.)                 
271     G4Exception("Par03DetectorConstruction::Se    
272                 ("Detector length cannot be la    
273                  + G4String(G4BestUnit(fWorldS    
274                   .c_str());                      
275   fDetectorLength = aLength;                      
276 }