Import Geant4 9.6.0 source tree

This commit is contained in:
Gabriele Cosmo
2016-06-09 17:01:34 +02:00
parent b1eb5424d2
commit e2d2f9810a
10384 changed files with 698580 additions and 628834 deletions
@@ -23,8 +23,10 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: DetectorConstruction.cc,v 1.15 2009-01-22 17:41:43 vnivanch Exp $
// GEANT4 tag $Name: not supported by cvs2svn $
/// \file electromagnetic/TestEm5/src/DetectorConstruction.cc
/// \brief Implementation of the DetectorConstruction class
//
// $Id$
//
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -47,18 +49,21 @@
#include "G4NistManager.hh"
#include "G4RunManager.hh"
#include "G4PhysicalConstants.hh"
#include "G4SystemOfUnits.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
DetectorConstruction::DetectorConstruction()
:AbsorberMaterial(0),WorldMaterial(0),defaultWorld(true),
solidWorld(0),logicWorld(0),physiWorld(0),
solidAbsorber(0),logicAbsorber(0),physiAbsorber(0),
magField(0)
:fAbsorberMaterial(0),fWorldMaterial(0),fDefaultWorld(true),
fSolidWorld(0),fLogicWorld(0),fPhysiWorld(0),
fSolidAbsorber(0),fLogicAbsorber(0),fPhysiAbsorber(0),
fMagField(0)
{
// default parameter values of the calorimeter
AbsorberThickness = 1.*cm;
AbsorberSizeYZ = 2.*cm;
XposAbs = 0.*cm;
fAbsorberThickness = 1.*cm;
fAbsorberSizeYZ = 2.*cm;
fXposAbs = 0.*cm;
ComputeCalorParameters();
// materials
@@ -67,14 +72,14 @@ DetectorConstruction::DetectorConstruction()
SetAbsorberMaterial("Silicon");
// create commands for interactive definition of the calorimeter
detectorMessenger = new DetectorMessenger(this);
fDetectorMessenger = new DetectorMessenger(this);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
DetectorConstruction::~DetectorConstruction()
{
delete detectorMessenger;
delete fDetectorMessenger;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -159,7 +164,7 @@ void DetectorConstruction::DefineMaterials()
G4Material* Air20 =
new G4Material("Air20", density= 1.205*mg/cm3, ncomponents=2,
kStateGas, 293.*kelvin, 1.*atmosphere);
kStateGas, 293.*kelvin, 1.*atmosphere);
Air20->AddElement(N, fractionmass=0.7);
Air20->AddElement(O, fractionmass=0.3);
@@ -189,11 +194,11 @@ void DetectorConstruction::DefineMaterials()
// examples of gas
//
new G4Material("ArgonGas", z=18, a=39.948*g/mole, density= 1.782*mg/cm3,
kStateGas, 273.15*kelvin, 1*atmosphere);
kStateGas, 273.15*kelvin, 1*atmosphere);
new G4Material("XenonGas", z=54, a=131.29*g/mole, density= 5.458*mg/cm3,
kStateGas, 293.15*kelvin, 1*atmosphere);
kStateGas, 293.15*kelvin, 1*atmosphere);
G4Material* CO2 =
new G4Material("CarbonicGas", density= 1.977*mg/cm3, ncomponents=2);
CO2->AddElement(C, natoms=1);
@@ -219,7 +224,7 @@ void DetectorConstruction::DefineMaterials()
G4Material* XeCH =
new G4Material("XenonMethanePropane", density= 4.9196*mg/cm3, ncomponents=3,
kStateGas, 293.15*kelvin, 1*atmosphere);
kStateGas, 293.15*kelvin, 1*atmosphere);
XeCH->AddElement (Xe, natoms=875);
XeCH->AddElement (C, natoms=225);
XeCH->AddElement (H, natoms=700);
@@ -237,7 +242,7 @@ void DetectorConstruction::DefineMaterials()
pressure = 3.e-18*pascal;
temperature = 2.73*kelvin;
new G4Material("Galactic", z=1, a=1.01*g/mole,density,
kStateGas,temperature,pressure);
kStateGas,temperature,pressure);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -245,12 +250,12 @@ void DetectorConstruction::DefineMaterials()
void DetectorConstruction::ComputeCalorParameters()
{
// Compute derived parameters of the calorimeter
xstartAbs = XposAbs-0.5*AbsorberThickness;
xendAbs = XposAbs+0.5*AbsorberThickness;
fXstartAbs = fXposAbs-0.5*fAbsorberThickness;
fXendAbs = fXposAbs+0.5*fAbsorberThickness;
if (defaultWorld) {
WorldSizeX = 1.5*AbsorberThickness; WorldSizeYZ= 1.2*AbsorberSizeYZ;
}
if (fDefaultWorld) {
fWorldSizeX = 1.5*fAbsorberThickness; fWorldSizeYZ= 1.2*fAbsorberSizeYZ;
}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -269,35 +274,35 @@ G4VPhysicalVolume* DetectorConstruction::ConstructCalorimeter()
// World
//
solidWorld = new G4Box("World", //its name
WorldSizeX/2,WorldSizeYZ/2,WorldSizeYZ/2); //its size
fSolidWorld = new G4Box("World", //its name
fWorldSizeX/2,fWorldSizeYZ/2,fWorldSizeYZ/2); //its size
logicWorld = new G4LogicalVolume(solidWorld, //its solid
WorldMaterial, //its material
"World"); //its name
fLogicWorld = new G4LogicalVolume(fSolidWorld, //its solid
fWorldMaterial, //its material
"World"); //its name
physiWorld = new G4PVPlacement(0, //no rotation
G4ThreeVector(), //at (0,0,0)
logicWorld, //its logical volume
"World", //its name
0, //its mother volume
false, //no boolean operation
0); //copy number
fPhysiWorld = new G4PVPlacement(0, //no rotation
G4ThreeVector(), //at (0,0,0)
fLogicWorld, //its logical volume
"World", //its name
0, //its mother volume
false, //no boolean operation
0); //copy number
// Absorber
//
solidAbsorber = new G4Box("Absorber",
AbsorberThickness/2,AbsorberSizeYZ/2,AbsorberSizeYZ/2);
fSolidAbsorber = new G4Box("Absorber",
fAbsorberThickness/2,fAbsorberSizeYZ/2,fAbsorberSizeYZ/2);
logicAbsorber = new G4LogicalVolume(solidAbsorber, //its solid
AbsorberMaterial, //its material
"Absorber"); //its name
physiAbsorber = new G4PVPlacement(0, //no rotation
G4ThreeVector(XposAbs,0.,0.), //its position
logicAbsorber, //its logical volume
"Absorber", //its name
logicWorld, //its mother
fLogicAbsorber = new G4LogicalVolume(fSolidAbsorber, //its solid
fAbsorberMaterial, //its material
"Absorber"); //its name
fPhysiAbsorber = new G4PVPlacement(0, //no rotation
G4ThreeVector(fXposAbs,0.,0.), //its position
fLogicAbsorber, //its logical volume
"Absorber", //its name
fLogicWorld, //its mother
false, //no boulean operat
0); //copy number
@@ -305,27 +310,27 @@ G4VPhysicalVolume* DetectorConstruction::ConstructCalorimeter()
//always return the physical World
//
return physiWorld;
return fPhysiWorld;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void DetectorConstruction::PrintCalorParameters()
{
G4cout << "\n" << WorldMaterial << G4endl;
G4cout << "\n" << AbsorberMaterial << G4endl;
G4cout << "\n" << fWorldMaterial << G4endl;
G4cout << "\n" << fAbsorberMaterial << G4endl;
G4cout << "\n The WORLD is made of " << G4BestUnit(WorldSizeX,"Length")
<< " of " << WorldMaterial->GetName();
G4cout << "\n The WORLD is made of " << G4BestUnit(fWorldSizeX,"Length")
<< " of " << fWorldMaterial->GetName();
G4cout << ". The transverse size (YZ) of the world is "
<< G4BestUnit(WorldSizeYZ,"Length") << G4endl;
<< G4BestUnit(fWorldSizeYZ,"Length") << G4endl;
G4cout << " The ABSORBER is made of "
<<G4BestUnit(AbsorberThickness,"Length")
<< " of " << AbsorberMaterial->GetName();
<<G4BestUnit(fAbsorberThickness,"Length")
<< " of " << fAbsorberMaterial->GetName();
G4cout << ". The transverse size (YZ) is "
<< G4BestUnit(AbsorberSizeYZ,"Length") << G4endl;
<< G4BestUnit(fAbsorberSizeYZ,"Length") << G4endl;
G4cout << " X position of the middle of the absorber "
<< G4BestUnit(XposAbs,"Length");
<< G4BestUnit(fXposAbs,"Length");
G4cout << G4endl;
}
@@ -337,9 +342,9 @@ void DetectorConstruction::SetAbsorberMaterial(G4String materialChoice)
G4Material* pttoMaterial =
G4NistManager::Instance()->FindOrBuildMaterial(materialChoice);
if (pttoMaterial && AbsorberMaterial != pttoMaterial) {
AbsorberMaterial = pttoMaterial;
if(logicAbsorber) logicAbsorber->SetMaterial(AbsorberMaterial);
if (pttoMaterial && fAbsorberMaterial != pttoMaterial) {
fAbsorberMaterial = pttoMaterial;
if(fLogicAbsorber) fLogicAbsorber->SetMaterial(fAbsorberMaterial);
G4RunManager::GetRunManager()->PhysicsHasBeenModified();
}
}
@@ -352,9 +357,9 @@ void DetectorConstruction::SetWorldMaterial(G4String materialChoice)
G4Material* pttoMaterial =
G4NistManager::Instance()->FindOrBuildMaterial(materialChoice);
if (pttoMaterial && WorldMaterial != pttoMaterial) {
WorldMaterial = pttoMaterial;
if(logicWorld) logicWorld->SetMaterial(WorldMaterial);
if (pttoMaterial && fWorldMaterial != pttoMaterial) {
fWorldMaterial = pttoMaterial;
if(fLogicWorld) fLogicWorld->SetMaterial(fWorldMaterial);
G4RunManager::GetRunManager()->PhysicsHasBeenModified();
}
}
@@ -363,7 +368,7 @@ void DetectorConstruction::SetWorldMaterial(G4String materialChoice)
void DetectorConstruction::SetAbsorberThickness(G4double val)
{
AbsorberThickness = val;
fAbsorberThickness = val;
G4RunManager::GetRunManager()->GeometryHasBeenModified();
}
@@ -371,7 +376,7 @@ void DetectorConstruction::SetAbsorberThickness(G4double val)
void DetectorConstruction::SetAbsorberSizeYZ(G4double val)
{
AbsorberSizeYZ = val;
fAbsorberSizeYZ = val;
G4RunManager::GetRunManager()->GeometryHasBeenModified();
}
@@ -379,8 +384,8 @@ void DetectorConstruction::SetAbsorberSizeYZ(G4double val)
void DetectorConstruction::SetWorldSizeX(G4double val)
{
WorldSizeX = val;
defaultWorld = false;
fWorldSizeX = val;
fDefaultWorld = false;
G4RunManager::GetRunManager()->GeometryHasBeenModified();
}
@@ -388,8 +393,8 @@ void DetectorConstruction::SetWorldSizeX(G4double val)
void DetectorConstruction::SetWorldSizeYZ(G4double val)
{
WorldSizeYZ = val;
defaultWorld = false;
fWorldSizeYZ = val;
fDefaultWorld = false;
G4RunManager::GetRunManager()->GeometryHasBeenModified();
}
@@ -397,7 +402,7 @@ void DetectorConstruction::SetWorldSizeYZ(G4double val)
void DetectorConstruction::SetAbsorberXpos(G4double val)
{
XposAbs = val;
fXposAbs = val;
G4RunManager::GetRunManager()->GeometryHasBeenModified();
}
@@ -412,15 +417,15 @@ void DetectorConstruction::SetMagField(G4double fieldValue)
G4FieldManager* fieldMgr
= G4TransportationManager::GetTransportationManager()->GetFieldManager();
if(magField) delete magField; //delete the existing magn field
if(fMagField) delete fMagField; //delete the existing magn field
if(fieldValue!=0.) // create a new one if non nul
{ magField = new G4UniformMagField(G4ThreeVector(0.,0.,fieldValue));
fieldMgr->SetDetectorField(magField);
fieldMgr->CreateChordFinder(magField);
if(fieldValue!=0.) // create a new one if non nul
{ fMagField = new G4UniformMagField(G4ThreeVector(0.,0.,fieldValue));
fieldMgr->SetDetectorField(fMagField);
fieldMgr->CreateChordFinder(fMagField);
} else {
magField = NULL;
fieldMgr->SetDetectorField(magField);
fMagField = NULL;
fieldMgr->SetDetectorField(fMagField);
}
}
@@ -23,8 +23,10 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: DetectorMessenger.cc,v 1.4 2006-06-29 16:55:32 gunter Exp $
// GEANT4 tag $Name: not supported by cvs2svn $
/// \file electromagnetic/TestEm5/src/DetectorMessenger.cc
/// \brief Implementation of the DetectorMessenger class
//
// $Id$
//
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -41,70 +43,70 @@
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
DetectorMessenger::DetectorMessenger(DetectorConstruction * Det)
:Detector(Det)
:fDetector(Det)
{
testemDir = new G4UIdirectory("/testem/");
testemDir->SetGuidance("UI commands specific to this example.");
fTestemDir = new G4UIdirectory("/testem/");
fTestemDir->SetGuidance("UI commands specific to this example.");
detDir = new G4UIdirectory("/testem/det/");
detDir->SetGuidance("detector construction commands");
fDetDir = new G4UIdirectory("/testem/det/");
fDetDir->SetGuidance("detector construction commands");
AbsMaterCmd = new G4UIcmdWithAString("/testem/det/setAbsMat",this);
AbsMaterCmd->SetGuidance("Select Material of the Absorber.");
AbsMaterCmd->SetParameterName("choice",false);
AbsMaterCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
fAbsMaterCmd = new G4UIcmdWithAString("/testem/det/setAbsMat",this);
fAbsMaterCmd->SetGuidance("Select Material of the Absorber.");
fAbsMaterCmd->SetParameterName("choice",false);
fAbsMaterCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
WorldMaterCmd = new G4UIcmdWithAString("/testem/det/setWorldMat",this);
WorldMaterCmd->SetGuidance("Select Material of the World.");
WorldMaterCmd->SetParameterName("wchoice",false);
WorldMaterCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
fWorldMaterCmd = new G4UIcmdWithAString("/testem/det/setWorldMat",this);
fWorldMaterCmd->SetGuidance("Select Material of the World.");
fWorldMaterCmd->SetParameterName("wchoice",false);
fWorldMaterCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
AbsThickCmd = new G4UIcmdWithADoubleAndUnit("/testem/det/setAbsThick",this);
AbsThickCmd->SetGuidance("Set Thickness of the Absorber");
AbsThickCmd->SetParameterName("SizeZ",false);
AbsThickCmd->SetRange("SizeZ>0.");
AbsThickCmd->SetUnitCategory("Length");
AbsThickCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
fAbsThickCmd = new G4UIcmdWithADoubleAndUnit("/testem/det/setAbsThick",this);
fAbsThickCmd->SetGuidance("Set Thickness of the Absorber");
fAbsThickCmd->SetParameterName("SizeZ",false);
fAbsThickCmd->SetRange("SizeZ>0.");
fAbsThickCmd->SetUnitCategory("Length");
fAbsThickCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
AbsSizYZCmd = new G4UIcmdWithADoubleAndUnit("/testem/det/setAbsYZ",this);
AbsSizYZCmd->SetGuidance("Set sizeYZ of the Absorber");
AbsSizYZCmd->SetParameterName("SizeYZ",false);
AbsSizYZCmd->SetRange("SizeYZ>0.");
AbsSizYZCmd->SetUnitCategory("Length");
AbsSizYZCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
fAbsSizYZCmd = new G4UIcmdWithADoubleAndUnit("/testem/det/setAbsYZ",this);
fAbsSizYZCmd->SetGuidance("Set sizeYZ of the Absorber");
fAbsSizYZCmd->SetParameterName("SizeYZ",false);
fAbsSizYZCmd->SetRange("SizeYZ>0.");
fAbsSizYZCmd->SetUnitCategory("Length");
fAbsSizYZCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
AbsXposCmd = new G4UIcmdWithADoubleAndUnit("/testem/det/setAbsXpos",this);
AbsXposCmd->SetGuidance("Set X pos. of the Absorber");
AbsXposCmd->SetParameterName("Xpos",false);
AbsXposCmd->SetUnitCategory("Length");
AbsXposCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
fAbsXposCmd = new G4UIcmdWithADoubleAndUnit("/testem/det/setAbsXpos",this);
fAbsXposCmd->SetGuidance("Set X pos. of the Absorber");
fAbsXposCmd->SetParameterName("Xpos",false);
fAbsXposCmd->SetUnitCategory("Length");
fAbsXposCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
WorldXCmd = new G4UIcmdWithADoubleAndUnit("/testem/det/setWorldX",this);
WorldXCmd->SetGuidance("Set X size of the World");
WorldXCmd->SetParameterName("WSizeX",false);
WorldXCmd->SetRange("WSizeX>0.");
WorldXCmd->SetUnitCategory("Length");
WorldXCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
fWorldXCmd = new G4UIcmdWithADoubleAndUnit("/testem/det/setWorldX",this);
fWorldXCmd->SetGuidance("Set X size of the World");
fWorldXCmd->SetParameterName("WSizeX",false);
fWorldXCmd->SetRange("WSizeX>0.");
fWorldXCmd->SetUnitCategory("Length");
fWorldXCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
WorldYZCmd = new G4UIcmdWithADoubleAndUnit("/testem/det/setWorldYZ",this);
WorldYZCmd->SetGuidance("Set sizeYZ of the World");
WorldYZCmd->SetParameterName("WSizeYZ",false);
WorldYZCmd->SetRange("WSizeYZ>0.");
WorldYZCmd->SetUnitCategory("Length");
WorldYZCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
fWorldYZCmd = new G4UIcmdWithADoubleAndUnit("/testem/det/setWorldYZ",this);
fWorldYZCmd->SetGuidance("Set sizeYZ of the World");
fWorldYZCmd->SetParameterName("WSizeYZ",false);
fWorldYZCmd->SetRange("WSizeYZ>0.");
fWorldYZCmd->SetUnitCategory("Length");
fWorldYZCmd->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);
MagFieldCmd = new G4UIcmdWithADoubleAndUnit("/testem/det/setField",this);
MagFieldCmd->SetGuidance("Define magnetic field.");
MagFieldCmd->SetGuidance("Magnetic field will be in Z direction.");
MagFieldCmd->SetParameterName("Bz",false);
MagFieldCmd->SetUnitCategory("Magnetic flux density");
MagFieldCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
fMagFieldCmd = new G4UIcmdWithADoubleAndUnit("/testem/det/setField",this);
fMagFieldCmd->SetGuidance("Define magnetic field.");
fMagFieldCmd->SetGuidance("Magnetic field will be in Z direction.");
fMagFieldCmd->SetParameterName("Bz",false);
fMagFieldCmd->SetUnitCategory("Magnetic flux density");
fMagFieldCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
}
@@ -112,49 +114,49 @@ DetectorMessenger::DetectorMessenger(DetectorConstruction * Det)
DetectorMessenger::~DetectorMessenger()
{
delete AbsMaterCmd;
delete AbsThickCmd;
delete AbsSizYZCmd;
delete AbsXposCmd;
delete WorldMaterCmd;
delete WorldXCmd;
delete WorldYZCmd;
delete UpdateCmd;
delete MagFieldCmd;
delete detDir;
delete testemDir;
delete fAbsMaterCmd;
delete fAbsThickCmd;
delete fAbsSizYZCmd;
delete fAbsXposCmd;
delete fWorldMaterCmd;
delete fWorldXCmd;
delete fWorldYZCmd;
delete fUpdateCmd;
delete fMagFieldCmd;
delete fDetDir;
delete fTestemDir;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void DetectorMessenger::SetNewValue(G4UIcommand* command,G4String newValue)
{
if ( command == AbsMaterCmd )
{Detector->SetAbsorberMaterial(newValue);}
if ( command == fAbsMaterCmd )
{fDetector->SetAbsorberMaterial(newValue);}
if ( command == WorldMaterCmd )
{Detector->SetWorldMaterial(newValue);}
if ( command == fWorldMaterCmd )
{fDetector->SetWorldMaterial(newValue);}
if ( command == AbsThickCmd )
{Detector->SetAbsorberThickness(AbsThickCmd->GetNewDoubleValue(newValue));}
if ( command == fAbsThickCmd )
{fDetector->SetAbsorberThickness(fAbsThickCmd->GetNewDoubleValue(newValue));}
if ( command == AbsSizYZCmd )
{Detector->SetAbsorberSizeYZ(AbsSizYZCmd->GetNewDoubleValue(newValue));}
if ( command == fAbsSizYZCmd )
{fDetector->SetAbsorberSizeYZ(fAbsSizYZCmd->GetNewDoubleValue(newValue));}
if ( command == AbsXposCmd )
{Detector->SetAbsorberXpos(AbsXposCmd->GetNewDoubleValue(newValue));}
if ( command == fAbsXposCmd )
{fDetector->SetAbsorberXpos(fAbsXposCmd->GetNewDoubleValue(newValue));}
if ( command == WorldXCmd )
{Detector->SetWorldSizeX(WorldXCmd->GetNewDoubleValue(newValue));}
if ( command == fWorldXCmd )
{fDetector->SetWorldSizeX(fWorldXCmd->GetNewDoubleValue(newValue));}
if ( command == WorldYZCmd )
{Detector->SetWorldSizeYZ(WorldYZCmd->GetNewDoubleValue(newValue));}
if ( command == fWorldYZCmd )
{fDetector->SetWorldSizeYZ(fWorldYZCmd->GetNewDoubleValue(newValue));}
if ( command == UpdateCmd )
{Detector->UpdateGeometry(); }
if ( command == fUpdateCmd )
{fDetector->UpdateGeometry(); }
if( command == MagFieldCmd )
{Detector->SetMagField(MagFieldCmd->GetNewDoubleValue(newValue));}
if( command == fMagFieldCmd )
{fDetector->SetMagField(fMagFieldCmd->GetNewDoubleValue(newValue));}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -23,8 +23,10 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: EventAction.cc,v 1.9 2010-06-07 05:40:46 perl Exp $
// GEANT4 tag $Name: not supported by cvs2svn $
/// \file electromagnetic/TestEm5/src/EventAction.cc
/// \brief Implementation of the EventAction class
//
// $Id$
//
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -32,25 +34,25 @@
#include "EventAction.hh"
#include "RunAction.hh"
#include "HistoManager.hh"
#include "EventMessenger.hh"
#include "HistoManager.hh"
#include "G4Event.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
EventAction::EventAction(RunAction* RA, HistoManager* histo)
:runaction(RA),histoManager(histo),
drawFlag("none"),printModulo(10000)
EventAction::EventAction(RunAction* RA)
:fRunAction(RA),
fDrawFlag("none"),fPrintModulo(10000)
{
eventMessenger = new EventMessenger(this);
fEventMessenger = new EventMessenger(this);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
EventAction::~EventAction()
{
delete eventMessenger;
delete fEventMessenger;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -60,31 +62,31 @@ void EventAction::BeginOfEventAction(const G4Event* evt)
G4int evtNb = evt->GetEventID();
//printing survey
if (evtNb%printModulo == 0)
if (evtNb%fPrintModulo == 0)
G4cout << "\n---> Begin of Event: " << evtNb << G4endl;
// initialisation per event
EnergyDeposit = 0.;
TrakLenCharged = TrakLenNeutral = 0.;
nbStepsCharged = nbStepsNeutral = 0;
TransmitFlag = ReflectFlag = 0;
fEnergyDeposit = 0.;
fTrakLenCharged = fTrakLenNeutral = 0.;
fNbStepsCharged = fNbStepsNeutral = 0;
fTransmitFlag = fReflectFlag = 0;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void EventAction::EndOfEventAction(const G4Event*)
{
runaction->AddEnergy(EnergyDeposit);
runaction->AddTrakLenCharg(TrakLenCharged);
runaction->AddTrakLenNeutr(TrakLenNeutral);
fRunAction->AddEnergy(fEnergyDeposit);
fRunAction->AddTrakLenCharg(fTrakLenCharged);
fRunAction->AddTrakLenNeutr(fTrakLenNeutral);
runaction->CountStepsCharg(nbStepsCharged);
runaction->CountStepsNeutr(nbStepsNeutral);
fRunAction->CountStepsCharg(fNbStepsCharged);
fRunAction->CountStepsNeutr(fNbStepsNeutral);
runaction->CountTransmit (TransmitFlag);
runaction->CountReflect (ReflectFlag);
fRunAction->CountTransmit (fTransmitFlag);
fRunAction->CountReflect (fReflectFlag);
histoManager->FillHisto(1,EnergyDeposit);
G4AnalysisManager::Instance()->FillH1(1,fEnergyDeposit);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -23,8 +23,10 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: EventMessenger.cc,v 1.5 2006-06-29 16:55:36 gunter Exp $
// GEANT4 tag $Name: not supported by cvs2svn $
/// \file electromagnetic/TestEm5/src/EventMessenger.cc
/// \brief Implementation of the EventMessenger class
//
// $Id$
//
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -39,33 +41,33 @@
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
EventMessenger::EventMessenger(EventAction* EvAct)
:eventAction(EvAct)
:fEventAction(EvAct)
{
eventDir = new G4UIdirectory("/testem/event/");
eventDir->SetGuidance("event control");
fEventDir = new G4UIdirectory("/testem/event/");
fEventDir->SetGuidance("event control");
DrawCmd = new G4UIcmdWithAString("/testem/event/drawTracks",this);
DrawCmd->SetGuidance("Draw the tracks in the event");
DrawCmd->SetGuidance(" Choice : none,charged,neutral,all");
DrawCmd->SetParameterName("choice",true);
DrawCmd->SetDefaultValue("all");
DrawCmd->SetCandidates("none charged neutral all");
DrawCmd->AvailableForStates(G4State_Idle);
fDrawCmd = new G4UIcmdWithAString("/testem/event/drawTracks",this);
fDrawCmd->SetGuidance("Draw the tracks in the event");
fDrawCmd->SetGuidance(" Choice : none,charged,neutral,all");
fDrawCmd->SetParameterName("choice",true);
fDrawCmd->SetDefaultValue("all");
fDrawCmd->SetCandidates("none charged neutral all");
fDrawCmd->AvailableForStates(G4State_Idle);
PrintCmd = new G4UIcmdWithAnInteger("/testem/event/printModulo",this);
PrintCmd->SetGuidance("Print events modulo n");
PrintCmd->SetParameterName("EventNb",false);
PrintCmd->SetRange("EventNb>0");
PrintCmd->AvailableForStates(G4State_Idle);
fPrintCmd = new G4UIcmdWithAnInteger("/testem/event/printModulo",this);
fPrintCmd->SetGuidance("Print events modulo n");
fPrintCmd->SetParameterName("EventNb",false);
fPrintCmd->SetRange("EventNb>0");
fPrintCmd->AvailableForStates(G4State_Idle);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
EventMessenger::~EventMessenger()
{
delete DrawCmd;
delete PrintCmd;
delete eventDir;
delete fDrawCmd;
delete fPrintCmd;
delete fEventDir;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -73,11 +75,11 @@ EventMessenger::~EventMessenger()
void EventMessenger::SetNewValue(G4UIcommand* command,
G4String newValue)
{
if(command == DrawCmd)
{eventAction->SetDrawFlag(newValue);}
if(command == fDrawCmd)
{fEventAction->SetDrawFlag(newValue);}
if(command == PrintCmd)
{eventAction->SetPrintModulo(PrintCmd->GetNewIntValue(newValue));}
if(command == fPrintCmd)
{fEventAction->SetPrintModulo(fPrintCmd->GetNewIntValue(newValue));}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -0,0 +1,805 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
/// \file electromagnetic/TestEm5/src/ExG4HbookAnalysisManager.cc
/// \brief Implementation of the ExG4HbookAnalysisManager class
//
// $Id$
//
/// \file ExG4HbookAnalysisManager.cc
/// \brief Implementation of the ExG4HbookAnalysisManager class
// Author: Ivana Hrivnacova, 15/06/2011 (ivana@ipno.in2p3.fr)
#ifdef G4_USE_HBOOK
#include "ExG4HbookAnalysisManager.hh"
#include "G4UnitsTable.hh"
#include <iostream>
extern "C" int setpawc();
extern "C" int setntuc();
ExG4HbookAnalysisManager* ExG4HbookAnalysisManager::fgInstance = 0;
const G4int ExG4HbookAnalysisManager::fgkDefaultH2HbookIdOffset = 100;
const G4int ExG4HbookAnalysisManager::fgkDefaultNtupleHbookId = 1;
const G4String ExG4HbookAnalysisManager::fgkDefaultNtupleDirectoryName = "ntuple";
//_____________________________________________________________________________
ExG4HbookAnalysisManager* ExG4HbookAnalysisManager::Instance()
{
if ( fgInstance == 0 ) {
fgInstance = new ExG4HbookAnalysisManager();
}
return fgInstance;
}
//_____________________________________________________________________________
ExG4HbookAnalysisManager::ExG4HbookAnalysisManager()
: G4VAnalysisManager("Hbook"),
fH1HbookIdOffset(-1),
fH2HbookIdOffset(-1),
fNtupleHbookId(-1),
fFile(0),
fH1Vector(),
fH1MapByName(),
fH2Vector(),
fH2MapByName(),
fNtupleName(),
fNtupleTitle(),
fNtuple(0),
fNtupleIColumnMap(),
fNtupleFColumnMap(),
fNtupleDColumnMap()
{
if ( fgInstance ) {
G4ExceptionDescription description;
description << " "
<< "G4HbookAnalysisManager already exists."
<< "Cannot create another instance.";
G4Exception("G4HbookAnalysisManager::G4HbookAnalysisManager()",
"Analysis_F001", FatalException, description);
}
fgInstance = this;
// Initialize HBOOK :
tools::hbook::CHLIMIT(setpawc());
setntuc(); //for ntuple.
}
//_____________________________________________________________________________
ExG4HbookAnalysisManager::~ExG4HbookAnalysisManager()
{
std::vector<tools::hbook::h1*>::iterator it;
for ( it = fH1Vector.begin(); it != fH1Vector.end(); it++ ) {
delete *it;
}
std::vector<tools::hbook::h2*>::iterator it2;
for ( it2 = fH2Vector.begin(); it2 != fH2Vector.end(); it2++ ) {
delete *it2;
}
delete fNtuple;
delete fFile;
fgInstance = 0;
}
//
// private methods
//
//_____________________________________________________________________________
tools::hbook::wntuple::column<int>*
ExG4HbookAnalysisManager::GetNtupleIColumn(G4int id) const
{
std::map<G4int, tools::hbook::wntuple::column<int>* >::const_iterator it
= fNtupleIColumnMap.find(id);
if ( it == fNtupleIColumnMap.end() ) {
G4ExceptionDescription description;
description << " " << "column " << id << " does not exist.";
G4Exception("G4HbookAnalysisManager::GetNtupleIColumn()",
"Analysis_W009", JustWarning, description);
return 0;
}
return it->second;
}
//_____________________________________________________________________________
tools::hbook::wntuple::column<float>*
ExG4HbookAnalysisManager::GetNtupleFColumn(G4int id) const
{
std::map<G4int, tools::hbook::wntuple::column<float>* >::const_iterator it
= fNtupleFColumnMap.find(id);
if ( it == fNtupleFColumnMap.end() ) {
G4ExceptionDescription description;
description << " " << "column " << id << " does not exist.";
G4Exception("G4HbookAnalysisManager::GetNtupleFColumn()",
"Analysis_W009", JustWarning, description);
return 0;
}
return it->second;
}
//_____________________________________________________________________________
tools::hbook::wntuple::column<double>*
ExG4HbookAnalysisManager::GetNtupleDColumn(G4int id) const
{
std::map<G4int, tools::hbook::wntuple::column<double>* >::const_iterator it
= fNtupleDColumnMap.find(id);
if ( it == fNtupleDColumnMap.end() ) {
G4ExceptionDescription description;
description << " " << "column " << id << " does not exist.";
G4Exception("G4HbookAnalysisManager::GetNtupleDColumn()",
"Analysis_W009", JustWarning, description);
return 0;
}
return it->second;
}
//
// public methods
//
//_____________________________________________________________________________
G4bool ExG4HbookAnalysisManager::OpenFile(const G4String& fileName)
{
G4String name(fileName);
if ( name.find(".") == std::string::npos ) {
name.append(".");
name.append(GetFileType());
}
#ifdef G4VERBOSE
if ( fpVerboseL3 )
fpVerboseL3->Message("open", "analysis file", name);
#endif
tools::hbook::CHCDIR("//PAWC"," ");
unsigned int unit = 1;
fFile = new tools::hbook::wfile(std::cout, name, unit);
if ( ! fFile->is_valid() ) {
G4ExceptionDescription description;
description << " " << "Cannot open file " << fileName;
G4Exception("G4HbookAnalysisManager::OpenFile()",
"Analysis_W001", JustWarning, description);
return false;
}
// At this point, in HBOOK, we should have :
// - created a //LUN1 directory attached to the file
// - created a //PAWC/LUN1 in memory
// - be in the directory //PAWC/LUN1.
// create an "histo" HBOOK directory both in memory and in the file :
if ( fHistoDirectoryName != "" ) {
tools::hbook::CHCDIR("//PAWC/LUN1"," ");
tools::hbook::CHMDIR(fHistoDirectoryName.data()," ");
tools::hbook::CHCDIR("//LUN1"," ");
tools::hbook::CHMDIR(fHistoDirectoryName.data()," ");
}
fLockHistoDirectoryName = true;
// the five upper lines could have been done with :
//fFile->cd_home();
//fFile->mkcd("histo");
#ifdef G4VERBOSE
if ( fpVerboseL1 )
fpVerboseL1->Message("open", "analysis file", name);
#endif
return true;
}
//_____________________________________________________________________________
G4bool ExG4HbookAnalysisManager::Write()
{
#ifdef G4VERBOSE
if ( fpVerboseL3 )
fpVerboseL3->Message("write", "file", "");
#endif
// ntuple
//if ( fNtuple ) fNtuple->add_row_end();
G4bool result = fFile->write();
#ifdef G4VERBOSE
if ( fpVerboseL1 )
fpVerboseL1->Message("write", "file", "", result);
#endif
return result;
}
//_____________________________________________________________________________
G4bool ExG4HbookAnalysisManager::CloseFile()
{
#ifdef G4VERBOSE
if ( fpVerboseL3 )
fpVerboseL3->Message("close", "file", "");
#endif
//WARNING : have to delete the ntuple before closing the file.
delete fNtuple;
fNtuple = 0;
G4bool result = fFile->close();
#ifdef G4VERBOSE
if ( fpVerboseL1 )
fpVerboseL1->Message("close", "file", "", result);
#endif
return result;
}
//_____________________________________________________________________________
G4int ExG4HbookAnalysisManager::CreateH1(const G4String& name, const G4String& title,
G4int nbins, G4double xmin, G4double xmax)
{
#ifdef G4VERBOSE
if ( fpVerboseL3 )
fpVerboseL3->Message("create", "H1", name);
#endif
// Go to histograms directory
if ( fHistoDirectoryName != "" ) {
G4String histoPath = "//PAWC/LUN1/";
histoPath.append(fHistoDirectoryName.data());
tools::hbook::CHCDIR(histoPath.data()," ");
}
// Set fH1HbookIdOffset if needed
if ( fH1Vector.size() == 0 ) {
if ( fH1HbookIdOffset == -1 ) {
if ( fFirstHistoId > 0 )
fH1HbookIdOffset = 0;
else
fH1HbookIdOffset = 1;
if ( fH1HbookIdOffset > 0 ) {
G4ExceptionDescription description;
description << "H1 will be defined in HBOOK with ID = G4_firstHistoId + 1";
G4Exception("ExG4HbookAnalysisManager::CreateH1()",
"Analysis_W011", JustWarning, description);
}
}
}
// Create histogram
G4int index = fH1Vector.size();
G4int hbookIndex = fH1HbookIdOffset + fH1Vector.size() + fFirstHistoId;
tools::hbook::h1* h1 = new tools::hbook::h1(hbookIndex, title, nbins, xmin, xmax);
fH1Vector.push_back(h1);
fH1MapByName[name] = h1;
if ( fHistoDirectoryName != "" ) {
// Return to //PAWC/LUN1 :
tools::hbook::CHCDIR("//PAWC/LUN1"," ");
}
fLockFirstHistoId = true;
#ifdef G4VERBOSE
if ( fpVerboseL1 ) {
G4ExceptionDescription description;
description << " name : " << name << " hbook index : " << hbookIndex;
fpVerboseL1->Message("create", "H1", description);
}
#endif
return index + fFirstHistoId;
}
//_____________________________________________________________________________
G4int ExG4HbookAnalysisManager::CreateH2(const G4String& name, const G4String& title,
G4int nxbins, G4double xmin, G4double xmax,
G4int nybins, G4double ymin, G4double ymax)
{
#ifdef G4VERBOSE
if ( fpVerboseL3 )
fpVerboseL3->Message("create", "H2", name);
#endif
// Go to histograms directory
if ( fHistoDirectoryName != "" ) {
G4String histoPath = "//PAWC/LUN1/";
histoPath.append(fHistoDirectoryName.data());
tools::hbook::CHCDIR(histoPath.data()," ");
}
// Set fH2HbookIdOffset if needed
if ( fH2Vector.size() == 0 ) {
if ( fH2HbookIdOffset == -1 ) {
if ( fFirstHistoId > 0 )
fH2HbookIdOffset = fgkDefaultH2HbookIdOffset;
else
fH2HbookIdOffset = fgkDefaultH2HbookIdOffset + 1;
if ( fH2HbookIdOffset != fgkDefaultH2HbookIdOffset ) {
G4ExceptionDescription description;
description
<< "H2 will be defined in HBOOK with ID = "
<< fgkDefaultH2HbookIdOffset << " + G4_firstHistoId + 1";
G4Exception("ExG4HbookAnalysisManager::CreateH2()",
"Analysis_W011", JustWarning, description);
}
}
}
G4int index = fH2Vector.size();
G4int hbookIndex = fH2HbookIdOffset + fH2Vector.size() + fFirstHistoId;
tools::hbook::h2* h2
= new tools::hbook::h2(hbookIndex, title, nxbins, xmin, xmax, nybins, ymin, ymax);
fH2Vector.push_back(h2);
fH2MapByName[name] = h2;
// Return to //PAWC/LUN1 :
if ( fHistoDirectoryName != "" ) {
tools::hbook::CHCDIR("//PAWC/LUN1"," ");
}
fLockFirstHistoId = true;
#ifdef G4VERBOSE
if ( fpVerboseL1 ) {
G4ExceptionDescription description;
description << " name : " << name << " hbook index : " << hbookIndex;
fpVerboseL1->Message("create", "H2", description);
}
#endif
return index + fFirstHistoId;
}
//_____________________________________________________________________________
void ExG4HbookAnalysisManager::CreateNtuple(const G4String& name,
const G4String& title)
{
#ifdef G4VERBOSE
if ( fpVerboseL3 )
fpVerboseL3->Message("create", "ntuple", name);
#endif
if ( fNtuple ) {
G4ExceptionDescription description;
description << " "
<< "Ntuple already exists. "
<< "(Only one ntuple is currently supported.)";
G4Exception("G4HbookAnalysisManager::CreateNtuple()",
"Analysis_W006", JustWarning, description);
return;
}
// Create an "ntuple" directory both in memory and in the file
fFile->cd_home(); //go under //PAWC/LUN1
if ( fNtupleDirectoryName == "" )
fFile->mkcd(fgkDefaultNtupleDirectoryName.data());
else
fFile->mkcd(fNtupleDirectoryName.data());
// Define ntuple ID in HBOOK
if ( fNtupleHbookId == -1 ) fNtupleHbookId = fgkDefaultNtupleHbookId;
// We should be under //PAWC/LUN1/ntuple
fNtuple = new tools::hbook::wntuple(fNtupleHbookId, name);
fNtupleName = name;
fNtupleTitle = title;
#ifdef G4VERBOSE
if ( fpVerboseL1 ) {
G4ExceptionDescription description;
description << " name : " << name << " hbook index : " << fNtupleHbookId;
fpVerboseL1->Message("create", "ntuple", description);
}
#endif
}
//_____________________________________________________________________________
G4int ExG4HbookAnalysisManager::CreateNtupleIColumn(const G4String& name)
{
#ifdef G4VERBOSE
if ( fpVerboseL3 )
fpVerboseL3->Message("create", "ntuple I column", name);
#endif
G4int index = fNtuple->columns().size();
tools::hbook::wntuple::column<int>* column = fNtuple->create_column<int>(name);
fNtupleIColumnMap[index] = column;
fLockFirstNtupleColumnId = true;
#ifdef G4VERBOSE
if ( fpVerboseL1 )
fpVerboseL1->Message("create", "ntuple I column", name);
#endif
return index + fFirstNtupleColumnId;
}
//_____________________________________________________________________________
G4int ExG4HbookAnalysisManager::CreateNtupleFColumn(const G4String& name)
{
#ifdef G4VERBOSE
if ( fpVerboseL3 )
fpVerboseL3->Message("create", "ntuple F column", name);
#endif
G4int index = fNtuple->columns().size();
tools::hbook::wntuple::column<float>* column = fNtuple->create_column<float>(name);
fNtupleFColumnMap[index] = column;
fLockFirstNtupleColumnId = true;
#ifdef G4VERBOSE
if ( fpVerboseL1 )
fpVerboseL1->Message("create", "ntuple F column", name);
#endif
return index + fFirstNtupleColumnId;
}
//_____________________________________________________________________________
G4int ExG4HbookAnalysisManager::CreateNtupleDColumn(const G4String& name)
{
#ifdef G4VERBOSE
if ( fpVerboseL3 )
fpVerboseL3->Message("create", "ntuple D column", name);
#endif
G4int index = fNtuple->columns().size();
tools::hbook::wntuple::column<double>* column = fNtuple->create_column<double>(name);
fNtupleDColumnMap[index] = column;
fLockFirstNtupleColumnId = true;
#ifdef G4VERBOSE
if ( fpVerboseL1 )
fpVerboseL1->Message("create", "ntuple D column", name);
#endif
return index + fFirstNtupleColumnId;
}
//_____________________________________________________________________________
void ExG4HbookAnalysisManager::FinishNtuple()
{
#ifdef G4VERBOSE
if ( fpVerboseL3 )
fpVerboseL3->Message("finish", "ntuple", fNtupleName);
#endif
// Return to //PAWC/LUN1 :
tools::hbook::CHCDIR("//PAWC/LUN1"," ");
//fNtuple->add_row_beg();
#ifdef G4VERBOSE
if ( fpVerboseL1 )
fpVerboseL1->Message("finish", "ntuple", fNtupleName);
#endif
}
//_____________________________________________________________________________
G4bool ExG4HbookAnalysisManager::FillH1(G4int id, G4double value, G4double weight)
{
#ifdef G4VERBOSE
if ( fpVerboseL3 ) {
G4ExceptionDescription description;
description << " id " << id << " value " << value;
fpVerboseL3->Message("fill", "H1", description);
}
#endif
tools::hbook::h1* h1 = GetH1(id);
if ( ! h1 ) {
G4ExceptionDescription description;
description << " " << "histogram " << id << " does not exist.";
G4Exception("G4HbookAnalysisManager::FillH1()",
"Analysis_W007", JustWarning, description);
return false;
}
h1->fill(value, weight);
#ifdef G4VERBOSE
if ( fpVerboseL2 ) {
G4ExceptionDescription description;
description << " id " << id << " value " << value;
fpVerboseL2->Message("fill", "H1", description);
}
#endif
return true;
}
//_____________________________________________________________________________
G4bool ExG4HbookAnalysisManager::FillH2(G4int id,
G4double xvalue, G4double yvalue,
G4double weight)
{
#ifdef G4VERBOSE
if ( fpVerboseL3 ) {
G4ExceptionDescription description;
description << " id " << id
<< " xvalue " << xvalue << " yvalue " << yvalue;
fpVerboseL3->Message("fill", "H2", description);
}
#endif
tools::hbook::h2* h2 = GetH2(id);
if ( ! h2 ) {
G4ExceptionDescription description;
description << " " << "histogram " << id << " does not exist.";
G4Exception("G4HbookAnalysisManager::FillH2()",
"Analysis_W007", JustWarning, description);
return false;
}
h2->fill(xvalue, yvalue, weight);
#ifdef G4VERBOSE
if ( fpVerboseL2 ) {
G4ExceptionDescription description;
description << " id " << id
<< " xvalue " << xvalue << " yvalue " << yvalue;
fpVerboseL2->Message("fill", "H2", description);
}
#endif
return true;
}
//_____________________________________________________________________________
G4bool ExG4HbookAnalysisManager::FillNtupleIColumn(G4int id, G4int value)
{
#ifdef G4VERBOSE
if ( fpVerboseL3 ) {
G4ExceptionDescription description;
description << " id " << id << " value " << value;
fpVerboseL3->Message("fill", "ntuple I column", description);
}
#endif
tools::hbook::wntuple::column<int>* column = GetNtupleIColumn(id);
if ( ! column ) {
G4ExceptionDescription description;
description << " " << "column " << id << " does not exist.";
G4Exception("G4HbookAnalysisManager::FillNtupleIColumn()",
"Analysis_W009", JustWarning, description);
return false;
}
column->fill(value);
#ifdef G4VERBOSE
if ( fpVerboseL2 ) {
G4ExceptionDescription description;
description << " id " << id << " value " << value;
fpVerboseL2->Message("fill", "ntuple I column", description);
}
#endif
return true;
}
//_____________________________________________________________________________
G4bool ExG4HbookAnalysisManager::FillNtupleFColumn(G4int id, G4float value)
{
#ifdef G4VERBOSE
if ( fpVerboseL3 ) {
G4ExceptionDescription description;
description << " id " << id << " value " << value;
fpVerboseL3->Message("fill", "ntuple F column", description);
}
#endif
tools::hbook::wntuple::column<float>* column = GetNtupleFColumn(id);
if ( ! column ) {
G4ExceptionDescription description;
description << " " << "column " << id << " does not exist.";
G4Exception("G4HbookAnalysisManager::FillNtupleFColumn()",
"Analysis_W009", JustWarning, description);
return false;
}
column->fill(value);
#ifdef G4VERBOSE
if ( fpVerboseL2 ) {
G4ExceptionDescription description;
description << " id " << id << " value " << value;
fpVerboseL2->Message("fill", "ntuple F column", description);
}
#endif
return true;
}
//_____________________________________________________________________________
G4bool ExG4HbookAnalysisManager::FillNtupleDColumn(G4int id, G4double value)
{
#ifdef G4VERBOSE
if ( fpVerboseL3 ) {
G4ExceptionDescription description;
description << " id " << id << " value " << value;
fpVerboseL3->Message("fill", "ntuple D column", description);
}
#endif
tools::hbook::wntuple::column<double>* column = GetNtupleDColumn(id);
if ( ! column ) {
G4ExceptionDescription description;
description << " " << "column " << id << " does not exist.";
G4Exception("G4HbookAnalysisManager::FillNtupleDColumn()",
"Analysis_W009", JustWarning, description);
return false;
}
column->fill(value);
#ifdef G4VERBOSE
if ( fpVerboseL2 ) {
G4ExceptionDescription description;
description << " id " << id << " value " << value;
fpVerboseL2->Message("fill", "ntuple D column", description);
}
#endif
return true;
}
//_____________________________________________________________________________
G4bool ExG4HbookAnalysisManager::AddNtupleRow()
{
#ifdef G4VERBOSE
if ( fpVerboseL3 )
fpVerboseL3->Message("add", "ntuple row", "");
#endif
//G4cout << "Hbook: Going to add Ntuple row ..." << G4endl;
if ( ! fNtuple ) {
G4ExceptionDescription description;
description << " " << "ntuple does not exist. ";
G4Exception("G4HbookAnalysisManager::AddNtupleRow()",
"Analysis_W008", JustWarning, description);
return false;
}
//fNtuple->add_row_fast();
fNtuple->add_row();
#ifdef G4VERBOSE
if ( fpVerboseL2 )
fpVerboseL2->Message("add", "ntuple row", "");
#endif
return true;
}
//_____________________________________________________________________________
tools::hbook::h1* ExG4HbookAnalysisManager::GetH1(G4int id, G4bool warn) const
{
G4int index = id - fFirstHistoId;
if ( index < 0 || index >= G4int(fH1Vector.size()) ) {
if ( warn) {
G4ExceptionDescription description;
description << " " << "histo " << id << " does not exist.";
G4Exception("G4HbookAnalysisManager::GetH1()",
"Analysis_W007", JustWarning, description);
}
return 0;
}
return fH1Vector[index];
}
//_____________________________________________________________________________
tools::hbook::h2* ExG4HbookAnalysisManager::GetH2(G4int id, G4bool warn) const
{
G4int index = id - fFirstHistoId;
if ( index < 0 || index >= G4int(fH2Vector.size()) ) {
if ( warn) {
G4ExceptionDescription description;
description << " " << "histo " << id << " does not exist.";
G4Exception("G4HbookAnalysisManager::GetH2()",
"Analysis_W007", JustWarning, description);
}
return 0;
}
return fH2Vector[index];
}
//_____________________________________________________________________________
tools::hbook::wntuple* ExG4HbookAnalysisManager::GetNtuple() const
{
return fNtuple;
}
//_____________________________________________________________________________
G4bool ExG4HbookAnalysisManager::SetH1HbookIdOffset(G4int offset)
{
if ( fH1Vector.size() ) {
G4ExceptionDescription description;
description
<< "Cannot set H1HbookIdOffset as some H1 histogramms already exist.";
G4Exception("G4HbookAnalysisManager::SetH1HbookIdOffset()",
"Analysis_W009", JustWarning, description);
return false;
}
if ( fFirstHistoId + offset < 1 ) {
G4ExceptionDescription description;
description << "The first histogram HBOOK id must be >= 1.";
G4Exception("G4HbookAnalysisManager::SetH1HbookIdOffset()",
"Analysis_W009", JustWarning, description);
return false;
}
fH1HbookIdOffset = offset;
return true;
}
//_____________________________________________________________________________
G4bool ExG4HbookAnalysisManager::SetH2HbookIdOffset(G4int offset)
{
if ( fH2Vector.size() ) {
G4ExceptionDescription description;
description
<< "Cannot set H2HbookIdOffset as some H2 histogramms already exist.";
G4Exception("G4HbookAnalysisManager::SetH2HbookIdOffset()",
"Analysis_W009", JustWarning, description);
return false;
}
if ( fFirstHistoId + offset < 1 ) {
G4ExceptionDescription description;
description << "The first histogram HBOOK id must be >= 1.";
G4Exception("G4HbookAnalysisManager::SetH1HbookIdOffset()",
"Analysis_W009", JustWarning, description);
return false;
}
fH2HbookIdOffset = offset;
return true;
}
//_____________________________________________________________________________
G4bool ExG4HbookAnalysisManager::SetNtupleHbookId(G4int ntupleId)
{
if ( fNtuple ) {
G4ExceptionDescription description;
description
<< "Cannot set NtupleHbookId as an ntuple already exists.";
G4Exception("G4HbookAnalysisManager::SetNtupleHbookId()",
"Analysis_W010", JustWarning, description);
return false;
}
if ( ntupleId < 1 ) {
G4ExceptionDescription description;
description << "The ntuple HBOOK id must be >= 1.";
G4Exception("G4HbookAnalysisManager::SetNtupleHbookId()",
"Analysis_W010", JustWarning, description);
return false;
}
fNtupleHbookId = ntupleId;
return true;
}
#endif
@@ -23,281 +23,97 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: HistoManager.cc,v 1.27 2010-11-09 20:52:09 asaim Exp $
// GEANT4 tag $Name: not supported by cvs2svn $
/// \file electromagnetic/TestEm5/src/HistoManager.cc
/// \brief Implementation of the HistoManager class
//
//
// $Id$
//
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
#include "HistoManager.hh"
#include "HistoMessenger.hh"
#include "G4UnitsTable.hh"
#ifdef G4ANALYSIS_USE
#include "AIDA/AIDA.h"
#endif
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
HistoManager::HistoManager()
:af(0),tree(0),factoryOn(false)
: fFileName("testem5")
{
#ifdef G4ANALYSIS_USE
// Creating the analysis factory
af = AIDA_createAnalysisFactory();
if(!af) {
G4cout << " HistoManager::HistoManager() :"
<< " problem creating the AIDA analysis factory."
<< G4endl;
}
#endif
fileName[0] = "testem5";
fileType = "root";
fileOption = "";
// histograms
for (G4int k=0; k<MaxHisto; k++) {
histo[k] = 0;
exist[k] = false;
Unit[k] = 1.0;
Width[k] = 1.0;
ascii[k] = false;
}
histoMessenger = new HistoMessenger(this);
Book();
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
HistoManager::~HistoManager()
{
delete histoMessenger;
#ifdef G4ANALYSIS_USE
delete af;
#endif
delete G4AnalysisManager::Instance();
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void HistoManager::book()
void HistoManager::Book()
{
#ifdef G4ANALYSIS_USE
if(!af) return;
// Creating a tree mapped to an hbook file.
fileName[1] = fileName[0] + "." + fileType;
G4bool readOnly = false;
G4bool createNew = true;
AIDA::ITreeFactory* tf = af->createTreeFactory();
tree = tf->create(fileName[1], fileType, readOnly, createNew, fileOption);
delete tf;
if(!tree) {
G4cout << "HistoManager::book() :"
<< " problem creating the AIDA tree with "
<< " storeName = " << fileName[1]
<< " storeType = " << fileType
<< " readOnly = " << readOnly
<< " createNew = " << createNew
<< " options = " << fileOption
<< G4endl;
return;
}
// Creating a histogram factory, whose histograms will be handled by the tree
AIDA::IHistogramFactory* hf = af->createHistogramFactory(*tree);
// create selected histograms
for (G4int k=0; k<MaxHisto; k++) {
if (exist[k]) {
histo[k] = hf->createHistogram1D( Label[k], Title[k],
Nbins[k], Vmin[k], Vmax[k]);
factoryOn = true;
}
}
delete hf;
if(factoryOn)
G4cout << "\n----> Histogram Tree is opened in " << fileName[1] << G4endl;
#endif
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void HistoManager::save()
{
#ifdef G4ANALYSIS_USE
if (factoryOn) {
saveAscii(); // Write ascii file, if any
tree->commit(); // Writing the histograms to the file
tree->close(); // and closing the tree (and the file)
G4cout << "\n----> Histogram Tree is saved in " << fileName[1] << G4endl;
delete tree;
tree = 0;
factoryOn = false;
}
#endif
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void HistoManager::FillHisto(G4int ih, G4double e, G4double weight)
{
if (ih > MaxHisto) {
G4cout << "---> warning from HistoManager::FillHisto() : histo " << ih
<< "does not exist; e= " << e << " w= " << weight << G4endl;
return;
}
#ifdef G4ANALYSIS_USE
if(exist[ih]) histo[ih]->fill(e/Unit[ih], weight);
#endif
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void HistoManager::SetHisto(G4int ih,
G4int nbins, G4double valmin, G4double valmax, const G4String& unit)
{
if (ih > MaxHisto) {
G4cout << "---> warning from HistoManager::SetHisto() : histo " << ih
<< "does not exist" << G4endl;
return;
}
// Create or get analysis manager
// The choice of analysis technology is done via selection of a namespace
// in HistoManager.hh
G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
analysisManager->SetFileName(fFileName);
analysisManager->SetVerboseLevel(1);
analysisManager->SetActivation(true); // enable inactivation of histograms
// Define histograms start values
const G4int kMaxHisto = 50;
const G4String id[] = { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9",
"10","11","12","13","14","15","16","17","18","19",
"20","21","22","23","24","25","26","27","28","29",
"30","31","32","33","34","35","36","37","38","39",
"40","41","42","43","44","45","46","47","48","49"
};
"20","21","22","23","24","25","26","27","28","29",
"30","31","32","33","34","35","36","37","38","39",
"40","41","42","43","44","45","46","47","48","49"
};
const G4String title[] =
{ "dummy", //0
"energy deposit in absorber", //1
"energy of charged secondaries at creation", //2
"energy of gammas at creation (std::log10(ekin/MeV))",//3
"x_vertex of charged secondaries (all)", //4
"x_vertex of charged secondaries (not absorbed)", //5
"dummy","dummy","dummy","dummy", //6-9
"(transmit, charged) : kinetic energy at exit", //10
"(transmit, charged) : ener fluence: dE(MeV)/dOmega", //11
"(transmit, charged) : space angle: dN/dOmega", //12
"(transmit, charged) : projected angle at exit", //13
"(transmit, charged) : projected position at exit", //14
"(transmit, charged) : radius at exit", //15
"dummy","dummy","dummy","dummy", //16-19
"(transmit, neutral) : kinetic energy at exit", //20
"(transmit, neutral) : ener fluence: dE(MeV)/dOmega", //21
"(transmit, neutral) : space angle: dN/dOmega", //22
"(transmit, neutral) : projected angle at exit", //23
"dummy","dummy","dummy","dummy","dummy","dummy", //24-29
"(reflect , charged) : kinetic energy at exit", //30
"(reflect , charged) : ener fluence: dE(MeV)/dOmega", //31
"(reflect , charged) : space angle: dN/dOmega", //32
"(reflect , charged) : projected angle at exit", //33
"dummy","dummy","dummy","dummy","dummy","dummy", //34-39
"(reflect , neutral) : kinetic energy at exit", //40
"(reflect , neutral) : ener fluence: dE(MeV)/dOmega", //41
"(reflect , neutral) : space angle: dN/dOmega", //42
"(reflect , neutral) : projected angle at exit", //43
"dummy","dummy","dummy","dummy","dummy","dummy" //44-49
{ "dummy", //0
"energy deposit in absorber", //1
"energy of charged secondaries at creation", //2
"energy of neutral secondaries at creation", //3
"energy of charged at creation (log scale)", //4
"energy of neutral at creation (log scale)", //5
"x_vertex of charged secondaries (all)", //6
"x_vertex of charged secondaries (not absorbed)", //7
"dummy","dummy", //8-9
"(transmit, charged) : kinetic energy at exit", //10
"(transmit, charged) : ener fluence: dE(MeV)/dOmega", //11
"(transmit, charged) : space angle: dN/dOmega", //12
"(transmit, charged) : projected angle at exit", //13
"(transmit, charged) : projected position at exit", //14
"(transmit, charged) : radius at exit", //15
"dummy","dummy","dummy","dummy", //16-19
"(transmit, neutral) : kinetic energy at exit", //20
"(transmit, neutral) : ener fluence: dE(MeV)/dOmega", //21
"(transmit, neutral) : space angle: dN/dOmega", //22
"(transmit, neutral) : projected angle at exit", //23
"dummy","dummy","dummy","dummy","dummy","dummy", //24-29
"(reflect , charged) : kinetic energy at exit", //30
"(reflect , charged) : ener fluence: dE(MeV)/dOmega", //31
"(reflect , charged) : space angle: dN/dOmega", //32
"(reflect , charged) : projected angle at exit", //33
"dummy","dummy","dummy","dummy","dummy","dummy", //34-39
"(reflect , neutral) : kinetic energy at exit", //40
"(reflect , neutral) : ener fluence: dE(MeV)/dOmega", //41
"(reflect , neutral) : space angle: dN/dOmega", //42
"(reflect , neutral) : projected angle at exit", //43
"dummy","dummy","dummy","dummy","dummy","dummy" //44-49
};
G4String titl = title[ih];
G4double vmin = valmin, vmax = valmax;
Unit[ih] = 1.;
// Default values (to be reset via /analysis/h1/set command)
G4int nbins = 100;
G4double vmin = 0.;
G4double vmax = 100.;
if (ih == 3) { vmin = std::log10(valmin/MeV); vmax = std::log10(valmax/MeV);}
else if (unit != "none") {
titl = title[ih] + " (" + unit + ")";
Unit[ih] = G4UnitDefinition::GetValueOf(unit);
vmin = valmin/Unit[ih]; vmax = valmax/Unit[ih];
// Create all histograms as inactivated
// as we have not yet set nbins, vmin, vmax
for (G4int k=0; k<kMaxHisto; k++) {
G4int ih = analysisManager->CreateH1(id[k], title[k], nbins, vmin, vmax);
analysisManager->SetActivation(G4VAnalysisManager::kH1, ih, false);
}
exist[ih] = true;
Label[ih] = id[ih];
Title[ih] = titl;
Nbins[ih] = nbins;
Vmin[ih] = vmin;
Vmax[ih] = vmax;
Width[ih] = (valmax-valmin)/nbins;
G4cout << "----> SetHisto " << ih << ": " << titl << "; "
<< nbins << " bins from "
<< vmin << " " << unit << " to " << vmax << " " << unit << G4endl;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void HistoManager::RemoveHisto(G4int ih)
{
if (ih > MaxHisto) {
G4cout << "---> warning from HistoManager::RemoveHisto() : histo " << ih
<< "does not exist" << G4endl;
return;
}
histo[ih] = 0; exist[ih] = false;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void HistoManager::Scale(G4int ih, G4double fac)
{
if (ih > MaxHisto) {
G4cout << "---> warning from HistoManager::Scale() : histo " << ih
<< "does not exist. (fac = " << fac << ")" << G4endl;
return;
}
#ifdef G4ANALYSIS_USE
if(exist[ih]) histo[ih]->scale(fac);
#endif
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void HistoManager::PrintHisto(G4int ih)
{
if (ih < MaxHisto) { ascii[ih] = true; ascii[0] = true; }
else
G4cout << "---> warning from HistoManager::PrintHisto() : histo " << ih
<< "does not exist" << G4endl;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
#include <fstream>
void HistoManager::saveAscii()
{
#ifdef G4ANALYSIS_USE
if (!ascii[0]) return;
G4String name = fileName[0] + ".ascii";
std::ofstream File(name, std::ios::out);
File.setf( std::ios::scientific, std::ios::floatfield );
//write selected histograms
for (G4int ih=0; ih<MaxHisto; ih++) {
if (exist[ih] && ascii[ih]) {
File << "\n 1D histogram " << ih << ": " << Title[ih]
<< "\n \n \t X \t\t Y" << G4endl;
for (G4int iBin=0; iBin<Nbins[ih]; iBin++) {
File << " " << iBin << "\t"
<< 0.5*(histo[ih]->axis().binLowerEdge(iBin) +
histo[ih]->axis().binUpperEdge(iBin)) << "\t"
<< histo[ih]->binHeight(iBin)
<< G4endl;
}
}
}
#endif
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -1,144 +0,0 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: HistoMessenger.cc,v 1.8 2007-11-12 17:48:16 maire Exp $
// GEANT4 tag $Name: not supported by cvs2svn $
//
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
#include "HistoMessenger.hh"
#include <sstream>
#include "HistoManager.hh"
#include "G4UIdirectory.hh"
#include "G4UIcommand.hh"
#include "G4UIparameter.hh"
#include "G4UIcmdWithAString.hh"
#include "G4UIcmdWithAnInteger.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
HistoMessenger::HistoMessenger(HistoManager* manager)
:histoManager (manager)
{
histoDir = new G4UIdirectory("/testem/histo/");
histoDir->SetGuidance("histograms control");
factoryCmd = new G4UIcmdWithAString("/testem/histo/setFileName",this);
factoryCmd->SetGuidance("set name for the histograms file");
typeCmd = new G4UIcmdWithAString("/testem/histo/setFileType",this);
typeCmd->SetGuidance("set histograms file type: hbook, root, XML");
typeCmd->SetCandidates("hbook root XML");
optionCmd = new G4UIcmdWithAString("/testem/histo/setFileOption",this);
optionCmd->SetGuidance("set option for the histograms file");
histoCmd = new G4UIcommand("/testem/histo/setHisto",this);
histoCmd->SetGuidance("Set bining of the histo number ih :");
histoCmd->SetGuidance(" nbBins; valMin; valMax; unit (of vmin and vmax)");
//
G4UIparameter* ih = new G4UIparameter("ih",'i',false);
ih->SetGuidance("histo number : from 1 to MaxHisto");
ih->SetParameterRange("ih>0");
histoCmd->SetParameter(ih);
//
G4UIparameter* nbBins = new G4UIparameter("nbBins",'i',false);
nbBins->SetGuidance("number of bins");
nbBins->SetParameterRange("nbBins>0");
histoCmd->SetParameter(nbBins);
//
G4UIparameter* valMin = new G4UIparameter("valMin",'d',false);
valMin->SetGuidance("valMin, expressed in unit");
histoCmd->SetParameter(valMin);
//
G4UIparameter* valMax = new G4UIparameter("valMax",'d',false);
valMax->SetGuidance("valMax, expressed in unit");
histoCmd->SetParameter(valMax);
//
G4UIparameter* unit = new G4UIparameter("unit",'s',true);
unit->SetGuidance("if omitted, vmin and vmax are assumed dimensionless");
unit->SetDefaultValue("none");
histoCmd->SetParameter(unit);
prhistoCmd = new G4UIcmdWithAnInteger("/testem/histo/printHisto",this);
prhistoCmd->SetGuidance("print histo #id on ascii file");
prhistoCmd->SetParameterName("id",false);
prhistoCmd->SetRange("id>0");
rmhistoCmd = new G4UIcmdWithAnInteger("/testem/histo/removeHisto",this);
rmhistoCmd->SetGuidance("desactivate histo #id");
rmhistoCmd->SetParameterName("id",false);
rmhistoCmd->SetRange("id>0");
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
HistoMessenger::~HistoMessenger()
{
delete rmhistoCmd;
delete prhistoCmd;
delete histoCmd;
delete optionCmd;
delete typeCmd;
delete factoryCmd;
delete histoDir;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void HistoMessenger::SetNewValue(G4UIcommand* command, G4String newValues)
{
if (command == factoryCmd)
histoManager->SetFileName(newValues);
if (command == typeCmd)
histoManager->SetFileType(newValues);
if (command == optionCmd)
histoManager->SetFileOption(newValues);
if (command == histoCmd)
{ G4int ih,nbBins; G4double vmin,vmax; char unts[30];
const char* t = newValues;
std::istringstream is(t);
is >> ih >> nbBins >> vmin >> vmax >> unts;
G4String unit = unts;
G4double vUnit = 1. ;
if (unit != "none") vUnit = G4UIcommand::ValueOf(unit);
histoManager->SetHisto (ih,nbBins,vmin*vUnit,vmax*vUnit,unit);
}
if (command == prhistoCmd)
histoManager->PrintHisto(prhistoCmd->GetNewIntValue(newValues));
if (command == rmhistoCmd)
histoManager->RemoveHisto(rmhistoCmd->GetNewIntValue(newValues));
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -23,8 +23,7 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: PhysListEmStandard.cc,v 1.24 2009-11-15 22:10:03 maire Exp $
// GEANT4 tag $Name: not supported by cvs2svn $
// $Id$
//
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -41,6 +40,7 @@
#include "G4KleinNishinaModel.hh"
#include "G4eMultipleScattering.hh"
#include "G4UrbanMscModel96.hh"
#include "G4eIonisation.hh"
#include "G4eBremsstrahlung.hh"
#include "G4eplusAnnihilation.hh"
@@ -65,6 +65,8 @@
#include "G4LossTableManager.hh"
#include "G4UAtomicDeexcitation.hh"
#include "G4SystemOfUnits.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
PhysListEmStandard::PhysListEmStandard(const G4String& name)
@@ -100,20 +102,29 @@ void PhysListEmStandard::ConstructProcess()
} else if (particleName == "e-") {
ph->RegisterProcess(new G4eMultipleScattering(), particle);
G4eMultipleScattering* msc = new G4eMultipleScattering();
msc -> AddEmModel(0, new G4UrbanMscModel96());
ph->RegisterProcess(msc, particle);
//
G4eIonisation* eIoni = new G4eIonisation();
eIoni->SetStepFunction(0.1, 100*um);
ph->RegisterProcess(eIoni, particle);
//
ph->RegisterProcess(new G4eBremsstrahlung(), particle);
} else if (particleName == "e+") {
ph->RegisterProcess(new G4eMultipleScattering(), particle);
G4eMultipleScattering* msc = new G4eMultipleScattering();
msc -> AddEmModel(0, new G4UrbanMscModel96());
ph->RegisterProcess(msc, particle);
//
G4eIonisation* eIoni = new G4eIonisation();
eIoni->SetStepFunction(0.1, 100*um);
ph->RegisterProcess(eIoni, particle);
//
ph->RegisterProcess(new G4eBremsstrahlung(), particle);
ph->RegisterProcess(new G4eplusAnnihilation(), particle);
//
ph->RegisterProcess(new G4eplusAnnihilation(), particle);
} else if (particleName == "mu+" ||
particleName == "mu-" ) {
@@ -23,8 +23,10 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: PhysListEmStandardGS.cc,v 1.1 2009-11-16 13:54:53 maire Exp $
// GEANT4 tag $Name: not supported by cvs2svn $
/// \file electromagnetic/TestEm5/src/PhysListEmStandardGS.cc
/// \brief Implementation of the PhysListEmStandardGS class
//
// $Id$
//
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -60,6 +62,8 @@
#include "G4EmProcessOptions.hh"
#include "G4MscStepLimitType.hh"
#include "G4SystemOfUnits.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
PhysListEmStandardGS::PhysListEmStandardGS(const G4String& name)
@@ -97,7 +101,7 @@ void PhysListEmStandardGS::ConstructProcess()
pmanager->AddProcess(msc, -1, 1, 1);
pmanager->AddProcess(new G4eIonisation, -1, 2, 2);
pmanager->AddProcess(new G4eBremsstrahlung, -1, 3, 3);
} else if (particleName == "e+") {
//positron
G4eMultipleScattering* msc = new G4eMultipleScattering();
@@ -125,7 +129,7 @@ void PhysListEmStandardGS::ConstructProcess()
pmanager->AddProcess(new G4hPairProduction, -1, 4, 4);
} else if( particleName == "alpha" ||
particleName == "He3" ) {
particleName == "He3" ) {
//alpha
pmanager->AddProcess(new G4hMultipleScattering, -1, 1, 1);
pmanager->AddProcess(new G4ionIonisation, -1, 2, 2);
@@ -140,8 +144,8 @@ void PhysListEmStandardGS::ConstructProcess()
pmanager->AddProcess(new G4NuclearStopping, -1, 3,-1);
} else if ((!particle->IsShortLived()) &&
(particle->GetPDGCharge() != 0.0) &&
(particle->GetParticleName() != "chargedgeantino")) {
(particle->GetPDGCharge() != 0.0) &&
(particle->GetParticleName() != "chargedgeantino")) {
//all others charged particles except geantino
pmanager->AddProcess(new G4hMultipleScattering, -1, 1, 1);
pmanager->AddProcess(new G4hIonisation, -1, 2, 2);
@@ -157,27 +161,27 @@ void PhysListEmStandardGS::ConstructProcess()
//physics tables
//
emOptions.SetMinEnergy(100*eV); //default
emOptions.SetMaxEnergy(100*TeV); //default
emOptions.SetDEDXBinning(12*20); //default=12*7
emOptions.SetLambdaBinning(12*20); //default=12*7
emOptions.SetSplineFlag(true); //default
emOptions.SetMinEnergy(100*eV); //default
emOptions.SetMaxEnergy(100*TeV); //default
emOptions.SetDEDXBinning(12*20); //default=12*7
emOptions.SetLambdaBinning(12*20); //default=12*7
emOptions.SetSplineFlag(true); //default
//multiple coulomb scattering
//
emOptions.SetMscStepLimitation(fUseDistanceToBoundary); //default=fUseSafety
emOptions.SetMscRangeFactor(0.04); //default
emOptions.SetMscGeomFactor (2.5); //default
emOptions.SetSkin(3.); //default
emOptions.SetMscRangeFactor(0.04); //default
emOptions.SetMscGeomFactor (2.5); //default
emOptions.SetSkin(3.); //default
//energy loss
//
emOptions.SetStepFunction(0.2, 100*um); //default=(0.2, 1*mm)
emOptions.SetLinearLossLimit(1.e-2); //default
emOptions.SetStepFunction(0.2, 100*um); //default=(0.2, 1*mm)
emOptions.SetLinearLossLimit(1.e-2); //default
//ionization
//
emOptions.SetSubCutoff(false); //default
emOptions.SetSubCutoff(false); //default
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -23,8 +23,10 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: PhysListEmStandardSS.cc,v 1.9 2011-01-05 19:02:39 vnivanch Exp $
// GEANT4 tag $Name: not supported by cvs2svn $
/// \file electromagnetic/TestEm5/src/PhysListEmStandardSS.cc
/// \brief Implementation of the PhysListEmStandardSS class
//
// $Id$
//
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -54,6 +56,8 @@
#include "G4EmProcessOptions.hh"
#include "G4SystemOfUnits.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
PhysListEmStandardSS::PhysListEmStandardSS(const G4String& name)
@@ -85,29 +89,29 @@ void PhysListEmStandardSS::ConstructProcess()
} else if (particleName == "e-") {
//electron
pmanager->AddDiscreteProcess(new G4CoulombScattering);
pmanager->AddProcess(new G4eIonisation, -1, 1, 1);
pmanager->AddProcess(new G4eBremsstrahlung, -1, 2, 2);
pmanager->AddDiscreteProcess(new G4CoulombScattering);
} else if (particleName == "e+") {
//positron
pmanager->AddDiscreteProcess(new G4CoulombScattering);
pmanager->AddProcess(new G4eIonisation, -1, 1, 1);
pmanager->AddProcess(new G4eBremsstrahlung, -1, 2, 2);
pmanager->AddProcess(new G4eplusAnnihilation, 0,-1, 3);
pmanager->AddDiscreteProcess(new G4CoulombScattering);
} else if (particleName == "mu+" ||
particleName == "mu-" ) {
//muon
pmanager->AddDiscreteProcess(new G4CoulombScattering);
pmanager->AddProcess(new G4MuIonisation, -1, 1, 1);
pmanager->AddProcess(new G4MuBremsstrahlung, -1, 2, 2);
pmanager->AddProcess(new G4MuPairProduction, -1, 3, 3);
pmanager->AddDiscreteProcess(new G4CoulombScattering);
} else if (particleName == "alpha" || particleName == "He3") {
pmanager->AddProcess(new G4ionIonisation, -1, 1, 1);
G4CoulombScattering* cs = new G4CoulombScattering();
cs->AddEmModel(0, new G4IonCoulombScatteringModel());
//cs->AddEmModel(0, new G4IonCoulombScatteringModel());
cs->SetBuildTableFlag(false);
pmanager->AddDiscreteProcess(cs);
@@ -119,8 +123,8 @@ void PhysListEmStandardSS::ConstructProcess()
pmanager->AddDiscreteProcess(cs);
} else if ((!particle->IsShortLived()) &&
(particle->GetPDGCharge() != 0.0) &&
(particle->GetParticleName() != "chargedgeantino")) {
(particle->GetPDGCharge() != 0.0) &&
(particle->GetParticleName() != "chargedgeantino")) {
//all others charged particles except geantino
pmanager->AddDiscreteProcess(new G4CoulombScattering);
pmanager->AddProcess(new G4hIonisation, -1, 1, 1);
@@ -136,20 +140,20 @@ void PhysListEmStandardSS::ConstructProcess()
//physics tables
//
emOptions.SetMinEnergy(100*eV); //default
emOptions.SetMaxEnergy(100*TeV); //default
emOptions.SetDEDXBinning(12*20); //default=12*7
emOptions.SetLambdaBinning(12*20); //default=12*7
emOptions.SetSplineFlag(true); //default
emOptions.SetMinEnergy(100*eV); //default
emOptions.SetMaxEnergy(100*TeV); //default
emOptions.SetDEDXBinning(12*20); //default=12*7
emOptions.SetLambdaBinning(12*20); //default=12*7
emOptions.SetSplineFlag(true); //default
//energy loss
//
emOptions.SetStepFunction(0.2, 100*um); //default=(0.2, 1*mm)
emOptions.SetLinearLossLimit(1.e-2); //default
emOptions.SetStepFunction(0.2, 100*um); //default=(0.2, 1*mm)
emOptions.SetLinearLossLimit(1.e-2); //default
//ionization
//
emOptions.SetSubCutoff(false); //default
emOptions.SetSubCutoff(false); //default
// scattering
emOptions.SetPolarAngleLimit(0.0);
@@ -0,0 +1,160 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
/// \file electromagnetic/TestEm5/src/PhysListEmStandardSSM.cc
/// \brief Implementation of the PhysListEmStandardSSM class
//
// $Id$
//
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
#include "PhysListEmStandardSSM.hh"
#include "G4ParticleDefinition.hh"
#include "G4ProcessManager.hh"
#include "G4ComptonScattering.hh"
#include "G4GammaConversion.hh"
#include "G4PhotoElectricEffect.hh"
#include "G4CoulombScattering.hh"
#include "G4eCoulombScatteringModel.hh"
#include "G4eSingleCoulombScatteringModel.hh"
#include "G4IonCoulombScatteringModel.hh"
#include "G4eIonisation.hh"
#include "G4eBremsstrahlung.hh"
#include "G4eplusAnnihilation.hh"
#include "G4MuIonisation.hh"
#include "G4MuBremsstrahlung.hh"
#include "G4MuPairProduction.hh"
#include "G4hIonisation.hh"
#include "G4ionIonisation.hh"
#include "G4EmProcessOptions.hh"
#include "G4SystemOfUnits.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
PhysListEmStandardSSM::PhysListEmStandardSSM(const G4String& name)
: G4VPhysicsConstructor(name)
{}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
PhysListEmStandardSSM::~PhysListEmStandardSSM()
{}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void PhysListEmStandardSSM::ConstructProcess()
{
// Add standard EM Processes
theParticleIterator->reset();
while( (*theParticleIterator)() ){
G4ParticleDefinition* particle = theParticleIterator->value();
G4ProcessManager* pmanager = particle->GetProcessManager();
G4String particleName = particle->GetParticleName();
if (particleName == "gamma") {
// gamma
pmanager->AddDiscreteProcess(new G4PhotoElectricEffect);
pmanager->AddDiscreteProcess(new G4ComptonScattering);
pmanager->AddDiscreteProcess(new G4GammaConversion);
} else if (particleName == "e-") {
//electron
pmanager->AddProcess(new G4eIonisation, -1, 1, 1);
pmanager->AddProcess(new G4eBremsstrahlung, -1, 2, 2);
G4CoulombScattering* cs = new G4CoulombScattering();
G4eSingleCoulombScatteringModel* model =
new G4eSingleCoulombScatteringModel();
//model->SetLowEnergyThreshold(10*eV);
model->SetPolarAngleLimit(0.0);
cs->AddEmModel(0, model);
pmanager->AddDiscreteProcess(cs);
} else if (particleName == "e+") {
//positron
pmanager->AddProcess(new G4eIonisation, -1, 1, 1);
pmanager->AddProcess(new G4eBremsstrahlung, -1, 2, 2);
pmanager->AddProcess(new G4eplusAnnihilation, 0,-1, 3);
G4CoulombScattering* cs = new G4CoulombScattering();
G4eSingleCoulombScatteringModel* model =
new G4eSingleCoulombScatteringModel();
model->SetPolarAngleLimit(0.0);
cs->AddEmModel(0, model);
pmanager->AddDiscreteProcess(cs);
} else if (particleName == "mu+" ||
particleName == "mu-" ) {
//muon
pmanager->AddProcess(new G4MuIonisation, -1, 1, 1);
pmanager->AddProcess(new G4MuBremsstrahlung, -1, 2, 2);
pmanager->AddProcess(new G4MuPairProduction, -1, 3, 3);
G4CoulombScattering* cs = new G4CoulombScattering();
G4eCoulombScatteringModel* model = new G4eCoulombScatteringModel();
model->SetPolarAngleLimit(0.0);
cs->AddEmModel(0, model);
pmanager->AddDiscreteProcess(cs);
} else if (particleName == "alpha" || particleName == "He3") {
pmanager->AddProcess(new G4ionIonisation, -1, 1, 1);
G4CoulombScattering* cs = new G4CoulombScattering();
cs->AddEmModel(0, new G4IonCoulombScatteringModel());
cs->SetBuildTableFlag(false);
pmanager->AddDiscreteProcess(cs);
} else if (particleName == "GenericIon" ) {
pmanager->AddProcess(new G4ionIonisation, -1, 1, 1);
G4CoulombScattering* cs = new G4CoulombScattering();
cs->AddEmModel(0, new G4IonCoulombScatteringModel());
cs->SetBuildTableFlag(false);
pmanager->AddDiscreteProcess(cs);
} else if ((!particle->IsShortLived()) &&
(particle->GetPDGCharge() != 0.0) &&
(particle->GetParticleName() != "chargedgeantino")) {
//all others charged particles except geantino
pmanager->AddProcess(new G4hIonisation, -1, 1, 1);
pmanager->AddDiscreteProcess(new G4CoulombScattering);
}
}
// scattering
G4EmProcessOptions emOptions;
emOptions.SetPolarAngleLimit(0.0);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -23,8 +23,10 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: PhysListEmStandardWVI.cc,v 1.1 2010-11-19 15:59:01 vnivanch Exp $
// GEANT4 tag $Name: not supported by cvs2svn $
/// \file electromagnetic/TestEm5/src/PhysListEmStandardWVI.cc
/// \brief Implementation of the PhysListEmStandardWVI class
//
// $Id$
//
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -62,6 +64,10 @@
#include "G4EmProcessOptions.hh"
#include "G4MscStepLimitType.hh"
#include "G4PhysicalConstants.hh"
#include "G4SystemOfUnits.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
PhysListEmStandardWVI::PhysListEmStandardWVI(const G4String& name)
@@ -94,16 +100,16 @@ void PhysListEmStandardWVI::ConstructProcess()
} else if (particleName == "e-") {
//electron
G4eMultipleScattering* msc = new G4eMultipleScattering();
G4MuMultipleScattering* msc = new G4MuMultipleScattering();
msc->AddEmModel(0, new G4WentzelVIModel());
pmanager->AddProcess(msc, -1, 1, 1);
pmanager->AddProcess(new G4eIonisation, -1, 2, 2);
pmanager->AddProcess(new G4eBremsstrahlung, -1, 3, 3);
pmanager->AddProcess(new G4CoulombScattering, -1,-1, 4);
} else if (particleName == "e+") {
//positron
G4eMultipleScattering* msc = new G4eMultipleScattering();
G4MuMultipleScattering* msc = new G4MuMultipleScattering();
msc->AddEmModel(0, new G4WentzelVIModel());
pmanager->AddProcess(msc, -1, 1, 1);
pmanager->AddProcess(new G4eIonisation, -1, 2, 2);
@@ -126,16 +132,15 @@ void PhysListEmStandardWVI::ConstructProcess()
particleName == "pi-" ||
particleName == "pi+" ) {
//proton
G4hMultipleScattering* msc = new G4hMultipleScattering();
G4MuMultipleScattering* msc = new G4MuMultipleScattering();
msc->AddEmModel(0, new G4WentzelVIModel());
pmanager->AddProcess(msc, -1, 1, 1);
pmanager->AddProcess(new G4hIonisation, -1, 2, 2);
pmanager->AddProcess(new G4hBremsstrahlung, -1, 3, 3);
pmanager->AddProcess(new G4hPairProduction, -1, 4, 4);
pmanager->AddProcess(new G4CoulombScattering, -1,-1, 5);
} else if( particleName == "alpha" ||
particleName == "He3" ) {
particleName == "He3" ) {
//alpha
G4hMultipleScattering* msc = new G4hMultipleScattering();
pmanager->AddProcess(msc, -1, 1, 1);
@@ -152,14 +157,12 @@ void PhysListEmStandardWVI::ConstructProcess()
pmanager->AddProcess(new G4NuclearStopping, -1, 3,-1);
} else if ((!particle->IsShortLived()) &&
(particle->GetPDGCharge() != 0.0) &&
(particle->GetParticleName() != "chargedgeantino")) {
(particle->GetPDGCharge() != 0.0) &&
(particle->GetParticleName() != "chargedgeantino")) {
//all others charged particles except geantino
G4hMultipleScattering* msc = new G4hMultipleScattering();
msc->AddEmModel(0, new G4WentzelVIModel());
pmanager->AddProcess(msc, -1, 1, 1);
pmanager->AddProcess(new G4hIonisation, -1, 2, 2);
pmanager->AddProcess(new G4CoulombScattering, -1,-1, 3);
}
}
@@ -23,8 +23,10 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: PhysicsList.cc,v 1.42 2010-11-19 16:29:35 vnivanch Exp $
// GEANT4 tag $Name: not supported by cvs2svn $
/// \file electromagnetic/TestEm5/src/PhysicsList.cc
/// \brief Implementation of the PhysicsList class
//
// $Id$
//
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -34,6 +36,7 @@
#include "PhysListEmStandard.hh"
#include "PhysListEmStandardSS.hh"
#include "PhysListEmStandardSSM.hh"
#include "PhysListEmStandardGS.hh"
#include "PhysListEmStandardWVI.hh"
@@ -41,6 +44,7 @@
#include "G4EmStandardPhysics_option1.hh"
#include "G4EmStandardPhysics_option2.hh"
#include "G4EmStandardPhysics_option3.hh"
#include "G4EmStandardPhysics_option4.hh"
#include "G4EmLivermorePhysics.hh"
#include "G4EmPenelopePhysics.hh"
@@ -48,6 +52,7 @@
#include "StepMax.hh"
#include "G4UnitsTable.hh"
#include "G4SystemOfUnits.hh"
#include "G4ParticleDefinition.hh"
#include "G4ProcessManager.hh"
@@ -78,17 +83,17 @@
PhysicsList::PhysicsList() : G4VModularPhysicsList()
{
pMessenger = new PhysicsListMessenger(this);
fMessenger = new PhysicsListMessenger(this);
// EM physics
emName = G4String("local");
emPhysicsList = new PhysListEmStandard(emName);
fEmName = G4String("local");
fEmPhysicsList = new PhysListEmStandard(fEmName);
defaultCutValue = 1.*mm;
cutForGamma = defaultCutValue;
cutForElectron = defaultCutValue;
cutForPositron = defaultCutValue;
fCutForGamma = defaultCutValue;
fCutForElectron = defaultCutValue;
fCutForPositron = defaultCutValue;
SetVerboseLevel(1);
}
@@ -97,8 +102,8 @@ PhysicsList::PhysicsList() : G4VModularPhysicsList()
PhysicsList::~PhysicsList()
{
delete emPhysicsList;
delete pMessenger;
delete fEmPhysicsList;
delete fMessenger;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -141,7 +146,7 @@ void PhysicsList::ConstructParticle()
void PhysicsList::ConstructProcess()
{
AddTransportation();
emPhysicsList->ConstructProcess();
fEmPhysicsList->ConstructProcess();
AddDecay();
AddStepMax();
}
@@ -185,7 +190,7 @@ void PhysicsList::AddStepMax()
if (stepMaxProcess->IsApplicable(*particle) && !particle->IsShortLived())
{
pmanager ->AddDiscreteProcess(stepMaxProcess);
pmanager ->AddDiscreteProcess(stepMaxProcess);
}
}
}
@@ -198,65 +203,77 @@ void PhysicsList::AddPhysicsList(const G4String& name)
G4cout << "PhysicsList::AddPhysicsList: <" << name << ">" << G4endl;
}
if (name == emName) return;
if (name == fEmName) return;
if (name == "local") {
emName = name;
delete emPhysicsList;
emPhysicsList = new PhysListEmStandard(name);
fEmName = name;
delete fEmPhysicsList;
fEmPhysicsList = new PhysListEmStandard(name);
} else if (name == "emstandard_opt0") {
emName = name;
delete emPhysicsList;
emPhysicsList = new G4EmStandardPhysics();
fEmName = name;
delete fEmPhysicsList;
fEmPhysicsList = new G4EmStandardPhysics();
} else if (name == "emstandard_opt1") {
emName = name;
delete emPhysicsList;
emPhysicsList = new G4EmStandardPhysics_option1();
fEmName = name;
delete fEmPhysicsList;
fEmPhysicsList = new G4EmStandardPhysics_option1();
} else if (name == "emstandard_opt2") {
emName = name;
delete emPhysicsList;
emPhysicsList = new G4EmStandardPhysics_option2();
fEmName = name;
delete fEmPhysicsList;
fEmPhysicsList = new G4EmStandardPhysics_option2();
} else if (name == "emstandard_opt3") {
emName = name;
delete emPhysicsList;
emPhysicsList = new G4EmStandardPhysics_option3();
fEmName = name;
delete fEmPhysicsList;
fEmPhysicsList = new G4EmStandardPhysics_option3();
} else if (name == "emstandard_opt4") {
fEmName = name;
delete fEmPhysicsList;
fEmPhysicsList = new G4EmStandardPhysics_option4();
} else if (name == "standardSS") {
emName = name;
delete emPhysicsList;
emPhysicsList = new PhysListEmStandardSS(name);
fEmName = name;
delete fEmPhysicsList;
fEmPhysicsList = new PhysListEmStandardSS(name);
} else if (name == "standardSSM") {
fEmName = name;
delete fEmPhysicsList;
fEmPhysicsList = new PhysListEmStandardSSM(name);
} else if (name == "standardWVI") {
emName = name;
delete emPhysicsList;
emPhysicsList = new PhysListEmStandardWVI(name);
fEmName = name;
delete fEmPhysicsList;
fEmPhysicsList = new PhysListEmStandardWVI(name);
} else if (name == "standardGS") {
emName = name;
delete emPhysicsList;
emPhysicsList = new PhysListEmStandardGS(name);
fEmName = name;
delete fEmPhysicsList;
fEmPhysicsList = new PhysListEmStandardGS(name);
} else if (name == "empenelope"){
emName = name;
delete emPhysicsList;
emPhysicsList = new G4EmPenelopePhysics();
fEmName = name;
delete fEmPhysicsList;
fEmPhysicsList = new G4EmPenelopePhysics();
} else if (name == "emlivermore"){
emName = name;
delete emPhysicsList;
emPhysicsList = new G4EmLivermorePhysics();
fEmName = name;
delete fEmPhysicsList;
fEmPhysicsList = new G4EmLivermorePhysics();
} else {
@@ -277,9 +294,9 @@ void PhysicsList::SetCuts()
// set cut values for gamma at first and for e- second and next for e+,
// because some processes for e+/e- need cut values for gamma
SetCutValue(cutForGamma, "gamma");
SetCutValue(cutForElectron, "e-");
SetCutValue(cutForPositron, "e+");
SetCutValue(fCutForGamma, "gamma");
SetCutValue(fCutForElectron, "e-");
SetCutValue(fCutForPositron, "e+");
if (verboseLevel>0) DumpCutValuesTable();
}
@@ -288,24 +305,24 @@ void PhysicsList::SetCuts()
void PhysicsList::SetCutForGamma(G4double cut)
{
cutForGamma = cut;
SetParticleCuts(cutForGamma, G4Gamma::Gamma());
fCutForGamma = cut;
SetParticleCuts(fCutForGamma, G4Gamma::Gamma());
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void PhysicsList::SetCutForElectron(G4double cut)
{
cutForElectron = cut;
SetParticleCuts(cutForElectron, G4Electron::Electron());
fCutForElectron = cut;
SetParticleCuts(fCutForElectron, G4Electron::Electron());
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void PhysicsList::SetCutForPositron(G4double cut)
{
cutForPositron = cut;
SetParticleCuts(cutForPositron, G4Positron::Positron());
fCutForPositron = cut;
SetParticleCuts(fCutForPositron, G4Positron::Positron());
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -23,8 +23,10 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: PhysicsListMessenger.cc,v 1.8 2009-03-06 18:04:23 maire Exp $
// GEANT4 tag $Name: not supported by cvs2svn $
/// \file electromagnetic/TestEm5/src/PhysicsListMessenger.cc
/// \brief Implementation of the PhysicsListMessenger class
//
// $Id$
//
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -39,43 +41,43 @@
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
PhysicsListMessenger::PhysicsListMessenger(PhysicsList* pPhys)
:pPhysicsList(pPhys)
:fPhysicsList(pPhys)
{
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("Add modula physics list.");
pListCmd->SetParameterName("PList",false);
pListCmd->AvailableForStates(G4State_PreInit);
fListCmd = new G4UIcmdWithAString("/testem/phys/addPhysics",this);
fListCmd->SetGuidance("Add modula physics list.");
fListCmd->SetParameterName("PList",false);
fListCmd->AvailableForStates(G4State_PreInit);
gammaCutCmd = new G4UIcmdWithADoubleAndUnit("/testem/phys/setGCut",this);
gammaCutCmd->SetGuidance("Set gamma cut.");
gammaCutCmd->SetParameterName("Gcut",false);
gammaCutCmd->SetUnitCategory("Length");
gammaCutCmd->SetRange("Gcut>0.0");
gammaCutCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
fGammaCutCmd = new G4UIcmdWithADoubleAndUnit("/testem/phys/setGCut",this);
fGammaCutCmd->SetGuidance("Set gamma cut.");
fGammaCutCmd->SetParameterName("Gcut",false);
fGammaCutCmd->SetUnitCategory("Length");
fGammaCutCmd->SetRange("Gcut>0.0");
fGammaCutCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
electCutCmd = new G4UIcmdWithADoubleAndUnit("/testem/phys/setECut",this);
electCutCmd->SetGuidance("Set electron cut.");
electCutCmd->SetParameterName("Ecut",false);
electCutCmd->SetUnitCategory("Length");
electCutCmd->SetRange("Ecut>0.0");
electCutCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
fElectCutCmd = new G4UIcmdWithADoubleAndUnit("/testem/phys/setECut",this);
fElectCutCmd->SetGuidance("Set electron cut.");
fElectCutCmd->SetParameterName("Ecut",false);
fElectCutCmd->SetUnitCategory("Length");
fElectCutCmd->SetRange("Ecut>0.0");
fElectCutCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
protoCutCmd = new G4UIcmdWithADoubleAndUnit("/testem/phys/setPCut",this);
protoCutCmd->SetGuidance("Set positron cut.");
protoCutCmd->SetParameterName("Pcut",false);
protoCutCmd->SetUnitCategory("Length");
protoCutCmd->SetRange("Pcut>0.0");
protoCutCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
fProtoCutCmd = new G4UIcmdWithADoubleAndUnit("/testem/phys/setPCut",this);
fProtoCutCmd->SetGuidance("Set positron cut.");
fProtoCutCmd->SetParameterName("Pcut",false);
fProtoCutCmd->SetUnitCategory("Length");
fProtoCutCmd->SetRange("Pcut>0.0");
fProtoCutCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
allCutCmd = new G4UIcmdWithADoubleAndUnit("/testem/phys/setCuts",this);
allCutCmd->SetGuidance("Set cut for all.");
allCutCmd->SetParameterName("cut",false);
allCutCmd->SetUnitCategory("Length");
allCutCmd->SetRange("cut>0.0");
allCutCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
fAllCutCmd = new G4UIcmdWithADoubleAndUnit("/testem/phys/setCuts",this);
fAllCutCmd->SetGuidance("Set cut for all.");
fAllCutCmd->SetParameterName("cut",false);
fAllCutCmd->SetUnitCategory("Length");
fAllCutCmd->SetRange("cut>0.0");
fAllCutCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
}
@@ -83,36 +85,36 @@ PhysicsListMessenger::PhysicsListMessenger(PhysicsList* pPhys)
PhysicsListMessenger::~PhysicsListMessenger()
{
delete pListCmd;
delete gammaCutCmd;
delete electCutCmd;
delete protoCutCmd;
delete allCutCmd;
delete physDir;
delete fListCmd;
delete fGammaCutCmd;
delete fElectCutCmd;
delete fProtoCutCmd;
delete fAllCutCmd;
delete fPhysDir;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void PhysicsListMessenger::SetNewValue(G4UIcommand* command, G4String newValue)
{
if( command == pListCmd )
{ pPhysicsList->AddPhysicsList(newValue);}
if( command == fListCmd )
{ fPhysicsList->AddPhysicsList(newValue);}
if( command == gammaCutCmd )
{ pPhysicsList->SetCutForGamma(gammaCutCmd->GetNewDoubleValue(newValue));}
if( command == fGammaCutCmd )
{ fPhysicsList->SetCutForGamma(fGammaCutCmd->GetNewDoubleValue(newValue));}
if( command == electCutCmd )
{ pPhysicsList->SetCutForElectron(electCutCmd->GetNewDoubleValue(newValue));}
if( command == fElectCutCmd )
{ fPhysicsList->SetCutForElectron(fElectCutCmd->GetNewDoubleValue(newValue));}
if( command == protoCutCmd )
{ pPhysicsList->SetCutForPositron(protoCutCmd->GetNewDoubleValue(newValue));}
if( command == fProtoCutCmd )
{ fPhysicsList->SetCutForPositron(fProtoCutCmd->GetNewDoubleValue(newValue));}
if( command == allCutCmd )
if( command == fAllCutCmd )
{
G4double cut = allCutCmd->GetNewDoubleValue(newValue);
pPhysicsList->SetCutForGamma(cut);
pPhysicsList->SetCutForElectron(cut);
pPhysicsList->SetCutForPositron(cut);
G4double cut = fAllCutCmd->GetNewDoubleValue(newValue);
fPhysicsList->SetCutForGamma(cut);
fPhysicsList->SetCutForElectron(cut);
fPhysicsList->SetCutForPositron(cut);
}
}
@@ -23,8 +23,10 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: PrimaryGeneratorAction.cc,v 1.4 2006-06-29 16:56:09 gunter Exp $
// GEANT4 tag $Name: not supported by cvs2svn $
/// \file electromagnetic/TestEm5/src/PrimaryGeneratorAction.cc
/// \brief Implementation of the PrimaryGeneratorAction class
//
// $Id$
//
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -37,29 +39,30 @@
#include "G4Event.hh"
#include "G4ParticleTable.hh"
#include "G4ParticleDefinition.hh"
#include "G4SystemOfUnits.hh"
#include "Randomize.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
PrimaryGeneratorAction::PrimaryGeneratorAction(
DetectorConstruction* DC)
:Detector(DC)
:fDetector(DC)
{
G4int n_particle = 1;
particleGun = new G4ParticleGun(n_particle);
fParticleGun = new G4ParticleGun(n_particle);
SetDefaultKinematic();
rndmBeam = 0.;
fRndmBeam = 0.;
//create a messenger for this class
gunMessenger = new PrimaryGeneratorMessenger(this);
fGunMessenger = new PrimaryGeneratorMessenger(this);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
PrimaryGeneratorAction::~PrimaryGeneratorAction()
{
delete particleGun;
delete gunMessenger;
delete fParticleGun;
delete fGunMessenger;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -71,11 +74,11 @@ void PrimaryGeneratorAction::SetDefaultKinematic()
G4ParticleTable* particleTable = G4ParticleTable::GetParticleTable();
G4ParticleDefinition* particle
= particleTable->FindParticle("e-");
particleGun->SetParticleDefinition(particle);
particleGun->SetParticleMomentumDirection(G4ThreeVector(1.,0.,0.));
particleGun->SetParticleEnergy(30.*MeV);
G4double x0 = -0.5*(Detector->GetWorldSizeX());
particleGun->SetParticlePosition(G4ThreeVector(x0, 0*cm, 0*cm));
fParticleGun->SetParticleDefinition(particle);
fParticleGun->SetParticleMomentumDirection(G4ThreeVector(1.,0.,0.));
fParticleGun->SetParticleEnergy(30.*MeV);
G4double x0 = -0.5*(fDetector->GetWorldSizeX());
fParticleGun->SetParticlePosition(G4ThreeVector(x0, 0*cm, 0*cm));
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -85,18 +88,18 @@ void PrimaryGeneratorAction::GeneratePrimaries(G4Event* anEvent)
//this function is called at the begining of event
//
//randomize the beam, if requested.
if (rndmBeam > 0.)
if (fRndmBeam > 0.)
{
G4ThreeVector oldPosition = particleGun->GetParticlePosition();
G4double rbeam = 0.5*(Detector->GetAbsorberSizeYZ())*rndmBeam;
G4ThreeVector oldPosition = fParticleGun->GetParticlePosition();
G4double rbeam = 0.5*(fDetector->GetAbsorberSizeYZ())*fRndmBeam;
G4double x0 = oldPosition.x();
G4double y0 = oldPosition.y() + (2*G4UniformRand()-1.)*rbeam;
G4double z0 = oldPosition.z() + (2*G4UniformRand()-1.)*rbeam;
particleGun->SetParticlePosition(G4ThreeVector(x0,y0,z0));
particleGun->GeneratePrimaryVertex(anEvent);
particleGun->SetParticlePosition(oldPosition);
fParticleGun->SetParticlePosition(G4ThreeVector(x0,y0,z0));
fParticleGun->GeneratePrimaryVertex(anEvent);
fParticleGun->SetParticlePosition(oldPosition);
}
else particleGun->GeneratePrimaryVertex(anEvent);
else fParticleGun->GeneratePrimaryVertex(anEvent);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -23,8 +23,10 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: PrimaryGeneratorMessenger.cc,v 1.4 2006-06-29 16:56:12 gunter Exp $
// GEANT4 tag $Name: not supported by cvs2svn $
/// \file electromagnetic/TestEm5/src/PrimaryGeneratorMessenger.cc
/// \brief Implementation of the PrimaryGeneratorMessenger class
//
// $Id$
//
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -40,30 +42,30 @@
PrimaryGeneratorMessenger::PrimaryGeneratorMessenger(
PrimaryGeneratorAction* Gun)
:Action(Gun)
:fAction(Gun)
{
gunDir = new G4UIdirectory("/testem/gun/");
gunDir->SetGuidance("gun control");
fGunDir = new G4UIdirectory("/testem/gun/");
fGunDir->SetGuidance("gun control");
DefaultCmd = new G4UIcmdWithoutParameter("/testem/gun/setDefault",this);
DefaultCmd->SetGuidance("set/reset the kinematic defined in PrimaryGenerator");
DefaultCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
fDefaultCmd = new G4UIcmdWithoutParameter("/testem/gun/setDefault",this);
fDefaultCmd->SetGuidance("set/reset the kinematic defined in PrimaryGenerator");
fDefaultCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
RndmCmd = new G4UIcmdWithADouble("/testem/gun/rndm",this);
RndmCmd->SetGuidance("random lateral extension on the beam");
RndmCmd->SetGuidance("in fraction of 0.5*sizeYZ");
RndmCmd->SetParameterName("rBeam",false);
RndmCmd->SetRange("rBeam>=0.&&rBeam<=1.");
RndmCmd->AvailableForStates(G4State_Idle);
fRndmCmd = new G4UIcmdWithADouble("/testem/gun/rndm",this);
fRndmCmd->SetGuidance("random lateral extension on the beam");
fRndmCmd->SetGuidance("in fraction of 0.5*sizeYZ");
fRndmCmd->SetParameterName("rBeam",false);
fRndmCmd->SetRange("rBeam>=0.&&rBeam<=1.");
fRndmCmd->AvailableForStates(G4State_Idle);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
PrimaryGeneratorMessenger::~PrimaryGeneratorMessenger()
{
delete DefaultCmd;
delete RndmCmd;
delete gunDir;
delete fDefaultCmd;
delete fRndmCmd;
delete fGunDir;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -71,11 +73,11 @@ PrimaryGeneratorMessenger::~PrimaryGeneratorMessenger()
void PrimaryGeneratorMessenger::SetNewValue(G4UIcommand* command,
G4String newValue)
{
if (command == DefaultCmd)
{Action->SetDefaultKinematic();}
if (command == fDefaultCmd)
{fAction->SetDefaultKinematic();}
if (command == RndmCmd)
{ Action->SetRndmBeam(RndmCmd->GetNewDoubleValue(newValue));}
if (command == fRndmCmd)
{ fAction->SetRndmBeam(fRndmCmd->GetNewDoubleValue(newValue));}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -23,8 +23,10 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: RunAction.cc,v 1.29 2009-06-18 19:08:18 vnivanch Exp $
// GEANT4 tag $Name: not supported by cvs2svn $
/// \file electromagnetic/TestEm5/src/RunAction.cc
/// \brief Implementation of the RunAction class
//
// $Id$
//
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -40,19 +42,24 @@
#include "G4EmCalculator.hh"
#include "Randomize.hh"
#include "G4SystemOfUnits.hh"
#include <iomanip>
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
RunAction::RunAction(DetectorConstruction* det, PrimaryGeneratorAction* kin,
HistoManager* histo)
:detector(det), primary(kin), histoManager(histo)
{ }
RunAction::RunAction(DetectorConstruction* det, PrimaryGeneratorAction* kin)
:fDetector(det), fPrimary(kin), fHistoManager(0)
{
// Book predefined histograms
fHistoManager = new HistoManager();
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
RunAction::~RunAction()
{ }
{
delete fHistoManager;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -61,26 +68,29 @@ void RunAction::BeginOfRunAction(const G4Run* aRun)
G4cout << "### Run " << aRun->GetRunID() << " start." << G4endl;
//initialisation
EnergyDeposit = EnergyDeposit2 = 0.;
TrakLenCharged = TrakLenCharged2 = 0.;
TrakLenNeutral = TrakLenNeutral2 = 0.;
nbStepsCharged = nbStepsCharged2 = 0.;
nbStepsNeutral = nbStepsNeutral2 = 0.;
MscProjecTheta = MscProjecTheta2 = 0.;
MscThetaCentral = 3*ComputeMscHighland();
fEnergyDeposit = fEnergyDeposit2 = 0.;
fTrakLenCharged = fTrakLenCharged2 = 0.;
fTrakLenNeutral = fTrakLenNeutral2 = 0.;
fNbStepsCharged = fNbStepsCharged2 = 0.;
fNbStepsNeutral = fNbStepsNeutral2 = 0.;
fMscProjecTheta = fMscProjecTheta2 = 0.;
fMscThetaCentral = 3*ComputeMscHighland();
nbGamma = nbElect = nbPosit = 0;
fNbGamma = fNbElect = fNbPosit = 0;
Transmit[0] = Transmit[1] = Reflect[0] = Reflect[1] = 0;
fTransmit[0] = fTransmit[1] = fReflect[0] = fReflect[1] = 0;
MscEntryCentral = 0;
fMscEntryCentral = 0;
EnergyLeak[0] = EnergyLeak[1] = EnergyLeak2[0] = EnergyLeak2[1] = 0.;
fEnergyLeak[0] = fEnergyLeak[1] = fEnergyLeak2[0] = fEnergyLeak2[1] = 0.;
histoManager->book();
G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
if ( analysisManager->IsActive() ) {
analysisManager->OpenFile();
}
// save Rndm status
G4RunManager::GetRunManager()->SetRandomNumberStore(true);
//// G4RunManager::GetRunManager()->SetRandomNumberStore(true);
CLHEP::HepRandom::showEngineStatus();
}
@@ -93,75 +103,77 @@ void RunAction::EndOfRunAction(const G4Run* aRun)
G4int TotNbofEvents = aRun->GetNumberOfEvent();
if (TotNbofEvents == 0) return;
G4double EnergyBalance = EnergyDeposit + EnergyLeak[0] + EnergyLeak[1];
G4double EnergyBalance = fEnergyDeposit + fEnergyLeak[0] + fEnergyLeak[1];
EnergyBalance /= TotNbofEvents;
EnergyDeposit /= TotNbofEvents; EnergyDeposit2 /= TotNbofEvents;
G4double rmsEdep = EnergyDeposit2 - EnergyDeposit*EnergyDeposit;
fEnergyDeposit /= TotNbofEvents; fEnergyDeposit2 /= TotNbofEvents;
G4double rmsEdep = fEnergyDeposit2 - fEnergyDeposit*fEnergyDeposit;
if (rmsEdep>0.) rmsEdep = std::sqrt(rmsEdep/TotNbofEvents);
else rmsEdep = 0.;
TrakLenCharged /= TotNbofEvents; TrakLenCharged2 /= TotNbofEvents;
G4double rmsTLCh = TrakLenCharged2 - TrakLenCharged*TrakLenCharged;
fTrakLenCharged /= TotNbofEvents; fTrakLenCharged2 /= TotNbofEvents;
G4double rmsTLCh = fTrakLenCharged2 - fTrakLenCharged*fTrakLenCharged;
if (rmsTLCh>0.) rmsTLCh = std::sqrt(rmsTLCh/TotNbofEvents);
else rmsTLCh = 0.;
TrakLenNeutral /= TotNbofEvents; TrakLenNeutral2 /= TotNbofEvents;
G4double rmsTLNe = TrakLenNeutral2 - TrakLenNeutral*TrakLenNeutral;
fTrakLenNeutral /= TotNbofEvents; fTrakLenNeutral2 /= TotNbofEvents;
G4double rmsTLNe = fTrakLenNeutral2 - fTrakLenNeutral*fTrakLenNeutral;
if (rmsTLNe>0.) rmsTLNe = std::sqrt(rmsTLNe/TotNbofEvents);
else rmsTLNe = 0.;
nbStepsCharged /= TotNbofEvents; nbStepsCharged2 /= TotNbofEvents;
G4double rmsStCh = nbStepsCharged2 - nbStepsCharged*nbStepsCharged;
fNbStepsCharged /= TotNbofEvents; fNbStepsCharged2 /= TotNbofEvents;
G4double rmsStCh = fNbStepsCharged2 - fNbStepsCharged*fNbStepsCharged;
if (rmsStCh>0.) rmsStCh = std::sqrt(rmsTLCh/TotNbofEvents);
else rmsStCh = 0.;
nbStepsNeutral /= TotNbofEvents; nbStepsNeutral2 /= TotNbofEvents;
G4double rmsStNe = nbStepsNeutral2 - nbStepsNeutral*nbStepsNeutral;
fNbStepsNeutral /= TotNbofEvents; fNbStepsNeutral2 /= TotNbofEvents;
G4double rmsStNe = fNbStepsNeutral2 - fNbStepsNeutral*fNbStepsNeutral;
if (rmsStNe>0.) rmsStNe = std::sqrt(rmsTLCh/TotNbofEvents);
else rmsStNe = 0.;
G4double Gamma = (G4double)nbGamma/TotNbofEvents;
G4double Elect = (G4double)nbElect/TotNbofEvents;
G4double Posit = (G4double)nbPosit/TotNbofEvents;
G4double Gamma = (G4double)fNbGamma/TotNbofEvents;
G4double Elect = (G4double)fNbElect/TotNbofEvents;
G4double Posit = (G4double)fNbPosit/TotNbofEvents;
G4double transmit[2];
transmit[0] = 100.*Transmit[0]/TotNbofEvents;
transmit[1] = 100.*Transmit[1]/TotNbofEvents;
transmit[0] = 100.*fTransmit[0]/TotNbofEvents;
transmit[1] = 100.*fTransmit[1]/TotNbofEvents;
G4double reflect[2];
reflect[0] = 100.*Reflect[0]/TotNbofEvents;
reflect[1] = 100.*Reflect[1]/TotNbofEvents;
reflect[0] = 100.*fReflect[0]/TotNbofEvents;
reflect[1] = 100.*fReflect[1]/TotNbofEvents;
G4double rmsMsc = 0., tailMsc = 0.;
if (MscEntryCentral > 0) {
MscProjecTheta /= MscEntryCentral; MscProjecTheta2 /= MscEntryCentral;
rmsMsc = MscProjecTheta2 - MscProjecTheta*MscProjecTheta;
if (rmsMsc > 0.) rmsMsc = std::sqrt(rmsMsc);
tailMsc = 100.- (100.*MscEntryCentral)/(2*Transmit[1]);
if (fMscEntryCentral > 0) {
fMscProjecTheta /= fMscEntryCentral; fMscProjecTheta2 /= fMscEntryCentral;
rmsMsc = fMscProjecTheta2 - fMscProjecTheta*fMscProjecTheta;
if (rmsMsc > 0.) { rmsMsc = std::sqrt(rmsMsc); }
if(fTransmit[1] > 0.0) {
tailMsc = 100.- (100.*fMscEntryCentral)/(2*fTransmit[1]);
}
}
EnergyLeak[0] /= TotNbofEvents; EnergyLeak2[0] /= TotNbofEvents;
G4double rmsEl0 = EnergyLeak2[0] - EnergyLeak[0]*EnergyLeak[0];
fEnergyLeak[0] /= TotNbofEvents; fEnergyLeak2[0] /= TotNbofEvents;
G4double rmsEl0 = fEnergyLeak2[0] - fEnergyLeak[0]*fEnergyLeak[0];
if (rmsEl0>0.) rmsEl0 = std::sqrt(rmsEl0/TotNbofEvents);
else rmsEl0 = 0.;
EnergyLeak[1] /= TotNbofEvents; EnergyLeak2[1] /= TotNbofEvents;
G4double rmsEl1 = EnergyLeak2[1] - EnergyLeak[1]*EnergyLeak[1];
fEnergyLeak[1] /= TotNbofEvents; fEnergyLeak2[1] /= TotNbofEvents;
G4double rmsEl1 = fEnergyLeak2[1] - fEnergyLeak[1]*fEnergyLeak[1];
if (rmsEl1>0.) rmsEl1 = std::sqrt(rmsEl1/TotNbofEvents);
else rmsEl1 = 0.;
//Stopping Power from input Table.
//
G4Material* material = detector->GetAbsorberMaterial();
G4double length = detector->GetAbsorberThickness();
G4Material* material = fDetector->GetAbsorberMaterial();
G4double length = fDetector->GetAbsorberThickness();
G4double density = material->GetDensity();
G4ParticleDefinition* particle = primary->GetParticleGun()
G4ParticleDefinition* particle = fPrimary->GetParticleGun()
->GetParticleDefinition();
G4String partName = particle->GetParticleName();
G4double energy = primary->GetParticleGun()->GetParticleEnergy();
G4double energy = fPrimary->GetParticleGun()->GetParticleEnergy();
G4EmCalculator emCalculator;
G4double dEdxTable = 0., dEdxFull = 0.;
@@ -174,7 +186,7 @@ void RunAction::EndOfRunAction(const G4Run* aRun)
//Stopping Power from simulation.
//
G4double meandEdx = EnergyDeposit/length;
G4double meandEdx = fEnergyDeposit/length;
G4double stopPower = meandEdx/density;
G4cout << "\n ======================== run summary ======================\n";
@@ -183,59 +195,59 @@ void RunAction::EndOfRunAction(const G4Run* aRun)
G4cout << "\n The run was " << TotNbofEvents << " " << partName << " of "
<< G4BestUnit(energy,"Energy") << " through "
<< G4BestUnit(length,"Length") << " of "
<< material->GetName() << " (density: "
<< G4BestUnit(density,"Volumic Mass") << ")" << G4endl;
<< G4BestUnit(length,"Length") << " of "
<< material->GetName() << " (density: "
<< G4BestUnit(density,"Volumic Mass") << ")" << G4endl;
G4cout.precision(4);
G4cout << "\n Total energy deposit in absorber per event = "
<< G4BestUnit(EnergyDeposit,"Energy") << " +- "
<< G4BestUnit(fEnergyDeposit,"Energy") << " +- "
<< G4BestUnit(rmsEdep, "Energy")
<< G4endl;
G4cout << "\n -----> Mean dE/dx = " << meandEdx/(MeV/cm) << " MeV/cm"
<< "\t(" << stopPower/(MeV*cm2/g) << " MeV*cm2/g)"
<< G4endl;
<< G4endl;
G4cout << "\n From formulas :" << G4endl;
G4cout << " restricted dEdx = " << dEdxTable/(MeV/cm) << " MeV/cm"
<< "\t(" << stopTable/(MeV*cm2/g) << " MeV*cm2/g)"
<< G4endl;
<< G4endl;
G4cout << " full dEdx = " << dEdxFull/(MeV/cm) << " MeV/cm"
<< "\t(" << stopFull/(MeV*cm2/g) << " MeV*cm2/g)"
<< G4endl;
G4cout << "\n Leakage : primary = "
<< G4BestUnit(EnergyLeak[0],"Energy") << " +- "
<< G4BestUnit(rmsEl0, "Energy")
<< " secondaries = "
<< G4BestUnit(EnergyLeak[1],"Energy") << " +- "
<< G4BestUnit(rmsEl1, "Energy")
<< G4endl;
G4cout << "\n Leakage : primary = "
<< G4BestUnit(fEnergyLeak[0],"Energy") << " +- "
<< G4BestUnit(rmsEl0, "Energy")
<< " secondaries = "
<< G4BestUnit(fEnergyLeak[1],"Energy") << " +- "
<< G4BestUnit(rmsEl1, "Energy")
<< G4endl;
G4cout << " Energy balance : edep + eleak = "
<< G4BestUnit(EnergyBalance,"Energy")
<< G4endl;
<< G4endl;
G4cout << "\n Total track length (charged) in absorber per event = "
<< G4BestUnit(TrakLenCharged,"Length") << " +- "
<< G4BestUnit(fTrakLenCharged,"Length") << " +- "
<< G4BestUnit(rmsTLCh, "Length") << G4endl;
G4cout << " Total track length (neutral) in absorber per event = "
<< G4BestUnit(TrakLenNeutral,"Length") << " +- "
<< G4BestUnit(fTrakLenNeutral,"Length") << " +- "
<< G4BestUnit(rmsTLNe, "Length") << G4endl;
G4cout << "\n Number of steps (charged) in absorber per event = "
<< nbStepsCharged << " +- " << rmsStCh << G4endl;
<< fNbStepsCharged << " +- " << rmsStCh << G4endl;
G4cout << " Number of steps (neutral) in absorber per event = "
<< nbStepsNeutral << " +- " << rmsStNe << G4endl;
<< fNbStepsNeutral << " +- " << rmsStNe << G4endl;
G4cout << "\n Number of secondaries per event : Gammas = " << Gamma
<< "; electrons = " << Elect
<< "; positrons = " << Posit << G4endl;
<< "; positrons = " << Posit << G4endl;
G4cout << "\n Number of events with the primary particle transmitted = "
<< transmit[1] << " %" << G4endl;
@@ -252,38 +264,42 @@ void RunAction::EndOfRunAction(const G4Run* aRun)
// compute width of the Gaussian central part of the MultipleScattering
//
G4cout << "\n MultipleScattering:"
<< "\n rms proj angle of transmit primary particle = "
<< rmsMsc/mrad << " mrad (central part only)" << G4endl;
<< "\n rms proj angle of transmit primary particle = "
<< rmsMsc/mrad << " mrad (central part only)" << G4endl;
G4cout << " computed theta0 (Highland formula) = "
<< ComputeMscHighland()/mrad << " mrad" << G4endl;
<< ComputeMscHighland()/mrad << " mrad" << G4endl;
G4cout << " central part defined as +- "
<< MscThetaCentral/mrad << " mrad; "
<< " Tail ratio = " << tailMsc << " %" << G4endl;
<< fMscThetaCentral/mrad << " mrad; "
<< " Tail ratio = " << tailMsc << " %" << G4endl;
G4cout.precision(prec);
// normalize histograms
//
G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
G4int ih = 1;
G4double binWidth = histoManager->GetBinWidth(ih);
G4double unit = histoManager->GetHistoUnit(ih);
G4double binWidth = analysisManager->GetH1Width(ih);
G4double unit = analysisManager->GetH1Unit(ih);
G4double fac = unit/(TotNbofEvents*binWidth);
histoManager->Scale(ih,fac);
analysisManager->ScaleH1(ih,fac);
ih = 10;
binWidth = histoManager->GetBinWidth(ih);
unit = histoManager->GetHistoUnit(ih);
binWidth = analysisManager->GetH1Width(ih);
unit = analysisManager->GetH1Unit(ih);
fac = unit/(TotNbofEvents*binWidth);
histoManager->Scale(ih,fac);
analysisManager->ScaleH1(ih,fac);
ih = 12;
fac = 1./TotNbofEvents;
histoManager->Scale(ih,fac);
analysisManager->ScaleH1(ih,1./TotNbofEvents);
// save histograms
histoManager->save();
if ( analysisManager->IsActive() ) {
analysisManager->Write();
analysisManager->CloseFile();
}
// show Rndm status
CLHEP::HepRandom::showEngineStatus();
@@ -297,11 +313,11 @@ G4double RunAction::ComputeMscHighland()
//projected angular distribution.
//Eur. Phys. Jour. C15 (2000) page 166, formule 23.9
G4double t = (detector->GetAbsorberThickness())
/(detector->GetAbsorberMaterial()->GetRadlen());
G4double t = (fDetector->GetAbsorberThickness())
/(fDetector->GetAbsorberMaterial()->GetRadlen());
if (t < DBL_MIN) return 0.;
G4ParticleGun* particle = primary->GetParticleGun();
G4ParticleGun* particle = fPrimary->GetParticleGun();
G4double T = particle->GetParticleEnergy();
G4double M = particle->GetParticleDefinition()->GetPDGMass();
G4double z = std::abs(particle->GetParticleDefinition()->GetPDGCharge()/eplus);
@@ -23,8 +23,10 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: StackingAction.cc,v 1.8 2009-03-06 18:04:23 maire Exp $
// GEANT4 tag $Name: not supported by cvs2svn $
/// \file electromagnetic/TestEm5/src/StackingAction.cc
/// \brief Implementation of the StackingAction class
//
// $Id$
//
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -40,18 +42,18 @@
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
StackingAction::StackingAction(RunAction* RA, EventAction* EA, HistoManager* HM)
:runaction(RA), eventaction(EA), histoManager(HM)
StackingAction::StackingAction(RunAction* RA, EventAction* EA)
:fRunAction(RA), fEventAction(EA)
{
killSecondary = 0;
stackMessenger = new StackingMessenger(this);
fKillSecondary = 0;
fStackMessenger = new StackingMessenger(this);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
StackingAction::~StackingAction()
{
delete stackMessenger;
delete fStackMessenger;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -59,11 +61,13 @@ StackingAction::~StackingAction()
G4ClassificationOfNewTrack
StackingAction::ClassifyNewTrack(const G4Track* aTrack)
{
G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
//keep primary particle
if (aTrack->GetParentID() == 0) return fUrgent;
//count secondary particles
runaction->CountParticles(aTrack->GetDefinition());
fRunAction->CountParticles(aTrack->GetDefinition());
//
//energy spectrum of secondaries
@@ -71,16 +75,21 @@ StackingAction::ClassifyNewTrack(const G4Track* aTrack)
G4double energy = aTrack->GetKineticEnergy();
G4double charge = aTrack->GetDefinition()->GetPDGCharge();
if (charge != 0.) histoManager->FillHisto(2,energy);
if (charge != 0.) {
analysisManager->FillH1(2,energy);
analysisManager->FillH1(4,energy);
}
if (aTrack->GetDefinition() == G4Gamma::Gamma())
histoManager->FillHisto(3, std::log10(energy/MeV));
if (aTrack->GetDefinition() == G4Gamma::Gamma()) {
analysisManager->FillH1(3,energy);
analysisManager->FillH1(5,energy);
}
//stack or delete secondaries
G4ClassificationOfNewTrack status = fUrgent;
if (killSecondary) {
if (killSecondary == 1) {
eventaction->AddEnergy(energy);
if (fKillSecondary) {
if (fKillSecondary == 1) {
fEventAction->AddEnergy(energy);
}
status = fKill;
}
@@ -23,8 +23,10 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: StackingMessenger.cc,v 1.5 2006-09-25 17:06:29 maire Exp $
// GEANT4 tag $Name: not supported by cvs2svn $
/// \file electromagnetic/TestEm5/src/StackingMessenger.cc
/// \brief Implementation of the StackingMessenger class
//
// $Id$
//
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -38,32 +40,32 @@
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
StackingMessenger::StackingMessenger(StackingAction* stack)
:stackAction(stack)
:fStackAction(stack)
{
stackDir = new G4UIdirectory("/testem/stack/");
stackDir->SetGuidance("stacking control");
fStackDir = new G4UIdirectory("/testem/stack/");
fStackDir->SetGuidance("stacking control");
killCmd = new G4UIcmdWithAnInteger("/testem/stack/killSecondaries",this);
killCmd->SetGuidance(" Choice: 0=no kill; 1=kill and record; 2=kill only");
killCmd->SetParameterName("choice",true);
killCmd->SetRange("choice>=0");
killCmd->SetDefaultValue(1);
fKillCmd = new G4UIcmdWithAnInteger("/testem/stack/killSecondaries",this);
fKillCmd->SetGuidance(" Choice: 0=no kill; 1=kill and record; 2=kill only");
fKillCmd->SetParameterName("choice",true);
fKillCmd->SetRange("choice>=0");
fKillCmd->SetDefaultValue(1);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
StackingMessenger::~StackingMessenger()
{
delete killCmd;
delete stackDir;
delete fKillCmd;
delete fStackDir;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void StackingMessenger::SetNewValue(G4UIcommand* command, G4String newValue)
{
if(command == killCmd)
{stackAction->SetKillStatus(killCmd->GetNewIntValue(newValue));}
if(command == fKillCmd)
{fStackAction->SetKillStatus(fKillCmd->GetNewIntValue(newValue));}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -23,8 +23,10 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: StepMax.cc,v 1.2 2006-06-29 16:56:21 gunter Exp $
// GEANT4 tag $Name: not supported by cvs2svn $
/// \file electromagnetic/TestEm5/src/StepMax.cc
/// \brief Implementation of the StepMax class
//
// $Id$
//
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -35,14 +37,14 @@
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
StepMax::StepMax(const G4String& processName)
: G4VDiscreteProcess(processName),MaxChargedStep(DBL_MAX)
: G4VDiscreteProcess(processName),fMaxChargedStep(DBL_MAX)
{
pMess = new StepMaxMessenger(this);
fMess = new StepMaxMessenger(this);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
StepMax::~StepMax() { delete pMess; }
StepMax::~StepMax() { delete fMess; }
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -53,7 +55,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......
@@ -66,10 +68,10 @@ G4double StepMax::PostStepGetPhysicalInteractionLength(const G4Track& aTrack,
G4double ProposedStep = DBL_MAX;
if((MaxChargedStep > 0.) &&
if((fMaxChargedStep > 0.) &&
(aTrack.GetVolume() != 0) &&
(aTrack.GetVolume()->GetName() == "Absorber"))
ProposedStep = MaxChargedStep;
ProposedStep = fMaxChargedStep;
return ProposedStep;
}
@@ -23,8 +23,10 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: StepMaxMessenger.cc,v 1.3 2006-06-29 16:56:23 gunter Exp $
// GEANT4 tag $Name: not supported by cvs2svn $
/// \file electromagnetic/TestEm5/src/StepMaxMessenger.cc
/// \brief Implementation of the StepMaxMessenger class
//
// $Id$
//
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -37,28 +39,28 @@
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
StepMaxMessenger::StepMaxMessenger(StepMax* stepM)
:pStepMax(stepM)
:fStepMax(stepM)
{
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......
@@ -23,8 +23,10 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: SteppingAction.cc,v 1.8 2009-03-06 18:04:23 maire Exp $
// GEANT4 tag $Name: not supported by cvs2svn $
/// \file electromagnetic/TestEm5/src/SteppingAction.cc
/// \brief Implementation of the SteppingAction class
//
// $Id$
//
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -41,8 +43,8 @@
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
SteppingAction::SteppingAction(DetectorConstruction* DET, RunAction* RA,
EventAction* EA, HistoManager* HM)
:detector(DET), runaction(RA), eventaction(EA), histoManager(HM)
EventAction* EA)
:fDetector(DET), fRunAction(RA), fEventAction(EA)
{ }
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -55,17 +57,17 @@ SteppingAction::~SteppingAction()
void SteppingAction::UserSteppingAction(const G4Step* aStep)
{
if (aStep->GetPreStepPoint()->GetTouchableHandle()->GetVolume()
!= detector->GetAbsorber()) return;
!= fDetector->GetAbsorber()) return;
eventaction->AddEnergy (aStep->GetTotalEnergyDeposit());
fEventAction->AddEnergy (aStep->GetTotalEnergyDeposit());
G4double charge = aStep->GetTrack()->GetDefinition()->GetPDGCharge();
if (charge != 0.) {
eventaction->AddTrakLenCharg(aStep->GetStepLength());
eventaction->CountStepsCharg();
fEventAction->AddTrakLenCharg(aStep->GetStepLength());
fEventAction->CountStepsCharg();
} else {
eventaction->AddTrakLenNeutr(aStep->GetStepLength());
eventaction->CountStepsNeutr();
fEventAction->AddTrakLenNeutr(aStep->GetStepLength());
fEventAction->CountStepsNeutr();
}
}
@@ -23,9 +23,11 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
/// \file electromagnetic/TestEm5/src/SteppingVerbose.cc
/// \brief Implementation of the SteppingVerbose class
//
// $Id: SteppingVerbose.cc,v 1.1 2010-09-16 16:26:13 gcosmo Exp $
// GEANT4 tag $Name: not supported by cvs2svn $
//
// $Id$
//
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -58,26 +60,26 @@ void SteppingVerbose::StepInfo()
if( verboseLevel >= 3 ){
G4cout << G4endl;
G4cout << std::setw( 5) << "#Step#" << " "
<< std::setw( 6) << "X" << " "
<< std::setw( 6) << "Y" << " "
<< std::setw( 6) << "Z" << " "
<< std::setw( 9) << "KineE" << " "
<< std::setw( 9) << "dEStep" << " "
<< std::setw(10) << "StepLeng"
<< std::setw(10) << "TrakLeng"
<< std::setw(10) << "Volume" << " "
<< std::setw(10) << "Process" << G4endl;
<< std::setw( 6) << "X" << " "
<< std::setw( 6) << "Y" << " "
<< std::setw( 6) << "Z" << " "
<< std::setw( 9) << "KineE" << " "
<< std::setw( 9) << "dEStep" << " "
<< std::setw(10) << "StepLeng"
<< std::setw(10) << "TrakLeng"
<< std::setw(10) << "Volume" << " "
<< std::setw(10) << "Process" << G4endl;
}
G4cout << std::setw( 5) << fTrack->GetCurrentStepNumber() << " "
<< std::setw(6) << G4BestUnit(fTrack->GetPosition().x(),"Length")
<< std::setw(6) << G4BestUnit(fTrack->GetPosition().y(),"Length")
<< std::setw(6) << G4BestUnit(fTrack->GetPosition().z(),"Length")
<< std::setw(6) << G4BestUnit(fTrack->GetKineticEnergy(),"Energy")
<< std::setw(6) << G4BestUnit(fStep->GetTotalEnergyDeposit(),"Energy")
<< std::setw(6) << G4BestUnit(fStep->GetStepLength(),"Length")
<< std::setw(6) << G4BestUnit(fTrack->GetTrackLength(),"Length")
<< std::setw(10) << fTrack->GetVolume()->GetName();
<< std::setw(6) << G4BestUnit(fTrack->GetPosition().x(),"Length")
<< std::setw(6) << G4BestUnit(fTrack->GetPosition().y(),"Length")
<< std::setw(6) << G4BestUnit(fTrack->GetPosition().z(),"Length")
<< std::setw(6) << G4BestUnit(fTrack->GetKineticEnergy(),"Energy")
<< std::setw(6) << G4BestUnit(fStep->GetTotalEnergyDeposit(),"Energy")
<< std::setw(6) << G4BestUnit(fStep->GetStepLength(),"Length")
<< std::setw(6) << G4BestUnit(fTrack->GetTrackLength(),"Length")
<< std::setw(10) << fTrack->GetVolume()->GetName();
const G4VProcess* process
= fStep->GetPostStepPoint()->GetProcessDefinedStep();
@@ -89,28 +91,28 @@ void SteppingVerbose::StepInfo()
if( verboseLevel == 2 ){
G4int tN2ndariesTot = fN2ndariesAtRestDoIt +
fN2ndariesAlongStepDoIt +
fN2ndariesPostStepDoIt;
fN2ndariesAlongStepDoIt +
fN2ndariesPostStepDoIt;
if(tN2ndariesTot>0){
G4cout << "\n :----- List of secondaries ----------------"
<< G4endl;
G4cout << "\n :----- List of secondaries ----------------"
<< G4endl;
G4cout.precision(4);
for(size_t lp1=(*fSecondary).size()-tN2ndariesTot;
for(size_t lp1=(*fSecondary).size()-tN2ndariesTot;
lp1<(*fSecondary).size(); lp1++){
G4cout << " "
<< std::setw(13)
<< (*fSecondary)[lp1]->GetDefinition()->GetParticleName()
<< ": energy ="
<< std::setw(6)
<< G4BestUnit((*fSecondary)[lp1]->GetKineticEnergy(),"Energy")
<< " time ="
<< std::setw(6)
<< G4BestUnit((*fSecondary)[lp1]->GetGlobalTime(),"Time");
G4cout << G4endl;
}
G4cout << " "
<< std::setw(13)
<< (*fSecondary)[lp1]->GetDefinition()->GetParticleName()
<< ": energy ="
<< std::setw(6)
<< G4BestUnit((*fSecondary)[lp1]->GetKineticEnergy(),"Energy")
<< " time ="
<< std::setw(6)
<< G4BestUnit((*fSecondary)[lp1]->GetGlobalTime(),"Time");
G4cout << G4endl;
}
G4cout << " :------------------------------------------\n"
<< G4endl;
G4cout << " :------------------------------------------\n"
<< G4endl;
}
}
@@ -129,25 +131,25 @@ G4int prec = G4cout.precision(3);
G4cout << std::setw( 5) << "Step#" << " "
<< std::setw( 6) << "X" << " "
<< std::setw( 6) << "Y" << " "
<< std::setw( 6) << "Z" << " "
<< std::setw( 9) << "KineE" << " "
<< std::setw( 9) << "dEStep" << " "
<< std::setw(10) << "StepLeng"
<< std::setw(10) << "TrakLeng"
<< std::setw(10) << "Volume" << " "
<< std::setw(10) << "Process" << G4endl;
<< std::setw( 6) << "Y" << " "
<< std::setw( 6) << "Z" << " "
<< std::setw( 9) << "KineE" << " "
<< std::setw( 9) << "dEStep" << " "
<< std::setw(10) << "StepLeng"
<< std::setw(10) << "TrakLeng"
<< std::setw(10) << "Volume" << " "
<< std::setw(10) << "Process" << G4endl;
G4cout << std::setw(5) << fTrack->GetCurrentStepNumber() << " "
<< std::setw(6) << G4BestUnit(fTrack->GetPosition().x(),"Length")
<< std::setw(6) << G4BestUnit(fTrack->GetPosition().y(),"Length")
<< std::setw(6) << G4BestUnit(fTrack->GetPosition().z(),"Length")
<< std::setw(6) << G4BestUnit(fTrack->GetKineticEnergy(),"Energy")
<< std::setw(6) << G4BestUnit(fStep->GetTotalEnergyDeposit(),"Energy")
<< std::setw(6) << G4BestUnit(fStep->GetStepLength(),"Length")
<< std::setw(6) << G4BestUnit(fTrack->GetTrackLength(),"Length")
<< std::setw(10) << fTrack->GetVolume()->GetName()
<< " initStep" << G4endl;
<< std::setw(6) << G4BestUnit(fTrack->GetPosition().x(),"Length")
<< std::setw(6) << G4BestUnit(fTrack->GetPosition().y(),"Length")
<< std::setw(6) << G4BestUnit(fTrack->GetPosition().z(),"Length")
<< std::setw(6) << G4BestUnit(fTrack->GetKineticEnergy(),"Energy")
<< std::setw(6) << G4BestUnit(fStep->GetTotalEnergyDeposit(),"Energy")
<< std::setw(6) << G4BestUnit(fStep->GetStepLength(),"Length")
<< std::setw(6) << G4BestUnit(fTrack->GetTrackLength(),"Length")
<< std::setw(10) << fTrack->GetVolume()->GetName()
<< " initStep" << G4endl;
}
G4cout.precision(prec);
}
@@ -23,9 +23,11 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
/// \file electromagnetic/TestEm5/src/TrackingAction.cc
/// \brief Implementation of the TrackingAction class
//
// $Id: TrackingAction.cc,v 1.18 2008-08-28 15:28:04 maire Exp $
// GEANT4 tag $Name: not supported by cvs2svn $
//
// $Id$
//
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -38,12 +40,14 @@
#include "HistoManager.hh"
#include "G4Track.hh"
#include "G4PhysicalConstants.hh"
#include "G4SystemOfUnits.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
TrackingAction::TrackingAction(DetectorConstruction* DET,RunAction* RA,
EventAction* EA, HistoManager* HM)
:detector(DET), runaction(RA), eventaction(EA), histoManager(HM)
EventAction* EA)
:fDetector(DET), fRunAction(RA), fEventAction(EA)
{ }
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -53,9 +57,9 @@ void TrackingAction::PreUserTrackingAction(const G4Track* aTrack )
// few initialisations
//
if (aTrack->GetTrackID() == 1) {
xstartAbs = detector->GetxstartAbs();
xendAbs = detector->GetxendAbs();
primaryCharge = aTrack->GetDefinition()->GetPDGCharge();
fXstartAbs = fDetector->GetxstartAbs();
fXendAbs = fDetector->GetxendAbs();
fPrimaryCharge = aTrack->GetDefinition()->GetPDGCharge();
}
}
@@ -63,21 +67,23 @@ void TrackingAction::PreUserTrackingAction(const G4Track* aTrack )
void TrackingAction::PostUserTrackingAction(const G4Track* aTrack)
{
G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
G4ThreeVector position = aTrack->GetPosition();
G4ThreeVector vertex = aTrack->GetVertexPosition();
G4double charge = aTrack->GetDefinition()->GetPDGCharge();
G4bool transmit = ((position.x() >= xendAbs) && (vertex.x() < xendAbs));
G4bool reflect = (position.x() <= xstartAbs);
G4bool transmit = ((position.x() >= fXendAbs) && (vertex.x() < fXendAbs));
G4bool reflect = (position.x() <= fXstartAbs);
G4bool notabsor = (transmit || reflect);
//transmitted + reflected particles counter
//
G4int flag = 0;
if (charge == primaryCharge) flag = 1;
if (charge == fPrimaryCharge) flag = 1;
if (aTrack->GetTrackID() == 1) flag = 2;
if (transmit) eventaction->SetTransmitFlag(flag);
if (reflect) eventaction->SetReflectFlag(flag);
if (transmit) fEventAction->SetTransmitFlag(flag);
if (reflect) fEventAction->SetReflectFlag(flag);
//
//histograms
@@ -94,7 +100,7 @@ void TrackingAction::PostUserTrackingAction(const G4Track* aTrack)
else if (reflect && neutral) id = 40;
if (id>0)
histoManager->FillHisto(id, aTrack->GetKineticEnergy());
analysisManager->FillH1(id, aTrack->GetKineticEnergy());
//energy leakage
//
@@ -104,7 +110,7 @@ void TrackingAction::PostUserTrackingAction(const G4Track* aTrack)
G4double eleak = aTrack->GetKineticEnergy();
if ((aTrack->GetDefinition() == G4Positron::Positron()) && (trackID > 1))
eleak += 2*electron_mass_c2;
runaction->AddEnergyLeak(eleak,index);
fRunAction->AddEnergyLeak(eleak,index);
}
//space angle distribution at exit : dN/dOmega
@@ -118,45 +124,58 @@ void TrackingAction::PostUserTrackingAction(const G4Track* aTrack)
if (id>0) {
G4double theta = std::acos(direction.x());
G4double dteta = histoManager->GetBinWidth(id);
G4double unit = histoManager->GetHistoUnit(id);
G4double weight = (unit*unit)/(twopi*std::sin(theta)*dteta);
histoManager->FillHisto(id,theta,weight);
if (theta > 0.0) {
G4double dteta = analysisManager->GetH1Width(id);
G4double unit = analysisManager->GetH1Unit(id);
G4double weight = (unit*unit)/(twopi*std::sin(theta)*dteta);
/*
G4cout << "theta, dteta, unit, weight: "
<< theta << " "
<< dteta << " "
<< unit << " "
<< weight << G4endl;
*/
analysisManager->FillH1(id,theta,weight);
}
}
//energy fluence at exit : dE(MeV)/dOmega
//
id = 0;
if (transmit && charged) id = 11;
if (transmit && charged) id = 11;
else if (transmit && neutral) id = 21;
else if (reflect && charged) id = 31;
else if (reflect && neutral) id = 41;
if (id>0) {
G4double theta = std::acos(direction.x());
G4double dteta = histoManager->GetBinWidth(id);
G4double unit = histoManager->GetHistoUnit(id);
G4double weight = (unit*unit)/(twopi*std::sin(theta)*dteta);
weight *= (aTrack->GetKineticEnergy()/MeV);
histoManager->FillHisto(id,theta,weight);
if (theta > 0.0) {
G4double dteta = analysisManager->GetH1Width(id);
G4double unit = analysisManager->GetH1Unit(id);
G4double weight = (unit*unit)/(twopi*std::sin(theta)*dteta);
weight *= (aTrack->GetKineticEnergy()/MeV);
analysisManager->FillH1(id,theta,weight);
}
}
//projected angles distribution at exit
//
id = 0;
if (transmit && charged) id = 13;
if (transmit && charged) id = 13;
else if (transmit && neutral) id = 23;
else if (reflect && charged) id = 33;
else if (reflect && neutral) id = 43;
if(id>0) {
G4double tet = std::atan(direction.y()/std::fabs(direction.x()));
histoManager->FillHisto(id,tet);
if (transmit && (flag == 2)) runaction->AddMscProjTheta(tet);
if (id>0) {
if (direction.x() != 0.0) {
G4double tet = std::atan(direction.y()/std::fabs(direction.x()));
analysisManager->FillH1(id,tet);
if (transmit && (flag == 2)) fRunAction->AddMscProjTheta(tet);
tet = std::atan(direction.z()/std::fabs(direction.x()));
histoManager->FillHisto(id,tet);
if (transmit && (flag == 2)) runaction->AddMscProjTheta(tet);
tet = std::atan(direction.z()/std::fabs(direction.x()));
analysisManager->FillH1(id,tet);
if (transmit && (flag == 2)) fRunAction->AddMscProjTheta(tet);
}
}
//projected position and radius at exit
@@ -167,17 +186,17 @@ void TrackingAction::PostUserTrackingAction(const G4Track* aTrack)
if (id>0) {
G4double y = position.y(), z = position.z();
G4double r = std::sqrt(y*y + z*z);
histoManager->FillHisto(id, y);
histoManager->FillHisto(id, z);
histoManager->FillHisto(id+1, r);
analysisManager->FillH1(id, y);
analysisManager->FillH1(id, z);
analysisManager->FillH1(id+1, r);
}
//x-vertex of charged secondaries
//
if ((aTrack->GetParentID() == 1) && charged) {
G4double xVertex = (aTrack->GetVertexPosition()).x();
histoManager->FillHisto(4, xVertex);
if (notabsor) histoManager->FillHisto(5, xVertex);
analysisManager->FillH1(6, xVertex);
if (notabsor) analysisManager->FillH1(7, xVertex);
}
}