Import Geant4 6.2.0 source tree

This commit is contained in:
Gabriele Cosmo
2016-06-09 10:56:29 +02:00
parent 1d812b78b1
commit e083ffb441
1415 changed files with 111223 additions and 21207 deletions
@@ -0,0 +1,63 @@
//
// ********************************************************************
// * DISCLAIMER *
// * *
// * The following disclaimer summarizes all the specific disclaimers *
// * of contributors to this software. The specific disclaimers,which *
// * govern, are listed with their locations in: *
// * http://cern.ch/geant4/license *
// * *
// * 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. *
// * *
// * This code implementation is the intellectual property of the *
// * GEANT4 collaboration. *
// * By copying, distributing or modifying the Program (or any work *
// * based on the Program) you indicate your acceptance of this *
// * statement, and all its terms. *
// ********************************************************************
//
// $Id: HadrontherapyCalorHit.cc,v 1.0
// --------------------------------------------------------------
// GEANT 4 - Hadrontherapy example
// --------------------------------------------------------------
// Code developed by:
//
// G.A.P. Cirrone, G. Russo
// Laboratori Nazionali del Sud - INFN, Catania, Italy
//
// --------------------------------------------------------------
#include "HadrontherapyCalorHit.hh"
G4Allocator<HadrontherapyCalorHit> HadrontherapyCalorHitAllocator;
// -------------------------------------------------------------
HadrontherapyCalorHit::HadrontherapyCalorHit()
{
EdepAbs = 0.; TrackLengthAbs = 0.;
}
// --------------------------------------------------------------
HadrontherapyCalorHit::~HadrontherapyCalorHit()
{ }
// ----------------------------------------------------------------
HadrontherapyCalorHit::HadrontherapyCalorHit(const HadrontherapyCalorHit& right):G4VHit()
{
EdepAbs = right.EdepAbs;
}
// -----------------------------------------------------------------
const HadrontherapyCalorHit& HadrontherapyCalorHit::operator=(const HadrontherapyCalorHit& right)
{
EdepAbs = right.EdepAbs;
return *this;
}
// ---------------------------------------------------------------
void HadrontherapyCalorHit::Print()
{ }
@@ -0,0 +1,207 @@
//
// ********************************************************************
// * DISCLAIMER *
// * *
// * The following disclaimer summarizes all the specific disclaimers *
// * of contributors to this software. The specific disclaimers,which *
// * govern, are listed with their locations in: *
// * http://cern.ch/geant4/license *
// * *
// * 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. *
// * *
// * This code implementation is the intellectual property of the *
// * GEANT4 collaboration. *
// * By copying, distributing or modifying the Program (or any work *
// * based on the Program) you indicate your acceptance of this *
// * statement, and all its terms. *
// ********************************************************************
//
// $Id: HadrontherapyCalorimeterSD.cc,v 1.0
// --------------------------------------------------------------
// GEANT 4 - Hadrontherapy example
// --------------------------------------------------------------
// Code developed by:
//
// G.A.P. Cirrone, G. Russo
// Laboratori Nazionali del Sud - INFN, Catania, Italy
//
// --------------------------------------------------------------
#include "HadrontherapyCalorimeterSD.hh"
#include "G4HCofThisEvent.hh"
#include "HadrontherapyEventAction.hh"
#include "HadrontherapyHit.hh"
#include "HadrontherapyDetectorConstruction.hh"
#include "HadrontherapyHit.hh"
#include "G4VPhysicalVolume.hh"
#include "G4Step.hh"
#include "G4Positron.hh"
#include "G4VTouchable.hh"
#include "G4TouchableHistory.hh"
#include "G4SDManager.hh"
#include "HadrontherapyRunAction.hh"
#include "G4ios.hh"
HadrontherapyCalorimeterSD::HadrontherapyCalorimeterSD(G4String name,
HadrontherapyDetectorConstruction* det)
:G4VSensitiveDetector(name),Detector(det),
delta(1.0e-6*mm),evno(0),evnOld(-1),trIDold(-1),NbOfLayer(20000)
{
collectionName.insert("CalCollection");
p_Run = new HadrontherapyRunAction();
}
// -------------------------------------------------------------------
HadrontherapyCalorimeterSD::~HadrontherapyCalorimeterSD()
{
delete p_Run;
}
// -----------------------------------------------------------------
void HadrontherapyCalorimeterSD::Initialize(G4HCofThisEvent*)
{
CalCollection = new HadrontherapyHitsCollection
(SensitiveDetectorName,collectionName[0]);
for (G4int i=0; i < NbOfLayer; i++)
{
energy[i] = 0.0;
}
for (G4int k=0; k < NbOfLayer; k++)
{
sliceID[k] = -1;
}
depthMax = (0.002*NbOfLayer - delta); // 0.2 is the actual dosimeter thickness
}
// ---------------------------------------------------------------------
G4bool HadrontherapyCalorimeterSD::ProcessHits(G4Step* aStep,G4TouchableHistory*)
{
G4int j = aStep -> GetPreStepPoint() -> GetPhysicalVolume() -> GetCopyNo();
G4double edep = aStep->GetTotalEnergyDeposit();
if (edep ==0) return false;
if(sliceID[j]== -1)
{
HadrontherapyHit* newHit = new HadrontherapyHit(j);
newHit->SetEdep(edep);
G4int barbatrucco_ID = CalCollection->insert(newHit);
sliceID[j] = barbatrucco_ID - 1;
}
else
{
(*CalCollection)[sliceID[j]]->AddEdep(edep);
}
if (j < 0 || j >= NbOfLayer)
{
G4cout << " Warning!! HadrontherapyCalorimeterSD cannot add "
<< edep
<< " to the layer Nb " << j << G4endl;
}
else
{
energy[j] = energy[j] + edep;
}
const G4Track* track = aStep->GetTrack();
G4int trIDnow = track->GetTrackID();
G4double tkin = track->GetKineticEnergy();
G4double xend = aStep->GetPostStepPoint()->GetPosition().x();
G4bool stop = false;
G4bool primary = false;
G4bool outAbs = false;
if(track->GetNextVolume()->GetName() == "TreatmentRoom"
&& (xend <= delta || xend >= depthMax-delta) ) outAbs = true;
if(tkin == 0.0) stop = true;
// Here checks if the particle is primary
if(aStep->GetTrack()->GetParentID() == 0)
{
primary = true;
}
// new particle
if(trIDnow != trIDold || evno != evnOld)
{
trIDold = trIDnow;
evnOld = evno;
part_is_out = true;
tkinold = aStep->GetPreStepPoint()->GetKineticEnergy();
}
// Primary particle stop
if(primary && (stop || outAbs)) {
}
if(outAbs && part_is_out) {
G4double e = tkin;
if(track->GetDefinition() == G4Positron::Positron())
e += 2.*electron_mass_c2;
if(xend > depthMax-delta) leakEnergy += e;
else if(xend < delta) backEnergy += e;
part_is_out = false;
}
return true;
}
// ----------------------------------------------------------------------
void HadrontherapyCalorimeterSD::EndOfEvent(G4HCofThisEvent* HCE)
{
G4int i;
G4double etot = 0.0;
if (NbOfLayer > 0)
{
G4double s = 0.002; //Actual thickness in mm of the dosimeter
G4double z = -0.5 * s;
for (i = 0; i < NbOfLayer; i ++)
{
z += s;
etot += energy[i];
}
}
//*******************************
// Total energy of a particle
// that reach the dosemeter
//*******************************
static G4int HCID = -1;
if(HCID<0)
{
HCID = GetCollectionID(0);
}
HCE->AddHitsCollection(HCID, CalCollection);
}
// -------------------------------------------------------------------------
void HadrontherapyCalorimeterSD::clear()
{}
void HadrontherapyCalorimeterSD::PrintAll()
{}
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,76 @@
//
// ********************************************************************
// * DISCLAIMER *
// * *
// * The following disclaimer summarizes all the specific disclaimers *
// * of contributors to this software. The specific disclaimers,which *
// * govern, are listed with their locations in: *
// * http://cern.ch/geant4/license *
// * *
// * 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. *
// * *
// * This code implementation is the intellectual property of the *
// * GEANT4 collaboration. *
// * By copying, distributing or modifying the Program (or any work *
// * based on the Program) you indicate your acceptance of this *
// * statement, and all its terms. *
// ********************************************************************
//
// $Id: HadrontherapyDetectorMessenger.cc,v 1.0
// --------------------------------------------------------------
// GEANT 4 - Hadrontherapy example
// --------------------------------------------------------------
// Code developed by:
//
// G.A.P. Cirrone, G. Russo, Francesco Di Rosa
// Laboratori Nazionali del Sud - INFN, Catania, Italy
//
// --------------------------------------------------------------
#include "HadrontherapyDetectorMessenger.hh"
#include "HadrontherapyDetectorConstruction.hh"
#include "G4UIdirectory.hh"
#include "G4UIcmdWithAString.hh"
#include "G4UIcmdWithAnInteger.hh"
#include "G4UIcmdWithADoubleAndUnit.hh"
#include "G4UIcmdWithoutParameter.hh"
// -----------------------------------------------------------------------------
HadrontherapyDetectorMessenger::HadrontherapyDetectorMessenger(
HadrontherapyDetectorConstruction* HadrontherapyDet)
:HadrontherapyDetector(HadrontherapyDet)
{
HadronDir = new G4UIdirectory("/modulator/");
HadronDir->SetGuidance("Command to rotate the modulator wheel");
detDir = new G4UIdirectory("/modulator/angle/");
detDir->SetGuidance("Modulator angle control");
ModulatorAngleCmd = new G4UIcmdWithADoubleAndUnit("/modulator/angle/modAngle",this);
ModulatorAngleCmd->SetGuidance("Set Modulator Angle");
ModulatorAngleCmd->SetParameterName("Size",false);
ModulatorAngleCmd->SetRange("Size>=0.");
ModulatorAngleCmd->SetUnitCategory("Angle");
ModulatorAngleCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
}
// -------------------------------------------------------------------------------
HadrontherapyDetectorMessenger::~HadrontherapyDetectorMessenger()
{
delete ModulatorAngleCmd;
delete detDir;
delete HadronDir;
}
// --------------------------------------------------------------------------------
void HadrontherapyDetectorMessenger::SetNewValue(G4UIcommand* command,G4String newValue)
{
if( command == ModulatorAngleCmd )
{ HadrontherapyDetector->SetModulatorAngle(ModulatorAngleCmd->GetNewDoubleValue(newValue));}
}
// ------------------------------------------------------------------------------------
@@ -0,0 +1,110 @@
//
// ********************************************************************
// * DISCLAIMER *
// * *
// * The following disclaimer summarizes all the specific disclaimers *
// * of contributors to this software. The specific disclaimers,which *
// * govern, are listed with their locations in: *
// * http://cern.ch/geant4/license *
// * *
// * 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. *
// * *
// * This code implementation is the intellectual property of the *
// * GEANT4 collaboration. *
// * By copying, distributing or modifying the Program (or any work *
// * based on the Program) you indicate your acceptance of this *
// * statement, and all its terms. *
// ********************************************************************
//
// $Id: HadrontherapyEventAction.cc,v 1.0
// --------------------------------------------------------------
// GEANT 4 - Hadrontherapy example
// --------------------------------------------------------------
// Code developed by:
//
// G.A.P. Cirrone, G. Russo
// Laboratori Nazionali del Sud - INFN, Catania, Italy
//
// --------------------------------------------------------------
#include "HadrontherapyEventAction.hh"
#include "HadrontherapyRunAction.hh"
#include "HadrontherapyHit.hh"
#include "G4Event.hh"
#include "G4EventManager.hh"
#include "G4HCofThisEvent.hh"
#include "G4VHitsCollection.hh"
#include "G4SDManager.hh"
#include "G4UImanager.hh"
#include "G4TrajectoryContainer.hh"
#include "G4Trajectory.hh"
#include "G4VVisManager.hh"
#include "G4ios.hh"
#include "G4UnitsTable.hh"
#include "HadrontherapyCalorimeterSD.hh"
// -------------------------------------------------------------------
HadrontherapyEventAction::HadrontherapyEventAction(HadrontherapyRunAction* runAction)
:calorimeterCollID(-1), eventMessenger(NULL), verboselevel(0)
{
p_Run = runAction;
}
// --------------------------------------------------------------------
HadrontherapyEventAction::~HadrontherapyEventAction()
{
}
// --------------------------------------------------------------------
void HadrontherapyEventAction::BeginOfEventAction(const G4Event* evt)
{
event_id = evt->GetEventID();
if (calorimeterCollID==-1)
{
G4SDManager * SDman = G4SDManager::GetSDMpointer();
calorimeterCollID = SDman->GetCollectionID("CalCollection");
}
nstep = 0. ;
for (G4int slice = 0; slice < 20000; slice ++) //slice dependence
{
energyDep[slice]=0;
}
}
// ---------------------------------------------------------------------
void HadrontherapyEventAction::EndOfEventAction(const G4Event* evt)
{
if (calorimeterCollID < 0) return;
G4HCofThisEvent* HCE = evt->GetHCofThisEvent();
HadrontherapyHitsCollection* CHC = NULL;
if(HCE)
CHC = (HadrontherapyHitsCollection*)(HCE->GetHC(calorimeterCollID));
if(CHC)
{
G4int HitCount = CHC->entries();
for (G4int h=0; h < HitCount; h++)
{
G4int j=((*CHC)[h])->GetSliceID();
energyDep[j]+=((*CHC)[h]->GetEdep());
p_Run->EnergyTotSlice(j,energyDep[j]);
}
}
}
G4int HadrontherapyEventAction::Trasporto()
{
G4int var = event_id;
return var;
}
+83
View File
@@ -0,0 +1,83 @@
//
// ********************************************************************
// * DISCLAIMER *
// * *
// * The following disclaimer summarizes all the specific disclaimers *
// * of contributors to this software. The specific disclaimers,which *
// * govern, are listed with their locations in: *
// * http://cern.ch/geant4/license *
// * *
// * 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. *
// * *
// * This code implementation is the intellectual property of the *
// * GEANT4 collaboration. *
// * By copying, distributing or modifying the Program (or any work *
// * based on the Program) you indicate your acceptance of this *
// * statement, and all its terms. *
// ********************************************************************
//
// $Id: HadrontherapyHit.cc,v 1.0
// --------------------------------------------------------------
// GEANT 4 - Hadrontherapy example
// --------------------------------------------------------------
// Code developed by:
//
// G.A.P. Cirrone, G. Russo
// Laboratori Nazionali del Sud - INFN, Catania, Italy
//
// --------------------------------------------------------------
#include "HadrontherapyHit.hh"
#include "G4ios.hh"
#include "G4VVisManager.hh"
#include "G4Colour.hh"
#include "G4VisAttributes.hh"
#include "G4LogicalVolume.hh"
G4Allocator<HadrontherapyHit> HadrontherapyHitAllocator;
// -----------------------------------------------------------------
HadrontherapyHit::HadrontherapyHit(G4int j)
:slice(j)
{
m_Edep = 0;
}
// ----------------------------------------------------------------
HadrontherapyHit::~HadrontherapyHit()
{
}
// ----------------------------------------------------------------
HadrontherapyHit::HadrontherapyHit(const HadrontherapyHit &right):G4VHit()
{
slice = right.slice;
m_Edep = right.m_Edep;
}
// -----------------------------------------------------------------
const HadrontherapyHit& HadrontherapyHit::operator=(const HadrontherapyHit &right)
{
m_Edep = right.m_Edep;
slice = right.slice;
return *this;
}
// -----------------------------------------------------------------
int HadrontherapyHit::operator==(const HadrontherapyHit &right) const
{
return (slice==right.slice);
}
// ----------------------------------------------------------------
void HadrontherapyHit::Draw()
{
}
// ----------------------------------------------------------------
void HadrontherapyHit::Print()
{
}
@@ -0,0 +1,475 @@
//
// ********************************************************************
// * DISCLAIMER *
// * *
// * The following disclaimer summarizes all the specific disclaimers *
// * of contributors to this software. The specific disclaimers,which *
// * govern, are listed with their locations in: *
// * http://cern.ch/geant4/license *
// * *
// * 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. *
// * *
// * This code implementation is the intellectual property of the *
// * GEANT4 collaboration. *
// * By copying, distributing or modifying the Program (or any work *
// * based on the Program) you indicate your acceptance of this *
// * statement, and all its terms. *
// ********************************************************************
//
// $Id: HadrontherapyPhysicsList.cc,v 1.0
// --------------------------------------------------------------
// GEANT 4 - Hadrontherapy example
// --------------------------------------------------------------
// Code developed by:
//
// G.A.P. Cirrone, G. Russo
// Laboratori Nazionali del Sud - INFN, Catania, Italy
//
// --------------------------------------------------------------
#include "globals.hh"
#include "HadrontherapyPhysicsList.hh"
#include "HadrontherapyDetectorConstruction.hh"
#include "G4ParticleDefinition.hh"
#include "G4ParticleWithCuts.hh"
#include "G4ProcessManager.hh"
#include "G4ProcessVector.hh"
#include "G4ParticleTypes.hh"
#include "G4ParticleTable.hh"
#include "G4Material.hh"
#include "G4VeLowEnergyLoss.hh"
#include "G4EnergyLossTables.hh"
#include "G4ios.hh"
#include <iomanip.h>
// ---------------------------------------------------------------------
HadrontherapyPhysicsList::HadrontherapyPhysicsList(HadrontherapyDetectorConstruction* p)
:G4VUserPhysicsList()
{
pDet = p;
currentDefaultCut = defaultCutValue = 10 *mm;
cutForGamma = defaultCutValue;
cutForElectron = defaultCutValue;
cutForProton = defaultCutValue;
SetVerboseLevel(1);
}
// ----------------------------------------------------------------------
HadrontherapyPhysicsList::~HadrontherapyPhysicsList()
{
}
// -----------------------------------------------------------------------
void HadrontherapyPhysicsList::ConstructParticle()
{
// In this method, static member functions should be called
// for all particles which you want to use.
// This ensures that objects of these particle types will be
// created in the program.
ConstructBosons();
ConstructLeptons();
ConstructMesons();
ConstructBarions();
ConstructIons();
}
// -----------------------------------------------------------------------
void HadrontherapyPhysicsList::ConstructBosons()
{
// *******
// gamma
// *******
G4Gamma::GammaDefinition();
// ****************
// optical photons
// ****************
G4OpticalPhoton::OpticalPhotonDefinition();
}
// ------------------------------------------------------------------------
void HadrontherapyPhysicsList::ConstructLeptons()
{
// *******
// leptons
// *******
G4Electron::ElectronDefinition();
G4Positron::PositronDefinition();
G4MuonPlus::MuonPlusDefinition();
G4MuonMinus::MuonMinusDefinition();
G4NeutrinoE::NeutrinoEDefinition();
G4AntiNeutrinoE::AntiNeutrinoEDefinition();
G4NeutrinoMu::NeutrinoMuDefinition();
G4AntiNeutrinoMu::AntiNeutrinoMuDefinition();
}
// ------------------------------------------------------------------------
void HadrontherapyPhysicsList::ConstructMesons()
{
// ********
// mesons
// ********
G4PionPlus::PionPlusDefinition();
G4PionMinus::PionMinusDefinition();
G4PionZero::PionZeroDefinition();
G4KaonPlus::KaonPlusDefinition();
G4KaonMinus::KaonMinusDefinition();
}
// ------------------------------------------------------------------------
void HadrontherapyPhysicsList::ConstructBarions()
{
// **********
// barions
// **********
G4Proton::ProtonDefinition();
G4AntiProton::AntiProtonDefinition();
G4Neutron::NeutronDefinition();
G4AntiNeutron::AntiNeutronDefinition();
}
// -----------------------------------------------------------------------
void HadrontherapyPhysicsList::ConstructIons()
{
// ******
// ions
// ******
G4Deuteron::DeuteronDefinition();
G4Triton::TritonDefinition();
G4He3::He3Definition();
G4Alpha::AlphaDefinition();
G4GenericIon::GenericIonDefinition();
}
// -----------------------------------------------------------------------
void HadrontherapyPhysicsList::ConstructProcess()
{
AddTransportation();
ConstructEM();
ConstructHad();
ConstructGeneral();
}
// -----------------------------------------------------------------------
// Electromagnetic processes valid for all charged particles
// -----------------------------------------------------------------------
#include "G4MultipleScattering.hh"
// >>> gamma <<
#include "G4LowEnergyRayleigh.hh"
#include "G4LowEnergyPhotoElectric.hh"
#include "G4LowEnergyCompton.hh"
#include "G4LowEnergyGammaConversion.hh"
// >>> e- <<<
#include "G4LowEnergyIonisation.hh"
#include "G4LowEnergyBremsstrahlung.hh"
// >>> e+ <<<
#include "G4eplusAnnihilation.hh"
#include "G4eIonisation.hh"
#include "G4eBremsstrahlung.hh"
// >>> Alpha and generic Ions, deuteron, triton, He3 <<<
#include "G4hLowEnergyIonisation.hh"
// hLowEnergyIonisation uses Ziegler 1988 as the default
#include "G4EnergyLossTables.hh"
// >>> muon <<<<
#include "G4MuIonisation.hh"
#include "G4MuBremsstrahlung.hh"
#include "G4MuPairProduction.hh"
#include "G4MuonMinusCaptureAtRest.hh"
// >>> Standard process for gamma <<<
#include "G4ComptonScattering.hh"
#include "G4GammaConversion.hh"
#include "G4PhotoElectricEffect.hh"
// >>> Standard processes for hadro ionisation <<<
#include "G4hIonisation.hh"
// ------------------------------------------------------------------------------
void HadrontherapyPhysicsList::ConstructEM()
{
G4int LowEnergy = 1;
// to active the Low Energy processes make LowEnergy =1;
// ***********
// processes
// ***********
G4MultipleScattering* aMultipleScattering = new G4MultipleScattering();
G4LowEnergyPhotoElectric* lowePhot = new G4LowEnergyPhotoElectric();
G4LowEnergyIonisation* loweIon = new G4LowEnergyIonisation();
G4LowEnergyBremsstrahlung* loweBrem = new G4LowEnergyBremsstrahlung();
G4hLowEnergyIonisation* ahadronLowEIon = new G4hLowEnergyIonisation();
if (LowEnergy == 1)
{
ahadronLowEIon -> SetNuclearStoppingPowerModel("ICRU_R49") ; // ICRU49 models for nuclear SP
ahadronLowEIon -> SetNuclearStoppingOn() ;
// setting tables explicitly for electronic stopping power
ahadronLowEIon -> SetElectronicStoppingPowerModel(G4GenericIon::GenericIonDefinition(),
"ICRU_R49p") ; // ICRU49 models for elettronic SP
ahadronLowEIon -> SetElectronicStoppingPowerModel(G4Proton::ProtonDefinition(),
"ICRU_R49p") ;
// Switch off the Barkas and Bloch corrections
ahadronLowEIon -> SetBarkasOff();
}
theParticleIterator -> reset();
while( (*theParticleIterator)() )
{
G4ParticleDefinition* particle = theParticleIterator->value();
G4ProcessManager* pmanager = particle->GetProcessManager();
G4String particleName = particle->GetParticleName();
G4String particleType = particle->GetParticleType();
G4double charge = particle->GetPDGCharge();
if (particleName == "gamma")
{
// >>> gamma <<<
if (LowEnergy == 1) {
// Low Energy processes
pmanager->AddDiscreteProcess(new G4LowEnergyRayleigh());
pmanager->AddDiscreteProcess(lowePhot);
pmanager->AddDiscreteProcess(new G4LowEnergyCompton());
pmanager->AddDiscreteProcess(new G4LowEnergyGammaConversion());
}
else {
// Standard processes
pmanager->AddDiscreteProcess(new G4PhotoElectricEffect);
pmanager->AddDiscreteProcess(new G4ComptonScattering);
pmanager->AddDiscreteProcess(new G4GammaConversion);
}
}
else if (particleName == "e-")
{
// >>> electron <<<
if (LowEnergy == 1) {
// Low energy process
pmanager->AddProcess(aMultipleScattering, -1, 1, 1);
pmanager->AddProcess(loweIon, -1, 2, 2);
pmanager->AddProcess(loweBrem, -1,-1, 3);
}
else {
// Standard processes
pmanager->AddProcess(aMultipleScattering, -1, 1, 1);
pmanager->AddProcess(new G4eIonisation, -1, 2,2);
pmanager->AddProcess(new G4eBremsstrahlung, -1,-1,3);
}
}
else if (particleName == "e+")
{
// >>> positron <<<
// Standard processes
pmanager->AddProcess(aMultipleScattering, -1, 1,1);
pmanager->AddProcess(new G4eIonisation, -1, 2,2);
pmanager->AddProcess(new G4eBremsstrahlung, -1,-1,3);
pmanager->AddProcess(new G4eplusAnnihilation, 0,-1,4);
}
else if( particleName == "mu+" ||
particleName == "mu-" )
{
// >>> muon <<<
pmanager->AddProcess(aMultipleScattering, -1, 1,1);
pmanager->AddProcess(new G4MuIonisation, -1, 2,2);
pmanager->AddProcess(new G4MuBremsstrahlung, -1,-1,3);
pmanager->AddProcess(new G4MuPairProduction, -1,-1,4);
}
else if (
particleName == "proton"
|| particleName == "antiproton"
|| particleName == "pi+"
|| particleName == "pi-"
|| particleName == "kaon+"
|| particleName == "kaon-"
)
{
if (LowEnergy == 1) {
pmanager->AddProcess(aMultipleScattering, -1,1,1);
pmanager->AddProcess(ahadronLowEIon, -1,2,2);
}
else {
pmanager->AddProcess(aMultipleScattering, -1,1,1);
pmanager->AddProcess(new G4hIonisation, -1,2,2);
}
}
else if ((!particle->IsShortLived()) &&
(charge != 0.0) )
{
//all others charged particles except geantino
if (LowEnergy == 1) {
pmanager->AddProcess(aMultipleScattering,-1,1,1);
pmanager->AddProcess(ahadronLowEIon, -1,2,2);
}
else {
pmanager->AddProcess(aMultipleScattering,-1,1,1);
pmanager->AddProcess(new G4hIonisation(),-1, 2,2);
}
}
}
}
// ----------------------------------------------------------------------
#include "G4Decay.hh"
void HadrontherapyPhysicsList::ConstructGeneral()
{
G4Decay* theDecayProcess = new G4Decay();
theParticleIterator->reset();
while( (*theParticleIterator)() ){
G4ParticleDefinition* particle = theParticleIterator->value();
G4ProcessManager* pmanager = particle->GetProcessManager();
//add decay process
if (theDecayProcess->IsApplicable(*particle)) {
pmanager ->AddProcess(theDecayProcess);
// set ordering for PostStepDoIt and AtRestDoIt
pmanager ->SetProcessOrdering(theDecayProcess, idxPostStep);
pmanager ->SetProcessOrdering(theDecayProcess, idxAtRest);
}
}
}
// ----------------------------------------------------------------------
#include "G4ProtonInelasticProcess.hh"
#include "G4HadronElasticProcess.hh"
#include "G4LElastic.hh"
#include "G4LEProtonInelastic.hh"
#include "G4HEProtonInelastic.hh"
void HadrontherapyPhysicsList:: ConstructHad()
{
G4int Hadronic = 1;
// to activate the hadronic processes make Hadronic =1
if(Hadronic == 1)
{
G4HadronElasticProcess* theElasticProcess = new G4HadronElasticProcess;
G4LElastic* theElasticModel = new G4LElastic;
theElasticProcess->RegisterMe(theElasticModel);
theParticleIterator->reset();
while ((*theParticleIterator)())
{
G4ParticleDefinition* particle = theParticleIterator->value();
G4ProcessManager* pmanager = particle->GetProcessManager();
G4String particleName = particle->GetParticleName();
if (particleName == "proton")
{
pmanager->AddDiscreteProcess(theElasticProcess);
G4ProtonInelasticProcess* theInelasticProcess = new G4ProtonInelasticProcess("inelastic");
G4LEProtonInelastic* theLEInelasticModel = new G4LEProtonInelastic;
theInelasticProcess->RegisterMe(theLEInelasticModel);
G4HEProtonInelastic* theHEInelasticModel = new G4HEProtonInelastic;
theInelasticProcess->RegisterMe(theHEInelasticModel);
pmanager->AddDiscreteProcess(theInelasticProcess);
}
}
}
}
#include "G4Region.hh"
#include "G4RegionStore.hh"
void HadrontherapyPhysicsList::SetCuts()
{
// reactualise cutValues
if (currentDefaultCut != defaultCutValue)
{
if(cutForGamma == currentDefaultCut) cutForGamma = defaultCutValue;
if(cutForElectron == currentDefaultCut) cutForElectron = defaultCutValue;
if(cutForProton == currentDefaultCut) cutForProton = defaultCutValue;
currentDefaultCut = defaultCutValue;
}
// set cut values for gamma at first and for e- second and next for e+,
// because some processes for e+/e- need cut values for gamma
SetCutValue(cutForGamma,"gamma");
SetCutValue(cutForElectron,"e-");
SetCutValue(cutForElectron,"e+");
// Cut per region
// in region dosemeter we need a very accurate precision
G4Region* region;
G4String regName;
G4ProductionCuts* cuts;
regName = "Dosemeter";
region = G4RegionStore::GetInstance()->GetRegion(regName);
cuts = new G4ProductionCuts;
cuts->SetProductionCut(0.02*mm,G4ProductionCuts::GetIndex("gamma"));
cuts->SetProductionCut(0.02*mm,G4ProductionCuts::GetIndex("e-"));
cuts->SetProductionCut(0.02*mm,G4ProductionCuts::GetIndex("e+"));
region->SetProductionCuts(cuts);
// SetCutValueForOthers(defaultCutValue);
if (verboseLevel >0){
G4cout << "HadrontherapyPhysicsList::SetCuts:";
G4cout << "CutLength : " << G4BestUnit(defaultCutValue,"Length") << G4endl;
}
if (verboseLevel>0) DumpCutValuesTable();
}
// ---------------------------------------------------------------------------
void HadrontherapyPhysicsList::SetGammaCut(G4double val)
{
ResetCuts();
cutForGamma = val;
}
// ---------------------------------------------------------------------------
void HadrontherapyPhysicsList::SetElectronCut(G4double val)
{
ResetCuts();
cutForElectron = val;
}
// ---------------------------------------------------------------------------
void HadrontherapyPhysicsList::SetProtonCut(G4double val)
{
ResetCuts();
cutForProton = val;
}
// ---------------------------------------------------------------------------
void HadrontherapyPhysicsList::GetRange(G4double val)
{
G4ParticleTable* theParticleTable = G4ParticleTable::GetParticleTable();
G4Material* currMat = pDet->GetDosemeterMaterial();
G4ParticleDefinition* part;
G4double cut;
part = theParticleTable->FindParticle("e-");
cut = G4EnergyLossTables::GetRange(part,val,currMat);
G4cout << "material : " << currMat->GetName() << G4endl;
G4cout << "particle : " << part->GetParticleName() << G4endl;
G4cout << "energy : " << G4BestUnit(val,"Energy") << G4endl;
G4cout << "range : " << G4BestUnit(cut,"Length") << G4endl;
}
@@ -0,0 +1,138 @@
//
// ********************************************************************
// * DISCLAIMER *
// * *
// * The following disclaimer summarizes all the specific disclaimers *
// * of contributors to this software. The specific disclaimers,which *
// * govern, are listed with their locations in: *
// * http://cern.ch/geant4/license *
// * *
// * 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. *
// * *
// * This code implementation is the intellectual property of the *
// * GEANT4 collaboration. *
// * By copying, distributing or modifying the Program (or any work *
// * based on the Program) you indicate your acceptance of this *
// * statement, and all its terms. *
// ********************************************************************
//
// $Id: HadrontherapyPrimaryGeneratorAction.cc,v 1.0
//
// --------------------------------------------------------------
// GEANT 4 - Hadrontherapy example
// --------------------------------------------------------------
// Code developed by:
//
// G.A.P. Cirrone, G. Russo
// Laboratori Nazionali del Sud - INFN, Catania, Italy
// --------------------------------------------------------------
#include "HadrontherapyPrimaryGeneratorAction.hh"
#include "HadrontherapyDetectorConstruction.hh"
//#include "HadrontherapyPrimaryGeneratorMessenger.hh"
#include "G4Event.hh"
#include "G4ParticleGun.hh"
#include "G4ParticleTable.hh"
#include "G4ParticleDefinition.hh"
#include "Randomize.hh"
// -------------------------------------------------------------------------
HadrontherapyPrimaryGeneratorAction::HadrontherapyPrimaryGeneratorAction(
HadrontherapyDetectorConstruction* HadrontherapyDC)
:HadrontherapyDetector(HadrontherapyDC)
{
particleGun = new G4ParticleGun();
SetDefaultKinematic();
//create a messenger for this class
//gunMessenger = new HadrontherapyPrimaryGeneratorMessenger(this);
}
// -------------------------------------------------------------------------
HadrontherapyPrimaryGeneratorAction::~HadrontherapyPrimaryGeneratorAction()
{
delete particleGun;
//delete gunMessenger;
}
// ------------------------------------------------------------------------
void HadrontherapyPrimaryGeneratorAction::SetDefaultKinematic()
{
// ****************************
// default particle kinematic
// ****************************
G4ParticleTable* particleTable = G4ParticleTable::GetParticleTable();
G4ParticleDefinition* particle = particleTable->FindParticle("proton");
particleGun -> SetParticleDefinition(particle);
particleGun -> SetParticleMomentumDirection(G4ThreeVector(1.,0.,0.));
particleGun -> SetParticleEnergy(63.4 *MeV);
particleGun -> SetParticlePosition(G4ThreeVector( -200.0 *cm, 0.0 *cm,0.0 *cm ));
}
// -------------------------------------------------------------------------
void HadrontherapyPrimaryGeneratorAction::GeneratePrimaries(G4Event* anEvent)
{
// ****************************************
// Set the beam angular apread
// and spot size
// beam spot size
// ****************************************
G4double X0 = -2000 *mm;
G4double Y0 = 0.0 *cm;
G4double Z0 = 0.0 *cm;
G4double sigmaY = 1.0 *mm ;
G4double sigmaZ = 1.0 *mm ;
G4double x = X0;
G4double y = Y0;
G4double z = Z0;
if ( sigmaY > 0.0 )
{
y += G4RandGauss::shoot( 0., sigmaY );
}
if ( sigmaZ > 0.0 )
{
z += G4RandGauss::shoot( Z0, sigmaZ );
}
particleGun -> SetParticlePosition(G4ThreeVector( x , y , z ) );
// ********************************************
// Set the beam energy and energy spread
// ********************************************
G4double meanKineticEnergy = 63.4 *MeV;
G4double sigmaK = 300.0 *keV;
G4double kineticEnergy = G4RandGauss::shoot ( meanKineticEnergy, sigmaK );
particleGun -> SetParticleEnergy ( kineticEnergy );
particleGun -> GeneratePrimaryVertex( anEvent );
G4double momentumY = 0.0;
G4double momentumZ = 0.0;
G4double sigmaMomentumY = 0.0001;
G4double sigmaMomentumZ = 0.0001;
if ( sigmaMomentumY > 0.0 )
{
momentumY += G4RandGauss::shoot( 0., sigmaMomentumY );
}
if ( sigmaMomentumZ > 0.0 )
{
momentumZ += G4RandGauss::shoot( 0., sigmaMomentumZ );
}
particleGun -> SetParticleMomentumDirection(G4ThreeVector(1.,momentumY,momentumZ));
}
@@ -0,0 +1,99 @@
//
// ********************************************************************
// * DISCLAIMER *
// * *
// * The following disclaimer summarizes all the specific disclaimers *
// * of contributors to this software. The specific disclaimers,which *
// * govern, are listed with their locations in: *
// * http://cern.ch/geant4/license *
// * *
// * 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. *
// * *
// * This code implementation is the intellectual property of the *
// * GEANT4 collaboration. *
// * By copying, distributing or modifying the Program (or any work *
// * based on the Program) you indicate your acceptance of this *
// * statement, and all its terms. *
// ********************************************************************
//
// $Id: HadrontherapyRunAction.cc,v 1.0
// --------------------------------------------------------------
// GEANT 4 - Hadrontherapy example
// --------------------------------------------------------------
// Code developed by:
//
// G.A.P. Cirrone, G. Russo
// Laboratori Nazionali del Sud - INFN, Catania, Italy
//
// --------------------------------------------------------------
#include "HadrontherapyRunAction.hh"
#include "G4Run.hh"
#include "G4RunManager.hh"
#include "G4UImanager.hh"
#include "G4VVisManager.hh"
#include "G4ios.hh"
#include <iomanip.h>
#include "Randomize.hh"
// ---------------------------------------------------------------
HadrontherapyRunAction::HadrontherapyRunAction()
:NbOfLayer(20000)
{
}
// ---------------------------------------------------------------
HadrontherapyRunAction::~HadrontherapyRunAction()
{
}
// ---------------------------------------------------------------
void HadrontherapyRunAction::BeginOfRunAction(const G4Run* aRun)
{
for (G4int i=0; i < 50000; i++)
{
energy[i] = 0.0;
};
G4cout << "### Run " << aRun->GetRunID() << " start." << G4endl;
// save Rndm status
G4RunManager::GetRunManager() -> SetRandomNumberStore(true);
HepRandom::showEngineStatus();
}
// ---------------------------------------------------------------------
void HadrontherapyRunAction::EndOfRunAction(const G4Run*)
{
// WRITE ASCII FILE FOR THE REGISTRATION OF THE BRAGG PEAK
// The a two column file (piccoXX.dat) is registered. The first column represents
// the ionization chamber position (in mm of water); the second
// is the energy deposited for each position of the chamber
for (G4int i = 0; i < 20000; i++) {
G4double depth = 0;
depth = i*0.002; //the number represents the thickness of the ionization chamber (in mm ofwater)
std::ofstream pmtfile("BraggPeak.out", std::ios::app);
if(pmtfile.is_open())
{
pmtfile << depth << '\t' << energy[i] << '\t' << G4endl;
}
}
// show Rndm status
HepRandom::showEngineStatus();
}
// -----------------------------------------------------------------------------
void HadrontherapyRunAction::EnergyTotSlice(G4int slice, G4double energy_dep)
{
energy[ slice ] = energy [ slice ] + energy_dep;
}
@@ -0,0 +1,111 @@
//
// ********************************************************************
// * DISCLAIMER *
// * *
// * The following disclaimer summarizes all the specific disclaimers *
// * of contributors to this software. The specific disclaimers,which *
// * govern, are listed with their locations in: *
// * http://cern.ch/geant4/license *
// * *
// * 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. *
// * *
// * This code implementation is the intellectual property of the *
// * GEANT4 collaboration. *
// * By copying, distributing or modifying the Program (or any work *
// * based on the Program) you indicate your acceptance of this *
// * statement, and all its terms. *
// ********************************************************************
//
// $Id: HadrontherapySteppingAction.cc,v 1.0
// --------------------------------------------------------------
// GEANT 4 - Hadrontherapy example
// --------------------------------------------------------------
// Code developed by:
//
// G.A.P. Cirrone, G. Russo
// Laboratori Nazionali del Sud - INFN, Catania, Italy
//
// --------------------------------------------------------------
#include "HadrontherapyDetectorConstruction.hh"
#include "G4EnergyLossTables.hh"
#include "G4SteppingManager.hh"
#include "G4TrackVector.hh"
#include "HadrontherapySteppingAction.hh"
#include "HadrontherapyPrimaryGeneratorAction.hh"
#include "HadrontherapyEventAction.hh"
#include "HadrontherapyRunAction.hh"
#include "G4Event.hh"
#include "G4EventManager.hh"
#include "G4ios.hh"
#include <iomanip.h>
#include "G4UImanager.hh"
// -----------------------------------------------------------------
HadrontherapySteppingAction::HadrontherapySteppingAction(HadrontherapyEventAction* EA)
{
eventaction = EA;
}
// ----------------------------------------------------------------
HadrontherapySteppingAction::~HadrontherapySteppingAction()
{
}
// -----------------------------------------------------------------
void HadrontherapySteppingAction::UserSteppingAction(const G4Step* aStep)
{
event_id = eventaction -> Trasporto();
//the function Trasporto takes the event's number from EventAction Class
G4double x = aStep -> GetPostStepPoint() -> GetPosition().x();
G4double y = aStep -> GetPostStepPoint() -> GetPosition().y();
G4double z = aStep -> GetPostStepPoint() -> GetPosition().z();
G4Track * theTrack = aStep -> GetTrack();
G4double TrackID = theTrack -> GetTrackID();
G4double KEnergy = theTrack -> GetKineticEnergy();
G4double thicknessPlane = 1 *mm;
G4double xPlane = 1048.59 *mm;
//------------------------------------------------------------
// The PLANE that simulate radiochromic film
// Particles that interact within this "software plane" are registered;
if (event_id == 0) {Controllo = 0;}
if (x >= xPlane & x <= (xPlane+thicknessPlane) & Controllo != event_id & TrackID == 1)
{
Controllo = event_id;
// ----------------------------------------------------------
// WRITE ASCII FILES
// Properties of the particles interacting with the plane
// are registered in two different files. Exactly
// Number of event and kinetic energy are registered in the disEnXX.dat file;
// Coordinates of the particles are registered in the disAngXX.dat file;
std::ofstream pmtfile("energyDistribution.out", std::ios::app);
if(pmtfile.is_open())
{
pmtfile << KEnergy << '\t' << " " << event_id << '\t' << G4endl;
}
std::ofstream pmtfile2("angularDistribution.out", std::ios::app);
if(pmtfile2.is_open())
{
pmtfile2 << x/mm << '\t' <<" " << y/mm << '\t' <<" " << z/mm << '\t' << G4endl;
}
}
}
@@ -0,0 +1,144 @@
//
// ********************************************************************
// * DISCLAIMER *
// * *
// * The following disclaimer summarizes all the specific disclaimers *
// * of contributors to this software. The specific disclaimers,which *
// * govern, are listed with their locations in: *
// * http://cern.ch/geant4/license *
// * *
// * 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. *
// * *
// * This code implementation is the intellectual property of the *
// * GEANT4 collaboration. *
// * By copying, distributing or modifying the Program (or any work *
// * based on the Program) you indicate your acceptance of this *
// * statement, and all its terms. *
// ********************************************************************
//
//
// $Id: HadrontherapyVisManager.cc
//
//
// John Allison 24th January 1998.
#ifdef G4VIS_USE
#include "HadrontherapyVisManager.hh"
// Supported drivers...
// Not needing external packages or libraries...
#include "G4ASCIITree.hh"
#include "G4DAWNFILE.hh"
#include "G4GAGTree.hh"
#include "G4HepRepFile.hh"
#include "G4HepRep.hh"
#include "G4RayTracer.hh"
#include "G4VRML1File.hh"
#include "G4VRML2File.hh"
// Needing external packages or libraries...
#ifdef G4VIS_USE_DAWN
#include "G4FukuiRenderer.hh"
#endif
#ifdef G4VIS_USE_OPACS
#include "G4Wo.hh"
#include "G4Xo.hh"
#endif
#ifdef G4VIS_USE_OPENGLX
#include "G4OpenGLImmediateX.hh"
#include "G4OpenGLStoredX.hh"
#endif
#ifdef G4VIS_USE_OPENGLWIN32
#include "G4OpenGLImmediateWin32.hh"
#include "G4OpenGLStoredWin32.hh"
#endif
#ifdef G4VIS_USE_OPENGLXM
#include "G4OpenGLImmediateXm.hh"
#include "G4OpenGLStoredXm.hh"
#endif
#ifdef G4VIS_USE_OIX
#include "G4OpenInventorX.hh"
#endif
#ifdef G4VIS_USE_OIWIN32
#include "G4OpenInventorWin32.hh"
#endif
#ifdef G4VIS_USE_VRML
#include "G4VRML1.hh"
#include "G4VRML2.hh"
#endif
HadrontherapyVisManager::HadrontherapyVisManager () {}
void HadrontherapyVisManager::RegisterGraphicsSystems () {
// Graphics Systems not needing external packages or libraries...
RegisterGraphicsSystem (new G4ASCIITree);
RegisterGraphicsSystem (new G4DAWNFILE);
RegisterGraphicsSystem (new G4GAGTree);
RegisterGraphicsSystem (new G4HepRepFile);
RegisterGraphicsSystem (new G4HepRep);
RegisterGraphicsSystem (new G4RayTracer);
RegisterGraphicsSystem (new G4VRML1File);
RegisterGraphicsSystem (new G4VRML2File);
// Graphics systems needing external packages or libraries...
#ifdef G4VIS_USE_DAWN
RegisterGraphicsSystem (new G4FukuiRenderer);
#endif
#ifdef G4VIS_USE_OPACS
RegisterGraphicsSystem (new G4Wo);
RegisterGraphicsSystem (new G4Xo);
#endif
#ifdef G4VIS_USE_OPENGLX
RegisterGraphicsSystem (new G4OpenGLImmediateX);
RegisterGraphicsSystem (new G4OpenGLStoredX);
#endif
#ifdef G4VIS_USE_OPENGLWIN32
RegisterGraphicsSystem (new G4OpenGLImmediateWin32);
RegisterGraphicsSystem (new G4OpenGLStoredWin32);
#endif
#ifdef G4VIS_USE_OPENGLXM
RegisterGraphicsSystem (new G4OpenGLImmediateXm);
RegisterGraphicsSystem (new G4OpenGLStoredXm);
#endif
#ifdef G4VIS_USE_OIX
RegisterGraphicsSystem (new G4OpenInventorX);
#endif
#ifdef G4VIS_USE_OIWIN32
RegisterGraphicsSystem (new G4OpenInventorWin32);
#endif
#ifdef G4VIS_USE_VRML
RegisterGraphicsSystem (new G4VRML1);
RegisterGraphicsSystem (new G4VRML2);
#endif
if (fVerbose > 0) {
G4cout <<
"\nYou have successfully chosen to use the following graphics systems."
<< G4endl;
PrintAvailableGraphicsSystems ();
}
}
#endif