Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-06-22 07:53:42

0001 //
0002 // ********************************************************************
0003 // * License and Disclaimer                                           *
0004 // *                                                                  *
0005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
0006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
0007 // * conditions of the Geant4 Software License,  included in the file *
0008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
0009 // * include a list of copyright holders.                             *
0010 // *                                                                  *
0011 // * Neither the authors of this software system, nor their employing *
0012 // * institutes,nor the agencies providing financial support for this *
0013 // * work  make  any representation or  warranty, express or implied, *
0014 // * regarding  this  software system or assume any liability for its *
0015 // * use.  Please see the license in the file  LICENSE  and URL above *
0016 // * for the full disclaimer and the limitation of liability.         *
0017 // *                                                                  *
0018 // * This  code  implementation is the result of  the  scientific and *
0019 // * technical work of the GEANT4 collaboration.                      *
0020 // * By using,  copying,  modifying or  distributing the software (or *
0021 // * any work based  on the software)  you  agree  to acknowledge its *
0022 // * use  in  resulting  scientific  publications,  and indicate your *
0023 // * acceptance of all terms of the Geant4 Software license.          *
0024 // ********************************************************************
0025 //
0026 /// \file F05DetectorConstruction.cc
0027 /// \brief Implementation of the F05DetectorConstruction class
0028 
0029 #include "F05DetectorConstruction.hh"
0030 
0031 #include "F05Field.hh"
0032 
0033 #include "G4Box.hh"
0034 #include "G4Colour.hh"
0035 #include "G4FieldManager.hh"
0036 #include "G4GeometryManager.hh"
0037 #include "G4LogicalVolume.hh"
0038 #include "G4LogicalVolumeStore.hh"
0039 #include "G4Material.hh"
0040 #include "G4NistManager.hh"
0041 #include "G4PVPlacement.hh"
0042 #include "G4PhysicalVolumeStore.hh"
0043 #include "G4SolidStore.hh"
0044 #include "G4SystemOfUnits.hh"
0045 #include "G4TransportationManager.hh"
0046 #include "G4UserLimits.hh"
0047 #include "G4VisAttributes.hh"
0048 
0049 // #include "G4RepleteEofM.hh"
0050 #include "G4ChordFinder.hh"
0051 #include "G4ClassicalRK4.hh"
0052 #include "G4EqEMFieldWithSpin.hh"
0053 #include "G4MagIntegratorStepper.hh"
0054 #include "G4PropagatorInField.hh"
0055 
0056 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0057 
0058 F05DetectorConstruction::F05DetectorConstruction() : fVacuum(nullptr)
0059 {
0060   // materials
0061   DefineMaterials();
0062 }
0063 
0064 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0065 
0066 F05DetectorConstruction::~F05DetectorConstruction()
0067 {
0068   delete fField;
0069 }
0070 
0071 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0072 
0073 void F05DetectorConstruction::DefineMaterials()
0074 {
0075   G4NistManager* nistMan = G4NistManager::Instance();
0076 
0077   fVacuum = nistMan->FindOrBuildMaterial("G4_Galactic");
0078 
0079   G4cout << *(G4Material::GetMaterialTable()) << G4endl;
0080 }
0081 
0082 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0083 
0084 G4VPhysicalVolume* F05DetectorConstruction::Construct()
0085 {
0086   //
0087   // World
0088   //
0089 
0090   G4double worldSizeXY = 20.0 * m;
0091   G4double worldSizeZ = 1.0 * mm;
0092 
0093   auto solidWorld = new G4Box("World",  // its name
0094                               worldSizeXY / 2, worldSizeXY / 2, worldSizeZ / 2);  // its size
0095 
0096   auto logicWorld = new G4LogicalVolume(solidWorld,  // its solid
0097                                         fVacuum,  // its material
0098                                         "World");  // its name
0099 
0100   auto physiWorld = new G4PVPlacement(nullptr,  // no rotation
0101                                       G4ThreeVector(),  // at (0,0,0)
0102                                       logicWorld,  // its logical volume
0103                                       "World",  // its name
0104                                       nullptr,  // its mother  volume
0105                                       false,  // no boolean operation
0106                                       0);  // copy number
0107 
0108   G4UserLimits* stepLimit;
0109   stepLimit = new G4UserLimits(5 * mm);
0110 
0111   logicWorld->SetUserLimits(stepLimit);
0112 
0113   //
0114   // Visualization attributes
0115   //
0116   // fLogicWorld->SetVisAttributes (G4VisAttributes::GetInvisible());
0117 
0118   //
0119   // always return the physical World
0120   //
0121   return physiWorld;
0122 }
0123 
0124 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0125 
0126 G4ThreadLocal F05Field* F05DetectorConstruction::fField = nullptr;
0127 
0128 void F05DetectorConstruction::ConstructSDandField()
0129 
0130 {
0131   if (!fField) {
0132     fField = new F05Field();
0133 
0134     //     G4RepleteEofM* equation = new G4RepleteEofM(fField);
0135     auto equation = new G4EqEMFieldWithSpin(fField);
0136     //     equation->SetBField();
0137     //     equation->SetEField();
0138     //     equation->SetSpin();
0139 
0140     G4FieldManager* fieldManager =
0141       G4TransportationManager::GetTransportationManager()->GetFieldManager();
0142     fieldManager->SetDetectorField(fField);
0143 
0144     G4MagIntegratorStepper* stepper = new G4ClassicalRK4(equation, 12);
0145 
0146     G4double minStep = 0.01 * mm;
0147 
0148     auto chordFinder = new G4ChordFinder((G4MagneticField*)fField, minStep, stepper);
0149 
0150     // Set accuracy parameters
0151     G4double deltaChord = 3.0 * mm;
0152     chordFinder->SetDeltaChord(deltaChord);
0153 
0154     // Maximum allowed integration error in one integration sub-step
0155     G4double deltaOneStep = 0.01 * mm;
0156     fieldManager->SetAccuraciesWithDeltaOneStep(deltaOneStep);
0157 
0158     G4double deltaIntersection = 0.1 * mm;
0159     fieldManager->SetDeltaIntersection(deltaIntersection);
0160 
0161     G4TransportationManager* transportManager = G4TransportationManager::GetTransportationManager();
0162 
0163     G4PropagatorInField* fieldPropagator = transportManager->GetPropagatorInField();
0164 
0165     // Limits for relative accuracy of integration
0166     G4double epsMin = 2.5e-7;
0167     G4double epsMax = 0.001;
0168 
0169     fieldPropagator->SetMinimumEpsilonStep(epsMin);
0170     fieldPropagator->SetMaximumEpsilonStep(epsMax);
0171 
0172     fieldManager->SetChordFinder(chordFinder);
0173   }
0174 }
0175 
0176 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......