ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
F06DetectorConstruction.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file F06DetectorConstruction.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 //
26 //
29 //
30 
31 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
32 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
33 
35 
36 #include "G4Material.hh"
37 #include "G4NistManager.hh"
38 
39 #include "G4Box.hh"
40 #include "G4LogicalVolume.hh"
41 #include "G4PVPlacement.hh"
42 
43 #include "G4GeometryManager.hh"
44 #include "G4PhysicalVolumeStore.hh"
45 #include "G4LogicalVolumeStore.hh"
46 #include "G4SolidStore.hh"
47 
48 #include "G4VisAttributes.hh"
49 #include "G4Colour.hh"
50 
51 #include "G4UserLimits.hh"
52 #include "G4SystemOfUnits.hh"
53 
54 #include "G4UniformGravityField.hh"
55 
56 #include "G4FieldManager.hh"
58 
59 #include "G4RepleteEofM.hh"
60 //#include "G4EqGravityField.hh"
61 
62 #include "G4ClassicalRK4.hh"
64 #include "G4IntegrationDriver.hh"
65 #include "G4ChordFinder.hh"
66 #include "G4PropagatorInField.hh"
67 
68 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
69 
71  : fVacuum(0), fSolidWorld(0), fLogicWorld(0), fPhysiWorld(0)
72 {
73  // materials
75 }
76 
77 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
78 
80 {
81  if (fField) delete fField;
82 }
83 
84 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
85 
87 {
89 
90  fVacuum = nistMan->FindOrBuildMaterial("G4_Galactic");
91 
93 }
94 
95 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
96 
98 {
99  //
100  // World
101  //
102 
103  G4double expHall_x = 1.0*m;
104  G4double expHall_y = 1.0*m;
105  G4double expHall_z = 1.0*m;
106 
107  fSolidWorld = new G4Box("World", //its name
108  expHall_x,expHall_y,expHall_z); //its size
109 
110  fLogicWorld = new G4LogicalVolume(fSolidWorld, //its solid
111  fVacuum, //its material
112  "World"); //its name
113 
114  fPhysiWorld = new G4PVPlacement(0, //no rotation
115  G4ThreeVector(), //at (0,0,0)
116  fLogicWorld, //its logical volume
117  "World", //its name
118  0, //its mother volume
119  false, //no boolean operation
120  0); //copy number
121 
122  G4double maxStep = 1.0*mm;
123  G4double maxTime = 41.*s;
124 
125  G4UserLimits* stepLimit = new G4UserLimits(maxStep,DBL_MAX,maxTime);
126 
127  fLogicWorld->SetUserLimits(stepLimit);
128 
129  //
130  // Visualization attributes
131  //
132  // fLogicWorld->SetVisAttributes (G4VisAttributes::GetInvisible());
133 
134  //
135  //always return the physical World
136  //
137  return fPhysiWorld;
138 }
139 
140 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
141 
143 
145 {
146  using StepperType = G4ClassicalRK4;
147 
148  if (!fField) {
149 
151 
152  G4RepleteEofM* equation = new G4RepleteEofM(fField);
153 // G4EqGravityField* equation = new G4EqGravityField(fField);
154 
155  G4TransportationManager* transportMgr =
157 
158  G4FieldManager* fieldManager= transportMgr->GetFieldManager();
159  fieldManager->SetDetectorField(fField);
160 
161  const int nVar= 8; // 12 for RepleteEofM
162  StepperType* stepper = new StepperType(equation,nVar);
163 
164  G4double minStep = 0.01*mm;
165  G4ChordFinder* chordFinder = nullptr;
166  if( stepper )
167  {
168  auto intgrDriver = new G4IntegrationDriver<StepperType>(minStep,
169  stepper,
170  stepper->GetNumberOfVariables());
171  if( intgrDriver ){
172  chordFinder = new G4ChordFinder(intgrDriver);
173  }
174  }
175 
176  // OLD -- and wrong
177  // new G4ChordFinder((G4MagneticField*)fField,minStep,stepper);
178 
179  // Set accuracy parameters
180  G4double deltaChord = 3.0*mm;
181  chordFinder->SetDeltaChord( deltaChord );
182 
183  G4double deltaIntersection = 0.1*mm;
184  fieldManager->SetDeltaIntersection(deltaIntersection);
185 
186  // Control accuracy of integration
187  //
188  G4double deltaOneStep = 0.01*mm;
189  fieldManager->SetAccuraciesWithDeltaOneStep(deltaOneStep);
190  //
191  G4double epsMax = 1.0e-4; // Pure number -- maximum relative integration error
192  G4double epsMin = 2.5e-7; //
193  fieldManager->SetMinimumEpsilonStep(epsMin);
194  fieldManager->SetMaximumEpsilonStep(epsMax);
195  // The acceptable relative accuracy is calculated as deltaOneStep / stepsize
196  // but bounded to the interval between these values!
197 
198  fieldManager->SetChordFinder(chordFinder);
199  }
200 }
201 
202 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......