Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-02-23 09:20:46

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 GB05DetectorConstruction.cc
0028 /// \brief Implementation of the GB05DetectorConstruction class
0029 
0030 #include "GB05DetectorConstruction.hh"
0031 
0032 #include "GB05BOptrSplitAndKillByCrossSection.hh"
0033 #include "GB05SD.hh"
0034 
0035 #include "G4Box.hh"
0036 #include "G4LogicalVolume.hh"
0037 #include "G4LogicalVolumeStore.hh"
0038 #include "G4Material.hh"
0039 #include "G4NistManager.hh"
0040 #include "G4PVPlacement.hh"
0041 #include "G4SDManager.hh"
0042 #include "G4SystemOfUnits.hh"
0043 
0044 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0045 
0046 GB05DetectorConstruction::GB05DetectorConstruction() : G4VUserDetectorConstruction() {}
0047 
0048 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0049 
0050 GB05DetectorConstruction::~GB05DetectorConstruction() {}
0051 
0052 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0053 
0054 G4VPhysicalVolume* GB05DetectorConstruction::Construct()
0055 {
0056   // -- Collect a few materials from NIST database:
0057   auto nistManager = G4NistManager::Instance();
0058   G4Material* worldMaterial = nistManager->FindOrBuildMaterial("G4_Galactic");
0059   G4Material* defaultMaterial = nistManager->FindOrBuildMaterial("G4_CONCRETE");
0060 
0061   G4VSolid* solidWorld = new G4Box("World", 10 * m, 10 * m, 10 * m);
0062 
0063   G4LogicalVolume* logicWorld = new G4LogicalVolume(solidWorld,  // its solid
0064                                                     worldMaterial,  // its material
0065                                                     "World");  // its name
0066 
0067   G4PVPlacement* physiWorld = new G4PVPlacement(0,  // no rotation
0068                                                 G4ThreeVector(),  // at (0,0,0)
0069                                                 logicWorld,  // its logical volume
0070                                                 "World",  // its name
0071                                                 0,  // its mother volume
0072                                                 false,  // no boolean operation
0073                                                 0);  // copy number
0074 
0075   // -----------------------------------
0076   // -- volume where biasing is applied:
0077   // -----------------------------------
0078   G4double halfXY = 5.0 * m;
0079   G4double halfZ = 1.0 * m;
0080   G4VSolid* solidShield = new G4Box("shield.solid", halfXY, halfXY, halfZ);
0081 
0082   G4LogicalVolume* logicShield = new G4LogicalVolume(solidShield,  // its solid
0083                                                      defaultMaterial,  // its material
0084                                                      "shield.logical");  // its name
0085 
0086   new G4PVPlacement(0,  // no rotation
0087                     G4ThreeVector(0, 0, halfZ),  // volume entrance at (0,0,0)
0088                     logicShield,  // its logical volume
0089                     "shield.phys",  // its name
0090                     logicWorld,  // its mother  volume
0091                     false,  // no boolean operation
0092                     0);  // copy number
0093 
0094   // --------------------------------------------------------------------
0095   // -- dummy volume to print information on particle exiting the shield:
0096   // --------------------------------------------------------------------
0097   G4double halfz = 1 * cm;
0098   G4VSolid* solidMeasurement = new G4Box("meas.solid", halfXY, halfXY, halfz);
0099 
0100   G4LogicalVolume* logicMeasurement = new G4LogicalVolume(solidMeasurement,  // its solid
0101                                                           worldMaterial,  // its material
0102                                                           "meas.logical");  // its name
0103 
0104   new G4PVPlacement(0,  // no rotation
0105                     G4ThreeVector(0, 0, 2 * halfZ + halfz),  // volume entrance at (0,0,0)
0106                     logicMeasurement,  // its logical volume
0107                     "meas.phys",  // its name
0108                     logicWorld,  // its mother  volume
0109                     false,  // no boolean operation
0110                     0);  // copy number
0111 
0112   return physiWorld;
0113 }
0114 
0115 void GB05DetectorConstruction::ConstructSDandField()
0116 {
0117   // -- Fetch volume for biasing:
0118   G4LogicalVolume* logicShield = G4LogicalVolumeStore::GetInstance()->GetVolume("shield.logical");
0119 
0120   // -------------------------------------------------------------
0121   // -- operator creation, configuration and attachment to volume:
0122   // -------------------------------------------------------------
0123   GB05BOptrSplitAndKillByCrossSection* biasingOperator =
0124     new GB05BOptrSplitAndKillByCrossSection("neutron");
0125   // -- Now, we declare to our biasing operator all the processes we
0126   // -- their disapperance effect on neutrons to be counterbalanced
0127   // -- by the splitting by cross-section :
0128   biasingOperator->AddProcessToEquipoise("Decay");
0129   biasingOperator->AddProcessToEquipoise("nCapture");
0130   biasingOperator->AddProcessToEquipoise("neutronInelastic");
0131 
0132   biasingOperator->AttachTo(logicShield);
0133 
0134   G4cout << " Attaching biasing operator " << biasingOperator->GetName() << " to logical volume "
0135          << biasingOperator->GetName() << G4endl;
0136 
0137   // ------------------------------------------------------------------------------------
0138   // -- Attach a sensitive detector to print information on particles exiting the shield:
0139   // ------------------------------------------------------------------------------------
0140   // -- create and register sensitive detector code module:
0141   G4SDManager* SDman = G4SDManager::GetSDMpointer();
0142   G4VSensitiveDetector* sd = new GB05SD("Scorer");
0143   SDman->AddNewDetector(sd);
0144   // -- Fetch volume for sensitivity and attach sensitive module to it:
0145   G4LogicalVolume* logicSD = G4LogicalVolumeStore::GetInstance()->GetVolume("meas.logical");
0146   logicSD->SetSensitiveDetector(sd);
0147 }