Import Geant4 11.1.0 source tree
This commit is contained in:
@@ -35,6 +35,7 @@
|
||||
#include "PrimaryGeneratorAction.hh"
|
||||
#include "RunAction.hh"
|
||||
#include "SteppingAction.hh"
|
||||
#include "TrackingAction.hh"
|
||||
#include "Run.hh"
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
@@ -45,10 +46,6 @@ ActionInitialization::ActionInitialization( const DetectorConstruction*
|
||||
|
||||
//....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 );
|
||||
@@ -61,7 +58,9 @@ void ActionInitialization::Build() const {
|
||||
SetUserAction( new PrimaryGeneratorAction( fPtrDetectorConstruction ) );
|
||||
SteppingAction* steppingAction = new SteppingAction;
|
||||
SetUserAction( steppingAction );
|
||||
SetUserAction( new RunAction( steppingAction ) );
|
||||
TrackingAction* trackingAction = new TrackingAction;
|
||||
SetUserAction( trackingAction );
|
||||
SetUserAction( new RunAction( steppingAction, trackingAction ) );
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
Executable → Regular
Executable → Regular
Executable → Regular
@@ -44,15 +44,13 @@ Run::Run() : G4Run(), fNumEvents( 0 ),
|
||||
fTargetMaterialName( "" ),
|
||||
fCubicVolumeScoringUpDown( 1.0 ), fCubicVolumeScoringSide( 1.0 )
|
||||
{
|
||||
for ( G4int i = 0; i < SteppingAction::numberCombinations; ++i ) fArray[i] = 0.0;
|
||||
fSteppingArray.fill( 0.0 );
|
||||
fTrackingArray1.fill( 0 );
|
||||
fTrackingArray2.fill( 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.
|
||||
@@ -67,22 +65,26 @@ 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();
|
||||
fTargetMaterialName = localRun->getTargetMaterialName();
|
||||
fCubicVolumeScoringUpDown = localRun->getCubicVolumeScoringUpDown();
|
||||
fCubicVolumeScoringSide = localRun->getCubicVolumeScoringSide();
|
||||
fPrimaryParticleId = localRun->GetPrimaryParticleId();
|
||||
fPrimaryParticleEnergy = localRun->GetPrimaryParticleEnergy();
|
||||
fPrimaryParticleDirection = localRun->GetPrimaryParticleDirection();
|
||||
fTargetMaterialName = localRun->GetTargetMaterialName();
|
||||
fCubicVolumeScoringUpDown = localRun->GetCubicVolumeScoringUpDown();
|
||||
fCubicVolumeScoringSide = localRun->GetCubicVolumeScoringSide();
|
||||
fNumEvents += localRun->GetNumberOfEvent();
|
||||
for ( G4int i = 0; i < SteppingAction::numberCombinations; ++i ) {
|
||||
fArray[i] += localRun->getArray()[i];
|
||||
for ( G4int i = 0; i < SteppingAction::fkNumberCombinations; ++i ) {
|
||||
fSteppingArray[i] += localRun->GetSteppingArray()[i];
|
||||
}
|
||||
for ( G4int i = 0; i < TrackingAction::fkNumberCombinations; ++i ) {
|
||||
fTrackingArray1[i] += localRun->GetTrackingArray1()[i];
|
||||
fTrackingArray2[i] += localRun->GetTrackingArray2()[i];
|
||||
}
|
||||
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 =
|
||||
@@ -95,7 +97,7 @@ void Run::printInfo() const {
|
||||
const G4double factorSide =
|
||||
conversionFactor / ( fCubicVolumeScoringSide*floatingNumberOfEvents );
|
||||
G4cout << std::setprecision(6) << G4endl << G4endl
|
||||
<< " =============== Run::printInfo() =============== \t RunID = " << GetRunID()
|
||||
<< " =============== Run::PrintInfo() =============== \t RunID = " << GetRunID()
|
||||
<< G4endl
|
||||
<< " Primary particle PDG code = " << fPrimaryParticleId << G4endl
|
||||
<< " Primary particle kinetic energy = " << fPrimaryParticleEnergy / CLHEP::GeV
|
||||
@@ -107,17 +109,39 @@ void Run::printInfo() const {
|
||||
<< " 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::numberScoringVolumes; ++i ) {
|
||||
for ( G4int i = 0; i < SteppingAction::fkNumberScoringVolumes; ++i ) {
|
||||
G4double factor = ( i == 1 ? factorSide : factorUpDown );
|
||||
for ( G4int j = 0; j < SteppingAction::numberKinematicRegions; ++j ) {
|
||||
for ( G4int k = 0; k < SteppingAction::numberParticleTypes; ++k ) {
|
||||
G4int index = SteppingAction::getIndex( i, j, k );
|
||||
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::arrayScoringVolumeNames[i]
|
||||
<< " " << std::setw(12) << SteppingAction::arrayKinematicRegionNames[j]
|
||||
<< " " << std::setw(12) << SteppingAction::arrayParticleTypeNames[k]
|
||||
<< " " << factor*fArray[index] << G4endl;
|
||||
<< " " << 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
G4cout << " ------------------------------------------------------------- " << G4endl
|
||||
<< " 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -126,11 +150,29 @@ void Run::printInfo() const {
|
||||
|
||||
//....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];
|
||||
}
|
||||
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< G4int,
|
||||
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 ) {
|
||||
fTrackingArray2[i] = inputArray[i];
|
||||
}
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
Executable → Regular
+13
-11
@@ -36,16 +36,13 @@
|
||||
#include "G4Run.hh"
|
||||
#include "Run.hh"
|
||||
#include "SteppingAction.hh"
|
||||
#include "TrackingAction.hh"
|
||||
#include "G4RunManager.hh"
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
RunAction::RunAction( SteppingAction* steppingAction ) :
|
||||
G4UserRunAction(), fSteppingAction( steppingAction ) {}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
RunAction::~RunAction() {}
|
||||
RunAction::RunAction( SteppingAction* steppingAction, TrackingAction* trackingAction ) :
|
||||
G4UserRunAction(), fSteppingAction( steppingAction ), fTrackingAction( trackingAction ) {}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
@@ -57,10 +54,15 @@ G4Run* RunAction::GenerateRun() {
|
||||
|
||||
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 );
|
||||
Run* run = const_cast< Run* >( static_cast< const Run* >( aRun ) );
|
||||
if ( run == nullptr ) return;
|
||||
if ( fSteppingAction != nullptr ) {
|
||||
fSteppingAction->Initialize();
|
||||
fSteppingAction->SetRunPointer( run );
|
||||
}
|
||||
if ( fTrackingAction != nullptr ) {
|
||||
fTrackingAction->Initialize();
|
||||
fTrackingAction->SetRunPointer( run );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -69,7 +71,7 @@ void RunAction::BeginOfRunAction( const G4Run* aRun ) {
|
||||
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();
|
||||
if ( IsMaster() ) run->PrintInfo();
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
Executable → Regular
+42
-42
@@ -46,45 +46,45 @@
|
||||
#include "G4SystemOfUnits.hh"
|
||||
#include "Run.hh"
|
||||
|
||||
const std::array< G4String, SteppingAction::numberScoringVolumes >
|
||||
SteppingAction::arrayScoringVolumeNames = { "downstream", "side", "upstream" };
|
||||
const std::array< G4String, SteppingAction::fkNumberScoringVolumes >
|
||||
SteppingAction::fkArrayScoringVolumeNames = { "downstream", "side", "upstream" };
|
||||
|
||||
const std::array< G4String, SteppingAction::numberKinematicRegions >
|
||||
SteppingAction::arrayKinematicRegionNames = { "", "below 20 MeV", "above 20 MeV" };
|
||||
const std::array< G4String, SteppingAction::fkNumberKinematicRegions >
|
||||
SteppingAction::fkArrayKinematicRegionNames = { "", "below 20 MeV", "above 20 MeV" };
|
||||
|
||||
const std::array< G4String, SteppingAction::numberParticleTypes >
|
||||
SteppingAction::arrayParticleTypeNames = { "all", "electron", "gamma", "muon", "neutrino",
|
||||
"pion", "neutron", "proton", "ion", "otherMeson",
|
||||
"otherBaryon" };
|
||||
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,
|
||||
G4int SteppingAction::GetIndex( const G4int iScoringVolume, const G4int iKinematicRegion,
|
||||
const G4int iParticleType ) {
|
||||
G4int index = -1;
|
||||
if ( iScoringVolume >= 0 && iScoringVolume < numberScoringVolumes &&
|
||||
iKinematicRegion >= 0 && iKinematicRegion < numberKinematicRegions &&
|
||||
iParticleType >= 0 && iParticleType < numberParticleTypes ) {
|
||||
index = iScoringVolume * numberKinematicRegions * numberParticleTypes +
|
||||
iKinematicRegion * numberParticleTypes +
|
||||
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 ) {
|
||||
G4cerr << "SteppingAction::GetIndex : WRONG index=" << index << " set it to 0 !" << G4endl;
|
||||
index = 0;
|
||||
}
|
||||
return index;
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
SteppingAction::SteppingAction() :G4UserSteppingAction() {
|
||||
initialize();
|
||||
SteppingAction::SteppingAction() : G4UserSteppingAction() {
|
||||
Initialize();
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
SteppingAction::~SteppingAction() {}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void SteppingAction::initialize() {
|
||||
void SteppingAction::Initialize() {
|
||||
// Initialization needed at the beginning of each Run
|
||||
fPrimaryParticleId = 0;
|
||||
fPrimaryParticleEnergy = 0.0;
|
||||
@@ -96,16 +96,16 @@ void SteppingAction::initialize() {
|
||||
fIsFirstStepInScoringSide = true;
|
||||
fCubicVolumeScoringUpDown = 1.0;
|
||||
fCubicVolumeScoringSide = 1.0;
|
||||
for ( G4int i = 0; i < numberCombinations; ++i ) {
|
||||
for ( G4int i = 0; i < fkNumberCombinations; ++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 < numberScoringVolumes; ++i ) {
|
||||
for ( G4int j = 0; j < numberKinematicRegions; ++j ) {
|
||||
for ( G4int k = 0; k < numberParticleTypes; ++k ) {
|
||||
G4int index = getIndex( i, j, k );
|
||||
for ( G4int i = 0; i < fkNumberCombinations; ++i ) fArraySumStepLengths[i] = 999.9;
|
||||
G4cout << " fkNumberCombinations=" << fkNumberCombinations << G4endl;
|
||||
for ( G4int i = 0; i < fkNumberScoringVolumes; ++i ) {
|
||||
for ( G4int j = 0; j < fkNumberKinematicRegions; ++j ) {
|
||||
for ( G4int k = 0; k < fkNumberParticleTypes; ++k ) {
|
||||
G4int index = GetIndex( i, j, k );
|
||||
G4cout << "(i, j, k)=(" << i << ", " << j << ", " << k << ") ->" << index;
|
||||
if ( fArraySumStepLengths[ index ] < 1.0 ) G4cout << " <=== REPEATED!";
|
||||
else fArraySumStepLengths[ index ] = 0.0;
|
||||
@@ -113,7 +113,7 @@ void SteppingAction::initialize() {
|
||||
}
|
||||
}
|
||||
}
|
||||
for ( G4int i = 0; i < numberCombinations; ++i ) {
|
||||
for ( G4int i = 0; i < fkNumberCombinations; ++i ) {
|
||||
if ( fArraySumStepLengths[i] > 999.0 ) G4cout << " i=" << i << " NOT COVERED !" << G4endl;
|
||||
}
|
||||
*/
|
||||
@@ -129,9 +129,9 @@ void SteppingAction::UserSteppingAction( const G4Step* theStep ) {
|
||||
fPrimaryParticleEnergy = theStep->GetPreStepPoint()->GetKineticEnergy();
|
||||
fPrimaryParticleDirection = theStep->GetPreStepPoint()->GetMomentumDirection();
|
||||
if ( fRunPtr ) {
|
||||
fRunPtr->setPrimaryParticleId( fPrimaryParticleId );
|
||||
fRunPtr->setPrimaryParticleEnergy( fPrimaryParticleEnergy );
|
||||
fRunPtr->setPrimaryParticleDirection( fPrimaryParticleDirection );
|
||||
fRunPtr->SetPrimaryParticleId( fPrimaryParticleId );
|
||||
fRunPtr->SetPrimaryParticleEnergy( fPrimaryParticleEnergy );
|
||||
fRunPtr->SetPrimaryParticleDirection( fPrimaryParticleDirection );
|
||||
}
|
||||
fIsFirstStepOfTheEvent = false;
|
||||
}
|
||||
@@ -140,7 +140,7 @@ void SteppingAction::UserSteppingAction( const G4Step* theStep ) {
|
||||
if ( fIsFirstStepInTarget &&
|
||||
theStep->GetPreStepPoint()->GetPhysicalVolume()->GetName() == "physiLayer" ) {
|
||||
fTargetMaterialName = theStep->GetPreStepPoint()->GetMaterial()->GetName();
|
||||
if ( fRunPtr ) fRunPtr->setTargetMaterialName( fTargetMaterialName );
|
||||
if ( fRunPtr ) fRunPtr->SetTargetMaterialName( fTargetMaterialName );
|
||||
fIsFirstStepInTarget = false;
|
||||
}
|
||||
// Get information on step lengths in the scoring volumes
|
||||
@@ -150,7 +150,7 @@ void SteppingAction::UserSteppingAction( const G4Step* theStep ) {
|
||||
if ( fIsFirstStepInScoringUpDown ) {
|
||||
fCubicVolumeScoringUpDown =
|
||||
theStep->GetTrack()->GetVolume()->GetLogicalVolume()->GetSolid()->GetCubicVolume();
|
||||
if ( fRunPtr ) fRunPtr->setCubicVolumeScoringUpDown( fCubicVolumeScoringUpDown );
|
||||
if ( fRunPtr ) fRunPtr->SetCubicVolumeScoringUpDown( fCubicVolumeScoringUpDown );
|
||||
fIsFirstStepInScoringUpDown = false;
|
||||
}
|
||||
} else if ( theStep->GetPreStepPoint()->GetPhysicalVolume()->GetName() == "physiScoringSide" ) {
|
||||
@@ -158,7 +158,7 @@ void SteppingAction::UserSteppingAction( const G4Step* theStep ) {
|
||||
if ( fIsFirstStepInScoringSide ) {
|
||||
fCubicVolumeScoringSide =
|
||||
theStep->GetTrack()->GetVolume()->GetLogicalVolume()->GetSolid()->GetCubicVolume();
|
||||
if ( fRunPtr ) fRunPtr->setCubicVolumeScoringSide( fCubicVolumeScoringSide );
|
||||
if ( fRunPtr ) fRunPtr->SetCubicVolumeScoringSide( fCubicVolumeScoringSide );
|
||||
fIsFirstStepInScoringSide = false;
|
||||
}
|
||||
} else if ( theStep->GetPreStepPoint()->GetPhysicalVolume()->GetName() ==
|
||||
@@ -167,7 +167,7 @@ void SteppingAction::UserSteppingAction( const G4Step* theStep ) {
|
||||
if ( fIsFirstStepInScoringUpDown ) {
|
||||
fCubicVolumeScoringUpDown =
|
||||
theStep->GetTrack()->GetVolume()->GetLogicalVolume()->GetSolid()->GetCubicVolume();
|
||||
if ( fRunPtr ) fRunPtr->setCubicVolumeScoringUpDown( fCubicVolumeScoringUpDown );
|
||||
if ( fRunPtr ) fRunPtr->SetCubicVolumeScoringUpDown( fCubicVolumeScoringUpDown );
|
||||
fIsFirstStepInScoringUpDown = false;
|
||||
}
|
||||
}
|
||||
@@ -214,18 +214,18 @@ void SteppingAction::UserSteppingAction( const G4Step* theStep ) {
|
||||
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 );
|
||||
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->setArray( fArraySumStepLengths );
|
||||
if ( fRunPtr ) fRunPtr->SetSteppingArray( fArraySumStepLengths );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,143 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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 TrackingAction.cc
|
||||
/// \brief Implementation of the TrackingAction class
|
||||
//
|
||||
//
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
//....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 = { "layer" };
|
||||
|
||||
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 index = -1;
|
||||
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() {
|
||||
Initialize();
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void TrackingAction::Initialize() {
|
||||
// Initialization needed at the beginning of each Run
|
||||
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,
|
||||
// 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() != "logicLayer" ) 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 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.)
|
||||
// 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 );
|
||||
++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 );
|
||||
++fArrayMultiplicities[index];
|
||||
fArraySumKineticEnergies[index] += aTrack->GetKineticEnergy();
|
||||
if ( fRunPtr ) {
|
||||
fRunPtr->SetTrackingArray1( fArrayMultiplicities );
|
||||
fRunPtr->SetTrackingArray2( fArraySumKineticEnergies );
|
||||
}
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void TrackingAction::PostUserTrackingAction( const G4Track* /* aTrack */ ) {}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
Reference in New Issue
Block a user