Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-04-17 07:51:37

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 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0028 
0029 #include "DetectorConstruction.hh"
0030 #include "DetectorMessenger.hh"
0031 
0032 #include "globals.hh"
0033 #include "G4SystemOfUnits.hh"
0034 #include "G4Box.hh"
0035 #include "G4LogicalVolume.hh"
0036 #include "G4VPhysicalVolume.hh"
0037 #include "G4PVPlacement.hh"
0038 #include "G4Material.hh"
0039 #include "G4NistManager.hh"
0040 #include "G4GeometryManager.hh"
0041 #include "G4PhysicalVolumeStore.hh"
0042 #include "G4LogicalVolumeStore.hh"
0043 #include "G4SolidStore.hh"
0044 #include "G4VisAttributes.hh"
0045 #include "G4Colour.hh"
0046 
0047 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0048 
0049 DetectorConstruction::DetectorConstruction()
0050 {
0051   G4NistManager* man = G4NistManager::Instance();
0052   //man->SetVerbose(1);
0053 
0054   fMessenger = new DetectorMessenger(this);
0055 
0056   fWorldMat   = man->FindOrBuildMaterial("G4_Galactic");
0057   fWorldXY = 50.*cm;
0058   fWorldZ = 100.*cm;
0059 
0060   G4cout << *(G4Material::GetMaterialTable()) << G4endl;
0061 }
0062 
0063 
0064 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0065 
0066 DetectorConstruction::~DetectorConstruction()
0067 {
0068   delete fMessenger;
0069 }
0070 
0071 
0072 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0073 
0074 G4VPhysicalVolume* DetectorConstruction::Construct()
0075 {
0076   DumpGeometryParameters();
0077 
0078   G4GeometryManager::GetInstance()->OpenGeometry();
0079   G4PhysicalVolumeStore::GetInstance()->Clean();
0080   G4LogicalVolumeStore::GetInstance()->Clean();
0081   G4SolidStore::GetInstance()->Clean();
0082   //
0083   // World
0084   //
0085 
0086   G4Box* sWorld = new G4Box("World",
0087                 fWorldXY, fWorldXY, fWorldZ);
0088   G4LogicalVolume* lWorld = new G4LogicalVolume(sWorld,
0089                         fWorldMat, "World");
0090   G4VPhysicalVolume* phWorld = new G4PVPlacement(0, G4ThreeVector(),
0091                          "World", lWorld,
0092                          0, false, 0);
0093 
0094   //
0095   // Visualization attributes
0096   //
0097   auto visAtt = new G4VisAttributes(G4Colour(0.1,0.5,1.0));
0098   visAtt->SetVisibility(true);
0099   lWorld->SetVisAttributes(visAtt);
0100 
0101   return phWorld;
0102 }
0103 
0104 
0105 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0106 
0107 void DetectorConstruction::DumpGeometryParameters()
0108 {
0109 
0110   G4cout << "\n===================================================" << G4endl;
0111   G4cout << "#               IAEAphsp Geometry                 #" << G4endl;
0112   G4cout << "===================================================" << G4endl;
0113   G4cout << "  WorldXY = " << fWorldXY/cm << " cm " << G4endl;
0114   G4cout << "  WorldZ = " << fWorldZ/cm << " cm " << G4endl;
0115   G4cout << "  WorldMat: " << fWorldMat->GetName() << G4endl;
0116   G4cout << "===================================================\n" << G4endl;
0117 }