Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /geant4/examples/advanced/dna/moleculardna/src/DetectorConstruction.cc was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

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