Import Geant4 11.3.0.beta source tree
This commit is contained in:
@@ -32,35 +32,38 @@
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
#include "ActionInitialization.hh"
|
||||
|
||||
#include "PrimaryGeneratorAction.hh"
|
||||
#include "Run.hh"
|
||||
#include "RunAction.hh"
|
||||
#include "SteppingAction.hh"
|
||||
#include "TrackingAction.hh"
|
||||
#include "Run.hh"
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
ActionInitialization::
|
||||
ActionInitialization( const DetectorConstruction* inputDetectorConstruction ) :
|
||||
G4VUserActionInitialization(), fPtrDetectorConstruction( inputDetectorConstruction ) {}
|
||||
ActionInitialization::ActionInitialization(const DetectorConstruction* inputDetectorConstruction)
|
||||
: G4VUserActionInitialization(), fPtrDetectorConstruction(inputDetectorConstruction)
|
||||
{}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void ActionInitialization::BuildForMaster() const {
|
||||
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 );
|
||||
SetUserAction(new RunAction);
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void ActionInitialization::Build() const {
|
||||
void ActionInitialization::Build() const
|
||||
{
|
||||
// This is called in the SEQ-mode and in the MT-mode only for Worker threads.
|
||||
SetUserAction( new PrimaryGeneratorAction( fPtrDetectorConstruction ) );
|
||||
SetUserAction(new PrimaryGeneratorAction(fPtrDetectorConstruction));
|
||||
SteppingAction* steppingAction = new SteppingAction;
|
||||
SetUserAction( steppingAction );
|
||||
SetUserAction(steppingAction);
|
||||
TrackingAction* trackingAction = new TrackingAction;
|
||||
SetUserAction( trackingAction );
|
||||
SetUserAction( new RunAction( steppingAction, trackingAction ) );
|
||||
SetUserAction(trackingAction);
|
||||
SetUserAction(new RunAction(steppingAction, trackingAction));
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -32,106 +32,110 @@
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
#include "DetectorMessenger.hh"
|
||||
|
||||
#include "DetectorConstruction.hh"
|
||||
#include "G4UIdirectory.hh"
|
||||
#include "G4UIcmdWithADoubleAndUnit.hh"
|
||||
#include "G4UIcmdWithADouble.hh"
|
||||
#include "G4UIcmdWithAString.hh"
|
||||
|
||||
#include "G4UIcmdWithABool.hh"
|
||||
#include "G4UIcmdWithADouble.hh"
|
||||
#include "G4UIcmdWithADoubleAndUnit.hh"
|
||||
#include "G4UIcmdWithAString.hh"
|
||||
#include "G4UIcmdWithAnInteger.hh"
|
||||
#include "G4UIcmdWithoutParameter.hh"
|
||||
#include "G4UIdirectory.hh"
|
||||
#include "globals.hh"
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
DetectorMessenger::DetectorMessenger( DetectorConstruction* myDet ) : fDetector( myDet ) {
|
||||
fDetectorDir = new G4UIdirectory( "/mydet/" );
|
||||
fDetectorDir->SetGuidance( "Detector control." );
|
||||
|
||||
fFieldCommand = new G4UIcmdWithADoubleAndUnit( "/mydet/setField", this );
|
||||
fFieldCommand->SetGuidance( "Define uniform magnetic field along Y." );
|
||||
fFieldCommand->SetGuidance( " -> in unit of [Tesla]" );
|
||||
fFieldCommand->SetParameterName( "By", false );
|
||||
fFieldCommand->SetDefaultValue( 0.0 );
|
||||
fFieldCommand->SetUnitCategory( "Magnetic flux density" );
|
||||
fFieldCommand->AvailableForStates( G4State_PreInit, G4State_Idle );
|
||||
DetectorMessenger::DetectorMessenger(DetectorConstruction* myDet) : fDetector(myDet)
|
||||
{
|
||||
fDetectorDir = new G4UIdirectory("/mydet/");
|
||||
fDetectorDir->SetGuidance("Detector control.");
|
||||
|
||||
fAbsorberMaterial = new G4UIcmdWithAString( "/mydet/absorberMaterial", this );
|
||||
fAbsorberMaterial->SetGuidance( "Choice of the absorber material:" );
|
||||
fAbsorberMaterial->SetGuidance( " iron / copper / tungsten / lead / PbWO4 / uranium " );
|
||||
fAbsorberMaterial->SetParameterName( "choiceAbsorberMaterial", true );
|
||||
fAbsorberMaterial->SetDefaultValue( "iron" );
|
||||
fAbsorberMaterial->AvailableForStates( G4State_PreInit, G4State_Idle );
|
||||
fFieldCommand = new G4UIcmdWithADoubleAndUnit("/mydet/setField", this);
|
||||
fFieldCommand->SetGuidance("Define uniform magnetic field along Y.");
|
||||
fFieldCommand->SetGuidance(" -> in unit of [Tesla]");
|
||||
fFieldCommand->SetParameterName("By", false);
|
||||
fFieldCommand->SetDefaultValue(0.0);
|
||||
fFieldCommand->SetUnitCategory("Magnetic flux density");
|
||||
fFieldCommand->AvailableForStates(G4State_PreInit, G4State_Idle);
|
||||
|
||||
fActiveMaterial = new G4UIcmdWithAString( "/mydet/activeMaterial", this );
|
||||
fActiveMaterial->SetGuidance( "Choice of the active material:" );
|
||||
fActiveMaterial->SetGuidance( " scintillator / liquidArgon / PbWO4 / silicon / quartz " );
|
||||
fActiveMaterial->SetParameterName( "choiceActiveMaterial", true );
|
||||
fActiveMaterial->SetDefaultValue( "scintillator" );
|
||||
fActiveMaterial->AvailableForStates( G4State_PreInit, G4State_Idle );
|
||||
fAbsorberMaterial = new G4UIcmdWithAString("/mydet/absorberMaterial", this);
|
||||
fAbsorberMaterial->SetGuidance("Choice of the absorber material:");
|
||||
fAbsorberMaterial->SetGuidance(" iron / copper / tungsten / lead / PbWO4 / uranium ");
|
||||
fAbsorberMaterial->SetParameterName("choiceAbsorberMaterial", true);
|
||||
fAbsorberMaterial->SetDefaultValue("iron");
|
||||
fAbsorberMaterial->AvailableForStates(G4State_PreInit, G4State_Idle);
|
||||
|
||||
fIsCalHomogeneous = new G4UIcmdWithABool( "/mydet/isCalHomogeneous", this );
|
||||
fIsCalHomogeneous->SetParameterName( "choiceIsCalHomogeneous", true );
|
||||
fIsCalHomogeneous->SetGuidance( "Is the calorimeter homogeneous?" );
|
||||
fIsCalHomogeneous->SetGuidance( " -> yes|y|true|t|1 : Homogeneous calorimeter" );
|
||||
fIsCalHomogeneous->SetGuidance( " -> no|n|false|f|0 : Sampling calorimeter" );
|
||||
fIsCalHomogeneous->SetDefaultValue( false ); // default: sampling calorimeter
|
||||
fIsCalHomogeneous->AvailableForStates( G4State_PreInit, G4State_Idle );
|
||||
|
||||
fIsUnitInLambda = new G4UIcmdWithABool( "/mydet/isUnitInLambda", this );
|
||||
fIsUnitInLambda->SetParameterName( "choiceIsUnitInLambda", true );
|
||||
fIsUnitInLambda->SetGuidance( "Is unit for absorber length in lambda?" );
|
||||
fIsUnitInLambda->SetGuidance( " -> yes|y|true|t|1 : unit in lambda" );
|
||||
fIsUnitInLambda->SetGuidance( " -> no|n|false|f|0 : unit in [mm]" );
|
||||
fIsUnitInLambda->SetDefaultValue( false ); // default: unit in [mm].
|
||||
fIsUnitInLambda->AvailableForStates( G4State_PreInit, G4State_Idle );
|
||||
|
||||
fAbsorberTotalLength = new G4UIcmdWithADouble( "/mydet/absorberTotalLength", this );
|
||||
fAbsorberTotalLength->SetParameterName( "choiceAbsorberTotalLength", true );
|
||||
fAbsorberTotalLength->SetGuidance( "Absorber total length" );
|
||||
fAbsorberTotalLength->SetGuidance( " -> in unit of lambda or [mm]" );
|
||||
fAbsorberTotalLength->SetGuidance( " -> depending on value of choiceIsUnitInLambda" );
|
||||
fAbsorberTotalLength->SetDefaultValue( 2000.0 ); // default: 2 meters.
|
||||
fAbsorberTotalLength->AvailableForStates( G4State_PreInit, G4State_Idle );
|
||||
fActiveMaterial = new G4UIcmdWithAString("/mydet/activeMaterial", this);
|
||||
fActiveMaterial->SetGuidance("Choice of the active material:");
|
||||
fActiveMaterial->SetGuidance(" scintillator / liquidArgon / PbWO4 / silicon / quartz ");
|
||||
fActiveMaterial->SetParameterName("choiceActiveMaterial", true);
|
||||
fActiveMaterial->SetDefaultValue("scintillator");
|
||||
fActiveMaterial->AvailableForStates(G4State_PreInit, G4State_Idle);
|
||||
|
||||
fCalorimeterRadius = new G4UIcmdWithADouble( "/mydet/calorimeterRadius", this );
|
||||
fCalorimeterRadius->SetParameterName( "choiceCalorimeterRadius", true );
|
||||
fCalorimeterRadius->SetGuidance( "Calorimeter Radius" );
|
||||
fCalorimeterRadius->SetGuidance( " -> in unit of lambda or [mm]" );
|
||||
fCalorimeterRadius->SetGuidance( " -> depending on value of choiceIsUnitInLambda" );
|
||||
fCalorimeterRadius->SetDefaultValue( 1000.0 ); // default: 1 meter.
|
||||
fCalorimeterRadius->AvailableForStates( G4State_PreInit, G4State_Idle );
|
||||
fIsCalHomogeneous = new G4UIcmdWithABool("/mydet/isCalHomogeneous", this);
|
||||
fIsCalHomogeneous->SetParameterName("choiceIsCalHomogeneous", true);
|
||||
fIsCalHomogeneous->SetGuidance("Is the calorimeter homogeneous?");
|
||||
fIsCalHomogeneous->SetGuidance(" -> yes|y|true|t|1 : Homogeneous calorimeter");
|
||||
fIsCalHomogeneous->SetGuidance(" -> no|n|false|f|0 : Sampling calorimeter");
|
||||
fIsCalHomogeneous->SetDefaultValue(false); // default: sampling calorimeter
|
||||
fIsCalHomogeneous->AvailableForStates(G4State_PreInit, G4State_Idle);
|
||||
|
||||
fActiveLayerNumber = new G4UIcmdWithAnInteger( "/mydet/activeLayerNumber", this );
|
||||
fActiveLayerNumber->SetParameterName( "choiceActiveLayerNumber", true );
|
||||
fActiveLayerNumber->SetGuidance( "Number of active layers" );
|
||||
fActiveLayerNumber->SetDefaultValue( 50 );
|
||||
fActiveLayerNumber->AvailableForStates( G4State_PreInit, G4State_Idle );
|
||||
fIsUnitInLambda = new G4UIcmdWithABool("/mydet/isUnitInLambda", this);
|
||||
fIsUnitInLambda->SetParameterName("choiceIsUnitInLambda", true);
|
||||
fIsUnitInLambda->SetGuidance("Is unit for absorber length in lambda?");
|
||||
fIsUnitInLambda->SetGuidance(" -> yes|y|true|t|1 : unit in lambda");
|
||||
fIsUnitInLambda->SetGuidance(" -> no|n|false|f|0 : unit in [mm]");
|
||||
fIsUnitInLambda->SetDefaultValue(false); // default: unit in [mm].
|
||||
fIsUnitInLambda->AvailableForStates(G4State_PreInit, G4State_Idle);
|
||||
|
||||
fActiveLayerSize = new G4UIcmdWithADouble( "/mydet/activeLayerSize", this );
|
||||
fActiveLayerSize->SetParameterName( "choiceActiveLayerSize", true );
|
||||
fActiveLayerSize->SetGuidance( "Size (thickness) of the active layer, in [mm]" );
|
||||
fActiveLayerSize->SetDefaultValue( 4.0 ); // default: 4 millimeters.
|
||||
fActiveLayerSize->AvailableForStates( G4State_PreInit, G4State_Idle );
|
||||
fAbsorberTotalLength = new G4UIcmdWithADouble("/mydet/absorberTotalLength", this);
|
||||
fAbsorberTotalLength->SetParameterName("choiceAbsorberTotalLength", true);
|
||||
fAbsorberTotalLength->SetGuidance("Absorber total length");
|
||||
fAbsorberTotalLength->SetGuidance(" -> in unit of lambda or [mm]");
|
||||
fAbsorberTotalLength->SetGuidance(" -> depending on value of choiceIsUnitInLambda");
|
||||
fAbsorberTotalLength->SetDefaultValue(2000.0); // default: 2 meters.
|
||||
fAbsorberTotalLength->AvailableForStates(G4State_PreInit, G4State_Idle);
|
||||
|
||||
fIsRadiusUnitInLambda = new G4UIcmdWithABool( "/mydet/isRadiusUnitInLambda", this );
|
||||
fIsRadiusUnitInLambda->SetParameterName( "choiceIsRadiusUnitInLambda", true );
|
||||
fIsRadiusUnitInLambda->SetGuidance( "Is unit of radius in lambda?" );
|
||||
fIsRadiusUnitInLambda->SetGuidance( " -> yes|y|true|t|1 : unit in lambda" );
|
||||
fIsRadiusUnitInLambda->SetGuidance( " -> no|n|false|f|0 : unit in [mm]" );
|
||||
fIsRadiusUnitInLambda->SetDefaultValue( false ); // default: unit in [mm].
|
||||
fIsRadiusUnitInLambda->AvailableForStates( G4State_PreInit, G4State_Idle );
|
||||
|
||||
fUpdateCommand = new G4UIcmdWithoutParameter( "/mydet/update", this);
|
||||
fUpdateCommand->SetGuidance( "Update calorimeter geometry." );
|
||||
fUpdateCommand->SetGuidance( "This command MUST be applied before \"beamOn\" " );
|
||||
fUpdateCommand->SetGuidance( "if you changed geometrical value(s)." );
|
||||
fUpdateCommand->AvailableForStates( G4State_Idle );
|
||||
fCalorimeterRadius = new G4UIcmdWithADouble("/mydet/calorimeterRadius", this);
|
||||
fCalorimeterRadius->SetParameterName("choiceCalorimeterRadius", true);
|
||||
fCalorimeterRadius->SetGuidance("Calorimeter Radius");
|
||||
fCalorimeterRadius->SetGuidance(" -> in unit of lambda or [mm]");
|
||||
fCalorimeterRadius->SetGuidance(" -> depending on value of choiceIsUnitInLambda");
|
||||
fCalorimeterRadius->SetDefaultValue(1000.0); // default: 1 meter.
|
||||
fCalorimeterRadius->AvailableForStates(G4State_PreInit, G4State_Idle);
|
||||
|
||||
fActiveLayerNumber = new G4UIcmdWithAnInteger("/mydet/activeLayerNumber", this);
|
||||
fActiveLayerNumber->SetParameterName("choiceActiveLayerNumber", true);
|
||||
fActiveLayerNumber->SetGuidance("Number of active layers");
|
||||
fActiveLayerNumber->SetDefaultValue(50);
|
||||
fActiveLayerNumber->AvailableForStates(G4State_PreInit, G4State_Idle);
|
||||
|
||||
fActiveLayerSize = new G4UIcmdWithADouble("/mydet/activeLayerSize", this);
|
||||
fActiveLayerSize->SetParameterName("choiceActiveLayerSize", true);
|
||||
fActiveLayerSize->SetGuidance("Size (thickness) of the active layer, in [mm]");
|
||||
fActiveLayerSize->SetDefaultValue(4.0); // default: 4 millimeters.
|
||||
fActiveLayerSize->AvailableForStates(G4State_PreInit, G4State_Idle);
|
||||
|
||||
fIsRadiusUnitInLambda = new G4UIcmdWithABool("/mydet/isRadiusUnitInLambda", this);
|
||||
fIsRadiusUnitInLambda->SetParameterName("choiceIsRadiusUnitInLambda", true);
|
||||
fIsRadiusUnitInLambda->SetGuidance("Is unit of radius in lambda?");
|
||||
fIsRadiusUnitInLambda->SetGuidance(" -> yes|y|true|t|1 : unit in lambda");
|
||||
fIsRadiusUnitInLambda->SetGuidance(" -> no|n|false|f|0 : unit in [mm]");
|
||||
fIsRadiusUnitInLambda->SetDefaultValue(false); // default: unit in [mm].
|
||||
fIsRadiusUnitInLambda->AvailableForStates(G4State_PreInit, G4State_Idle);
|
||||
|
||||
fUpdateCommand = new G4UIcmdWithoutParameter("/mydet/update", this);
|
||||
fUpdateCommand->SetGuidance("Update calorimeter 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() {
|
||||
DetectorMessenger::~DetectorMessenger()
|
||||
{
|
||||
delete fFieldCommand;
|
||||
delete fDetectorDir;
|
||||
delete fAbsorberMaterial;
|
||||
@@ -148,38 +152,39 @@ DetectorMessenger::~DetectorMessenger() {
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void DetectorMessenger::SetNewValue( G4UIcommand* command, G4String newValue ) {
|
||||
if ( command == fFieldCommand ) {
|
||||
fDetector->SetMagField( fFieldCommand->GetNewDoubleValue( newValue ) );
|
||||
void DetectorMessenger::SetNewValue(G4UIcommand* command, G4String newValue)
|
||||
{
|
||||
if (command == fFieldCommand) {
|
||||
fDetector->SetMagField(fFieldCommand->GetNewDoubleValue(newValue));
|
||||
}
|
||||
if ( command == fAbsorberMaterial ) {
|
||||
fDetector->SetAbsorberMaterial( newValue );
|
||||
if (command == fAbsorberMaterial) {
|
||||
fDetector->SetAbsorberMaterial(newValue);
|
||||
}
|
||||
if ( command == fActiveMaterial ) {
|
||||
fDetector->SetActiveMaterial( newValue );
|
||||
if (command == fActiveMaterial) {
|
||||
fDetector->SetActiveMaterial(newValue);
|
||||
}
|
||||
if ( command == fIsCalHomogeneous ) {
|
||||
fDetector->SetIsCalHomogeneous( fIsCalHomogeneous->GetNewBoolValue( newValue ) );
|
||||
if (command == fIsCalHomogeneous) {
|
||||
fDetector->SetIsCalHomogeneous(fIsCalHomogeneous->GetNewBoolValue(newValue));
|
||||
}
|
||||
if ( command == fIsUnitInLambda ) {
|
||||
fDetector->SetIsUnitInLambda( fIsUnitInLambda->GetNewBoolValue( newValue ) );
|
||||
if (command == fIsUnitInLambda) {
|
||||
fDetector->SetIsUnitInLambda(fIsUnitInLambda->GetNewBoolValue(newValue));
|
||||
}
|
||||
if ( command == fAbsorberTotalLength ) {
|
||||
fDetector->SetAbsorberTotalLength( fAbsorberTotalLength->GetNewDoubleValue( newValue ) );
|
||||
if (command == fAbsorberTotalLength) {
|
||||
fDetector->SetAbsorberTotalLength(fAbsorberTotalLength->GetNewDoubleValue(newValue));
|
||||
}
|
||||
if ( command == fCalorimeterRadius ) {
|
||||
fDetector->SetCalorimeterRadius( fCalorimeterRadius->GetNewDoubleValue(newValue) );
|
||||
if (command == fCalorimeterRadius) {
|
||||
fDetector->SetCalorimeterRadius(fCalorimeterRadius->GetNewDoubleValue(newValue));
|
||||
}
|
||||
if ( command == fActiveLayerNumber ) {
|
||||
fDetector->SetActiveLayerNumber( fActiveLayerNumber->GetNewIntValue( newValue ) );
|
||||
if (command == fActiveLayerNumber) {
|
||||
fDetector->SetActiveLayerNumber(fActiveLayerNumber->GetNewIntValue(newValue));
|
||||
}
|
||||
if ( command == fActiveLayerSize ) {
|
||||
fDetector->SetActiveLayerSize( fActiveLayerSize->GetNewDoubleValue( newValue ) );
|
||||
if (command == fActiveLayerSize) {
|
||||
fDetector->SetActiveLayerSize(fActiveLayerSize->GetNewDoubleValue(newValue));
|
||||
}
|
||||
if ( command == fIsRadiusUnitInLambda ) {
|
||||
fDetector->SetIsRadiusUnitInLambda( fIsRadiusUnitInLambda->GetNewBoolValue( newValue ) );
|
||||
if (command == fIsRadiusUnitInLambda) {
|
||||
fDetector->SetIsRadiusUnitInLambda(fIsRadiusUnitInLambda->GetNewBoolValue(newValue));
|
||||
}
|
||||
if ( command == fUpdateCommand ) {
|
||||
if (command == fUpdateCommand) {
|
||||
fDetector->UpdateGeometry();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,52 +32,58 @@
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
#include "PrimaryGeneratorAction.hh"
|
||||
|
||||
#include "DetectorConstruction.hh"
|
||||
|
||||
#include "G4Event.hh"
|
||||
#include "G4ParticleDefinition.hh"
|
||||
#include "G4ParticleGun.hh"
|
||||
#include "G4ParticleTable.hh"
|
||||
#include "G4ParticleDefinition.hh"
|
||||
#include "globals.hh"
|
||||
#include "G4SystemOfUnits.hh"
|
||||
#include "globals.hh"
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
PrimaryGeneratorAction::PrimaryGeneratorAction( const DetectorConstruction* pDetector ) :
|
||||
fPointerDetectorConstruction( pDetector )
|
||||
PrimaryGeneratorAction::PrimaryGeneratorAction(const DetectorConstruction* pDetector)
|
||||
: fPointerDetectorConstruction(pDetector)
|
||||
{
|
||||
G4int n_particle = 1;
|
||||
fParticleGun = new G4ParticleGun( n_particle );
|
||||
fParticleGun = new G4ParticleGun(n_particle);
|
||||
G4ParticleTable* particleTable = G4ParticleTable::GetParticleTable();
|
||||
//***LOOKHERE*** Default particle and energy
|
||||
fParticleGun->SetParticleDefinition( particleTable->FindParticle( "geantino" ) );
|
||||
fParticleGun->SetParticleEnergy( 10.0*GeV );
|
||||
fParticleGun->SetParticleDefinition(particleTable->FindParticle("geantino"));
|
||||
fParticleGun->SetParticleEnergy(10.0 * GeV);
|
||||
SetGunPosition();
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
PrimaryGeneratorAction::~PrimaryGeneratorAction() {
|
||||
PrimaryGeneratorAction::~PrimaryGeneratorAction()
|
||||
{
|
||||
delete fParticleGun;
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void PrimaryGeneratorAction::SetGunPosition() const {
|
||||
void PrimaryGeneratorAction::SetGunPosition() const
|
||||
{
|
||||
// Shoot the particle in the middle between the world and the calorimeter
|
||||
G4double caloLength =
|
||||
( fPointerDetectorConstruction ? fPointerDetectorConstruction->GetCaloLength() : 0.0 );
|
||||
G4double gunPosition = -0.55*caloLength; //***LOOKHERE*** default gun position along the z-axis
|
||||
G4cout << G4endl << "PrimaryGenerationAction::SetGunPosition() : gun position along z = "
|
||||
<< gunPosition << " mm " << G4endl << G4endl;
|
||||
fParticleGun->SetParticlePosition( G4ThreeVector( 0.0, 0.0, gunPosition ) );
|
||||
(fPointerDetectorConstruction ? fPointerDetectorConstruction->GetCaloLength() : 0.0);
|
||||
G4double gunPosition = -0.55 * caloLength; //***LOOKHERE*** default gun position along the z-axis
|
||||
G4cout << G4endl
|
||||
<< "PrimaryGenerationAction::SetGunPosition() : gun position along z = " << gunPosition
|
||||
<< " mm " << G4endl << G4endl;
|
||||
fParticleGun->SetParticlePosition(G4ThreeVector(0.0, 0.0, gunPosition));
|
||||
}
|
||||
|
||||
//....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 );
|
||||
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......
|
||||
|
||||
@@ -32,39 +32,47 @@
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
#include "Run.hh"
|
||||
#include "G4SystemOfUnits.hh"
|
||||
|
||||
#include "G4Run.hh"
|
||||
#include "G4RunManager.hh"
|
||||
#include "G4SystemOfUnits.hh"
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
Run::Run() : G4Run(), fNumEvents( 0 ),
|
||||
fPrimaryParticleId( 0 ), fPrimaryParticleEnergy( 0.0 ),
|
||||
fPrimaryParticleDirection( G4ThreeVector( 0.0, 0.0, 0.0 ) ),
|
||||
fAbsorberMaterialName( "" ), fActiveMaterialName( "" ),
|
||||
fCubicVolumeScoringUpDown( 1.0 ), fCubicVolumeScoringSide( 1.0 )
|
||||
Run::Run()
|
||||
: G4Run(),
|
||||
fNumEvents(0),
|
||||
fPrimaryParticleId(0),
|
||||
fPrimaryParticleEnergy(0.0),
|
||||
fPrimaryParticleDirection(G4ThreeVector(0.0, 0.0, 0.0)),
|
||||
fAbsorberMaterialName(""),
|
||||
fActiveMaterialName(""),
|
||||
fCubicVolumeScoringUpDown(1.0),
|
||||
fCubicVolumeScoringSide(1.0)
|
||||
{
|
||||
fSteppingArray.fill( 0.0 );
|
||||
fTrackingArray1.fill( 0 );
|
||||
fTrackingArray2.fill( 0.0 );
|
||||
fSteppingArray.fill(0.0);
|
||||
fTrackingArray1.fill(0);
|
||||
fTrackingArray2.fill(0.0);
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void Run::RecordEvent( const G4Event* anEvent ) {
|
||||
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 );
|
||||
if (nEvt % 10 == 0) G4cout << " Event#=" << nEvt << G4endl;
|
||||
G4Run::RecordEvent(anEvent);
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void Run::Merge( const G4Run* aRun ) {
|
||||
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 );
|
||||
const Run* localRun = static_cast<const Run*>(aRun);
|
||||
fPrimaryParticleId = localRun->GetPrimaryParticleId();
|
||||
fPrimaryParticleEnergy = localRun->GetPrimaryParticleEnergy();
|
||||
fPrimaryParticleDirection = localRun->GetPrimaryParticleDirection();
|
||||
@@ -73,55 +81,53 @@ void Run::Merge( const G4Run* aRun ) {
|
||||
fCubicVolumeScoringUpDown = localRun->GetCubicVolumeScoringUpDown();
|
||||
fCubicVolumeScoringSide = localRun->GetCubicVolumeScoringSide();
|
||||
fNumEvents += localRun->GetNumberOfEvent();
|
||||
for ( G4int i = 0; i < SteppingAction::fkNumberCombinations; ++i ) {
|
||||
for (G4int i = 0; i < SteppingAction::fkNumberCombinations; ++i) {
|
||||
fSteppingArray[i] += localRun->GetSteppingArray()[i];
|
||||
}
|
||||
for ( G4int i = 0; i < TrackingAction::fkNumberCombinations; ++i ) {
|
||||
for (G4int i = 0; i < TrackingAction::fkNumberCombinations; ++i) {
|
||||
fTrackingArray1[i] += localRun->GetTrackingArray1()[i];
|
||||
fTrackingArray2[i] += localRun->GetTrackingArray2()[i];
|
||||
}
|
||||
G4Run::Merge( aRun );
|
||||
G4Run::Merge(aRun);
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void Run::PrintInfo() const {
|
||||
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 );
|
||||
std::max(1.0, fNumEvents > 0 ? fNumEvents * 1.0 : GetNumberOfEvent() * 1.0);
|
||||
// The fluence in the scoring volume is defined as sum of step lengths in that volume
|
||||
// divided by the volume of that scoring volume.
|
||||
const G4double conversionFactor = CLHEP::cm * CLHEP::cm; // From mm^-2 to cm^-2
|
||||
const G4double factorUpDown =
|
||||
conversionFactor / ( fCubicVolumeScoringUpDown*floatingNumberOfEvents );
|
||||
const G4double factorSide =
|
||||
conversionFactor / ( fCubicVolumeScoringSide*floatingNumberOfEvents );
|
||||
conversionFactor / (fCubicVolumeScoringUpDown * floatingNumberOfEvents);
|
||||
const G4double factorSide = conversionFactor / (fCubicVolumeScoringSide * 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
|
||||
<< G4endl << " Primary particle PDG code = " << fPrimaryParticleId << G4endl
|
||||
<< " Primary particle kinetic energy = " << fPrimaryParticleEnergy / CLHEP::GeV << " GeV"
|
||||
<< G4endl << " Primary particle direction = " << fPrimaryParticleDirection << G4endl
|
||||
<< " Absorber material = " << fAbsorberMaterialName << G4endl
|
||||
<< " Active material = " << fActiveMaterialName << G4endl
|
||||
<< " Cubic-volume scoring up-down = " << fCubicVolumeScoringUpDown << " mm^3" << G4endl
|
||||
<< " Cubic-volume scoring side = " << fCubicVolumeScoringSide << " mm^3" << G4endl
|
||||
<< " Cubic-volume scoring side = " << fCubicVolumeScoringSide << " 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::fkNumberScoringVolumes; ++i ) {
|
||||
G4double factor = ( i == 1 ? factorSide : factorUpDown );
|
||||
for ( G4int j = 0; j < SteppingAction::fkNumberKinematicRegions; ++j ) {
|
||||
for ( G4int k = 0; k < SteppingAction::fkNumberParticleTypes; ++k ) {
|
||||
G4int index = SteppingAction::GetIndex( i, j, k );
|
||||
//G4cout << "(i, j, k)=(" << i << ", " << j << ", " << k << ") ->" << index;
|
||||
G4cout << " case=" << std::setw(3) << index
|
||||
<< " " << std::setw(12) << SteppingAction::fkArrayScoringVolumeNames[i]
|
||||
<< " " << std::setw(12) << SteppingAction::fkArrayKinematicRegionNames[j]
|
||||
<< " " << std::setw(12) << SteppingAction::fkArrayParticleTypeNames[k]
|
||||
<< " " << std::setw( 8) << factor*fSteppingArray[index] << G4endl;
|
||||
for (G4int i = 0; i < SteppingAction::fkNumberScoringVolumes; ++i) {
|
||||
G4double factor = (i == 1 ? factorSide : factorUpDown);
|
||||
for (G4int j = 0; j < SteppingAction::fkNumberKinematicRegions; ++j) {
|
||||
for (G4int k = 0; k < SteppingAction::fkNumberParticleTypes; ++k) {
|
||||
G4int index = SteppingAction::GetIndex(i, j, k);
|
||||
// G4cout << "(i, j, k)=(" << i << ", " << j << ", " << k << ") ->" << index;
|
||||
G4cout << " case=" << std::setw(3) << index << " " << std::setw(12)
|
||||
<< SteppingAction::fkArrayScoringVolumeNames[i] << " " << std::setw(12)
|
||||
<< SteppingAction::fkArrayKinematicRegionNames[j] << " " << std::setw(12)
|
||||
<< SteppingAction::fkArrayParticleTypeNames[k] << " " << std::setw(8)
|
||||
<< factor * fSteppingArray[index] << G4endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -129,50 +135,51 @@ void Run::PrintInfo() const {
|
||||
<< " Extra information: particle production \t \t <N> <E_kin> <Sum_Ekin> [MeV]"
|
||||
<< G4endl;
|
||||
const G4double normalization = 1.0 / floatingNumberOfEvents;
|
||||
for ( G4int i = 0; i < TrackingAction::fkNumberScoringVolumes; ++i ) {
|
||||
for ( G4int j = 0; j < TrackingAction::fkNumberKinematicRegions; ++j ) {
|
||||
for ( G4int k = 0; k < TrackingAction::fkNumberParticleTypes; ++k ) {
|
||||
G4int index = TrackingAction::GetIndex( i, j, k );
|
||||
//G4cout << "(i, j, k)=(" << i << ", " << j << ", " << k << ") ->" << index;
|
||||
G4cout << " case=" << std::setw(3) << index
|
||||
<< " " << std::setw(12) << TrackingAction::fkArrayScoringVolumeNames[i]
|
||||
<< " " << std::setw(12) << TrackingAction::fkArrayKinematicRegionNames[j]
|
||||
<< " " << std::setw(12) << TrackingAction::fkArrayParticleTypeNames[k]
|
||||
<< " " << std::setw( 8) << normalization * fTrackingArray1[index]
|
||||
<< " " << std::setw( 8) << ( fTrackingArray1[index] > 0 ?
|
||||
fTrackingArray2[index] / fTrackingArray1[index] :
|
||||
0.0 )
|
||||
<< " " << std::setw( 8) << normalization * fTrackingArray2[index]
|
||||
<< G4endl;
|
||||
for (G4int i = 0; i < TrackingAction::fkNumberScoringVolumes; ++i) {
|
||||
for (G4int j = 0; j < TrackingAction::fkNumberKinematicRegions; ++j) {
|
||||
for (G4int k = 0; k < TrackingAction::fkNumberParticleTypes; ++k) {
|
||||
G4int index = TrackingAction::GetIndex(i, j, k);
|
||||
// G4cout << "(i, j, k)=(" << i << ", " << j << ", " << k << ") ->" << index;
|
||||
G4cout << " case=" << std::setw(3) << index << " " << std::setw(12)
|
||||
<< TrackingAction::fkArrayScoringVolumeNames[i] << " " << std::setw(12)
|
||||
<< TrackingAction::fkArrayKinematicRegionNames[j] << " " << std::setw(12)
|
||||
<< TrackingAction::fkArrayParticleTypeNames[k] << " " << std::setw(8)
|
||||
<< normalization * fTrackingArray1[index] << " " << std::setw(8)
|
||||
<< (fTrackingArray1[index] > 0 ? fTrackingArray2[index] / fTrackingArray1[index]
|
||||
: 0.0)
|
||||
<< " " << std::setw(8) << normalization * fTrackingArray2[index] << G4endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
G4cout << " ============================================================= " << G4endl << G4endl;
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void Run::SetSteppingArray( const std::array< G4double,
|
||||
SteppingAction::fkNumberCombinations >& inputArray ) {
|
||||
for ( G4int i = 0; i < SteppingAction::fkNumberCombinations; ++i ) {
|
||||
void Run::SetSteppingArray(
|
||||
const std::array<G4double, SteppingAction::fkNumberCombinations>& inputArray)
|
||||
{
|
||||
for (G4int i = 0; i < SteppingAction::fkNumberCombinations; ++i) {
|
||||
fSteppingArray[i] = inputArray[i];
|
||||
}
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void Run::SetTrackingArray1( const std::array< G4long,
|
||||
TrackingAction::fkNumberCombinations >& inputArray ) {
|
||||
for ( G4int i = 0; i < TrackingAction::fkNumberCombinations; ++i ) {
|
||||
void Run::SetTrackingArray1(
|
||||
const std::array<G4long, TrackingAction::fkNumberCombinations>& inputArray)
|
||||
{
|
||||
for (G4int i = 0; i < TrackingAction::fkNumberCombinations; ++i) {
|
||||
fTrackingArray1[i] = inputArray[i];
|
||||
}
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void Run::SetTrackingArray2( const std::array< G4double,
|
||||
TrackingAction::fkNumberCombinations >& inputArray ) {
|
||||
for ( G4int i = 0; i < TrackingAction::fkNumberCombinations; ++i ) {
|
||||
void Run::SetTrackingArray2(
|
||||
const std::array<G4double, TrackingAction::fkNumberCombinations>& inputArray)
|
||||
{
|
||||
for (G4int i = 0; i < TrackingAction::fkNumberCombinations; ++i) {
|
||||
fTrackingArray2[i] = inputArray[i];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,46 +32,52 @@
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
#include "RunAction.hh"
|
||||
#include "globals.hh"
|
||||
#include "G4Run.hh"
|
||||
|
||||
#include "Run.hh"
|
||||
#include "SteppingAction.hh"
|
||||
#include "TrackingAction.hh"
|
||||
|
||||
#include "G4Run.hh"
|
||||
#include "G4RunManager.hh"
|
||||
#include "globals.hh"
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
RunAction::RunAction( SteppingAction* steppingAction, TrackingAction* trackingAction ) :
|
||||
G4UserRunAction(), fSteppingAction( steppingAction ), fTrackingAction( trackingAction ) {}
|
||||
RunAction::RunAction(SteppingAction* steppingAction, TrackingAction* trackingAction)
|
||||
: G4UserRunAction(), fSteppingAction(steppingAction), fTrackingAction(trackingAction)
|
||||
{}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
G4Run* RunAction::GenerateRun() {
|
||||
G4Run* RunAction::GenerateRun()
|
||||
{
|
||||
return new Run;
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void RunAction::BeginOfRunAction( const G4Run* aRun ) {
|
||||
void RunAction::BeginOfRunAction(const G4Run* aRun)
|
||||
{
|
||||
G4cout << "### Run " << aRun->GetRunID() << " starts." << G4endl;
|
||||
Run* run = const_cast< Run* >( static_cast< const Run* >( aRun ) );
|
||||
if ( run == nullptr ) return;
|
||||
if ( fSteppingAction != nullptr ) {
|
||||
Run* run = const_cast<Run*>(static_cast<const Run*>(aRun));
|
||||
if (run == nullptr) return;
|
||||
if (fSteppingAction != nullptr) {
|
||||
fSteppingAction->Initialize();
|
||||
fSteppingAction->SetRunPointer( run );
|
||||
fSteppingAction->SetRunPointer(run);
|
||||
}
|
||||
if ( fTrackingAction != nullptr ) {
|
||||
if (fTrackingAction != nullptr) {
|
||||
fTrackingAction->Initialize();
|
||||
fTrackingAction->SetRunPointer( run );
|
||||
fTrackingAction->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();
|
||||
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......
|
||||
|
||||
@@ -32,44 +32,47 @@
|
||||
//....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::fkNumberScoringVolumes >
|
||||
SteppingAction::fkArrayScoringVolumeNames = { "downstream", "side", "upstream" };
|
||||
#include "G4IonTable.hh"
|
||||
#include "G4LossTableManager.hh"
|
||||
#include "G4ParticleDefinition.hh"
|
||||
#include "G4ParticleTypes.hh"
|
||||
#include "G4Step.hh"
|
||||
#include "G4StepPoint.hh"
|
||||
#include "G4SystemOfUnits.hh"
|
||||
#include "G4TouchableHistory.hh"
|
||||
#include "G4Track.hh"
|
||||
#include "G4VPhysicalVolume.hh"
|
||||
#include "G4VSolid.hh"
|
||||
#include "G4VTouchable.hh"
|
||||
|
||||
const std::array< G4String, SteppingAction::fkNumberKinematicRegions >
|
||||
SteppingAction::fkArrayKinematicRegionNames = { "", "below 20 MeV", "above 20 MeV" };
|
||||
const std::array<G4String, SteppingAction::fkNumberScoringVolumes>
|
||||
SteppingAction::fkArrayScoringVolumeNames = {"downstream", "side", "upstream"};
|
||||
|
||||
const std::array< G4String, SteppingAction::fkNumberParticleTypes >
|
||||
SteppingAction::fkArrayParticleTypeNames = { "all", "electron", "gamma", "muon", "neutrino",
|
||||
"pion", "neutron", "proton", "ion", "otherMeson",
|
||||
"otherBaryon" };
|
||||
const std::array<G4String, SteppingAction::fkNumberKinematicRegions>
|
||||
SteppingAction::fkArrayKinematicRegionNames = {"", "below 20 MeV", "above 20 MeV"};
|
||||
|
||||
const std::array<G4String, SteppingAction::fkNumberParticleTypes>
|
||||
SteppingAction::fkArrayParticleTypeNames = {"all", "electron", "gamma", "muon",
|
||||
"neutrino", "pion", "neutron", "proton",
|
||||
"ion", "otherMeson", "otherBaryon"};
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
G4int SteppingAction::GetIndex( const G4int iScoringVolume, const G4int iKinematicRegion,
|
||||
const G4int iParticleType ) {
|
||||
G4int SteppingAction::GetIndex(const G4int iScoringVolume, const G4int iKinematicRegion,
|
||||
const G4int iParticleType)
|
||||
{
|
||||
G4int index = -1;
|
||||
if ( iScoringVolume >= 0 && iScoringVolume < fkNumberScoringVolumes &&
|
||||
iKinematicRegion >= 0 && iKinematicRegion < fkNumberKinematicRegions &&
|
||||
iParticleType >= 0 && iParticleType < fkNumberParticleTypes ) {
|
||||
index = iScoringVolume * fkNumberKinematicRegions * fkNumberParticleTypes +
|
||||
iKinematicRegion * fkNumberParticleTypes +
|
||||
iParticleType;
|
||||
if (iScoringVolume >= 0 && iScoringVolume < fkNumberScoringVolumes && iKinematicRegion >= 0
|
||||
&& iKinematicRegion < fkNumberKinematicRegions && iParticleType >= 0
|
||||
&& iParticleType < fkNumberParticleTypes)
|
||||
{
|
||||
index = iScoringVolume * fkNumberKinematicRegions * fkNumberParticleTypes
|
||||
+ iKinematicRegion * fkNumberParticleTypes + iParticleType;
|
||||
}
|
||||
if ( index < 0 || index >= fkNumberCombinations ) {
|
||||
if (index < 0 || index >= fkNumberCombinations) {
|
||||
G4cerr << "SteppingAction::GetIndex : WRONG index=" << index << " set it to 0 !" << G4endl;
|
||||
index = 0;
|
||||
}
|
||||
@@ -78,27 +81,29 @@ G4int SteppingAction::GetIndex( const G4int iScoringVolume, const G4int iKinemat
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
SteppingAction::SteppingAction() :G4UserSteppingAction() {
|
||||
SteppingAction::SteppingAction() : G4UserSteppingAction()
|
||||
{
|
||||
Initialize();
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void SteppingAction::Initialize() {
|
||||
// Initialization needed at the beginning of each Run
|
||||
void SteppingAction::Initialize()
|
||||
{
|
||||
// Initialization needed at the beginning of each Run
|
||||
fPrimaryParticleId = 0;
|
||||
fPrimaryParticleEnergy = 0.0;
|
||||
fPrimaryParticleDirection = G4ThreeVector( 0.0, 0.0, 1.0 );
|
||||
fPrimaryParticleDirection = G4ThreeVector(0.0, 0.0, 1.0);
|
||||
fAbsorberMaterialName = "";
|
||||
fActiveMaterialName = "";
|
||||
fIsFirstStepOfTheEvent = true;
|
||||
fIsFirstStepInAbsorberLayer = true;
|
||||
fIsFirstStepInActiveLayer = true;
|
||||
fIsFirstStepInScoringUpDown = true;
|
||||
fIsFirstStepInScoringSide = true;
|
||||
fIsFirstStepInScoringUpDown = true;
|
||||
fIsFirstStepInScoringSide = true;
|
||||
fCubicVolumeScoringUpDown = 1.0;
|
||||
fCubicVolumeScoringSide = 1.0;
|
||||
for ( G4int i = 0; i < fkNumberCombinations; ++i ) {
|
||||
for (G4int i = 0; i < fkNumberCombinations; ++i) {
|
||||
fArraySumStepLengths[i] = 0.0;
|
||||
}
|
||||
/*
|
||||
@@ -123,72 +128,77 @@ void SteppingAction::Initialize() {
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void SteppingAction::UserSteppingAction( const G4Step* theStep ) {
|
||||
void SteppingAction::UserSteppingAction(const G4Step* theStep)
|
||||
{
|
||||
// Get information on the primary particle
|
||||
if ( fIsFirstStepOfTheEvent ) {
|
||||
if ( theStep->GetTrack()->GetParentID() == 0 ) {
|
||||
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 );
|
||||
if (fRunPtr) {
|
||||
fRunPtr->SetPrimaryParticleId(fPrimaryParticleId);
|
||||
fRunPtr->SetPrimaryParticleEnergy(fPrimaryParticleEnergy);
|
||||
fRunPtr->SetPrimaryParticleDirection(fPrimaryParticleDirection);
|
||||
}
|
||||
fIsFirstStepOfTheEvent = false;
|
||||
}
|
||||
}
|
||||
// Get information on the materials of the calorimeter
|
||||
if ( fIsFirstStepInAbsorberLayer &&
|
||||
theStep->GetPreStepPoint()->GetPhysicalVolume()->GetName() == "physiAbsorber" ) {
|
||||
if (fIsFirstStepInAbsorberLayer
|
||||
&& theStep->GetPreStepPoint()->GetPhysicalVolume()->GetName() == "physiAbsorber")
|
||||
{
|
||||
fAbsorberMaterialName = theStep->GetPreStepPoint()->GetMaterial()->GetName();
|
||||
if ( fRunPtr ) fRunPtr->SetAbsorberMaterialName( fAbsorberMaterialName );
|
||||
if (fRunPtr) fRunPtr->SetAbsorberMaterialName(fAbsorberMaterialName);
|
||||
fIsFirstStepInAbsorberLayer = false;
|
||||
}
|
||||
if ( fIsFirstStepInActiveLayer &&
|
||||
theStep->GetPreStepPoint()->GetPhysicalVolume()->GetName() == "physiActive" ) {
|
||||
if (fIsFirstStepInActiveLayer
|
||||
&& theStep->GetPreStepPoint()->GetPhysicalVolume()->GetName() == "physiActive")
|
||||
{
|
||||
fActiveMaterialName = theStep->GetPreStepPoint()->GetMaterial()->GetName();
|
||||
if ( fRunPtr ) fRunPtr->SetActiveMaterialName( fActiveMaterialName );
|
||||
if (fRunPtr) fRunPtr->SetActiveMaterialName(fActiveMaterialName);
|
||||
fIsFirstStepInActiveLayer = false;
|
||||
}
|
||||
// Get information on step lengths in the scoring volumes
|
||||
G4int iScoringVolume = -1;
|
||||
if ( theStep->GetPreStepPoint()->GetPhysicalVolume()->GetName() == "physiScoringDownstream" ) {
|
||||
if (theStep->GetPreStepPoint()->GetPhysicalVolume()->GetName() == "physiScoringDownstream") {
|
||||
iScoringVolume = 0;
|
||||
if ( fIsFirstStepInScoringUpDown ) {
|
||||
if (fIsFirstStepInScoringUpDown) {
|
||||
fCubicVolumeScoringUpDown =
|
||||
theStep->GetTrack()->GetVolume()->GetLogicalVolume()->GetSolid()->GetCubicVolume();
|
||||
if ( fRunPtr ) fRunPtr->SetCubicVolumeScoringUpDown( fCubicVolumeScoringUpDown );
|
||||
fIsFirstStepInScoringUpDown = false;
|
||||
}
|
||||
} else if ( theStep->GetPreStepPoint()->GetPhysicalVolume()->GetName() == "physiScoringSide" ) {
|
||||
iScoringVolume = 1;
|
||||
if ( fIsFirstStepInScoringSide ) {
|
||||
fCubicVolumeScoringSide =
|
||||
theStep->GetTrack()->GetVolume()->GetLogicalVolume()->GetSolid()->GetCubicVolume();
|
||||
if ( fRunPtr ) fRunPtr->SetCubicVolumeScoringSide( fCubicVolumeScoringSide );
|
||||
fIsFirstStepInScoringSide = false;
|
||||
}
|
||||
} else if ( theStep->GetPreStepPoint()->GetPhysicalVolume()->GetName() ==
|
||||
"physiScoringUpstream" ) {
|
||||
iScoringVolume = 2;
|
||||
if ( fIsFirstStepInScoringUpDown ) {
|
||||
fCubicVolumeScoringUpDown =
|
||||
theStep->GetTrack()->GetVolume()->GetLogicalVolume()->GetSolid()->GetCubicVolume();
|
||||
if ( fRunPtr ) fRunPtr->SetCubicVolumeScoringUpDown( fCubicVolumeScoringUpDown );
|
||||
if (fRunPtr) fRunPtr->SetCubicVolumeScoringUpDown(fCubicVolumeScoringUpDown);
|
||||
fIsFirstStepInScoringUpDown = false;
|
||||
}
|
||||
}
|
||||
if ( iScoringVolume >= 0 ) {
|
||||
else if (theStep->GetPreStepPoint()->GetPhysicalVolume()->GetName() == "physiScoringSide") {
|
||||
iScoringVolume = 1;
|
||||
if (fIsFirstStepInScoringSide) {
|
||||
fCubicVolumeScoringSide =
|
||||
theStep->GetTrack()->GetVolume()->GetLogicalVolume()->GetSolid()->GetCubicVolume();
|
||||
if (fRunPtr) fRunPtr->SetCubicVolumeScoringSide(fCubicVolumeScoringSide);
|
||||
fIsFirstStepInScoringSide = false;
|
||||
}
|
||||
}
|
||||
else if (theStep->GetPreStepPoint()->GetPhysicalVolume()->GetName() == "physiScoringUpstream") {
|
||||
iScoringVolume = 2;
|
||||
if (fIsFirstStepInScoringUpDown) {
|
||||
fCubicVolumeScoringUpDown =
|
||||
theStep->GetTrack()->GetVolume()->GetLogicalVolume()->GetSolid()->GetCubicVolume();
|
||||
if (fRunPtr) fRunPtr->SetCubicVolumeScoringUpDown(fCubicVolumeScoringUpDown);
|
||||
fIsFirstStepInScoringUpDown = false;
|
||||
}
|
||||
}
|
||||
if (iScoringVolume >= 0) {
|
||||
// In the case of the upstream scoring volume, consider only particles whose direction
|
||||
// is opposite with respect to the primary particle (this is needed, in particular,
|
||||
// for avoiding to account the incoming, primary beam particle in the "upstream" fluence).
|
||||
if ( iScoringVolume == 2 &&
|
||||
fPrimaryParticleDirection.dot(
|
||||
theStep->GetPreStepPoint()->GetMomentumDirection() ) > 0.0 ) return;
|
||||
if (iScoringVolume == 2
|
||||
&& fPrimaryParticleDirection.dot(theStep->GetPreStepPoint()->GetMomentumDirection()) > 0.0)
|
||||
return;
|
||||
G4double stepLength = theStep->GetTrack()->GetStepLength() * theStep->GetTrack()->GetWeight();
|
||||
G4int absPdg = theStep->GetTrack()->GetDefinition() == nullptr ? 0 :
|
||||
std::abs( theStep->GetTrack()->GetDefinition()->GetPDGEncoding() );
|
||||
G4int absPdg = theStep->GetTrack()->GetDefinition() == nullptr
|
||||
? 0
|
||||
: std::abs(theStep->GetTrack()->GetDefinition()->GetPDGEncoding());
|
||||
/*
|
||||
G4cout << std::setprecision(6)
|
||||
<< theStep->GetTrack()->GetDefinition()->GetParticleName() << " absPdg=" << absPdg
|
||||
@@ -197,42 +207,52 @@ void SteppingAction::UserSteppingAction( const G4Step* theStep ) {
|
||||
<< "," << theStep->GetTrack()->GetPosition().z() << ")"
|
||||
<< " " << theStep->GetTrack()->GetVolume()->GetName()
|
||||
<< " " << theStep->GetTrack()->GetMaterial()->GetName()
|
||||
<< " L[mm]=" << stepLength << " "
|
||||
<< ( fPrimaryParticleDirection.dot(
|
||||
<< " L[mm]=" << stepLength << " "
|
||||
<< ( fPrimaryParticleDirection.dot(
|
||||
theStep->GetPreStepPoint()->GetMomentumDirection() ) > 0.0
|
||||
? "forward" : "backward" )
|
||||
? "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;
|
||||
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.)
|
||||
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 volume, kinematic region and particle type
|
||||
G4int index = GetIndex( iScoringVolume, iKinematicRegion, iParticleType );
|
||||
G4int index = GetIndex(iScoringVolume, iKinematicRegion, iParticleType);
|
||||
fArraySumStepLengths[index] += stepLength;
|
||||
// Consider the "all" particle case, with the same scoring volume and kinematic region
|
||||
index = GetIndex( iScoringVolume, iKinematicRegion, 0 );
|
||||
index = GetIndex(iScoringVolume, iKinematicRegion, 0);
|
||||
fArraySumStepLengths[index] += stepLength;
|
||||
// Consider the "any" kinematic region case, with the same scoring volume and particle type
|
||||
index = GetIndex( iScoringVolume, 0, iParticleType );
|
||||
// Consider the "any" kinematic region case, with the same scoring volume and particle type
|
||||
index = GetIndex(iScoringVolume, 0, iParticleType);
|
||||
fArraySumStepLengths[index] += stepLength;
|
||||
// Consider the "any" kinematic region and "all" particle, with the same scoring volume
|
||||
index = GetIndex( iScoringVolume, 0, 0 );
|
||||
index = GetIndex(iScoringVolume, 0, 0);
|
||||
fArraySumStepLengths[index] += stepLength;
|
||||
if ( fRunPtr ) fRunPtr->SetSteppingArray( fArraySumStepLengths );
|
||||
if (fRunPtr) fRunPtr->SetSteppingArray(fArraySumStepLengths);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -32,115 +32,130 @@
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
#include "TrackingAction.hh"
|
||||
#include "G4Track.hh"
|
||||
#include "G4Step.hh"
|
||||
#include "G4ParticleDefinition.hh"
|
||||
#include "G4ParticleTypes.hh"
|
||||
#include "G4IonTable.hh"
|
||||
#include "G4StepPoint.hh"
|
||||
#include "G4SystemOfUnits.hh"
|
||||
|
||||
#include "Run.hh"
|
||||
|
||||
const std::array< G4String, TrackingAction::fkNumberScoringVolumes >
|
||||
TrackingAction::fkArrayScoringVolumeNames = { "calorimeter" };
|
||||
#include "G4IonTable.hh"
|
||||
#include "G4ParticleDefinition.hh"
|
||||
#include "G4ParticleTypes.hh"
|
||||
#include "G4Step.hh"
|
||||
#include "G4StepPoint.hh"
|
||||
#include "G4SystemOfUnits.hh"
|
||||
#include "G4Track.hh"
|
||||
|
||||
const std::array< G4String, TrackingAction::fkNumberKinematicRegions >
|
||||
TrackingAction::fkArrayKinematicRegionNames = { "", "below 20 MeV", "above 20 MeV" };
|
||||
const std::array<G4String, TrackingAction::fkNumberScoringVolumes>
|
||||
TrackingAction::fkArrayScoringVolumeNames = {"calorimeter"};
|
||||
|
||||
const std::array< G4String, TrackingAction::fkNumberParticleTypes >
|
||||
TrackingAction::fkArrayParticleTypeNames = { "all", "electron", "gamma", "muon", "neutrino",
|
||||
"pion", "neutron", "proton", "ion", "otherMeson",
|
||||
"otherBaryon" };
|
||||
const std::array<G4String, TrackingAction::fkNumberKinematicRegions>
|
||||
TrackingAction::fkArrayKinematicRegionNames = {"", "below 20 MeV", "above 20 MeV"};
|
||||
|
||||
const std::array<G4String, TrackingAction::fkNumberParticleTypes>
|
||||
TrackingAction::fkArrayParticleTypeNames = {"all", "electron", "gamma", "muon",
|
||||
"neutrino", "pion", "neutron", "proton",
|
||||
"ion", "otherMeson", "otherBaryon"};
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
G4int TrackingAction::GetIndex( const G4int iScoringVolume, const G4int iKinematicRegion,
|
||||
const G4int iParticleType ) {
|
||||
G4int TrackingAction::GetIndex(const G4int iScoringVolume, const G4int iKinematicRegion,
|
||||
const G4int iParticleType)
|
||||
{
|
||||
G4int index = -1;
|
||||
if ( iScoringVolume >= 0 && iScoringVolume < fkNumberScoringVolumes &&
|
||||
iKinematicRegion >= 0 && iKinematicRegion < fkNumberKinematicRegions &&
|
||||
iParticleType >= 0 && iParticleType < fkNumberParticleTypes ) {
|
||||
index = iScoringVolume * fkNumberKinematicRegions * fkNumberParticleTypes +
|
||||
iKinematicRegion * fkNumberParticleTypes +
|
||||
iParticleType;
|
||||
if (iScoringVolume >= 0 && iScoringVolume < fkNumberScoringVolumes && iKinematicRegion >= 0
|
||||
&& iKinematicRegion < fkNumberKinematicRegions && iParticleType >= 0
|
||||
&& iParticleType < fkNumberParticleTypes)
|
||||
{
|
||||
index = iScoringVolume * fkNumberKinematicRegions * fkNumberParticleTypes
|
||||
+ iKinematicRegion * fkNumberParticleTypes + iParticleType;
|
||||
}
|
||||
return index;
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
TrackingAction::TrackingAction() : G4UserTrackingAction() {
|
||||
TrackingAction::TrackingAction() : G4UserTrackingAction()
|
||||
{
|
||||
Initialize();
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void TrackingAction::Initialize() {
|
||||
void TrackingAction::Initialize()
|
||||
{
|
||||
// Initialization needed at the beginning of each Run
|
||||
fArrayMultiplicities.fill( 0 );
|
||||
fArraySumKineticEnergies.fill( 0.0 );
|
||||
fArrayMultiplicities.fill(0);
|
||||
fArraySumKineticEnergies.fill(0.0);
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void TrackingAction::PreUserTrackingAction( const G4Track* aTrack ) {
|
||||
// This method is called not only once when a particle is created,
|
||||
void TrackingAction::PreUserTrackingAction(const G4Track* aTrack)
|
||||
{
|
||||
// This method is called not only once when a particle is created,
|
||||
// but also each time it is resumed, in the case the track gets suspended,
|
||||
// as it happens in the case of neutrons with _HP Physics Lists.
|
||||
// To be sure that we collect information about a track one and only once,
|
||||
// we require that the current step be the first one.
|
||||
if ( aTrack == nullptr ||
|
||||
aTrack->GetCurrentStepNumber() != 0 ||
|
||||
aTrack->GetDefinition() == nullptr ||
|
||||
aTrack->GetLogicalVolumeAtVertex() == nullptr ||
|
||||
( aTrack->GetLogicalVolumeAtVertex()->GetName() != "logicAbsorber" &&
|
||||
aTrack->GetLogicalVolumeAtVertex()->GetName() != "logicActive" ) ) {
|
||||
if (aTrack == nullptr || aTrack->GetCurrentStepNumber() != 0 || aTrack->GetDefinition() == nullptr
|
||||
|| aTrack->GetLogicalVolumeAtVertex() == nullptr
|
||||
|| (aTrack->GetLogicalVolumeAtVertex()->GetName() != "logicAbsorber"
|
||||
&& aTrack->GetLogicalVolumeAtVertex()->GetName() != "logicActive"))
|
||||
{
|
||||
return;
|
||||
}
|
||||
G4int iScoringVolume = 0;
|
||||
// Three kinematical regions: [0] : any value ; [1] : below 20 MeV ; [2] : above 20 MeV
|
||||
G4int iKinematicRegion = aTrack->GetKineticEnergy() < 20.0 ? 1 : 2;
|
||||
G4int absPdg = std::abs( aTrack->GetDefinition()->GetPDGEncoding() );
|
||||
G4int absPdg = std::abs(aTrack->GetDefinition()->GetPDGEncoding());
|
||||
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( aTrack->GetDefinition() ) ||
|
||||
G4IonTable::IsAntiIon( aTrack->GetDefinition() ) ) iParticleType = 8;
|
||||
// ions (and anti-ions)
|
||||
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.)
|
||||
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(aTrack->GetDefinition())
|
||||
|| G4IonTable::IsAntiIon(aTrack->GetDefinition()))
|
||||
iParticleType = 8;
|
||||
// ions (and anti-ions)
|
||||
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 volume, kinematic region and particle type
|
||||
G4int index = GetIndex( iScoringVolume, iKinematicRegion, iParticleType );
|
||||
++fArrayMultiplicities[index];
|
||||
fArraySumKineticEnergies[index] += aTrack->GetKineticEnergy();
|
||||
// Consider the "all" particle case, with the same scoring volume and kinematic region
|
||||
index = GetIndex( iScoringVolume, iKinematicRegion, 0 );
|
||||
G4int index = GetIndex(iScoringVolume, iKinematicRegion, iParticleType);
|
||||
++fArrayMultiplicities[index];
|
||||
fArraySumKineticEnergies[index] += aTrack->GetKineticEnergy();
|
||||
// Consider the "any" kinematic region case, with the same scoring volume and particle type
|
||||
index = GetIndex( iScoringVolume, 0, iParticleType );
|
||||
// Consider the "all" particle case, with the same scoring volume and kinematic region
|
||||
index = GetIndex(iScoringVolume, iKinematicRegion, 0);
|
||||
++fArrayMultiplicities[index];
|
||||
fArraySumKineticEnergies[index] += aTrack->GetKineticEnergy();
|
||||
// Consider the "any" kinematic region case, with the same scoring volume and particle type
|
||||
index = GetIndex(iScoringVolume, 0, iParticleType);
|
||||
++fArrayMultiplicities[index];
|
||||
fArraySumKineticEnergies[index] += aTrack->GetKineticEnergy();
|
||||
// Consider the "any" kinematic region and "all" particle, with the same scoring volume
|
||||
index = GetIndex( iScoringVolume, 0, 0 );
|
||||
index = GetIndex(iScoringVolume, 0, 0);
|
||||
++fArrayMultiplicities[index];
|
||||
fArraySumKineticEnergies[index] += aTrack->GetKineticEnergy();
|
||||
if ( fRunPtr ) {
|
||||
fRunPtr->SetTrackingArray1( fArrayMultiplicities );
|
||||
fRunPtr->SetTrackingArray2( fArraySumKineticEnergies );
|
||||
if (fRunPtr) {
|
||||
fRunPtr->SetTrackingArray1(fArrayMultiplicities);
|
||||
fRunPtr->SetTrackingArray2(fArraySumKineticEnergies);
|
||||
}
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void TrackingAction::PostUserTrackingAction( const G4Track* /* aTrack */ ) {}
|
||||
void TrackingAction::PostUserTrackingAction(const G4Track* /* aTrack */) {}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
Reference in New Issue
Block a user