Import Geant4 10.6.0 source tree

This commit is contained in:
Gabriele Cosmo
2019-12-06 15:12:28 +01:00
parent b2a62ae692
commit 5baee230e9
2997 changed files with 141580 additions and 98673 deletions
@@ -0,0 +1,57 @@
//
// ********************************************************************
// * 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 GB07ActionInitialization.cc
/// \brief Implementation of the GB07ActionInitialization class
#include "GB07ActionInitialization.hh"
#include "GB07PrimaryGeneratorAction.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
GB07ActionInitialization::GB07ActionInitialization()
: G4VUserActionInitialization()
{}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
GB07ActionInitialization::~GB07ActionInitialization()
{;}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void GB07ActionInitialization::BuildForMaster() const
{
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void GB07ActionInitialization::Build() const
{
SetUserAction(new GB07PrimaryGeneratorAction);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -0,0 +1,152 @@
//
// ********************************************************************
// * 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 GB07/src/GB07BOptrLeadingParticle.cc
/// \brief Implementation of the GB07BOptrLeadingParticle class
//
#include "GB07BOptrLeadingParticle.hh"
#include "G4BiasingProcessInterface.hh"
#include "G4BOptnLeadingParticle.hh"
#include "G4ParticleDefinition.hh"
#include "G4Gamma.hh"
#include "G4Electron.hh"
#include "G4Positron.hh"
#include "G4PionZero.hh"
#include "G4ProcessManager.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
GB07BOptrLeadingParticle::GB07BOptrLeadingParticle( G4String operatorName )
: G4VBiasingOperator ( operatorName ),
fAnnihilation ( nullptr ),
fConversion ( nullptr ),
fDecay ( nullptr ),
fTwoParticleProcess ( nullptr )
{
fLeadingParticleBiasingOperation =
new G4BOptnLeadingParticle("LeadingParticleBiasingOperation");
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
GB07BOptrLeadingParticle::~GB07BOptrLeadingParticle()
{
delete fLeadingParticleBiasingOperation;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4VBiasingOperation*
GB07BOptrLeadingParticle::
ProposeFinalStateBiasingOperation(const G4Track*,
const G4BiasingProcessInterface* callingProcess)
{
// -- When the present method is called, we are at the process final state
// -- generation level. The process is given by the callingProcess argument,
// -- which, in our case, wrappes a physics process, to control it.
// -- To bias the final state generation, we return a biasing operation
// -- which is fLeadingParticleBiasingOperation here. Before returning it, we
// -- configure it depending on if the process is a two-particle final state
// -- or if it is a many-particle final state process. For the two-particle
// -- final state, one track is the leading and the other is alone in its category,
// -- so always surviving by default. We play a Russian roulette on it to
// -- trim also these two-particles final states.
if ( callingProcess == fTwoParticleProcess )
{
// -- secondary particle accompagnying the leading one will be
// -- killed with 2./3. probability (Russian roulette):
fLeadingParticleBiasingOperation->SetFurtherKillingProbability( 2./3.);
}
else
{
// -- -1.0 means no effect : no further killing is applied to secondary
// -- particles accompanying the leading one.
fLeadingParticleBiasingOperation->SetFurtherKillingProbability( -1.0 );
}
return fLeadingParticleBiasingOperation;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void
GB07BOptrLeadingParticle::
StartRun()
{
// -- collect the two-particle final state processes:
fAnnihilation = nullptr;
fConversion = nullptr;
fDecay = nullptr;
// ---- collect e+ annihilation process:
auto positronProcesses = G4Positron::Definition()->GetProcessManager()->GetProcessList();
for ( size_t i = 0; i < positronProcesses->size(); ++i )
{
if ( (*positronProcesses)[i]->GetProcessName() == "biasWrapper(annihil)")
{
fAnnihilation = (*positronProcesses)[i];
break;
}
}
// ---- collect gamma conversion process:
auto gammaProcesses = G4Gamma::Definition()->GetProcessManager()->GetProcessList();
for ( size_t i = 0; i < gammaProcesses->size(); ++i )
{
if ( (*gammaProcesses)[i]->GetProcessName() == "biasWrapper(conv)")
{
fConversion = (*gammaProcesses)[i];
break;
}
}
// ---- collect pi0 decay process:
auto pi0Processes = G4PionZero::Definition()->GetProcessManager()->GetProcessList();
for ( size_t i = 0; i < pi0Processes->size(); ++i )
{
if ( (*pi0Processes)[i]->GetProcessName() == "biasWrapper(Decay)")
{
fDecay = (*pi0Processes)[i];
break;
}
}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void
GB07BOptrLeadingParticle::
StartTracking( const G4Track* track )
{
// -- remember what is the two-particle final state process -if any- for this starting
// -- track:
fTwoParticleProcess = nullptr;
if ( track->GetDefinition() == G4Gamma ::Definition() ) fTwoParticleProcess = fConversion;
if ( track->GetDefinition() == G4Positron::Definition() ) fTwoParticleProcess = fAnnihilation;
if ( track->GetDefinition() == G4PionZero::Definition() ) fTwoParticleProcess = fDecay;
}
@@ -0,0 +1,148 @@
//
// ********************************************************************
// * 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 GB07/src/GB07DetectorConstruction.cc
/// \brief Implementation of the GB07DetectorConstruction class
//
#include "GB07DetectorConstruction.hh"
#include "G4SystemOfUnits.hh"
#include "G4Material.hh"
#include "G4NistManager.hh"
#include "G4Box.hh"
#include "G4LogicalVolume.hh"
#include "G4LogicalVolumeStore.hh"
#include "G4PVPlacement.hh"
#include "G4NistManager.hh"
#include "GB07BOptrLeadingParticle.hh"
#include "GB07SD.hh"
#include "G4SDManager.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
GB07DetectorConstruction::GB07DetectorConstruction()
: G4VUserDetectorConstruction()
{}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
GB07DetectorConstruction::~GB07DetectorConstruction()
{}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4VPhysicalVolume* GB07DetectorConstruction::Construct()
{
G4Material* worldMaterial = G4NistManager::Instance()->FindOrBuildMaterial("G4_Galactic");
G4Material* defaultMaterial = G4NistManager::Instance()->FindOrBuildMaterial("G4_CONCRETE");
G4VSolid* solidWorld = new G4Box("World", 10*m, 10*m, 10*m );
G4LogicalVolume* logicWorld = new G4LogicalVolume(solidWorld, // its solid
worldMaterial, // its material
"World"); // its name
G4PVPlacement* physiWorld = new G4PVPlacement(0, // no rotation
G4ThreeVector(), // at (0,0,0)
logicWorld, // its logical volume
"World", // its name
0, // its mother volume
false, // no boolean operation
0); // copy number
// -----------------------------------
// -- volume where biasing is applied:
// -----------------------------------
G4double halfZ = 1*m;
G4VSolid* solidTest = new G4Box("test.solid", 1*m, 1*m, halfZ );
G4LogicalVolume* logicTest = new G4LogicalVolume(solidTest, // its solid
defaultMaterial, // its material
"test.logical"); // its name
new G4PVPlacement(0, // no rotation
G4ThreeVector(0,0, halfZ), // put entrance at (0,0,0)
logicTest, // its logical volume
"test.physical", // its name
logicWorld, // its mother volume
false, // no boolean operation
0); // copy number
// ------------------------------------------------------------
// -- volume to tally exiting particles, put next to above one:
// ------------------------------------------------------------
G4double halfZtally = 0.5*mm;
G4VSolid* solidTally = new G4Box("tally.solid", 1*m, 1*m, halfZtally );
G4LogicalVolume* logicTally = new G4LogicalVolume(solidTally, // its solid
worldMaterial, // its material
"tally.logical"); // its name
new G4PVPlacement(0, // no rotation
G4ThreeVector(0,0, 2*halfZ + halfZtally), // put next to test.phys
logicTally, // its logical volume
"tally.physical", // its name
logicWorld, // its mother volume
false, // no boolean operation
0); // copy number
return physiWorld;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void GB07DetectorConstruction::ConstructSDandField()
{
// -- Fetch volume for biasing:
G4LogicalVolume* logicTest = G4LogicalVolumeStore::GetInstance()->GetVolume("test.logical");
// ----------------------------------------------
// -- operator creation and attachment to volume:
// ----------------------------------------------
GB07BOptrLeadingParticle* testMany = new GB07BOptrLeadingParticle();
testMany->AttachTo(logicTest);
G4cout << " Attaching biasing operator " << testMany->GetName()
<< " to logical volume " << logicTest->GetName()
<< G4endl;
// ---------------------------------------------------------------------------------
// -- Attach sensitive detector to print information on particle exiting the shield:
// ---------------------------------------------------------------------------------
// -- create and register sensitive detector code module:
G4SDManager* SDman = G4SDManager::GetSDMpointer();
G4VSensitiveDetector* sd = new GB07SD("Tally");
SDman->AddNewDetector(sd);
// -- Fetch volume for sensitivity and attach sensitive module to it:
G4LogicalVolume* logicSD =
G4LogicalVolumeStore::GetInstance()->GetVolume("tally.logical");
logicSD->SetSensitiveDetector(sd);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -0,0 +1,70 @@
//
// ********************************************************************
// * 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 GB07/src/GB07PrimaryGeneratorAction.cc
/// \brief Implementation of the GB07PrimaryGeneratorAction class
//
#include "GB07PrimaryGeneratorAction.hh"
#include "G4SystemOfUnits.hh"
#include "G4Event.hh"
#include "G4ParticleGun.hh"
#include "G4ParticleTable.hh"
#include "G4ParticleDefinition.hh"
#include "Randomize.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
GB07PrimaryGeneratorAction::GB07PrimaryGeneratorAction()
: G4VUserPrimaryGeneratorAction()
{
G4int n_particle = 1;
fParticleGun = new G4ParticleGun(n_particle);
// default particle kinematic
G4ParticleTable* particleTable = G4ParticleTable::GetParticleTable();
G4String particleName;
G4ParticleDefinition* particle = particleTable->FindParticle(particleName="proton");
fParticleGun->SetParticleDefinition(particle);
fParticleGun->SetParticleMomentumDirection(G4ThreeVector(0.,0.,1.));
fParticleGun->SetParticleEnergy(10.*GeV);
fParticleGun->SetParticlePosition(G4ThreeVector(0.,0.,-50*cm));
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
GB07PrimaryGeneratorAction::~GB07PrimaryGeneratorAction()
{
delete fParticleGun;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void GB07PrimaryGeneratorAction::GeneratePrimaries(G4Event* anEvent)
{
fParticleGun->GeneratePrimaryVertex(anEvent);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -0,0 +1,66 @@
//
// ********************************************************************
// * 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 GB07/src/GB07SD.cc
/// \brief Implementation of the GB07SD class
//
//
#include "GB07SD.hh"
#include "G4Track.hh"
#include "G4Step.hh"
#include "G4SystemOfUnits.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
GB07SD::GB07SD(G4String name)
: G4VSensitiveDetector(name)
{}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4bool GB07SD::ProcessHits(G4Step* step, G4TouchableHistory*)
{
auto track = step->GetTrack();
auto preStepPoint = step->GetPreStepPoint();
G4cout << std::setw(14)
<< track->GetParticleDefinition()->GetParticleName()
<< ", kinetic energy (MeV) = "
<< std::setw(12) << preStepPoint->GetKineticEnergy()/MeV
<< ", position (cm) = "
<< preStepPoint->GetPosition()/cm
<< ",\t weight = "
<< preStepPoint->GetWeight()
<< G4endl;
return true;
}
GB07SD::~GB07SD()
{
}