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/field06/src/F06DetectorConstruction.cc
0028 /// \brief Implementation of the F06DetectorConstruction class
0029 //
0030 
0031 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0032 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0033 
0034 #include "F06DetectorConstruction.hh"
0035 
0036 #include "G4Box.hh"
0037 #include "G4Colour.hh"
0038 #include "G4FieldManager.hh"
0039 #include "G4GeometryManager.hh"
0040 #include "G4LogicalVolume.hh"
0041 #include "G4LogicalVolumeStore.hh"
0042 #include "G4Material.hh"
0043 #include "G4NistManager.hh"
0044 #include "G4PVPlacement.hh"
0045 #include "G4PhysicalVolumeStore.hh"
0046 #include "G4RepleteEofM.hh"
0047 #include "G4SolidStore.hh"
0048 #include "G4SystemOfUnits.hh"
0049 #include "G4TransportationManager.hh"
0050 #include "G4UniformGravityField.hh"
0051 #include "G4UserLimits.hh"
0052 #include "G4VisAttributes.hh"
0053 // #include "G4EqGravityField.hh"
0054 
0055 #include "G4ChordFinder.hh"
0056 #include "G4ClassicalRK4.hh"
0057 #include "G4IntegrationDriver.hh"
0058 #include "G4MagIntegratorStepper.hh"
0059 #include "G4PropagatorInField.hh"
0060 
0061 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0062 
0063 F06DetectorConstruction::F06DetectorConstruction() : fVacuum(nullptr)
0064 {
0065   // materials
0066   DefineMaterials();
0067 }
0068 
0069 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0070 
0071 F06DetectorConstruction::~F06DetectorConstruction()
0072 {
0073   delete fField;
0074 }
0075 
0076 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0077 
0078 void F06DetectorConstruction::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* F06DetectorConstruction::Construct()
0090 {
0091   //
0092   // World
0093   //
0094 
0095   G4double expHall_x = 1.0 * m;
0096   G4double expHall_y = 1.0 * m;
0097   G4double expHall_z = 1.0 * m;
0098 
0099   auto solidWorld = new G4Box("World",  // its name
0100                               expHall_x, expHall_y, expHall_z);  // its size
0101 
0102   auto logicWorld = new G4LogicalVolume(solidWorld,  // its solid
0103                                         fVacuum,  // its material
0104                                         "World");  // its name
0105 
0106   auto physiWorld = new G4PVPlacement(nullptr,  // no rotation
0107                                       G4ThreeVector(),  // at (0,0,0)
0108                                       logicWorld,  // its logical volume
0109                                       "World",  // its name
0110                                       nullptr,  // its mother  volume
0111                                       false,  // no boolean operation
0112                                       0);  // copy number
0113 
0114   G4double maxStep = 1.0 * mm;
0115   G4double maxTime = 41. * s;
0116 
0117   auto stepLimit = new G4UserLimits(maxStep, DBL_MAX, maxTime);
0118 
0119   logicWorld->SetUserLimits(stepLimit);
0120 
0121   //
0122   // Visualization attributes
0123   //
0124   // logicWorld->SetVisAttributes (G4VisAttributes::GetInvisible());
0125 
0126   //
0127   // always return the physical World
0128   //
0129   return physiWorld;
0130 }
0131 
0132 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0133 
0134 G4ThreadLocal G4UniformGravityField* F06DetectorConstruction::fField = nullptr;
0135 
0136 void F06DetectorConstruction::ConstructSDandField()
0137 {
0138   using StepperType = G4ClassicalRK4;
0139 
0140   if (!fField) {
0141     fField = new G4UniformGravityField();
0142 
0143     auto equation = new G4RepleteEofM(fField);
0144     //     G4EqGravityField* equation = new G4EqGravityField(fField);
0145 
0146     G4TransportationManager* transportMgr = G4TransportationManager::GetTransportationManager();
0147 
0148     G4FieldManager* fieldManager = transportMgr->GetFieldManager();
0149     fieldManager->SetDetectorField(fField);
0150 
0151     const int nVar = 8;  // 12 for RepleteEofM
0152     auto stepper = new StepperType(equation, nVar);
0153 
0154     G4double minStep = 0.01 * mm;
0155     G4ChordFinder* chordFinder = nullptr;
0156     if (stepper) {
0157       auto intgrDriver =
0158         new G4IntegrationDriver<StepperType>(minStep, stepper, stepper->GetNumberOfVariables());
0159       if (intgrDriver) {
0160         chordFinder = new G4ChordFinder(intgrDriver);
0161       }
0162     }
0163 
0164     // OLD -- and wrong
0165     // new G4ChordFinder((G4MagneticField*)fField,minStep,stepper);
0166 
0167     // Set accuracy parameters
0168     G4double deltaChord = 3.0 * mm;
0169     chordFinder->SetDeltaChord(deltaChord);
0170 
0171     G4double deltaIntersection = 0.1 * mm;
0172     fieldManager->SetDeltaIntersection(deltaIntersection);
0173 
0174     //  Control accuracy of integration
0175     //
0176     G4double deltaOneStep = 0.01 * mm;
0177     fieldManager->SetAccuraciesWithDeltaOneStep(deltaOneStep);
0178     //
0179     G4double epsMax = 1.0e-4;  // Pure number -- maximum relative integration error
0180     G4double epsMin = 2.5e-7;  //
0181     fieldManager->SetMinimumEpsilonStep(epsMin);
0182     fieldManager->SetMaximumEpsilonStep(epsMax);
0183     // The acceptable relative accuracy is calculated  as  deltaOneStep / stepsize
0184     //    but bounded to the interval between these values!
0185 
0186     fieldManager->SetChordFinder(chordFinder);
0187   }
0188 }
0189 
0190 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......