Back to home page

EIC code displayed by LXR

 
 

    


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

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