Import Geant4 10.3.0 source tree

This commit is contained in:
Gabriele Cosmo
2016-12-09 12:35:28 +01:00
parent 4ec577e5c4
commit a3452e42ac
3514 changed files with 210500 additions and 89628 deletions
@@ -26,7 +26,7 @@
/// \file polarisation/Pol01/src/DetectorConstruction.cc
/// \brief Implementation of the DetectorConstruction class
//
// $Id: DetectorConstruction.cc 84603 2014-10-17 07:47:11Z gcosmo $
// $Id: DetectorConstruction.cc 98772 2016-08-09 14:25:31Z gcosmo $
//
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -53,23 +53,22 @@
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
DetectorConstruction::DetectorConstruction()
:pWorld(0), pBox(0), aMaterial(0)
: G4VUserDetectorConstruction(),
fWorld(0), fBox(0), fTargetMaterial(0), fWorldMaterial(0)
{
boxSizeXY = 50*mm;
boxSizeZ = 5*mm;
worldSize = 1.*m;
aMaterial = 0;
wMaterial = 0;
fBoxSizeXY = 50*mm;
fBoxSizeZ = 5*mm;
fWorldSize = 1.*m;
SetTargetMaterial("G4_Fe");
SetWorldMaterial("G4_Galactic");
detectorMessenger = new DetectorMessenger(this);
fMessenger = new DetectorMessenger(this);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
DetectorConstruction::~DetectorConstruction()
{
delete detectorMessenger;
delete fMessenger;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -88,14 +87,14 @@ G4VPhysicalVolume* DetectorConstruction::Construct()
//
G4Box*
sWorld = new G4Box("World", //name
worldSize/2,worldSize/2,worldSize/2); //dimensions
fWorldSize/2,fWorldSize/2,fWorldSize/2); //dimensions
G4LogicalVolume*
lWorld = new G4LogicalVolume(sWorld, //shape
wMaterial, //material
fWorldMaterial, //material
"World"); //name
pWorld = new G4PVPlacement(0, //no rotation
fWorld = new G4PVPlacement(0, //no rotation
G4ThreeVector(), //at (0,0,0)
lWorld, //logical volume
"World", //name
@@ -107,17 +106,17 @@ G4VPhysicalVolume* DetectorConstruction::Construct()
//
G4Box*
sBox = new G4Box("Container", //its name
boxSizeXY/2.,boxSizeXY/2.,boxSizeZ/2.);//its dimensions
fBoxSizeXY/2.,fBoxSizeXY/2.,fBoxSizeZ/2.);//its dimensions
G4LogicalVolume*
lBox = new G4LogicalVolume(sBox, //its shape
aMaterial, //its material
fTargetMaterial, //its material
"theBox"); //its name
pBox = new G4PVPlacement(0, //no rotation
fBox = new G4PVPlacement(0, //no rotation
G4ThreeVector(), //at (0,0,0)
lBox, //its logical volume
aMaterial->GetName(), //its name
fTargetMaterial->GetName(), //its name
lWorld, //its mother volume
false, //no boolean operation
0); //copy number
@@ -130,17 +129,17 @@ G4VPhysicalVolume* DetectorConstruction::Construct()
//always return the root volume
//
return pWorld;
return fWorld;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void DetectorConstruction::PrintParameters()
{
G4cout << "\n The Box is " << G4BestUnit(boxSizeXY,"Length")
<< " x " << G4BestUnit(boxSizeXY,"Length")
<< " x " << G4BestUnit(boxSizeZ,"Length")
<< " of " << aMaterial->GetName() << G4endl;
G4cout << "\n The Box is " << G4BestUnit(fBoxSizeXY,"Length")
<< " x " << G4BestUnit(fBoxSizeXY,"Length")
<< " x " << G4BestUnit(fBoxSizeZ,"Length")
<< " of " << fTargetMaterial->GetName() << G4endl;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -150,9 +149,9 @@ void DetectorConstruction::SetTargetMaterial(G4String materialChoice)
// search the material by its name
G4Material* mat =
G4NistManager::Instance()->FindOrBuildMaterial(materialChoice);
if (mat != aMaterial) {
if (mat != fTargetMaterial) {
if(mat) {
aMaterial = mat;
fTargetMaterial = mat;
UpdateGeometry();
} else {
G4cout << "### Warning! Target material: <"
@@ -168,9 +167,9 @@ void DetectorConstruction::SetWorldMaterial(G4String materialChoice)
// search the material by its name
G4Material* mat =
G4NistManager::Instance()->FindOrBuildMaterial(materialChoice);
if (mat != wMaterial) {
if (mat != fWorldMaterial) {
if(mat) {
wMaterial = mat;
fWorldMaterial = mat;
UpdateGeometry();
} else {
G4cout << "### Warning! World material: <"
@@ -183,15 +182,15 @@ void DetectorConstruction::SetWorldMaterial(G4String materialChoice)
void DetectorConstruction::SetSizeXY(G4double value)
{
boxSizeXY = value;
if (worldSize<boxSizeXY) worldSize = 1.2*boxSizeXY;
fBoxSizeXY = value;
if (fWorldSize<fBoxSizeXY) fWorldSize = 1.2*fBoxSizeXY;
UpdateGeometry();
}
void DetectorConstruction::SetSizeZ(G4double value)
{
boxSizeZ = value;
if (worldSize<boxSizeZ) worldSize = 1.2*boxSizeZ;
fBoxSizeZ = value;
if (fWorldSize<fBoxSizeZ) fWorldSize = 1.2*fBoxSizeZ;
UpdateGeometry();
}
@@ -201,7 +200,7 @@ void DetectorConstruction::SetSizeZ(G4double value)
void DetectorConstruction::UpdateGeometry()
{
if (pWorld)
if (fWorld)
G4RunManager::GetRunManager()->DefineWorldVolume(Construct());
}
@@ -26,7 +26,7 @@
/// \file polarisation/Pol01/src/DetectorMessenger.cc
/// \brief Implementation of the DetectorMessenger class
//
// $Id: DetectorMessenger.cc 68753 2013-04-05 10:26:04Z gcosmo $
// $Id: DetectorMessenger.cc 98772 2016-08-09 14:25:31Z gcosmo $
//
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -41,68 +41,70 @@
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
DetectorMessenger::DetectorMessenger(DetectorConstruction * Det)
:Detector(Det)
DetectorMessenger::DetectorMessenger(DetectorConstruction * det)
:G4UImessenger(),
fDetector(det), fTestemDir(0), fDetDir(0),
fMaterCmd(0), fSizeXYCmd(0), fSizeZCmd(0), fUpdateCmd(0)
{
testemDir = new G4UIdirectory("/testem/");
testemDir->SetGuidance("commands specific to this example");
fTestemDir = new G4UIdirectory("/testem/");
fTestemDir->SetGuidance("commands specific to this example");
detDir = new G4UIdirectory("/testem/det/");
detDir->SetGuidance("detector construction");
fDetDir = new G4UIdirectory("/testem/det/");
fDetDir->SetGuidance("detector construction");
MaterCmd = new G4UIcmdWithAString("/testem/det/setMat",this);
MaterCmd->SetGuidance("Select material of the box.");
MaterCmd->SetParameterName("choice",false);
MaterCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
fMaterCmd = new G4UIcmdWithAString("/testem/det/setMat",this);
fMaterCmd->SetGuidance("Select material of the box.");
fMaterCmd->SetParameterName("choice",false);
fMaterCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
SizeXYCmd = new G4UIcmdWithADoubleAndUnit("/testem/det/setSizeXY",this);
SizeXYCmd->SetGuidance("Set sizeXY of the box");
SizeXYCmd->SetParameterName("Size",false);
SizeXYCmd->SetRange("Size>0.");
SizeXYCmd->SetUnitCategory("Length");
SizeXYCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
fSizeXYCmd = new G4UIcmdWithADoubleAndUnit("/testem/det/setSizeXY",this);
fSizeXYCmd->SetGuidance("Set sizeXY of the box");
fSizeXYCmd->SetParameterName("Size",false);
fSizeXYCmd->SetRange("Size>0.");
fSizeXYCmd->SetUnitCategory("Length");
fSizeXYCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
SizeZCmd = new G4UIcmdWithADoubleAndUnit("/testem/det/setSizeZ",this);
SizeZCmd->SetGuidance("Set sizeZ of the box");
SizeZCmd->SetParameterName("SizeZ",false);
SizeZCmd->SetRange("SizeZ>0.");
SizeZCmd->SetUnitCategory("Length");
SizeZCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
fSizeZCmd = new G4UIcmdWithADoubleAndUnit("/testem/det/setSizeZ",this);
fSizeZCmd->SetGuidance("Set sizeZ of the box");
fSizeZCmd->SetParameterName("SizeZ",false);
fSizeZCmd->SetRange("SizeZ>0.");
fSizeZCmd->SetUnitCategory("Length");
fSizeZCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
UpdateCmd = new G4UIcmdWithoutParameter("/testem/det/update",this);
UpdateCmd->SetGuidance("Update calorimeter geometry.");
UpdateCmd->SetGuidance("This command MUST be applied before \"beamOn\" ");
UpdateCmd->SetGuidance("if you changed geometrical value(s).");
UpdateCmd->AvailableForStates(G4State_Idle);
fUpdateCmd = new G4UIcmdWithoutParameter("/testem/det/update",this);
fUpdateCmd->SetGuidance("Update calorimeter geometry.");
fUpdateCmd->SetGuidance("This command MUST be applied before \"beamOn\" ");
fUpdateCmd->SetGuidance("if you changed geometrical value(s).");
fUpdateCmd->AvailableForStates(G4State_Idle);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
DetectorMessenger::~DetectorMessenger()
{
delete MaterCmd;
delete SizeXYCmd;
delete SizeZCmd;
delete UpdateCmd;
delete detDir;
delete testemDir;
delete fMaterCmd;
delete fSizeXYCmd;
delete fSizeZCmd;
delete fUpdateCmd;
delete fDetDir;
delete fTestemDir;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void DetectorMessenger::SetNewValue(G4UIcommand* command, G4String newValue)
{
if( command == MaterCmd )
{ Detector->SetTargetMaterial(newValue);}
if( command == fMaterCmd )
{ fDetector->SetTargetMaterial(newValue);}
if( command == SizeXYCmd )
{ Detector->SetSizeXY(SizeXYCmd->GetNewDoubleValue(newValue));}
if( command == fSizeXYCmd )
{ fDetector->SetSizeXY(fSizeXYCmd->GetNewDoubleValue(newValue));}
if( command == SizeZCmd )
{ Detector->SetSizeZ(SizeZCmd->GetNewDoubleValue(newValue));}
if( command == fSizeZCmd )
{ fDetector->SetSizeZ(fSizeZCmd->GetNewDoubleValue(newValue));}
if( command == UpdateCmd )
{ Detector->UpdateGeometry(); }
if( command == fUpdateCmd )
{ fDetector->UpdateGeometry(); }
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -26,18 +26,19 @@
/// \file polarisation/Pol01/src/EventAction.cc
/// \brief Implementation of the EventAction class
//
// $Id: EventAction.cc 86418 2014-11-11 10:39:38Z gcosmo $
// $Id: EventAction.cc 98772 2016-08-09 14:25:31Z gcosmo $
//
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
#include "EventAction.hh"
#include "G4Event.hh"
#include "RunAction.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
EventAction::EventAction(RunAction * ra) : runAction(ra)
EventAction::EventAction(RunAction * ra)
: G4UserEventAction(),
fRunAction(ra)
{}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -54,9 +55,8 @@ void EventAction::BeginOfEventAction(const G4Event*)
void EventAction::EndOfEventAction(const G4Event*)
{
runAction->EventFinished();
fRunAction->EventFinished();
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -27,7 +27,7 @@
/// \brief Implementation of the PhysListEmPolarized class
//
//
// $Id: PhysListEmPolarized.cc 86418 2014-11-11 10:39:38Z gcosmo $
// $Id: PhysListEmPolarized.cc 100257 2016-10-17 08:00:06Z gcosmo $
//
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -36,16 +36,8 @@
#include "G4ParticleDefinition.hh"
#include "G4ProcessManager.hh"
#include "G4ComptonScattering.hh"
#include "G4GammaConversion.hh"
#include "G4PhotoElectricEffect.hh"
#include "G4eMultipleScattering.hh"
#include "G4eIonisation.hh"
#include "G4eBremsstrahlung.hh"
#include "G4eplusAnnihilation.hh"
#include "G4PolarizedCompton.hh"
#include "G4PolarizedGammaConversion.hh"
#include "G4ePolarizedIonisation.hh"
@@ -70,9 +62,10 @@ void PhysListEmPolarized::ConstructProcess()
{
// Add standard EM Processes
aParticleIterator->reset();
while( (*aParticleIterator)() ){
G4ParticleDefinition* particle = aParticleIterator->value();
auto particleIterator=GetParticleIterator();
particleIterator->reset();
while( (*particleIterator)() ){
G4ParticleDefinition* particle = particleIterator->value();
G4ProcessManager* pmanager = particle->GetProcessManager();
G4String particleName = particle->GetParticleName();
@@ -96,4 +89,3 @@ void PhysListEmPolarized::ConstructProcess()
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -27,7 +27,7 @@
/// \brief Implementation of the PhysicsList class
//
//
// $Id: PhysicsList.cc 96116 2016-03-16 18:56:02Z gcosmo $
// $Id: PhysicsList.cc 100257 2016-10-17 08:00:06Z gcosmo $
//
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -39,22 +39,20 @@
#include "PhysListEmPolarized.hh"
#include "G4EmParameters.hh"
#include "G4UnitsTable.hh"
#include "G4SystemOfUnits.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
PhysicsList::PhysicsList()
: G4VModularPhysicsList()
: G4VModularPhysicsList(),
fEmPhysicsList(0), fEmName("polarized"), fMessenger(0)
{
pMessenger = new PhysicsListMessenger(this);
fMessenger = new PhysicsListMessenger(this);
G4EmParameters::Instance();
SetVerboseLevel(1);
emName = "polarized";
emPhysicsList = new PhysListEmPolarized();
fEmPhysicsList = new PhysListEmPolarized();
}
@@ -62,7 +60,7 @@ PhysicsList::PhysicsList()
PhysicsList::~PhysicsList()
{
delete pMessenger;
delete fMessenger;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -111,7 +109,7 @@ void PhysicsList::ConstructProcess()
// Electromagnetic physics list
//
emPhysicsList->ConstructProcess();
fEmPhysicsList->ConstructProcess();
// step limitation (as a full process)
//
@@ -126,19 +124,19 @@ void PhysicsList::AddPhysicsList(const G4String& name)
G4cout << "PhysicsList::AddPhysicsList: <" << name << ">" << G4endl;
}
if (name == emName) return;
if (name == fEmName) return;
if (name == "standard") {
emName = name;
delete emPhysicsList;
emPhysicsList = new G4EmStandardPhysics();
fEmName = name;
delete fEmPhysicsList;
fEmPhysicsList = new G4EmStandardPhysics();
} else if (name == "polarized") {
emName = name;
delete emPhysicsList;
emPhysicsList = new PhysListEmPolarized();
fEmName = name;
delete fEmPhysicsList;
fEmPhysicsList = new PhysListEmPolarized();
} else {
G4cout << "PhysicsList::AddPhysicsList: <" << name << ">"
@@ -157,9 +155,10 @@ void PhysicsList::AddStepMax()
// Step limitation seen as a process
StepMax* stepMaxProcess = new StepMax();
theParticleIterator->reset();
while ((*theParticleIterator)()){
G4ParticleDefinition* particle = theParticleIterator->value();
auto particleIterator=GetParticleIterator();
particleIterator->reset();
while ((*particleIterator)()){
G4ParticleDefinition* particle = particleIterator->value();
G4ProcessManager* pmanager = particle->GetProcessManager();
if (stepMaxProcess->IsApplicable(*particle) && pmanager)
@@ -26,7 +26,7 @@
/// \file polarisation/Pol01/src/PhysicsListMessenger.cc
/// \brief Implementation of the PhysicsListMessenger class
//
// $Id: PhysicsListMessenger.cc 86418 2014-11-11 10:39:38Z gcosmo $
// $Id: PhysicsListMessenger.cc 98772 2016-08-09 14:25:31Z gcosmo $
//
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -40,23 +40,24 @@
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
PhysicsListMessenger::PhysicsListMessenger(PhysicsList* pPhys)
:pPhysicsList(pPhys)
: G4UImessenger(),
fPhysicsList(pPhys), fPhysDir(0), fListCmd(0)
{
physDir = new G4UIdirectory("/testem/phys/");
physDir->SetGuidance("physics list commands");
fPhysDir = new G4UIdirectory("/testem/phys/");
fPhysDir->SetGuidance("physics list commands");
pListCmd = new G4UIcmdWithAString("/testem/phys/addPhysics",this);
pListCmd->SetGuidance("Select standard/polarized physics list.");
pListCmd->SetParameterName("PList",false);
pListCmd->AvailableForStates(G4State_PreInit);
fListCmd = new G4UIcmdWithAString("/testem/phys/addPhysics",this);
fListCmd->SetGuidance("Select standard/polarized physics list.");
fListCmd->SetParameterName("PList",false);
fListCmd->AvailableForStates(G4State_PreInit);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
PhysicsListMessenger::~PhysicsListMessenger()
{
delete pListCmd;
delete physDir;
delete fListCmd;
delete fPhysDir;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -64,8 +65,8 @@ PhysicsListMessenger::~PhysicsListMessenger()
void PhysicsListMessenger::SetNewValue(G4UIcommand* command,
G4String newValue)
{
if( command == pListCmd )
{ pPhysicsList->AddPhysicsList(newValue);}
if( command == fListCmd )
{ fPhysicsList->AddPhysicsList(newValue);}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -26,7 +26,7 @@
/// \file polarisation/Pol01/src/PrimaryGeneratorAction.cc
/// \brief Implementation of the PrimaryGeneratorAction class
//
// $Id: PrimaryGeneratorAction.cc 68753 2013-04-05 10:26:04Z gcosmo $
// $Id: PrimaryGeneratorAction.cc 98772 2016-08-09 14:25:31Z gcosmo $
//
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -43,21 +43,22 @@
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
PrimaryGeneratorAction::PrimaryGeneratorAction(DetectorConstruction* det)
:detector(det)
: G4VUserPrimaryGeneratorAction(),
fParticleGun(0), fDetector(det)
{
particleGun = new G4ParticleGun(1);
fParticleGun = new G4ParticleGun(1);
G4ParticleDefinition* particle
= G4ParticleTable::GetParticleTable()->FindParticle("e-");
particleGun->SetParticleDefinition(particle);
particleGun->SetParticleEnergy(10*MeV);
particleGun->SetParticleMomentumDirection(G4ThreeVector(0.,0.,1.));
fParticleGun->SetParticleDefinition(particle);
fParticleGun->SetParticleEnergy(10*MeV);
fParticleGun->SetParticleMomentumDirection(G4ThreeVector(0.,0.,1.));
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
PrimaryGeneratorAction::~PrimaryGeneratorAction()
{
delete particleGun;
delete fParticleGun;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -66,12 +67,11 @@ void PrimaryGeneratorAction::GeneratePrimaries(G4Event* anEvent)
{
//this function is called at the begining of event
//
G4double halfSize = 0.5*(detector->GetWorldSize());
G4double halfSize = 0.5*(fDetector->GetWorldSize());
G4double z0 = - halfSize;
particleGun->SetParticlePosition(G4ThreeVector(0., 0., z0));
particleGun->GeneratePrimaryVertex(anEvent);
fParticleGun->SetParticlePosition(G4ThreeVector(0., 0., z0));
fParticleGun->GeneratePrimaryVertex(anEvent);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -26,7 +26,7 @@
/// \file polarisation/Pol01/src/RunAction.cc
/// \brief Implementation of the RunAction class
//
// $Id: RunAction.cc 86443 2014-11-12 09:40:56Z gcosmo $
// $Id: RunAction.cc 98772 2016-08-09 14:25:31Z gcosmo $
//
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -53,9 +53,12 @@
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
RunAction::RunAction(DetectorConstruction* det, PrimaryGeneratorAction* prim)
: detector(det), primary(prim), ProcCounter(0), fAnalysisManager(0)
: G4UserRunAction(),
fGamma(0), fElectron(0), fPositron(0),
fDetector(det), fPrimary(prim), fProcCounter(0), fAnalysisManager(0),
fTotalEventCount(0),
fPhotonStats(), fElectronStats(), fPositronStats()
{
totalEventCount=0;
fGamma = G4Gamma::Gamma();
fElectron = G4Electron::Electron();
fPositron = G4Positron::Positron();
@@ -78,12 +81,12 @@ void RunAction::BeginOfRunAction(const G4Run* aRun)
// G4RunManager::GetRunManager()->SetRandomNumberStore(false);
// CLHEP::HepRandom::showEngineStatus();
if (ProcCounter) delete ProcCounter;
ProcCounter = new ProcessesCount;
totalEventCount = 0;
photonStats.Clear();
electronStats.Clear();
positronStats.Clear();
if (fProcCounter) delete fProcCounter;
fProcCounter = new ProcessesCount;
fTotalEventCount = 0;
fPhotonStats.Clear();
fElectronStats.Clear();
fPositronStats.Clear();
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -95,13 +98,13 @@ void RunAction::FillData(const G4ParticleDefinition* particle,
{
G4int id = -1;
if (particle == fGamma) {
photonStats.FillData(kinEnergy, costheta, longitudinalPolarization);
fPhotonStats.FillData(kinEnergy, costheta, longitudinalPolarization);
if(fAnalysisManager) { id = 1; }
} else if (particle == fElectron) {
electronStats.FillData(kinEnergy, costheta, longitudinalPolarization);
fElectronStats.FillData(kinEnergy, costheta, longitudinalPolarization);
if(fAnalysisManager) { id = 5; }
} else if (particle == fPositron) {
positronStats.FillData(kinEnergy, costheta, longitudinalPolarization);
fPositronStats.FillData(kinEnergy, costheta, longitudinalPolarization);
if(fAnalysisManager) { id = 9; }
}
if(id > 0) {
@@ -177,12 +180,12 @@ void RunAction::CountProcesses(G4String procName)
{
// is the process already counted ?
// *AS* change to std::map?!
size_t nbProc = ProcCounter->size();
size_t nbProc = fProcCounter->size();
size_t i = 0;
while ((i<nbProc)&&((*ProcCounter)[i]->GetName()!=procName)) i++;
if (i == nbProc) ProcCounter->push_back( new OneProcessCount(procName));
while ((i<nbProc)&&((*fProcCounter)[i]->GetName()!=procName)) i++;
if (i == nbProc) fProcCounter->push_back( new ProcessCount(procName));
(*ProcCounter)[i]->Count();
(*fProcCounter)[i]->Count();
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -194,35 +197,35 @@ void RunAction::EndOfRunAction(const G4Run* aRun)
G4int prec = G4cout.precision(5);
G4Material* material = detector->GetMaterial();
G4Material* material = fDetector->GetMaterial();
G4double density = material->GetDensity();
G4ParticleDefinition* particle =
primary->GetParticleGun()->GetParticleDefinition();
fPrimary->GetParticleGun()->GetParticleDefinition();
G4String Particle = particle->GetParticleName();
G4double energy = primary->GetParticleGun()->GetParticleEnergy();
G4double energy = fPrimary->GetParticleGun()->GetParticleEnergy();
G4cout << "\n The run consists of " << NbOfEvents << " "<< Particle << " of "
<< G4BestUnit(energy,"Energy") << " through "
<< G4BestUnit(detector->GetBoxSizeZ(),"Length") << " of "
<< G4BestUnit(fDetector->GetBoxSizeZ(),"Length") << " of "
<< material->GetName() << " (density: "
<< G4BestUnit(density,"Volumic Mass") << ")" << G4endl;
//frequency of processes
G4cout << "\n Process calls frequency --->\n";
for (size_t i=0; i< ProcCounter->size();i++) {
G4String procName = (*ProcCounter)[i]->GetName();
G4int count = (*ProcCounter)[i]->GetCounter();
for (size_t i=0; i< fProcCounter->size();i++) {
G4String procName = (*fProcCounter)[i]->GetName();
G4int count = (*fProcCounter)[i]->GetCounter();
G4cout << "\t" << procName << " = " << count<<"\n";
}
if (totalEventCount == 0) return;
if (fTotalEventCount == 0) return;
G4cout<<" Gamma: \n";
photonStats.PrintResults(totalEventCount);
fPhotonStats.PrintResults(fTotalEventCount);
G4cout<<" Electron: \n";
electronStats.PrintResults(totalEventCount);
fElectronStats.PrintResults(fTotalEventCount);
G4cout<<" Positron: \n";
positronStats.PrintResults(totalEventCount);
fPositronStats.PrintResults(fTotalEventCount);
//cross check from G4EmCalculator
// G4cout << "\n Verification from G4EmCalculator. \n";
@@ -242,20 +245,20 @@ void RunAction::EndOfRunAction(const G4Run* aRun)
void RunAction::EventFinished()
{
++totalEventCount;
photonStats.EventFinished();
electronStats.EventFinished();
positronStats.EventFinished();
++fTotalEventCount;
fPhotonStats.EventFinished();
fElectronStats.EventFinished();
fPositronStats.EventFinished();
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
RunAction::ParticleStatistics::ParticleStatistics()
: currentNumber(0),
totalNumber(0), totalNumber2(0),
sumEnergy(0), sumEnergy2(0),
sumPolarization(0), sumPolarization2(0),
sumCosTheta(0), sumCosTheta2(0)
: fCurrentNumber(0),
fTotalNumber(0), fTotalNumber2(0),
fSumEnergy(0), fSumEnergy2(0),
fSumPolarization(0), fSumPolarization2(0),
fSumCosTheta(0), fSumCosTheta2(0)
{}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -267,9 +270,9 @@ RunAction::ParticleStatistics::~ParticleStatistics()
void RunAction::ParticleStatistics::EventFinished()
{
totalNumber+=currentNumber;
totalNumber2+=currentNumber*currentNumber;
currentNumber=0;
fTotalNumber+=fCurrentNumber;
fTotalNumber2+=fCurrentNumber*fCurrentNumber;
fCurrentNumber=0;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -277,13 +280,13 @@ void RunAction::ParticleStatistics:: FillData(G4double kinEnergy,
G4double costheta,
G4double longitudinalPolarization)
{
++currentNumber;
sumEnergy+=kinEnergy;
sumEnergy2+=kinEnergy*kinEnergy;
sumPolarization+=longitudinalPolarization;
sumPolarization2+=longitudinalPolarization*longitudinalPolarization;
sumCosTheta+=costheta;
sumCosTheta2+=costheta*costheta;
++fCurrentNumber;
fSumEnergy+=kinEnergy;
fSumEnergy2+=kinEnergy*kinEnergy;
fSumPolarization+=longitudinalPolarization;
fSumPolarization2+=longitudinalPolarization*longitudinalPolarization;
fSumCosTheta+=costheta;
fSumCosTheta2+=costheta*costheta;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -291,15 +294,15 @@ void RunAction::ParticleStatistics:: FillData(G4double kinEnergy,
void RunAction::ParticleStatistics::PrintResults(G4int totalNumberOfEvents)
{
G4cout<<"Mean Number per Event :"
<<G4double(totalNumber)/G4double(totalNumberOfEvents)<<"\n";
if (totalNumber==0) totalNumber=1;
G4double energyMean=sumEnergy/totalNumber;
G4double energyRms=std::sqrt(sumEnergy2/totalNumber-energyMean*energyMean);
<<G4double(fTotalNumber)/G4double(totalNumberOfEvents)<<"\n";
if (fTotalNumber==0) fTotalNumber=1;
G4double energyMean=fSumEnergy/fTotalNumber;
G4double energyRms=std::sqrt(fSumEnergy2/fTotalNumber-energyMean*energyMean);
G4cout<<"Mean Energy :"<< G4BestUnit(energyMean,"Energy")
<<" +- "<<G4BestUnit(energyRms,"Energy")<<"\n";
G4double polarizationMean=sumPolarization/totalNumber;
G4double polarizationMean=fSumPolarization/fTotalNumber;
G4double polarizationRms=
std::sqrt(sumPolarization2/totalNumber-polarizationMean*polarizationMean);
std::sqrt(fSumPolarization2/fTotalNumber-polarizationMean*polarizationMean);
G4cout<<"Mean Polarization :"<< polarizationMean
<<" +- "<<polarizationRms<<"\n";
}
@@ -308,11 +311,11 @@ void RunAction::ParticleStatistics::PrintResults(G4int totalNumberOfEvents)
void RunAction::ParticleStatistics::Clear()
{
currentNumber=0;
totalNumber=totalNumber2=0;
sumEnergy=sumEnergy2=0;
sumPolarization=sumPolarization2=0;
sumCosTheta=sumCosTheta2=0;
fCurrentNumber=0;
fTotalNumber=fTotalNumber2=0;
fSumEnergy=fSumEnergy2=0;
fSumPolarization=fSumPolarization2=0;
fSumCosTheta=fSumCosTheta2=0;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -26,7 +26,7 @@
/// \file polarisation/Pol01/src/StepMax.cc
/// \brief Implementation of the StepMax class
//
// $Id: StepMax.cc 68753 2013-04-05 10:26:04Z gcosmo $
// $Id: StepMax.cc 98772 2016-08-09 14:25:31Z gcosmo $
//
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -34,17 +34,21 @@
#include "StepMax.hh"
#include "StepMaxMessenger.hh"
#include "G4ParticleDefinition.hh"
#include "G4Step.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
StepMax::StepMax(const G4String& processName)
: G4VDiscreteProcess(processName),MaxChargedStep(DBL_MAX)
: G4VDiscreteProcess(processName),
fMaxChargedStep(DBL_MAX), fMessenger(0)
{
pMess = new StepMaxMessenger(this);
fMessenger = new StepMaxMessenger(this);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
StepMax::~StepMax() { delete pMess; }
StepMax::~StepMax() { delete fMessenger; }
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -55,7 +59,7 @@ G4bool StepMax::IsApplicable(const G4ParticleDefinition& particle)
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void StepMax::SetMaxStep(G4double step) {MaxChargedStep = step;}
void StepMax::SetMaxStep(G4double step) {fMaxChargedStep = step;}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -68,10 +72,10 @@ G4double StepMax::PostStepGetPhysicalInteractionLength(const G4Track& aTrack,
G4double ProposedStep = DBL_MAX;
if((MaxChargedStep > 0.) &&
if((fMaxChargedStep > 0.) &&
(aTrack.GetVolume() != 0) &&
(aTrack.GetVolume()->GetName() != "World"))
ProposedStep = MaxChargedStep;
ProposedStep = fMaxChargedStep;
return ProposedStep;
}
@@ -86,5 +90,3 @@ G4VParticleChange* StepMax::PostStepDoIt(const G4Track& aTrack, const G4Step&)
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -26,7 +26,7 @@
/// \file polarisation/Pol01/src/StepMaxMessenger.cc
/// \brief Implementation of the StepMaxMessenger class
//
// $Id: StepMaxMessenger.cc 68753 2013-04-05 10:26:04Z gcosmo $
// $Id: StepMaxMessenger.cc 98772 2016-08-09 14:25:31Z gcosmo $
//
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -38,29 +38,30 @@
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
StepMaxMessenger::StepMaxMessenger(StepMax* stepM)
:pStepMax(stepM)
StepMaxMessenger::StepMaxMessenger(StepMax* stepMax)
: G4UImessenger(),
fStepMax(stepMax), fStepMaxCmd(0)
{
StepMaxCmd = new G4UIcmdWithADoubleAndUnit("/testem/stepMax",this);
StepMaxCmd->SetGuidance("Set max allowed step length");
StepMaxCmd->SetParameterName("mxStep",false);
StepMaxCmd->SetRange("mxStep>0.");
StepMaxCmd->SetUnitCategory("Length");
fStepMaxCmd = new G4UIcmdWithADoubleAndUnit("/testem/stepMax",this);
fStepMaxCmd->SetGuidance("Set max allowed step length");
fStepMaxCmd->SetParameterName("mxStep",false);
fStepMaxCmd->SetRange("mxStep>0.");
fStepMaxCmd->SetUnitCategory("Length");
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
StepMaxMessenger::~StepMaxMessenger()
{
delete StepMaxCmd;
delete fStepMaxCmd;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void StepMaxMessenger::SetNewValue(G4UIcommand* command, G4String newValue)
{
if (command == StepMaxCmd)
{ pStepMax->SetMaxStep(StepMaxCmd->GetNewDoubleValue(newValue));}
if (command == fStepMaxCmd)
{ fStepMax->SetMaxStep(fStepMaxCmd->GetNewDoubleValue(newValue));}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -26,7 +26,7 @@
/// \file polarisation/Pol01/src/SteppingAction.cc
/// \brief Implementation of the SteppingAction class
//
// $Id: SteppingAction.cc 86418 2014-11-11 10:39:38Z gcosmo $
// $Id: SteppingAction.cc 98772 2016-08-09 14:25:31Z gcosmo $
//
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -42,8 +42,9 @@
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
SteppingAction::SteppingAction(DetectorConstruction* det,
PrimaryGeneratorAction* prim, RunAction* RuAct)
: detector(det), primary(prim), runAction(RuAct)
PrimaryGeneratorAction* prim, RunAction* ruAct)
: G4UserSteppingAction(),
fDetector(det), fPrimary(prim), fRunAction(ruAct)
{ }
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -59,10 +60,10 @@ void SteppingAction::UserSteppingAction(const G4Step* aStep)
G4StepPoint* endPoint = aStep->GetPostStepPoint();
G4String procName = endPoint->GetProcessDefinedStep()->GetProcessName();
runAction->CountProcesses(procName);
fRunAction->CountProcesses(procName);
if (prePoint->GetTouchableHandle()->GetVolume()==detector->GetBox() &&
endPoint->GetTouchableHandle()->GetVolume()==detector->GetWorld()) {
if (prePoint->GetTouchableHandle()->GetVolume()==fDetector->GetBox() &&
endPoint->GetTouchableHandle()->GetVolume()==fDetector->GetWorld()) {
G4Track* aTrack = aStep->GetTrack();
const G4ParticleDefinition* part =
aTrack->GetDynamicParticle()->GetDefinition();
@@ -72,7 +73,7 @@ void SteppingAction::UserSteppingAction(const G4Step* aStep)
G4double kinEnergy = endPoint->GetKineticEnergy();
G4ThreeVector beamDirection =
primary->GetParticleGun()->GetParticleMomentumDirection();
fPrimary->GetParticleGun()->GetParticleMomentumDirection();
G4double polZ = endPoint->GetPolarization().z();
G4double costheta = direction*beamDirection;
@@ -83,10 +84,8 @@ void SteppingAction::UserSteppingAction(const G4Step* aStep)
direction*G4PolarizationHelper::GetParticleFrameY(beamDirection);
G4double phi=std::atan2(ydir,xdir);
runAction->FillData(part,kinEnergy,costheta,phi,polZ);
fRunAction->FillData(part,kinEnergy,costheta,phi,polZ);
}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......