Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-14 08:28:31

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 DetectorConstruction.cc
0027 /// \brief Implementation of the DetectorConstruction class
0028 
0029 // This example is provided by the Geant4-DNA collaboration
0030 // Any report or published results obtained using the Geant4-DNA software
0031 // shall cite the following Geant4-DNA collaboration publication:
0032 // Med. Phys. 37 (2010) 4692-4708
0033 // J. Comput. Phys. 274 (2014) 841-882
0034 // The Geant4-DNA web site is available at http://geant4-dna.org
0035 //
0036 //
0037 
0038 #include "DetectorConstruction.hh"
0039 
0040 #include "DetectorMessenger.hh"
0041 
0042 #include "G4ProductionCuts.hh"
0043 #include "G4RunManager.hh"
0044 #include "G4SystemOfUnits.hh"
0045 
0046 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
0047 
0048 DetectorConstruction::DetectorConstruction() : G4VUserDetectorConstruction()
0049 {
0050   // create commands for interactive definition of the detector
0051   fDetectorMessenger = new DetectorMessenger(this);
0052 }
0053 
0054 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
0055 
0056 DetectorConstruction::~DetectorConstruction()
0057 {
0058   delete fDetectorMessenger;
0059 }
0060 
0061 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
0062 
0063 G4VPhysicalVolume* DetectorConstruction::Construct()
0064 
0065 {
0066   DefineMaterials();
0067   return ConstructDetector();
0068 }
0069 
0070 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
0071 
0072 void DetectorConstruction::DefineMaterials()
0073 {
0074   // Water is defined from NIST material database
0075   G4NistManager* man = G4NistManager::Instance();
0076   G4Material* H2O = man->FindOrBuildMaterial("G4_WATER");
0077 
0078   // Default materials in setup.
0079   fpWaterMaterial = H2O;
0080 
0081   // needed variables
0082 
0083   G4double z, a, density;
0084   G4String name, symbol;
0085   G4int nComponents, nAtoms;
0086 
0087   a = 12.0107 * g / mole;
0088   G4Element* elC = new G4Element(name = "Carbon", symbol = "C", z = 6., a);
0089 
0090   a = 1.00794 * g / mole;
0091   G4Element* elH = new G4Element(name = "Hydrogen", symbol = "H", z = 1., a);
0092 
0093   a = 15.9994 * g / mole;
0094   G4Element* elO = new G4Element(name = "Oxygen", symbol = "O", z = 8., a);
0095 
0096   a = 14.0067 * g / mole;
0097   G4Element* elN = new G4Element(name = "Nitrogen", symbol = "N", z = 7., a);
0098 
0099   // Definition of Tetrahydrofurane (THF)
0100 
0101   density = 1.346 * g / cm3;
0102 
0103   fpTHFMaterial = new G4Material("THF", density, nComponents = 3);
0104   fpTHFMaterial->AddElement(elC, nAtoms = 4);
0105   fpTHFMaterial->AddElement(elH, nAtoms = 8);
0106   fpTHFMaterial->AddElement(elO, nAtoms = 1);
0107 
0108   // Definition of Nitrogen in nanodosimetry experiments
0109 
0110   density = 0.34e-6 * g / cm3;
0111 
0112   fpN2Material = new G4Material("N2", density, nComponents = 1);
0113   fpN2Material->AddElement(elN, nAtoms = 2);
0114 }
0115 
0116 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
0117 
0118 G4VPhysicalVolume* DetectorConstruction::ConstructDetector()
0119 {
0120   G4double diameter;
0121   G4double highz;
0122   G4Material* targetMaterial;
0123   G4Material* worldMaterial;
0124 
0125   if (fGeomType == "dna") {
0126     // nanometric geometry
0127     fWorldSize = 20. * nm;
0128     diameter = 2.3 * nm;
0129     highz = 3.4 * nm;
0130     targetMaterial = fpTHFMaterial;
0131     worldMaterial = fpWaterMaterial;
0132   }
0133   else {
0134     // macrometric geometry (experimental target in nanodosimetry)
0135     fWorldSize = 2 * cm;
0136     diameter = 1 * cm;
0137     highz = 1 * cm;
0138     ;
0139     targetMaterial = fpN2Material;
0140     worldMaterial = fpN2Material;
0141   }
0142 
0143   fpSolidWorld = new G4Box("World",  // its name
0144                            fWorldSize / 2, fWorldSize / 2, fWorldSize / 2);  // its size
0145 
0146   fpLogicWorld = new G4LogicalVolume(fpSolidWorld,  // its solid
0147                                      worldMaterial,  // its material
0148                                      "World");  // its name
0149 
0150   fpPhysiWorld = new G4PVPlacement(0,  // no rotation
0151                                    G4ThreeVector(),  // at (0,0,0)
0152                                    "World",  // its name
0153                                    fpLogicWorld,  // its logical volume
0154                                    0,  // its mother  volume
0155                                    false,  // no boolean operation
0156                                    0);  // copy number
0157 
0158   G4Tubs* solidTarget =
0159     new G4Tubs("Target", 0, diameter / 2., highz / 2., 0 * degree, 360 * degree);
0160 
0161   G4LogicalVolume* logicTarget = new G4LogicalVolume(solidTarget,  // its solid
0162                                                      targetMaterial,  // its material
0163                                                      "Target");  // its name
0164 
0165   new G4PVPlacement(0,  // no rotation
0166                     G4ThreeVector(),  // at (0,0,0)
0167                     "Target",  // its name
0168                     logicTarget,  // its logical volume
0169                     fpPhysiWorld,  // its mother  volume
0170                     false,  // no boolean operation
0171                     0);  // copy number
0172 
0173   // Visualization attributes
0174   G4VisAttributes* worldVisAtt = new G4VisAttributes(G4Colour(1.0, 1.0, 1.0));
0175   worldVisAtt->SetVisibility(true);
0176   fpLogicWorld->SetVisAttributes(worldVisAtt);
0177 
0178   G4VisAttributes* worldVisAtt1 = new G4VisAttributes(G4Colour(1.0, 0.0, 0.0));
0179   worldVisAtt1->SetVisibility(true);
0180   logicTarget->SetVisAttributes(worldVisAtt1);
0181 
0182   return fpPhysiWorld;
0183 }
0184 
0185 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
0186 
0187 void DetectorConstruction::SetGeometry(const G4String& name)
0188 {
0189   fGeomType = name;
0190 
0191   // tell RunManager about changes
0192   G4RunManager::GetRunManager()->GeometryHasBeenModified();
0193 }