Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-02-23 09:22:09

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 // This example is provided by the Geant4-DNA collaboration
0027 // Any report or published results obtained using the Geant4-DNA software
0028 // shall cite the following Geant4-DNA collaboration publications:
0029 // Med. Phys. 45 (2018) e722-e739
0030 // Phys. Med. 31 (2015) 861-874
0031 // Med. Phys. 37 (2010) 4692-4708
0032 // Int. J. Model. Simul. Sci. Comput. 1 (2010) 157–178
0033 //
0034 // The Geant4-DNA web site is available at http://geant4-dna.org
0035 //
0036 /// \file medical/dna/svalue/src/DetectorConstruction.cc
0037 /// \brief Implementation of the DetectorConstruction class
0038 
0039 #include "DetectorConstruction.hh"
0040 
0041 #include "DetectorMessenger.hh"
0042 
0043 #include "G4NistManager.hh"
0044 #include "G4PVPlacement.hh"
0045 #include "G4PhysicalConstants.hh"
0046 #include "G4RunManager.hh"
0047 #include "G4Sphere.hh"
0048 #include "G4UnitsTable.hh"
0049 #include "G4UserLimits.hh"
0050 
0051 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0052 
0053 DetectorConstruction::DetectorConstruction() : G4VUserDetectorConstruction()
0054 {
0055   // Default tracking cut
0056 
0057   fTrackingCut = 7.4 * CLHEP::eV;
0058 
0059   // Default parameter values
0060 
0061   fWorldRadius = 10 * CLHEP::m;
0062   fCytoThickness = 20 * CLHEP::nm;
0063   fNuclRadius = 10 * CLHEP::nm;
0064 
0065   DefineMaterials();
0066 
0067   // Create commands for interactive definition of the detector
0068 
0069   fDetectorMessenger = new DetectorMessenger(this);
0070 }
0071 
0072 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0073 
0074 DetectorConstruction::~DetectorConstruction()
0075 {
0076   delete fDetectorMessenger;
0077 }
0078 
0079 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0080 
0081 void DetectorConstruction::DefineMaterials()
0082 {
0083   G4NistManager* man = G4NistManager::Instance();
0084 
0085   fWorldMaterial = man->FindOrBuildMaterial("G4_WATER");
0086   fCytoMaterial = fNuclMaterial = man->FindOrBuildMaterial("G4_WATER");
0087 }
0088 
0089 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0090 
0091 G4VPhysicalVolume* DetectorConstruction::Construct()
0092 {
0093   if (fWorld) return fWorld;
0094 
0095   // Spherical world
0096 
0097   G4Sphere* sWorld = new G4Sphere("World", 0., 1000 * fNuclRadius, 0., twopi, 0., pi);
0098 
0099   fLogicalWorld = new G4LogicalVolume(sWorld, fWorldMaterial, "World");
0100 
0101   fWorld = new G4PVPlacement(0, G4ThreeVector(), fLogicalWorld, "World", 0, false, 0);
0102 
0103   // Spherical nucleus
0104 
0105   G4Sphere* sNucl = new G4Sphere("Nucl", 0., fNuclRadius, 0., twopi, 0., pi);
0106 
0107   fLogicalNucl = new G4LogicalVolume(sNucl, fNuclMaterial, "Nucl");
0108 
0109   fNucl = new G4PVPlacement(0, G4ThreeVector(), "Nucl", fLogicalNucl, fWorld, false, 0);
0110 
0111   // Spherical shell for cytoplasm
0112 
0113   G4Sphere* sCyto =
0114     new G4Sphere("Cyto", fNuclRadius, fNuclRadius + fCytoThickness, 0., twopi, 0., pi);
0115 
0116   fLogicalCyto = new G4LogicalVolume(sCyto, fCytoMaterial, "Cyto");
0117 
0118   fCyto = new G4PVPlacement(0, G4ThreeVector(), "Cyto", fLogicalCyto, fWorld, false, 0);
0119   //
0120 
0121   PrintParameters();
0122 
0123   // Tracking cut
0124 
0125   fLogicalNucl->SetUserLimits(new G4UserLimits(DBL_MAX, DBL_MAX, DBL_MAX, fTrackingCut));
0126   fLogicalCyto->SetUserLimits(new G4UserLimits(DBL_MAX, DBL_MAX, DBL_MAX, fTrackingCut));
0127   fLogicalWorld->SetUserLimits(new G4UserLimits(DBL_MAX, DBL_MAX, DBL_MAX, fTrackingCut));
0128 
0129   //
0130   return fWorld;
0131 }
0132 
0133 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0134 
0135 void DetectorConstruction::PrintParameters() const
0136 {
0137   G4cout << "\n---------------------------------------------------------\n";
0138   G4cout << "---> The tracking cut is set to " << G4BestUnit(fTrackingCut, "Energy") << G4endl;
0139   G4cout << "---> The World is a sphere of " << G4BestUnit(1000 * fNuclRadius, "Length")
0140          << "radius of " << fWorldMaterial->GetName() << G4endl;
0141   G4cout << "---> The Nucleus is a sphere of " << G4BestUnit(fNuclRadius, "Length") << "radius of "
0142          << fWorldMaterial->GetName() << " of mass " << G4BestUnit(GetNuclMass(), "Mass") << G4endl;
0143   G4cout << "---> The Cytoplasm is a spherical shell of thickness "
0144          << G4BestUnit(fCytoThickness, "Length") << "of " << fWorldMaterial->GetName()
0145          << " of mass " << G4BestUnit(GetCytoMass(), "Mass") << G4endl;
0146   G4cout << "\n---------------------------------------------------------\n";
0147 }
0148 
0149 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0150 
0151 void DetectorConstruction::SetTrackingCut(G4double value)
0152 {
0153   fTrackingCut = value;
0154 }
0155 
0156 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0157 
0158 void DetectorConstruction::SetNuclRadius(G4double value)
0159 {
0160   fNuclRadius = value;
0161 }
0162 
0163 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0164 
0165 void DetectorConstruction::SetCytoThickness(G4double value)
0166 {
0167   fCytoThickness = value;
0168 }
0169 
0170 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0171 
0172 void DetectorConstruction::SetWorldMaterial(const G4String& materialChoice)
0173 {
0174   // Search the material by its name
0175   G4Material* pttoMaterial = G4NistManager::Instance()->FindOrBuildMaterial(materialChoice);
0176 
0177   if (pttoMaterial && pttoMaterial != fWorldMaterial) {
0178     fWorldMaterial = pttoMaterial;
0179     if (fLogicalWorld) fLogicalWorld->SetMaterial(pttoMaterial);
0180     G4RunManager::GetRunManager()->PhysicsHasBeenModified();
0181   }
0182 }
0183 
0184 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0185 
0186 void DetectorConstruction::SetCytoMaterial(const G4String& materialChoice)
0187 {
0188   // Search the material by its name
0189   G4Material* pttoMaterial = G4NistManager::Instance()->FindOrBuildMaterial(materialChoice);
0190 
0191   if (pttoMaterial && pttoMaterial != fCytoMaterial) {
0192     fCytoMaterial = pttoMaterial;
0193     if (fLogicalCyto) fLogicalCyto->SetMaterial(pttoMaterial);
0194     G4RunManager::GetRunManager()->PhysicsHasBeenModified();
0195   }
0196 }
0197 
0198 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0199 
0200 void DetectorConstruction::SetNuclMaterial(const G4String& materialChoice)
0201 {
0202   // Search the material by its name
0203   G4Material* pttoMaterial = G4NistManager::Instance()->FindOrBuildMaterial(materialChoice);
0204 
0205   if (pttoMaterial && pttoMaterial != fNuclMaterial) {
0206     fNuclMaterial = pttoMaterial;
0207     if (fLogicalNucl) fLogicalNucl->SetMaterial(pttoMaterial);
0208     G4RunManager::GetRunManager()->PhysicsHasBeenModified();
0209   }
0210 }