Back to home page

EIC code displayed by LXR

 
 

    


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

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