Import Geant4 11.1.0.beta source tree
This commit is contained in:
+65
@@ -0,0 +1,65 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * License and Disclaimer *
|
||||
// * *
|
||||
// * The Geant4 software is copyright of the Copyright Holders of *
|
||||
// * the Geant4 Collaboration. It is provided under the terms and *
|
||||
// * conditions of the Geant4 Software License, included in the file *
|
||||
// * LICENSE and available at http://cern.ch/geant4/license . These *
|
||||
// * include a list of copyright holders. *
|
||||
// * *
|
||||
// * Neither the authors of this software system, nor their employing *
|
||||
// * institutes,nor the agencies providing financial support for this *
|
||||
// * work make any representation or warranty, express or implied, *
|
||||
// * regarding this software system or assume any liability for its *
|
||||
// * use. Please see the license in the file LICENSE and URL above *
|
||||
// * for the full disclaimer and the limitation of liability. *
|
||||
// * *
|
||||
// * This code implementation is the result of the scientific and *
|
||||
// * technical work of the GEANT4 collaboration. *
|
||||
// * By using, copying, modifying or distributing the software (or *
|
||||
// * any work based on the software) you agree to acknowledge its *
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
/// \file ActionInitialization.cc
|
||||
/// \brief Implementation of the ActionInitialization class
|
||||
//
|
||||
//
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
#include "ActionInitialization.hh"
|
||||
#include "PrimaryGeneratorAction.hh"
|
||||
#include "RunAction.hh"
|
||||
#include "SteppingAction.hh"
|
||||
#include "Run.hh"
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
ActionInitialization::ActionInitialization() : G4VUserActionInitialization() {}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
ActionInitialization::~ActionInitialization() {}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void ActionInitialization::BuildForMaster() const {
|
||||
// This is NOT called in SEQ-mode, while in the MT-mode is called only for the Master thread.
|
||||
SetUserAction( new RunAction );
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void ActionInitialization::Build() const {
|
||||
// This is called in the SEQ-mode and in the MT-mode only for Worker threads.
|
||||
SetUserAction( new PrimaryGeneratorAction );
|
||||
SteppingAction* steppingAction = new SteppingAction;
|
||||
SetUserAction( steppingAction );
|
||||
SetUserAction( new RunAction( steppingAction ) );
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
+409
@@ -0,0 +1,409 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * License and Disclaimer *
|
||||
// * *
|
||||
// * The Geant4 software is copyright of the Copyright Holders of *
|
||||
// * the Geant4 Collaboration. It is provided under the terms and *
|
||||
// * conditions of the Geant4 Software License, included in the file *
|
||||
// * LICENSE and available at http://cern.ch/geant4/license . These *
|
||||
// * include a list of copyright holders. *
|
||||
// * *
|
||||
// * Neither the authors of this software system, nor their employing *
|
||||
// * institutes,nor the agencies providing financial support for this *
|
||||
// * work make any representation or warranty, express or implied, *
|
||||
// * regarding this software system or assume any liability for its *
|
||||
// * use. Please see the license in the file LICENSE and URL above *
|
||||
// * for the full disclaimer and the limitation of liability. *
|
||||
// * *
|
||||
// * This code implementation is the result of the scientific and *
|
||||
// * technical work of the GEANT4 collaboration. *
|
||||
// * By using, copying, modifying or distributing the software (or *
|
||||
// * any work based on the software) you agree to acknowledge its *
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
/// \file DetectorConstruction.cc
|
||||
/// \brief Implementation of the DetectorConstruction class
|
||||
//
|
||||
//
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
#include "DetectorConstruction.hh"
|
||||
#include "DetectorMessenger.hh"
|
||||
#include "PrimaryGeneratorAction.hh"
|
||||
#include "G4Material.hh"
|
||||
#include "G4NistManager.hh"
|
||||
#include "G4Box.hh"
|
||||
#include "G4Sphere.hh"
|
||||
#include "G4LogicalVolume.hh"
|
||||
#include "G4ThreeVector.hh"
|
||||
#include "G4PVPlacement.hh"
|
||||
#include "globals.hh"
|
||||
#include "G4GeometryManager.hh"
|
||||
#include "G4PhysicalVolumeStore.hh"
|
||||
#include "G4LogicalVolumeStore.hh"
|
||||
#include "G4SolidStore.hh"
|
||||
#include "G4RunManager.hh"
|
||||
#include "G4SystemOfUnits.hh"
|
||||
#include "G4PhysicalConstants.hh"
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
DetectorConstruction::DetectorConstruction() :
|
||||
fMaterialTracker( nullptr ), fMaterialEmCalo( nullptr ), fMaterialHadCalo( nullptr ),
|
||||
fExperimentalHall_log( nullptr ), fExperimentalHall_phys( nullptr ),
|
||||
fLogicTrackerShell( nullptr), fPhysiTrackerShell( nullptr ),
|
||||
fLogicEmCaloShell( nullptr), fPhysiEmCaloShell( nullptr),
|
||||
fLogicHadCaloShell( nullptr), fPhysiHadCaloShell( nullptr),
|
||||
fLogicScoringTrackerShell( nullptr), fPhysiScoringTrackerShell( nullptr ),
|
||||
fLogicScoringEmCaloShell( nullptr), fPhysiScoringEmCaloShell( nullptr),
|
||||
fLogicScoringHadCaloShell( nullptr), fPhysiScoringHadCaloShell( nullptr),
|
||||
fDetectorMessenger( nullptr ),
|
||||
fInnerRadiusTracker( 10.0*cm ), fOuterRadiusTracker( 20.0*cm ), //***LOOKHERE*** Default radii
|
||||
fInnerRadiusEmCalo( 30.0*cm ), fOuterRadiusEmCalo( 60.0*cm ),
|
||||
fInnerRadiusHadCalo( 70.0*cm ), fOuterRadiusHadCalo( 170.0*cm )
|
||||
{
|
||||
//G4cout << " BEGIN DetectorConstruction::DetectorConstruction()" << G4endl;
|
||||
fMaterialTracker = G4NistManager::Instance()->FindOrBuildMaterial( "G4_Si" ); //***LOOKHERE***
|
||||
// Default material
|
||||
fMaterialEmCalo = G4NistManager::Instance()->FindOrBuildMaterial( "G4_PbWO4" );
|
||||
fMaterialHadCalo = G4NistManager::Instance()->FindOrBuildMaterial( "G4_Fe" );
|
||||
fDetectorMessenger = new DetectorMessenger( this );
|
||||
//G4cout << " END DetectorConstruction::DetectorConstruction()" << G4endl;
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
DetectorConstruction::~DetectorConstruction() {
|
||||
delete fDetectorMessenger;
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
G4VPhysicalVolume* DetectorConstruction::Construct() {
|
||||
//G4cout << " BEGIN DetectorConstruction::Construct()" << G4endl;
|
||||
return ConstructDetector();
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
G4VPhysicalVolume* DetectorConstruction::ConstructDetector() {
|
||||
//G4cout << " BEGIN DetectorConstruction::ConstructDetector()" << G4endl;
|
||||
|
||||
// Clean old geometry, if any.
|
||||
G4GeometryManager::GetInstance()->OpenGeometry();
|
||||
|
||||
G4PhysicalVolumeStore::GetInstance()->Clean();
|
||||
G4LogicalVolumeStore::GetInstance()->Clean();
|
||||
G4SolidStore::GetInstance()->Clean();
|
||||
|
||||
// Check that the radii are resonable
|
||||
G4bool isOK = true;
|
||||
if ( fInnerRadiusTracker < 0.0 ||
|
||||
fOuterRadiusTracker < fInnerRadiusTracker ||
|
||||
fInnerRadiusEmCalo < fOuterRadiusTracker + fScoringThickness ||
|
||||
fOuterRadiusEmCalo < fInnerRadiusEmCalo ||
|
||||
fInnerRadiusHadCalo < fOuterRadiusEmCalo + fScoringThickness ||
|
||||
fOuterRadiusHadCalo < fInnerRadiusHadCalo ) {
|
||||
isOK = false;
|
||||
}
|
||||
if ( ! isOK ) {
|
||||
G4cerr << G4endl << "ERROR: the radii are inconsistent !" << G4endl
|
||||
<< " InnerRadiusTracker = " << fInnerRadiusTracker << " mm" << G4endl
|
||||
<< " OuterRadiusTracker = " << fOuterRadiusTracker << " mm" << G4endl
|
||||
<< " InnerRadiusEmCalo = " << fInnerRadiusEmCalo << " mm" << G4endl
|
||||
<< " OuterRadiusEmCalo = " << fOuterRadiusEmCalo << " mm" << G4endl
|
||||
<< " InnerRadiusHadCalo = " << fInnerRadiusHadCalo << " mm" << G4endl
|
||||
<< " OuterRadiusHadCalo = " << fOuterRadiusHadCalo << " mm" << G4endl
|
||||
<< " ScoringThickness = " << fScoringThickness << " mm" << G4endl
|
||||
<< G4endl;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// The detector consists of 3 concentric full spherical shells (G4Sphere),
|
||||
// positioned at the center, (0.0, 0.0, 0.0).
|
||||
// The world volume (experimental hall) is a box 10% bigger than the outmost
|
||||
// spherical shell.
|
||||
// and it is filled of "G4_Galactic" material.
|
||||
|
||||
G4double expHall_x = 1.1*fOuterRadiusHadCalo; // half dimension along x
|
||||
G4double expHall_y = 1.1*fOuterRadiusHadCalo; // half dimension along y
|
||||
G4double expHall_z = 1.1*fOuterRadiusHadCalo; // half dimension along z
|
||||
|
||||
G4Material* vacuum = G4NistManager::Instance()->FindOrBuildMaterial( "G4_Galactic" );
|
||||
|
||||
G4Box* experimentalHall_box = new G4Box( "expHall_box", expHall_x, expHall_y, expHall_z );
|
||||
|
||||
fExperimentalHall_log = new G4LogicalVolume( experimentalHall_box, // solid
|
||||
vacuum, // material
|
||||
"expHall_log", // name
|
||||
0, // field manager
|
||||
0, // sensitive detector
|
||||
0 ); // user limits
|
||||
|
||||
fExperimentalHall_phys = new G4PVPlacement( 0, // rotation
|
||||
G4ThreeVector(), // translation
|
||||
"expHall", // name
|
||||
fExperimentalHall_log, // logical volume
|
||||
0, // mother physical volume
|
||||
false, // boolean operation
|
||||
0 ); // copy number
|
||||
|
||||
// 1st (innermost) spherical shell: Tracker
|
||||
G4Sphere* solidTrackerShell = new G4Sphere( "solidTrackerShell", // name
|
||||
fInnerRadiusTracker, // Inner radius
|
||||
fOuterRadiusTracker, // Outer radius
|
||||
0.0, // Starting Phi angle of the
|
||||
// segment in radians
|
||||
2.0*CLHEP::pi, // Delta Phi angle of the
|
||||
// segment in radians
|
||||
0.0, // Starting Theta angle of
|
||||
// the segment in radians
|
||||
CLHEP::pi ); // Delta Theta angle of the
|
||||
// segment in radians
|
||||
fLogicTrackerShell = new G4LogicalVolume( solidTrackerShell, // solid
|
||||
fMaterialTracker, // material
|
||||
"logicTrackerShell", // name
|
||||
0, // field manager
|
||||
0, // sensitive detector
|
||||
0 ); // user limits
|
||||
fPhysiTrackerShell = new G4PVPlacement( 0, // rotation
|
||||
G4ThreeVector(), // translation
|
||||
"physiTrackerShell", // name
|
||||
fLogicTrackerShell, // logical volume
|
||||
fExperimentalHall_phys, // mother physical volume
|
||||
false, // boolean operation
|
||||
0 ); // copy number
|
||||
|
||||
// Scoring tracker shell (a thin vacuum layer, immediately outside the Tracker shell)
|
||||
G4Sphere* solidScoringTrackerShell =
|
||||
new G4Sphere( "solidScoringTrackerShell", // name
|
||||
fOuterRadiusTracker, // Inner radius
|
||||
fOuterRadiusTracker + fScoringThickness, // Outer radius
|
||||
0.0, // Starting Phi angle of the segment
|
||||
// in radians
|
||||
2.0*CLHEP::pi, // Delta Phi angle of the segment
|
||||
// in radians
|
||||
0.0, // Starting Theta angle of the segment
|
||||
// in radians
|
||||
CLHEP::pi ); // Delta Theta angle of the segment
|
||||
// in radians
|
||||
fLogicScoringTrackerShell = new G4LogicalVolume( solidScoringTrackerShell, // solid
|
||||
vacuum, // material
|
||||
"logicScoringTrackerShell", // name
|
||||
0, // field manager
|
||||
0, // sensitive
|
||||
// detector
|
||||
0 ); // user limits
|
||||
fPhysiScoringTrackerShell = new G4PVPlacement( 0, // rotation
|
||||
G4ThreeVector(), // translation
|
||||
"physiScoringTrackerShell", // name
|
||||
fLogicScoringTrackerShell, // logical volume
|
||||
fExperimentalHall_phys, // mother physical
|
||||
// volume
|
||||
false, // boolean
|
||||
// operation
|
||||
0 ); // copy number
|
||||
|
||||
// 2nd (middle) spherical shell: EM Calo
|
||||
G4Sphere* solidEmCaloShell = new G4Sphere( "solidEmCaloShell", // name
|
||||
fInnerRadiusEmCalo, // Inner radius
|
||||
fOuterRadiusEmCalo, // Outer radius
|
||||
0.0, // Starting Phi angle of the
|
||||
// segment in radians
|
||||
2.0*CLHEP::pi, // Delta Phi angle of the
|
||||
// segment in radians
|
||||
0.0, // Starting Theta angle of the
|
||||
// segment in radians
|
||||
CLHEP::pi ); // Delta Theta angle of the
|
||||
// segment in radians
|
||||
fLogicEmCaloShell = new G4LogicalVolume( solidEmCaloShell, // solid
|
||||
fMaterialEmCalo, // material
|
||||
"logicEmCaloShell", // name
|
||||
0, // field manager
|
||||
0, // sensitive detector
|
||||
0 ); // user limits
|
||||
fPhysiEmCaloShell = new G4PVPlacement( 0, // rotation
|
||||
G4ThreeVector(), // translation
|
||||
"physiEmCaloShell", // name
|
||||
fLogicEmCaloShell, // logical volume
|
||||
fExperimentalHall_phys, // mother physical volume
|
||||
false, // boolean operation
|
||||
0 ); // copy number
|
||||
|
||||
// Scoring EmCalo shell (a thin vacuum layer, immediately outside the EmCalo shell)
|
||||
G4Sphere* solidScoringEmCaloShell =
|
||||
new G4Sphere( "solidScoringEmCaloShell", // name
|
||||
fOuterRadiusEmCalo, // Inner radius
|
||||
fOuterRadiusEmCalo + fScoringThickness, // Outer radius
|
||||
0.0, // Starting Phi angle of the segment
|
||||
// in radians
|
||||
2.0*CLHEP::pi, // Delta Phi angle of the segment
|
||||
// in radians
|
||||
0.0, // Starting Theta angle of the
|
||||
// segment in radians
|
||||
CLHEP::pi ); // Delta Theta angle of the segment
|
||||
// in radians
|
||||
fLogicScoringEmCaloShell = new G4LogicalVolume( solidScoringEmCaloShell, // solid
|
||||
vacuum, // material
|
||||
"logicScoringEmCaloShell", // name
|
||||
0, // field manager
|
||||
0, // sensitive
|
||||
// detector
|
||||
0 ); // user limits
|
||||
fPhysiScoringEmCaloShell = new G4PVPlacement( 0, // rotation
|
||||
G4ThreeVector(), // translation
|
||||
"physiScoringEmCaloShell", // name
|
||||
fLogicScoringEmCaloShell, // logical volume
|
||||
fExperimentalHall_phys, // mother physical
|
||||
// volume
|
||||
false, // boolean operation
|
||||
0 ); // copy number
|
||||
|
||||
// 3rd (outmost) spherical shell: HAD Calo
|
||||
G4Sphere* solidHadCaloShell = new G4Sphere( "solidHadCaloShell", // name
|
||||
fInnerRadiusHadCalo, // Inner radius
|
||||
fOuterRadiusHadCalo, // Outer radius
|
||||
0.0, // Starting Phi angle of the
|
||||
// segment in radians
|
||||
2.0*CLHEP::pi, // Delta Phi angle of the
|
||||
// segment in radians
|
||||
0.0, // Starting Theta angle of
|
||||
// the segment in radians
|
||||
CLHEP::pi ); // Delta Theta angle of the
|
||||
// segment in radians
|
||||
fLogicHadCaloShell = new G4LogicalVolume( solidHadCaloShell, // solid
|
||||
fMaterialHadCalo, // material
|
||||
"logicHadCaloShell", // name
|
||||
0, // field manager
|
||||
0, // sensitive detector
|
||||
0 ); // user limits
|
||||
fPhysiHadCaloShell = new G4PVPlacement( 0, // rotation
|
||||
G4ThreeVector(), // translation
|
||||
"physiHadCaloShell", // name
|
||||
fLogicHadCaloShell, // logical volume
|
||||
fExperimentalHall_phys, // mother physical volume
|
||||
false, // boolean operation
|
||||
0 ); // copy number
|
||||
|
||||
// Scoring HadCalo shell (a thin vacuum layer, immediately outside the HadCalo shell)
|
||||
G4Sphere* solidScoringHadCaloShell =
|
||||
new G4Sphere( "solidScoringHadCaloShell", // name
|
||||
fOuterRadiusHadCalo, // Inner radius
|
||||
fOuterRadiusHadCalo + fScoringThickness, // Outer radius
|
||||
0.0, // Starting Phi angle of the
|
||||
// segment in radians
|
||||
2.0*CLHEP::pi, // Delta Phi angle of the segment
|
||||
// in radians
|
||||
0.0, // Starting Theta angle of the
|
||||
// segment in radians
|
||||
CLHEP::pi ); // Delta Theta angle of the segment
|
||||
// in radians
|
||||
fLogicScoringHadCaloShell = new G4LogicalVolume( solidScoringHadCaloShell, // solid
|
||||
vacuum, // material
|
||||
"logicScoringHadCaloShell", // name
|
||||
0, // field manager
|
||||
0, // sensitive
|
||||
// detector
|
||||
0 ); // user limits
|
||||
fPhysiScoringHadCaloShell = new G4PVPlacement( 0, // rotation
|
||||
G4ThreeVector(), // translation
|
||||
"physiScoringHadCaloShell", // name
|
||||
fLogicScoringHadCaloShell, // logical volume
|
||||
fExperimentalHall_phys, // mother physical
|
||||
// volume
|
||||
false, // boolean
|
||||
// operation
|
||||
0 ); // copy number
|
||||
|
||||
G4cout << "DetectorConstruction::ConstructSphere() : " << G4endl
|
||||
<< "\t World (box) size: " << G4endl
|
||||
<< "\t \t x : -/+ " << expHall_x << " mm ;"
|
||||
<< "\t y : -/+ " << expHall_y << " mm ;"
|
||||
<< "\t z : -/+ " << expHall_z << " mm ;" << G4endl
|
||||
<< G4endl;
|
||||
PrintParameters();
|
||||
//G4cout << " END DetectorConstruction::ConstructDetector()
|
||||
|
||||
return fExperimentalHall_phys;
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void DetectorConstruction::SetMaterialTracker( const G4String name ) {
|
||||
fMaterialTracker = G4NistManager::Instance()->FindOrBuildMaterial( name );
|
||||
if ( ! fMaterialTracker ) {
|
||||
G4cout << G4endl << G4endl
|
||||
<< "WARNING: the name of the material has not been recognized!" << G4endl
|
||||
<< " ===> the default * G4_Si * will be used."
|
||||
<< G4endl << G4endl;
|
||||
fMaterialTracker = G4NistManager::Instance()->FindOrBuildMaterial( "G4_Si" );
|
||||
}
|
||||
if ( fLogicTrackerShell ) fLogicTrackerShell->SetMaterial( fMaterialTracker );
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void DetectorConstruction::SetMaterialEmCalo( const G4String name ) {
|
||||
fMaterialEmCalo = G4NistManager::Instance()->FindOrBuildMaterial( name );
|
||||
if ( ! fMaterialEmCalo ) {
|
||||
G4cout << G4endl << G4endl
|
||||
<< "WARNING: the name of the material has not been recognized!" << G4endl
|
||||
<< " ===> the default * G4_Pb * will be used."
|
||||
<< G4endl << G4endl;
|
||||
fMaterialEmCalo = G4NistManager::Instance()->FindOrBuildMaterial( "G4_Pb" );
|
||||
}
|
||||
if ( fLogicEmCaloShell ) fLogicEmCaloShell->SetMaterial( fMaterialEmCalo );
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void DetectorConstruction::SetMaterialHadCalo( const G4String name ) {
|
||||
fMaterialHadCalo = G4NistManager::Instance()->FindOrBuildMaterial( name );
|
||||
if ( fMaterialHadCalo == nullptr ) {
|
||||
G4cout << G4endl << G4endl
|
||||
<< "WARNING: the name of the material has not been recognized!" << G4endl
|
||||
<< " ===> the default * G4_Fe * will be used."
|
||||
<< G4endl << G4endl;
|
||||
fMaterialHadCalo = G4NistManager::Instance()->FindOrBuildMaterial( "G4_Fe" );
|
||||
}
|
||||
if ( fLogicHadCaloShell ) fLogicHadCaloShell->SetMaterial( fMaterialHadCalo );
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void DetectorConstruction::UpdateGeometry() {
|
||||
//G4cout << " BEGIN DetectorConstruction::UpdateGeometry" << G4endl;
|
||||
G4RunManager::GetRunManager()->ReinitializeGeometry();
|
||||
PrintParameters();
|
||||
// Update also the position of the gun
|
||||
const PrimaryGeneratorAction* pPrimaryAction =
|
||||
dynamic_cast< const PrimaryGeneratorAction* >
|
||||
( G4RunManager::GetRunManager()->GetUserPrimaryGeneratorAction() );
|
||||
if ( pPrimaryAction ) pPrimaryAction->SetGunPosition();
|
||||
//G4cout << " END DetectorConstruction::UpdateGeometry" << G4endl;
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void DetectorConstruction::PrintParameters() {
|
||||
G4cout << G4endl
|
||||
<< " ------ DetectorConstruction::PrintParameters() ------ " << G4endl
|
||||
<< " MaterialTracker = " << fMaterialTracker->GetName() << G4endl
|
||||
<< " MaterialEmCalo = " << fMaterialEmCalo->GetName() << G4endl
|
||||
<< " MaterialHadCalo = " << fMaterialHadCalo->GetName() << G4endl
|
||||
<< " InnerRadiusTracker = " << fInnerRadiusTracker << " mm" << G4endl
|
||||
<< " OuterRadiusTracker = " << fOuterRadiusTracker << " mm" << G4endl
|
||||
<< " InnerRadiusEmCalo = " << fInnerRadiusEmCalo << " mm" << G4endl
|
||||
<< " OuterRadiusEmCalo = " << fOuterRadiusEmCalo << " mm" << G4endl
|
||||
<< " InnerRadiusHadCalo = " << fInnerRadiusHadCalo << " mm" << G4endl
|
||||
<< " OuterRadiusHadCalo = " << fOuterRadiusHadCalo << " mm" << G4endl
|
||||
<< " ScoringThickness = " << fScoringThickness << " mm" << G4endl
|
||||
<< " -------------------------------------------------------- " << G4endl
|
||||
<< G4endl;
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
+163
@@ -0,0 +1,163 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * License and Disclaimer *
|
||||
// * *
|
||||
// * The Geant4 software is copyright of the Copyright Holders of *
|
||||
// * the Geant4 Collaboration. It is provided under the terms and *
|
||||
// * conditions of the Geant4 Software License, included in the file *
|
||||
// * LICENSE and available at http://cern.ch/geant4/license . These *
|
||||
// * include a list of copyright holders. *
|
||||
// * *
|
||||
// * Neither the authors of this software system, nor their employing *
|
||||
// * institutes,nor the agencies providing financial support for this *
|
||||
// * work make any representation or warranty, express or implied, *
|
||||
// * regarding this software system or assume any liability for its *
|
||||
// * use. Please see the license in the file LICENSE and URL above *
|
||||
// * for the full disclaimer and the limitation of liability. *
|
||||
// * *
|
||||
// * This code implementation is the result of the scientific and *
|
||||
// * technical work of the GEANT4 collaboration. *
|
||||
// * By using, copying, modifying or distributing the software (or *
|
||||
// * any work based on the software) you agree to acknowledge its *
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
/// \file DetectorMessenger.cc
|
||||
/// \brief Implementation of the DetectorMessenger class
|
||||
//
|
||||
//
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
#include "DetectorMessenger.hh"
|
||||
#include "DetectorConstruction.hh"
|
||||
#include "G4UIdirectory.hh"
|
||||
#include "G4UIcmdWithADoubleAndUnit.hh"
|
||||
#include "G4UIcmdWithAString.hh"
|
||||
#include "G4UIcmdWithoutParameter.hh"
|
||||
#include "globals.hh"
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
DetectorMessenger::DetectorMessenger( DetectorConstruction* myDet ) : fDetector( myDet ) {
|
||||
fDetectorDir = new G4UIdirectory( "/mydet/" );
|
||||
fDetectorDir->SetGuidance( "Detector control." );
|
||||
|
||||
fMaterialTracker = new G4UIcmdWithAString( "/mydet/material_tracker", this );
|
||||
fMaterialTracker->SetGuidance( "Choice of the material for the Tracker:" );
|
||||
fMaterialTracker->SetGuidance( " a Geant4 NIST material, e.g. G4_Si " );
|
||||
fMaterialTracker->SetParameterName( "choiceMaterial", true );
|
||||
fMaterialTracker->SetDefaultValue( "G4_Si" );
|
||||
fMaterialTracker->AvailableForStates( G4State_PreInit, G4State_Idle );
|
||||
|
||||
fMaterialEmCalo = new G4UIcmdWithAString( "/mydet/material_emCalo", this );
|
||||
fMaterialEmCalo->SetGuidance( "Choice of the material for the EM calo:" );
|
||||
fMaterialEmCalo->SetGuidance( " a Geant4 NIST material, e.g. G4_Pb " );
|
||||
fMaterialEmCalo->SetParameterName( "choiceMaterial", true );
|
||||
fMaterialEmCalo->SetDefaultValue( "G4_Pb" );
|
||||
fMaterialEmCalo->AvailableForStates( G4State_PreInit, G4State_Idle );
|
||||
|
||||
fMaterialHadCalo = new G4UIcmdWithAString( "/mydet/material_hadCalo", this );
|
||||
fMaterialHadCalo->SetGuidance( "Choice of the material for the HAD calo:" );
|
||||
fMaterialHadCalo->SetGuidance( " a Geant4 NIST material, e.g. G4_Fe " );
|
||||
fMaterialHadCalo->SetParameterName( "choiceMaterial", true );
|
||||
fMaterialHadCalo->SetDefaultValue( "G4_Fe" );
|
||||
fMaterialHadCalo->AvailableForStates( G4State_PreInit, G4State_Idle );
|
||||
|
||||
fInnerRadiusTracker = new G4UIcmdWithADoubleAndUnit( "/mydet/inner_radius_tracker", this );
|
||||
fInnerRadiusTracker->SetParameterName( "choiceInnerRadiusTracker", true );
|
||||
fInnerRadiusTracker->SetGuidance( "Inner radius of the Tracker" );
|
||||
fInnerRadiusTracker->SetDefaultValue( 100.0 ); // default: 10 cm.
|
||||
fInnerRadiusTracker->AvailableForStates( G4State_PreInit, G4State_Idle );
|
||||
|
||||
fOuterRadiusTracker = new G4UIcmdWithADoubleAndUnit( "/mydet/outer_radius_tracker", this );
|
||||
fOuterRadiusTracker->SetParameterName( "choiceOuterRadiusTracker", true );
|
||||
fOuterRadiusTracker->SetGuidance( "Outer radius of the Tracker" );
|
||||
fOuterRadiusTracker->SetDefaultValue( 200.0 ); // default: 20 cm.
|
||||
fOuterRadiusTracker->AvailableForStates( G4State_PreInit, G4State_Idle );
|
||||
|
||||
fInnerRadiusEmCalo = new G4UIcmdWithADoubleAndUnit( "/mydet/inner_radius_emCalo", this );
|
||||
fInnerRadiusEmCalo->SetParameterName( "choiceInnerRadiusEmCalo", true );
|
||||
fInnerRadiusEmCalo->SetGuidance( "Inner radius of the EM Calo" );
|
||||
fInnerRadiusEmCalo->SetDefaultValue( 300.0 ); // default: 30 cm.
|
||||
fInnerRadiusEmCalo->AvailableForStates( G4State_PreInit, G4State_Idle );
|
||||
|
||||
fOuterRadiusEmCalo = new G4UIcmdWithADoubleAndUnit( "/mydet/outer_radius_emCalo", this );
|
||||
fOuterRadiusEmCalo->SetParameterName( "choiceOuterRadiusEmCalo", true );
|
||||
fOuterRadiusEmCalo->SetGuidance( "Outer radius of the EM Calo" );
|
||||
fOuterRadiusEmCalo->SetDefaultValue( 600.0 ); // default: 60 cm.
|
||||
fOuterRadiusEmCalo->AvailableForStates( G4State_PreInit, G4State_Idle );
|
||||
|
||||
fInnerRadiusHadCalo = new G4UIcmdWithADoubleAndUnit( "/mydet/inner_radius_hadCalo", this );
|
||||
fInnerRadiusHadCalo->SetParameterName( "choiceInnerRadiusHadCalo", true );
|
||||
fInnerRadiusHadCalo->SetGuidance( "Inner radius of the HAD Calo" );
|
||||
fInnerRadiusHadCalo->SetDefaultValue( 700.0 ); // default: 70 cm.
|
||||
fInnerRadiusHadCalo->AvailableForStates( G4State_PreInit, G4State_Idle );
|
||||
|
||||
fOuterRadiusHadCalo = new G4UIcmdWithADoubleAndUnit( "/mydet/outer_radius_hadCalo", this );
|
||||
fOuterRadiusHadCalo->SetParameterName( "choiceOuterRadiusHadCalo", true );
|
||||
fOuterRadiusHadCalo->SetGuidance( "Outer radius of the HAD Calo" );
|
||||
fOuterRadiusHadCalo->SetDefaultValue( 1700.0 ); // default: 170 cm.
|
||||
fOuterRadiusHadCalo->AvailableForStates( G4State_PreInit, G4State_Idle );
|
||||
|
||||
fUpdateCommand = new G4UIcmdWithoutParameter( "/mydet/update", this);
|
||||
fUpdateCommand->SetGuidance( "Update geometry." );
|
||||
fUpdateCommand->SetGuidance( "This command MUST be applied before \"beamOn\" " );
|
||||
fUpdateCommand->SetGuidance( "if you changed geometrical value(s)." );
|
||||
fUpdateCommand->AvailableForStates( G4State_Idle );
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
DetectorMessenger::~DetectorMessenger() {
|
||||
delete fDetectorDir;
|
||||
delete fMaterialTracker;
|
||||
delete fMaterialEmCalo;
|
||||
delete fMaterialHadCalo;
|
||||
delete fInnerRadiusTracker;
|
||||
delete fOuterRadiusTracker;
|
||||
delete fInnerRadiusEmCalo;
|
||||
delete fOuterRadiusEmCalo;
|
||||
delete fInnerRadiusHadCalo;
|
||||
delete fOuterRadiusHadCalo;
|
||||
delete fUpdateCommand;
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void DetectorMessenger::SetNewValue( G4UIcommand* command, G4String newValue ) {
|
||||
if ( command == fMaterialTracker ) {
|
||||
fDetector->SetMaterialTracker( newValue );
|
||||
}
|
||||
if ( command == fMaterialEmCalo ) {
|
||||
fDetector->SetMaterialEmCalo( newValue );
|
||||
}
|
||||
if ( command == fMaterialHadCalo ) {
|
||||
fDetector->SetMaterialHadCalo( newValue );
|
||||
}
|
||||
if ( command == fInnerRadiusTracker ) {
|
||||
fDetector->SetInnerRadiusTracker( fInnerRadiusTracker->GetNewDoubleValue( newValue ) );
|
||||
}
|
||||
if ( command == fOuterRadiusTracker ) {
|
||||
fDetector->SetOuterRadiusTracker( fOuterRadiusTracker->GetNewDoubleValue( newValue ) );
|
||||
}
|
||||
if ( command == fInnerRadiusEmCalo ) {
|
||||
fDetector->SetInnerRadiusEmCalo( fInnerRadiusEmCalo->GetNewDoubleValue( newValue ) );
|
||||
}
|
||||
if ( command == fOuterRadiusEmCalo ) {
|
||||
fDetector->SetOuterRadiusEmCalo( fOuterRadiusEmCalo->GetNewDoubleValue( newValue ) );
|
||||
}
|
||||
if ( command == fInnerRadiusHadCalo ) {
|
||||
fDetector->SetInnerRadiusHadCalo( fInnerRadiusHadCalo->GetNewDoubleValue( newValue ) );
|
||||
}
|
||||
if ( command == fOuterRadiusHadCalo ) {
|
||||
fDetector->SetOuterRadiusHadCalo( fOuterRadiusHadCalo->GetNewDoubleValue( newValue ) );
|
||||
}
|
||||
if ( command == fUpdateCommand ) {
|
||||
fDetector->UpdateGeometry();
|
||||
}
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
Executable
+76
@@ -0,0 +1,76 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * License and Disclaimer *
|
||||
// * *
|
||||
// * The Geant4 software is copyright of the Copyright Holders of *
|
||||
// * the Geant4 Collaboration. It is provided under the terms and *
|
||||
// * conditions of the Geant4 Software License, included in the file *
|
||||
// * LICENSE and available at http://cern.ch/geant4/license . These *
|
||||
// * include a list of copyright holders. *
|
||||
// * *
|
||||
// * Neither the authors of this software system, nor their employing *
|
||||
// * institutes,nor the agencies providing financial support for this *
|
||||
// * work make any representation or warranty, express or implied, *
|
||||
// * regarding this software system or assume any liability for its *
|
||||
// * use. Please see the license in the file LICENSE and URL above *
|
||||
// * for the full disclaimer and the limitation of liability. *
|
||||
// * *
|
||||
// * This code implementation is the result of the scientific and *
|
||||
// * technical work of the GEANT4 collaboration. *
|
||||
// * By using, copying, modifying or distributing the software (or *
|
||||
// * any work based on the software) you agree to acknowledge its *
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
/// \file PrimaryGeneratorAction.cc
|
||||
/// \brief Implementation of the PrimaryGeneratorAction class
|
||||
//
|
||||
//
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
#include "PrimaryGeneratorAction.hh"
|
||||
#include "G4Event.hh"
|
||||
#include "G4ParticleGun.hh"
|
||||
#include "G4ParticleTable.hh"
|
||||
#include "G4ParticleDefinition.hh"
|
||||
#include "globals.hh"
|
||||
#include "G4SystemOfUnits.hh"
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
PrimaryGeneratorAction::PrimaryGeneratorAction() : G4VUserPrimaryGeneratorAction(),
|
||||
fParticleGun( nullptr ) {
|
||||
G4int n_particle = 1;
|
||||
fParticleGun = new G4ParticleGun( n_particle );
|
||||
G4ParticleTable* particleTable = G4ParticleTable::GetParticleTable();
|
||||
//***LOOKHERE*** Default particle and energy
|
||||
fParticleGun->SetParticleDefinition( particleTable->FindParticle( "geantino" ) );
|
||||
fParticleGun->SetParticleEnergy( 10.0*GeV );
|
||||
SetGunPosition();
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
PrimaryGeneratorAction::~PrimaryGeneratorAction() {
|
||||
delete fParticleGun;
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void PrimaryGeneratorAction::SetGunPosition() const {
|
||||
// Shoot the particle from the center of the sphere
|
||||
fParticleGun->SetParticlePosition( G4ThreeVector( 0.0, 0.0, 0.0 ) );
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void PrimaryGeneratorAction::GeneratePrimaries( G4Event* anEvent ) {
|
||||
G4ThreeVector v( 0.0, 0.0, 1.0 ); //***LOOKHERE*** default shoot along the z-axis
|
||||
fParticleGun->SetParticleMomentumDirection( v );
|
||||
fParticleGun->GeneratePrimaryVertex( anEvent );
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
@@ -0,0 +1,154 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * License and Disclaimer *
|
||||
// * *
|
||||
// * The Geant4 software is copyright of the Copyright Holders of *
|
||||
// * the Geant4 Collaboration. It is provided under the terms and *
|
||||
// * conditions of the Geant4 Software License, included in the file *
|
||||
// * LICENSE and available at http://cern.ch/geant4/license . These *
|
||||
// * include a list of copyright holders. *
|
||||
// * *
|
||||
// * Neither the authors of this software system, nor their employing *
|
||||
// * institutes,nor the agencies providing financial support for this *
|
||||
// * work make any representation or warranty, express or implied, *
|
||||
// * regarding this software system or assume any liability for its *
|
||||
// * use. Please see the license in the file LICENSE and URL above *
|
||||
// * for the full disclaimer and the limitation of liability. *
|
||||
// * *
|
||||
// * This code implementation is the result of the scientific and *
|
||||
// * technical work of the GEANT4 collaboration. *
|
||||
// * By using, copying, modifying or distributing the software (or *
|
||||
// * any work based on the software) you agree to acknowledge its *
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
/// \file Run.cc
|
||||
/// \brief Implementation of the Run class
|
||||
//
|
||||
//
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
#include "Run.hh"
|
||||
#include "G4SystemOfUnits.hh"
|
||||
#include "G4Run.hh"
|
||||
#include "G4RunManager.hh"
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
Run::Run() : G4Run(), fNumEvents( 0 ),
|
||||
fPrimaryParticleId( 0 ), fPrimaryParticleEnergy( 0.0 ),
|
||||
fPrimaryParticleDirection( G4ThreeVector( 0.0, 0.0, 0.0 ) ),
|
||||
fTrackerMaterialName( "" ), fEmCaloMaterialName( "" ), fHadCaloMaterialName( "" ),
|
||||
fCubicVolumeScoringTrackerShell( 1.0 ), fCubicVolumeScoringEmCaloShell( 1.0 ),
|
||||
fCubicVolumeScoringHadCaloShell( 1.0 )
|
||||
{
|
||||
for ( G4int i = 0; i < SteppingAction::numberCombinations; ++i ) fArray[i] = 0.0;
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
Run::~Run() {}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void Run::RecordEvent( const G4Event* anEvent ) {
|
||||
// This method is called automatically by the Geant4 kernel (not by the user!) at the end
|
||||
// of each event : in MT-mode, it is called only for the working thread that handled the event.
|
||||
G4int nEvt = anEvent->GetEventID();
|
||||
if ( nEvt % 10 == 0 ) G4cout << " Event#=" << nEvt << G4endl;
|
||||
G4Run::RecordEvent( anEvent );
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void Run::Merge( const G4Run* aRun ) {
|
||||
// This method is called automatically by the Geant4 kernel (not by the user!) only in the case
|
||||
// of multithreaded mode and only for working threads.
|
||||
const Run* localRun = static_cast< const Run* >( aRun );
|
||||
fPrimaryParticleId = localRun->getPrimaryParticleId();
|
||||
fPrimaryParticleEnergy = localRun->getPrimaryParticleEnergy();
|
||||
fPrimaryParticleDirection = localRun->getPrimaryParticleDirection();
|
||||
fTrackerMaterialName = localRun->getTrackerMaterialName();
|
||||
fEmCaloMaterialName = localRun->getEmCaloMaterialName();
|
||||
fHadCaloMaterialName = localRun->getHadCaloMaterialName();
|
||||
fCubicVolumeScoringTrackerShell = localRun->getCubicVolumeScoringTrackerShell();
|
||||
fCubicVolumeScoringEmCaloShell = localRun->getCubicVolumeScoringEmCaloShell();
|
||||
fCubicVolumeScoringHadCaloShell = localRun->getCubicVolumeScoringHadCaloShell();
|
||||
fNumEvents += localRun->GetNumberOfEvent();
|
||||
for ( G4int i = 0; i < SteppingAction::numberCombinations; ++i ) {
|
||||
fArray[i] += localRun->getArray()[i];
|
||||
}
|
||||
G4Run::Merge( aRun );
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void Run::printInfo() const {
|
||||
// This method is called by RunAction::EndOfRunAction.
|
||||
// In MT-mode, only the master thread calls it.
|
||||
const G4double floatingNumberOfEvents =
|
||||
std::max( 1.0, fNumEvents > 0 ? fNumEvents*1.0 : GetNumberOfEvent()*1.0 );
|
||||
// The fluence in a scoring shell is defined as sum of step lengths in that shell
|
||||
// divided by the cubic-volume of the scoring shell.
|
||||
const G4double conversionFactor = CLHEP::cm * CLHEP::cm; // From mm^-2 to cm^-2
|
||||
const G4double factorTracker =
|
||||
conversionFactor / ( 0.5*fCubicVolumeScoringTrackerShell*floatingNumberOfEvents );
|
||||
const G4double factorEmCalo =
|
||||
conversionFactor / ( 0.5*fCubicVolumeScoringEmCaloShell*floatingNumberOfEvents );
|
||||
const G4double factorHadCalo =
|
||||
conversionFactor / ( 0.5*fCubicVolumeScoringHadCaloShell*floatingNumberOfEvents );
|
||||
G4cout << std::setprecision(6) << G4endl << G4endl
|
||||
<< " =============== Run::printInfo() =============== \t RunID = " << GetRunID()
|
||||
<< G4endl
|
||||
<< " Primary particle PDG code = " << fPrimaryParticleId << G4endl
|
||||
<< " Primary particle kinetic energy = " << fPrimaryParticleEnergy / CLHEP::GeV
|
||||
<< " GeV" << G4endl
|
||||
<< " Primary particle direction = " << fPrimaryParticleDirection << G4endl
|
||||
<< " Tracker material = " << fTrackerMaterialName << G4endl
|
||||
<< " EmCalo material = " << fEmCaloMaterialName << G4endl
|
||||
<< " HadCalo material = " << fHadCaloMaterialName << G4endl
|
||||
<< " Cubic-volume scoring tracker shell = " << fCubicVolumeScoringTrackerShell
|
||||
<< " mm^3" << G4endl
|
||||
<< " Cubic-volume scoring emCalo shell = " << fCubicVolumeScoringEmCaloShell
|
||||
<< " mm^3" << G4endl
|
||||
<< " Cubic-volume scoring hadCalo shell = " << fCubicVolumeScoringHadCaloShell
|
||||
<< " mm^3" << G4endl
|
||||
<< " Number of events = " << floatingNumberOfEvents << G4endl
|
||||
<< " Conversion factor: fluence from mm^-2 to cm^-2 = " << conversionFactor << G4endl
|
||||
<< " Particle fluence in unit of cm^-2 :" << G4endl;
|
||||
for ( G4int i = 0; i < SteppingAction::numberScoringShells; ++i ) {
|
||||
G4double factor = factorTracker;
|
||||
if ( i == 1 ) factor = factorEmCalo;
|
||||
else if ( i == 2 ) factor = factorHadCalo;
|
||||
for ( G4int j = 0; j < SteppingAction::numberKinematicRegions; ++j ) {
|
||||
for ( G4int k = 0; k < SteppingAction::numberScoringPositions; ++k ) {
|
||||
for ( G4int ll = 0; ll < SteppingAction::numberParticleTypes; ++ll ) {
|
||||
G4int index = SteppingAction::getIndex( i, j, k, ll );
|
||||
//G4cout << "(i, j, k, ll)=(" << i << ", " << j << ", " << k << ", "
|
||||
// << ll << ") ->" << index;
|
||||
G4cout << " case=" << std::setw(3) << index
|
||||
<< " " << std::setw(12) << SteppingAction::arrayScoringShellNames[i]
|
||||
<< " " << std::setw(12) << SteppingAction::arrayKinematicRegionNames[j]
|
||||
<< " " << std::setw(12) << SteppingAction::arrayScoringPositionNames[k]
|
||||
<< " " << std::setw(12) << SteppingAction::arrayParticleTypeNames[ll]
|
||||
<< " " << factor*fArray[index] << G4endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
G4cout << " ============================================================= " << G4endl << G4endl;
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void Run::setArray( const std::array< G4double,
|
||||
SteppingAction::numberCombinations >& inputArray ) {
|
||||
for ( G4int i = 0; i < SteppingAction::numberCombinations; ++i ) {
|
||||
fArray[i] = inputArray[i];
|
||||
}
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
+75
@@ -0,0 +1,75 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * License and Disclaimer *
|
||||
// * *
|
||||
// * The Geant4 software is copyright of the Copyright Holders of *
|
||||
// * the Geant4 Collaboration. It is provided under the terms and *
|
||||
// * conditions of the Geant4 Software License, included in the file *
|
||||
// * LICENSE and available at http://cern.ch/geant4/license . These *
|
||||
// * include a list of copyright holders. *
|
||||
// * *
|
||||
// * Neither the authors of this software system, nor their employing *
|
||||
// * institutes,nor the agencies providing financial support for this *
|
||||
// * work make any representation or warranty, express or implied, *
|
||||
// * regarding this software system or assume any liability for its *
|
||||
// * use. Please see the license in the file LICENSE and URL above *
|
||||
// * for the full disclaimer and the limitation of liability. *
|
||||
// * *
|
||||
// * This code implementation is the result of the scientific and *
|
||||
// * technical work of the GEANT4 collaboration. *
|
||||
// * By using, copying, modifying or distributing the software (or *
|
||||
// * any work based on the software) you agree to acknowledge its *
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
/// \file RunAction.cc
|
||||
/// \brief Implementation of the RunAction class
|
||||
//
|
||||
//
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
#include "RunAction.hh"
|
||||
#include "globals.hh"
|
||||
#include "G4Run.hh"
|
||||
#include "Run.hh"
|
||||
#include "SteppingAction.hh"
|
||||
#include "G4RunManager.hh"
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
RunAction::RunAction( SteppingAction* steppingAction ) :
|
||||
G4UserRunAction(), fSteppingAction( steppingAction ) {}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
RunAction::~RunAction() {}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
G4Run* RunAction::GenerateRun() {
|
||||
return new Run;
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void RunAction::BeginOfRunAction( const G4Run* aRun ) {
|
||||
G4cout << "### Run " << aRun->GetRunID() << " starts." << G4endl;
|
||||
if ( fSteppingAction ) {
|
||||
fSteppingAction->initialize();
|
||||
Run* run = const_cast< Run* >( static_cast< const Run* >( aRun ) );
|
||||
if ( run != nullptr ) fSteppingAction->setRunPointer( run );
|
||||
}
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void RunAction::EndOfRunAction( const G4Run* aRun ) {
|
||||
const Run* run = static_cast< const Run* >( aRun );
|
||||
if ( run == nullptr || run->GetNumberOfEvent() == 0 ) return;
|
||||
if ( IsMaster() ) run->printInfo();
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
+252
@@ -0,0 +1,252 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * License and Disclaimer *
|
||||
// * *
|
||||
// * The Geant4 software is copyright of the Copyright Holders of *
|
||||
// * the Geant4 Collaboration. It is provided under the terms and *
|
||||
// * conditions of the Geant4 Software License, included in the file *
|
||||
// * LICENSE and available at http://cern.ch/geant4/license . These *
|
||||
// * include a list of copyright holders. *
|
||||
// * *
|
||||
// * Neither the authors of this software system, nor their employing *
|
||||
// * institutes,nor the agencies providing financial support for this *
|
||||
// * work make any representation or warranty, express or implied, *
|
||||
// * regarding this software system or assume any liability for its *
|
||||
// * use. Please see the license in the file LICENSE and URL above *
|
||||
// * for the full disclaimer and the limitation of liability. *
|
||||
// * *
|
||||
// * This code implementation is the result of the scientific and *
|
||||
// * technical work of the GEANT4 collaboration. *
|
||||
// * By using, copying, modifying or distributing the software (or *
|
||||
// * any work based on the software) you agree to acknowledge its *
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
/// \file SteppingAction.cc
|
||||
/// \brief Implementation of the SteppingAction class
|
||||
//
|
||||
//
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
#include "SteppingAction.hh"
|
||||
#include "G4Track.hh"
|
||||
#include "G4Step.hh"
|
||||
#include "G4ParticleDefinition.hh"
|
||||
#include "G4ParticleTypes.hh"
|
||||
#include "G4IonTable.hh"
|
||||
#include "G4StepPoint.hh"
|
||||
#include "G4VPhysicalVolume.hh"
|
||||
#include "G4VTouchable.hh"
|
||||
#include "G4TouchableHistory.hh"
|
||||
#include "G4VSolid.hh"
|
||||
#include "G4LossTableManager.hh"
|
||||
#include "G4SystemOfUnits.hh"
|
||||
#include "Run.hh"
|
||||
|
||||
const std::array< G4String, SteppingAction::numberScoringShells >
|
||||
SteppingAction::arrayScoringShellNames = { "tracker", "emCalo", "hadCalo" };
|
||||
|
||||
const std::array< G4String, SteppingAction::numberKinematicRegions >
|
||||
SteppingAction::arrayKinematicRegionNames = { "", "below 20 MeV", "above 20 MeV" };
|
||||
|
||||
const std::array< G4String, SteppingAction::numberScoringPositions >
|
||||
SteppingAction::arrayScoringPositionNames = { "forward", "backward" };
|
||||
|
||||
const std::array< G4String, SteppingAction::numberParticleTypes >
|
||||
SteppingAction::arrayParticleTypeNames = { "all", "electron", "gamma", "muon", "neutrino",
|
||||
"pion", "neutron", "proton", "ion", "otherMeson",
|
||||
"otherBaryon" };
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
G4int SteppingAction::getIndex( const G4int iScoringShell, const G4int iKinematicRegion,
|
||||
const G4int iScoringPosition, const G4int iParticleType ) {
|
||||
G4int index = -1;
|
||||
if ( iScoringShell >= 0 && iScoringShell < numberScoringShells &&
|
||||
iKinematicRegion >= 0 && iKinematicRegion < numberKinematicRegions &&
|
||||
iScoringPosition >= 0 && iScoringPosition < numberScoringPositions &&
|
||||
iParticleType >= 0 && iParticleType < numberParticleTypes ) {
|
||||
index = iScoringShell * numberKinematicRegions * numberScoringPositions * numberParticleTypes +
|
||||
iKinematicRegion * numberScoringPositions * numberParticleTypes +
|
||||
iScoringPosition * numberParticleTypes +
|
||||
iParticleType;
|
||||
}
|
||||
return index;
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
SteppingAction::SteppingAction() :G4UserSteppingAction() {
|
||||
initialize();
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
SteppingAction::~SteppingAction() {}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void SteppingAction::initialize() {
|
||||
// Initialization needed at the beginning of each Run
|
||||
fPrimaryParticleId = 0;
|
||||
fPrimaryParticleEnergy = 0.0;
|
||||
fPrimaryParticleDirection = G4ThreeVector( 0.0, 0.0, 1.0 );
|
||||
fTrackerMaterialName = fEmCaloMaterialName = fHadCaloMaterialName = "";
|
||||
fIsFirstStepOfTheEvent = true;
|
||||
fIsFirstStepInTracker = fIsFirstStepInEmCalo = fIsFirstStepInHadCalo = true;
|
||||
fIsFirstStepInScoringTrackerShell = fIsFirstStepInScoringEmCaloShell =
|
||||
fIsFirstStepInScoringHadCaloShell = true;
|
||||
fCubicVolumeScoringTrackerShell = fCubicVolumeScoringEmCaloShell =
|
||||
fCubicVolumeScoringHadCaloShell = 1.0;
|
||||
for ( G4int i = 0; i < numberCombinations; ++i ) {
|
||||
fArraySumStepLengths[i] = 0.0;
|
||||
}
|
||||
/*
|
||||
for ( G4int i = 0; i < numberCombinations; ++i ) fArraySumStepLengths[i] = 999.9;
|
||||
G4cout << " numberCombinations=" << numberCombinations << G4endl;
|
||||
for ( G4int i = 0; i < numberScoringShells; ++i ) {
|
||||
for ( G4int j = 0; j < numberKinematicRegions; ++j ) {
|
||||
for ( G4int k = 0; k < numberScoringPositions; ++k ) {
|
||||
for ( G4int ll = 0; ll < numberParticleTypes; ++ll ) {
|
||||
G4int index = getIndex( i, j, k, ll );
|
||||
G4cout << "(i, j, k, ll)=(" << i << ", " << j << ", " << k << ", "
|
||||
<< ll << ") ->" << index;
|
||||
if ( fArraySumStepLengths[ index ] < 1.0 ) G4cout << " <=== REPEATED!";
|
||||
else fArraySumStepLengths[ index ] = 0.0;
|
||||
G4cout << G4endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
for ( G4int i = 0; i < numberCombinations; ++i ) {
|
||||
if ( fArraySumStepLengths[i] > 999.0 ) G4cout << " i=" << i << " NOT COVERED !" << G4endl;
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void SteppingAction::UserSteppingAction( const G4Step* theStep ) {
|
||||
// Get information on the primary particle
|
||||
if ( fIsFirstStepOfTheEvent ) {
|
||||
if ( theStep->GetTrack()->GetParentID() == 0 ) {
|
||||
fPrimaryParticleId = theStep->GetTrack()->GetDefinition()->GetPDGEncoding();
|
||||
fPrimaryParticleEnergy = theStep->GetPreStepPoint()->GetKineticEnergy();
|
||||
fPrimaryParticleDirection = theStep->GetPreStepPoint()->GetMomentumDirection();
|
||||
if ( fRunPtr ) {
|
||||
fRunPtr->setPrimaryParticleId( fPrimaryParticleId );
|
||||
fRunPtr->setPrimaryParticleEnergy( fPrimaryParticleEnergy );
|
||||
fRunPtr->setPrimaryParticleDirection( fPrimaryParticleDirection );
|
||||
}
|
||||
fIsFirstStepOfTheEvent = false;
|
||||
}
|
||||
}
|
||||
// Get information on the materials
|
||||
if ( fIsFirstStepInTracker &&
|
||||
theStep->GetPreStepPoint()->GetPhysicalVolume()->GetName() == "physiTrackerShell" ) {
|
||||
fTrackerMaterialName = theStep->GetPreStepPoint()->GetMaterial()->GetName();
|
||||
if ( fRunPtr ) fRunPtr->setTrackerMaterialName( fTrackerMaterialName );
|
||||
fIsFirstStepInTracker = false;
|
||||
}
|
||||
if ( fIsFirstStepInEmCalo &&
|
||||
theStep->GetPreStepPoint()->GetPhysicalVolume()->GetName() == "physiEmCaloShell" ) {
|
||||
fEmCaloMaterialName = theStep->GetPreStepPoint()->GetMaterial()->GetName();
|
||||
if ( fRunPtr ) fRunPtr->setEmCaloMaterialName( fEmCaloMaterialName );
|
||||
fIsFirstStepInEmCalo = false;
|
||||
}
|
||||
if ( fIsFirstStepInHadCalo &&
|
||||
theStep->GetPreStepPoint()->GetPhysicalVolume()->GetName() == "physiHadCaloShell" ) {
|
||||
fHadCaloMaterialName = theStep->GetPreStepPoint()->GetMaterial()->GetName();
|
||||
if ( fRunPtr ) fRunPtr->setHadCaloMaterialName( fHadCaloMaterialName );
|
||||
fIsFirstStepInHadCalo = false;
|
||||
}
|
||||
// Get information on step lengths in the scoring shells
|
||||
G4int iScoringShell = -1;
|
||||
if ( theStep->GetPreStepPoint()->GetPhysicalVolume()->GetName() ==
|
||||
"physiScoringTrackerShell" ) {
|
||||
iScoringShell = 0;
|
||||
if ( fIsFirstStepInScoringTrackerShell ) {
|
||||
fCubicVolumeScoringTrackerShell =
|
||||
theStep->GetTrack()->GetVolume()->GetLogicalVolume()->GetSolid()->GetCubicVolume();
|
||||
if ( fRunPtr ) fRunPtr->setCubicVolumeScoringTrackerShell( fCubicVolumeScoringTrackerShell );
|
||||
fIsFirstStepInScoringTrackerShell = false;
|
||||
}
|
||||
} else if ( theStep->GetPreStepPoint()->GetPhysicalVolume()->GetName() ==
|
||||
"physiScoringEmCaloShell" ) {
|
||||
iScoringShell = 1;
|
||||
if ( fIsFirstStepInScoringEmCaloShell ) {
|
||||
fCubicVolumeScoringEmCaloShell =
|
||||
theStep->GetTrack()->GetVolume()->GetLogicalVolume()->GetSolid()->GetCubicVolume();
|
||||
if ( fRunPtr ) fRunPtr->setCubicVolumeScoringEmCaloShell( fCubicVolumeScoringEmCaloShell );
|
||||
fIsFirstStepInScoringEmCaloShell = false;
|
||||
}
|
||||
} else if ( theStep->GetPreStepPoint()->GetPhysicalVolume()->GetName() ==
|
||||
"physiScoringHadCaloShell" ) {
|
||||
iScoringShell = 2;
|
||||
if ( fIsFirstStepInScoringHadCaloShell ) {
|
||||
fCubicVolumeScoringHadCaloShell =
|
||||
theStep->GetTrack()->GetVolume()->GetLogicalVolume()->GetSolid()->GetCubicVolume();
|
||||
if ( fRunPtr ) fRunPtr->setCubicVolumeScoringHadCaloShell( fCubicVolumeScoringHadCaloShell );
|
||||
fIsFirstStepInScoringHadCaloShell = false;
|
||||
}
|
||||
}
|
||||
if ( iScoringShell >= 0 ) {
|
||||
G4double stepLength = theStep->GetTrack()->GetStepLength() * theStep->GetTrack()->GetWeight();
|
||||
G4int absPdg = theStep->GetTrack()->GetDefinition() == nullptr ? 0 :
|
||||
std::abs( theStep->GetTrack()->GetDefinition()->GetPDGEncoding() );
|
||||
/*
|
||||
G4cout << theStep->GetTrack()->GetDefinition()->GetParticleName() << " absPdg=" << absPdg
|
||||
<< " Ekin[MeV]=" << theStep->GetPreStepPoint()->GetKineticEnergy()
|
||||
<< " r[mm]=" << theStep->GetTrack()->GetPosition().mag()
|
||||
<< " z[mm]=" << theStep->GetTrack()->GetPosition().z()
|
||||
<< " " << theStep->GetTrack()->GetVolume()->GetName()
|
||||
<< " " << theStep->GetTrack()->GetMaterial()->GetName()
|
||||
<< " L[mm]=" << stepLength << " "
|
||||
<< ( fPrimaryParticleDirection.dot( theStep->GetTrack()->GetPosition().unit() ) > 0.0
|
||||
? "forward" : "backward" ) << G4endl;
|
||||
*/
|
||||
// Three kinematical regions: [0] : any value ; [1] : below 20 MeV ; [2] : above 20 MeV
|
||||
G4int iKinematicRegion = theStep->GetPreStepPoint()->GetKineticEnergy() < 20.0 ? 1 : 2;
|
||||
// Two scoring positions: [0] : forward hemisphere ; [1] : backward hemisphere
|
||||
// (with respect to the primary particle initial direction)
|
||||
G4int iScoringPosition =
|
||||
fPrimaryParticleDirection.dot( theStep->GetTrack()->GetPosition().unit() ) > 0.0 ? 0 : 1;
|
||||
G4int iParticleType = -1;
|
||||
if ( absPdg == 11 ) iParticleType = 1; // electron (and positron)
|
||||
else if ( absPdg == 22 ) iParticleType = 2; // gamma
|
||||
else if ( absPdg == 13 ) iParticleType = 3; // muons (mu- and mu+)
|
||||
else if ( absPdg == 12 || absPdg == 14 || absPdg == 16 ) iParticleType = 4; // neutrinos
|
||||
// (and anti-neutrinos), all flavors
|
||||
else if ( absPdg == 111 || absPdg == 211 ) iParticleType = 5; // (charged) pions
|
||||
else if ( absPdg == 2112 ) iParticleType = 6; // neutron (and anti-neutron)
|
||||
else if ( absPdg == 2212 ) iParticleType = 7; // proton (and anti-proton)
|
||||
else if ( G4IonTable::IsIon( theStep->GetTrack()->GetDefinition() ) || // ions (and anti-ions)
|
||||
G4IonTable::IsAntiIon( theStep->GetTrack()->GetDefinition() ) ) iParticleType = 8;
|
||||
else if ( absPdg < 1000 ) iParticleType = 9; // other mesons (e.g. kaons) (Note: this works
|
||||
// in most cases, but not always!)
|
||||
else if ( absPdg > 1000 ) iParticleType = 10; // other baryons (e.g. hyperons, anti-hyperons,
|
||||
// etc.)
|
||||
// Consider the specific case : scoring shell, kinematic region, scoring position, and
|
||||
// particle type
|
||||
G4int index = getIndex( iScoringShell, iKinematicRegion, iScoringPosition, iParticleType );
|
||||
fArraySumStepLengths[index] += stepLength;
|
||||
// Consider the "all" particle case, with the same scoring shell, kinematic region and
|
||||
// scoring position
|
||||
index = getIndex( iScoringShell, iKinematicRegion, iScoringPosition, 0 );
|
||||
fArraySumStepLengths[index] += stepLength;
|
||||
// Consider the "any" kinematic region case, with the same scoring shell, scoring position
|
||||
// and particle type
|
||||
index = getIndex( iScoringShell, 0, iScoringPosition, iParticleType );
|
||||
fArraySumStepLengths[index] += stepLength;
|
||||
// Consider the "any" kinematic region and "all" particle, with the same scoring shell and
|
||||
// scoring position
|
||||
index = getIndex( iScoringShell, 0, iScoringPosition, 0 );
|
||||
fArraySumStepLengths[index] += stepLength;
|
||||
if ( fRunPtr ) fRunPtr->setArray( fArraySumStepLengths );
|
||||
}
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
Reference in New Issue
Block a user