Back to home page

EIC code displayed by LXR

 
 

    


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

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 medical/dna/range/src/DetectorConstruction.cc
0027 /// \brief Implementation of the DetectorConstruction class
0028 //
0029 // $Id: DetectorConstruction.cc 78723 2014-01-20 10:32:17Z gcosmo $
0030 //
0031 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0032 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0033 
0034 #include "DetectorConstruction.hh"
0035 
0036 #include "DetectorMessenger.hh"
0037 
0038 #include "G4Colour.hh"
0039 #include "G4GeometryManager.hh"
0040 #include "G4LogicalVolume.hh"
0041 #include "G4LogicalVolumeStore.hh"
0042 #include "G4MultiFunctionalDetector.hh"
0043 #include "G4NistManager.hh"
0044 #include "G4PSDoseDeposit.hh"
0045 #include "G4PSEnergyDeposit.hh"
0046 #include "G4PVParameterised.hh"
0047 #include "G4PVPlacement.hh"
0048 #include "G4PVReplica.hh"
0049 #include "G4PhysicalConstants.hh"
0050 #include "G4PhysicalVolumeStore.hh"
0051 #include "G4ProductionCuts.hh"
0052 #include "G4RunManager.hh"
0053 #include "G4SDManager.hh"
0054 #include "G4SolidStore.hh"
0055 #include "G4Sphere.hh"
0056 #include "G4SubtractionSolid.hh"
0057 #include "G4SystemOfUnits.hh"
0058 #include "G4Tubs.hh"
0059 #include "G4UnitsTable.hh"
0060 #include "G4UserLimits.hh"
0061 #include "G4VPhysicalVolume.hh"
0062 #include "G4VPrimitiveScorer.hh"
0063 #include "G4VSensitiveDetector.hh"
0064 #include "G4VisAttributes.hh"
0065 
0066 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0067 
0068 DetectorConstruction::DetectorConstruction()
0069   : G4VUserDetectorConstruction(),
0070     fNPRadius(0),
0071     fAbsRadius(0),
0072     fNPMaterial(0),
0073     fAbsMaterial(0),
0074     pWorld(0),
0075     fNP(0),
0076     fAbs(0),
0077     fDetectorMessenger(0),
0078     fRegion(0)
0079 {
0080   // default tracking cut
0081   fTrackingCut = 10.0 * eV;
0082 
0083   // default parameter values
0084   fNPRadius = 50 * nm;
0085   fAbsRadius = 100000 * nm + fNPRadius;
0086 
0087   fNreplicaR = 1000;
0088   fNreplicaAzm = 360;
0089 
0090   DefineMaterials();
0091   SetNPMaterial("G4_Au");
0092   SetAbsMaterial("G4_WATER");
0093 
0094   // create commands for interactive definition of the detector
0095   fDetectorMessenger = new DetectorMessenger(this);
0096 }
0097 
0098 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0099 
0100 DetectorConstruction::~DetectorConstruction()
0101 {
0102   delete fDetectorMessenger;
0103 }
0104 
0105 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0106 
0107 G4VPhysicalVolume* DetectorConstruction::Construct()
0108 {
0109   return ConstructVolumes();
0110 }
0111 
0112 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0113 
0114 void DetectorConstruction::DefineMaterials()
0115 {
0116   G4NistManager* man = G4NistManager::Instance();
0117 
0118   man->FindOrBuildMaterial("G4_Au");
0119   man->FindOrBuildMaterial("G4_WATER");
0120 }
0121 
0122 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0123 
0124 G4VPhysicalVolume* DetectorConstruction::ConstructVolumes()
0125 {
0126   const G4bool check_overlap = false;
0127   G4GeometryManager::GetInstance()->OpenGeometry();
0128   G4PhysicalVolumeStore::GetInstance()->Clean();
0129   G4LogicalVolumeStore::GetInstance()->Clean();
0130   G4SolidStore::GetInstance()->Clean();
0131 
0132   // World  ====================================================================
0133   G4Material* Vacuum = new G4Material("Galactic", 1., 1.01 * g / mole, universe_mean_density,
0134                                       kStateGas, 2.73 * kelvin, 3.e-18 * pascal);
0135 
0136   G4Sphere* sWorld = new G4Sphere("World", 0., fAbsRadius * 1.5, 0., 2 * pi * rad, 0., pi);
0137   G4LogicalVolume* lWorld = new G4LogicalVolume(sWorld, Vacuum, "World");
0138   pWorld = new G4PVPlacement(0, G4ThreeVector(), lWorld, "World", 0, false, 0);
0139 
0140   // Spherical NanoParticle ===================================================
0141   G4Sphere* sNP = new G4Sphere("NanoParticle", 0., fNPRadius, 0., 2 * pi * rad, 0., pi);
0142 
0143   fLogicalNP = new G4LogicalVolume(sNP, fNPMaterial, "NanoParticle");
0144 
0145   fNP = new G4PVPlacement(0, G4ThreeVector(), fLogicalNP, "NanoParticle", lWorld, false, 0,
0146                           check_overlap);
0147 
0148   // Sampling Plane ===========================================================
0149 
0150   // Spherical water absorber -------------------------------------------------
0151   G4Sphere* sAbsorber0 = new G4Sphere("Absorber0", 0., fAbsRadius * 1.2, 0., 2 * pi * rad, 0., pi);
0152   G4VSolid* sAbsorber = new G4SubtractionSolid("Absorber", sAbsorber0, sNP, 0, G4ThreeVector());
0153 
0154   fLogicalAbs = new G4LogicalVolume(sAbsorber, fAbsMaterial, "Absorber");
0155   fAbs =
0156     new G4PVPlacement(0, G4ThreeVector(), fLogicalAbs, "Absorber", lWorld, false, 0, check_overlap);
0157 
0158   // Set Visualization Setting#################################################
0159   G4VisAttributes* visWorld = new G4VisAttributes(true, G4Colour::Gray());
0160   G4VisAttributes* visNP = new G4VisAttributes(true, G4Colour::Yellow());
0161   G4VisAttributes* visAbs = new G4VisAttributes(true, G4Colour::Cyan());
0162 
0163   lWorld->SetVisAttributes(visWorld);
0164   fLogicalNP->SetVisAttributes(visNP);
0165   fLogicalAbs->SetVisAttributes(visAbs);
0166 
0167   PrintParameters();
0168 
0169   G4double maxStep = fNPRadius / 2.;
0170   fLogicalNP->SetUserLimits(new G4UserLimits(maxStep, DBL_MAX, DBL_MAX, fTrackingCut));
0171 
0172   fRegion = new G4Region("NP");
0173 
0174   G4ProductionCuts* cuts = new G4ProductionCuts();
0175   G4double defCut = 0.1 * nm;
0176   cuts->SetProductionCut(defCut, "gamma");
0177   cuts->SetProductionCut(defCut, "e-");
0178   cuts->SetProductionCut(defCut, "e+");
0179   cuts->SetProductionCut(defCut, "proton");
0180   fRegion->SetProductionCuts(cuts);
0181   fRegion->AddRootLogicalVolume(fLogicalNP);
0182 
0183   return pWorld;
0184 }
0185 
0186 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0187 
0188 void DetectorConstruction::PrintParameters() const
0189 {
0190   G4cout << "\n=========================================================\n";
0191   G4cout << "---> The tracking cut to all particles is set to "
0192          << G4BestUnit(fTrackingCut, "Energy") << G4endl;
0193   G4cout << "\n---------------------------------------------------------\n";
0194   G4cout << "---> The Nano-Particle is a sphere of " << G4BestUnit(fNPRadius, "Length")
0195          << " radius of " << fNPMaterial->GetName() << " made of"
0196          << "\n \n"
0197          << fNPMaterial << G4endl;
0198   G4cout << "\n---------------------------------------------------------\n";
0199   G4cout << "---> The Absorber is a sphere of " << G4BestUnit(fAbsRadius, "Length") << " radius of "
0200          << fAbsMaterial->GetName() << " made of"
0201          << "\n \n"
0202          << fAbsMaterial << G4endl;
0203   G4cout << "\n=========================================================\n";
0204 }
0205 
0206 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0207 
0208 void DetectorConstruction::SetTrackingCut(G4double value)
0209 {
0210   fTrackingCut = value;
0211   G4RunManager::GetRunManager()->ReinitializeGeometry();
0212 }
0213 
0214 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0215 
0216 void DetectorConstruction::SetAbsRadius(G4double value)
0217 {
0218   fAbsRadius = value;
0219   G4RunManager::GetRunManager()->ReinitializeGeometry();
0220 }
0221 
0222 void DetectorConstruction::SetNPRadius(G4double value)
0223 {
0224   fNPRadius = value;
0225   G4RunManager::GetRunManager()->ReinitializeGeometry();
0226 }
0227 
0228 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0229 //
0230 void DetectorConstruction::SetAbsMaterial(G4String materialChoice)
0231 {
0232   G4Material* pttoMaterial = G4Material::GetMaterial(materialChoice);
0233   if (pttoMaterial) fAbsMaterial = pttoMaterial;
0234   G4RunManager::GetRunManager()->PhysicsHasBeenModified();
0235 }
0236 
0237 void DetectorConstruction::SetNPMaterial(G4String materialChoice)
0238 {
0239   G4Material* pttoMaterial = G4Material::GetMaterial(materialChoice);
0240   if (pttoMaterial) fNPMaterial = pttoMaterial;
0241   G4RunManager::GetRunManager()->PhysicsHasBeenModified();
0242 }
0243 
0244 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0245 //
0246 void DetectorConstruction::SetNReplicaR(G4int value)
0247 {
0248   fNreplicaR = value;
0249   G4RunManager::GetRunManager()->ReinitializeGeometry();
0250 }
0251 void DetectorConstruction::SetNReplicaAzm(G4int value)
0252 {
0253   fNreplicaAzm = value;
0254   G4RunManager::GetRunManager()->ReinitializeGeometry();
0255 }