Import Geant4 9.6.0 source tree

This commit is contained in:
Gabriele Cosmo
2016-06-09 17:01:34 +02:00
parent b1eb5424d2
commit e2d2f9810a
10384 changed files with 698580 additions and 628834 deletions
@@ -23,8 +23,10 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: DetectorConstruction.cc,v 1.2 2010-10-27 14:52:07 vnivanch Exp $
// GEANT4 tag $Name: not supported by cvs2svn $
/// \file electromagnetic/TestEm8/src/DetectorConstruction.cc
/// \brief Implementation of the DetectorConstruction class
//
// $Id$
//
/////////////////////////////////////////////////////////////////////////
//
@@ -63,6 +65,8 @@
#include "G4Colour.hh"
#include "G4UnitsTable.hh"
#include "G4PhysicalConstants.hh"
#include "G4SystemOfUnits.hh"
#include "G4ios.hh"
/////////////////////////////////////////////////////////////////////////////
@@ -115,6 +119,7 @@ void DetectorConstruction::DefineMaterials()
G4Element* elC = manager->FindOrBuildElement(6);
G4Element* elO = manager->FindOrBuildElement(8);
G4Element* elF = manager->FindOrBuildElement(9);
G4Element* elNe = manager->FindOrBuildElement(10);
G4Element* elXe = manager->FindOrBuildElement(54);
//
// simple gases at STP conditions
@@ -134,18 +139,18 @@ void DetectorConstruction::DefineMaterials()
// 93% Kr + 7% CH4, STP
density = 3.491*mg/cm3 ;
G4Material* Kr7CH4 = new G4Material(name="Kr7CH4" , density,
ncomponents=2);
ncomponents=2);
Kr7CH4->AddMaterial( Kr, fractionmass = 0.986 ) ;
Kr7CH4->AddMaterial( Methane, fractionmass = 0.014 ) ;
G4double TRT_Xe_density = 5.485*mg/cm3;
G4Material* TRT_Xe = new G4Material(name="TRT_Xe", TRT_Xe_density, nel=1,
kStateGas,293.15*kelvin,1.*atmosphere);
kStateGas,293.15*kelvin,1.*atmosphere);
TRT_Xe->AddElement(elXe,1);
G4double TRT_CO2_density = 1.842*mg/cm3;
G4Material* TRT_CO2 = new G4Material(name="TRT_CO2", TRT_CO2_density, nel=2,
kStateGas,293.15*kelvin,1.*atmosphere);
kStateGas,293.15*kelvin,1.*atmosphere);
TRT_CO2->AddElement(elC,1);
TRT_CO2->AddElement(elO,2);
@@ -158,8 +163,8 @@ void DetectorConstruction::DefineMaterials()
// ATLAS TRT straw tube gas mixture (20 C, 1 atm)
G4double XeCO2CF4_density = 4.76*mg/cm3;
G4Material* XeCO2CF4 = new G4Material(name="XeCO2CF4", XeCO2CF4_density,
ncomponents=3,
kStateGas,293.15*kelvin,1.*atmosphere);
ncomponents=3,
kStateGas,293.15*kelvin,1.*atmosphere);
XeCO2CF4->AddMaterial(TRT_Xe,0.807);
XeCO2CF4->AddMaterial(TRT_CO2,0.039);
XeCO2CF4->AddMaterial(TRT_CF4,0.154);
@@ -187,23 +192,31 @@ void DetectorConstruction::DefineMaterials()
// 80% Ar + 20% CO2, STP
density = 1.8223*mg/cm3 ;
G4Material* Ar_80CO2_20 = new G4Material(name="ArCO2" , density,
ncomponents=2);
ncomponents=2);
Ar_80CO2_20->AddMaterial( Argon, fractionmass = 0.783 ) ;
Ar_80CO2_20->AddMaterial( CarbonDioxide, fractionmass = 0.217 ) ;
// 80% Xe + 20% CO2, STP
density = 5.0818*mg/cm3 ;
G4Material* Xe20CO2 = new G4Material(name="Xe20CO2", density,
ncomponents=2);
ncomponents=2);
Xe20CO2->AddMaterial( Xe, fractionmass = 0.922 ) ;
Xe20CO2->AddMaterial( CarbonDioxide, fractionmass = 0.078 ) ;
// 80% Kr + 20% CO2, STP
density = 3.601*mg/cm3 ;
G4Material* Kr20CO2 = new G4Material(name="Kr20CO2" , density,
ncomponents=2);
ncomponents=2);
Kr20CO2->AddMaterial( Kr, fractionmass = 0.89 ) ;
Kr20CO2->AddMaterial( CarbonDioxide, fractionmass = 0.11 ) ;
// ALICE mixture TPC_Ne-CO2-2
density = 0.939*mg/cm3 ;
G4Material* NeCO2 = new G4Material(name="TPC_Ne-CO2-2", density,
ncomponents=3);
NeCO2->AddElement( elNe, fractionmass = 0.8039 ) ;
NeCO2->AddElement( elO, fractionmass = 0.1426 ) ;
NeCO2->AddElement( elC, fractionmass = 0.0535 ) ;
fGasMat = XeCH4C3H8;
fWindowMat = Mylar;
@@ -238,38 +251,38 @@ G4VPhysicalVolume* DetectorConstruction::Construct()
// Printout parameters
G4cout << "\n The WORLD is made of "
<< worldSizeZ/mm << "mm of " << fWorldMaterial->GetName() ;
<< worldSizeZ/mm << "mm of " << fWorldMaterial->GetName() ;
G4cout << ", the transverse size (R) of the world is " << worldSizeR/mm
<< " mm. " << G4endl;
<< " mm. " << G4endl;
G4cout << " The CONTAINER is made of "
<< fWindowThick/mm << "mm of " << fWindowMat->GetName() << G4endl;
<< fWindowThick/mm << "mm of " << fWindowMat->GetName() << G4endl;
G4cout << " The TARGET is made of "
<< fGasThickness/mm << "mm of " << fGasMat->GetName() ;
<< fGasThickness/mm << "mm of " << fGasMat->GetName() ;
G4cout << ", the transverse size (R) is " << fGasRadius/mm << " mm. " << G4endl;
G4cout << G4endl;
// World
G4Tubs* SolidWorld = new G4Tubs("World",
0.,worldSizeR,worldSizeZ/2.,0.,CLHEP::twopi);
G4Tubs* SolidWorld = new G4Tubs("World",
0.,worldSizeR,worldSizeZ/2.,0.,CLHEP::twopi);
fLogicWorld = new G4LogicalVolume(SolidWorld, fWorldMaterial, "World");
fLogicWorld = new G4LogicalVolume(SolidWorld, fWorldMaterial, "World");
fPhysWorld = new G4PVPlacement(0, //no rotation
G4ThreeVector(0.,0.,0.),
fPhysWorld = new G4PVPlacement(0, //no rotation
G4ThreeVector(0.,0.,0.),
"World",
fLogicWorld,
0, //its mother volume
false, //no boolean operation
0); //copy number
0, //its mother volume
false, //no boolean operation
0); //copy number
// Window
G4Tubs* wind = new G4Tubs("Absorber",
0.,contR,contThick/2.,0.,CLHEP::twopi);
G4Tubs* wind = new G4Tubs("Absorber",
0.,contR,contThick/2.,0.,CLHEP::twopi);
fLogicWind = new G4LogicalVolume(wind, fWindowMat, "Window");
G4PVPlacement* PhysWind = new G4PVPlacement(0, G4ThreeVector(0.,0.,0.), "Window",
fLogicWind, fPhysWorld, false, 0);
fLogicWind, fPhysWorld, false, 0);
// Detector volume
G4Tubs* det = new G4Tubs("Gas", 0., fGasRadius, fGasThickness/2., 0., CLHEP::twopi);
@@ -23,8 +23,10 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: DetectorMessenger.cc,v 1.2 2010-10-27 14:52:07 vnivanch Exp $
// GEANT4 tag $Name: not supported by cvs2svn $
/// \file electromagnetic/TestEm8/src/DetectorMessenger.cc
/// \brief Implementation of the DetectorMessenger class
//
// $Id$
//
/////////////////////////////////////////////////////////////////////////
//
@@ -47,61 +49,61 @@
///////////////////////////////////////////////////////////////////////////////////
DetectorMessenger::DetectorMessenger(DetectorConstruction * Det)
:Detector(Det)
DetectorMessenger::DetectorMessenger(DetectorConstruction * det)
: fDetector(det)
{
detDir = new G4UIdirectory("/testem/");
detDir->SetGuidance("Detector control.");
fDetDir = new G4UIdirectory("/testem/");
fDetDir->SetGuidance("Detector control.");
GasMaterCmd = new G4UIcmdWithAString("/testem/setGasMat",this);
GasMaterCmd->SetGuidance("Select material of the detector.");
GasMaterCmd->SetParameterName("gmat",true);
GasMaterCmd->SetDefaultValue("Argon");
GasMaterCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
fGasMaterCmd = new G4UIcmdWithAString("/testem/setGasMat",this);
fGasMaterCmd->SetGuidance("Select material of the detector.");
fGasMaterCmd->SetParameterName("gmat",true);
fGasMaterCmd->SetDefaultValue("Argon");
fGasMaterCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
WindowMaterCmd = new G4UIcmdWithAString("/testem/setWindowMat",this);
WindowMaterCmd->SetGuidance("Select material of the window.");
WindowMaterCmd->SetParameterName("wmat",true);
WindowMaterCmd->SetDefaultValue("Mylar");
WindowMaterCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
fWindowMaterCmd = new G4UIcmdWithAString("/testem/setWindowMat",this);
fWindowMaterCmd->SetGuidance("Select material of the window.");
fWindowMaterCmd->SetParameterName("wmat",true);
fWindowMaterCmd->SetDefaultValue("Mylar");
fWindowMaterCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
WorldMaterCmd = new G4UIcmdWithAString("/testem/setWorldMat",this);
WorldMaterCmd->SetGuidance("Select material of the world.");
WorldMaterCmd->SetParameterName("worldmat",true);
WorldMaterCmd->SetDefaultValue("empty");
WorldMaterCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
fWorldMaterCmd = new G4UIcmdWithAString("/testem/setWorldMat",this);
fWorldMaterCmd->SetGuidance("Select material of the world.");
fWorldMaterCmd->SetParameterName("worldmat",true);
fWorldMaterCmd->SetDefaultValue("empty");
fWorldMaterCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
GasThickCmd = new G4UIcmdWithADoubleAndUnit("/testem/setGasThick",this);
GasThickCmd->SetGuidance("Set thickness of the detector");
GasThickCmd->SetParameterName("SizeZ",false,false);
GasThickCmd->SetUnitCategory("Length");
GasThickCmd->SetDefaultUnit("mm");
GasThickCmd->SetRange("SizeZ>0.");
GasThickCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
fGasThickCmd = new G4UIcmdWithADoubleAndUnit("/testem/setGasThick",this);
fGasThickCmd->SetGuidance("Set thickness of the detector");
fGasThickCmd->SetParameterName("SizeZ",false,false);
fGasThickCmd->SetUnitCategory("Length");
fGasThickCmd->SetDefaultUnit("mm");
fGasThickCmd->SetRange("SizeZ>0.");
fGasThickCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
GasRadCmd = new G4UIcmdWithADoubleAndUnit("/testem/setGasRad",this);
GasRadCmd->SetGuidance("Set radius of the detector");
GasRadCmd->SetParameterName("SizeR",false,false);
GasRadCmd->SetUnitCategory("Length");
GasRadCmd->SetDefaultUnit("mm");
GasRadCmd->SetRange("SizeR>0.");
GasRadCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
fGasRadCmd = new G4UIcmdWithADoubleAndUnit("/testem/setGasRad",this);
fGasRadCmd->SetGuidance("Set radius of the detector");
fGasRadCmd->SetParameterName("SizeR",false,false);
fGasRadCmd->SetUnitCategory("Length");
fGasRadCmd->SetDefaultUnit("mm");
fGasRadCmd->SetRange("SizeR>0.");
fGasRadCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
WinThickCmd = new G4UIcmdWithADoubleAndUnit("/testem/setWindowThick",this);
WinThickCmd->SetGuidance("Set thickness of the window");
WinThickCmd->SetParameterName("delta",false,false);
WinThickCmd->SetUnitCategory("Length");
WinThickCmd->SetDefaultUnit("mm");
WinThickCmd->SetRange("delta>0.");
WinThickCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
fWinThickCmd = new G4UIcmdWithADoubleAndUnit("/testem/setWindowThick",this);
fWinThickCmd->SetGuidance("Set thickness of the window");
fWinThickCmd->SetParameterName("delta",false,false);
fWinThickCmd->SetUnitCategory("Length");
fWinThickCmd->SetDefaultUnit("mm");
fWinThickCmd->SetRange("delta>0.");
fWinThickCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
ionCmd = new G4UIcmdWithADoubleAndUnit("/testem/setPairEnergy",this);
ionCmd->SetGuidance("Set energy per electron-ion pair for detector");
ionCmd->SetParameterName("en",false,false);
ionCmd->SetUnitCategory("Energy");
ionCmd->SetDefaultUnit("eV");
ionCmd->SetRange("en>0.");
ionCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
fIonCmd = new G4UIcmdWithADoubleAndUnit("/testem/setPairEnergy",this);
fIonCmd->SetGuidance("Set energy per electron-ion pair for detector");
fIonCmd->SetParameterName("en",false,false);
fIonCmd->SetUnitCategory("Energy");
fIonCmd->SetDefaultUnit("eV");
fIonCmd->SetRange("en>0.");
fIonCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
}
@@ -109,47 +111,47 @@ DetectorMessenger::DetectorMessenger(DetectorConstruction * Det)
DetectorMessenger::~DetectorMessenger()
{
delete GasMaterCmd;
delete GasThickCmd;
delete GasRadCmd;
delete WinThickCmd;
delete WindowMaterCmd;
delete WorldMaterCmd;
delete ionCmd;
delete detDir;
delete fGasMaterCmd;
delete fGasThickCmd;
delete fGasRadCmd;
delete fWinThickCmd;
delete fWindowMaterCmd;
delete fWorldMaterCmd;
delete fIonCmd;
delete fDetDir;
}
//////////////////////////////////////////////////////////////////////////////////
void DetectorMessenger::SetNewValue(G4UIcommand* command,G4String newValue)
{
if( command == GasMaterCmd )
if( command == fGasMaterCmd )
{
Detector->SetGasMaterial(newValue);
fDetector->SetGasMaterial(newValue);
}
else if( command == WindowMaterCmd )
else if( command == fWindowMaterCmd )
{
Detector->SetContainerMaterial(newValue);
fDetector->SetContainerMaterial(newValue);
}
else if( command == WorldMaterCmd )
else if( command == fWorldMaterCmd )
{
Detector->SetWorldMaterial(newValue);
fDetector->SetWorldMaterial(newValue);
}
else if( command == GasThickCmd )
else if( command == fGasThickCmd )
{
Detector->SetGasThickness(GasThickCmd->GetNewDoubleValue(newValue));
fDetector->SetGasThickness(fGasThickCmd->GetNewDoubleValue(newValue));
}
else if( command == GasRadCmd )
else if( command == fGasRadCmd )
{
Detector->SetGasRadius(GasRadCmd->GetNewDoubleValue(newValue));
fDetector->SetGasRadius(fGasRadCmd->GetNewDoubleValue(newValue));
}
else if( command == WinThickCmd )
else if( command == fWinThickCmd )
{
Detector->SetContainerThickness(WinThickCmd->GetNewDoubleValue(newValue));
fDetector->SetContainerThickness(fWinThickCmd->GetNewDoubleValue(newValue));
}
else if( command == ionCmd )
else if( command == fIonCmd )
{
Detector->SetPairEnergy(ionCmd->GetNewDoubleValue(newValue));
fDetector->SetPairEnergy(fIonCmd->GetNewDoubleValue(newValue));
}
}
@@ -23,8 +23,10 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: EventAction.cc,v 1.1 2010-09-08 11:23:53 vnivanch Exp $
// GEANT4 tag $Name: not supported by cvs2svn $
/// \file electromagnetic/TestEm8/src/EventAction.cc
/// \brief Implementation of the EventAction class
//
// $Id$
//
//---------------------------------------------------------------------------
//
@@ -23,8 +23,10 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: Histo.cc,v 1.2 2010-09-28 19:08:27 vnivanch Exp $
// GEANT4 tag $Name: not supported by cvs2svn $
/// \file electromagnetic/TestEm8/src/Histo.cc
/// \brief Implementation of the Histo class
//
// $Id$
//
//---------------------------------------------------------------------------
//
@@ -41,226 +43,310 @@
#include "Histo.hh"
#include "HistoMessenger.hh"
#ifdef G4ANALYSIS_USE
#include "AIDA/AIDA.h"
#endif
#include "G4RootAnalysisManager.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
Histo::Histo()
{
verbose = 0;
histName = "testem8";
histType = "root";
tupleList = "";
ntup = 0;
nHisto = 0;
defaultAct = 1;
messenger = 0;
#ifdef G4ANALYSIS_USE
tree = 0;
af = 0;
#endif
messenger = new HistoMessenger(this);
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,8 +23,10 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: HistoManager.cc,v 1.4 2010-11-19 10:15:33 grichine Exp $
// GEANT4 tag $Name: not supported by cvs2svn $
/// \file electromagnetic/TestEm8/src/HistoManager.cc
/// \brief Implementation of the HistoManager class
//
// $Id$
//
//---------------------------------------------------------------------------
//
@@ -44,6 +46,7 @@
#include "G4Step.hh"
#include "G4LossTableManager.hh"
#include "G4ElectronIonPair.hh"
#include "G4SystemOfUnits.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
@@ -63,34 +66,32 @@ HistoManager* HistoManager::GetPointer()
HistoManager::HistoManager()
{
nHisto = 2;
verbose = 1;
maxEnergy = 100.*keV;
nBinsE = 100;
nBinsCluster = 200;
histo = new Histo();
elIonPair = G4LossTableManager::Instance()->ElectronIonPair();
fNHisto = 2;
fVerbose = 1;
fMaxEnergy = 100.*keV;
fBinsE = 100;
fBinsCluster = 200;
fHisto = new Histo();
bookHisto();
fElIonPair = G4LossTableManager::Instance()->ElectronIonPair();
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
HistoManager::~HistoManager()
{
delete histo;
delete fHisto;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
void HistoManager::bookHisto()
{
histo->add1D("10",
"Energy deposition in detector (keV)",nBinsE,0.0,maxEnergy/keV,1.0);
histo->add1D("11",
"Number of primary clusters",nBinsCluster,-0.5,G4double(nBinsCluster)-0.5,1.0);
fHisto->Add1D("10","Energy deposition in detector (keV)",
fBinsE,0.0,fMaxEnergy/keV,1.0);
fHisto->Add1D("11","Number of primary clusters",
fBinsCluster,-0.5,fBinsCluster-0.5,1.0);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
@@ -98,18 +99,24 @@ void HistoManager::bookHisto()
void HistoManager::BeginOfRun()
{
// initilise scoring
nEvt = 0;
nTotStepGas = 0;
nTotCluster = 0;
overflow = 0;
fEvt = 0.0;
fTotStepGas = 0.0;
fTotCluster = 0.0;
fOverflow = 0.0;
histo->book();
if(fHisto->IsActive()) {
fHisto->Activate(0, true);
fHisto->Activate(1, true);
}
fHisto->Book();
Egas.resize(nBinsE,0.0);
fEgas.resize(fBinsE,0.0);
if(verbose > 0) {
if(fVerbose > 0) {
G4cout << "HistoManager: Histograms are booked and run has been started"
<< G4endl;
G4cout << " BinsCluster= " << fBinsCluster << " BinsE= " << fBinsE
<< " Emax(keV)= " << fMaxEnergy/keV << G4endl;
}
}
@@ -117,44 +124,48 @@ void HistoManager::BeginOfRun()
void HistoManager::EndOfRun()
{
G4double norm = nEvt;
if(nEvt > 0.0) { norm = 1.0/norm; }
G4double norm = fEvt;
if(fEvt > 0.0) { norm = 1.0/norm; }
nTotStepGas *= norm;
nTotCluster *= norm;
overflow *= norm;
fTotStepGas *= norm;
fTotCluster *= norm;
fOverflow *= norm;
G4double y1 = 0.0;
G4double y2 = 0.0;
G4double de = maxEnergy/G4double(nBinsE);
G4double de = fMaxEnergy/G4double(fBinsE);
G4double x1 = -de*0.5;
for(G4int j=0; j<nBinsE; ++j) {
for(G4int j=0; j<fBinsE; ++j) {
x1 += de;
G4double y = Egas[j]*norm;
G4double y = fEgas[j]*norm;
y1 += y*x1;
y2 += y*x1*x1;
}
G4double norm1 = G4double(fBinsE);
if(norm1 > 0.0) { norm1 = 1.0/norm1; }
y1 *= norm1;
y2 *= norm1;
y2 -= y1*y1;
if(y2 >= 0.0) { y2 = std::sqrt(y2); }
G4cout << " ================== run summary =====================" << G4endl;
G4int prec = G4cout.precision(5);
G4cout << " End of Run TotNbofEvents = " <<
G4int(nEvt) << G4endl ;
G4int(fEvt) << G4endl ;
G4cout << G4endl;
G4cout << " Mean energy deposit in absorber = " <<
y1/keV << " +- " << y2*std::sqrt(norm)/keV << " keV; ";
if(y1 > 0.0) { G4cout << " RMS/Emean = " << y2/y1; }
G4cout << G4endl;
G4cout << " Mean number of steps in absorber= "
<< nTotStepGas << "; mean number of ion-clusters = " << nTotCluster
<< fTotStepGas << "; mean number of ion-clusters = " << fTotCluster
<< G4endl;
G4cout << G4endl;
G4cout << " ====== Energy deposit distribution Noverflows= " << overflow
<< " ====== " << G4endl ;
G4cout << " ====== Energy deposit distribution Noverflows= " << fOverflow
<< " ====== " << G4endl ;
G4cout << " bin nb Elow entries normalized " << G4endl;
std::ofstream fileOut("distribution.out", std::ios::out );
@@ -162,22 +173,22 @@ void HistoManager::EndOfRun()
x1 = 0.0;
fileOut<<nBinsE<<G4endl;
fileOut << fBinsE << G4endl;
for(G4int j=0; j<nBinsE; ++j)
for(G4int j=0; j<fBinsE; ++j)
{
G4cout << std::setw(5) << j << std::setw(10) << x1/keV
<< std::setw(12) << Egas[j] << std::setw(12) << Egas[j]*norm
<< G4endl ;
fileOut << x1/keV << "\t" << Egas[j] << G4endl;
<< std::setw(12) << fEgas[j] << std::setw(12) << fEgas[j]*norm
<< G4endl ;
fileOut << x1/keV << "\t" << fEgas[j] << G4endl;
x1 += de;
}
G4cout.precision(prec);
// normalise histograms
histo->scale(0,norm);
histo->scale(1,norm);
fHisto->ScaleH1(0,norm);
fHisto->ScaleH1(1,norm);
histo->save();
fHisto->Save();
G4cout << " ================== run end ==========================" << G4endl;
}
@@ -185,41 +196,41 @@ void HistoManager::EndOfRun()
void HistoManager::BeginOfEvent()
{
nEvt += 1;
totEdep = 0.0;
nStepGas = 0;
nCluster = 0;
fEvt += 1.0;
fTotEdep = 0.0;
fStepGas = 0;
fCluster = 0;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
void HistoManager::EndOfEvent()
{
nTotStepGas += nStepGas;
nTotCluster += nCluster;
fTotStepGas += fStepGas;
fTotCluster += fCluster;
G4int idx = G4int(totEdep*nBinsE/maxEnergy);
G4int idx = G4int(fTotEdep*fBinsE/fMaxEnergy);
if(idx < 0) { idx = 0; }
if(idx >= nBinsE) { overflow += 1.0; }
else { Egas[idx] += 1.0; }
if(idx >= fBinsE) { fOverflow += 1.0; }
else { fEgas[idx] += 1.0; }
// fill histo
histo->fill(0,totEdep/keV,1.0);
histo->fill(1,nCluster,1.0);
fHisto->Fill(0,fTotEdep/keV,1.0);
fHisto->Fill(1,fCluster,1.0);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void HistoManager::AddEnergy(G4double edep, G4Step* step)
{
if(1 < verbose) {
if(1 < fVerbose) {
G4cout << "HistoManager::AddEnergy: e(keV)= " << edep/keV
<< G4endl;
}
totEdep += edep;
if(step->GetTrack()->GetTrackID() == 1) { nStepGas += 1.0; }
fTotEdep += edep;
if(step->GetTrack()->GetTrackID() == 1) { fStepGas += 1.0; }
nCluster += elIonPair->SampleNumberOfIonsAlongStep(step);
fCluster += fElIonPair->SampleNumberOfIonsAlongStep(step);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
@@ -23,9 +23,11 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
/// \file electromagnetic/TestEm8/src/HistoMessenger.cc
/// \brief Implementation of the HistoMessenger class
//
// $Id: HistoMessenger.cc,v 1.1 2010-09-08 11:23: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: PhysicsList.cc,v 1.21 2010-10-27 14:52:07 vnivanch Exp $
// GEANT4 tag $Name: not supported by cvs2svn $
/// \file electromagnetic/TestEm8/src/PhysicsList.cc
/// \brief Implementation of the PhysicsList class
//
// $Id$
//
//---------------------------------------------------------------------------
//
@@ -47,6 +49,7 @@
#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"
@@ -60,7 +63,9 @@
#include "G4Proton.hh"
#include "G4UnitsTable.hh"
#include "G4SystemOfUnits.hh"
#include "G4LossTableManager.hh"
#include "G4ProductionCutsTable.hh"
#include "StepMax.hh"
@@ -72,24 +77,24 @@
PhysicsList::PhysicsList() : G4VModularPhysicsList()
{
em_config = G4LossTableManager::Instance()->EmConfigurator();
fConfig = G4LossTableManager::Instance()->EmConfigurator();
G4LossTableManager::Instance()->SetVerbose(1);
defaultCutValue = 1.*mm;
cutForGamma = defaultCutValue;
cutForElectron = defaultCutValue;
cutForPositron = defaultCutValue;
cutForProton = defaultCutValue;
fCutForGamma = defaultCutValue;
fCutForElectron = defaultCutValue;
fCutForPositron = defaultCutValue;
fCutForProton = defaultCutValue;
pMessenger = new PhysicsListMessenger(this);
fMessenger = new PhysicsListMessenger(this);
stepMaxProcess = new StepMax();
fStepMaxProcess = new StepMax();
// Decay Physics is always defined
generalPhysicsList = new G4DecayPhysics();
fDecayPhysicsList = new G4DecayPhysics();
// EM physics
emName = G4String("emstandard");
emPhysicsList = new G4EmStandardPhysics(1);
fEmName = G4String("emstandard");
fEmPhysicsList = new G4EmStandardPhysics(1);
SetVerboseLevel(1);
}
@@ -98,18 +103,18 @@ PhysicsList::PhysicsList() : G4VModularPhysicsList()
PhysicsList::~PhysicsList()
{
delete pMessenger;
delete generalPhysicsList;
delete emPhysicsList;
for(size_t i=0; i<hadronPhys.size(); ++i) { delete hadronPhys[i]; }
delete stepMaxProcess;
delete fMessenger;
delete fDecayPhysicsList;
delete fEmPhysicsList;
for(size_t i=0; i<fHadronPhys.size(); ++i) { delete fHadronPhys[i]; }
delete fStepMaxProcess;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void PhysicsList::ConstructParticle()
{
generalPhysicsList->ConstructParticle();
fDecayPhysicsList->ConstructParticle();
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -117,9 +122,9 @@ 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();
}
@@ -131,47 +136,53 @@ void PhysicsList::AddPhysicsList(const G4String& name)
G4cout << "PhysicsList::AddPhysicsList: <" << name << ">" << G4endl;
}
if (name == emName) {
if (name == fEmName) {
return;
} else if (name == "emstandard_opt1") {
emName = name;
delete emPhysicsList;
emPhysicsList = new G4EmStandardPhysics_option1();
fEmName = name;
delete fEmPhysicsList;
fEmPhysicsList = new G4EmStandardPhysics_option1();
} else if (name == "emstandard_opt2") {
emName = name;
delete emPhysicsList;
emPhysicsList = new G4EmStandardPhysics_option2();
fEmName = name;
delete fEmPhysicsList;
fEmPhysicsList = new G4EmStandardPhysics_option2();
} else if (name == "emstandard_opt3") {
emName = name;
delete emPhysicsList;
emPhysicsList = new G4EmStandardPhysics_option3();
fEmName = name;
delete fEmPhysicsList;
fEmPhysicsList = new G4EmStandardPhysics_option3();
} else if (name == "emstandard_opt4") {
fEmName = name;
delete fEmPhysicsList;
fEmPhysicsList = new G4EmStandardPhysics_option4();
} else if (name == "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 == "pai") {
emName = name;
fEmName = name;
AddPAIModel(name);
} else if (name == "pai_photon") {
emName = name;
fEmName = name;
AddPAIModel(name);
} else {
@@ -194,9 +205,9 @@ void PhysicsList::AddStepMax()
G4ParticleDefinition* particle = theParticleIterator->value();
G4ProcessManager* pmanager = particle->GetProcessManager();
if (stepMaxProcess->IsApplicable(*particle))
if (fStepMaxProcess->IsApplicable(*particle))
{
pmanager ->AddDiscreteProcess(stepMaxProcess);
pmanager ->AddDiscreteProcess(fStepMaxProcess);
}
}
}
@@ -205,7 +216,7 @@ void PhysicsList::AddStepMax()
void PhysicsList::SetCuts()
{
G4ProductionCutsTable::GetProductionCutsTable()->SetEnergyRange(100.*eV,1e5);
if ( verboseLevel > 0 )
{
G4cout << "PhysicsList::SetCuts:";
@@ -215,10 +226,10 @@ void PhysicsList::SetCuts()
// set cut values for gamma at first and for e- second and next for e+,
// because some processes for e+/e- need cut values for gamma
SetCutValue(cutForGamma, "gamma");
SetCutValue(cutForElectron, "e-");
SetCutValue(cutForPositron, "e+");
SetCutValue(cutForProton, "proton");
SetCutValue(fCutForGamma, "gamma");
SetCutValue(fCutForElectron, "e-");
SetCutValue(fCutForPositron, "e+");
SetCutValue(fCutForProton, "proton");
if ( verboseLevel > 0 ) { DumpCutValuesTable(); }
}
@@ -227,32 +238,32 @@ void PhysicsList::SetCuts()
void PhysicsList::SetCutForGamma(G4double cut)
{
cutForGamma = cut;
SetParticleCuts(cutForGamma, G4Gamma::Gamma());
fCutForGamma = cut;
SetParticleCuts(fCutForGamma, G4Gamma::Gamma());
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void PhysicsList::SetCutForElectron(G4double cut)
{
cutForElectron = cut;
SetParticleCuts(cutForElectron, G4Electron::Electron());
fCutForElectron = cut;
SetParticleCuts(fCutForElectron, G4Electron::Electron());
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void PhysicsList::SetCutForPositron(G4double cut)
{
cutForPositron = cut;
SetParticleCuts(cutForPositron, G4Positron::Positron());
fCutForPositron = cut;
SetParticleCuts(fCutForPositron, G4Positron::Positron());
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void PhysicsList::SetCutForProton(G4double cut)
{
cutForPositron = cut;
SetParticleCuts(cutForProton, G4Proton::Proton());
fCutForPositron = cut;
SetParticleCuts(fCutForProton, G4Proton::Proton());
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -271,9 +282,9 @@ void PhysicsList::AddPAIModel(const G4String& modname)
NewPAIModel(particle, modname, "muIoni");
} else if(partname == "proton" ||
partname == "pi+" ||
partname == "pi+" ||
partname == "pi-"
) {
) {
NewPAIModel(particle, modname, "hIoni");
}
}
@@ -282,18 +293,18 @@ void PhysicsList::AddPAIModel(const G4String& modname)
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void PhysicsList::NewPAIModel(const G4ParticleDefinition* part,
const G4String& modname,
const G4String& procname)
const G4String& modname,
const G4String& procname)
{
G4String partname = part->GetParticleName();
if(modname == "pai") {
G4PAIModel* pai = new G4PAIModel(part,"PAIModel");
em_config->SetExtraEmModel(partname,procname,pai,"GasDetector",
0.0,100.*TeV,pai);
fConfig->SetExtraEmModel(partname,procname,pai,"GasDetector",
0.0,100.*TeV,pai);
} else if(modname == "pai_photon") {
G4PAIPhotonModel* pai = new G4PAIPhotonModel(part,"PAIPhotModel");
em_config->SetExtraEmModel(partname,procname,pai,"GasDetector",
0.0,100.*TeV,pai);
fConfig->SetExtraEmModel(partname,procname,pai,"GasDetector",
0.0,100.*TeV,pai);
}
}
@@ -23,8 +23,10 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: PhysicsListMessenger.cc,v 1.3 2010-09-08 09:12:10 vnivanch Exp $
// GEANT4 tag $Name: not supported by cvs2svn $
/// \file electromagnetic/TestEm8/src/PhysicsListMessenger.cc
/// \brief Implementation of the PhysicsListMessenger class
//
// $Id$
//
//---------------------------------------------------------------------------
//
@@ -51,41 +53,41 @@
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
PhysicsListMessenger::PhysicsListMessenger(PhysicsList* pPhys)
:pPhysicsList(pPhys)
:fPhysicsList(pPhys)
{
eCmd = new G4UIcmdWithADoubleAndUnit("/testem/phys/setMaxE",this);
eCmd->SetGuidance("Set max energy deposit");
eCmd->SetParameterName("Emax",false);
eCmd->SetUnitCategory("Energy");
eCmd->SetRange("Emax>0.0");
eCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
fECmd = new G4UIcmdWithADoubleAndUnit("/testem/phys/setMaxE",this);
fECmd->SetGuidance("Set max energy deposit");
fECmd->SetParameterName("Emax",false);
fECmd->SetUnitCategory("Energy");
fECmd->SetRange("Emax>0.0");
fECmd->AvailableForStates(G4State_PreInit,G4State_Idle);
ebCmd = new G4UIcmdWithAnInteger("/testem/phys/setNbinsE",this);
ebCmd->SetGuidance("Set number of bins in energy.");
ebCmd->SetParameterName("Ebins",false);
ebCmd->SetRange("Ebins>0");
ebCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
fEBCmd = new G4UIcmdWithAnInteger("/testem/phys/setNbinsE",this);
fEBCmd->SetGuidance("Set number of bins in energy.");
fEBCmd->SetParameterName("Ebins",false);
fEBCmd->SetRange("Ebins>0");
fEBCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
cbCmd = new G4UIcmdWithAnInteger("/testem/phys/setNbinsCl",this);
cbCmd->SetGuidance("Set max number of clusters.");
cbCmd->SetParameterName("Cbins",false);
cbCmd->SetRange("Cbins>0");
cbCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
fCBCmd = new G4UIcmdWithAnInteger("/testem/phys/setNbinsCl",this);
fCBCmd->SetGuidance("Set max number of clusters.");
fCBCmd->SetParameterName("Cbins",false);
fCBCmd->SetRange("Cbins>0");
fCBCmd->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);
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 eCmd;
delete ebCmd;
delete cbCmd;
delete pListCmd;
delete fECmd;
delete fEBCmd;
delete fCBCmd;
delete fListCmd;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -94,17 +96,17 @@ void PhysicsListMessenger::SetNewValue(G4UIcommand* command,
G4String newValue)
{
HistoManager* man = HistoManager::GetPointer();
if( command == eCmd )
{ man->SetMaxEnergy(eCmd->GetNewDoubleValue(newValue));}
if( command == fECmd )
{ man->SetMaxEnergy(fECmd->GetNewDoubleValue(newValue)); }
if( command == ebCmd )
{ man->SetNumberBins(ebCmd->GetNewIntValue(newValue));}
if( command == fEBCmd )
{ man->SetNumberBins(fEBCmd->GetNewIntValue(newValue)); }
if( command == cbCmd )
{ man->SetNumberBinsCluster(cbCmd->GetNewIntValue(newValue));}
if( command == fCBCmd )
{ man->SetNumberBinsCluster(fCBCmd->GetNewIntValue(newValue)); }
if( command == pListCmd )
{ pPhysicsList->AddPhysicsList(newValue);}
if( command == fListCmd )
{ fPhysicsList->AddPhysicsList(newValue); }
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -23,8 +23,10 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: PrimaryGeneratorAction.cc,v 1.1 2010-09-08 11:23:53 vnivanch Exp $
// GEANT4 tag $Name: not supported by cvs2svn $
/// \file electromagnetic/TestEm8/src/PrimaryGeneratorAction.cc
/// \brief Implementation of the PrimaryGeneratorAction class
//
// $Id$
//
/////////////////////////////////////////////////////////////////////////
//
@@ -43,44 +45,45 @@
#include "PrimaryGeneratorAction.hh"
#include "G4Event.hh"
#include "G4Electron.hh"
#include "G4SystemOfUnits.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
PrimaryGeneratorAction::PrimaryGeneratorAction()
{
particleGun = new G4ParticleGun(1);
particleGun->SetParticleDefinition(G4Electron::Electron());
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)
{
if(1 == anEvent->GetEventID()) {
if(0 == anEvent->GetEventID()) {
G4cout << "### PrimaryGeneratorAction::GeneratePrimaries ##########" << G4endl;
G4cout << "### " << particleGun->GetParticleDefinition()->GetParticleName()
<< " E(MeV)= " << particleGun->GetParticleEnergy()/MeV << G4endl;
G4cout << "### " << fParticleGun->GetParticleDefinition()->GetParticleName()
<< " E(MeV)= " << fParticleGun->GetParticleEnergy()/MeV << G4endl;
G4cout << "########################################################"
<< G4endl;
<< G4endl;
}
particleGun->GeneratePrimaryVertex(anEvent);
fParticleGun->GeneratePrimaryVertex(anEvent);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void PrimaryGeneratorAction::SetPositionZ(G4double z)
{
particleGun->SetParticlePosition(G4ThreeVector(0.,0.,z));
fParticleGun->SetParticlePosition(G4ThreeVector(0.,0.,z));
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -23,8 +23,10 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: RunAction.cc,v 1.1 2010-09-08 11:23:53 vnivanch Exp $
// GEANT4 tag $Name: not supported by cvs2svn $
/// \file electromagnetic/TestEm8/src/RunAction.cc
/// \brief Implementation of the RunAction class
//
// $Id$
//
//---------------------------------------------------------------------------
//
@@ -23,8 +23,10 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: StepMax.cc,v 1.3 2006-06-29 17:00:49 gunter Exp $
// GEANT4 tag $Name: not supported by cvs2svn $
/// \file electromagnetic/TestEm8/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:00:52 gunter Exp $
// GEANT4 tag $Name: not supported by cvs2svn $
/// \file electromagnetic/TestEm8/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,8 +23,10 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: TargetSD.cc,v 1.1 2010-09-08 11:23:53 vnivanch Exp $
// GEANT4 tag $Name: not supported by cvs2svn $
/// \file electromagnetic/TestEm8/src/TargetSD.cc
/// \brief Implementation of the TargetSD class
//
// $Id$
//
/////////////////////////////////////////////////////////////////////////
//
@@ -47,7 +49,7 @@
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
TargetSD::TargetSD(const G4String& name)
: G4VSensitiveDetector(name), theHisto(HistoManager::GetPointer())
: G4VSensitiveDetector(name), fHisto(HistoManager::GetPointer())
{}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
@@ -65,7 +67,7 @@ void TargetSD::Initialize(G4HCofThisEvent*)
G4bool TargetSD::ProcessHits(G4Step* aStep, G4TouchableHistory*)
{
G4double edep = aStep->GetTotalEnergyDeposit();
if(edep > 0.0) { theHisto->AddEnergy(edep, aStep); }
fHisto->AddEnergy(edep, aStep);
return true;
}