Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-02-23 09:21:19

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 //
0027 /// \file field/field05/src/F05DetectorConstruction.cc
0028 /// \brief Implementation of the F05DetectorConstruction class
0029 //
0030 
0031 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0032 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0033 
0034 #include "F05DetectorConstruction.hh"
0035 
0036 #include "F05Field.hh"
0037 
0038 #include "G4Box.hh"
0039 #include "G4Colour.hh"
0040 #include "G4FieldManager.hh"
0041 #include "G4GeometryManager.hh"
0042 #include "G4LogicalVolume.hh"
0043 #include "G4LogicalVolumeStore.hh"
0044 #include "G4Material.hh"
0045 #include "G4NistManager.hh"
0046 #include "G4PVPlacement.hh"
0047 #include "G4PhysicalVolumeStore.hh"
0048 #include "G4SolidStore.hh"
0049 #include "G4SystemOfUnits.hh"
0050 #include "G4TransportationManager.hh"
0051 #include "G4UserLimits.hh"
0052 #include "G4VisAttributes.hh"
0053 
0054 // #include "G4RepleteEofM.hh"
0055 #include "G4ChordFinder.hh"
0056 #include "G4ClassicalRK4.hh"
0057 #include "G4EqEMFieldWithSpin.hh"
0058 #include "G4MagIntegratorStepper.hh"
0059 #include "G4PropagatorInField.hh"
0060 
0061 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0062 
0063 F05DetectorConstruction::F05DetectorConstruction() : fVacuum(nullptr)
0064 {
0065   // materials
0066   DefineMaterials();
0067 }
0068 
0069 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0070 
0071 F05DetectorConstruction::~F05DetectorConstruction()
0072 {
0073   delete fField;
0074 }
0075 
0076 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0077 
0078 void F05DetectorConstruction::DefineMaterials()
0079 {
0080   G4NistManager* nistMan = G4NistManager::Instance();
0081 
0082   fVacuum = nistMan->FindOrBuildMaterial("G4_Galactic");
0083 
0084   G4cout << *(G4Material::GetMaterialTable()) << G4endl;
0085 }
0086 
0087 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0088 
0089 G4VPhysicalVolume* F05DetectorConstruction::Construct()
0090 {
0091   //
0092   // World
0093   //
0094 
0095   G4double worldSizeXY = 20.0 * m;
0096   G4double worldSizeZ = 1.0 * mm;
0097 
0098   auto solidWorld = new G4Box("World",  // its name
0099                               worldSizeXY / 2, worldSizeXY / 2, worldSizeZ / 2);  // its size
0100 
0101   auto logicWorld = new G4LogicalVolume(solidWorld,  // its solid
0102                                         fVacuum,  // its material
0103                                         "World");  // its name
0104 
0105   auto physiWorld = new G4PVPlacement(nullptr,  // no rotation
0106                                       G4ThreeVector(),  // at (0,0,0)
0107                                       logicWorld,  // its logical volume
0108                                       "World",  // its name
0109                                       nullptr,  // its mother  volume
0110                                       false,  // no boolean operation
0111                                       0);  // copy number
0112 
0113   G4UserLimits* stepLimit;
0114   stepLimit = new G4UserLimits(5 * mm);
0115 
0116   logicWorld->SetUserLimits(stepLimit);
0117 
0118   //
0119   // Visualization attributes
0120   //
0121   // fLogicWorld->SetVisAttributes (G4VisAttributes::GetInvisible());
0122 
0123   //
0124   // always return the physical World
0125   //
0126   return physiWorld;
0127 }
0128 
0129 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0130 
0131 G4ThreadLocal F05Field* F05DetectorConstruction::fField = nullptr;
0132 
0133 void F05DetectorConstruction::ConstructSDandField()
0134 
0135 {
0136   if (!fField) {
0137     fField = new F05Field();
0138 
0139     //     G4RepleteEofM* equation = new G4RepleteEofM(fField);
0140     auto equation = new G4EqEMFieldWithSpin(fField);
0141     //     equation->SetBField();
0142     //     equation->SetEField();
0143     //     equation->SetSpin();
0144 
0145     G4FieldManager* fieldManager =
0146       G4TransportationManager::GetTransportationManager()->GetFieldManager();
0147     fieldManager->SetDetectorField(fField);
0148 
0149     G4MagIntegratorStepper* stepper = new G4ClassicalRK4(equation, 12);
0150 
0151     G4double minStep = 0.01 * mm;
0152 
0153     auto chordFinder = new G4ChordFinder((G4MagneticField*)fField, minStep, stepper);
0154 
0155     // Set accuracy parameters
0156     G4double deltaChord = 3.0 * mm;
0157     chordFinder->SetDeltaChord(deltaChord);
0158 
0159     // Maximum allowed integration error in one integration sub-step
0160     G4double deltaOneStep = 0.01 * mm;
0161     fieldManager->SetAccuraciesWithDeltaOneStep(deltaOneStep);
0162 
0163     G4double deltaIntersection = 0.1 * mm;
0164     fieldManager->SetDeltaIntersection(deltaIntersection);
0165 
0166     G4TransportationManager* transportManager = G4TransportationManager::GetTransportationManager();
0167 
0168     G4PropagatorInField* fieldPropagator = transportManager->GetPropagatorInField();
0169 
0170     // Limits for relative accuracy of integration
0171     G4double epsMin = 2.5e-7;
0172     G4double epsMax = 0.001;
0173 
0174     fieldPropagator->SetMinimumEpsilonStep(epsMin);
0175     fieldPropagator->SetMaximumEpsilonStep(epsMax);
0176 
0177     fieldManager->SetChordFinder(chordFinder);
0178   }
0179 }
0180 
0181 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......