Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-13 08:29:12

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 ExUCNDetectorConstruction.cc
0027 /// \brief Implementation of the ExUCNDetectorConstruction class
0028 
0029 #include "ExUCNDetectorConstruction.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 "G4PhysicalConstants.hh"
0041 #include "G4PhysicalVolumeStore.hh"
0042 #include "G4RepleteEofM.hh"
0043 #include "G4SolidStore.hh"
0044 #include "G4SystemOfUnits.hh"
0045 #include "G4TransportationManager.hh"
0046 #include "G4Tubs.hh"
0047 #include "G4UCNMaterialPropertiesTable.hh"
0048 #include "G4UniformGravityField.hh"
0049 #include "G4UserLimits.hh"
0050 #include "G4VPhysicalVolume.hh"
0051 #include "G4VisAttributes.hh"
0052 // #include "G4EqGravityField.hh"
0053 
0054 #include "G4ChordFinder.hh"
0055 #include "G4ClassicalRK4.hh"
0056 #include "G4MagIntegratorStepper.hh"
0057 #include "G4PropagatorInField.hh"
0058 
0059 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0060 
0061 ExUCNDetectorConstruction::ExUCNDetectorConstruction() : fVacuum(0), fGuideMaterial(0)
0062 {
0063   // materials
0064   DefineMaterials();
0065 }
0066 
0067 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0068 
0069 ExUCNDetectorConstruction::~ExUCNDetectorConstruction()
0070 {
0071   if (fField) delete fField;
0072 }
0073 
0074 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0075 
0076 void ExUCNDetectorConstruction::DefineMaterials()
0077 {
0078   G4NistManager* nistMan = G4NistManager::Instance();
0079 
0080   fVacuum = nistMan->FindOrBuildMaterial("G4_Galactic");
0081   fGuideMaterial = nistMan->FindOrBuildMaterial("G4_Ni");
0082 
0083   // --- Ni diffuse 10%
0084 
0085   G4UCNMaterialPropertiesTable* MPT = new G4UCNMaterialPropertiesTable();
0086 
0087   //  MPT->AddConstProperty("REFLECTIVITY",1.);
0088   //  Commented out above line as REFLECTIVITY=1 by default in
0089   //  G4OpBoundaryProcess.  Also use AddProperty to set REFLECTIVITY if needed
0090   MPT->AddConstProperty("DIFFUSION", 0.1);
0091   MPT->AddConstProperty("FERMIPOT", 252.0);  // Gollub, Table 2.1 in neV
0092   MPT->AddConstProperty("SPINFLIP", 0.);
0093   MPT->AddConstProperty("LOSS", 12.5e-5);  //  Gollub, Table 2.1
0094   MPT->AddConstProperty("LOSSCS", 0.);
0095   MPT->AddConstProperty("ABSCS", 4.49);  // 1/v loss cross-section  at room temp.
0096   MPT->AddConstProperty("SCATCS", 18.5);  // (incoherent) "elastic" scattering cs
0097 
0098   G4double neV = 1.e-9 * eV;
0099 
0100   MPT->SetMicroRoughnessParameters(30 * nm, 1 * nm, 180, 1000, 0 * degree, 90 * degree, 1 * neV,
0101                                    1000 * neV, 15, 15, 0.01 * degree);
0102 
0103   fGuideMaterial->SetMaterialPropertiesTable(MPT);
0104 
0105   G4cout << *(G4Material::GetMaterialTable()) << G4endl;
0106 }
0107 
0108 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0109 
0110 G4VPhysicalVolume* ExUCNDetectorConstruction::Construct()
0111 {
0112   //
0113   // World
0114   //
0115 
0116   G4double worldSizeX = 1. * m;
0117   G4double worldSizeY = 1. * m;
0118   G4double worldSizeZ = 100. * m;
0119 
0120   G4Box* solidWorld = new G4Box("World", worldSizeX / 2., worldSizeY / 2., worldSizeZ / 2.);
0121 
0122   G4LogicalVolume* logicWorld = new G4LogicalVolume(solidWorld, fVacuum, "World");
0123 
0124   G4VPhysicalVolume* physiWorld =
0125     new G4PVPlacement(0, G4ThreeVector(), "World", logicWorld, 0, false, 0);
0126 
0127   // --------------------------------- Guide -------------------------------------
0128 
0129   G4double GuideR = 35. * mm;
0130   G4double GuideW = 2. * mm;
0131   G4double GuideL = 6. * m;
0132 
0133   G4Tubs* solidGuide = new G4Tubs("SolidGuide", GuideR, GuideR + GuideW, GuideL / 2., 0., twopi);
0134 
0135   G4LogicalVolume* logicGuide = new G4LogicalVolume(solidGuide, fGuideMaterial, "Guide");
0136 
0137   new G4PVPlacement(0, G4ThreeVector(), "Guide", logicGuide, physiWorld, false, 0);
0138 
0139   // ------------------------------ End Plate  -----------------------------------
0140 
0141   G4Tubs* solidEndPlate = new G4Tubs("EndPlate", 0., GuideR, GuideW / 2., 0., twopi);
0142 
0143   G4LogicalVolume* logicEndPlate = new G4LogicalVolume(solidEndPlate, fVacuum, "EndPlate");
0144 
0145   G4ThreeVector endPlatePos = G4ThreeVector(0., 0., GuideL / 2. + GuideW / 2.);
0146 
0147   new G4PVPlacement(0, endPlatePos, "EndPlate", logicEndPlate, physiWorld, false, 0);
0148 
0149   G4double maxStep = 1.0 * mm;
0150   G4double maxTime = 100. * s;
0151 
0152   G4UserLimits* stepLimit = new G4UserLimits(maxStep, DBL_MAX, maxTime);
0153 
0154   logicWorld->SetUserLimits(stepLimit);
0155 
0156   //
0157   // Visualization attributes
0158   //
0159 
0160   G4VisAttributes* guideColor = new G4VisAttributes(G4Colour(0.0, 0.0, 1.0));
0161   guideColor->SetVisibility(true);
0162   guideColor->SetForceWireframe(true);
0163 
0164   G4VisAttributes* endPlateColor = new G4VisAttributes(G4Colour(1.0, 0.0, 0.0));
0165   endPlateColor->SetVisibility(true);
0166   endPlateColor->SetForceSolid(true);
0167 
0168   logicWorld->SetVisAttributes(G4VisAttributes::GetInvisible());
0169   logicGuide->SetVisAttributes(guideColor);
0170   logicEndPlate->SetVisAttributes(endPlateColor);
0171 
0172   //
0173   // always return the physical World
0174   //
0175   return physiWorld;
0176 }
0177 
0178 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0179 
0180 G4ThreadLocal G4UniformGravityField* ExUCNDetectorConstruction::fField = 0;
0181 
0182 void ExUCNDetectorConstruction::ConstructSDandField()
0183 {
0184   if (!fField) {
0185     fField = new G4UniformGravityField();
0186 
0187     G4RepleteEofM* equation = new G4RepleteEofM(fField);
0188     //     G4RepleteEofM* equation = new G4RepleteEofM(fField,12);
0189     //     G4EqGravityField* equation = new G4EqGravityField(fField);
0190 
0191     G4FieldManager* fieldManager =
0192       G4TransportationManager::GetTransportationManager()->GetFieldManager();
0193     fieldManager->SetDetectorField(fField);
0194 
0195     G4MagIntegratorStepper* stepper = new G4ClassicalRK4(equation, 8);
0196     //     G4MagIntegratorStepper* stepper = new G4ClassicalRK4(equation,12);
0197 
0198     G4double minStep = 0.01 * mm;
0199 
0200     G4ChordFinder* chordFinder = new G4ChordFinder((G4MagneticField*)fField, minStep, stepper);
0201 
0202     // Set accuracy parameters
0203     G4double deltaChord = 3.0 * mm;
0204     chordFinder->SetDeltaChord(deltaChord);
0205 
0206     G4double deltaOneStep = 0.01 * mm;
0207     fieldManager->SetAccuraciesWithDeltaOneStep(deltaOneStep);
0208 
0209     G4double deltaIntersection = 0.1 * mm;
0210     fieldManager->SetDeltaIntersection(deltaIntersection);
0211 
0212     G4TransportationManager* transportManager = G4TransportationManager::GetTransportationManager();
0213 
0214     G4PropagatorInField* fieldPropagator = transportManager->GetPropagatorInField();
0215 
0216     // Dimensionless limits for relative accuracy of integration
0217     G4double epsMin = 2.5e-7;
0218     G4double epsMax = 0.001;  // Will soon be maximum without warning.
0219     // The relative accuracy used for a step of length 'l'
0220     //                    a.)  epsMin              if deltaOneStep / l < epsMin
0221     //    epsilon_step =  b.)  epsMax              if deltaOneStep / l > epsMax
0222     //                    c.)  deltaOneStep / l    otherwise
0223 
0224     fieldPropagator->SetMinimumEpsilonStep(epsMin);
0225     fieldPropagator->SetMaximumEpsilonStep(epsMax);
0226 
0227     fieldManager->SetChordFinder(chordFinder);
0228   }
0229 }
0230 
0231 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......