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,9 +23,11 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
/// \file electromagnetic/TestEm9/src/DetectorConstruction.cc
/// \brief Implementation of the DetectorConstruction class
//
// $Id: DetectorConstruction.cc,v 1.14 2009-11-21 17:28:16 vnivanch Exp $
// GEANT4 tag $Name: not supported by cvs2svn $
//
// $Id$
//
//
/////////////////////////////////////////////////////////////////////////
@@ -67,6 +69,7 @@
#include "G4Colour.hh"
#include "G4UnitsTable.hh"
#include "G4SystemOfUnits.hh"
#include "G4ios.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -74,31 +77,36 @@
DetectorConstruction::DetectorConstruction()
: G4VUserDetectorConstruction()
{
detectorMessenger = new DetectorMessenger(this);
fDetectorMessenger = new DetectorMessenger(this);
fEcalLength = 36.*cm;
fEcalWidth = 6.*cm;
fVertexLength = 3.*cm;
fPadLength = 0.1*mm;
fPadWidth = 0.02*mm;
fAbsLength = 2.*mm;
fWorldZ = 0.0;
fLogicWorld = 0;
fLogicCal = 0;
fLogicA1 = 0;
fLogicA2 = 0;
fLogicA3 = 0;
fLogicA4 = 0;
fVertexRegion = 0;
fMuonRegion = 0;
ecalLength = 36.*cm;
ecalWidth = 6.*cm;
vertexLength = 3.*cm;
padLength = 0.1*mm;
padWidth = 0.02*mm;
absLength = 2.*mm;
vertexRegion = 0;
muonRegion = 0;
logicWorld = 0;
logicCal = 0;
logicA1 = 0;
DefineMaterials();
vertexDetectorCuts = new G4ProductionCuts();
muonDetectorCuts = new G4ProductionCuts();
fVertexDetectorCuts = new G4ProductionCuts();
fMuonDetectorCuts = new G4ProductionCuts();
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
DetectorConstruction::~DetectorConstruction()
{
delete detectorMessenger;
delete vertexDetectorCuts;
delete muonDetectorCuts;
delete fDetectorMessenger;
delete fVertexDetectorCuts;
delete fMuonDetectorCuts;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -116,11 +124,11 @@ void DetectorConstruction::DefineMaterials()
G4NistManager* man = G4NistManager::Instance();
// man->SetVerbose(1);
worldMaterial = man->FindOrBuildMaterial("G4_AIR");
absMaterial = man->FindOrBuildMaterial("G4_Al");
vertMaterial = man->FindOrBuildMaterial("G4_Si");
yorkMaterial = man->FindOrBuildMaterial("G4_Fe");
calMaterial = man->FindOrBuildMaterial("G4_CESIUM_IODIDE");
fWorldMaterial = man->FindOrBuildMaterial("G4_AIR");
fAbsMaterial = man->FindOrBuildMaterial("G4_Al");
fVertMaterial = man->FindOrBuildMaterial("G4_Si");
fYorkMaterial = man->FindOrBuildMaterial("G4_Fe");
fCalMaterial = man->FindOrBuildMaterial("G4_CESIUM_IODIDE");
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -134,60 +142,61 @@ G4VPhysicalVolume* DetectorConstruction::ConstructVolumes()
if(G4NistManager::Instance()->GetVerbose() > 0)
G4cout << *(G4Material::GetMaterialTable()) << G4endl;
if(vertexRegion) {
delete vertexRegion;
delete muonRegion;
if(fVertexRegion) {
delete fVertexRegion;
delete fMuonRegion;
}
vertexRegion = new G4Region("VertexDetector");
vertexRegion->SetProductionCuts(vertexDetectorCuts);
fVertexRegion = new G4Region("VertexDetector");
fVertexRegion->SetProductionCuts(fVertexDetectorCuts);
muonRegion = new G4Region("MuonDetector");
muonRegion->SetProductionCuts(muonDetectorCuts);
fMuonRegion = new G4Region("MuonDetector");
fMuonRegion->SetProductionCuts(fMuonDetectorCuts);
G4SolidStore::GetInstance()->Clean();
G4LogicalVolumeStore::GetInstance()->Clean();
G4PhysicalVolumeStore::GetInstance()->Clean();
if(vertexLength < padLength*5.0) vertexLength = padLength*5.0;
if(fVertexLength < fPadLength*5.0) fVertexLength = fPadLength*5.0;
G4double gap = 0.01*mm;
G4double biggap = 2.*cm;
G4double york = 10.*cm;
worldZ = 2.*vertexLength + 3.*absLength + 0.5*(ecalLength + york) + biggap*2.;
fWorldZ = 2.*fVertexLength + 3.*fAbsLength + 0.5*(fEcalLength + york) + biggap*2.;
G4double worldX = ecalWidth*3.0;
G4double vertexZ= -worldZ + vertexLength*2.0 + absLength + biggap;
G4double absZ2 = -worldZ + vertexLength*4.0 + absLength*3.5 + biggap;
G4double ecalZ = -worldZ + vertexLength*4.0 + absLength*4.0 + ecalLength*0.5
G4double worldX = fEcalWidth*3.0;
G4double vertexZ= -fWorldZ + fVertexLength*2.0 + fAbsLength + biggap;
G4double absZ2 = -fWorldZ + fVertexLength*4.0 + fAbsLength*3.5 + biggap;
G4double ecalZ = -fWorldZ + fVertexLength*4.0 + fAbsLength*4.0 + fEcalLength*0.5
+ 2.*biggap;
G4double yorkZ = -worldZ + vertexLength*4.0 + absLength*5.0 + ecalLength
G4double yorkZ = -fWorldZ + fVertexLength*4.0 + fAbsLength*5.0 + fEcalLength
+ york*0.5 + 3.*biggap;
//
// World
//
G4Box* solidW = new G4Box("World",worldX,worldX,worldZ);
logicWorld = new G4LogicalVolume( solidW,worldMaterial,"World");
G4Box* solidW = new G4Box("World",worldX,worldX,fWorldZ);
fLogicWorld = new G4LogicalVolume( solidW,fWorldMaterial,"World");
G4VPhysicalVolume* world = new G4PVPlacement(0,G4ThreeVector(),
"World",logicWorld,0,false,0);
"World",fLogicWorld,0,false,0);
//
// Ecal
//
G4Box* solidE = new G4Box("VolE",worldX,worldX,ecalLength*0.5 + gap);
logicECal = new G4LogicalVolume( solidE,worldMaterial,"VolE");
G4Box* solidE = new G4Box("VolE",worldX,worldX,fEcalLength*0.5 + gap);
G4LogicalVolume* logicECal =
new G4LogicalVolume( solidE,fWorldMaterial,"VolE");
G4VPhysicalVolume* physE = new G4PVPlacement(0,G4ThreeVector(0.,0.,ecalZ),
"VolE",logicECal,world,false,0);
"VolE",logicECal,world,false,0);
G4Box* solidC = new G4Box("Ecal",ecalWidth*0.5,ecalWidth*0.5,ecalLength*0.5);
logicCal = new G4LogicalVolume( solidC,calMaterial,"Ecal");
G4Box* solidC = new G4Box("Ecal",fEcalWidth*0.5,fEcalWidth*0.5,fEcalLength*0.5);
fLogicCal = new G4LogicalVolume( solidC,fCalMaterial,"Ecal");
G4cout << "Ecal is " << G4BestUnit(ecalLength,"Length")
<< " of " << calMaterial->GetName() << G4endl;
G4cout << "Ecal is " << G4BestUnit(fEcalLength,"Length")
<< " of " << fCalMaterial->GetName() << G4endl;
// Crystals
G4double x0 = -(ecalWidth + gap)*2.0;
G4double x0 = -(fEcalWidth + gap)*2.0;
G4double y = x0;
G4double x;
G4int k = 0;
@@ -197,77 +206,81 @@ G4VPhysicalVolume* DetectorConstruction::ConstructVolumes()
x = x0;
for (j=0; j<5; j++) {
new G4PVPlacement(0,G4ThreeVector(x,y,0.),"Ecal",logicCal,
new G4PVPlacement(0,G4ThreeVector(x,y,0.),"Ecal",fLogicCal,
physE,false,k);
k++;
x += ecalWidth + gap;
x += fEcalWidth + gap;
}
y += ecalWidth + gap;
y += fEcalWidth + gap;
}
//Absorber
G4Box* solidA = new G4Box("Abso",worldX,worldX,absLength*0.5);
logicA2 = new G4LogicalVolume( solidA,absMaterial,"Abs2");
G4Box* solidA = new G4Box("Abso",worldX,worldX,fAbsLength*0.5);
fLogicA2 = new G4LogicalVolume( solidA,fAbsMaterial,"Abs2");
new G4PVPlacement(0,G4ThreeVector(0.,0.,absZ2),
"Abs2",logicA2,world,false,0);
"Abs2",fLogicA2,world,false,0);
G4cout << "Absorber is " << G4BestUnit(absLength,"Length")
<< " of " << absMaterial->GetName() << G4endl;
G4cout << "Absorber is " << G4BestUnit(fAbsLength,"Length")
<< " of " << fAbsMaterial->GetName() << G4endl;
//York
G4Box* solidYV = new G4Box("VolY",worldX,worldX,york*0.5+absLength);
logicYV = new G4LogicalVolume( solidYV,yorkMaterial,"VolY");
G4Box* solidYV = new G4Box("VolY",worldX,worldX,york*0.5+fAbsLength);
G4LogicalVolume* logicYV =
new G4LogicalVolume( solidYV,fYorkMaterial,"VolY");
G4VPhysicalVolume* physYV = new G4PVPlacement(0,G4ThreeVector(0.,0.,yorkZ),
"VolY",logicYV,world,false,0);
"VolY",logicYV,world,false,0);
G4Box* solidY = new G4Box("York",worldX,worldX,york*0.5);
logicY = new G4LogicalVolume( solidY,yorkMaterial,"York");
G4LogicalVolume* logicY =
new G4LogicalVolume( solidY,fYorkMaterial,"York");
new G4PVPlacement(0,G4ThreeVector(),
"York",logicY,physYV,false,0);
"York",logicY,physYV,false,0);
logicA3 = new G4LogicalVolume( solidA,absMaterial,"Abs3");
logicA4 = new G4LogicalVolume( solidA,absMaterial,"Abs4");
fLogicA3 = new G4LogicalVolume( solidA,fAbsMaterial,"Abs3");
fLogicA4 = new G4LogicalVolume( solidA,fAbsMaterial,"Abs4");
new G4PVPlacement(0,G4ThreeVector(0.,0.,-(york+absLength)*0.5),
"Abs3",logicA3,physYV,false,0);
new G4PVPlacement(0,G4ThreeVector(0.,0.,(york+absLength)*0.5),
"Abs4",logicA4,physYV,false,0);
new G4PVPlacement(0,G4ThreeVector(0.,0.,-(york+fAbsLength)*0.5),
"Abs3",fLogicA3,physYV,false,0);
new G4PVPlacement(0,G4ThreeVector(0.,0.,(york+fAbsLength)*0.5),
"Abs4",fLogicA4,physYV,false,0);
//Vertex volume
G4Box* solidVV = new G4Box("VolV",worldX,worldX,vertexLength*2.+absLength+gap);
logicVV = new G4LogicalVolume( solidVV,worldMaterial,"VolV");
G4Box* solidVV = new G4Box("VolV",worldX,worldX,fVertexLength*2.+fAbsLength+gap);
G4LogicalVolume* logicVV =
new G4LogicalVolume( solidVV,fWorldMaterial,"VolV");
G4VPhysicalVolume* physVV = new G4PVPlacement(0,G4ThreeVector(0.,0.,vertexZ),
"VolV",logicVV,world,false,0);
"VolV",logicVV,world,false,0);
//Absorber
logicA1 = new G4LogicalVolume( solidA,absMaterial,"Abs1");
new G4PVPlacement(0,G4ThreeVector(0.,0.,vertexLength*2.-absLength*0.5),
"Abs1",logicA1,physVV,false,0);
fLogicA1 = new G4LogicalVolume( solidA,fAbsMaterial,"Abs1");
new G4PVPlacement(0,G4ThreeVector(0.,0.,fVertexLength*2.-fAbsLength*0.5),
"Abs1",fLogicA1,physVV,false,0);
//Vertex
G4double vertWidth = ecalWidth/5.;
G4int npads = (G4int)(vertWidth/padWidth);
G4double vertWidth = fEcalWidth/5.;
G4int npads = (G4int)(vertWidth/fPadWidth);
//G4cout << " vertWidth= " << vertWidth << " padWidth= " << padWidth
// << " npads= " << npads << G4endl;
// << " npads= " << npads << G4endl;
// insure beam to hit a middle of central pad
npads = (npads/2)*2 + 1;
x0 = -0.5*(padWidth + vertWidth);
x0 = -0.5*(fPadWidth + vertWidth);
G4double x1 = 0.5*vertWidth + gap;
G4double z = -(vertexLength+absLength);
G4double z = -(fVertexLength+fAbsLength);
G4Box* solidVD = new G4Box("VertDet",x1,ecalWidth*0.5+gap,padLength*0.5);
logicVD = new G4LogicalVolume( solidVD,vertMaterial,"VertDet");
G4Box* solidVD = new G4Box("VertDet",x1,fEcalWidth*0.5+gap,fPadLength*0.5);
G4LogicalVolume* logicVD =
new G4LogicalVolume( solidVD,fVertMaterial,"VertDet");
logicVD->SetSolid(solidVD);
G4Box* solidV = new G4Box("Vert",padWidth*0.5,ecalWidth*0.5,padLength*0.5);
logicV = new G4LogicalVolume( solidV,vertMaterial,"Vert");
G4Box* solidV = new G4Box("Vert",fPadWidth*0.5,fEcalWidth*0.5,fPadLength*0.5);
G4LogicalVolume* logicV = new G4LogicalVolume( solidV,fVertMaterial,"Vert");
for (i=0; i<3; i++) {
new G4PVPlacement(0,G4ThreeVector(0.,0.,z),"VertDet",logicVD,
physVV,false,i);
z += vertexLength;
z += fVertexLength;
}
x = x0;
@@ -275,20 +288,20 @@ G4VPhysicalVolume* DetectorConstruction::ConstructVolumes()
new G4PVPlacement(0,G4ThreeVector(x,0.,0.),logicV,"Vert",logicVD,
false,k);
x += padWidth;
x += fPadWidth;
}
G4cout << "Vertex is " << G4BestUnit(vertexLength,"Length")
<< " of 3 layers of Si of " << G4BestUnit(padLength,"Length")
G4cout << "Vertex is " << G4BestUnit(fVertexLength,"Length")
<< " of 3 layers of Si of " << G4BestUnit(fPadLength,"Length")
<< " npads= " << npads
<< G4endl;
<< G4endl;
// Define region for the vertex detector
vertexRegion->AddRootLogicalVolume(logicVV);
vertexRegion->AddRootLogicalVolume(logicA3);
fVertexRegion->AddRootLogicalVolume(logicVV);
fVertexRegion->AddRootLogicalVolume(fLogicA3);
// Define region for the muon detector
muonRegion->AddRootLogicalVolume(logicYV);
fMuonRegion->AddRootLogicalVolume(logicYV);
// color regions
logicVV-> SetVisAttributes(G4VisAttributes::Invisible);
@@ -297,19 +310,19 @@ G4VPhysicalVolume* DetectorConstruction::ConstructVolumes()
logicYV-> SetVisAttributes(G4VisAttributes::Invisible);
G4VisAttributes* regWcolor = new G4VisAttributes(G4Colour(0.3, 0.3, 0.3));
logicWorld->SetVisAttributes(regWcolor);
fLogicWorld->SetVisAttributes(regWcolor);
G4VisAttributes* regVcolor = new G4VisAttributes(G4Colour(0., 0.3, 0.7));
logicVD->SetVisAttributes(regVcolor);
G4VisAttributes* regCcolor = new G4VisAttributes(G4Colour(0., 0.7, 0.3));
logicCal->SetVisAttributes(regCcolor);
fLogicCal->SetVisAttributes(regCcolor);
G4VisAttributes* regAcolor = new G4VisAttributes(G4Colour(1., 0.5, 0.5));
logicA1->SetVisAttributes(regAcolor);
logicA2->SetVisAttributes(regAcolor);
logicA3->SetVisAttributes(regAcolor);
logicA4->SetVisAttributes(regAcolor);
fLogicA1->SetVisAttributes(regAcolor);
fLogicA2->SetVisAttributes(regAcolor);
fLogicA3->SetVisAttributes(regAcolor);
fLogicA4->SetVisAttributes(regAcolor);
G4VisAttributes* regMcolor = new G4VisAttributes(G4Colour(1., 1., 0.));
logicY->SetVisAttributes(regMcolor);
@@ -327,10 +340,10 @@ void DetectorConstruction::SetEcalMaterial(const G4String& mat)
// search the material by its name
G4Material* pttoMaterial =
G4NistManager::Instance()->FindOrBuildMaterial(mat, false);
if (pttoMaterial) {
calMaterial = pttoMaterial;
if(logicCal) {
logicCal->SetMaterial(calMaterial);
if (pttoMaterial && pttoMaterial != fCalMaterial) {
fCalMaterial = pttoMaterial;
if(fLogicCal) {
fLogicCal->SetMaterial(fCalMaterial);
G4RunManager::GetRunManager()->PhysicsHasBeenModified();
}
}
@@ -343,13 +356,13 @@ void DetectorConstruction::SetAbsMaterial(const G4String& mat)
// search the material by its name
G4Material* pttoMaterial =
G4NistManager::Instance()->FindOrBuildMaterial(mat, false);
if (pttoMaterial) {
absMaterial = pttoMaterial;
if(logicA1) {
logicA1->SetMaterial(absMaterial);
logicA2->SetMaterial(absMaterial);
logicA3->SetMaterial(absMaterial);
logicA4->SetMaterial(absMaterial);
if (pttoMaterial && pttoMaterial != fAbsMaterial) {
fAbsMaterial = pttoMaterial;
if(fLogicA1) {
fLogicA1->SetMaterial(fAbsMaterial);
fLogicA2->SetMaterial(fAbsMaterial);
fLogicA3->SetMaterial(fAbsMaterial);
fLogicA4->SetMaterial(fAbsMaterial);
G4RunManager::GetRunManager()->PhysicsHasBeenModified();
}
}
@@ -368,7 +381,7 @@ void DetectorConstruction::UpdateGeometry()
void DetectorConstruction::SetEcalLength (G4double val)
{
if(val > 0.0) {
ecalLength = val;
fEcalLength = val;
G4RunManager::GetRunManager()->GeometryHasBeenModified();
}
}
@@ -378,7 +391,7 @@ void DetectorConstruction::SetEcalLength (G4double val)
void DetectorConstruction::SetEcalWidth (G4double val)
{
if(val > 0.0) {
ecalWidth = val;
fEcalWidth = val;
G4RunManager::GetRunManager()->GeometryHasBeenModified();
}
}
@@ -388,7 +401,7 @@ void DetectorConstruction::SetEcalWidth (G4double val)
void DetectorConstruction::SetVertexLength (G4double val)
{
if(val > 0.0) {
vertexLength = val;
fVertexLength = val;
G4RunManager::GetRunManager()->GeometryHasBeenModified();
}
}
@@ -398,7 +411,7 @@ void DetectorConstruction::SetVertexLength (G4double val)
void DetectorConstruction::SetPadLength (G4double val)
{
if(val > 0.0) {
padLength = val;
fPadLength = val;
G4RunManager::GetRunManager()->GeometryHasBeenModified();
}
}
@@ -408,7 +421,7 @@ void DetectorConstruction::SetPadLength (G4double val)
void DetectorConstruction::SetPadWidth (G4double val)
{
if(val > 0.0) {
padWidth = val;
fPadWidth = val;
G4RunManager::GetRunManager()->GeometryHasBeenModified();
}
}
@@ -418,7 +431,7 @@ void DetectorConstruction::SetPadWidth (G4double val)
void DetectorConstruction::SetAbsLength(G4double val)
{
if(val > 0.0) {
absLength = val;
fAbsLength = val;
G4RunManager::GetRunManager()->GeometryHasBeenModified();
}
}
@@ -23,9 +23,11 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
/// \file electromagnetic/TestEm9/src/DetectorMessenger.cc
/// \brief Implementation of the DetectorMessenger class
//
// $Id: DetectorMessenger.cc,v 1.3 2006-06-29 17:03:01 gunter Exp $
// GEANT4 tag $Name: not supported by cvs2svn $
//
// $Id$
//
//
/////////////////////////////////////////////////////////////////////////
@@ -54,86 +56,85 @@
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
DetectorMessenger::DetectorMessenger(DetectorConstruction * Det)
:Detector(Det)
DetectorMessenger::DetectorMessenger(DetectorConstruction * det)
:fDetector(det)
{
testemDir = new G4UIdirectory("/testem/");
testemDir->SetGuidance(" detector control.");
fAtestemDir = new G4UIdirectory("/testem/");
fAtestemDir->SetGuidance(" detector control.");
MaterCmd = new G4UIcmdWithAString("/testem/det/CalMat",this);
MaterCmd->SetGuidance("Select Material for calorimeter");
MaterCmd->SetParameterName("calMaterial",false);
MaterCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
fAMaterCmd = new G4UIcmdWithAString("/testem/det/CalMat",this);
fAMaterCmd->SetGuidance("Select Material for calorimeter");
fAMaterCmd->SetParameterName("calMaterial",false);
fAMaterCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
LBinCmd = new G4UIcmdWithAString("/testem/det/AbsMat",this);
LBinCmd->SetGuidance("Select Material for absorber");
LBinCmd->SetParameterName("absMarerial",false);
LBinCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
fALBinCmd = new G4UIcmdWithAString("/testem/det/AbsMat",this);
fALBinCmd->SetGuidance("Select Material for absorber");
fALBinCmd->SetParameterName("absMarerial",false);
fALBinCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
l1Cmd = new G4UIcmdWithADoubleAndUnit("/testem/det/EcalLength",this);
l1Cmd->SetGuidance("Set length of Ecal");
l1Cmd->SetParameterName("lEcal",false);
l1Cmd->SetUnitCategory("Length");
l1Cmd->SetRange("lEcal>0");
l1Cmd->AvailableForStates(G4State_PreInit,G4State_Idle);
fAl1Cmd = new G4UIcmdWithADoubleAndUnit("/testem/det/EcalLength",this);
fAl1Cmd->SetGuidance("Set length of Ecal");
fAl1Cmd->SetParameterName("lEcal",false);
fAl1Cmd->SetUnitCategory("Length");
fAl1Cmd->SetRange("lEcal>0");
fAl1Cmd->AvailableForStates(G4State_PreInit,G4State_Idle);
l2Cmd = new G4UIcmdWithADoubleAndUnit("/testem/det/EcalWidth",this);
l2Cmd->SetGuidance("Set width of Ecal crystal");
l2Cmd->SetParameterName("wEcal",false);
l2Cmd->SetUnitCategory("Length");
l2Cmd->AvailableForStates(G4State_PreInit,G4State_Idle);
fAl2Cmd = new G4UIcmdWithADoubleAndUnit("/testem/det/EcalWidth",this);
fAl2Cmd->SetGuidance("Set width of Ecal crystal");
fAl2Cmd->SetParameterName("wEcal",false);
fAl2Cmd->SetUnitCategory("Length");
fAl2Cmd->AvailableForStates(G4State_PreInit,G4State_Idle);
l3Cmd = new G4UIcmdWithADoubleAndUnit("/testem/det/AbsLength",this);
l3Cmd->SetGuidance("Set length of the absorber");
l3Cmd->SetParameterName("lAbs",false);
l3Cmd->SetUnitCategory("Length");
l3Cmd->AvailableForStates(G4State_PreInit,G4State_Idle);
fAl3Cmd = new G4UIcmdWithADoubleAndUnit("/testem/det/AbsLength",this);
fAl3Cmd->SetGuidance("Set length of the absorber");
fAl3Cmd->SetParameterName("lAbs",false);
fAl3Cmd->SetUnitCategory("Length");
fAl3Cmd->AvailableForStates(G4State_PreInit,G4State_Idle);
l4Cmd = new G4UIcmdWithADoubleAndUnit("/testem/det/VertexLength",this);
l4Cmd->SetGuidance("Set length of the vertex region");
l4Cmd->SetParameterName("lVert",false);
l4Cmd->SetUnitCategory("Length");
l4Cmd->AvailableForStates(G4State_PreInit,G4State_Idle);
fAl4Cmd = new G4UIcmdWithADoubleAndUnit("/testem/det/VertexLength",this);
fAl4Cmd->SetGuidance("Set length of the vertex region");
fAl4Cmd->SetParameterName("lVert",false);
fAl4Cmd->SetUnitCategory("Length");
fAl4Cmd->AvailableForStates(G4State_PreInit,G4State_Idle);
l5Cmd = new G4UIcmdWithADoubleAndUnit("/testem/det/PadLength",this);
l5Cmd->SetGuidance("Set length of vertex detector");
l5Cmd->SetParameterName("lPad",false);
l5Cmd->SetUnitCategory("Length");
l5Cmd->AvailableForStates(G4State_PreInit,G4State_Idle);
fAl5Cmd = new G4UIcmdWithADoubleAndUnit("/testem/det/PadLength",this);
fAl5Cmd->SetGuidance("Set length of vertex detector");
fAl5Cmd->SetParameterName("lPad",false);
fAl5Cmd->SetUnitCategory("Length");
fAl5Cmd->AvailableForStates(G4State_PreInit,G4State_Idle);
l6Cmd = new G4UIcmdWithADoubleAndUnit("/testem/det/PadWidth",this);
l6Cmd->SetGuidance("Set width of a vertex pad");
l6Cmd->SetParameterName("wPad",false);
l6Cmd->SetUnitCategory("Length");
l6Cmd->AvailableForStates(G4State_PreInit,G4State_Idle);
fAl6Cmd = new G4UIcmdWithADoubleAndUnit("/testem/det/PadWidth",this);
fAl6Cmd->SetGuidance("Set width of a vertex pad");
fAl6Cmd->SetParameterName("wPad",false);
fAl6Cmd->SetUnitCategory("Length");
fAl6Cmd->AvailableForStates(G4State_PreInit,G4State_Idle);
UpdateCmd = new G4UIcmdWithoutParameter("/testem/det/update",this);
UpdateCmd->SetGuidance("Update geometry.");
UpdateCmd->SetGuidance("This command MUST be applied before \"beamOn\" ");
UpdateCmd->SetGuidance("if you changed geometrical value(s)");
UpdateCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
fAUpdateCmd = new G4UIcmdWithoutParameter("/testem/det/update",this);
fAUpdateCmd->SetGuidance("Update geometry.");
fAUpdateCmd->SetGuidance("This command MUST be applied before \"beamOn\" ");
fAUpdateCmd->SetGuidance("if you changed geometrical value(s)");
fAUpdateCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
fAaccCmd1 = new G4UIcmdWith3Vector("/testem/det/acceptance1",this);
fAaccCmd1->SetGuidance("set Edep and RMS");
fAaccCmd1->SetGuidance("acceptance values for central cell");
fAaccCmd1->SetParameterName("edep","rms","limit",true);
fAaccCmd1->SetRange("edep>0 && edep<1 && rms>0");
fAaccCmd1->AvailableForStates(G4State_PreInit,G4State_Idle);
accCmd1 = new G4UIcmdWith3Vector("/testem/det/acceptance1",this);
accCmd1->SetGuidance("set Edep and RMS");
accCmd1->SetGuidance("acceptance values for central cell");
accCmd1->SetParameterName("edep","rms","limit",true);
accCmd1->SetRange("edep>0 && edep<1 && rms>0");
accCmd1->AvailableForStates(G4State_PreInit,G4State_Idle);
fAaccCmd2 = new G4UIcmdWith3Vector("/testem/det/acceptance9",this);
fAaccCmd2->SetGuidance("set Edep and RMS");
fAaccCmd2->SetGuidance("acceptance values for 3x3 matrix");
fAaccCmd2->SetParameterName("edep","rms","limit",true);
fAaccCmd2->SetRange("edep>0 && edep<1 && rms>0");
fAaccCmd2->AvailableForStates(G4State_PreInit,G4State_Idle);
accCmd2 = new G4UIcmdWith3Vector("/testem/det/acceptance9",this);
accCmd2->SetGuidance("set Edep and RMS");
accCmd2->SetGuidance("acceptance values for 3x3 matrix");
accCmd2->SetParameterName("edep","rms","limit",true);
accCmd2->SetRange("edep>0 && edep<1 && rms>0");
accCmd2->AvailableForStates(G4State_PreInit,G4State_Idle);
accCmd3 = new G4UIcmdWith3Vector("/testem/det/acceptance25",this);
accCmd3->SetGuidance("set Edep and RMS");
accCmd3->SetGuidance("acceptance values for 5x5 matrix");
accCmd3->SetParameterName("edep","rms","limit",true);
accCmd3->SetRange("edep>0 && edep<1 && rms>0");
accCmd3->AvailableForStates(G4State_PreInit,G4State_Idle);
fAaccCmd3 = new G4UIcmdWith3Vector("/testem/det/acceptance25",this);
fAaccCmd3->SetGuidance("set Edep and RMS");
fAaccCmd3->SetGuidance("acceptance values for 5x5 matrix");
fAaccCmd3->SetParameterName("edep","rms","limit",true);
fAaccCmd3->SetRange("edep>0 && edep<1 && rms>0");
fAaccCmd3->AvailableForStates(G4State_PreInit,G4State_Idle);
}
@@ -141,61 +142,61 @@ DetectorMessenger::DetectorMessenger(DetectorConstruction * Det)
DetectorMessenger::~DetectorMessenger()
{
delete MaterCmd;
delete LBinCmd;
delete l1Cmd;
delete l2Cmd;
delete l3Cmd;
delete l4Cmd;
delete l5Cmd;
delete l6Cmd;
delete UpdateCmd;
delete testemDir;
delete accCmd1;
delete accCmd2;
delete accCmd3;
delete fAMaterCmd;
delete fALBinCmd;
delete fAl1Cmd;
delete fAl2Cmd;
delete fAl3Cmd;
delete fAl4Cmd;
delete fAl5Cmd;
delete fAl6Cmd;
delete fAUpdateCmd;
delete fAtestemDir;
delete fAaccCmd1;
delete fAaccCmd2;
delete fAaccCmd3;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void DetectorMessenger::SetNewValue(G4UIcommand* command,G4String newValue)
{
if( command == MaterCmd )
{ Detector->SetEcalMaterial(newValue);}
if( command == fAMaterCmd )
{ fDetector->SetEcalMaterial(newValue);}
if( command == LBinCmd )
{ Detector->SetAbsMaterial(newValue);}
if( command == fALBinCmd )
{ fDetector->SetAbsMaterial(newValue);}
if( command == l1Cmd )
{ Detector->SetEcalLength(l1Cmd->GetNewDoubleValue(newValue));}
if( command == fAl1Cmd )
{ fDetector->SetEcalLength(fAl1Cmd->GetNewDoubleValue(newValue));}
if( command == l2Cmd )
{ Detector->SetEcalWidth(l2Cmd->GetNewDoubleValue(newValue));}
if( command == fAl2Cmd )
{ fDetector->SetEcalWidth(fAl2Cmd->GetNewDoubleValue(newValue));}
if( command == l3Cmd )
{ Detector->SetAbsLength(l3Cmd->GetNewDoubleValue(newValue));}
if( command == fAl3Cmd )
{ fDetector->SetAbsLength(fAl3Cmd->GetNewDoubleValue(newValue));}
if( command == l4Cmd )
{ Detector->SetVertexLength(l4Cmd->GetNewDoubleValue(newValue));}
if( command == fAl4Cmd )
{ fDetector->SetVertexLength(fAl4Cmd->GetNewDoubleValue(newValue));}
if( command == l5Cmd )
{ Detector->SetPadLength(l5Cmd->GetNewDoubleValue(newValue));}
if( command == fAl5Cmd )
{ fDetector->SetPadLength(fAl5Cmd->GetNewDoubleValue(newValue));}
if( command == l6Cmd )
{ Detector->SetPadWidth(l6Cmd->GetNewDoubleValue(newValue));}
if( command == fAl6Cmd )
{ fDetector->SetPadWidth(fAl6Cmd->GetNewDoubleValue(newValue));}
if( command == UpdateCmd )
{ Detector->UpdateGeometry();}
if( command == fAUpdateCmd )
{ fDetector->UpdateGeometry();}
HistoManager* histo = HistoManager::GetPointer();
if( command == accCmd1 )
{ histo->SetEdepAndRMS(0,accCmd1->GetNew3VectorValue(newValue));}
if( command == fAaccCmd1 )
{ histo->SetEdepAndRMS(0,fAaccCmd1->GetNew3VectorValue(newValue));}
if( command == accCmd2 )
{ histo->SetEdepAndRMS(1,accCmd2->GetNew3VectorValue(newValue));}
if( command == fAaccCmd2 )
{ histo->SetEdepAndRMS(1,fAaccCmd2->GetNew3VectorValue(newValue));}
if( command == accCmd3 )
{ histo->SetEdepAndRMS(2,accCmd3->GetNew3VectorValue(newValue));}
if( command == fAaccCmd3 )
{ histo->SetEdepAndRMS(2,fAaccCmd3->GetNew3VectorValue(newValue));}
}
@@ -23,9 +23,11 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
/// \file electromagnetic/TestEm9/src/EmAcceptance.cc
/// \brief Implementation of the Emeptance class
//
// $Id: EmAcceptance.cc,v 1.4 2006-06-29 17:03:03 gunter Exp $
// GEANT4 tag $Name: not supported by cvs2svn $
//
// $Id$
//
//
@@ -36,7 +38,7 @@
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
EmAcceptance::EmAcceptance()
EmAcceptance::EmAcceptance():fIsAccepted(true)
{}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -51,7 +53,7 @@ void EmAcceptance::BeginOfAcceptance(const G4String& title, G4int stat)
{
G4cout << G4endl;
G4cout << "<<<<<ACCEPTANCE>>>>> " << stat << " events for " << title << G4endl;
isAccepted = true;
fIsAccepted = true;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -59,7 +61,7 @@ void EmAcceptance::BeginOfAcceptance(const G4String& title, G4int stat)
void EmAcceptance::EndOfAcceptance()
{
G4String resume = "IS ACCEPTED";
if(!isAccepted) resume = "IS NOT ACCEPTED";
if(!fIsAccepted) resume = "IS NOT ACCEPTED";
G4cout << "<<<<<END>>>>> " << resume << G4endl;
G4cout << G4endl;
}
@@ -75,7 +77,7 @@ void EmAcceptance::EmAcceptanceGauss(const G4String& title, G4int stat,
G4double de = dde*x/rms;
G4cout << title << ": " << avr << " del"<< title << "= " << dde << " nrms= " << de << G4endl;
if(std::fabs(de) > limit) isAccepted = false;
if(std::fabs(de) > limit) fIsAccepted = false;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -23,8 +23,10 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: EventAction.cc,v 1.6 2010-06-07 05:40:46 perl Exp $
// GEANT4 tag $Name: not supported by cvs2svn $
/// \file electromagnetic/TestEm9/src/EventAction.cc
/// \brief Implementation of the EventAction class
//
// $Id$
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
@@ -40,12 +42,10 @@
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
EventAction::EventAction():
nEvt(0),
printModulo(100),
verbose(0),
drawFlag("all")
fPrintModulo(100),
fVerbose(0)
{
eventMessenger = new EventActionMessenger(this);
fEventMessenger = new EventActionMessenger(this);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
@@ -55,46 +55,44 @@ EventAction::~EventAction()
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
void EventAction::BeginOfEventAction(const G4Event*)
void EventAction::BeginOfEventAction(const G4Event* event)
{
// New event
nEvt++;
G4int n = event->GetEventID();
HistoManager* hi = HistoManager::GetPointer();
hi->BeginOfEvent();
// Switch on verbose mode
if(hi->FirstEventToDebug() == nEvt) {
verbose = 2;
if(hi->FirstEventToDebug() == n) {
fVerbose = 2;
hi->SetVerbose(2);
(G4UImanager::GetUIpointer())->ApplyCommand("/tracking/verbose 2");
}
// Switch off verbose mode
if(hi->LastEventToDebug() == nEvt-1) {
verbose = 0;
if(hi->LastEventToDebug() == n+1) {
fVerbose = 0;
hi->SetVerbose(0);
(G4UImanager::GetUIpointer())->ApplyCommand("/tracking/verbose 0");
}
// Initialize user actions
if(verbose > 0) {
G4cout << "EventAction: Event # "
<< nEvt << " started" << G4endl;
if(fVerbose > 0 || (n/fPrintModulo)*fPrintModulo == n) {
G4cout << "EventAction: Event # " << n << " started" << G4endl;
}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
void EventAction::EndOfEventAction(const G4Event*)
void EventAction::EndOfEventAction(const G4Event* event)
{
(HistoManager::GetPointer())->EndOfEvent();
if(verbose > 0) {
G4cout << "EventAction: Event # "
<< nEvt << " ended" << G4endl;
if(fVerbose > 0) {
G4cout << "EventAction: Event # " << event->GetEventID()
<< " ended" << G4endl;
}
}
@@ -23,57 +23,45 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: EventActionMessenger.cc,v 1.3 2006-06-29 17:03:08 gunter Exp $
// GEANT4 tag $Name: not supported by cvs2svn $
/// \file electromagnetic/TestEm9/src/EventActionMessenger.cc
/// \brief Implementation of the EventActionMessenger class
//
// $Id$
//
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
#include "EventActionMessenger.hh"
#include "EventAction.hh"
#include "G4UIcmdWithAString.hh"
#include "G4UIcmdWithAnInteger.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
EventActionMessenger::EventActionMessenger(EventAction* EvAct)
:eventAction(EvAct)
{
DrawCmd = new G4UIcmdWithAString("/testem/event/drawTracks",this);
DrawCmd->SetGuidance("Draw the tracks in the event");
DrawCmd->SetGuidance(" Choice : none,charged, all");
DrawCmd->SetParameterName("choice",true);
DrawCmd->SetDefaultValue("all");
DrawCmd->SetCandidates("none charged all");
DrawCmd->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_PreInit,G4State_Idle);
EventActionMessenger::EventActionMessenger(EventAction* evAct)
:fEventAction(evAct)
{
fPrintCmd = new G4UIcmdWithAnInteger("/testem/event/printModulo",this);
fPrintCmd->SetGuidance("Print events modulo n");
fPrintCmd->SetParameterName("EventNb",false);
fPrintCmd->SetRange("EventNb>0");
fPrintCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
EventActionMessenger::~EventActionMessenger()
{
delete DrawCmd;
delete PrintCmd;
delete fPrintCmd;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void EventActionMessenger::SetNewValue(G4UIcommand* command,
G4String newValue)
{
if(command == DrawCmd)
{eventAction->SetDrawFlag(newValue);}
if(command == PrintCmd)
{eventAction->SetPrintModulo(PrintCmd->GetNewIntValue(newValue));}
G4String newValue)
{
if(command == fPrintCmd)
{fEventAction->SetPrintModulo(fPrintCmd->GetNewIntValue(newValue));}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -23,6 +23,11 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
/// \file electromagnetic/TestEm9/src/Histo.cc
/// \brief Implementation of the Histo class
//
// $Id$
//
//---------------------------------------------------------------------------
//
// ClassName: Histo - Generic histogram/ntuple manager class
@@ -37,231 +42,311 @@
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
#include "Histo.hh"
#ifdef G4ANALYSIS_USE
#include "AIDA/AIDA.h"
#include "HistoMessenger.hh"
#endif
#include "G4RootAnalysisManager.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
Histo::Histo()
{
verbose = 0;
histName = "testem9";
histType = "root";
nHisto = 0;
defaultAct = 1;
tupleName = "tuple9";
tupleId = "100";
tupleList = "";
ntup = 0;
messenger = 0;
#ifdef G4ANALYSIS_USE
tree = 0;
af = 0;
messenger = new HistoMessenger(this);
#endif
fManager = 0;
fMessenger = new HistoMessenger(this);
fHistName = "test";
fHistType = "root";
fTupleName = "tuple";
fTupleTitle = "test";
fNHisto = 0;
fVerbose = 0;
fDefaultAct = true;
fHistoActive= false;
fNtupleActive= false;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
Histo::~Histo()
{
#ifdef G4ANALYSIS_USE
delete messenger;
delete af;
#endif
delete fMessenger;
delete fManager;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
void Histo::book()
void Histo::Book()
{
#ifdef G4ANALYSIS_USE
G4cout << "### Histo books " << nHisto << " histograms " << G4endl;
// Creating the analysis factory
if(!af) af = AIDA_createAnalysisFactory();
// Creating the tree factory
AIDA::ITreeFactory* tf = af->createTreeFactory();
if(!(fHistoActive || fNtupleActive)) { return; }
// Always creating analysis manager
fManager = G4RootAnalysisManager::Instance();
// Creating a tree mapped to a new hbook file.
G4String nam = fHistName + "." + fHistType;
G4String nam = histName + "." + histType;
G4String options = "";
//G4String options = "--noErrors export=root uncompress";
tree = tf->create(nam,histType,false,true,options);
delete tf;
if(tree) {
G4cout << "Tree store : " << tree->storeName() << G4endl;
} else {
G4cout << "ERROR: Tree store " << histName << " is not created!" << G4endl;
return;
// Open file histogram file
if(!fManager->OpenFile(nam)) {
G4cout << "Histo::Book: ERROR open file <" << nam << ">" << G4endl;
fHistoActive = false;
fNtupleActive = false;
return;
}
// Creating a histogram factory, whose histograms will be handled by the tree
AIDA::IHistogramFactory* hf = af->createHistogramFactory( *tree );
G4cout << "### Histo::Save: Opended file <" << nam << "> for "
<< fNHisto << " histograms " << G4endl;
// Creating an 1-dimensional histograms in the root directory of the tree
for(G4int i=0; i<nHisto; i++) {
if(active[i]) {
G4String ss = ids[i];
if(histType == "root") ss = "h" + ids[i];
histo[i] = hf->createHistogram1D(ss, titles[i], bins[i], xmin[i], xmax[i]);
for(G4int i=0; i<fNHisto; ++i) {
if(fActive[i]) {
G4String ss = "h" + fIds[i];
fHisto[i] = fManager->CreateH1(ss, fTitles[i], fBins[i], fXmin[i], fXmax[i]);
if(fVerbose > 0) {
G4cout << "Created histogram #" << i << " id= " << fHisto[i]
<< " " << ss << " " << fTitles[i] << G4endl;
}
}
}
delete hf;
// Creating a tuple factory, whose tuples will be handled by the tree
if(tupleList != "") {
AIDA::ITupleFactory* tpf = af->createTupleFactory( *tree );
ntup = tpf->create(tupleId, tupleName, tupleList);
delete tpf;
if(fNtupleActive) {
fManager->CreateNtuple(fTupleName,fTupleTitle);
G4int i;
G4int n = fNtupleI.size();
for(i=0; i<n; ++i) {
if(fTupleI[i] == -1) { fTupleI[i] = fManager->CreateNtupleIColumn(fNtupleI[i]); }
}
n = fNtupleF.size();
for(i=0; i<n; ++i) {
if(fTupleF[i] == -1) { fTupleF[i] = fManager->CreateNtupleFColumn(fNtupleF[i]); }
}
n = fNtupleD.size();
for(i=0; i<n; ++i) {
if(fTupleD[i] == -1) { fTupleD[i] = fManager->CreateNtupleDColumn(fNtupleD[i]); }
}
}
#endif
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
void Histo::save()
void Histo::Save()
{
#ifdef G4ANALYSIS_USE
if(!(fHistoActive || fNtupleActive)) { return; }
// Creating a tree mapped to a new hbook file.
G4String nam = fHistName + "." + fHistType;
// Write histogram file
if(tree) {
tree->commit();
G4cout << "Closing the tree..." << G4endl;
tree->close();
G4cout << "Histograms and Ntuples are saved" << G4endl;
delete tree;
tree = 0;
if(!fManager->Write()) {
G4cout << "Histo::Save: FATAL ERROR writing ROOT file" << G4endl;
exit(1);
}
#endif
if(fVerbose > 0) {
G4cout << "### Histo::Save: Histograms and Ntuples are saved" << G4endl;
}
if(fManager->CloseFile() && fVerbose > 0) {
G4cout << " File is closed" << G4endl;
}
delete G4RootAnalysisManager::Instance();
fManager = 0;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
void Histo::add1D(const G4String& id, const G4String& name, G4int nb,
void Histo::Add1D(const G4String& id, const G4String& name, G4int nb,
G4double x1, G4double x2, G4double u)
{
if(verbose > 0) {
G4cout << "New histogram will be booked: #" << id << " <" << name
if(fVerbose > 0) {
G4cout << "Histo::Add1D: New histogram will be booked: #" << id << " <" << name
<< " " << nb << " " << x1 << " " << x2 << " " << u
<< G4endl;
}
nHisto++;
++fNHisto;
x1 /= u;
x2 /= u;
active.push_back(defaultAct);
bins.push_back(nb);
xmin.push_back(x1);
xmax.push_back(x2);
unit.push_back(u);
ids.push_back(id);
titles.push_back(name);
histo.push_back(0);
fActive.push_back(fDefaultAct);
fBins.push_back(nb);
fXmin.push_back(x1);
fXmax.push_back(x2);
fUnit.push_back(u);
fIds.push_back(id);
fTitles.push_back(name);
fHisto.push_back(-1);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
void Histo::setHisto1D(G4int i, G4int nb, G4double x1, G4double x2, G4double u)
void Histo::SetHisto1D(G4int i, G4int nb, G4double x1, G4double x2, G4double u)
{
if(i>=0 && i<nHisto) {
if(verbose > 0) {
G4cout << "Update histogram: #" << i
if(i>=0 && i<fNHisto) {
if(fVerbose > 0) {
G4cout << "Histo::SetHisto1D: #" << i
<< " " << nb << " " << x1 << " " << x2 << " " << u
<< G4endl;
}
bins[i] = nb;
xmin[i] = x1;
xmax[i] = x2;
unit[i] = u;
fBins[i] = nb;
fXmin[i] = x1;
fXmax[i] = x2;
fUnit[i] = u;
fActive[i] = true;
fHistoActive = true;
} else {
G4cout << "Histo::setHisto1D: WARNING! wrong histogram index " << i << G4endl;
G4cout << "Histo::SetHisto1D: WARNING! wrong histogram index " << i << G4endl;
}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
void Histo::fill(G4int i, G4double x, G4double w)
void Histo::Activate(G4int i, G4bool val)
{
if(verbose > 1) {
G4cout << "fill histogram: #" << i << " at x= " << x
if(fVerbose > 1) {
G4cout << "Histo::Activate: Histogram: #" << i << " "
<< val << G4endl;
}
if(i>=0 && i<fNHisto) {
fActive[i] = val;
if(val) { fHistoActive = true; }
}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
void Histo::Fill(G4int i, G4double x, G4double w)
{
if(!fHistoActive) { return; }
if(fVerbose > 1) {
G4cout << "Histo::Fill: Histogram: #" << i << " at x= " << x
<< " weight= " << w
<< G4endl;
}
#ifdef G4ANALYSIS_USE
if(!tree) return;
if(i>=0 && i<nHisto) {
if(active[i]) histo[i]->fill((x/unit[i]), w);
if(i>=0 && i<fNHisto) {
if(fActive[i]) { fManager->FillH1(fHisto[i], x/fUnit[i], w); }
} else {
G4cout << "Histo::fill: WARNING! wrong histogram index " << i << G4endl;
G4cout << "Histo::Fill: WARNING! wrong histogram index " << i << G4endl;
}
#endif
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
void Histo::scale(G4int i, G4double x)
void Histo::ScaleH1(G4int i, G4double x)
{
if(verbose > 0) {
G4cout << "Scale histogram: #" << i << " by factor " << x << G4endl;
if(!fHistoActive) { return; }
if(fVerbose > 0) {
G4cout << "Histo::Scale: Histogram: #" << i << " by factor " << x << G4endl;
}
#ifdef G4ANALYSIS_USE
if(!tree) return;
if(i>=0 && i<nHisto) {
histo[i]->scale(x);
if(i>=0 && i<fNHisto) {
if(fActive[i]) { fManager->GetH1(fHisto[i])->scale(x); }
} else {
G4cout << "Histo::scale: WARNING! wrong histogram index " << i << G4endl;
G4cout << "Histo::Scale: WARNING! wrong histogram index " << i << G4endl;
}
#endif
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
void Histo::addTuple(const G4String& w1, const G4String& w2, const G4String& w3)
void Histo::AddTuple(const G4String& w1)
{
tupleId = w1;
tupleName = w2;
tupleList = w3;
fTupleTitle = w1;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
void Histo::fillTuple(const G4String& parname, G4double x)
void Histo::AddTupleI(const G4String& w1)
{
if(verbose > 1) {
G4cout << "fill tuple by parameter <" << parname << "> = " << x << G4endl;
fNtupleActive = true;
fNtupleI.push_back(w1);
fTupleI.push_back(-1);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
void Histo::AddTupleF(const G4String& w1)
{
fNtupleActive = true;
fNtupleF.push_back(w1);
fTupleF.push_back(-1);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
void Histo::AddTupleD(const G4String& w1)
{
fNtupleActive = true;
fNtupleD.push_back(w1);
fTupleD.push_back(-1);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
void Histo::FillTupleI(G4int i, G4int x)
{
if(!fNtupleActive) { return; }
G4int n = fNtupleI.size();
if(i >= 0 && i < n) {
if(fVerbose > 1) {
G4cout << "Histo::FillTupleI: i= " << i << " id= " << fTupleI[i]
<< " <" << fNtupleI[i] << "> = " << x << G4endl;
}
fManager->FillNtupleIColumn(fTupleI[i], x);
} else {
G4cout << "Histo::FillTupleI: WARNING! wrong ntuple index " << i << G4endl;
}
#ifdef G4ANALYSIS_USE
if(ntup) ntup->fill(ntup->findColumn(parname), (float)x);
#endif
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
void Histo::addRow()
void Histo::FillTupleF(G4int i, G4float x)
{
#ifdef G4ANALYSIS_USE
if(ntup) ntup->addRow();
#endif
if(!fNtupleActive) { return; }
G4int n = fNtupleF.size();
if(i >= 0 && i < n) {
if(fVerbose > 1) {
G4cout << "Histo::FillTupleF: i= " << i << " id= " << fTupleF[i]
<< " <" << fNtupleF[i] << "> = " << x << G4endl;
}
fManager->FillNtupleFColumn(fTupleF[i], x);
} else {
G4cout << "Histo::FillTupleF: WARNING! wrong ntuple index " << i << G4endl;
}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
void Histo::FillTupleD(G4int i, G4double x)
{
if(!fNtupleActive) { return; }
G4int n = fNtupleD.size();
if(i >= 0 && i < n) {
if(fVerbose > 1) {
G4cout << "Histo::FillTupleD: i= " << i << " id= " << fTupleD[i]
<< " <" << fNtupleD[i] << "> = " << x << G4endl;
}
fManager->FillNtupleDColumn(fTupleD[i], x);
} else {
G4cout << "Histo::FillTupleD: WARNING! wrong ntuple index " << i << G4endl;
}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
void Histo::AddRow()
{
if(!fNtupleActive) { return; }
fManager->AddNtupleRow();
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
void Histo::setFileName(const G4String& nam)
void Histo::SetFileName(const G4String& nam)
{
histName = nam;
fHistName = nam;
fHistoActive = true;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
void Histo::setFileType(const G4String& nam)
void Histo::SetFileType(const G4String& nam)
{
if(nam == "root" || nam == "hbook" || nam == "aida") histType = nam;
else if(nam == "xml" || nam == "XML") histType = "aida";
if(nam == "root" || nam == "ROOT" ) { fHistType = "root"; }
else if(nam == "xml" || nam == "XML") { fHistType = "xml"; }
else if(nam == "ascii" || nam == "ASCII" ||
nam == "Csv" || nam == "csv" || nam == "CSV") { fHistType = "ascii"; }
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
@@ -23,6 +23,9 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
/// \file electromagnetic/TestEm9/src/HistoManager.cc
/// \brief Implementation of the HistoManager class
//
//---------------------------------------------------------------------------
//
// ClassName: HistoManager
@@ -45,6 +48,10 @@
#include "G4UnitsTable.hh"
#include "Histo.hh"
#include "EmAcceptance.hh"
#include "G4Gamma.hh"
#include "G4Electron.hh"
#include "G4Positron.hh"
#include "G4SystemOfUnits.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
@@ -64,84 +71,51 @@ HistoManager* HistoManager::GetPointer()
HistoManager::HistoManager()
{
verbose = 1;
nEvt1 = -1;
nEvt2 = -1;
nmax = 3;
histo = new Histo();
fVerbose = 1;
fEvt1 = -1;
fEvt2 = -1;
fNmax = 3;
fMaxEnergy = 50.0*MeV;
fBeamEnergy= 1.*GeV;
fMaxEnergyAbs = 10.*MeV;
fBinsE = 100;
fBinsEA= 40;
fBinsED= 100;
fNHisto = 13;
fHisto = new Histo();
bookHisto();
fGamma = G4Gamma::Gamma();
fElectron = G4Electron::Electron();
fPositron = G4Positron::Positron();
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
HistoManager::~HistoManager()
{
delete histo;
delete fHisto;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
void HistoManager::bookHisto()
{
maxEnergy = 50.0*MeV;
beamEnergy= 1.*GeV;
maxEnergyAbs = 10.*MeV;
thKinE = 1.*MeV;
nBinsE = 100;
nBinsEA= 40;
nBinsED= 100;
nTuple = false;
nHisto = 13;
// initialise acceptance
for(G4int i=0; i<nmax; i++) {
edeptrue[i] = 1.0;
rmstrue[i] = 1.0;
limittrue[i]= DBL_MAX;
}
histo->add1D("10",
"Evis/E0 in central crystal",nBinsED,0.0,1,1.0);
histo->add1D("11",
"Evis/E0 in 3x3",nBinsED,0.0,1.0,1.0);
histo->add1D("12",
"Evis/E0 in 5x5",nBinsED,0.0,1.0,1.0);
histo->add1D("13",
"Energy (MeV) of delta-electrons",nBinsE,0.0,maxEnergy,MeV);
histo->add1D("14",
"Energy (MeV) of gammas",nBinsE,0.0,maxEnergy,MeV);
histo->add1D("15",
"Energy (MeV) in abs1",nBinsEA,0.0,maxEnergyAbs,MeV);
histo->add1D("16",
"Energy (MeV) in abs2",nBinsEA,0.0,maxEnergyAbs,MeV);
histo->add1D("17",
"Energy (MeV) in abs3",nBinsEA,0.0,maxEnergyAbs,MeV);
histo->add1D("18",
"Energy (MeV) in abs4",nBinsEA,0.0,maxEnergyAbs,MeV);
histo->add1D("19",
"Number of vertex hits",20,-0.5,19.5,1.0);
histo->add1D("20",
"E1/E9 Ratio",nBinsED,0.0,1,1.0);
histo->add1D("21",
"E1/25 Ratio",nBinsED,0.0,1.0,1.0);
histo->add1D("22",
"E9/E25 Ratio",nBinsED,0.0,1.0,1.0);
if(nTuple) {
histo->addTuple( "100", "Dose deposite","float r, z, e" );
}
fHisto->Add1D("10","Evis/E0 in central crystal",fBinsED,0.0,1,1.0);
fHisto->Add1D("11","Evis/E0 in 3x3",fBinsED,0.0,1.0,1.0);
fHisto->Add1D("12","Evis/E0 in 5x5",fBinsED,0.0,1.0,1.0);
fHisto->Add1D("13","Energy (MeV) of delta-electrons",
fBinsE,0.0,fMaxEnergy,MeV);
fHisto->Add1D("14","Energy (MeV) of gammas",fBinsE,0.0,fMaxEnergy,MeV);
fHisto->Add1D("15","Energy (MeV) in abs1",fBinsEA,0.0,fMaxEnergyAbs,MeV);
fHisto->Add1D("16","Energy (MeV) in abs2",fBinsEA,0.0,fMaxEnergyAbs,MeV);
fHisto->Add1D("17","Energy (MeV) in abs3",fBinsEA,0.0,fMaxEnergyAbs,MeV);
fHisto->Add1D("18","Energy (MeV) in abs4",fBinsEA,0.0,fMaxEnergyAbs,MeV);
fHisto->Add1D("19","Number of vertex hits",20,-0.5,19.5,1.0);
fHisto->Add1D("20","E1/E9 Ratio",fBinsED,0.0,1,1.0);
fHisto->Add1D("21","E1/E25 Ratio",fBinsED,0.0,1.0,1.0);
fHisto->Add1D("22","E9/E25 Ratio",fBinsED,0.0,1.0,1.0);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
@@ -149,33 +123,44 @@ void HistoManager::bookHisto()
void HistoManager::BeginOfRun()
{
// initilise scoring
n_evt = 0;
n_elec = 0;
n_posit= 0;
n_gam = 0;
n_step = 0;
n_lowe = 0;
fEvt = 0;
fElec = 0;
fPosit= 0;
fGam = 0;
fStep = 0;
fLowe = 0;
for(G4int i=0; i<6; i++) {
stat[i] = 0;
edep[i] = 0.0;
erms[i] = 0.0;
fStat[i] = 0;
fEdep[i] = 0.0;
fErms[i] = 0.0;
if(i < 3) {
edeptr[i] = 0.0;
ermstr[i] = 0.0;
fEdeptr[i] = 0.0;
fErmstr[i] = 0.0;
}
}
histo->book();
// initialise counters
fBrem.resize(93,0.0);
fPhot.resize(93,0.0);
fComp.resize(93,0.0);
fConv.resize(93,0.0);
brem.resize(93,0.0);
phot.resize(93,0.0);
comp.resize(93,0.0);
conv.resize(93,0.0);
// initialise acceptance - by default is not applied
for(G4int i=0; i<fNmax; i++) {
fEdeptrue[i] = 1.0;
fRmstrue[i] = 1.0;
fLimittrue[i]= 10.;
}
if(verbose > 0) {
G4cout << "HistoManager: Histograms are booked and run has been started"
<< G4endl;
if(fHisto->IsActive()) {
for(G4int i=0; i<fNHisto; ++i) {fHisto->Activate(i, true); }
fHisto->Book();
if(fVerbose > 0) {
G4cout << "HistoManager: Histograms are booked and run has been started"
<< G4endl;
}
}
}
@@ -185,109 +170,113 @@ void HistoManager::EndOfRun(G4int runID)
{
G4cout << "HistoManager: End of run actions are started RunID# "
<< runID << G4endl;
<< runID << G4endl;
G4String nam[6] = {"1x1", "3x3", "5x5", "E1/E9 ", "E1/E25", "E9/E25"};
// average
G4cout<<"================================================================="<<G4endl;
G4double x = (G4double)n_evt;
if(n_evt > 0) x = 1.0/x;
G4cout<<"================================================================="
<<G4endl;
G4double x = (G4double)fEvt;
if(fEvt > 0) x = 1.0/x;
G4int j;
for(j=0; j<nmax; j++) {
for(j=0; j<fNmax; j++) {
// total mean
edep[j] *= x;
G4double y = erms[j]*x - edep[j]*edep[j];
fEdep[j] *= x;
G4double y = fErms[j]*x - fEdep[j]*fEdep[j];
if(y < 0.0) y = 0.0;
erms[j] = std::sqrt(y);
fErms[j] = std::sqrt(y);
// trancated mean
G4double xx = G4double(stat[j]);
G4double xx = G4double(fStat[j]);
if(xx > 0.0) xx = 1.0/xx;
edeptr[j] *= xx;
y = ermstr[j]*xx - edeptr[j]*edeptr[j];
fEdeptr[j] *= xx;
y = fErmstr[j]*xx - fEdeptr[j]*fEdeptr[j];
if(y < 0.0) y = 0.0;
ermstr[j] = std::sqrt(y);
fErmstr[j] = std::sqrt(y);
}
G4double xe = x*(G4double)n_elec;
G4double xg = x*(G4double)n_gam;
G4double xp = x*(G4double)n_posit;
G4double xs = x*n_step;
G4double xe = x*(G4double)fElec;
G4double xg = x*(G4double)fGam;
G4double xp = x*(G4double)fPosit;
G4double xs = x*fStep;
G4double f = 100.*std::sqrt(beamEnergy/GeV);
G4double f = 100.*std::sqrt(fBeamEnergy/GeV);
G4cout << "Number of events " << n_evt <<G4endl;
G4cout << "Number of events " << fEvt <<G4endl;
G4cout << std::setprecision(4) << "Average number of e- " << xe << G4endl;
G4cout << std::setprecision(4) << "Average number of gamma " << xg << G4endl;
G4cout << std::setprecision(4) << "Average number of e+ " << xp << G4endl;
G4cout << std::setprecision(4) << "Average number of steps " << xs << G4endl;
for(j=0; j<3; j++) {
G4double e = edeptr[j];
G4double s = ermstr[j];
G4double xx= G4double(stat[j]);
G4double ex = fEdeptr[j];
G4double sx = fErmstr[j];
G4double xx= G4double(fStat[j]);
if(xx > 0.0) xx = 1.0/xx;
G4double r = s*std::sqrt(xx);
G4cout << std::setprecision(4) << "Edep " << nam[j] << " = " << e
G4double r = sx*std::sqrt(xx);
G4cout << std::setprecision(4) << "Edep " << nam[j]
<< " = " << ex
<< " +- " << r;
if(e > 0.0) G4cout << " res= " << f*s/e << " %";
if(ex > 0.1) G4cout << " res= " << f*sx/ex << " % " << fStat[j];
G4cout << G4endl;
}
if(limittrue[0] != DBL_MAX || limittrue[1] != DBL_MAX || limittrue[2] != DBL_MAX) {
if(fLimittrue[0] < 10. || fLimittrue[1] < 10. || fLimittrue[2] < 10.) {
G4cout<<"=========== Mean values without trancating ====================="<<G4endl;
for(j=0; j<nmax; j++) {
G4double e = edep[j];
G4double s = erms[j];
G4double r = s*std::sqrt(x);
G4cout << std::setprecision(4) << "Edep " << nam[j] << " = " << e
<< " +- " << r;
if(e > 0.0) G4cout << " res= " << f*s/e << " %";
for(j=0; j<fNmax; j++) {
G4double ex = fEdep[j];
G4double sx = fErms[j];
G4double rx = sx*std::sqrt(x);
G4cout << std::setprecision(4) << "Edep " << nam[j]
<< " = " << ex
<< " +- " << rx;
if(ex > 0.0) G4cout << " res= " << f*sx/ex << " %";
G4cout << G4endl;
}
}
G4cout<<"=========== Ratios without trancating ==========================="<<G4endl;
for(j=3; j<6; j++) {
G4double e = edep[j];
G4double xx= G4double(stat[j]);
G4double e = fEdep[j];
G4double xx= G4double(fStat[j]);
if(xx > 0.0) xx = 1.0/xx;
e *= xx;
G4double y = erms[j]*xx - e*e;
G4double y = fErms[j]*xx - e*e;
G4double r = 0.0;
if(y > 0.0) r = std::sqrt(y*xx);
G4cout << " " << nam[j] << " = " << e
<< " +- " << r;
G4cout << G4endl;
}
G4cout << std::setprecision(4) << "Beam Energy " << beamEnergy/GeV
<< " GeV" << G4endl;
if(n_lowe > 0) G4cout << "Number of events E/E0<0.8 " << n_lowe << G4endl;
G4cout << std::setprecision(4) << "Beam Energy " << fBeamEnergy/GeV
<< " GeV" << G4endl;
if(fLowe > 0) G4cout << "Number of events E/E0<0.8 " << fLowe << G4endl;
G4cout<<"=================================================================="<<G4endl;
G4cout<<G4endl;
// normalise histograms
for(G4int i=0; i<nHisto; i++) {
histo->scale(i,x);
if(fHisto->IsActive()) {
for(G4int i=0; i<fNHisto; i++) {
fHisto->ScaleH1(i,x);
}
fHisto->Save();
}
histo->save();
if(0 < runID) { return; }
// Acceptance
// Acceptance only for the first run
EmAcceptance acc;
G4bool isStarted = false;
for (j=0; j<nmax; j++) {
for (j=0; j<fNmax; j++) {
G4double ltrue = limittrue[j];
G4double ltrue = fLimittrue[j];
if (ltrue < DBL_MAX) {
if (!isStarted) {
acc.BeginOfAcceptance("Crystal Calorimeter",n_evt);
acc.BeginOfAcceptance("Crystal Calorimeter",fEvt);
isStarted = true;
}
G4double etrue = edeptrue[j];
G4double rtrue = rmstrue[j];
acc.EmAcceptanceGauss("Edep"+nam[j],n_evt,edeptr[j],etrue,rtrue,ltrue);
acc.EmAcceptanceGauss("Erms"+nam[j],n_evt,ermstr[j],rtrue,rtrue,2.0*ltrue);
G4double etrue = fEdeptrue[j];
G4double rtrue = fRmstrue[j];
acc.EmAcceptanceGauss("Edep"+nam[j],fEvt,fEdeptr[j],etrue,rtrue,ltrue);
acc.EmAcceptanceGauss("Erms"+nam[j],fEvt,fErmstr[j],rtrue,rtrue,2.0*ltrue);
}
}
if(isStarted) acc.EndOfAcceptance();
@@ -295,13 +284,13 @@ void HistoManager::EndOfRun(G4int runID)
// atom frequency
G4cout << " Z bremsstrahlung photoeffect compton conversion" << G4endl;
for(j=1; j<93; ++j) {
G4int n1 = G4int(brem[j]*x);
G4int n2 = G4int(phot[j]*x);
G4int n3 = G4int(comp[j]*x);
G4int n4 = G4int(conv[j]*x);
G4int n1 = G4int(fBrem[j]*x);
G4int n2 = G4int(fPhot[j]*x);
G4int n3 = G4int(fComp[j]*x);
G4int n4 = G4int(fConv[j]*x);
if(n1 + n2 + n3 + n4 > 0) {
G4cout << std::setw(4) << j << std::setw(12) << n1 << std::setw(12) << n2
<< std::setw(12) << n3 << std::setw(12) << n4 << G4endl;
<< std::setw(12) << n3 << std::setw(12) << n4 << G4endl;
}
}
}
@@ -310,16 +299,16 @@ void HistoManager::EndOfRun(G4int runID)
void HistoManager::BeginOfEvent()
{
n_evt++;
++fEvt;
Eabs1 = 0.0;
Eabs2 = 0.0;
Eabs3 = 0.0;
Eabs4 = 0.0;
Evertex.clear();
Nvertex.clear();
fEabs1 = 0.0;
fEabs2 = 0.0;
fEabs3 = 0.0;
fEabs4 = 0.0;
fEvertex.clear();
fNvertex.clear();
for (G4int i=0; i<25; i++) {
E[i] = 0.0;
fE[i] = 0.0;
}
}
@@ -330,18 +319,18 @@ void HistoManager::EndOfEvent()
G4double e9 = 0.0;
G4double e25= 0.0;
for (G4int i=0; i<25; i++) {
E[i] /= beamEnergy;
e25 += E[i];
if( ( 6<=i && 8>=i) || (11<=i && 13>=i) || (16<=i && 18>=i)) e9 += E[i];
fE[i] /= fBeamEnergy;
e25 += fE[i];
if( ( 6<=i && 8>=i) || (11<=i && 13>=i) || (16<=i && 18>=i)) e9 += fE[i];
}
if(1 < verbose && e25 < 0.8) {
n_lowe++;
G4cout << "### in the event# " << n_evt << " E25= " << e25 << G4endl;
if(1 < fVerbose && e25 < 0.8) {
++fLowe;
G4cout << "### in the event# " << fEvt << " E25= " << e25 << G4endl;
}
// compute ratios
G4double e0 = E[12];
G4double e0 = fE[12];
G4double e19 = 0.0;
G4double e125 = 0.0;
G4double e925 = 0.0;
@@ -349,56 +338,54 @@ void HistoManager::EndOfEvent()
e19 = e0/e9;
e125 = e0/e25;
e925 = e9/e25;
edep[3] += e19;
erms[3] += e19*e19;
edep[4] += e125;
erms[4] += e125*e125;
edep[5] += e925;
erms[5] += e925*e925;
stat[3] += 1;
stat[4] += 1;
stat[5] += 1;
fEdep[3] += e19;
fErms[3] += e19*e19;
fEdep[4] += e125;
fErms[4] += e125*e125;
fEdep[5] += e925;
fErms[5] += e925*e925;
fStat[3] += 1;
fStat[4] += 1;
fStat[5] += 1;
}
// fill histo
histo->fill(0,e0,1.0);
histo->fill(1,e9,1.0);
histo->fill(2,e25,1.0);
histo->fill(5,Eabs1,1.0);
histo->fill(6,Eabs2,1.0);
histo->fill(7,Eabs3,1.0);
histo->fill(8,Eabs4,1.0);
histo->fill(9,G4double(Nvertex.size()),1.0);
histo->fill(10,e19,1.0);
histo->fill(11,e125,1.0);
histo->fill(12,e925,1.0);
// Fill histo
fHisto->Fill(0,e0,1.0);
fHisto->Fill(1,e9,1.0);
fHisto->Fill(2,e25,1.0);
fHisto->Fill(5,fEabs1,1.0);
fHisto->Fill(6,fEabs2,1.0);
fHisto->Fill(7,fEabs3,1.0);
fHisto->Fill(8,fEabs4,1.0);
fHisto->Fill(9,G4double(fNvertex.size()),1.0);
fHisto->Fill(10,e19,1.0);
fHisto->Fill(11,e125,1.0);
fHisto->Fill(12,e925,1.0);
// compute sums
edep[0] += e0;
erms[0] += e0*e0;
edep[1] += e9;
erms[1] += e9*e9;
edep[2] += e25;
erms[2] += e25*e25;
fEdep[0] += e0;
fErms[0] += e0*e0;
fEdep[1] += e9;
fErms[1] += e9*e9;
fEdep[2] += e25;
fErms[2] += e25*e25;
// trancated mean
if(limittrue[0] == DBL_MAX || std::abs(e0-edeptrue[0])<rmstrue[0]*limittrue[0]) {
stat[0] += 1;
edeptr[0] += e0;
ermstr[0] += e0*e0;
if(std::abs(e0-fEdeptrue[0])<fRmstrue[0]*fLimittrue[0]) {
fStat[0] += 1;
fEdeptr[0] += e0;
fErmstr[0] += e0*e0;
}
if(limittrue[1] == DBL_MAX || std::abs(e9-edeptrue[1])<rmstrue[1]*limittrue[1]) {
stat[1] += 1;
edeptr[1] += e9;
ermstr[1] += e9*e9;
if(std::abs(e9-fEdeptrue[1])<fRmstrue[1]*fLimittrue[1]) {
fStat[1] += 1;
fEdeptr[1] += e9;
fErmstr[1] += e9*e9;
}
if(limittrue[2] == DBL_MAX || std::abs(e25-edeptrue[2])<rmstrue[2]*limittrue[2]) {
stat[2] += 1;
edeptr[2] += e25;
ermstr[2] += e25*e25;
if(std::abs(e25-fEdeptrue[2])<fRmstrue[2]*fLimittrue[2]) {
fStat[2] += 1;
fEdeptr[2] += e25;
fErmstr[2] += e25*e25;
}
if(nTuple) histo->addRow();
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
@@ -409,7 +396,7 @@ void HistoManager::ScoreNewTrack(const G4Track* aTrack)
ResetTrackLength();
const G4ParticleDefinition* particle = aTrack->GetDefinition();
const G4DynamicParticle* dynParticle = aTrack->GetDynamicParticle();
G4String name = particle->GetParticleName();
G4int pid = aTrack->GetParentID();
G4double kinE = dynParticle->GetKineticEnergy();
G4ThreeVector pos = aTrack->GetVertexPosition();
@@ -417,18 +404,13 @@ void HistoManager::ScoreNewTrack(const G4Track* aTrack)
// primary
if(0 == pid) {
beamEnergy = kinE;
histo->fillTuple("TKIN", kinE/MeV);
G4double mass = 0.0;
if(particle) {
mass = particle->GetPDGMass();
histo->fillTuple("MASS", mass/MeV);
histo->fillTuple("CHAR",(particle->GetPDGCharge())/eplus);
}
G4ThreeVector dir = dynParticle->GetMomentumDirection();
if(1 < verbose) {
if(1 < fVerbose) {
G4cout << "TrackingAction: Primary kinE(MeV)= " << kinE/MeV
<< "; m(MeV)= " << mass/MeV
<< "; pos= " << pos << "; dir= " << dir << G4endl;
@@ -439,48 +421,52 @@ void HistoManager::ScoreNewTrack(const G4Track* aTrack)
const G4VProcess* proc = aTrack->GetCreatorProcess();
G4int type = proc->GetProcessSubType();
if(type == fBremsstrahlung) {
const G4Element* elm = static_cast<const G4VEnergyLossProcess*>(proc)->GetCurrentElement();
const G4Element* elm =
static_cast<const G4VEnergyLossProcess*>(proc)->GetCurrentElement();
if(elm) {
G4int Z = G4int(elm->GetZ());
if(Z > 0 && Z < 93) { brem[Z] += 1.0; }
G4int Z = G4lrint(elm->GetZ());
if(Z > 0 && Z < 93) { fBrem[Z] += 1.0; }
}
} else if(type == fPhotoElectricEffect) {
const G4Element* elm = static_cast<const G4VEmProcess*>(proc)->GetCurrentElement();
const G4Element* elm =
static_cast<const G4VEmProcess*>(proc)->GetCurrentElement();
if(elm) {
G4int Z = G4int(elm->GetZ());
if(Z > 0 && Z < 93) { phot[Z] += 1.0; }
G4int Z = G4lrint(elm->GetZ());
if(Z > 0 && Z < 93) { fPhot[Z] += 1.0; }
}
} else if(type == fGammaConversion) {
const G4Element* elm = static_cast<const G4VEmProcess*>(proc)->GetCurrentElement();
const G4Element* elm =
static_cast<const G4VEmProcess*>(proc)->GetCurrentElement();
if(elm) {
G4int Z = G4int(elm->GetZ());
if(Z > 0 && Z < 93) { conv[Z] += 1.0; }
G4int Z = G4lrint(elm->GetZ());
if(Z > 0 && Z < 93) { fConv[Z] += 1.0; }
}
} else if(type == fComptonScattering) {
const G4Element* elm = static_cast<const G4VEmProcess*>(proc)->GetCurrentElement();
const G4Element* elm =
static_cast<const G4VEmProcess*>(proc)->GetCurrentElement();
if(elm) {
G4int Z = G4int(elm->GetZ());
if(Z > 0 && Z < 93) { comp[Z] += 1.0; }
G4int Z = G4lrint(elm->GetZ());
if(Z > 0 && Z < 93) { fComp[Z] += 1.0; }
}
}
// delta-electron
if (0 < pid && "e-" == name) {
if(1 < verbose) {
G4cout << "TrackingAction: Secondary electron " << G4endl;
if (particle == fElectron) {
if(1 < fVerbose) {
G4cout << "TrackingAction: Secondary electron " << G4endl;
}
AddDeltaElectron(dynParticle);
} else if (0 < pid && "e+" == name) {
if(1 < verbose) {
G4cout << "TrackingAction: Secondary positron " << G4endl;
} else if (particle == fPositron) {
if(1 < fVerbose) {
G4cout << "TrackingAction: Secondary positron " << G4endl;
}
AddPositron(dynParticle);
} else if (0 < pid && "gamma" == name) {
if(1 < verbose) {
G4cout << "TrackingAction: Secondary gamma; parentID= " << pid
<< " E= " << kinE << G4endl;
} else if (particle == fGamma) {
if(1 < fVerbose) {
G4cout << "TrackingAction: Secondary gamma; parentID= " << pid
<< " E= " << kinE << G4endl;
}
AddPhoton(dynParticle);
}
@@ -491,37 +477,37 @@ void HistoManager::ScoreNewTrack(const G4Track* aTrack)
void HistoManager::AddEnergy(G4double edep, G4int volIndex, G4int copyNo)
{
if(1 < verbose) {
if(1 < fVerbose) {
G4cout << "HistoManager::AddEnergy: e(keV)= " << edep/keV
<< "; volIdx= " << volIndex
<< "; copyNo= " << copyNo
<< G4endl;
}
if(0 == volIndex) {
E[copyNo] += edep;
fE[copyNo] += edep;
} else if (1 == volIndex) {
Eabs1 += edep;
fEabs1 += edep;
} else if (2 == volIndex) {
Eabs2 += edep;
fEabs2 += edep;
} else if (3 == volIndex) {
Eabs3 += edep;
fEabs3 += edep;
} else if (4 == volIndex) {
Eabs4 += edep;
fEabs4 += edep;
} else if (5 == volIndex) {
G4int n = Nvertex.size();
G4int n = fNvertex.size();
G4bool newPad = true;
if (n > 0) {
for(G4int i=0; i<n; i++) {
if (copyNo == Nvertex[i]) {
if (copyNo == fNvertex[i]) {
newPad = false;
Evertex[i] += edep;
fEvertex[i] += edep;
break;
}
}
}
if(newPad) {
Nvertex.push_back(copyNo);
Evertex.push_back(edep);
fNvertex.push_back(copyNo);
fEvertex.push_back(edep);
}
}
}
@@ -531,8 +517,8 @@ void HistoManager::AddEnergy(G4double edep, G4int volIndex, G4int copyNo)
void HistoManager::AddDeltaElectron(const G4DynamicParticle* elec)
{
G4double e = elec->GetKineticEnergy()/MeV;
if(e > 0.0) n_elec++;
histo->fill(3,e,1.0);
if(e > 0.0) fElec++;
fHisto->Fill(3,e,1.0);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
@@ -540,18 +526,18 @@ void HistoManager::AddDeltaElectron(const G4DynamicParticle* elec)
void HistoManager::AddPhoton(const G4DynamicParticle* ph)
{
G4double e = ph->GetKineticEnergy()/MeV;
if(e > 0.0) n_gam++;
histo->fill(4,e,1.0);
if(e > 0.0) fGam++;
fHisto->Fill(4,e,1.0);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
void HistoManager::SetEdepAndRMS(G4int i, G4ThreeVector val)
{
if(i<nmax && i>=0) {
if(val[0] > 0.0) edeptrue[i] = val[0];
if(val[1] > 0.0) rmstrue[i] = val[1];
if(val[2] > 0.0) limittrue[i] = val[2];
if(i<fNmax && i>=0) {
if(val[0] > 0.0) fEdeptrue[i] = val[0];
if(val[1] > 0.0) fRmstrue[i] = val[1];
if(val[2] > 0.0) fLimittrue[i] = val[2];
}
}
@@ -23,9 +23,11 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
/// \file electromagnetic/TestEm9/src/HistoMessenger.cc
/// \brief Implementation of the HistoMessenger class
//
// $Id: HistoMessenger.cc,v 1.7 2008-08-22 14:11:53 vnivanch Exp $
// GEANT4 tag $Name: not supported by cvs2svn $
//
// $Id$
//
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -42,43 +44,43 @@
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
HistoMessenger::HistoMessenger(Histo* manager)
:histo (manager)
HistoMessenger::HistoMessenger(Histo* hist)
:fHisto(hist)
{
histoDir = new G4UIdirectory("/testem/histo/");
histoDir->SetGuidance("histograms control");
fHistoDir = new G4UIdirectory("/testem/histo/");
fHistoDir->SetGuidance("histograms control");
factoryCmd = new G4UIcmdWithAString("/testem/histo/fileName",this);
factoryCmd->SetGuidance("set name for the histograms file");
fFactoryCmd = new G4UIcmdWithAString("/testem/histo/fileName",this);
fFactoryCmd->SetGuidance("set name for the histograms file");
fileCmd = new G4UIcmdWithAString("/testem/histo/fileType",this);
fileCmd->SetGuidance("set type (hbook, XML) for the histograms file");
fFileCmd = new G4UIcmdWithAString("/testem/histo/fileType",this);
fFileCmd->SetGuidance("set type (hbook, XML) 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)");
fHistoCmd = new G4UIcommand("/testem/histo/setHisto",this);
fHistoCmd->SetGuidance("Set bining of the histo number ih :");
fHistoCmd->SetGuidance(" nbBins; valMin; valMax; unit (of vmin and vmax)");
//
G4UIparameter* ih = new G4UIparameter("ih",'i',false);
ih->SetGuidance("histo number : from 0 to MaxHisto-1");
histoCmd->SetParameter(ih);
fHistoCmd->SetParameter(ih);
//
G4UIparameter* nbBins = new G4UIparameter("nbBins",'i',false);
nbBins->SetGuidance("number of bins");
nbBins->SetParameterRange("nbBins>0");
histoCmd->SetParameter(nbBins);
fHistoCmd->SetParameter(nbBins);
//
G4UIparameter* valMin = new G4UIparameter("valMin",'d',false);
valMin->SetGuidance("valMin, expressed in unit");
histoCmd->SetParameter(valMin);
fHistoCmd->SetParameter(valMin);
//
G4UIparameter* valMax = new G4UIparameter("valMax",'d',false);
valMax->SetGuidance("valMax, expressed in unit");
histoCmd->SetParameter(valMax);
fHistoCmd->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);
fHistoCmd->SetParameter(unit);
}
@@ -86,33 +88,32 @@ HistoMessenger::HistoMessenger(Histo* manager)
HistoMessenger::~HistoMessenger()
{
delete fileCmd;
delete histoCmd;
delete factoryCmd;
delete histoDir;
delete fFileCmd;
delete fHistoCmd;
delete fFactoryCmd;
delete fHistoDir;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void HistoMessenger::SetNewValue(G4UIcommand* command,G4String newValues)
void HistoMessenger::SetNewValue(G4UIcommand* command, G4String newValues)
{
if (command == factoryCmd)
histo->setFileName(newValues);
if (command == fFactoryCmd) { fHisto->SetFileName(newValues); }
if (command == fileCmd)
histo->setFileType(newValues);
if (command == fFileCmd) { fHisto->SetFileType(newValues); }
if (command == histoCmd)
{ G4int ih,nbBins; G4double vmin,vmax;
std::istringstream is(newValues);
G4String unts;
is >> ih >> nbBins >> vmin >> vmax >> unts;
G4String unit = unts;
G4double vUnit = 1. ;
if(unit != "none") vUnit = G4UIcommand::ValueOf(unit);
if(vUnit <= 0.0) vUnit = 1.;
histo->setHisto1D(ih,nbBins,vmin,vmax,vUnit);
}
if (command == fHistoCmd) {
G4int ih,nbBins;
G4double vmin,vmax;
std::istringstream is(newValues);
G4String unts;
is >> ih >> nbBins >> vmin >> vmax >> unts;
G4String unit = unts;
G4double vUnit = 1. ;
if(unit != "none") { vUnit = G4UIcommand::ValueOf(unit); }
if(vUnit <= 0.0) { vUnit = 1.; }
fHisto->SetHisto1D(ih,nbBins,vmin,vmax,vUnit);
}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -23,8 +23,10 @@
// * 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 $
/// \file electromagnetic/TestEm9/src/PhysListEmStandard.cc
/// \brief Implementation of the PhysListEmStandard class
//
// $Id$
//
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -65,6 +67,8 @@
#include "G4LossTableManager.hh"
#include "G4UAtomicDeexcitation.hh"
#include "G4SystemOfUnits.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
PhysListEmStandard::PhysListEmStandard(const G4String& name)
@@ -105,7 +109,7 @@ void PhysListEmStandard::ConstructProcess()
eIoni->SetStepFunction(0.1, 100*um);
ph->RegisterProcess(eIoni, particle);
ph->RegisterProcess(new G4eBremsstrahlung(), particle);
} else if (particleName == "e+") {
ph->RegisterProcess(new G4eMultipleScattering(), particle);
@@ -137,7 +141,7 @@ void PhysListEmStandard::ConstructProcess()
ph->RegisterProcess(new G4hPairProduction(), particle);
} else if( particleName == "alpha" ||
particleName == "He3" ) {
particleName == "He3" ) {
ph->RegisterProcess(new G4hMultipleScattering(), particle);
G4ionIonisation* ionIoni = new G4ionIonisation();
@@ -155,9 +159,9 @@ void PhysListEmStandard::ConstructProcess()
ph->RegisterProcess(new G4NuclearStopping(), particle);
} else if ((!particle->IsShortLived()) &&
(particle->GetPDGCharge() != 0.0) &&
(particle->GetParticleName() != "chargedgeantino")) {
(particle->GetPDGCharge() != 0.0) &&
(particle->GetParticleName() != "chargedgeantino")) {
//all others charged particles except geantino
ph->RegisterProcess(new G4hMultipleScattering(), particle);
ph->RegisterProcess(new G4hIonisation(), particle);
@@ -173,10 +177,10 @@ void PhysListEmStandard::ConstructProcess()
//physics tables
//
emOptions.SetMinEnergy(10*eV); //default 100 eV
emOptions.SetMaxEnergy(10*TeV); //default 100 TeV
emOptions.SetDEDXBinning(12*10); //default=12*7
emOptions.SetLambdaBinning(12*10); //default=12*7
emOptions.SetMinEnergy(10*eV); //default 100 eV
emOptions.SetMaxEnergy(10*TeV); //default 100 TeV
emOptions.SetDEDXBinning(12*10); //default=12*7
emOptions.SetLambdaBinning(12*10); //default=12*7
//multiple coulomb scattering
//
@@ -23,8 +23,10 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: PhysicsList.cc,v 1.26 2010-08-12 11:38:20 vnivanch Exp $
// GEANT4 tag $Name: not supported by cvs2svn $
/// \file electromagnetic/TestEm9/src/PhysicsList.cc
/// \brief Implementation of the PhysicsList class
//
// $Id$
//
//---------------------------------------------------------------------------
//
@@ -34,6 +36,7 @@
//
// Modified:
// 17.11.06 Use components from physics_lists subdirectory (V.Ivanchenko)
// 24.10.12 Migrated to new stopping and ion physics (A.Ribon)
//
//----------------------------------------------------------------------------
//
@@ -49,14 +52,15 @@
#include "G4EmStandardPhysics_option1.hh"
#include "G4EmStandardPhysics_option2.hh"
#include "G4EmStandardPhysics_option3.hh"
#include "G4EmStandardPhysics_option4.hh"
#include "G4EmLivermorePhysics.hh"
#include "G4EmPenelopePhysics.hh"
#include "G4DecayPhysics.hh"
#include "G4HadronElasticPhysics.hh"
#include "G4HadronInelasticQBBC.hh"
#include "G4IonBinaryCascadePhysics.hh"
#include "G4IonPhysics.hh"
#include "G4EmExtraPhysics.hh"
#include "G4QStoppingPhysics.hh"
#include "G4StoppingPhysics.hh"
#include "G4RegionStore.hh"
#include "G4Region.hh"
@@ -68,8 +72,10 @@
#include "G4Gamma.hh"
#include "G4Electron.hh"
#include "G4Positron.hh"
#include "G4Proton.hh"
#include "G4UnitsTable.hh"
#include "G4SystemOfUnits.hh"
#include "G4LossTableManager.hh"
#include "StepMax.hh"
@@ -80,46 +86,46 @@
PhysicsList::PhysicsList() : G4VModularPhysicsList()
{
G4LossTableManager::Instance();
defaultCutValue = 1.*mm;
cutForGamma = defaultCutValue;
cutForElectron = defaultCutValue;
cutForPositron = defaultCutValue;
cutForVertexDetector = defaultCutValue;
cutForMuonDetector = defaultCutValue;
defaultCutValue = 1.*mm;
fCutForGamma = defaultCutValue;
fCutForElectron = defaultCutValue;
fCutForPositron = defaultCutValue;
fCutForVertexDetector = defaultCutValue;
fCutForMuonDetector = defaultCutValue;
vertexDetectorCuts = 0;
muonDetectorCuts = 0;
fVertexDetectorCuts = 0;
fMuonDetectorCuts = 0;
pMessenger = new PhysicsListMessenger(this);
stepMaxProcess = new StepMax();
fMessenger = new PhysicsListMessenger(this);
fStepMaxProcess = new StepMax();
// Initilise flags
SetVerboseLevel(1);
helIsRegisted = false;
bicIsRegisted = false;
gnucIsRegisted = false;
stopIsRegisted = false;
// Decay Physics is always defined
generalPhysicsList = new G4DecayPhysics();
fHelIsRegisted = false;
fBicIsRegisted = false;
fGnucIsRegisted = false;
fStopIsRegisted = false;
// EM physics
emName = G4String("emstandard");
emPhysicsList = new G4EmStandardPhysics();
fEmName = G4String("emstandard");
fEmPhysicsList = new G4EmStandardPhysics();
// Decay Physics is always defined
fDecayPhysicsList = new G4DecayPhysics();
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
PhysicsList::~PhysicsList()
{
delete pMessenger;
delete generalPhysicsList;
delete emPhysicsList;
delete stepMaxProcess;
for(size_t i=0; i<hadronPhys.size(); i++) {
delete hadronPhys[i];
delete fMessenger;
delete fDecayPhysicsList;
delete fEmPhysicsList;
delete fStepMaxProcess;
for(size_t i=0; i<fHadronPhys.size(); i++) {
delete fHadronPhys[i];
}
}
@@ -127,7 +133,7 @@ PhysicsList::~PhysicsList()
void PhysicsList::ConstructParticle()
{
generalPhysicsList->ConstructParticle();
fDecayPhysicsList->ConstructParticle();
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -135,10 +141,10 @@ void PhysicsList::ConstructParticle()
void PhysicsList::ConstructProcess()
{
AddTransportation();
emPhysicsList->ConstructProcess();
generalPhysicsList->ConstructProcess();
for(size_t i=0; i<hadronPhys.size(); i++) {
hadronPhys[i]->ConstructProcess();
fEmPhysicsList->ConstructProcess();
fDecayPhysicsList->ConstructProcess();
for(size_t i=0; i<fHadronPhys.size(); ++i) {
fHadronPhys[i]->ConstructProcess();
}
AddStepMax();
}
@@ -150,75 +156,82 @@ void PhysicsList::AddPhysicsList(const G4String& name)
if (verboseLevel > 1)
G4cout << "PhysicsList::AddPhysicsList: <" << name << ">" << G4endl;
if (name == emName) return;
if (name == fEmName) return;
if (name == "emstandard") {
emName = name;
delete emPhysicsList;
emPhysicsList = new G4EmStandardPhysics();
fEmName = name;
delete fEmPhysicsList;
fEmPhysicsList = new G4EmStandardPhysics();
if (verboseLevel > 0)
G4cout << "PhysicsList::Set " << name << " EM physics" << G4endl;
} else if (name == "emstandard_opt1") {
emName = name;
delete emPhysicsList;
emPhysicsList = new G4EmStandardPhysics_option1();
fEmName = name;
delete fEmPhysicsList;
fEmPhysicsList = new G4EmStandardPhysics_option1();
if (verboseLevel > 0)
G4cout << "PhysicsList::Set " << name << " EM physics" << G4endl;
} else if (name == "emstandard_opt2") {
emName = name;
delete emPhysicsList;
emPhysicsList = new G4EmStandardPhysics_option2();
fEmName = name;
delete fEmPhysicsList;
fEmPhysicsList = new G4EmStandardPhysics_option2();
if (verboseLevel > 0)
G4cout << "PhysicsList::Set " << name << " EM physics" << G4endl;
} else if (name == "emstandard_opt3") {
emName = name;
delete emPhysicsList;
emPhysicsList = new G4EmStandardPhysics_option3();
fEmName = name;
delete fEmPhysicsList;
fEmPhysicsList = new G4EmStandardPhysics_option3();
if (verboseLevel > 0)
G4cout << "PhysicsList::Set " << name << " EM physics" << G4endl;
} else if (name == "emstandard_opt4") {
fEmName = name;
delete fEmPhysicsList;
fEmPhysicsList = new G4EmStandardPhysics_option4();
if (verboseLevel > 0)
G4cout << "PhysicsList::Set " << name << " EM physics" << G4endl;
} else if (name == "emstandard_local") {
emName = name;
delete emPhysicsList;
emPhysicsList = new PhysListEmStandard();
fEmName = name;
delete fEmPhysicsList;
fEmPhysicsList = new PhysListEmStandard();
if (verboseLevel > 0)
G4cout << "PhysicsList::Set " << name << " EM physics" << G4endl;
} else if (name == "emlivermore") {
emName = name;
delete emPhysicsList;
emPhysicsList = new G4EmLivermorePhysics();
fEmName = name;
delete fEmPhysicsList;
fEmPhysicsList = new G4EmLivermorePhysics();
} else if (name == "empenelope") {
emName = name;
delete emPhysicsList;
emPhysicsList = new G4EmPenelopePhysics();
fEmName = name;
delete fEmPhysicsList;
fEmPhysicsList = new G4EmPenelopePhysics();
} else if (name == "elastic" && !helIsRegisted) {
hadronPhys.push_back( new G4HadronElasticPhysics());
helIsRegisted = true;
} else if (name == "elastic" && !fHelIsRegisted) {
fHadronPhys.push_back( new G4HadronElasticPhysics());
fHelIsRegisted = true;
if (verboseLevel > 0)
G4cout << "PhysicsList::Add hadron elastic physics" << G4endl;
} else if (name == "binary" && !bicIsRegisted) {
hadronPhys.push_back(new G4HadronInelasticQBBC());
hadronPhys.push_back(new G4IonBinaryCascadePhysics());
bicIsRegisted = true;
} else if (name == "binary" && !fBicIsRegisted) {
fHadronPhys.push_back(new G4HadronInelasticQBBC());
fHadronPhys.push_back(new G4IonPhysics());
fBicIsRegisted = true;
if (verboseLevel > 0)
G4cout << "PhysicsList::Add hadron inelastic physics from <QBBC>" << G4endl;
} else if (name == "gamma_nuc" && !gnucIsRegisted) {
hadronPhys.push_back(new G4EmExtraPhysics());
gnucIsRegisted = true;
} else if (name == "gamma_nuc" && !fGnucIsRegisted) {
fHadronPhys.push_back(new G4EmExtraPhysics());
fGnucIsRegisted = true;
if (verboseLevel > 0)
G4cout << "PhysicsList::Add gamma- and electro-nuclear physics" << G4endl;
} else if (name == "stopping" && !stopIsRegisted) {
hadronPhys.push_back(new G4QStoppingPhysics());
gnucIsRegisted = true;
} else if (name == "stopping" && !fStopIsRegisted) {
fHadronPhys.push_back(new G4StoppingPhysics());
fStopIsRegisted = true;
if (verboseLevel > 0)
G4cout << "PhysicsList::Add stopping physics" << G4endl;
@@ -237,13 +250,13 @@ void PhysicsList::AddStepMax()
theParticleIterator->reset();
while ((*theParticleIterator)()){
G4ParticleDefinition* particle = theParticleIterator->value();
G4ProcessManager* pmanager = particle->GetProcessManager();
G4ParticleDefinition* particle = theParticleIterator->value();
G4ProcessManager* pmanager = particle->GetProcessManager();
if (stepMaxProcess->IsApplicable(*particle) && !particle->IsShortLived())
{
pmanager ->AddDiscreteProcess(stepMaxProcess);
}
if (fStepMaxProcess->IsApplicable(*particle) && !particle->IsShortLived())
{
pmanager ->AddDiscreteProcess(fStepMaxProcess);
}
}
}
@@ -251,23 +264,24 @@ void PhysicsList::AddStepMax()
void PhysicsList::SetCuts()
{
SetCutValue(cutForGamma, "gamma", "DefaultRegionForTheWorld");
SetCutValue(cutForElectron, "e-", "DefaultRegionForTheWorld");
SetCutValue(cutForPositron, "e+", "DefaultRegionForTheWorld");
SetCutValue(fCutForGamma, "gamma", "DefaultRegionForTheWorld");
SetCutValue(fCutForElectron, "e-", "DefaultRegionForTheWorld");
SetCutValue(fCutForElectron, "e+", "DefaultRegionForTheWorld");
SetCutValue(fCutForProton, "proton", "DefaultRegionForTheWorld");
// G4cout << "PhysicsList: world cuts are set cutG= " << cutForGamma/mm
// << " mm cutE= " << cutForElectron/mm << " mm " << G4endl;
// << " mm cutE= " << fCutForElectron/mm << " mm " << G4endl;
//G4cout << " cutV= " << cutForVertexDetector
// << " cutM= " << cutForMuonDetector<<G4endl;
//G4cout << " cutV= " << fCutForVertexDetector
// << " cutM= " << fCutForMuonDetector<<G4endl;
G4Region* region = (G4RegionStore::GetInstance())->GetRegion("VertexDetector");
vertexDetectorCuts = region->GetProductionCuts();
SetVertexCut(cutForVertexDetector);
fVertexDetectorCuts = region->GetProductionCuts();
SetVertexCut(fCutForVertexDetector);
// G4cout << "Vertex cuts are set" << G4endl;
region = (G4RegionStore::GetInstance())->GetRegion("MuonDetector");
muonDetectorCuts = region->GetProductionCuts();
SetMuonCut(cutForMuonDetector);
fMuonDetectorCuts = region->GetProductionCuts();
SetMuonCut(fCutForMuonDetector);
//G4cout << "Muon cuts are set " <<muonRegion << " " << muonDetectorCuts << G4endl;
if (verboseLevel>0) DumpCutValuesTable();
@@ -277,36 +291,38 @@ 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());
SetParticleCuts(fCutForElectron, G4Positron::Positron());
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void PhysicsList::SetCutForPositron(G4double cut)
void PhysicsList::SetCutForProton(G4double cut)
{
cutForPositron = cut;
SetParticleCuts(cutForPositron, G4Positron::Positron());
fCutForProton = cut;
SetParticleCuts(fCutForProton, G4Proton::Proton());
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void PhysicsList::SetVertexCut(G4double cut)
{
cutForVertexDetector = cut;
fCutForVertexDetector = cut;
if( vertexDetectorCuts ) {
vertexDetectorCuts->SetProductionCut(cut, idxG4GammaCut);
vertexDetectorCuts->SetProductionCut(cut, idxG4ElectronCut);
vertexDetectorCuts->SetProductionCut(cut, idxG4PositronCut);
if( fVertexDetectorCuts ) {
fVertexDetectorCuts->SetProductionCut(cut, idxG4GammaCut);
fVertexDetectorCuts->SetProductionCut(cut, idxG4ElectronCut);
fVertexDetectorCuts->SetProductionCut(cut, idxG4PositronCut);
fVertexDetectorCuts->SetProductionCut(cut, idxG4ProtonCut);
}
}
@@ -314,12 +330,13 @@ void PhysicsList::SetVertexCut(G4double cut)
void PhysicsList::SetMuonCut(G4double cut)
{
cutForMuonDetector = cut;
fCutForMuonDetector = cut;
if( muonDetectorCuts ) {
muonDetectorCuts->SetProductionCut(cut, idxG4GammaCut);
muonDetectorCuts->SetProductionCut(cut, idxG4ElectronCut);
muonDetectorCuts->SetProductionCut(cut, idxG4PositronCut);
if( fMuonDetectorCuts ) {
fMuonDetectorCuts->SetProductionCut(cut, idxG4GammaCut);
fMuonDetectorCuts->SetProductionCut(cut, idxG4ElectronCut);
fMuonDetectorCuts->SetProductionCut(cut, idxG4PositronCut);
fMuonDetectorCuts->SetProductionCut(cut, idxG4ProtonCut);
}
}
@@ -23,9 +23,11 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
/// \file electromagnetic/TestEm9/src/PhysicsListMessenger.cc
/// \brief Implementation of the PhysicsListMessenger class
//
// $Id: PhysicsListMessenger.cc,v 1.4 2008-04-03 15:07:55 vnivanch Exp $
// GEANT4 tag $Name: not supported by cvs2svn $
//
// $Id$
//
//
@@ -42,73 +44,67 @@
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
PhysicsListMessenger::PhysicsListMessenger(PhysicsList* pPhys)
:pPhysicsList(pPhys)
:fPhysicsList(pPhys)
{
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 fGamma 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);
eCutCmd = new G4UIcmdWithADoubleAndUnit("/testem/phys/VertexCuts",this);
eCutCmd->SetGuidance("Set cuts for the Vertex Detector");
eCutCmd->SetParameterName("Ecut",false);
eCutCmd->SetUnitCategory("Length");
eCutCmd->SetRange("Ecut>0.0");
eCutCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
fECutCmd = new G4UIcmdWithADoubleAndUnit("/testem/phys/VertexCuts",this);
fECutCmd->SetGuidance("Set cuts for the Vertex Detector");
fECutCmd->SetParameterName("Ecut",false);
fECutCmd->SetUnitCategory("Length");
fECutCmd->SetRange("Ecut>0.0");
fECutCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
mCutCmd = new G4UIcmdWithADoubleAndUnit("/testem/phys/MuonCuts",this);
mCutCmd->SetGuidance("Set cuts for the Muon Detector");
mCutCmd->SetParameterName("Ecut",false);
mCutCmd->SetUnitCategory("Length");
mCutCmd->SetRange("Ecut>0.0");
mCutCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
fMCutCmd = new G4UIcmdWithADoubleAndUnit("/testem/phys/MuonCuts",this);
fMCutCmd->SetGuidance("Set cuts for the Muon Detector");
fMCutCmd->SetParameterName("Ecut",false);
fMCutCmd->SetUnitCategory("Length");
fMCutCmd->SetRange("Ecut>0.0");
fMCutCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
pListCmd = new G4UIcmdWithAString("/testem/phys/addPhysics",this);
pListCmd->SetGuidance("Add modula physics list.");
pListCmd->SetParameterName("PList",false);
pListCmd->AvailableForStates(G4State_PreInit);
mscCmd = new G4UIcmdWithABool("/testem/phys/mscStepLimit",this);
mscCmd->SetGuidance("Activate Multiple Scattering step limit");
mscCmd->SetParameterName("PList",false);
mscCmd->AvailableForStates(G4State_PreInit);
fListCmd = new G4UIcmdWithAString("/testem/phys/addPhysics",this);
fListCmd->SetGuidance("Add modula physics list.");
fListCmd->SetParameterName("PList",false);
fListCmd->AvailableForStates(G4State_PreInit);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
PhysicsListMessenger::~PhysicsListMessenger()
{
delete gammaCutCmd;
delete electCutCmd;
delete protoCutCmd;
delete allCutCmd;
delete pListCmd;
delete eCutCmd;
delete mCutCmd;
delete mscCmd;
delete fGammaCutCmd;
delete fElectCutCmd;
delete fProtoCutCmd;
delete fAllCutCmd;
delete fListCmd;
delete fECutCmd;
delete fMCutCmd;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -116,34 +112,31 @@ PhysicsListMessenger::~PhysicsListMessenger()
void PhysicsListMessenger::SetNewValue(G4UIcommand* command,
G4String 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->SetCutForProton(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->SetCutForProton(cut);
}
if( command == eCutCmd )
{ pPhysicsList->SetVertexCut(eCutCmd->GetNewDoubleValue(newValue));}
if( command == fECutCmd )
{ fPhysicsList->SetVertexCut(fECutCmd->GetNewDoubleValue(newValue));}
if( command == mCutCmd )
{ pPhysicsList->SetMuonCut(mCutCmd->GetNewDoubleValue(newValue));}
if( command == fMCutCmd )
{ fPhysicsList->SetMuonCut(fMCutCmd->GetNewDoubleValue(newValue));}
if( command == pListCmd )
{ pPhysicsList->AddPhysicsList(newValue);}
// if( command == mscCmd )
// { pPhysicsList->SetMscStepLimit(mscCmd->GetNewBoolValue(newValue));}
if( command == fListCmd )
{ fPhysicsList->AddPhysicsList(newValue);}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -23,9 +23,11 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
/// \file electromagnetic/TestEm9/src/PrimaryGeneratorAction.cc
/// \brief Implementation of the PrimaryGeneratorAction class
//
// $Id: PrimaryGeneratorAction.cc,v 1.3 2006-06-29 17:03:46 gunter Exp $
// GEANT4 tag $Name: not supported by cvs2svn $
//
// $Id$
//
//
/////////////////////////////////////////////////////////////////////////
@@ -48,40 +50,43 @@
#include "G4Event.hh"
#include "G4ParticleTable.hh"
#include "G4ParticleDefinition.hh"
#include "G4Electron.hh"
#include "HistoManager.hh"
#include "G4SystemOfUnits.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
PrimaryGeneratorAction::PrimaryGeneratorAction(DetectorConstruction* det)
:detector(det)
:fDetector(det)
{
G4int n_particle = 1;
particleGun = new G4ParticleGun(n_particle);
G4ParticleDefinition* particle
= G4ParticleTable::GetParticleTable()->FindParticle("e-");
particleGun->SetParticleDefinition(particle);
particleGun->SetParticleMomentumDirection(G4ThreeVector(0.,0.,1.));
particleGun->SetParticleEnergy(1.*GeV);
fParticleGun = new G4ParticleGun(1);
fParticleGun->SetParticleDefinition(G4Electron::Electron());
fParticleGun->SetParticleMomentumDirection(G4ThreeVector(0.,0.,1.));
fParticleGun->SetParticleEnergy(1.*GeV);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
PrimaryGeneratorAction::~PrimaryGeneratorAction()
{
delete particleGun;
delete fParticleGun;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void PrimaryGeneratorAction::GeneratePrimaries(G4Event* anEvent)
{
G4double zVertex = - (detector->GetWorldSizeZ());
particleGun->SetParticlePosition(G4ThreeVector(0.,0.,zVertex));
if(anEvent->GetEventID() == 1)
(HistoManager::GetPointer())->SetBeamEnergy(particleGun->GetParticleEnergy());
particleGun->GeneratePrimaryVertex(anEvent);
if(anEvent->GetEventID() == 0) {
G4double zVertex = - (fDetector->GetWorldSizeZ());
fParticleGun->SetParticlePosition(G4ThreeVector(0.,0.,zVertex));
(HistoManager::GetPointer())->SetBeamEnergy(fParticleGun->GetParticleEnergy());
G4cout << "### PrimaryGeneratorAction::GeneratePrimaries ##########" << G4endl;
G4cout << "### " << fParticleGun->GetParticleDefinition()->GetParticleName()
<< " E(MeV)= " << fParticleGun->GetParticleEnergy()/MeV << G4endl;
G4cout << "########################################################"
<< G4endl;
}
fParticleGun->GeneratePrimaryVertex(anEvent);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -23,11 +23,13 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// -------------------------------------------------------------
/// \file electromagnetic/TestEm9/src/RunAction.cc
/// \brief Implementation of the RunAction class
//
//
// -------------------------------------------------------------
// GEANT4
//
// GEANT4
//
//
// -------------------------------------------------------------
@@ -23,8 +23,10 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: StepMax.cc,v 1.3 2006-06-29 17:03:52 gunter Exp $
// GEANT4 tag $Name: not supported by cvs2svn $
/// \file electromagnetic/TestEm9/src/StepMax.cc
/// \brief Implementation of the StepMax class
//
// $Id$
//
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -36,15 +38,18 @@
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
StepMax::StepMax(const G4String& processName)
: G4VDiscreteProcess(processName),
MaxChargedStep(DBL_MAX)
: G4VDiscreteProcess(processName),
fMaxChargedStep(DBL_MAX)
{
pMess = new StepMaxMessenger(this);
fMessenger = new StepMaxMessenger(this);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
StepMax::~StepMax() { delete pMess; }
StepMax::~StepMax()
{
delete fMessenger;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -55,20 +60,23 @@ 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......
G4double StepMax::PostStepGetPhysicalInteractionLength(
const G4Track&,
G4double,
G4ForceCondition* condition )
G4double
StepMax::PostStepGetPhysicalInteractionLength(const G4Track&,
G4double,
G4ForceCondition* condition)
{
// condition is set to "Not Forced"
*condition = NotForced;
ProposedStep = MaxChargedStep;
fProposedStep = fMaxChargedStep;
return ProposedStep;
return fProposedStep;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -80,3 +88,10 @@ G4VParticleChange* StepMax::PostStepDoIt(const G4Track& aTrack, const G4Step&)
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4double StepMax::GetMeanFreePath(const G4Track&, G4double, G4ForceCondition*)
{
return 0.;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -23,8 +23,10 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: StepMaxMessenger.cc,v 1.2 2006-06-29 17:03:54 gunter Exp $
// GEANT4 tag $Name: not supported by cvs2svn $
/// \file electromagnetic/TestEm9/src/StepMaxMessenger.cc
/// \brief Implementation of the StepMaxMessenger class
//
// $Id$
//
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -38,29 +40,29 @@
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
StepMaxMessenger::StepMaxMessenger(StepMax* stepM)
:stepMax(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");
StepMaxCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
fStepMaxCmd = new G4UIcmdWithADoubleAndUnit("/testem/stepMax",this);
fStepMaxCmd->SetGuidance("Set max allowed step length");
fStepMaxCmd->SetParameterName("mxStep",false);
fStepMaxCmd->SetRange("mxStep>0.");
fStepMaxCmd->SetUnitCategory("Length");
fStepMaxCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
StepMaxMessenger::~StepMaxMessenger()
{
delete StepMaxCmd;
delete fStepMaxCmd;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void StepMaxMessenger::SetNewValue(G4UIcommand* command, G4String newValue)
{
if (command == StepMaxCmd)
{ stepMax->SetMaxStep(StepMaxCmd->GetNewDoubleValue(newValue));}
if (command == fStepMaxCmd)
{ fStepMax->SetMaxStep(fStepMaxCmd->GetNewDoubleValue(newValue));}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -23,9 +23,11 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
/// \file electromagnetic/TestEm9/src/SteppingAction.cc
/// \brief Implementation of the SteppingAction class
//
// $Id: SteppingAction.cc,v 1.2 2006-06-29 17:03:57 gunter Exp $
// GEANT4 tag $Name: not supported by cvs2svn $
//
// $Id$
//
//
/////////////////////////////////////////////////////////////////////////
@@ -50,7 +52,7 @@
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
SteppingAction::SteppingAction():
theHisto(HistoManager::GetPointer())
fHisto(HistoManager::GetPointer())
{}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -62,28 +64,28 @@ SteppingAction::~SteppingAction()
void SteppingAction::UserSteppingAction(const G4Step* aStep)
{
theHisto->AddStep();
G4double edep = aStep->GetTotalEnergyDeposit();
if(edep == 0.) return;
fHisto->AddStep();
G4double edep = aStep->GetTotalEnergyDeposit()*aStep->GetTrack()->GetWeight();
if(edep == 0.) { return; }
const G4VPhysicalVolume* pv = aStep->GetPreStepPoint()->GetPhysicalVolume();
const G4LogicalVolume* lv = pv->GetLogicalVolume();
// const G4MaterialCutsCouple* couple = aStep->GetTrack()->GetMaterialCutsCouple();
// G4int idx = couple->GetIndex();
// const G4Material* mat = couple->GetMaterial();
// G4cout << "Step in " << mat->GetName() << " idx= " << idx << " edep= " << edep << G4endl;
G4int volumeIndex = -1;
G4int copyNo = pv->GetCopyNo();
// comparison of strings is not effective
// this method left only for simplicity of the code
G4String name = lv->GetName();
if(name == "Ecal") volumeIndex = 0;
else if(name == "Abs1") volumeIndex = 1;
else if(name == "Abs2") volumeIndex = 2;
else if(name == "Abs3") volumeIndex = 3;
else if(name == "Abs4") volumeIndex = 4;
else if(name == "Vert") volumeIndex = 5;
// G4cout << " vIndx= " << volumeIndex << " copyNo= " << copyNo << G4endl;
if(volumeIndex>=0) theHisto->AddEnergy(edep, volumeIndex, copyNo);
if(name == "Ecal") { volumeIndex = 0; }
else if(name == "Abs1") { volumeIndex = 1; }
else if(name == "Abs2") { volumeIndex = 2; }
else if(name == "Abs3") { volumeIndex = 3; }
else if(name == "Abs4") { volumeIndex = 4; }
else if(name == "Vert") { volumeIndex = 5; }
// G4cout << " vIndx= " << volumeIndex << " copyNo= " << copyNo << G4endl;
if(volumeIndex>=0) { fHisto->AddEnergy(edep, volumeIndex, copyNo); }
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -23,6 +23,9 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
/// \file electromagnetic/TestEm9/src/TrackingAction.cc
/// \brief Implementation of the TrackingAction class
//
//---------------------------------------------------------------------------
//
@@ -49,12 +52,13 @@
#include "G4Electron.hh"
#include "G4EventManager.hh"
#include "G4Event.hh"
#include "G4SystemOfUnits.hh"
#include "HistoManager.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
TrackingAction::TrackingAction():
theHisto(HistoManager::GetPointer())
fHisto(HistoManager::GetPointer())
{}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
@@ -66,17 +70,17 @@ TrackingAction::~TrackingAction()
void TrackingAction::PreUserTrackingAction(const G4Track* aTrack)
{
theHisto->ScoreNewTrack(aTrack);
fHisto->ScoreNewTrack(aTrack);
if(1 < theHisto->GetVerbose()) {
if(1 < fHisto->GetVerbose()) {
G4int pid = aTrack->GetParentID();
const G4String name = aTrack->GetDefinition()->GetParticleName();
if (theHisto->GetMaxEnergy() < aTrack->GetKineticEnergy() && pid > 0) {
if (fHisto->GetMaxEnergy() < aTrack->GetKineticEnergy() && pid > 0) {
G4cout << "Track #"
<< aTrack->GetTrackID() << " of " << name
<< " Emax(MeV)= " << theHisto->GetMaxEnergy()/MeV
<< " Emax(MeV)= " << fHisto->GetMaxEnergy()/MeV
<< " Ekin(MeV)= " << aTrack->GetKineticEnergy()/MeV
<< " ## EventID= "
<< (G4EventManager::GetEventManager())->GetConstCurrentEvent()
@@ -87,3 +91,8 @@ void TrackingAction::PreUserTrackingAction(const G4Track* aTrack)
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
void TrackingAction::PostUserTrackingAction(const G4Track*)
{}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....