Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-04-27 07:33:22

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