Back to home page

EIC code displayed by LXR

 
 

    


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

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 DetectorConstruction.cc
0028 /// \brief Detector Construction for a DNA molecule in a cell
0029 
0030 #include "DetectorConstruction.hh"
0031 
0032 #include "DNAGeometry.hh"
0033 #include "DetectorMessenger.hh"
0034 #include "OctreeNode.hh"
0035 
0036 #include "G4Box.hh"
0037 #include "G4Color.hh"
0038 #include "G4Ellipsoid.hh"
0039 #include "G4LogicalVolume.hh"
0040 #include "G4NistManager.hh"
0041 #include "G4PVPlacement.hh"
0042 #include "G4SDManager.hh"
0043 #include "G4VPhysicalVolume.hh"
0044 #include "G4VisAttributes.hh"
0045 
0046 #include <fstream>
0047 
0048 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0049 
0050 DetectorConstruction::DetectorConstruction()
0051   : fpDNAGeometry(new DNAGeometry()), fpDetectorMessenger(new DetectorMessenger(this))
0052 {
0053   G4bool useParallelPhysicsWorld = false;
0054   if (useParallelPhysicsWorld) {
0055     RegisterParallelWorld(fpDNAGeometry->GetDNAWorld());
0056   }
0057 }
0058 
0059 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0060 
0061 DetectorConstruction::~DetectorConstruction()
0062 {
0063   delete fpDetectorMessenger;
0064 }
0065 
0066 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0067 
0068 G4VPhysicalVolume* DetectorConstruction::Construct()
0069 {
0070   BuildMaterials();
0071   return ConstructDetector();
0072 }
0073 
0074 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0075 
0076 void DetectorConstruction::BuildMaterials()
0077 {
0078   G4NistManager* man = G4NistManager::Instance();
0079   fpWorld = man->FindOrBuildMaterial("G4_Galactic");
0080   fpWater = man->FindOrBuildMaterial("G4_WATER");
0081 }
0082 
0083 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0084 
0085 G4VPhysicalVolume* DetectorConstruction::ConstructDetector()
0086 {
0087   //////////////////////////////////////////////////////////////////////////////
0088   // Brief :: Build the detector. This real world for only chemistry stage only.
0089   // An other parallel world is built in DNAWorld for only physics We either
0090   // build a DNA region inside a cell if fCellRadius is se in macro file, or we
0091   // just run the experiment in the World if it isn't. If we run in a cell, the
0092   // world material is a vacuum, and the cell is water. Otherwise everything is
0093   // water.
0094   //////////////////////////////////////////////////////////////////////////////
0095 
0096   G4LogicalVolume* pDnaRegionLogical;
0097 
0098   G4double dnasx = fCellRadius.getX();
0099   G4double dnasy = fCellRadius.getY();
0100   G4double dnasz = fCellRadius.getZ();
0101   if ((dnasx <= 0) || (dnasy <= 0) || (dnasz <= 0)) {
0102     // Experiment in the world only
0103     G4cout << "No cell radius has been specified (or the radii are less than 0)." << G4endl;
0104     G4cout << "This will fill the entire world with water" << G4endl;
0105 
0106     G4double wsize = 1.01 * fWorldSideLength / 2.;
0107     auto worldPhysical = new G4Box("WorldPhysical", wsize, wsize, wsize);
0108     auto worldLogical = new G4LogicalVolume(worldPhysical, fpWater, "world");
0109     fWorld = new G4PVPlacement(nullptr, G4ThreeVector(0), worldLogical, "world", nullptr, false, 0);
0110     pDnaRegionLogical = worldLogical;
0111   }
0112   else {
0113     // experiment inside a cell.
0114     G4double wsize = 1.01 * fWorldSideLength / 2.;
0115     auto worldPhysical = new G4Box("WorldPhysical", wsize, wsize, wsize);
0116     auto worldLogical = new G4LogicalVolume(worldPhysical, fpWorld, "world");
0117 
0118     fWorld = new G4PVPlacement(nullptr, G4ThreeVector(0), worldLogical, "world", nullptr, false, 0);
0119     auto dnaPhysical = new G4Ellipsoid("CellPhysical", dnasx, dnasy, dnasz);
0120     auto dnaLogical = new G4LogicalVolume(dnaPhysical, fpWater, "CellLogical");
0121 
0122     new G4PVPlacement(nullptr, G4ThreeVector(0), "CellVolume", dnaLogical, fWorld, false, 0, false);
0123     pDnaRegionLogical = dnaLogical;
0124   }
0125   // we build DNA geometry for physical stage
0126   this->GetDNAGeometry()->BuildDNA(pDnaRegionLogical);
0127   return fWorld;
0128 }
0129 
0130 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......