Import Geant4 10.0.0 source tree

This commit is contained in:
Gabriele Cosmo
2016-06-10 11:51:14 +02:00
parent e2d2f9810a
commit 286caacf06
12421 changed files with 730077 additions and 502383 deletions
@@ -0,0 +1,86 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: ActionInitialization.cc 68058 2013-03-13 14:47:43Z gcosmo $
//
/// \file ActionInitialization.cc
/// \brief Implementation of the ActionInitialization class
#include "ActionInitialization.hh"
#include "PrimaryGeneratorAction.hh"
#include "RunAction.hh"
#include "TrackingAction.hh"
#include "SteppingAction.hh"
#include "SteppingVerbose.hh"
#include "StackingAction.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
ActionInitialization::ActionInitialization(DetectorConstruction* detector)
: G4VUserActionInitialization(),
fDetector(detector)
{}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
ActionInitialization::~ActionInitialization()
{}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void ActionInitialization::BuildForMaster() const
{
RunAction* runAction = new RunAction(fDetector, 0);
SetUserAction(runAction);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void ActionInitialization::Build() const
{
PrimaryGeneratorAction* primary = new PrimaryGeneratorAction();
SetUserAction(primary);
RunAction* runAction = new RunAction(fDetector, primary );
SetUserAction(runAction);
TrackingAction* trackingAction = new TrackingAction();
SetUserAction(trackingAction);
SteppingAction* steppingAction = new SteppingAction(trackingAction);
SetUserAction(steppingAction);
StackingAction* stackingAction = new StackingAction();
SetUserAction(stackingAction);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4VSteppingVerbose* ActionInitialization::InitializeSteppingVerbose() const
{
return new SteppingVerbose();
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -0,0 +1,199 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
/// \file hadronic/Hadr03/src/DetectorConstruction.cc
/// \brief Implementation of the DetectorConstruction class
//
// $Id: DetectorConstruction.cc 70755 2013-06-05 12:17:48Z ihrivnac $
//
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
#include "DetectorConstruction.hh"
#include "DetectorMessenger.hh"
#include "G4Material.hh"
#include "G4NistManager.hh"
#include "G4Box.hh"
#include "G4LogicalVolume.hh"
#include "G4PVPlacement.hh"
#include "G4GeometryManager.hh"
#include "G4PhysicalVolumeStore.hh"
#include "G4LogicalVolumeStore.hh"
#include "G4SolidStore.hh"
#include "G4RunManager.hh"
#include "G4UnitsTable.hh"
#include "G4SystemOfUnits.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
DetectorConstruction::DetectorConstruction()
:G4VUserDetectorConstruction(),
fPBox(0), fLBox(0), fMaterial(0), fDetectorMessenger(0)
{
fBoxSize = 1*m;
DefineMaterials();
SetMaterial("Water_ts");
fDetectorMessenger = new DetectorMessenger(this);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
DetectorConstruction::~DetectorConstruction()
{ delete fDetectorMessenger;}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4VPhysicalVolume* DetectorConstruction::Construct()
{
return ConstructVolumes();
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void DetectorConstruction::DefineMaterials()
{
// specific element name for thermal neutronHP
// (see G4NeutronHPThermalScatteringNames.cc)
G4Element* H = new G4Element("TS_H_of_Water" ,"H" , 1., 1.0079*g/mole);
G4Element* O = new G4Element("Oxygen" ,"O" , 8., 16.00*g/mole);
G4int ncomponents, natoms;
G4Material* H2O =
new G4Material("Water_ts", 1.000*g/cm3, ncomponents=2,
kStateLiquid, 593*kelvin, 150*bar);
H2O->AddElement(H, natoms=2);
H2O->AddElement(O, natoms=1);
H2O->GetIonisation()->SetMeanExcitationEnergy(78.0*eV);
// graphite
G4Isotope* C12 = new G4Isotope("C12", 6, 12);
G4Element* elC = new G4Element("TS_C_of_Graphite","C", ncomponents=1);
elC->AddIsotope(C12, 100.*perCent);
G4Material* graphite =
new G4Material("graphite", 2.27*g/cm3, ncomponents=1,
kStateSolid, 293*kelvin, 1*atmosphere);
graphite->AddElement(elC, natoms=1);
///G4cout << *(G4Material::GetMaterialTable()) << G4endl;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4Material* DetectorConstruction::MaterialWithSingleIsotope( G4String name,
G4String symbol, G4double density, G4int Z, G4int A)
{
// define a material from an isotope
//
G4int ncomponents;
G4double abundance, massfraction;
G4Isotope* isotope = new G4Isotope(symbol, Z, A);
G4Element* element = new G4Element(name, symbol, ncomponents=1);
element->AddIsotope(isotope, abundance= 100.*perCent);
G4Material* material = new G4Material(name, density, ncomponents=1);
material->AddElement(element, massfraction=100.*perCent);
return material;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4VPhysicalVolume* DetectorConstruction::ConstructVolumes()
{
// Cleanup old geometry
G4GeometryManager::GetInstance()->OpenGeometry();
G4PhysicalVolumeStore::GetInstance()->Clean();
G4LogicalVolumeStore::GetInstance()->Clean();
G4SolidStore::GetInstance()->Clean();
G4Box*
sBox = new G4Box("Container", //its name
fBoxSize/2,fBoxSize/2,fBoxSize/2); //its dimensions
fLBox = new G4LogicalVolume(sBox, //its shape
fMaterial, //its material
fMaterial->GetName()); //its name
fPBox = new G4PVPlacement(0, //no rotation
G4ThreeVector(), //at (0,0,0)
fLBox, //its logical volume
fMaterial->GetName(), //its name
0, //its mother volume
false, //no boolean operation
0); //copy number
PrintParameters();
//always return the root volume
//
return fPBox;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void DetectorConstruction::PrintParameters()
{
G4cout << "\n The Box is " << G4BestUnit(fBoxSize,"Length")
<< " of " << fMaterial->GetName()
<< "\n \n" << fMaterial << G4endl;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void DetectorConstruction::SetMaterial(G4String materialChoice)
{
// search the material by its name
G4Material* pttoMaterial =
G4NistManager::Instance()->FindOrBuildMaterial(materialChoice);
if (pttoMaterial) {
if(fMaterial != pttoMaterial) {
fMaterial = pttoMaterial;
if(fLBox) { fLBox->SetMaterial(pttoMaterial); }
G4RunManager::GetRunManager()->PhysicsHasBeenModified();
}
} else {
G4cout << "\n--> warning from DetectorConstruction::SetMaterial : "
<< materialChoice << " not found" << G4endl;
}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void DetectorConstruction::SetSize(G4double value)
{
fBoxSize = value;
G4RunManager::GetRunManager()->ReinitializeGeometry();
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -0,0 +1,135 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
/// \file hadronic/Hadr03/src/DetectorMessenger.cc
/// \brief Implementation of the DetectorMessenger class
//
// $Id: DetectorMessenger.cc 70755 2013-06-05 12:17:48Z ihrivnac $
//
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
#include "DetectorMessenger.hh"
#include "DetectorConstruction.hh"
#include "G4UIdirectory.hh"
#include "G4UIcommand.hh"
#include "G4UIparameter.hh"
#include "G4UIcmdWithAString.hh"
#include "G4UIcmdWithADoubleAndUnit.hh"
#include "G4UIcmdWithoutParameter.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
DetectorMessenger::DetectorMessenger(DetectorConstruction * Det)
:G4UImessenger(),
fDetector(Det), fTestemDir(0), fDetDir(0), fMaterCmd(0), fSizeCmd(0),
fIsotopeCmd(0)
{
fTestemDir = new G4UIdirectory("/testhadr/");
fTestemDir->SetGuidance("commands specific to this example");
G4bool broadcast = false;
fDetDir = new G4UIdirectory("/testhadr/det/",broadcast);
fDetDir->SetGuidance("detector construction commands");
fMaterCmd = new G4UIcmdWithAString("/testhadr/det/setMat",this);
fMaterCmd->SetGuidance("Select material of the box.");
fMaterCmd->SetParameterName("choice",false);
fMaterCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
fSizeCmd = new G4UIcmdWithADoubleAndUnit("/testhadr/det/setSize",this);
fSizeCmd->SetGuidance("Set size of the box");
fSizeCmd->SetParameterName("Size",false);
fSizeCmd->SetRange("Size>0.");
fSizeCmd->SetUnitCategory("Length");
fSizeCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
fIsotopeCmd = new G4UIcommand("/testhadr/det/setIsotopeMat",this);
fIsotopeCmd->SetGuidance("Build and select a material with single isotope");
fIsotopeCmd->SetGuidance(" symbol of isotope, Z, A, density of material");
//
G4UIparameter* symbPrm = new G4UIparameter("isotope",'s',false);
symbPrm->SetGuidance("isotope symbol");
fIsotopeCmd->SetParameter(symbPrm);
//
G4UIparameter* ZPrm = new G4UIparameter("Z",'i',false);
ZPrm->SetGuidance("Z");
ZPrm->SetParameterRange("Z>0");
fIsotopeCmd->SetParameter(ZPrm);
//
G4UIparameter* APrm = new G4UIparameter("A",'i',false);
APrm->SetGuidance("A");
APrm->SetParameterRange("A>0");
fIsotopeCmd->SetParameter(APrm);
//
G4UIparameter* densityPrm = new G4UIparameter("density",'d',false);
densityPrm->SetGuidance("density of material");
densityPrm->SetParameterRange("density>0.");
fIsotopeCmd->SetParameter(densityPrm);
//
G4UIparameter* unitPrm = new G4UIparameter("unit",'s',false);
unitPrm->SetGuidance("unit of density");
G4String unitList = G4UIcommand::UnitsList(G4UIcommand::CategoryOf("g/cm3"));
unitPrm->SetParameterCandidates(unitList);
fIsotopeCmd->SetParameter(unitPrm);
//
fIsotopeCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
DetectorMessenger::~DetectorMessenger()
{
delete fMaterCmd;
delete fSizeCmd;
delete fIsotopeCmd;
delete fDetDir;
delete fTestemDir;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void DetectorMessenger::SetNewValue(G4UIcommand* command,G4String newValue)
{
if( command == fMaterCmd )
{ fDetector->SetMaterial(newValue);}
if( command == fSizeCmd )
{ fDetector->SetSize(fSizeCmd->GetNewDoubleValue(newValue));}
if (command == fIsotopeCmd)
{
G4int Z; G4int A; G4double dens;
G4String name, unt;
std::istringstream is(newValue);
is >> name >> Z >> A >> dens >> unt;
dens *= G4UIcommand::ValueOf(unt);
fDetector->MaterialWithSingleIsotope (name,name,dens,Z,A);
fDetector->SetMaterial(name);
}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -0,0 +1,91 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
/// \file hadronic/Hadr03/src/HistoManager.cc
/// \brief Implementation of the HistoManager class
//
// $Id: HistoManager.cc 67909 2013-03-12 18:51:09Z vnivanch $
//
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
#include "HistoManager.hh"
#include "G4UnitsTable.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
HistoManager::HistoManager()
: fFileName("Hadr04")
{
Book();
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
HistoManager::~HistoManager()
{
delete G4AnalysisManager::Instance();
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void HistoManager::Book()
{
// Create or get analysis manager
// The choice of analysis technology is done via selection of a namespace
// in HistoManager.hh
G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
analysisManager->SetFileName(fFileName);
analysisManager->SetVerboseLevel(1);
analysisManager->SetActivation(true); //enable inactivation of histograms
// Define histograms start values
const G4int kMaxHisto = 8;
const G4String id[] = {"0","1","2","3","4","5","6","7"};
const G4String title[] =
{ "dummy", //0
"incident neutron: nb of collisions above 1 eV", //1
"incident neutron: total track length above 1 eV", //2
"incident neutron: time of flight above 1 eV", //3
"incident neutron: nb of collisions below 1 eV", //4
"incident neutron: total track length below 1*eV", //5
"incident neutron: time of flight below 1 eV", //6
"incident neutron: energy distribution below 1*eV" //7
};
// Default values (to be reset via /analysis/h1/set command)
G4int nbins = 100;
G4double vmin = 0.;
G4double vmax = 100.;
// Create all histograms as inactivated
// as we have not yet set nbins, vmin, vmax
for (G4int k=0; k<kMaxHisto; k++) {
G4int ih = analysisManager->CreateH1(id[k], title[k], nbins, vmin, vmax);
analysisManager->SetH1Activation(ih, false);
}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -0,0 +1,72 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
/// \file electromagnetic/TestEm12/src/NeutronHPMessenger.cc
/// \brief Implementation of the NeutronHPMessenger class
//
// $Id: NeutronHPMessenger.cc 67268 2013-02-13 11:38:40Z ihrivnac $
//
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
#include "NeutronHPMessenger.hh"
#include "NeutronHPphysics.hh"
#include "G4UIdirectory.hh"
#include "G4UIcmdWithABool.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
NeutronHPMessenger::NeutronHPMessenger(NeutronHPphysics* phys)
:G4UImessenger(),fNeutronPhysics(phys),
fPhysDir(0), fThermalCmd(0)
{
fPhysDir = new G4UIdirectory("/testhadr/phys/");
fPhysDir->SetGuidance("physics list commands");
fThermalCmd = new G4UIcmdWithABool("/testhadr/phys/thermalScattering",this);
fThermalCmd->SetGuidance("set thermal scattering model");
fThermalCmd->SetParameterName("thermal",false);
fThermalCmd->AvailableForStates(G4State_PreInit);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
NeutronHPMessenger::~NeutronHPMessenger()
{
delete fThermalCmd;
delete fPhysDir;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void NeutronHPMessenger::SetNewValue(G4UIcommand* command, G4String newValue)
{
if (command == fThermalCmd)
{fNeutronPhysics->SetThermalPhysics(fThermalCmd->GetNewBoolValue(newValue));}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -0,0 +1,143 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
/// \file hadronic/Hadr04/src/NeutronHPphysics.cc
/// \brief Implementation of the NeutronHPphysics class
//
// $Id: NeutronHPphysics.cc 66587 2012-12-21 11:06:44Z ihrivnac $
//
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
#include "NeutronHPphysics.hh"
#include "NeutronHPMessenger.hh"
#include "G4ParticleDefinition.hh"
#include "G4ProcessManager.hh"
// Processes
#include "G4HadronElasticProcess.hh"
#include "G4NeutronHPElasticData.hh"
#include "G4NeutronHPThermalScatteringData.hh"
#include "G4NeutronHPElastic.hh"
#include "G4NeutronHPThermalScattering.hh"
#include "G4NeutronInelasticProcess.hh"
#include "G4NeutronHPInelasticData.hh"
#include "G4NeutronHPInelastic.hh"
#include "G4HadronCaptureProcess.hh"
#include "G4NeutronHPCaptureData.hh"
#include "G4NeutronHPCapture.hh"
#include "G4HadronFissionProcess.hh"
#include "G4NeutronHPFissionData.hh"
#include "G4NeutronHPFission.hh"
#include "G4SystemOfUnits.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
NeutronHPphysics::NeutronHPphysics(const G4String& name)
: G4VPhysicsConstructor(name), fThermal(true), fNeutronMessenger(0)
{
fNeutronMessenger = new NeutronHPMessenger(this);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
NeutronHPphysics::~NeutronHPphysics()
{
delete fNeutronMessenger;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void NeutronHPphysics::ConstructProcess()
{
G4ProcessManager* pManager = G4Neutron::Neutron()->GetProcessManager();
// process: elastic
//
G4HadronElasticProcess* process1 = new G4HadronElasticProcess();
pManager->AddDiscreteProcess(process1);
//
// cross section data set
G4NeutronHPElasticData* dataSet1a = new G4NeutronHPElasticData();
G4NeutronHPThermalScatteringData* dataSet1b
= new G4NeutronHPThermalScatteringData();
process1->AddDataSet(dataSet1a);
if (fThermal) process1->AddDataSet(dataSet1b);
//
// models
G4NeutronHPElastic* model1a = new G4NeutronHPElastic();
G4NeutronHPThermalScattering* model1b = new G4NeutronHPThermalScattering();
if (fThermal) model1a->SetMinEnergy(4*eV);
process1->RegisterMe(model1a);
if (fThermal) process1->RegisterMe(model1b);
// process: inelastic
//
G4NeutronInelasticProcess* process2 = new G4NeutronInelasticProcess();
pManager->AddDiscreteProcess(process2);
//
// cross section data set
G4NeutronHPInelasticData* dataSet2 = new G4NeutronHPInelasticData();
process2->AddDataSet(dataSet2);
//
// models
G4NeutronHPInelastic* model2 = new G4NeutronHPInelastic();
process2->RegisterMe(model2);
// process: nCapture
//
G4HadronCaptureProcess* process3 = new G4HadronCaptureProcess();
pManager->AddDiscreteProcess(process3);
//
// cross section data set
G4NeutronHPCaptureData* dataSet3 = new G4NeutronHPCaptureData();
process3->AddDataSet(dataSet3);
//
// models
G4NeutronHPCapture* model3 = new G4NeutronHPCapture();
process3->RegisterMe(model3);
// process: nFission
//
G4HadronFissionProcess* process4 = new G4HadronFissionProcess();
pManager->AddDiscreteProcess(process4);
//
// cross section data set
G4NeutronHPFissionData* dataSet4 = new G4NeutronHPFissionData();
process4->AddDataSet(dataSet4);
//
// models
G4NeutronHPFission* model4 = new G4NeutronHPFission();
process4->RegisterMe(model4);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -0,0 +1,101 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
/// \file hadronic/Hadr03/src/PhysicsList.cc
/// \brief Implementation of the PhysicsList class
//
// $Id: PhysicsList.cc 70268 2013-05-28 14:17:50Z maire $
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
#include "PhysicsList.hh"
#include "G4SystemOfUnits.hh"
#include "G4UnitsTable.hh"
#include "NeutronHPphysics.hh"
// particles
#include "G4BosonConstructor.hh"
#include "G4LeptonConstructor.hh"
#include "G4MesonConstructor.hh"
#include "G4BosonConstructor.hh"
#include "G4BaryonConstructor.hh"
#include "G4IonConstructor.hh"
#include "G4ShortLivedConstructor.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
PhysicsList::PhysicsList()
:G4VModularPhysicsList()
{
SetVerboseLevel(1);
//add new units
//
new G4UnitDefinition( "millielectronVolt", "meV", "Energy", 1.e-3*eV);
new G4UnitDefinition( "mm2/g", "mm2/g", "Surface/Mass", mm2/g);
new G4UnitDefinition( "um2/mg", "um2/mg","Surface/Mass", um*um/mg);
// Neutron Physics
RegisterPhysics( new NeutronHPphysics("neutronHP"));
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
PhysicsList::~PhysicsList()
{ }
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void PhysicsList::ConstructParticle()
{
G4BosonConstructor pBosonConstructor;
pBosonConstructor.ConstructParticle();
G4LeptonConstructor pLeptonConstructor;
pLeptonConstructor.ConstructParticle();
G4MesonConstructor pMesonConstructor;
pMesonConstructor.ConstructParticle();
G4BaryonConstructor pBaryonConstructor;
pBaryonConstructor.ConstructParticle();
G4IonConstructor pIonConstructor;
pIonConstructor.ConstructParticle();
G4ShortLivedConstructor pShortLivedConstructor;
pShortLivedConstructor.ConstructParticle();
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void PhysicsList::SetCuts()
{
SetCutValue(0*mm, "proton");
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -0,0 +1,92 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
/// \file electromagnetic/TestEm4/src/PrimaryGeneratorAction.cc
/// \brief Implementation of the PrimaryGeneratorAction class
//
//
// $Id: PrimaryGeneratorAction.cc 67268 2013-02-13 11:38:40Z ihrivnac $
//
//
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
#include "PrimaryGeneratorAction.hh"
#include "G4Event.hh"
#include "G4ParticleTable.hh"
#include "G4ParticleDefinition.hh"
#include "G4PhysicalConstants.hh"
#include "G4SystemOfUnits.hh"
#include "Randomize.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
PrimaryGeneratorAction::PrimaryGeneratorAction()
: G4VUserPrimaryGeneratorAction(),fParticleGun(0)
{
G4int n_particle = 1;
fParticleGun = new G4ParticleGun(n_particle);
// default particle kinematic
G4ParticleDefinition* particle
= G4ParticleTable::GetParticleTable()->FindParticle("neutron");
fParticleGun->SetParticleDefinition(particle);
fParticleGun->SetParticleMomentumDirection(G4ThreeVector(1.,0.,0.));
fParticleGun->SetParticleEnergy(2*MeV);
fParticleGun->SetParticlePosition(G4ThreeVector(0.*cm,0.*cm,0.*cm));
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
PrimaryGeneratorAction::~PrimaryGeneratorAction()
{
delete fParticleGun;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void PrimaryGeneratorAction::GeneratePrimaries(G4Event* anEvent)
{
//this function is called at the begining of event
//
//distribution uniform in solid angle
//
G4double cosTheta = 2*G4UniformRand() - 1., phi = twopi*G4UniformRand();
G4double sinTheta = std::sqrt(1. - cosTheta*cosTheta);
G4double ux = sinTheta*std::cos(phi),
uy = sinTheta*std::sin(phi),
uz = cosTheta;
fParticleGun->SetParticleMomentumDirection(G4ThreeVector(ux,uy,uz));
fParticleGun->GeneratePrimaryVertex(anEvent);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -0,0 +1,240 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
/// \file electromagnetic/TestEm11/src/Run.cc
/// \brief Implementation of the Run class
//
// $Id: Run.cc 71376 2013-06-14 07:44:50Z maire $
//
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
#include "Run.hh"
#include "DetectorConstruction.hh"
#include "G4UnitsTable.hh"
#include "G4SystemOfUnits.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
Run::Run(DetectorConstruction* det)
: G4Run(),
fDetector(det),
fNbStep1(0), fNbStep2(0),
fTrackLen1(0.), fTrackLen2(0.),
fTime1(0.),fTime2(0.)
{ }
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
Run::~Run()
{ }
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void Run::CountProcesses(const G4VProcess* process)
{
std::map<const G4VProcess*,G4int>::iterator it = fProcCounter.find(process);
if ( it == fProcCounter.end()) {
fProcCounter[process] = 1;
}
else {
fProcCounter[process]++;
}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void Run::ParticleCount(G4String name, G4double Ekin)
{
std::map<G4String, ParticleData>::iterator it = fParticleDataMap.find(name);
if ( it == fParticleDataMap.end()) {
fParticleDataMap[name] = ParticleData(1, Ekin, Ekin, Ekin);
}
else {
ParticleData& data = it->second;
data.fCount++;
data.fEmean += Ekin;
//update min max
G4double emin = data.fEmin;
if (Ekin < emin) data.fEmin = Ekin;
G4double emax = data.fEmax;
if (Ekin > emax) data.fEmax = Ekin;
}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void Run::SumTrackLength(G4int nstep1, G4int nstep2,
G4double trackl1, G4double trackl2,
G4double time1, G4double time2)
{
fNbStep1 += nstep1; fNbStep2 += nstep2;
fTrackLen1 += trackl1; fTrackLen2 += trackl2;
fTime1 += time1; fTime2 += time2;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void Run::ComputeStatistics()
{
G4int prec = 5, wid = prec + 2;
G4int dfprec = G4cout.precision(prec);
//frequency of processes
//
G4cout << "\n Process calls frequency --->";
G4int survive = 0;
std::map<const G4VProcess*,G4int>::iterator it;
for (it = fProcCounter.begin(); it != fProcCounter.end(); it++) {
G4String procName = it->first->GetProcessName();
G4int count = it->second;
G4cout << "\t" << procName << "= " << count;
if (procName == "Transportation") survive = count;
}
G4cout << G4endl;
if (survive > 0) {
G4cout << "\n Nb of incident particles surviving after "
<< G4BestUnit(0.5*(fDetector->GetSize()),"Length") << " of "
<< fDetector->GetMaterial()->GetName() << " : " << survive << G4endl;
}
// total track length of incident neutron
//
G4cout << "\n Parcours of incident neutron:";
G4double meanCollision1 = (G4double)fNbStep1/numberOfEvent;
G4double meanCollision2 = (G4double)fNbStep2/numberOfEvent;
G4double meanCollisTota = meanCollision1 + meanCollision2;
G4cout << "\n nb of collisions E>1*eV= " << meanCollision1
<< " E<1*eV= " << meanCollision2
<< " total= " << meanCollisTota;
G4double meanTrackLen1 = fTrackLen1/numberOfEvent;
G4double meanTrackLen2 = fTrackLen2/numberOfEvent;
G4double meanTrackLtot = meanTrackLen1 + meanTrackLen2;
G4cout
<< "\n track length E>1*eV= " << G4BestUnit(meanTrackLen1,"Length")
<< " E<1*eV= " << G4BestUnit(meanTrackLen2, "Length")
<< " total= " << G4BestUnit(meanTrackLtot, "Length");
G4double meanTime1 = fTime1/numberOfEvent;
G4double meanTime2 = fTime2/numberOfEvent;
G4double meanTimeTo = meanTime1 + meanTime2;
G4cout
<< "\n time of flight E>1*eV= " << G4BestUnit(meanTime1,"Time")
<< " E<1*eV= " << G4BestUnit(meanTime2, "Time")
<< " total= " << G4BestUnit(meanTimeTo, "Time") << G4endl;
//particles count
//
G4cout << "\n List of generated particles:" << G4endl;
std::map<G4String,ParticleData>::iterator itn;
for (itn = fParticleDataMap.begin(); itn != fParticleDataMap.end(); itn++) {
G4String name = itn->first;
ParticleData data = itn->second;
G4int count = data.fCount;
G4double eMean = data.fEmean/count;
G4double eMin = data.fEmin;
G4double eMax = data.fEmax;
G4cout << " " << std::setw(13) << name << ": " << std::setw(7) << count
<< " Emean = " << std::setw(wid) << G4BestUnit(eMean, "Energy")
<< "\t( " << G4BestUnit(eMin, "Energy")
<< " --> " << G4BestUnit(eMax, "Energy")
<< ")" << G4endl;
}
//restore default format
G4cout.precision(dfprec);
// remove all contents in fProcCounter
fProcCounter.clear();
// remove all contents in fCount
fParticleDataMap.clear();
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void Run::Merge(const G4Run* run)
{
const Run* localRun = static_cast<const Run*>(run);
// accumulate sums
//
fNbStep1 += localRun->fNbStep1;
fNbStep2 += localRun->fNbStep2;
fTrackLen1 += localRun->fTrackLen1;
fTrackLen2 += localRun->fTrackLen2;
fTime1 += localRun->fTime1;
fTime2 += localRun->fTime2;
//maps
std::map<const G4VProcess*,G4int>::const_iterator itp;
for ( itp = localRun->fProcCounter.begin();
itp != localRun->fProcCounter.end(); ++itp ) {
const G4VProcess* process = itp->first;
G4int localCount = itp->second;
if ( fProcCounter.find(process) == fProcCounter.end()) {
fProcCounter[process] = localCount;
}
else {
fProcCounter[process] += localCount;
}
}
std::map<G4String,ParticleData>::const_iterator itn;
for (itn = localRun->fParticleDataMap.begin();
itn != localRun->fParticleDataMap.end(); ++itn) {
G4String name = itn->first;
const ParticleData& localData = itn->second;
if ( fParticleDataMap.find(name) == fParticleDataMap.end()) {
fParticleDataMap[name]
= ParticleData(localData.fCount,
localData.fEmean,
localData.fEmin,
localData.fEmax);
}
else {
ParticleData& data = fParticleDataMap[name];
data.fCount += localData.fCount;
data.fEmean += localData.fEmean;
G4double emin = localData.fEmin;
if (emin < data.fEmin) data.fEmin = emin;
G4double emax = localData.fEmax;
if (emax > data.fEmax) data.fEmax = emax;
}
}
G4Run::Merge(run);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -0,0 +1,135 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
/// \file hadronic/Hadr03/src/RunAction.cc
/// \brief Implementation of the RunAction class
//
// $Id: RunAction.cc 70756 2013-06-05 12:20:06Z ihrivnac $
//
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
#include "RunAction.hh"
#include "DetectorConstruction.hh"
#include "PrimaryGeneratorAction.hh"
#include "HistoManager.hh"
#include "Run.hh"
#include "G4Run.hh"
#include "G4RunManager.hh"
#include "G4UnitsTable.hh"
#include "G4SystemOfUnits.hh"
#include "Randomize.hh"
#include <iomanip>
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
RunAction::RunAction(DetectorConstruction* det, PrimaryGeneratorAction* prim)
: G4UserRunAction(),
fDetector(det), fPrimary(prim), fRun(0), fHistoManager(0)
{
// Book predefined histograms
fHistoManager = new HistoManager();
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
RunAction::~RunAction()
{
delete fHistoManager;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4Run* RunAction::GenerateRun()
{
fRun = new Run(fDetector);
return fRun;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void RunAction::BeginOfRunAction(const G4Run*)
{
// save Rndm status
G4RunManager::GetRunManager()->SetRandomNumberStore(false);
G4Random::showEngineStatus();
//histograms
//
G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
if ( analysisManager->IsActive() ) {
analysisManager->OpenFile();
}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void RunAction::EndOfRunAction(const G4Run* aRun)
{
G4int nbOfEvents = aRun->GetNumberOfEvent();
if ( fPrimary && nbOfEvents ) {
G4int prec = 5;
G4int dfprec = G4cout.precision(prec);
G4Material* material = fDetector->GetMaterial();
G4double density = material->GetDensity();
G4ParticleDefinition* particle =
fPrimary->GetParticleGun()->GetParticleDefinition();
G4String Particle = particle->GetParticleName();
G4double energy = fPrimary->GetParticleGun()->GetParticleEnergy();
G4cout << "\n The run is of " << nbOfEvents << " "<< Particle << " of "
<< G4BestUnit(energy,"Energy") << " through "
<< G4BestUnit(fDetector->GetSize(),"Length") << " of "
<< material->GetName() << " (density: "
<< G4BestUnit(density,"Volumic Mass") << ")" << G4endl;
//restore default format
G4cout.precision(dfprec);
}
//compute and print statistics
//
if (isMaster) fRun->ComputeStatistics();
//save histograms
G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
////G4double factor = 1./nbOfEvents;
////analysisManager->ScaleH1(3,factor);
if ( analysisManager->IsActive() ) {
analysisManager->Write();
analysisManager->CloseFile();
}
// show Rndm status
G4Random::showEngineStatus();
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -0,0 +1,70 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
/// \file electromagnetic/TestEm5/src/StackingAction.cc
/// \brief Implementation of the StackingAction class
//
// $Id: StackingAction.cc 67268 2013-02-13 11:38:40Z ihrivnac $
//
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
#include "StackingAction.hh"
#include "Run.hh"
#include "G4RunManager.hh"
#include "G4Track.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
StackingAction::StackingAction()
:G4UserStackingAction()
{ }
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
StackingAction::~StackingAction()
{ }
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4ClassificationOfNewTrack
StackingAction::ClassifyNewTrack(const G4Track* aTrack)
{
//keep primary particle
if (aTrack->GetParentID() == 0) return fUrgent;
//count secondary particles
G4String name = aTrack->GetDefinition()->GetParticleName();
G4double energy = aTrack->GetKineticEnergy();
Run* run = static_cast<Run*>(
G4RunManager::GetRunManager()->GetNonConstCurrentRun());
run->ParticleCount(name,energy);
//kill all secondaries
return fKill;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -0,0 +1,77 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
/// \file hadronic/Hadr03/src/SteppingAction.cc
/// \brief Implementation of the SteppingAction class
//
// $Id: SteppingAction.cc 71404 2013-06-14 16:56:38Z maire $
//
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
#include "SteppingAction.hh"
#include "Run.hh"
#include "TrackingAction.hh"
#include "HistoManager.hh"
#include "G4RunManager.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
SteppingAction::SteppingAction(TrackingAction* TrAct)
: G4UserSteppingAction(),fTrackingAction(TrAct)
{ }
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
SteppingAction::~SteppingAction()
{ }
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void SteppingAction::UserSteppingAction(const G4Step* aStep)
{
// count processes
//
const G4StepPoint* endPoint = aStep->GetPostStepPoint();
const G4VProcess* process = endPoint->GetProcessDefinedStep();
Run* run = static_cast<Run*>(
G4RunManager::GetRunManager()->GetNonConstCurrentRun());
run->CountProcesses(process);
// incident neutron
//
if (aStep->GetTrack()->GetTrackID() == 1) {
G4double ekin = endPoint->GetKineticEnergy();
G4double trackl = aStep->GetTrack()->GetTrackLength();
G4double time = aStep->GetTrack()->GetLocalTime();
fTrackingAction->UpdateTrackInfo(ekin,trackl,time);
G4AnalysisManager::Instance()->FillH1(7,ekin);
}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -0,0 +1,158 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
/// \file radioactivedecay/rdecay01/src/SteppingVerbose.cc
/// \brief Implementation of the SteppingVerbose class
//
//
// $Id: SteppingVerbose.cc 71654 2013-06-19 18:20:04Z maire $
//
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
#include "SteppingVerbose.hh"
#include "G4SteppingManager.hh"
#include "G4ParticleTypes.hh"
#include "G4UnitsTable.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
SteppingVerbose::SteppingVerbose()
: G4SteppingVerbose()
{ }
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
SteppingVerbose::~SteppingVerbose()
{}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void SteppingVerbose::TrackingStarted()
{
CopyState();
G4int prec = G4cout.precision(3);
//Step zero
//
if( verboseLevel > 0 ){
G4cout << std::setw( 5) << "Step#" << " "
<< std::setw( 6) << "X" << " "
<< std::setw( 6) << "Y" << " "
<< std::setw( 6) << "Z" << " "
<< std::setw( 9) << "KineE" << " "
<< std::setw( 9) << "dEStep" << " "
<< std::setw(10) << "StepLeng"
<< std::setw(10) << "TrakLeng"
<< std::setw(10) << "Volume" << " "
<< std::setw(10) << "Process" << G4endl;
G4cout << std::setw(5) << fTrack->GetCurrentStepNumber() << " "
<< std::setw(6) << G4BestUnit(fTrack->GetPosition().x(),"Length")
<< std::setw(6) << G4BestUnit(fTrack->GetPosition().y(),"Length")
<< std::setw(6) << G4BestUnit(fTrack->GetPosition().z(),"Length")
<< std::setw(6) << G4BestUnit(fTrack->GetKineticEnergy(),"Energy")
<< std::setw(6) << G4BestUnit(fStep->GetTotalEnergyDeposit(),"Energy")
<< std::setw(6) << G4BestUnit(fStep->GetStepLength(),"Length")
<< std::setw(6) << G4BestUnit(fTrack->GetTrackLength(),"Length")
<< std::setw(10) << fTrack->GetVolume()->GetName()
<< " initStep" << G4endl;
}
G4cout.precision(prec);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void SteppingVerbose::StepInfo()
{
CopyState();
G4int prec = G4cout.precision(3);
if( verboseLevel >= 1 ){
if( verboseLevel >= 4 ) VerboseTrack();
if( verboseLevel >= 3 ){
G4cout << G4endl;
G4cout << std::setw( 5) << "#Step#" << " "
<< std::setw( 6) << "X" << " "
<< std::setw( 6) << "Y" << " "
<< std::setw( 6) << "Z" << " "
<< std::setw( 9) << "KineE" << " "
<< std::setw( 9) << "dEStep" << " "
<< std::setw(10) << "StepLeng"
<< std::setw(10) << "TrakLeng"
<< std::setw(10) << "Volume" << " "
<< std::setw(10) << "Process" << G4endl;
}
G4cout << std::setw( 5) << fTrack->GetCurrentStepNumber() << " "
<< std::setw(6) << G4BestUnit(fTrack->GetPosition().x(),"Length")
<< std::setw(6) << G4BestUnit(fTrack->GetPosition().y(),"Length")
<< std::setw(6) << G4BestUnit(fTrack->GetPosition().z(),"Length")
<< std::setw(6) << G4BestUnit(fTrack->GetKineticEnergy(),"Energy")
<< std::setw(6) << G4BestUnit(fStep->GetTotalEnergyDeposit(),"Energy")
<< std::setw(6) << G4BestUnit(fStep->GetStepLength(),"Length")
<< std::setw(6) << G4BestUnit(fTrack->GetTrackLength(),"Length")
<< std::setw(10) << fTrack->GetVolume()->GetName();
const G4VProcess* process
= fStep->GetPostStepPoint()->GetProcessDefinedStep();
G4String procName = " UserLimit";
if (process) procName = process->GetProcessName();
if (fStepStatus == fWorldBoundary) procName = "OutOfWorld";
G4cout << " " << std::setw(10) << procName;
G4cout << G4endl;
if (verboseLevel == 2) {
const std::vector<const G4Track*>* secondary
= fStep->GetSecondaryInCurrentStep();
size_t nbtrk = (*secondary).size();
if (nbtrk) {
G4cout << "\n :----- List of secondaries ----------------" << G4endl;
G4cout.precision(4);
for (size_t lp=0; lp<(*secondary).size(); lp++) {
G4cout << " "
<< std::setw(13)
<< (*secondary)[lp]->GetDefinition()->GetParticleName()
<< ": energy ="
<< std::setw(6)
<< G4BestUnit((*secondary)[lp]->GetKineticEnergy(),"Energy")
<< " time ="
<< std::setw(6)
<< G4BestUnit((*secondary)[lp]->GetGlobalTime(),"Time");
G4cout << G4endl;
}
G4cout << " :------------------------------------------\n" << G4endl;
}
}
}
G4cout.precision(prec);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -0,0 +1,98 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
/// \file electromagnetic/TestEm12/src/TrackingAction.cc
/// \brief Implementation of the TrackingAction class
//
// $Id: TrackingAction.cc 69099 2013-04-18 12:25:19Z maire $
//
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
#include "TrackingAction.hh"
#include "Run.hh"
#include "HistoManager.hh"
#include "G4RunManager.hh"
#include "G4Track.hh"
#include "G4SystemOfUnits.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
TrackingAction::TrackingAction()
:G4UserTrackingAction(),
fNbStep1(0),fNbStep2(0),fTrackLen1(0.),fTrackLen2(0.),fTime1(0.),fTime2(0.)
{ }
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void TrackingAction::PreUserTrackingAction(const G4Track*)
{
fNbStep1 = fNbStep2 = 0;
fTrackLen1 = fTrackLen2 = 0.;
fTime1 = fTime2 = 0.;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void TrackingAction::UpdateTrackInfo(G4double ekin,G4double trackl,
G4double time)
{
const G4double thermal = 1*eV;
if (ekin > thermal) {
fNbStep1++; fTrackLen1 = trackl; fTime1 = time;
} else {
fNbStep2++; fTrackLen2 = trackl - fTrackLen1; fTime2 = time - fTime1;
}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void TrackingAction::PostUserTrackingAction(const G4Track* track)
{
// keep only primary neutron
//
G4int trackID = track->GetTrackID();
if (trackID > 1) return;
Run* run
= static_cast<Run*>(
G4RunManager::GetRunManager()->GetNonConstCurrentRun());
run->SumTrackLength(fNbStep1,fNbStep2,fTrackLen1,fTrackLen2,fTime1,fTime2);
// histograms
//
G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
analysisManager->FillH1(1,fNbStep1);
analysisManager->FillH1(2,fTrackLen1);
analysisManager->FillH1(3,fTime1);
analysisManager->FillH1(4,fNbStep2);
analysisManager->FillH1(5,fTrackLen2);
analysisManager->FillH1(6,fTime2);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......