Import Geant4 11.3.0.beta source tree

This commit is contained in:
Gabriele Cosmo
2024-06-28 13:08:51 +02:00
parent f7b23877ed
commit e58e650b32
5232 changed files with 239416 additions and 244360 deletions
@@ -27,23 +27,20 @@
#include "ActionInitialization.hh"
#include "RunAction.hh"
#include "EventAction.hh"
#include "TrackingAction.hh"
#include "SteppingAction.hh"
#include "PrimaryGeneratorAction.hh"
#include "RunAction.hh"
#include "SteppingAction.hh"
#include "TrackingAction.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
ActionInitialization::ActionInitialization(DetectorConstruction* det)
: fDetector(det)
{}
ActionInitialization::ActionInitialization(DetectorConstruction* det) : fDetector(det) {}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void ActionInitialization::Build() const
{
PrimaryGeneratorAction* kin = new PrimaryGeneratorAction(fDetector);
SetUserAction(kin);
@@ -57,8 +54,7 @@ void ActionInitialization::Build() const
void ActionInitialization::BuildForMaster() const
{
SetUserAction(
new RunAction(fDetector, new PrimaryGeneratorAction(fDetector)));
SetUserAction(new RunAction(fDetector, new PrimaryGeneratorAction(fDetector)));
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -30,26 +30,22 @@
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
#include "DetectorConstruction.hh"
#include "DetectorMessenger.hh"
#include "G4Tubs.hh"
#include "G4LogicalVolume.hh"
#include "G4PVPlacement.hh"
#include "G4GeometryManager.hh"
#include "G4PhysicalVolumeStore.hh"
#include "G4LogicalVolumeStore.hh"
#include "G4SolidStore.hh"
#include "G4GlobalMagFieldMessenger.hh"
#include "G4NistManager.hh"
#include "G4RunManager.hh"
#include "G4SystemOfUnits.hh"
#include "G4UnitsTable.hh"
#include "G4AutoDelete.hh"
#include "G4GeometryManager.hh"
#include "G4GlobalMagFieldMessenger.hh"
#include "G4LogicalVolume.hh"
#include "G4LogicalVolumeStore.hh"
#include "G4NistManager.hh"
#include "G4PVPlacement.hh"
#include "G4PhysicalVolumeStore.hh"
#include "G4RunManager.hh"
#include "G4SolidStore.hh"
#include "G4SystemOfUnits.hh"
#include "G4Tubs.hh"
#include "G4UnitsTable.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -63,7 +59,7 @@ DetectorConstruction::DetectorConstruction()
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
DetectorConstruction::~DetectorConstruction()
{
{
delete fDetectorMessenger;
}
@@ -75,11 +71,11 @@ void DetectorConstruction::DefineMaterials()
// define few Elements by hand
//
G4double a, z;
G4Element* H = new G4Element("Hydrogen", "H", z= 1., a= 1.01*g/mole);
G4Element* O = new G4Element("Oxygen" , "O", z= 8., a= 16.00*g/mole);
G4Element* Ge = new G4Element("Germanium", "Ge",z=32., a= 72.59*g/mole);
G4Element* Bi = new G4Element("Bismuth", "Bi",z=83., a= 208.98*g/mole);
G4Element* H = new G4Element("Hydrogen", "H", z = 1., a = 1.01 * g / mole);
G4Element* O = new G4Element("Oxygen", "O", z = 8., a = 16.00 * g / mole);
G4Element* Ge = new G4Element("Germanium", "Ge", z = 32., a = 72.59 * g / mole);
G4Element* Bi = new G4Element("Bismuth", "Bi", z = 83., a = 208.98 * g / mole);
//
// define materials
@@ -88,27 +84,25 @@ void DetectorConstruction::DefineMaterials()
G4int ncomponents, natoms;
// water with ionisation potential 78 eV
G4Material* H2O =
new G4Material("Water", density= 1.00*g/cm3, ncomponents=2);
H2O->AddElement(H, natoms=2);
H2O->AddElement(O, natoms=1);
H2O->GetIonisation()->SetMeanExcitationEnergy(78.0*eV);
G4Material* H2O = new G4Material("Water", density = 1.00 * g / cm3, ncomponents = 2);
H2O->AddElement(H, natoms = 2);
H2O->AddElement(O, natoms = 1);
H2O->GetIonisation()->SetMeanExcitationEnergy(78.0 * eV);
// pure materails
new G4Material("liquidArgon", z=18., a= 39.95*g/mole, density= 1.390*g/cm3);
new G4Material("Aluminium", z=13., a= 26.98*g/mole, density= 2.7*g/cm3);
new G4Material("Iron", z=26., a= 55.85*g/mole, density= 7.87*g/cm3);
new G4Material("Copper", z=29., a= 63.55*g/mole, density= 8.960*g/cm3);
new G4Material("Tungsten", z=74., a=183.84*g/mole, density=19.35*g/cm3);
new G4Material("Lead", z=82., a=207.19*g/mole, density=11.35*g/cm3);
new G4Material("Uranium" , z=92., a=238.03*g/mole, density= 18.95*g/cm3);
new G4Material("liquidArgon", z = 18., a = 39.95 * g / mole, density = 1.390 * g / cm3);
new G4Material("Aluminium", z = 13., a = 26.98 * g / mole, density = 2.7 * g / cm3);
new G4Material("Iron", z = 26., a = 55.85 * g / mole, density = 7.87 * g / cm3);
new G4Material("Copper", z = 29., a = 63.55 * g / mole, density = 8.960 * g / cm3);
new G4Material("Tungsten", z = 74., a = 183.84 * g / mole, density = 19.35 * g / cm3);
new G4Material("Lead", z = 82., a = 207.19 * g / mole, density = 11.35 * g / cm3);
new G4Material("Uranium", z = 92., a = 238.03 * g / mole, density = 18.95 * g / cm3);
// compound material
G4Material* BGO =
new G4Material("BGO", density= 7.10*g/cm3, ncomponents=3);
BGO->AddElement(O , natoms=12);
BGO->AddElement(Ge, natoms= 3);
BGO->AddElement(Bi, natoms= 4);
G4Material* BGO = new G4Material("BGO", density = 7.10 * g / cm3, ncomponents = 3);
BGO->AddElement(O, natoms = 12);
BGO->AddElement(Ge, natoms = 3);
BGO->AddElement(Bi, natoms = 4);
////G4cout << *(G4Material::GetMaterialTable()) << G4endl;
}
@@ -118,11 +112,13 @@ void DetectorConstruction::DefineMaterials()
void DetectorConstruction::UpdateParameters()
{
G4double Radl = fMaterial->GetRadlen();
fDLlength = fDLradl*Radl; fDRlength = fDRradl*Radl;
fEcalLength = fNLtot*fDLlength; fEcalRadius = fNRtot*fDRlength;
if(fSolidEcal) {
fDLlength = fDLradl * Radl;
fDRlength = fDRradl * Radl;
fEcalLength = fNLtot * fDLlength;
fEcalRadius = fNRtot * fDRlength;
if (fSolidEcal) {
fSolidEcal->SetOuterRadius(fEcalRadius);
fSolidEcal->SetZHalfLength(0.5*fEcalLength);
fSolidEcal->SetZHalfLength(0.5 * fEcalLength);
}
}
@@ -134,18 +130,17 @@ G4VPhysicalVolume* DetectorConstruction::Construct()
//
// Ecal
//
if(!fPhysiEcal) {
fSolidEcal = new G4Tubs("Ecal",0.,fEcalRadius,0.5*fEcalLength,0.,360*deg);
fLogicEcal = new G4LogicalVolume( fSolidEcal,fMaterial,"Ecal",0,0,0);
fPhysiEcal = new G4PVPlacement(0,G4ThreeVector(),
fLogicEcal,"Ecal",0,false,0);
if (!fPhysiEcal) {
fSolidEcal = new G4Tubs("Ecal", 0., fEcalRadius, 0.5 * fEcalLength, 0., 360 * deg);
fLogicEcal = new G4LogicalVolume(fSolidEcal, fMaterial, "Ecal", 0, 0, 0);
fPhysiEcal = new G4PVPlacement(0, G4ThreeVector(), fLogicEcal, "Ecal", 0, false, 0);
}
G4cout << "\n Absorber is " << G4BestUnit(fEcalLength,"Length")
<< " of " << fMaterial->GetName()
<< " R= " << fEcalRadius/cm << " cm \n" << G4endl;
G4cout << fMaterial << G4endl;
G4cout << "\n Absorber is " << G4BestUnit(fEcalLength, "Length") << " of " << fMaterial->GetName()
<< " R= " << fEcalRadius / cm << " cm \n"
<< G4endl;
G4cout << fMaterial << G4endl;
//
//always return the physical World
// always return the physical World
//
return fPhysiEcal;
}
@@ -155,12 +150,13 @@ G4VPhysicalVolume* DetectorConstruction::Construct()
void DetectorConstruction::SetMaterial(const G4String& materialChoice)
{
// search the material by its name
G4Material* pttoMaterial =
G4NistManager::Instance()->FindOrBuildMaterial(materialChoice);
G4Material* pttoMaterial = G4NistManager::Instance()->FindOrBuildMaterial(materialChoice);
if(pttoMaterial && fMaterial != pttoMaterial) {
if (pttoMaterial && fMaterial != pttoMaterial) {
fMaterial = pttoMaterial;
if(fLogicEcal) { fLogicEcal->SetMaterial(fMaterial); }
if (fLogicEcal) {
fLogicEcal->SetMaterial(fMaterial);
}
G4RunManager::GetRunManager()->PhysicsHasBeenModified();
}
}
@@ -171,10 +167,10 @@ void DetectorConstruction::SetLBining(G4ThreeVector Value)
{
fNLtot = (G4int)Value(0);
if (fNLtot > kMaxBin) {
G4cout << "\n ---> warning from SetLBining: "
<< fNLtot << " truncated to " << kMaxBin << G4endl;
G4cout << "\n ---> warning from SetLBining: " << fNLtot << " truncated to " << kMaxBin
<< G4endl;
fNLtot = kMaxBin;
}
}
fDLradl = Value(1);
UpdateParameters();
}
@@ -185,10 +181,10 @@ void DetectorConstruction::SetRBining(G4ThreeVector Value)
{
fNRtot = (G4int)Value(0);
if (fNRtot > kMaxBin) {
G4cout << "\n ---> warning from SetRBining: "
<< fNRtot << " truncated to " << kMaxBin << G4endl;
G4cout << "\n ---> warning from SetRBining: " << fNRtot << " truncated to " << kMaxBin
<< G4endl;
fNRtot = kMaxBin;
}
}
fDRradl = Value(1);
UpdateParameters();
}
@@ -197,16 +193,15 @@ void DetectorConstruction::SetRBining(G4ThreeVector Value)
void DetectorConstruction::ConstructSDandField()
{
if ( fFieldMessenger.Get() == nullptr ) {
if (fFieldMessenger.Get() == nullptr) {
// Create global magnetic field messenger.
// Uniform magnetic field is then created automatically if
// the field value is not zero.
G4ThreeVector fieldValue = G4ThreeVector();
G4GlobalMagFieldMessenger* msg =
new G4GlobalMagFieldMessenger(fieldValue);
//msg->SetVerboseLevel(1);
G4GlobalMagFieldMessenger* msg = new G4GlobalMagFieldMessenger(fieldValue);
// msg->SetVerboseLevel(1);
G4AutoDelete::Register(msg);
fFieldMessenger.Put( msg );
fFieldMessenger.Put(msg);
}
}
@@ -33,43 +33,43 @@
#include "DetectorMessenger.hh"
#include "DetectorConstruction.hh"
#include "G4UIdirectory.hh"
#include "G4UIcmdWithAString.hh"
#include "G4UIcmdWith3Vector.hh"
#include "G4UIcmdWithADoubleAndUnit.hh"
#include "G4UIcmdWithAString.hh"
#include "G4UIcmdWithoutParameter.hh"
#include "G4UIdirectory.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
DetectorMessenger::DetectorMessenger(DetectorConstruction * Det)
:fDetector(Det)
DetectorMessenger::DetectorMessenger(DetectorConstruction* Det) : fDetector(Det)
{
fTestemDir = new G4UIdirectory("/testem/");
fTestemDir->SetGuidance(" detector control.");
fDetDir = new G4UIdirectory("/testem/det/");
fDetDir->SetGuidance("detector construction commands");
fMaterCmd = new G4UIcmdWithAString("/testem/det/setMat",this);
fMaterCmd = new G4UIcmdWithAString("/testem/det/setMat", this);
fMaterCmd->SetGuidance("Select Material.");
fMaterCmd->SetParameterName("material",false);
fMaterCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
fMaterCmd->SetParameterName("material", false);
fMaterCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
fMaterCmd->SetToBeBroadcasted(false);
fLBinCmd = new G4UIcmdWith3Vector("/testem/det/setLbin",this);
fLBinCmd = new G4UIcmdWith3Vector("/testem/det/setLbin", this);
fLBinCmd->SetGuidance("set longitudinal bining");
fLBinCmd->SetGuidance("nb of bins; bin thickness (in radl)");
fLBinCmd->SetParameterName("nLtot","dLradl"," ",true);
fLBinCmd->SetParameterName("nLtot", "dLradl", " ", true);
fLBinCmd->SetRange("nLtot>=1 && dLradl>0");
fLBinCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
fLBinCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
fLBinCmd->SetToBeBroadcasted(false);
fRBinCmd = new G4UIcmdWith3Vector("/testem/det/setRbin",this);
fRBinCmd = new G4UIcmdWith3Vector("/testem/det/setRbin", this);
fRBinCmd->SetGuidance("set radial bining");
fRBinCmd->SetGuidance("nb of bins; bin thickness (in radl)");
fRBinCmd->SetParameterName("nRtot","dRradl"," ",true);
fRBinCmd->SetParameterName("nRtot", "dRradl", " ", true);
fRBinCmd->SetRange("nRtot>=1 && dRradl>0");
fRBinCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
fRBinCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
fRBinCmd->SetToBeBroadcasted(false);
}
@@ -87,16 +87,18 @@ DetectorMessenger::~DetectorMessenger()
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void DetectorMessenger::SetNewValue(G4UIcommand* command, G4String newValue)
{
if( command == fMaterCmd )
{ fDetector->SetMaterial(newValue);}
if( command == fLBinCmd )
{ fDetector->SetLBining(fLBinCmd->GetNew3VectorValue(newValue));}
{
if (command == fMaterCmd) {
fDetector->SetMaterial(newValue);
}
if( command == fRBinCmd )
{ fDetector->SetRBining(fRBinCmd->GetNew3VectorValue(newValue));}
if (command == fLBinCmd) {
fDetector->SetLBining(fLBinCmd->GetNew3VectorValue(newValue));
}
if (command == fRBinCmd) {
fDetector->SetRBining(fRBinCmd->GetNew3VectorValue(newValue));
}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -46,24 +46,22 @@ void EmAcceptance::BeginOfAcceptance(const G4String& title, G4int stat)
void EmAcceptance::EndOfAcceptance()
{
G4String resume = "IS ACCEPTED";
if(!fIsAccepted) resume = "IS NOT ACCEPTED";
if (!fIsAccepted) resume = "IS NOT ACCEPTED";
G4cout << "<<<<END>>>> " << resume << G4endl;
G4cout << G4endl;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void EmAcceptance::EmAcceptanceGauss(const G4String& title, G4int stat,
G4double avr, G4double avr0,
void EmAcceptance::EmAcceptanceGauss(const G4String& title, G4int stat, G4double avr, G4double avr0,
G4double rms, G4double limit)
{
G4double x = std::sqrt((G4double)stat);
G4double dde = avr - avr0;
G4double de = dde*x/rms;
if(std::fabs(de) > limit) fIsAccepted = false;
G4cout << title << ": " << avr << " del" << title << "= " << dde
<< " nrms= " << de << G4endl;
G4double de = dde * x / rms;
if (std::fabs(de) > limit) fIsAccepted = false;
G4cout << title << ": " << avr << " del" << title << "= " << dde << " nrms= " << de << G4endl;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -33,6 +33,7 @@
#include "EventAction.hh"
#include "Run.hh"
#include "G4Event.hh"
#include "G4RunManager.hh"
#include "G4UnitsTable.hh"
@@ -41,20 +42,17 @@
void EventAction::BeginOfEventAction(const G4Event*)
{
//additional initializations
Run* run
= static_cast<Run*>(G4RunManager::GetRunManager()->GetNonConstCurrentRun());
run->InitializePerEvent();
// additional initializations
Run* run = static_cast<Run*>(G4RunManager::GetRunManager()->GetNonConstCurrentRun());
run->InitializePerEvent();
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void EventAction::EndOfEventAction(const G4Event*)
{
Run* run
= static_cast<Run*>(G4RunManager::GetRunManager()->GetNonConstCurrentRun());
run->FillPerEvent();
{
Run* run = static_cast<Run*>(G4RunManager::GetRunManager()->GetNonConstCurrentRun());
run->FillPerEvent();
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -28,62 +28,54 @@
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
#include "PhysListEmStandard.hh"
#include "G4ParticleDefinition.hh"
#include "G4ProcessManager.hh"
#include "G4PhysicsListHelper.hh"
#include "G4ComptonScattering.hh"
#include "G4GammaConversion.hh"
#include "G4PhotoElectricEffect.hh"
#include "G4RayleighScattering.hh"
#include "G4KleinNishinaModel.hh"
#include "G4LivermorePhotoElectricModel.hh"
#include "G4eMultipleScattering.hh"
#include "G4eIonisation.hh"
#include "G4eBremsstrahlung.hh"
#include "G4eplusAnnihilation.hh"
#include "G4MuMultipleScattering.hh"
#include "G4MuIonisation.hh"
#include "G4MuBremsstrahlung.hh"
#include "G4MuPairProduction.hh"
#include "G4hMultipleScattering.hh"
#include "G4hIonisation.hh"
#include "G4hBremsstrahlung.hh"
#include "G4hPairProduction.hh"
#include "G4ionIonisation.hh"
#include "G4IonParametrisedLossModel.hh"
#include "G4NuclearStopping.hh"
#include "G4MscStepLimitType.hh"
#include "G4LossTableManager.hh"
#include "G4UAtomicDeexcitation.hh"
#include "G4BuilderType.hh"
#include "G4ComptonScattering.hh"
#include "G4GammaConversion.hh"
#include "G4IonParametrisedLossModel.hh"
#include "G4KleinNishinaModel.hh"
#include "G4LivermorePhotoElectricModel.hh"
#include "G4LossTableManager.hh"
#include "G4MscStepLimitType.hh"
#include "G4MuBremsstrahlung.hh"
#include "G4MuIonisation.hh"
#include "G4MuMultipleScattering.hh"
#include "G4MuPairProduction.hh"
#include "G4NuclearStopping.hh"
#include "G4ParticleDefinition.hh"
#include "G4PhotoElectricEffect.hh"
#include "G4PhysicsListHelper.hh"
#include "G4ProcessManager.hh"
#include "G4RayleighScattering.hh"
#include "G4SystemOfUnits.hh"
#include "G4UAtomicDeexcitation.hh"
#include "G4eBremsstrahlung.hh"
#include "G4eIonisation.hh"
#include "G4eMultipleScattering.hh"
#include "G4eplusAnnihilation.hh"
#include "G4hBremsstrahlung.hh"
#include "G4hIonisation.hh"
#include "G4hMultipleScattering.hh"
#include "G4hPairProduction.hh"
#include "G4ionIonisation.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
PhysListEmStandard::PhysListEmStandard(const G4String& name)
: G4VPhysicsConstructor(name)
PhysListEmStandard::PhysListEmStandard(const G4String& name) : G4VPhysicsConstructor(name)
{
G4EmParameters* param = G4EmParameters::Instance();
param->SetDefaults();
param->SetVerbose(0);
param->SetMinEnergy(10*eV);
param->SetMaxEnergy(10*TeV);
param->SetNumberOfBinsPerDecade(10);
param->SetStepFunction(0.1, 100*um);
param->SetStepFunctionMuHad(0.1, 50*um);
param->SetStepFunctionLightIons(0.1, 20*um);
param->SetStepFunctionIons(0.1, 1*um);
param->SetMscStepLimitType(fUseDistanceToBoundary);
param->SetDeexcitationIgnoreCut(true);
SetPhysicsType(bElectromagnetic);
G4EmParameters* param = G4EmParameters::Instance();
param->SetDefaults();
param->SetVerbose(0);
param->SetMinEnergy(10 * eV);
param->SetMaxEnergy(10 * TeV);
param->SetNumberOfBinsPerDecade(10);
param->SetStepFunction(0.1, 100 * um);
param->SetStepFunctionMuHad(0.1, 50 * um);
param->SetStepFunctionLightIons(0.1, 20 * um);
param->SetStepFunctionIons(0.1, 1 * um);
param->SetMscStepLimitType(fUseDistanceToBoundary);
param->SetDeexcitationIgnoreCut(true);
SetPhysicsType(bElectromagnetic);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -91,74 +83,62 @@ PhysListEmStandard::PhysListEmStandard(const G4String& name)
void PhysListEmStandard::ConstructProcess()
{
G4PhysicsListHelper* ph = G4PhysicsListHelper::GetPhysicsListHelper();
// Add standard EM Processes
//
auto particleIterator=GetParticleIterator();
auto particleIterator = GetParticleIterator();
particleIterator->reset();
while( (*particleIterator)() ){
while ((*particleIterator)()) {
G4ParticleDefinition* particle = particleIterator->value();
G4String particleName = particle->GetParticleName();
if (particleName == "gamma") {
ph->RegisterProcess(new G4RayleighScattering, particle);
if (particleName == "gamma") {
ph->RegisterProcess(new G4RayleighScattering, particle);
ph->RegisterProcess(new G4PhotoElectricEffect, particle);
G4ComptonScattering* cs = new G4ComptonScattering;
G4ComptonScattering* cs = new G4ComptonScattering;
cs->SetEmModel(new G4KleinNishinaModel());
ph->RegisterProcess(cs, particle);
ph->RegisterProcess(new G4GammaConversion, particle);
} else if (particleName == "e-") {
ph->RegisterProcess(new G4eMultipleScattering(), particle);
ph->RegisterProcess(new G4eIonisation(), particle);
ph->RegisterProcess(new G4eBremsstrahlung(), particle);
} else if (particleName == "e+") {
ph->RegisterProcess(new G4eMultipleScattering(), particle);
}
else if (particleName == "e-") {
ph->RegisterProcess(new G4eMultipleScattering(), particle);
ph->RegisterProcess(new G4eIonisation(), particle);
ph->RegisterProcess(new G4eBremsstrahlung(), particle);
ph->RegisterProcess(new G4eplusAnnihilation(), particle);
} else if (particleName == "mu+" ||
particleName == "mu-" ) {
ph->RegisterProcess(new G4MuMultipleScattering(), particle);
}
else if (particleName == "e+") {
ph->RegisterProcess(new G4eMultipleScattering(), particle);
ph->RegisterProcess(new G4eIonisation(), particle);
ph->RegisterProcess(new G4eBremsstrahlung(), particle);
ph->RegisterProcess(new G4eplusAnnihilation(), particle);
}
else if (particleName == "mu+" || particleName == "mu-") {
ph->RegisterProcess(new G4MuMultipleScattering(), particle);
ph->RegisterProcess(new G4MuIonisation(), particle);
ph->RegisterProcess(new G4MuBremsstrahlung(), particle);
ph->RegisterProcess(new G4MuPairProduction(), particle);
} else if( particleName == "proton" ||
particleName == "pi-" ||
particleName == "pi+" ) {
ph->RegisterProcess(new G4hMultipleScattering(), particle);
}
else if (particleName == "proton" || particleName == "pi-" || particleName == "pi+") {
ph->RegisterProcess(new G4hMultipleScattering(), particle);
ph->RegisterProcess(new G4hIonisation(), particle);
ph->RegisterProcess(new G4hBremsstrahlung(), particle);
ph->RegisterProcess(new G4hPairProduction(), particle);
} else if( particleName == "alpha" ||
particleName == "He3" ) {
ph->RegisterProcess(new G4hMultipleScattering(), particle);
ph->RegisterProcess(new G4hPairProduction(), particle);
}
else if (particleName == "alpha" || particleName == "He3") {
ph->RegisterProcess(new G4hMultipleScattering(), particle);
ph->RegisterProcess(new G4ionIonisation(), particle);
ph->RegisterProcess(new G4NuclearStopping(), particle);
} else if( particleName == "GenericIon" ) {
ph->RegisterProcess(new G4hMultipleScattering(), particle);
ph->RegisterProcess(new G4NuclearStopping(), particle);
}
else if (particleName == "GenericIon") {
ph->RegisterProcess(new G4hMultipleScattering(), particle);
G4ionIonisation* ionIoni = new G4ionIonisation();
ionIoni->SetEmModel(new G4IonParametrisedLossModel());
ph->RegisterProcess(ionIoni, particle);
ph->RegisterProcess(new G4NuclearStopping(), particle);
} else if ((!particle->IsShortLived()) &&
(particle->GetPDGCharge() != 0.0) &&
(particle->GetParticleName() != "chargedgeantino")) {
//all others charged particles except geantino
ph->RegisterProcess(new G4NuclearStopping(), particle);
}
else if ((!particle->IsShortLived()) && (particle->GetPDGCharge() != 0.0)
&& (particle->GetParticleName() != "chargedgeantino"))
{
// all others charged particles except geantino
ph->RegisterProcess(new G4hMultipleScattering(), particle);
ph->RegisterProcess(new G4hIonisation(), particle);
}
@@ -171,4 +151,3 @@ void PhysListEmStandard::ConstructProcess()
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -31,65 +31,58 @@
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
#include "PhysicsList.hh"
#include "PhysicsListMessenger.hh"
#include "PhysListEmStandard.hh"
#include "PhysicsListMessenger.hh"
#include "StepMax.hh"
#include "G4EmStandardPhysics.hh"
#include "G4EmStandardPhysics_option1.hh"
#include "G4EmStandardPhysics_option2.hh"
#include "G4EmStandardPhysics_option3.hh"
#include "G4EmStandardPhysics_option4.hh"
#include "G4EmStandardPhysicsWVI.hh"
#include "G4EmStandardPhysicsGS.hh"
#include "G4EmStandardPhysicsSS.hh"
#include "G4EmLivermorePhysics.hh"
#include "G4EmPenelopePhysics.hh"
#include "G4EmLowEPPhysics.hh"
#include "G4DecayPhysics.hh"
#include "G4EmDNAPhysics.hh"
#include "G4EmDNAPhysics_option2.hh"
#include "G4EmDNAPhysics_option4.hh"
#include "G4EmDNAPhysics_option6.hh"
#include "G4EmLivermorePhysics.hh"
#include "G4EmLowEPPhysics.hh"
#include "G4EmPenelopePhysics.hh"
#include "G4EmStandardPhysics.hh"
#include "G4EmStandardPhysicsGS.hh"
#include "G4EmStandardPhysicsSS.hh"
#include "G4EmStandardPhysicsWVI.hh"
#include "G4EmStandardPhysics_option1.hh"
#include "G4EmStandardPhysics_option2.hh"
#include "G4EmStandardPhysics_option3.hh"
#include "G4EmStandardPhysics_option4.hh"
#include "G4HadronElasticPhysics.hh"
#include "G4DecayPhysics.hh"
#include "StepMax.hh"
#include "G4UnitsTable.hh"
#include "G4SystemOfUnits.hh"
#include "G4ParticleDefinition.hh"
#include "G4ProcessManager.hh"
#include "G4SystemOfUnits.hh"
#include "G4UnitsTable.hh"
// particles
#include "G4BaryonConstructor.hh"
#include "G4BosonConstructor.hh"
#include "G4DNAGenericIonsManager.hh"
#include "G4IonConstructor.hh"
#include "G4LeptonConstructor.hh"
#include "G4MesonConstructor.hh"
#include "G4BosonConstructor.hh"
#include "G4BaryonConstructor.hh"
#include "G4IonConstructor.hh"
#include "G4ShortLivedConstructor.hh"
#include "G4DNAGenericIonsManager.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
PhysicsList::PhysicsList()
{
fMessenger = new PhysicsListMessenger(this);
{
fMessenger = new PhysicsListMessenger(this);
SetVerboseLevel(1);
// EM physics
fEmName = G4String("emstandard_opt4");
fEmPhysicsList = new G4EmStandardPhysics_option4();
// Decay physics
// Decay physics
fDecayPhysics = new G4DecayPhysics(1);
SetDefaultCutValue(1*mm);
SetDefaultCutValue(1 * mm);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -97,14 +90,14 @@ PhysicsList::PhysicsList()
PhysicsList::~PhysicsList()
{
delete fEmPhysicsList;
delete fMessenger;
delete fMessenger;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void PhysicsList::ConstructParticle()
{
G4BosonConstructor pBosonConstructor;
G4BosonConstructor pBosonConstructor;
pBosonConstructor.ConstructParticle();
G4LeptonConstructor pLeptonConstructor;
@@ -125,11 +118,11 @@ void PhysicsList::ConstructParticle()
// Geant4-DNA
G4DNAGenericIonsManager* genericIonsManager;
genericIonsManager=G4DNAGenericIonsManager::Instance();
genericIonsManager = G4DNAGenericIonsManager::Instance();
genericIonsManager->GetIon("alpha++");
genericIonsManager->GetIon("alpha+");
genericIonsManager->GetIon("helium");
genericIonsManager->GetIon("hydrogen");
genericIonsManager->GetIon("hydrogen");
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -139,7 +132,9 @@ void PhysicsList::ConstructProcess()
AddTransportation();
fEmPhysicsList->ConstructProcess();
fDecayPhysics->ConstructProcess();
if(fHadPhysicsList) { fHadPhysicsList->ConstructProcess(); }
if (fHadPhysicsList) {
fHadPhysicsList->ConstructProcess();
}
AddStepMax();
}
@@ -150,16 +145,15 @@ void PhysicsList::AddStepMax()
// Step limitation seen as a process
StepMax* stepMaxProcess = new StepMax();
auto particleIterator=GetParticleIterator();
auto particleIterator = GetParticleIterator();
particleIterator->reset();
while ((*particleIterator)()){
while ((*particleIterator)()) {
G4ParticleDefinition* particle = particleIterator->value();
G4ProcessManager* pmanager = particle->GetProcessManager();
if (stepMaxProcess->IsApplicable(*particle))
{
pmanager->AddDiscreteProcess(stepMaxProcess);
}
if (stepMaxProcess->IsApplicable(*particle)) {
pmanager->AddDiscreteProcess(stepMaxProcess);
}
}
}
@@ -167,109 +161,98 @@ void PhysicsList::AddStepMax()
void PhysicsList::AddPhysicsList(const G4String& name)
{
if (verboseLevel>1) {
if (verboseLevel > 1) {
G4cout << "PhysicsList::AddPhysicsList: <" << name << ">" << G4endl;
}
if (name == fEmName) return;
if (name == "local") {
fEmName = name;
delete fEmPhysicsList;
fEmPhysicsList = new PhysListEmStandard(name);
} else if (name == "emstandard_opt0") {
}
else if (name == "emstandard_opt0") {
fEmName = name;
delete fEmPhysicsList;
fEmPhysicsList = new G4EmStandardPhysics();
} else if (name == "emstandard_opt1") {
}
else if (name == "emstandard_opt1") {
fEmName = name;
delete fEmPhysicsList;
fEmPhysicsList = new G4EmStandardPhysics_option1();
} else if (name == "emstandard_opt2") {
}
else if (name == "emstandard_opt2") {
fEmName = name;
delete fEmPhysicsList;
fEmPhysicsList = new G4EmStandardPhysics_option2();
} else if (name == "emstandard_opt3") {
}
else if (name == "emstandard_opt3") {
fEmName = name;
delete fEmPhysicsList;
fEmPhysicsList = new G4EmStandardPhysics_option3();
} else if (name == "emstandard_opt4") {
}
else if (name == "emstandard_opt4") {
fEmName = name;
delete fEmPhysicsList;
fEmPhysicsList = new G4EmStandardPhysics_option4();
} else if (name == "emstandardSS") {
}
else if (name == "emstandardSS") {
fEmName = name;
delete fEmPhysicsList;
fEmPhysicsList = new G4EmStandardPhysicsSS();
} else if (name == "emstandardWVI") {
}
else if (name == "emstandardWVI") {
fEmName = name;
delete fEmPhysicsList;
fEmPhysicsList = new G4EmStandardPhysicsWVI();
} else if (name == "emstandardGS") {
}
else if (name == "emstandardGS") {
fEmName = name;
delete fEmPhysicsList;
fEmPhysicsList = new G4EmStandardPhysicsGS();
} else if (name == "empenelope") {
}
else if (name == "empenelope") {
fEmName = name;
delete fEmPhysicsList;
fEmPhysicsList = new G4EmPenelopePhysics();
} else if (name == "emlowenergy") {
}
else if (name == "emlowenergy") {
fEmName = name;
delete fEmPhysicsList;
fEmPhysicsList = new G4EmLowEPPhysics();
} else if (name == "emlivermore") {
}
else if (name == "emlivermore") {
fEmName = name;
delete fEmPhysicsList;
fEmPhysicsList = new G4EmLivermorePhysics();
} else if (name == "dna") {
}
else if (name == "dna") {
fEmName = name;
delete fEmPhysicsList;
fEmPhysicsList = new G4EmDNAPhysics();
} else if (name == "dna_opt2") {
}
else if (name == "dna_opt2") {
fEmName = name;
delete fEmPhysicsList;
fEmPhysicsList = new G4EmDNAPhysics_option2();
} else if (name == "dna_opt4") {
}
else if (name == "dna_opt4") {
fEmName = name;
delete fEmPhysicsList;
fEmPhysicsList = new G4EmDNAPhysics_option4();
} else if (name == "dna_opt6") {
}
else if (name == "dna_opt6") {
fEmName = name;
delete fEmPhysicsList;
fEmPhysicsList = new G4EmDNAPhysics_option6();
} else if (name == "had_elastic" && !fHadPhysicsList) {
}
else if (name == "had_elastic" && !fHadPhysicsList) {
fHadPhysicsList = new G4HadronElasticPhysics();
} else {
}
else {
G4cout << "PhysicsList::AddPhysicsList: <" << name << ">"
<< " is not defined"
<< G4endl;
<< " is not defined" << G4endl;
}
}
@@ -33,22 +33,22 @@
#include "PhysicsListMessenger.hh"
#include "PhysicsList.hh"
#include "G4UIdirectory.hh"
#include "G4UIcmdWithAString.hh"
#include "G4UIdirectory.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
PhysicsListMessenger::PhysicsListMessenger(PhysicsList* pPhys)
:fPhysicsList(pPhys)
PhysicsListMessenger::PhysicsListMessenger(PhysicsList* pPhys) : fPhysicsList(pPhys)
{
fPhysDir = new G4UIdirectory("/testem/phys/");
fPhysDir->SetGuidance("physics list commands");
fListCmd = new G4UIcmdWithAString("/testem/phys/addPhysics",this);
fListCmd = new G4UIcmdWithAString("/testem/phys/addPhysics", this);
fListCmd->SetGuidance("Add modula physics list.");
fListCmd->SetParameterName("PList",false);
fListCmd->SetParameterName("PList", false);
fListCmd->AvailableForStates(G4State_PreInit);
fListCmd->SetToBeBroadcasted(false);
fListCmd->SetToBeBroadcasted(false);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -62,9 +62,10 @@ PhysicsListMessenger::~PhysicsListMessenger()
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void PhysicsListMessenger::SetNewValue(G4UIcommand* command, G4String newValue)
{
if( command == fListCmd )
{ fPhysicsList->AddPhysicsList(newValue); }
{
if (command == fListCmd) {
fPhysicsList->AddPhysicsList(newValue);
}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -33,25 +33,24 @@
#include "PrimaryGeneratorAction.hh"
#include "DetectorConstruction.hh"
#include "G4Event.hh"
#include "G4ParticleTable.hh"
#include "G4ParticleDefinition.hh"
#include "G4ParticleTable.hh"
#include "G4SystemOfUnits.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
PrimaryGeneratorAction::PrimaryGeneratorAction (DetectorConstruction* det)
:fDetector(det)
PrimaryGeneratorAction::PrimaryGeneratorAction(DetectorConstruction* det) : fDetector(det)
{
G4int n_particle = 1;
fParticleGun = new G4ParticleGun(n_particle);
fParticleGun = new G4ParticleGun(n_particle);
G4ParticleDefinition* particle
= G4ParticleTable::GetParticleTable()->FindParticle("e-");
G4ParticleDefinition* particle = G4ParticleTable::GetParticleTable()->FindParticle("e-");
fParticleGun->SetParticleDefinition(particle);
fParticleGun->SetParticleEnergy(5.*GeV);
fParticleGun->SetParticlePosition(G4ThreeVector(0.,0.,-1*cm));
fParticleGun->SetParticleMomentumDirection(G4ThreeVector(0.,0.,1.));
fParticleGun->SetParticleEnergy(5. * GeV);
fParticleGun->SetParticlePosition(G4ThreeVector(0., 0., -1 * cm));
fParticleGun->SetParticleMomentumDirection(G4ThreeVector(0., 0., 1.));
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -65,12 +64,11 @@ PrimaryGeneratorAction::~PrimaryGeneratorAction()
void PrimaryGeneratorAction::GeneratePrimaries(G4Event* anEvent)
{
//this function is called at the begin of event
// this function is called at the begin of event
//
G4double position = -0.5*(fDetector->GetfullLength());
fParticleGun->SetParticlePosition(G4ThreeVector(0.,0.,position));
G4double position = -0.5 * (fDetector->GetfullLength());
fParticleGun->SetParticlePosition(G4ThreeVector(0., 0., position));
fParticleGun->GeneratePrimaryVertex(anEvent);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -26,24 +26,24 @@
/// \file electromagnetic/TestEm2/src/Run.cc
/// \brief Implementation of the Run class
//
//
//
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
#include "Run.hh"
#include "PrimaryGeneratorAction.hh"
#include "EmAcceptance.hh"
#include "PrimaryGeneratorAction.hh"
#include "G4Run.hh"
#include "G4UnitsTable.hh"
#include "G4SystemOfUnits.hh"
#include "G4UnitsTable.hh"
#include <iomanip>
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
Run::Run(DetectorConstruction* det, PrimaryGeneratorAction* kin)
:fDet(det),fKin(kin)
Run::Run(DetectorConstruction* det, PrimaryGeneratorAction* kin) : fDet(det), fKin(kin)
{
Reset();
}
@@ -51,7 +51,7 @@ Run::Run(DetectorConstruction* det, PrimaryGeneratorAction* kin)
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void Run::Reset()
{
{
f_nLbin = fDet->GetnLtot();
f_dEdL.resize(f_nLbin);
fSumELongit.resize(f_nLbin);
@@ -65,37 +65,38 @@ void Run::Reset()
fSumERadialCumul.resize(f_nRbin);
fSumE2Radial.resize(f_nRbin);
fSumE2RadialCumul.resize(f_nRbin);
fChargedStep = 0.0;
fNeutralStep = 0.0;
fVerbose = 0;
//initialize arrays of cumulative energy deposition
//
for (G4int i=0; i<f_nLbin; ++i) {
fSumELongit[i]=fSumE2Longit[i]=fSumELongitCumul[i]=fSumE2LongitCumul[i]=0.;
}
for (G4int j=0; j<f_nRbin; ++j) {
fSumERadial[j]=fSumE2Radial[j]=fSumERadialCumul[j]=fSumE2RadialCumul[j]=0.;
}
//initialize track length
fSumChargTrLength=fSum2ChargTrLength=fSumNeutrTrLength=fSum2NeutrTrLength=0.;
fChargedStep = 0.0;
fNeutralStep = 0.0;
fVerbose = 0;
// initialize arrays of cumulative energy deposition
//
for (G4int i = 0; i < f_nLbin; ++i) {
fSumELongit[i] = fSumE2Longit[i] = fSumELongitCumul[i] = fSumE2LongitCumul[i] = 0.;
}
for (G4int j = 0; j < f_nRbin; ++j) {
fSumERadial[j] = fSumE2Radial[j] = fSumERadialCumul[j] = fSumE2RadialCumul[j] = 0.;
}
// initialize track length
fSumChargTrLength = fSum2ChargTrLength = fSumNeutrTrLength = fSum2NeutrTrLength = 0.;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void Run::InitializePerEvent()
{
//initialize arrays of energy deposit per bin
for (G4int i=0; i<f_nLbin; ++i)
{ f_dEdL[i] = 0.; }
for (G4int j=0; j<f_nRbin; ++j)
{ f_dEdR[j] = 0.; }
//initialize tracklength
// initialize arrays of energy deposit per bin
for (G4int i = 0; i < f_nLbin; ++i) {
f_dEdL[i] = 0.;
}
for (G4int j = 0; j < f_nRbin; ++j) {
f_dEdR[j] = 0.;
}
// initialize tracklength
fChargTrLength = fNeutrTrLength = 0.;
}
@@ -103,57 +104,55 @@ void Run::InitializePerEvent()
void Run::FillPerEvent()
{
//accumulate statistic
// accumulate statistic
//
G4double dLCumul = 0.;
for (G4int i=0; i<f_nLbin; ++i)
{
fSumELongit[i] += f_dEdL[i];
fSumE2Longit[i] += f_dEdL[i]*f_dEdL[i];
dLCumul += f_dEdL[i];
fSumELongitCumul[i] += dLCumul;
fSumE2LongitCumul[i] += dLCumul*dLCumul;
}
for (G4int i = 0; i < f_nLbin; ++i) {
fSumELongit[i] += f_dEdL[i];
fSumE2Longit[i] += f_dEdL[i] * f_dEdL[i];
dLCumul += f_dEdL[i];
fSumELongitCumul[i] += dLCumul;
fSumE2LongitCumul[i] += dLCumul * dLCumul;
}
G4double dRCumul = 0.;
for (G4int j=0; j<f_nRbin; j++)
{
fSumERadial[j] += f_dEdR[j];
fSumE2Radial[j] += f_dEdR[j]*f_dEdR[j];
dRCumul += f_dEdR[j];
fSumERadialCumul[j] += dRCumul;
fSumE2RadialCumul[j] += dRCumul*dRCumul;
}
for (G4int j = 0; j < f_nRbin; j++) {
fSumERadial[j] += f_dEdR[j];
fSumE2Radial[j] += f_dEdR[j] * f_dEdR[j];
dRCumul += f_dEdR[j];
fSumERadialCumul[j] += dRCumul;
fSumE2RadialCumul[j] += dRCumul * dRCumul;
}
fSumChargTrLength += fChargTrLength;
fSum2ChargTrLength += fChargTrLength*fChargTrLength;
fSumNeutrTrLength += fNeutrTrLength;
fSum2NeutrTrLength += fNeutrTrLength*fNeutrTrLength;
fSumChargTrLength += fChargTrLength;
fSum2ChargTrLength += fChargTrLength * fChargTrLength;
fSumNeutrTrLength += fNeutrTrLength;
fSum2NeutrTrLength += fNeutrTrLength * fNeutrTrLength;
//fill histograms
// fill histograms
//
G4double Ekin=fKin->GetParticleGun()->GetParticleEnergy();
G4double mass=fKin->GetParticleGun()->GetParticleDefinition()->GetPDGMass();
G4double radl=fDet->GetMaterial()->GetRadlen();
G4double Ekin = fKin->GetParticleGun()->GetParticleEnergy();
G4double mass = fKin->GetParticleGun()->GetParticleDefinition()->GetPDGMass();
G4double radl = fDet->GetMaterial()->GetRadlen();
G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
analysisManager->FillH1(1, 100.*dLCumul/(Ekin+mass));
analysisManager->FillH1(2, fChargTrLength/radl);
analysisManager->FillH1(3, fNeutrTrLength/radl);
analysisManager->FillH1(1, 100. * dLCumul / (Ekin + mass));
analysisManager->FillH1(2, fChargTrLength / radl);
analysisManager->FillH1(3, fNeutrTrLength / radl);
//profiles
G4double norm = 100./(Ekin+mass);
G4double dLradl = fDet->GetdLradl();
for (G4int i=0; i<f_nLbin; ++i) {
G4double bin = (i+0.5)*dLradl;
analysisManager->FillP1(0, bin, norm*f_dEdL[i]/dLradl);
// profiles
G4double norm = 100. / (Ekin + mass);
G4double dLradl = fDet->GetdLradl();
for (G4int i = 0; i < f_nLbin; ++i) {
G4double bin = (i + 0.5) * dLradl;
analysisManager->FillP1(0, bin, norm * f_dEdL[i] / dLradl);
}
G4double dRradl = fDet->GetdRradl();
for (G4int j = 0; j < f_nRbin; ++j) {
G4double bin = (j + 0.5) * dRradl;
analysisManager->FillP1(1, bin, norm * f_dEdR[j] / dRradl);
}
G4double dRradl = fDet->GetdRradl();
for (G4int j=0; j<f_nRbin; ++j) {
G4double bin = (j+0.5)*dRradl;
analysisManager->FillP1(1, bin, norm*f_dEdR[j]/dRradl);
}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -163,150 +162,148 @@ void Run::Merge(const G4Run* run)
const Run* localRun = static_cast<const Run*>(run);
fChargedStep += localRun->fChargedStep;
fNeutralStep += localRun->fNeutralStep;
fNeutralStep += localRun->fNeutralStep;
for (G4int i=0; i<f_nLbin; ++i) {
for (G4int i = 0; i < f_nLbin; ++i) {
fSumELongit[i] += localRun->fSumELongit[i];
fSumE2Longit[i] += localRun->fSumE2Longit[i];
fSumELongitCumul[i] += localRun->fSumELongitCumul[i];
fSumE2LongitCumul[i] += localRun->fSumE2LongitCumul[i];
}
for (G4int j=0; j<f_nRbin; ++j) {
for (G4int j = 0; j < f_nRbin; ++j) {
fSumERadial[j] += localRun->fSumERadial[j];
fSumE2Radial[j] += localRun->fSumE2Radial[j];
fSumERadialCumul[j] += localRun->fSumERadialCumul[j];
fSumE2RadialCumul[j] += localRun->fSumE2RadialCumul[j];
}
fSumChargTrLength += localRun->fSumChargTrLength;
fSumChargTrLength += localRun->fSumChargTrLength;
fSum2ChargTrLength += localRun->fSum2ChargTrLength;
fSumNeutrTrLength += localRun->fSumNeutrTrLength;
fSumNeutrTrLength += localRun->fSumNeutrTrLength;
fSum2NeutrTrLength += localRun->fSum2NeutrTrLength;
G4Run::Merge(run);
G4Run::Merge(run);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void Run::EndOfRun(G4double edep, G4double rms, G4double& limit)
void Run::EndOfRun(G4double edep, G4double rms, G4double& limit)
{
G4int NbOfEvents = GetNumberOfEvent();
G4double kinEnergy = fKin->GetParticleGun()->GetParticleEnergy();
assert(NbOfEvents*kinEnergy > 0);
assert(NbOfEvents * kinEnergy > 0);
fChargedStep /= G4double(NbOfEvents);
fNeutralStep /= G4double(NbOfEvents);
fNeutralStep /= G4double(NbOfEvents);
G4double mass=fKin->GetParticleGun()->GetParticleDefinition()->GetPDGMass();
G4double norme = 100./(NbOfEvents*(kinEnergy+mass));
//longitudinal
G4double mass = fKin->GetParticleGun()->GetParticleDefinition()->GetPDGMass();
G4double norme = 100. / (NbOfEvents * (kinEnergy + mass));
// longitudinal
//
G4double dLradl = fDet->GetdLradl();
MyVector MeanELongit(f_nLbin), rmsELongit(f_nLbin);
MyVector MeanELongit(f_nLbin), rmsELongit(f_nLbin);
MyVector MeanELongitCumul(f_nLbin), rmsELongitCumul(f_nLbin);
G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
G4int i;
for (i=0; i<f_nLbin; ++i) {
MeanELongit[i] = norme*fSumELongit[i];
rmsELongit[i] =
norme*std::sqrt(std::abs(NbOfEvents*fSumE2Longit[i]
- fSumELongit[i]*fSumELongit[i]));
MeanELongitCumul[i] = norme*fSumELongitCumul[i];
rmsELongitCumul[i] = norme*std::sqrt(std::abs(NbOfEvents*
fSumE2LongitCumul[i] - fSumELongitCumul[i]*fSumELongitCumul[i]));
G4double bin = (i+0.5)*dLradl;
analysisManager->FillH1(4, bin,MeanELongit[i]/dLradl);
analysisManager->FillH1(5, bin, rmsELongit[i]/dLradl);
bin = (i+1)*dLradl;
analysisManager->FillH1(6, bin,MeanELongitCumul[i]);
for (i = 0; i < f_nLbin; ++i) {
MeanELongit[i] = norme * fSumELongit[i];
rmsELongit[i] =
norme * std::sqrt(std::abs(NbOfEvents * fSumE2Longit[i] - fSumELongit[i] * fSumELongit[i]));
MeanELongitCumul[i] = norme * fSumELongitCumul[i];
rmsELongitCumul[i] = norme
* std::sqrt(std::abs(NbOfEvents * fSumE2LongitCumul[i]
- fSumELongitCumul[i] * fSumELongitCumul[i]));
G4double bin = (i + 0.5) * dLradl;
analysisManager->FillH1(4, bin, MeanELongit[i] / dLradl);
analysisManager->FillH1(5, bin, rmsELongit[i] / dLradl);
bin = (i + 1) * dLradl;
analysisManager->FillH1(6, bin, MeanELongitCumul[i]);
analysisManager->FillH1(7, bin, rmsELongitCumul[i]);
}
//radial
// radial
//
G4double dRradl = fDet->GetdRradl();
MyVector MeanERadial(f_nRbin), rmsERadial(f_nRbin);
MyVector MeanERadial(f_nRbin), rmsERadial(f_nRbin);
MyVector MeanERadialCumul(f_nRbin), rmsERadialCumul(f_nRbin);
for (i=0; i<f_nRbin; ++i) {
MeanERadial[i] = norme*fSumERadial[i];
rmsERadial[i] = norme*std::sqrt(std::abs(NbOfEvents*fSumE2Radial[i]
- fSumERadial[i]*fSumERadial[i]));
MeanERadialCumul[i] = norme*fSumERadialCumul[i];
rmsERadialCumul[i] =
norme*std::sqrt(std::abs(NbOfEvents*fSumE2RadialCumul[i]
- fSumERadialCumul[i]*fSumERadialCumul[i]));
for (i = 0; i < f_nRbin; ++i) {
MeanERadial[i] = norme * fSumERadial[i];
rmsERadial[i] =
norme * std::sqrt(std::abs(NbOfEvents * fSumE2Radial[i] - fSumERadial[i] * fSumERadial[i]));
G4double bin = (i+0.5)*dRradl;
analysisManager->FillH1(8, bin,MeanERadial[i]/dRradl);
analysisManager->FillH1(9, bin, rmsERadial[i]/dRradl);
bin = (i+1)*dRradl;
analysisManager->FillH1(10, bin,MeanERadialCumul[i]);
analysisManager->FillH1(11, bin, rmsERadialCumul[i]);
MeanERadialCumul[i] = norme * fSumERadialCumul[i];
rmsERadialCumul[i] = norme
* std::sqrt(std::abs(NbOfEvents * fSumE2RadialCumul[i]
- fSumERadialCumul[i] * fSumERadialCumul[i]));
G4double bin = (i + 0.5) * dRradl;
analysisManager->FillH1(8, bin, MeanERadial[i] / dRradl);
analysisManager->FillH1(9, bin, rmsERadial[i] / dRradl);
bin = (i + 1) * dRradl;
analysisManager->FillH1(10, bin, MeanERadialCumul[i]);
analysisManager->FillH1(11, bin, rmsERadialCumul[i]);
}
//find Moliere confinement
// find Moliere confinement
//
const G4double EMoliere = 90.;
G4double iMoliere = 0.;
if ((MeanERadialCumul[0] <= EMoliere) &&
(MeanERadialCumul[f_nRbin-1] >= EMoliere)) {
if ((MeanERadialCumul[0] <= EMoliere) && (MeanERadialCumul[f_nRbin - 1] >= EMoliere)) {
G4int imin = 0;
while( (imin < f_nRbin-1) && (MeanERadialCumul[imin] < EMoliere) )
{ ++imin; }
while ((imin < f_nRbin - 1) && (MeanERadialCumul[imin] < EMoliere)) {
++imin;
}
G4double del = MeanERadialCumul[imin+1] - MeanERadialCumul[imin];
G4double ratio =
(del > 0.0) ? (EMoliere - MeanERadialCumul[imin])/del : 0.0;
G4double del = MeanERadialCumul[imin + 1] - MeanERadialCumul[imin];
G4double ratio = (del > 0.0) ? (EMoliere - MeanERadialCumul[imin]) / del : 0.0;
iMoliere = 1. + imin + ratio;
}
//track length
}
// track length
//
norme = 1./(NbOfEvents*(fDet->GetMaterial()->GetRadlen()));
G4double MeanChargTrLength = norme*fSumChargTrLength;
G4double rmsChargTrLength =
norme*std::sqrt(std::abs(NbOfEvents*fSum2ChargTrLength
- fSumChargTrLength*fSumChargTrLength));
norme = 1. / (NbOfEvents * (fDet->GetMaterial()->GetRadlen()));
G4double MeanChargTrLength = norme * fSumChargTrLength;
G4double rmsChargTrLength =
norme
* std::sqrt(std::abs(NbOfEvents * fSum2ChargTrLength - fSumChargTrLength * fSumChargTrLength));
G4double MeanNeutrTrLength = norme*fSumNeutrTrLength;
G4double rmsNeutrTrLength =
norme*std::sqrt(std::abs(NbOfEvents*fSum2NeutrTrLength
- fSumNeutrTrLength*fSumNeutrTrLength));
G4double MeanNeutrTrLength = norme * fSumNeutrTrLength;
G4double rmsNeutrTrLength =
norme
* std::sqrt(std::abs(NbOfEvents * fSum2NeutrTrLength - fSumNeutrTrLength * fSumNeutrTrLength));
//print
// print
std::ios::fmtflags mode = G4cout.flags();
G4cout.setf(std::ios::fixed,std::ios::floatfield);
G4int prec = G4cout.precision(2);
if (fVerbose) {
G4cout.setf(std::ios::fixed, std::ios::floatfield);
G4int prec = G4cout.precision(2);
if (fVerbose) {
G4cout << " LOGITUDINAL PROFILE "
<< " CUMULATIVE LOGITUDINAL PROFILE" << G4endl << G4endl;
G4cout << " bin " << " Mean rms "
<< " bin " << " Mean rms \n" << G4endl;
G4cout << " bin "
<< " Mean rms "
<< " bin "
<< " Mean rms \n"
<< G4endl;
for (i=0; i<f_nLbin; ++i) {
G4double inf=i*dLradl, sup=inf+dLradl;
for (i = 0; i < f_nLbin; ++i) {
G4double inf = i * dLradl, sup = inf + dLradl;
G4cout << std::setw(8) << inf << "->"
<< std::setw(5) << sup << " radl: "
<< std::setw(7) << MeanELongit[i] << "% "
<< std::setw(9) << rmsELongit[i] << "% "
<< " 0->" << std::setw(5) << sup << " radl: "
<< std::setw(7) << MeanELongitCumul[i] << "% "
<< std::setw(7) << rmsELongitCumul[i] << "% "
<<G4endl;
G4cout << std::setw(8) << inf << "->" << std::setw(5) << sup << " radl: " << std::setw(7)
<< MeanELongit[i] << "% " << std::setw(9) << rmsELongit[i] << "% "
<< " 0->" << std::setw(5) << sup << " radl: " << std::setw(7)
<< MeanELongitCumul[i] << "% " << std::setw(7) << rmsELongitCumul[i] << "% "
<< G4endl;
}
G4cout << G4endl << G4endl << G4endl;
@@ -314,61 +311,58 @@ void Run::EndOfRun(G4double edep, G4double rms, G4double& limit)
G4cout << " RADIAL PROFILE "
<< " CUMULATIVE RADIAL PROFILE" << G4endl << G4endl;
G4cout << " bin " << " Mean rms "
<< " bin " << " Mean rms \n" << G4endl;
G4cout << " bin "
<< " Mean rms "
<< " bin "
<< " Mean rms \n"
<< G4endl;
for (i=0; i<f_nRbin; ++i) {
G4double inf=i*dRradl, sup=inf+dRradl;
for (i = 0; i < f_nRbin; ++i) {
G4double inf = i * dRradl, sup = inf + dRradl;
G4cout << std::setw(8) << inf << "->"
<< std::setw(5) << sup << " radl: "
<< std::setw(7) << MeanERadial[i] << "% "
<< std::setw(9) << rmsERadial[i] << "% "
<< " 0->" << std::setw(5) << sup << " radl: "
<< std::setw(7) << MeanERadialCumul[i] << "% "
<< std::setw(7) << rmsERadialCumul[i] << "% "
<<G4endl;
}
G4cout << std::setw(8) << inf << "->" << std::setw(5) << sup << " radl: " << std::setw(7)
<< MeanERadial[i] << "% " << std::setw(9) << rmsERadial[i] << "% "
<< " 0->" << std::setw(5) << sup << " radl: " << std::setw(7)
<< MeanERadialCumul[i] << "% " << std::setw(7) << rmsERadialCumul[i] << "% "
<< G4endl;
}
}
G4cout << "\n ===== SUMMARY ===== \n" << G4endl;
G4cout << " Total number of events: " << NbOfEvents << "\n"
<< " Mean number of charged steps: " << fChargedStep << G4endl;
G4cout << " Mean number of neutral steps: " << fNeutralStep
<< "\n" << G4endl;
G4cout << " Mean number of neutral steps: " << fNeutralStep << "\n" << G4endl;
G4cout << " energy deposit : "
<< std::setw(7) << MeanELongitCumul[f_nLbin-1] << " % E0 +- "
<< std::setw(7) << rmsELongitCumul[f_nLbin-1] << " % E0" << G4endl;
G4cout << " charged traklen: "
<< std::setw(7) << MeanChargTrLength << " radl +- "
<< std::setw(7) << rmsChargTrLength << " radl" << G4endl;
G4cout << " neutral traklen: "
<< std::setw(7) << MeanNeutrTrLength << " radl +- "
<< std::setw(7) << rmsNeutrTrLength << " radl" << G4endl;
if (iMoliere > 0. ) {
G4double RMoliere1 = iMoliere*fDet->GetdRradl();
G4double RMoliere2 = iMoliere*fDet->GetdRlength();
G4cout << "\n " << EMoliere << " % confinement: radius = "
<< RMoliere1 << " radl ("
<< G4BestUnit( RMoliere2, "Length") << ")" << "\n" << G4endl;
}
G4cout << " energy deposit : " << std::setw(7) << MeanELongitCumul[f_nLbin - 1] << " % E0 +- "
<< std::setw(7) << rmsELongitCumul[f_nLbin - 1] << " % E0" << G4endl;
G4cout << " charged traklen: " << std::setw(7) << MeanChargTrLength << " radl +- " << std::setw(7)
<< rmsChargTrLength << " radl" << G4endl;
G4cout << " neutral traklen: " << std::setw(7) << MeanNeutrTrLength << " radl +- " << std::setw(7)
<< rmsNeutrTrLength << " radl" << G4endl;
G4cout.setf(mode,std::ios::floatfield);
if (iMoliere > 0.) {
G4double RMoliere1 = iMoliere * fDet->GetdRradl();
G4double RMoliere2 = iMoliere * fDet->GetdRlength();
G4cout << "\n " << EMoliere << " % confinement: radius = " << RMoliere1 << " radl ("
<< G4BestUnit(RMoliere2, "Length") << ")"
<< "\n"
<< G4endl;
}
G4cout.setf(mode, std::ios::floatfield);
G4cout.precision(prec);
// Acceptance
G4int nLbin = fDet->GetnLtot();
if (limit < DBL_MAX) {
G4int nLbin = fDet->GetnLtot();
if (limit < DBL_MAX) {
EmAcceptance acc;
acc.BeginOfAcceptance("Total Energy in Absorber",NbOfEvents);
G4double e = MeanELongitCumul[nLbin-1]/100.;
G4double r = rmsELongitCumul[nLbin-1]/100.;
acc.EmAcceptanceGauss("Edep",NbOfEvents,e,edep,rms,limit);
acc.EmAcceptanceGauss("Erms",NbOfEvents,r,rms,rms,2.0*limit);
acc.BeginOfAcceptance("Total Energy in Absorber", NbOfEvents);
G4double e = MeanELongitCumul[nLbin - 1] / 100.;
G4double r = rmsELongitCumul[nLbin - 1] / 100.;
acc.EmAcceptanceGauss("Edep", NbOfEvents, e, edep, rms, limit);
acc.EmAcceptanceGauss("Erms", NbOfEvents, r, rms, rms, 2.0 * limit);
acc.EndOfAcceptance();
}
limit = DBL_MAX;
@@ -26,28 +26,26 @@
/// \file electromagnetic/TestEm2/src/RunAction.cc
/// \brief Implementation of the RunAction class
//
//
//
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
#include "RunAction.hh"
#include "DetectorConstruction.hh"
#include "PrimaryGeneratorAction.hh"
#include "RunActionMessenger.hh"
#include "Run.hh"
#include "EmAcceptance.hh"
#include "PrimaryGeneratorAction.hh"
#include "Run.hh"
#include "RunActionMessenger.hh"
#include "G4Run.hh"
#include "G4RunManager.hh"
#include "G4SystemOfUnits.hh"
#include "Randomize.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
RunAction::RunAction(DetectorConstruction* det, PrimaryGeneratorAction* kin)
:fDet(det),fKin(kin)
RunAction::RunAction(DetectorConstruction* det, PrimaryGeneratorAction* kin) : fDet(det), fKin(kin)
{
fRunMessenger = new RunActionMessenger(this);
@@ -74,7 +72,7 @@ void RunAction::BookHisto()
{
// Get analysis manager
fAnalysisManager = G4AnalysisManager::Instance();
// Open an output file
fAnalysisManager->OpenFile();
fAnalysisManager->SetVerboseLevel(1);
@@ -82,53 +80,42 @@ void RunAction::BookHisto()
// Creating histograms
//
G4double Ekin = fKin->GetParticleGun()->GetParticleEnergy();
G4int nLbin = fDet->GetnLtot();
G4int nRbin = fDet->GetnRtot();
G4int nLbin = fDet->GetnLtot();
G4int nRbin = fDet->GetnRtot();
G4double dLradl = fDet->GetdLradl();
G4double dRradl = fDet->GetdRradl();
fAnalysisManager->SetFirstHistoId(1);
fAnalysisManager->CreateH1( "h1","total energy deposit(percent of Einc)",
110,0.,110.);
fAnalysisManager->CreateH1( "h2","total charged tracklength (radl)",
110,0.,110.*Ekin/GeV);
fAnalysisManager->SetFirstHistoId(1);
fAnalysisManager->CreateH1("h1", "total energy deposit(percent of Einc)", 110, 0., 110.);
fAnalysisManager->CreateH1( "h3","total neutral tracklength (radl)",
110,0.,1100.*Ekin/GeV);
fAnalysisManager->CreateH1("h2", "total charged tracklength (radl)", 110, 0., 110. * Ekin / GeV);
fAnalysisManager->CreateH1( "h4","longit energy profile (% of E inc)",
nLbin,0.,nLbin*dLradl);
fAnalysisManager->CreateP1( "p4","longit energy profile (% of E inc)",
nLbin,0.,nLbin*dLradl, 0., 1000.);
fAnalysisManager->CreateH1( "h5","rms on longit Edep (% of E inc)",
nLbin,0.,nLbin*dLradl);
fAnalysisManager->CreateH1("h3", "total neutral tracklength (radl)", 110, 0., 1100. * Ekin / GeV);
G4double Zmin=0.5*dLradl, Zmax=Zmin+nLbin*dLradl;
fAnalysisManager->CreateH1( "h6","cumul longit energy dep (% of E inc)",
nLbin,Zmin,Zmax);
fAnalysisManager->CreateH1( "h7","rms on cumul longit Edep (% of E inc)",
nLbin,Zmin,Zmax);
fAnalysisManager->CreateH1("h4", "longit energy profile (% of E inc)", nLbin, 0., nLbin * dLradl);
fAnalysisManager->CreateH1( "h8","radial energy profile (% of E inc)",
nRbin,0.,nRbin*dRradl);
fAnalysisManager->CreateP1( "p8","radial energy profile (% of E inc)",
nRbin,0.,nRbin*dRradl, 0., 1000.);
fAnalysisManager->CreateH1( "h9","rms on radial Edep (% of E inc)",
nRbin,0.,nRbin*dRradl);
fAnalysisManager->CreateP1("p4", "longit energy profile (% of E inc)", nLbin, 0., nLbin * dLradl,
0., 1000.);
G4double Rmin=0.5*dRradl, Rmax=Rmin+nRbin*dRradl;
fAnalysisManager->CreateH1("h10","cumul radial energy dep (% of E inc)",
nRbin,Rmin,Rmax);
fAnalysisManager->CreateH1("h5", "rms on longit Edep (% of E inc)", nLbin, 0., nLbin * dLradl);
G4double Zmin = 0.5 * dLradl, Zmax = Zmin + nLbin * dLradl;
fAnalysisManager->CreateH1("h6", "cumul longit energy dep (% of E inc)", nLbin, Zmin, Zmax);
fAnalysisManager->CreateH1("h7", "rms on cumul longit Edep (% of E inc)", nLbin, Zmin, Zmax);
fAnalysisManager->CreateH1("h8", "radial energy profile (% of E inc)", nRbin, 0., nRbin * dRradl);
fAnalysisManager->CreateP1("p8", "radial energy profile (% of E inc)", nRbin, 0., nRbin * dRradl,
0., 1000.);
fAnalysisManager->CreateH1("h9", "rms on radial Edep (% of E inc)", nRbin, 0., nRbin * dRradl);
G4double Rmin = 0.5 * dRradl, Rmax = Rmin + nRbin * dRradl;
fAnalysisManager->CreateH1("h10", "cumul radial energy dep (% of E inc)", nRbin, Rmin, Rmax);
fAnalysisManager->CreateH1("h11", "rms on cumul radial Edep (% of E inc)", nRbin, Rmin, Rmax);
fAnalysisManager->CreateH1("h11","rms on cumul radial Edep (% of E inc)",
nRbin,Rmin,Rmax);
G4String fileName = fAnalysisManager->GetFileName();
G4String extension = fAnalysisManager->GetFileType();
G4String fullFileName = fileName + "." + extension;
@@ -138,8 +125,8 @@ void RunAction::BookHisto()
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4Run* RunAction::GenerateRun()
{
fRun = new Run(fDet, fKin);
{
fRun = new Run(fDet, fKin);
fRun->SetVerbose(fVerbose);
return fRun;
}
@@ -149,9 +136,9 @@ G4Run* RunAction::GenerateRun()
void RunAction::BeginOfRunAction(const G4Run*)
{
// show Rndm status
if (isMaster) G4Random::showEngineStatus();
if (isMaster) G4Random::showEngineStatus();
//histograms
// histograms
//
BookHisto();
}
@@ -160,17 +147,17 @@ void RunAction::BeginOfRunAction(const G4Run*)
void RunAction::EndOfRunAction(const G4Run*)
{
//compute and print statistic
//
if (isMaster) fRun->EndOfRun(fEdeptrue, fRmstrue, fLimittrue);
// compute and print statistic
//
if (isMaster) fRun->EndOfRun(fEdeptrue, fRmstrue, fLimittrue);
// show Rndm status
if (isMaster) G4Random::showEngineStatus();
// show Rndm status
if (isMaster) G4Random::showEngineStatus();
// save histos and close analysis
fAnalysisManager->Write();
fAnalysisManager->CloseFile();
fAnalysisManager->Clear();
// save histos and close analysis
fAnalysisManager->Write();
fAnalysisManager->CloseFile();
fAnalysisManager->Clear();
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -178,15 +165,15 @@ void RunAction::EndOfRunAction(const G4Run*)
void RunAction::SetEdepAndRMS(G4ThreeVector Value)
{
fEdeptrue = Value(0);
fRmstrue = Value(1);
fLimittrue= Value(2);
fRmstrue = Value(1);
fLimittrue = Value(2);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void RunAction::SetVerbose(G4int val)
void RunAction::SetVerbose(G4int val)
{
fVerbose = val;
if (fRun) fRun->SetVerbose(val);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -33,29 +33,29 @@
#include "RunActionMessenger.hh"
#include "RunAction.hh"
#include "G4UIdirectory.hh"
#include "G4UIcmdWith3Vector.hh"
#include "G4UIcmdWithAString.hh"
#include "G4UIcmdWithAnInteger.hh"
#include "G4UIdirectory.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
RunActionMessenger::RunActionMessenger(RunAction* run)
:fRun(run)
RunActionMessenger::RunActionMessenger(RunAction* run) : fRun(run)
{
fRunDir = new G4UIdirectory("/testem/run/");
fRunDir->SetGuidance("run control");
fAccCmd = new G4UIcmdWith3Vector("/testem/run/acceptance",this);
fAccCmd = new G4UIcmdWith3Vector("/testem/run/acceptance", this);
fAccCmd->SetGuidance("set Edep and RMS");
fAccCmd->SetGuidance("acceptance values for first layer");
fAccCmd->SetParameterName("edep","rms","limit",true);
fAccCmd->SetParameterName("edep", "rms", "limit", true);
fAccCmd->SetRange("edep>0 && edep<1 && rms>0");
fAccCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
fVerbCmd = new G4UIcmdWithAnInteger("/testem/run/verbose",this);
fAccCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
fVerbCmd = new G4UIcmdWithAnInteger("/testem/run/verbose", this);
fVerbCmd->SetGuidance("set verbose level for runAction");
fVerbCmd->SetParameterName("verbose",false);
fVerbCmd->SetParameterName("verbose", false);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -69,13 +69,15 @@ RunActionMessenger::~RunActionMessenger()
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void RunActionMessenger::SetNewValue(G4UIcommand* command,G4String newValue)
{
if (command == fAccCmd )
{ fRun->SetEdepAndRMS(fAccCmd->GetNew3VectorValue(newValue));}
if (command == fVerbCmd )
{ fRun->SetVerbose(fVerbCmd->GetNewIntValue(newValue));}
void RunActionMessenger::SetNewValue(G4UIcommand* command, G4String newValue)
{
if (command == fAccCmd) {
fRun->SetEdepAndRMS(fAccCmd->GetNew3VectorValue(newValue));
}
if (command == fVerbCmd) {
fRun->SetVerbose(fVerbCmd->GetNewIntValue(newValue));
}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -31,19 +31,22 @@
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
#include "StepMax.hh"
#include "StepMaxMessenger.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
StepMax::StepMax(const G4String& processName)
: G4VDiscreteProcess(processName)
StepMax::StepMax(const G4String& processName) : G4VDiscreteProcess(processName)
{
fMess = new StepMaxMessenger(this);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
StepMax::~StepMax() { delete fMess; }
StepMax::~StepMax()
{
delete fMess;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -54,13 +57,15 @@ G4bool StepMax::IsApplicable(const G4ParticleDefinition& particle)
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void StepMax::SetMaxStep(G4double step) {fMaxChargedStep = step;}
void StepMax::SetMaxStep(G4double step)
{
fMaxChargedStep = step;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4double StepMax::PostStepGetPhysicalInteractionLength( const G4Track&,
G4double,
G4ForceCondition* condition )
G4double StepMax::PostStepGetPhysicalInteractionLength(const G4Track&, G4double,
G4ForceCondition* condition)
{
// condition is set to "Not Forced"
*condition = NotForced;
@@ -72,16 +77,16 @@ G4double StepMax::PostStepGetPhysicalInteractionLength( const G4Track&,
G4VParticleChange* StepMax::PostStepDoIt(const G4Track& aTrack, const G4Step&)
{
// do nothing
aParticleChange.Initialize(aTrack);
return &aParticleChange;
// do nothing
aParticleChange.Initialize(aTrack);
return &aParticleChange;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4double StepMax::GetMeanFreePath(const G4Track&,G4double,G4ForceCondition*)
G4double StepMax::GetMeanFreePath(const G4Track&, G4double, G4ForceCondition*)
{
return fMaxChargedStep;
}
return fMaxChargedStep;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -33,16 +33,16 @@
#include "StepMaxMessenger.hh"
#include "StepMax.hh"
#include "G4UIcmdWithADoubleAndUnit.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
StepMaxMessenger::StepMaxMessenger(StepMax* stepM)
:fStepMax(stepM)
{
fStepMaxCmd = new G4UIcmdWithADoubleAndUnit("/testem/stepMax",this);
StepMaxMessenger::StepMaxMessenger(StepMax* stepM) : fStepMax(stepM)
{
fStepMaxCmd = new G4UIcmdWithADoubleAndUnit("/testem/stepMax", this);
fStepMaxCmd->SetGuidance("Set max allowed step length");
fStepMaxCmd->SetParameterName("mxStep",false);
fStepMaxCmd->SetParameterName("mxStep", false);
fStepMaxCmd->SetRange("mxStep>0.");
fStepMaxCmd->SetUnitCategory("Length");
}
@@ -57,9 +57,10 @@ StepMaxMessenger::~StepMaxMessenger()
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void StepMaxMessenger::SetNewValue(G4UIcommand* command, G4String newValue)
{
if (command == fStepMaxCmd)
{ fStepMax->SetMaxStep(fStepMaxCmd->GetNewDoubleValue(newValue));}
{
if (command == fStepMaxCmd) {
fStepMax->SetMaxStep(fStepMaxCmd->GetNewDoubleValue(newValue));
}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -31,6 +31,7 @@
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
#include "SteppingAction.hh"
#include "DetectorConstruction.hh"
#include "Run.hh"
@@ -39,30 +40,27 @@
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
SteppingAction::SteppingAction(DetectorConstruction* det)
:fDetector(det)
{}
SteppingAction::SteppingAction(DetectorConstruction* det) : fDetector(det) {}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void SteppingAction::UserSteppingAction(const G4Step* step)
{
{
// energy deposit
//
G4double dEStep = step->GetTotalEnergyDeposit();
Run* run
= static_cast<Run*>(G4RunManager::GetRunManager()->GetNonConstCurrentRun());
Run* run = static_cast<Run*>(G4RunManager::GetRunManager()->GetNonConstCurrentRun());
run->AddStep(step->GetTrack()->GetDefinition()->GetPDGCharge());
if (dEStep > 0.) {
G4ThreeVector prePoint = step->GetPreStepPoint()->GetPosition();
G4ThreeVector prePoint = step->GetPreStepPoint()->GetPosition();
G4ThreeVector delta = step->GetPostStepPoint()->GetPosition() - prePoint;
prePoint += G4UniformRand()*delta;
prePoint += G4UniformRand() * delta;
G4double x = prePoint.x(), y = prePoint.y(), z = prePoint.z();
G4double radius = std::sqrt(x*x + y*y);
G4double offset = 0.5*fDetector->GetfullLength();
G4int SlideNb = G4int((z + offset)/fDetector->GetdLlength());
G4int RingNb = G4int(radius/fDetector->GetdRlength());
run->FillPerStep(dEStep,SlideNb,RingNb);
G4double radius = std::sqrt(x * x + y * y);
G4double offset = 0.5 * fDetector->GetfullLength();
G4int SlideNb = G4int((z + offset) / fDetector->GetdLlength());
G4int RingNb = G4int(radius / fDetector->GetdRlength());
run->FillPerStep(dEStep, SlideNb, RingNb);
}
}
@@ -31,6 +31,7 @@
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
#include "TrackingAction.hh"
#include "Run.hh"
#include "G4RunManager.hh"
@@ -40,14 +41,12 @@
void TrackingAction::PostUserTrackingAction(const G4Track* aTrack)
{
//count total track length
G4double charge = aTrack->GetDefinition()->GetPDGCharge();
G4double TrLeng = aTrack->GetTrackLength();
Run* run
= static_cast<Run*>(G4RunManager::GetRunManager()->GetNonConstCurrentRun());
run->FillPerTrack(charge,TrLeng);
// count total track length
G4double charge = aTrack->GetDefinition()->GetPDGCharge();
G4double TrLeng = aTrack->GetTrackLength();
Run* run = static_cast<Run*>(G4RunManager::GetRunManager()->GetNonConstCurrentRun());
run->FillPerTrack(charge, TrLeng);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......