ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DetectorConstruction.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file DetectorConstruction.cc
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 //
28 //
29 //
30 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
31 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
32 
33 #include "DetectorConstruction.hh"
34 #include "DetectorMessenger.hh"
35 
36 #include "G4Material.hh"
37 #include "G4Box.hh"
38 #include "G4LogicalVolume.hh"
39 #include "G4PVPlacement.hh"
40 #include "G4UniformMagField.hh"
41 
42 #include "G4GeometryManager.hh"
43 #include "G4UserLimits.hh"
44 #include "G4PhysicalVolumeStore.hh"
45 #include "G4LogicalVolumeStore.hh"
46 #include "G4SolidStore.hh"
47 #include "G4StateManager.hh"
48 
49 #include "G4UnitsTable.hh"
50 #include "G4NistManager.hh"
51 
52 #include "G4MonopoleFieldSetup.hh"
53 //#include "G4FieldManager.hh"
54 //#include "G4TransportationManager.hh"
55 #include "G4ThreeVector.hh"
56 #include "G4RunManager.hh"
57 #include "G4SystemOfUnits.hh"
58 
60 #include "G4AutoDelete.hh"
61 
62 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
63 
66  fWorldMaterial(0),
67  fAbsorMaterial(0),
68  fLogAbsor(0),
69  fMonFieldSetup(),
70  fDetectorMessenger(0)
71 {
72  // default parameter values
73  fAbsorSizeX = fAbsorSizeYZ = 10 * cm;
75  fMaxStepSize = 5 * mm;
76 
77  SetMaterial("G4_Al");
80 
81  // create commands for interactive definition of the detector
83 }
84 
85 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
86 
88 {
89  delete fDetectorMessenger;
90  // delete fMonFieldSetup;
91 }
92 
93 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
94 
96 {
101 
102  /**************************** World *****************************/
103  G4Box * sWorld = new G4Box("world",
104  fWorldSizeX / 2, fWorldSizeYZ / 2, fWorldSizeYZ / 2);
105 
106  G4LogicalVolume * lWorld = new G4LogicalVolume(sWorld,
108  "world");
109 
110  G4VPhysicalVolume * pWorld = new G4PVPlacement(0, //no rotation
111  G4ThreeVector(), //at (0,0,0)
112  lWorld, //logical volume
113  "world", //name
114  0, //mother volume
115  false, //no boolean operation
116  0); //copy number
117 
118 
119  /************************** Absorber ***************************/
120  G4Box * sAbsor = new G4Box("Absorber",
121  fAbsorSizeX / 2, fAbsorSizeYZ / 2, fAbsorSizeYZ / 2);
122 
123  fLogAbsor = new G4LogicalVolume(sAbsor,
125  "Absorber");
126 
127  new G4PVPlacement(0, //no rotation
128  G4ThreeVector(), //at (0,0,0)
129  fLogAbsor, //logical volume
130  "Absorber", //name
131  lWorld, //mother volume
132  false, //no boolean operation
133  0); //copy number
135 
136  PrintParameters();
137 
138  /************ always return the World volume *****************/
139  return pWorld;
140 }
141 
142 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
143 
145 {
146  G4cout << "\n---------------------------------------------------------\n";
147  G4cout << "---> The Absorber is " << G4BestUnit(fAbsorSizeX, "Length")
148  << " of " << fAbsorMaterial->GetName() << G4endl;
149  G4cout << "\n---------------------------------------------------------\n";
150 
151 }
152 
153 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
154 
156 {
157  if(value > 0.0) {
158  fAbsorSizeX = value;
159  fWorldSizeX = 1.2 * fAbsorSizeX;
160  if ( G4StateManager::GetStateManager()->GetCurrentState() != G4State_PreInit ) {
162  }
163  }
164 }
165 
166 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
167 
169 {
170  if(value > 0.0) {
171  fAbsorSizeYZ = value;
172  fWorldSizeYZ = 1.2 * fAbsorSizeYZ;
173  if ( G4StateManager::GetStateManager()->GetCurrentState() != G4State_PreInit ) {
175  }
176  }
177 }
178 
179 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
180 
181 void DetectorConstruction::SetMaterial(const G4String& namemat)
182 {
183  // search the material by its name
185  if(!mat) {
186  G4cout << "!!! DetectorConstruction::SetMaterial: WARNING Material <"
187  << namemat << "> does not exist in DB" << G4endl;
188  return;
189  }
190  // new material is found out
191  if (mat != fAbsorMaterial) {
193  if(fLogAbsor) { fLogAbsor->SetMaterial(mat); }
195  }
196 }
197 
198 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
199 
201 {
202  // Define magnetic field
203  if ( ! fMonFieldSetup.Get() ) {
204  G4MonopoleFieldSetup* fieldSetup
205  = new G4MonopoleFieldSetup();
206  G4AutoDelete::Register(fieldSetup); // Kernel will delete the F01FieldSetup
207  fMonFieldSetup.Put(fieldSetup);
208  }
209  fMonFieldSetup.Get()->ConstructMagField(); // add field value
210 }
211 
212 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
213 
215 {
216  fMaxStepSize = step;
218 }
219 
220 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......