Import Geant4 9.2.0 source tree
This commit is contained in:
@@ -23,8 +23,8 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// $Id: DetectorConstruction.cc,v 1.8 2007/01/11 15:41:46 vnivanch Exp $
|
||||
// GEANT4 tag $Name: geant4-09-01 $
|
||||
// $Id: DetectorConstruction.cc,v 1.10 2008/04/21 13:13:30 vnivanch Exp $
|
||||
// GEANT4 tag $Name: geant4-09-02 $
|
||||
//
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
@@ -44,9 +44,12 @@
|
||||
#include "G4SolidStore.hh"
|
||||
|
||||
#include "G4NistManager.hh"
|
||||
|
||||
#include "G4UnitsTable.hh"
|
||||
|
||||
#include "G4FieldManager.hh"
|
||||
#include "G4TransportationManager.hh"
|
||||
#include "G4RunManager.hh"
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
DetectorConstruction::DetectorConstruction()
|
||||
@@ -117,6 +120,13 @@ void DetectorConstruction::DefineMaterials()
|
||||
Air->AddElement(N, fractionmass=0.7);
|
||||
Air->AddElement(O, fractionmass=0.3);
|
||||
|
||||
density = 1.e-5*g/cm3;
|
||||
pressure = 2.e-2*bar;
|
||||
temperature = STP_Temperature; // From PhysicalConstants.h .
|
||||
G4Material* vac = new G4Material( "TechVacuum", density, 1,
|
||||
kStateGas, temperature, pressure );
|
||||
vac->AddMaterial( Air, 1. );
|
||||
|
||||
density = universe_mean_density; //from PhysicalConstants.h
|
||||
pressure = 3.e-18*pascal;
|
||||
temperature = 2.73*kelvin;
|
||||
@@ -234,6 +244,7 @@ void DetectorConstruction::PrintParameters()
|
||||
void DetectorConstruction::SetSizeX(G4double value)
|
||||
{
|
||||
absorSizeX = value; worldSizeX = 1.2*absorSizeX;
|
||||
G4RunManager::GetRunManager()->GeometryHasBeenModified();
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
@@ -242,6 +253,7 @@ void DetectorConstruction::SetSizeYZ(G4double value)
|
||||
{
|
||||
absorSizeYZ = value;
|
||||
worldSizeYZ = 1.2*absorSizeYZ;
|
||||
G4RunManager::GetRunManager()->GeometryHasBeenModified();
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
@@ -251,14 +263,17 @@ void DetectorConstruction::SetMaterial(G4String materialChoice)
|
||||
// search the material by its name
|
||||
G4Material* pttoMaterial =
|
||||
G4NistManager::Instance()->FindOrBuildMaterial(materialChoice);
|
||||
if (pttoMaterial) absorMaterial = pttoMaterial;
|
||||
if (pttoMaterial) {
|
||||
absorMaterial = pttoMaterial;
|
||||
if(lAbsor) {
|
||||
lAbsor->SetMaterial(absorMaterial);
|
||||
G4RunManager::GetRunManager()->PhysicsHasBeenModified();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
#include "G4FieldManager.hh"
|
||||
#include "G4TransportationManager.hh"
|
||||
|
||||
void DetectorConstruction::SetMagField(G4double fieldValue)
|
||||
{
|
||||
//apply a global uniform magnetic field along Z axis
|
||||
@@ -284,6 +299,7 @@ void DetectorConstruction::SetMagField(G4double fieldValue)
|
||||
void DetectorConstruction::SetTallySize(G4ThreeVector value)
|
||||
{
|
||||
tallySize = value;
|
||||
G4RunManager::GetRunManager()->GeometryHasBeenModified();
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
@@ -293,7 +309,13 @@ void DetectorConstruction::SetTallyMaterial(G4String materialChoice)
|
||||
// search the material by its name
|
||||
G4Material* pttoMaterial =
|
||||
G4NistManager::Instance()->FindOrBuildMaterial(materialChoice);
|
||||
if (pttoMaterial) tallyMaterial = pttoMaterial;
|
||||
if (pttoMaterial) {
|
||||
tallyMaterial = pttoMaterial;
|
||||
if(lTally) {
|
||||
lTally->SetMaterial(tallyMaterial);
|
||||
G4RunManager::GetRunManager()->PhysicsHasBeenModified();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
@@ -304,15 +326,15 @@ void DetectorConstruction::SetTallyPosition(G4ThreeVector value)
|
||||
tallyPosition[tallyNumber] = value;
|
||||
tallyNumber++;
|
||||
}
|
||||
G4RunManager::GetRunManager()->GeometryHasBeenModified();
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
#include "G4RunManager.hh"
|
||||
|
||||
void DetectorConstruction::UpdateGeometry()
|
||||
{
|
||||
G4RunManager::GetRunManager()->DefineWorldVolume(ConstructVolumes());
|
||||
G4RunManager::GetRunManager()->PhysicsHasBeenModified();
|
||||
G4RunManager::GetRunManager()->DefineWorldVolume(ConstructVolumes());
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
// $Id: DetectorMessenger.cc,v 1.3 2006/06/29 16:58:13 gunter Exp $
|
||||
// GEANT4 tag $Name: geant4-09-01 $
|
||||
// GEANT4 tag $Name: geant4-09-02 $
|
||||
//
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
// $Id: EventAction.cc,v 1.4 2006/06/29 16:58:15 gunter Exp $
|
||||
// GEANT4 tag $Name: geant4-09-01 $
|
||||
// GEANT4 tag $Name: geant4-09-02 $
|
||||
//
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
// $Id: EventActionMessenger.cc,v 1.4 2006/06/29 16:58:17 gunter Exp $
|
||||
// GEANT4 tag $Name: geant4-09-01 $
|
||||
// GEANT4 tag $Name: geant4-09-02 $
|
||||
//
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
@@ -0,0 +1,100 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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: G4LindhardPartition.cc,v 1.1 2008/05/08 11:29:43 vnivanch Exp $
|
||||
// GEANT4 tag $Name: geant4-09-02 $
|
||||
//
|
||||
|
||||
/*
|
||||
* G4LindhardPartition.cc
|
||||
*
|
||||
* Created by Marcus Mendenhall on 1/14/08.
|
||||
* Copyright 2008 Vanderbilt University, Nashville, TN, USA. All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "G4LindhardPartition.hh"
|
||||
#include "G4Material.hh"
|
||||
#include "G4Element.hh"
|
||||
|
||||
/*
|
||||
for a first cut, we will compute NIEL from a Lindhard-Robinson partition
|
||||
based on the most abundant element in the material.
|
||||
|
||||
this is from IEEE Trans. Nucl Science Vol. 48 No.1 February 2001 page 162++
|
||||
Insoo Jun, "Effects of Secondary Particles on the Total Dose..."
|
||||
and, by reference,
|
||||
Lindhard, Nielsen, Scharff & Thompson,
|
||||
"Integral Equations Governing Radiation Efects...",
|
||||
Mat. Fys. Medd. Dan. Vid. Selsk. vol 33 #10, pp1-42, 1963
|
||||
and
|
||||
Robinson, "The dependence of radiation effects on primary recoil energy",
|
||||
in Proc. Int. Conf. Radiation-Induced Voids in Metal,
|
||||
Albany, NY 1972 pp. 397-439
|
||||
def lindhard_robinson(z1, a1, z2, a2, ke):
|
||||
el=30.724*z1*z2*math.sqrt(z1**0.6667+z2**0.6667)*(a1+a2)/a2
|
||||
fl=0.0793*z1**0.6667*math.sqrt(z2)*(a1+a2)**1.5/
|
||||
((z1**0.6667+z2**0.6667)**0.75*a1**1.5*math.sqrt(a2))
|
||||
eps=ke*(1.0/el)
|
||||
return 1.0/(1+fl*(3.4008*eps**0.16667+0.40244*eps**0.75+eps))
|
||||
*/
|
||||
|
||||
G4LindhardRobinsonPartition::G4LindhardRobinsonPartition()
|
||||
{
|
||||
max_z = 120;
|
||||
for(size_t i=1; i<max_z; i++) {z23[i]=std::pow((G4double)i, 2./3.);}
|
||||
}
|
||||
|
||||
G4double G4LindhardRobinsonPartition::PartitionNIEL(
|
||||
G4int z1, G4double a1, const G4Material *material, G4double energy) const
|
||||
{
|
||||
size_t nMatElements = material->GetNumberOfElements();
|
||||
|
||||
const G4double *atomDensities=material->GetVecNbOfAtomsPerVolume();
|
||||
G4double maxdens=0.0;
|
||||
size_t maxindex=0;
|
||||
for (size_t k=0 ; k < nMatElements ; k++ )
|
||||
{
|
||||
if(atomDensities[k] > maxdens) {
|
||||
maxdens=atomDensities[k];
|
||||
maxindex=k;
|
||||
}
|
||||
}
|
||||
const G4Element *element=material->GetElement(maxindex);
|
||||
|
||||
G4int z2=G4int(element->GetZ());
|
||||
|
||||
G4double a2=element->GetA()/(Avogadro*amu);
|
||||
|
||||
G4double zpow=z23[z1]+z23[z2];
|
||||
G4double asum=a1+a2;
|
||||
|
||||
G4double el=30.724*z1*z2*std::sqrt(zpow)*asum/a2;
|
||||
G4double fl=0.0793*z23[z1]*std::sqrt(z2*asum*asum*asum/(a1*a1*a1*a2))/std::pow(zpow, 0.75);
|
||||
G4double eps=(energy/eV)*(1.0/el);
|
||||
|
||||
return 1.0/(1+fl*(3.4008*std::pow(eps, 0.16667)+0.40244*std::pow(eps, 0.75)+eps));
|
||||
}
|
||||
|
||||
@@ -24,8 +24,8 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: G4ScreenedNuclearRecoil.cc,v 1.4 2007/12/10 16:28:15 gunter Exp $
|
||||
// GEANT4 tag $Name: geant4-09-01 $
|
||||
// G4ScreenedNuclearRecoil.cc,v 1.57 2008/05/07 11:51:26 marcus Exp
|
||||
// GEANT4 tag
|
||||
//
|
||||
//
|
||||
// Class Description
|
||||
@@ -83,10 +83,14 @@
|
||||
|
||||
#include "G4ScreenedNuclearRecoil.hh"
|
||||
|
||||
const char* G4ScreenedCoulombCrossSectionInfo::CVSFileVers() { return
|
||||
"G4ScreenedNuclearRecoil.cc,v 1.57 2008/05/07 11:51:26 marcus Exp GEANT4 tag ";
|
||||
}
|
||||
|
||||
#include "G4ParticleTypes.hh"
|
||||
#include "G4ParticleTable.hh"
|
||||
#include "G4VParticleChange.hh"
|
||||
#include "G4ParticleChange.hh"
|
||||
#include "G4ParticleChangeForLoss.hh"
|
||||
#include "G4DataVector.hh"
|
||||
#include "G4Track.hh"
|
||||
#include "G4Step.hh"
|
||||
@@ -98,11 +102,14 @@
|
||||
#include "G4ElementVector.hh"
|
||||
#include "G4IsotopeVector.hh"
|
||||
|
||||
#include "G4EmProcessSubType.hh"
|
||||
|
||||
#include "G4RangeTest.hh"
|
||||
#include "G4ParticleDefinition.hh"
|
||||
#include "G4DynamicParticle.hh"
|
||||
#include "G4ProcessManager.hh"
|
||||
#include "G4StableIsotopes.hh"
|
||||
#include "G4LindhardPartition.hh"
|
||||
|
||||
#include "Randomize.hh"
|
||||
|
||||
@@ -111,20 +118,14 @@
|
||||
#include <iostream>
|
||||
#include <iomanip>
|
||||
|
||||
#include "c2_factory.hh"
|
||||
static c2_factory<G4double> c2; // this makes a lot of notation shorter
|
||||
typedef c2_ptr<G4double> c2p;
|
||||
|
||||
G4ScreenedCoulombCrossSection::~G4ScreenedCoulombCrossSection()
|
||||
{
|
||||
ScreeningMap::iterator tables=screeningData.begin();
|
||||
for (;tables != screeningData.end(); tables++) {
|
||||
delete (*tables).second.EMphiData;
|
||||
}
|
||||
screeningData.clear();
|
||||
|
||||
std::map<G4int, c2_function<G4double> *>::iterator mfpit=MFPTables.begin();
|
||||
for (;mfpit != MFPTables.end(); mfpit++) {
|
||||
delete (*mfpit).second;
|
||||
}
|
||||
MFPTables.clear();
|
||||
|
||||
MFPTables.clear();
|
||||
}
|
||||
|
||||
const G4double G4ScreenedCoulombCrossSection::massmap[nMassMapElements+1]={
|
||||
@@ -247,7 +248,7 @@ void G4ScreenedCoulombCrossSection::BuildMFPTables()
|
||||
{
|
||||
element=elementVector[kel];
|
||||
G4int Z=(G4int)std::floor(element->GetZ()+0.5);
|
||||
c2_function<G4double> &ifunc=*sigmaMap[Z];
|
||||
const G4_c2_function &ifunc=sigmaMap[Z];
|
||||
if(!kel || ifunc.xmin() > emin) emin=ifunc.xmin();
|
||||
if(!kel || ifunc.xmax() < emax) emax=ifunc.xmax();
|
||||
}
|
||||
@@ -267,7 +268,7 @@ void G4ScreenedCoulombCrossSection::BuildMFPTables()
|
||||
{
|
||||
element=elementVector[kel];
|
||||
G4int Z=(G4int)std::floor(element->GetZ()+0.5);
|
||||
c2_function<G4double> &sigma=*sigmaMap[Z];
|
||||
const G4_c2_function &sigma=sigmaMap[Z];
|
||||
G4double ndens = atomDensities[kel]; // compute atom fraction for this element in this material
|
||||
|
||||
for (G4int eidx=0; eidx < nmfpvals; eidx++) {
|
||||
@@ -280,17 +281,8 @@ void G4ScreenedCoulombCrossSection::BuildMFPTables()
|
||||
mfpvals[eidx] = 1.0/mfpvals[eidx];
|
||||
}
|
||||
// and make a new interpolating function out of the sum
|
||||
MFPTables[matidx] = static_cast<c2_function<G4double> *>(new log_log_interpolating_function<G4double>(
|
||||
evals, mfpvals));
|
||||
MFPTables[matidx] = c2.log_log_interpolating_function().load(evals, mfpvals,true,0,true,0);
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
for (G4int matidx=0; matidx < nMaterials; matidx++) {
|
||||
const G4Material* material= (*materialTable)[matidx];
|
||||
G4cout << "***** MFP (1MeV) ***** " << material->GetName() << " " << (*MFPTables[matidx])(1.0) << G4endl;
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
G4ScreenedNuclearRecoil::
|
||||
@@ -303,8 +295,14 @@ G4ScreenedNuclearRecoil(const G4String& processName,
|
||||
generateRecoils(GenerateRecoils), avoidReactions(1),
|
||||
recoilCutoff(RecoilCutoff), physicsCutoff(PhysicsCutoff),
|
||||
hardeningFraction(0.0), hardeningFactor(1.0),
|
||||
externalCrossSectionConstructor(0)
|
||||
externalCrossSectionConstructor(0),
|
||||
NIELPartitionFunction(new G4LindhardRobinsonPartition)
|
||||
{
|
||||
// for now, point to class instance of this. Doing it by creating a new one fails
|
||||
// to correctly update NIEL
|
||||
// not even this is needed... done in G4VProcess().
|
||||
// pParticleChange=&aParticleChange;
|
||||
processMaxEnergy=50000.0*MeV;
|
||||
highEnergyLimit=100.0*MeV;
|
||||
lowEnergyLimit=physicsCutoff;
|
||||
registerDepositedEnergy=1; // by default, don't hide NIEL
|
||||
@@ -312,15 +310,11 @@ G4ScreenedNuclearRecoil(const G4String& processName,
|
||||
// SetVerboseLevel(2);
|
||||
AddStage(new G4ScreenedCoulombClassicalKinematics);
|
||||
AddStage(new G4SingleScatter);
|
||||
SetProcessSubType(fCoulombScattering);
|
||||
}
|
||||
|
||||
void G4ScreenedNuclearRecoil::ResetTables()
|
||||
{
|
||||
std::map<G4int, c2_function<G4double>*>::iterator xh=meanFreePathTables.begin();
|
||||
for(;xh != meanFreePathTables.end(); xh++) {
|
||||
delete (*xh).second;
|
||||
}
|
||||
meanFreePathTables.clear();
|
||||
|
||||
std::map<G4int, G4ScreenedCoulombCrossSection*>::iterator xt=crossSectionHandlers.begin();
|
||||
for(;xt != crossSectionHandlers.end(); xt++) {
|
||||
@@ -339,6 +333,23 @@ void G4ScreenedNuclearRecoil::ClearStages()
|
||||
collisionStages.clear();
|
||||
}
|
||||
|
||||
void G4ScreenedNuclearRecoil::SetNIELPartitionFunction(const G4VNIELPartition *part)
|
||||
{
|
||||
if(NIELPartitionFunction) delete NIELPartitionFunction;
|
||||
NIELPartitionFunction=part;
|
||||
}
|
||||
|
||||
void G4ScreenedNuclearRecoil::DepositEnergy(G4int z1, G4double a1, const G4Material *material, G4double energy)
|
||||
{
|
||||
if(!NIELPartitionFunction) {
|
||||
IonizingLoss+=energy;
|
||||
} else {
|
||||
G4double part=NIELPartitionFunction->PartitionNIEL(z1, a1, material, energy);
|
||||
IonizingLoss+=energy*(1-part);
|
||||
NIEL += energy*part;
|
||||
}
|
||||
}
|
||||
|
||||
G4ScreenedNuclearRecoil::~G4ScreenedNuclearRecoil()
|
||||
{
|
||||
ResetTables();
|
||||
@@ -362,16 +373,21 @@ G4ScreenedCoulombCrossSection *G4ScreenedNuclearRecoil::GetNewCrossSectionHandle
|
||||
|
||||
G4double G4ScreenedNuclearRecoil::GetMeanFreePath(const G4Track& track,
|
||||
G4double,
|
||||
G4ForceCondition*)
|
||||
G4ForceCondition* cond)
|
||||
{
|
||||
const G4DynamicParticle* incoming = track.GetDynamicParticle();
|
||||
G4double energy = incoming->GetKineticEnergy();
|
||||
G4double a1=incoming->GetDefinition()->GetPDGMass()/amu_c2;
|
||||
|
||||
G4double meanFreePath;
|
||||
*cond=NotForced;
|
||||
|
||||
if (energy < lowEnergyLimit || energy < recoilCutoff) return 1.0*nanometer; /* stop slow particles! */
|
||||
else if (energy > highEnergyLimit*a1) energy=highEnergyLimit*a1; /* constant MFP at high energy */
|
||||
if (energy < lowEnergyLimit || energy < recoilCutoff*a1) {
|
||||
*cond=Forced;
|
||||
return 1.0*nm; /* catch and stop slow particles to collect their NIEL! */
|
||||
} else if (energy > processMaxEnergy*a1) {
|
||||
return DBL_MAX; // infinite mean free path
|
||||
} else if (energy > highEnergyLimit*a1) energy=highEnergyLimit*a1; /* constant MFP at high energy */
|
||||
|
||||
G4double fz1=incoming->GetDefinition()->GetPDGCharge();
|
||||
G4int z1=(G4int)(fz1/eplus + 0.5);
|
||||
@@ -389,7 +405,7 @@ G4double G4ScreenedNuclearRecoil::GetMeanFreePath(const G4Track& track,
|
||||
const G4MaterialCutsCouple* materialCouple = track.GetMaterialCutsCouple();
|
||||
size_t materialIndex = materialCouple->GetMaterial()->GetIndex();
|
||||
|
||||
c2_function<G4double> &mfp=*(*xs)[materialIndex];
|
||||
const G4_c2_function &mfp=*(*xs)[materialIndex];
|
||||
|
||||
// make absolutely certain we don't get an out-of-range energy
|
||||
meanFreePath = mfp(std::min(std::max(energy, mfp.xmin()), mfp.xmax()));
|
||||
@@ -402,8 +418,9 @@ G4double G4ScreenedNuclearRecoil::GetMeanFreePath(const G4Track& track,
|
||||
G4VParticleChange* G4ScreenedNuclearRecoil::PostStepDoIt(const G4Track& aTrack, const G4Step& aStep)
|
||||
{
|
||||
validCollision=1;
|
||||
aParticleChange.Initialize(aTrack);
|
||||
pParticleChange->Initialize(aTrack);
|
||||
NIEL=0.0; // default is no NIEL deposited
|
||||
IonizingLoss=0.0;
|
||||
|
||||
// do universal setup
|
||||
|
||||
@@ -412,63 +429,64 @@ G4VParticleChange* G4ScreenedNuclearRecoil::PostStepDoIt(const G4Track& aTrack,
|
||||
|
||||
G4double fz1=baseParticle->GetPDGCharge()/eplus;
|
||||
G4int z1=(G4int)(fz1+0.5);
|
||||
G4double a1=baseParticle->GetPDGMass()/amu_c2;
|
||||
G4double incidentEnergy = incidentParticle->GetKineticEnergy();
|
||||
|
||||
// Select randomly one element and (possibly) isotope in the current material.
|
||||
const G4MaterialCutsCouple* couple = aTrack.GetMaterialCutsCouple();
|
||||
|
||||
if(incidentEnergy < GetRecoilCutoff()) { // check energy sanity on entry
|
||||
if(!baseParticle->GetProcessManager()->
|
||||
GetAtRestProcessVector()->size())
|
||||
aParticleChange.ProposeTrackStatus(fStopAndKill);
|
||||
else
|
||||
aParticleChange.ProposeTrackStatus(fStopButAlive);
|
||||
const G4Material* mat = couple->GetMaterial();
|
||||
|
||||
AddToNIEL(incidentEnergy);
|
||||
aParticleChange.ProposeEnergy(0.0);
|
||||
G4double P=0.0; // the impact parameter of this collision
|
||||
|
||||
if(incidentEnergy < GetRecoilCutoff()*a1) { // check energy sanity on entry
|
||||
DepositEnergy(z1, baseParticle->GetPDGMass()/amu_c2, mat, incidentEnergy);
|
||||
GetParticleChange().ProposeEnergy(0.0);
|
||||
// stop the particle and bail out
|
||||
validCollision=0;
|
||||
}
|
||||
|
||||
const G4Material* mat = couple->GetMaterial();
|
||||
G4double numberDensity=mat->GetTotNbOfAtomsPerVolume();
|
||||
G4double lattice=0.5/std::pow(numberDensity,1.0/3.0); // typical lattice half-spacing
|
||||
G4double length=GetCurrentInteractionLength();
|
||||
G4double sigopi=1.0/(CLHEP::pi*numberDensity*length); // this is sigma0/pi
|
||||
|
||||
// compute the impact parameter very early, so if is rejected as too far away, little effort is wasted
|
||||
// this is the TRIM method for determining an impact parameter based on the flight path
|
||||
// this gives a cumulative distribution of N(P)= 1-exp(-pi P^2 n l)
|
||||
// which says the probability of NOT hitting a disk of area sigma= pi P^2 =exp(-sigma N l)
|
||||
// which may be reasonable
|
||||
G4double P;
|
||||
if(sigopi < lattice*lattice) {
|
||||
// normal long-flight approximation
|
||||
P = std::sqrt(-std::log(G4UniformRand()) *sigopi);
|
||||
} else {
|
||||
// short-flight limit
|
||||
P = std::sqrt(G4UniformRand())*lattice;
|
||||
}
|
||||
|
||||
G4double fraction=GetHardeningFraction();
|
||||
if(fraction && G4UniformRand() < fraction) {
|
||||
// pick out some events, and increase the central cross section
|
||||
// by reducing the impact parameter
|
||||
P /= std::sqrt(GetHardeningFactor());
|
||||
}
|
||||
|
||||
|
||||
// check if we are far enough away that the energy transfer must be below cutoff,
|
||||
// and leave everything alone if so, saving a lot of time.
|
||||
if(P*P > sigopi) {
|
||||
if(GetVerboseLevel() > 1)
|
||||
printf("ScreenedNuclear impact reject: length=%.3f P=%.4f limit=%.4f\n",
|
||||
length/angstrom, P/angstrom,std::sqrt(sigopi)/angstrom);
|
||||
// no collision, don't follow up with anything
|
||||
validCollision=0;
|
||||
G4double numberDensity=mat->GetTotNbOfAtomsPerVolume();
|
||||
G4double lattice=0.5/std::pow(numberDensity,1.0/3.0); // typical lattice half-spacing
|
||||
G4double length=GetCurrentInteractionLength();
|
||||
G4double sigopi=1.0/(CLHEP::pi*numberDensity*length); // this is sigma0/pi
|
||||
|
||||
// compute the impact parameter very early, so if is rejected as too far away, little effort is wasted
|
||||
// this is the TRIM method for determining an impact parameter based on the flight path
|
||||
// this gives a cumulative distribution of N(P)= 1-exp(-pi P^2 n l)
|
||||
// which says the probability of NOT hitting a disk of area sigma= pi P^2 =exp(-sigma N l)
|
||||
// which may be reasonable
|
||||
if(sigopi < lattice*lattice) {
|
||||
// normal long-flight approximation
|
||||
P = std::sqrt(-std::log(G4UniformRand()) *sigopi);
|
||||
} else {
|
||||
// short-flight limit
|
||||
P = std::sqrt(G4UniformRand())*lattice;
|
||||
}
|
||||
|
||||
G4double fraction=GetHardeningFraction();
|
||||
if(fraction && G4UniformRand() < fraction) {
|
||||
// pick out some events, and increase the central cross section
|
||||
// by reducing the impact parameter
|
||||
P /= std::sqrt(GetHardeningFactor());
|
||||
}
|
||||
|
||||
|
||||
// check if we are far enough away that the energy transfer must be below cutoff,
|
||||
// and leave everything alone if so, saving a lot of time.
|
||||
if(P*P > sigopi) {
|
||||
if(GetVerboseLevel() > 1)
|
||||
printf("ScreenedNuclear impact reject: length=%.3f P=%.4f limit=%.4f\n",
|
||||
length/angstrom, P/angstrom,std::sqrt(sigopi)/angstrom);
|
||||
// no collision, don't follow up with anything
|
||||
validCollision=0;
|
||||
}
|
||||
}
|
||||
|
||||
// find out what we hit, and record it in our kinematics block.
|
||||
kinematics.targetMaterial=mat;
|
||||
kinematics.a1=a1;
|
||||
|
||||
if(validCollision) {
|
||||
G4ScreenedCoulombCrossSection *xsect=GetCrossSectionHandlers()[z1];
|
||||
G4ParticleDefinition *recoilIon=
|
||||
@@ -476,12 +494,10 @@ G4VParticleChange* G4ScreenedNuclearRecoil::PostStepDoIt(const G4Track& aTrack,
|
||||
kinematics.crossSection=xsect;
|
||||
kinematics.recoilIon=recoilIon;
|
||||
kinematics.impactParameter=P;
|
||||
kinematics.a1=baseParticle->GetPDGMass()/amu_c2;
|
||||
kinematics.a2=recoilIon->GetPDGMass()/amu_c2;
|
||||
} else {
|
||||
kinematics.recoilIon=0;
|
||||
kinematics.impactParameter=0;
|
||||
kinematics.a1=baseParticle->GetPDGMass()/amu_c2;
|
||||
kinematics.a2=0;
|
||||
}
|
||||
|
||||
@@ -490,11 +506,26 @@ G4VParticleChange* G4ScreenedNuclearRecoil::PostStepDoIt(const G4Track& aTrack,
|
||||
for(; stage != collisionStages.end(); stage++)
|
||||
(*stage)->DoCollisionStep(this,aTrack, aStep);
|
||||
|
||||
if(registerDepositedEnergy) aParticleChange.ProposeLocalEnergyDeposit(NIEL);
|
||||
|
||||
if(registerDepositedEnergy) {
|
||||
pParticleChange->ProposeLocalEnergyDeposit(IonizingLoss+NIEL);
|
||||
pParticleChange->ProposeNonIonizingEnergyDeposit(NIEL);
|
||||
//MHM G4cout << "depositing energy, total = " << IonizingLoss+NIEL << " NIEL = " << NIEL << G4endl;
|
||||
}
|
||||
|
||||
return G4VDiscreteProcess::PostStepDoIt( aTrack, aStep );
|
||||
}
|
||||
|
||||
G4ScreenedCoulombClassicalKinematics::G4ScreenedCoulombClassicalKinematics() :
|
||||
// instantiate all the needed functions statically, so no allocation is done at run time
|
||||
// we will be solving x^2 - x phi(x*au)/eps - beta^2 == 0.0
|
||||
// or, for easier scaling, x'^2 - x' au phi(x')/eps - beta^2 au^2
|
||||
// note that only the last of these gets deleted, since it owns the rest
|
||||
phifunc(c2.const_plugin_function()),
|
||||
xovereps(c2.linear(0., 0., 0.)), // will fill this in with the right slope at run time
|
||||
diff(c2.quadratic(0., 0., 0., 1.)-xovereps*phifunc)
|
||||
{
|
||||
}
|
||||
|
||||
G4bool G4ScreenedCoulombClassicalKinematics::DoScreeningComputation(G4ScreenedNuclearRecoil *master,
|
||||
const G4ScreeningTables *screen, G4double eps, G4double beta)
|
||||
{
|
||||
@@ -517,37 +548,26 @@ G4bool G4ScreenedCoulombClassicalKinematics::DoScreeningComputation(G4ScreenedNu
|
||||
|
||||
}
|
||||
|
||||
c2_function<G4double> &phiData=*(screen->EMphiData);
|
||||
// instantiate all the needed functions statically, so no allocation is done at run time
|
||||
// we will be solving x^2 - x phi(x*au)/eps - beta^2 == 0.0
|
||||
// or, for easier scaling, x'^2 - x' au phi(x')/eps - beta^2 au^2
|
||||
static c2_plugin_function<G4double> phifunc;
|
||||
static c2_quadratic<G4double> xsq(0., 0., 0., 1.); // x^2
|
||||
static c2_linear<G4double> xovereps(0., 0., 0.); // will fill this in with the right slope at run time
|
||||
static c2_function<G4double> &xphi=xovereps*phifunc;
|
||||
static c2_function<G4double> &diff=xsq-xphi;
|
||||
|
||||
xovereps.reset(0., 0.0, au/eps); // slope of x*au/eps term
|
||||
phifunc.set_function(phiData); // install interpolating table
|
||||
|
||||
phifunc.set_function(&(screen->EMphiData.get())); // install interpolating table
|
||||
G4double xx1, phip, phip2;
|
||||
G4int root_error;
|
||||
|
||||
xx1=diff.find_root(phiData.xmin(), std::min(10*xx0*au,phiData.xmax()),
|
||||
std::min(xx0*au, phiData.xmax()), beta*beta*au*au, &root_error, &phip, &phip2)/au;
|
||||
G4int root_error;
|
||||
xx1=diff->find_root(phifunc.xmin(), std::min(10*xx0*au,phifunc.xmax()),
|
||||
std::min(xx0*au, phifunc.xmax()), beta*beta*au*au, &root_error, &phip, &phip2)/au;
|
||||
|
||||
if(root_error) {
|
||||
G4cout << "Screened Coulomb Root Finder Error" << G4endl;
|
||||
G4cout << "au " << au << " A " << A << " a1 " << a1 << " xx1 " << xx1 << " eps " << eps << " beta " << beta << G4endl;
|
||||
G4cout << " xmin " << phiData.xmin() << " xmax " << std::min(10*xx0*au,phiData.xmax()) ;
|
||||
G4cout << " f(xmin) " << phifunc(phiData.xmin()) << " f(xmax) " << phifunc(std::min(10*xx0*au,phiData.xmax())) ;
|
||||
G4cout << " xstart " << std::min(xx0*au, phiData.xmax()) << " target " << beta*beta*au*au ;
|
||||
G4cout << " xmin " << phifunc.xmin() << " xmax " << std::min(10*xx0*au,phifunc.xmax()) ;
|
||||
G4cout << " f(xmin) " << phifunc(phifunc.xmin()) << " f(xmax) " << phifunc(std::min(10*xx0*au,phifunc.xmax())) ;
|
||||
G4cout << " xstart " << std::min(xx0*au, phifunc.xmax()) << " target " << beta*beta*au*au ;
|
||||
G4cout << G4endl;
|
||||
throw c2_exception("Failed root find");
|
||||
}
|
||||
|
||||
phifunc.unset_function(); // throws an exception if used without setting again
|
||||
// phiprime is scaled by one factor of au because phi is evaluated at (xx0*au),
|
||||
// phiprime is scaled by one factor of au because phi is evaluated at (xx0*au),
|
||||
G4double phiprime=phip*au;
|
||||
|
||||
//lambda0 is from W&M 19
|
||||
@@ -561,10 +581,12 @@ G4bool G4ScreenedCoulombClassicalKinematics::DoScreeningComputation(G4ScreenedNu
|
||||
for(G4int k=0; k<4; k++) {
|
||||
G4double x, ff;
|
||||
x=xx1/xvals[k];
|
||||
ff=1.0/std::sqrt(1.0-phiData(x*au)/(x*eps)-beta*beta/(x*x));
|
||||
ff=1.0/std::sqrt(1.0-phifunc(x*au)/(x*eps)-beta*beta/(x*x));
|
||||
alpha+=weights[k]*ff;
|
||||
}
|
||||
|
||||
phifunc.unset_function(); // throws an exception if used without setting again
|
||||
|
||||
G4double thetac1=CLHEP::pi*beta*alpha/xx1; // complement of CM scattering angle
|
||||
G4double sintheta=std::sin(thetac1); //note sin(pi-theta)=sin(theta)
|
||||
G4double costheta=-std::cos(thetac1); // note cos(pi-theta)=-cos(theta)
|
||||
@@ -623,21 +645,16 @@ void G4ScreenedCoulombClassicalKinematics::DoCollisionStep(G4ScreenedNuclearReco
|
||||
G4double eRecoil=4*incidentEnergy*a1*A*kin.cosZeta*kin.cosZeta/((a1+A)*(a1+A));
|
||||
kin.eRecoil=eRecoil;
|
||||
|
||||
if(incidentEnergy-eRecoil < master->GetRecoilCutoff()) {
|
||||
if(!baseParticle->GetProcessManager()->
|
||||
GetAtRestProcessVector()->size())
|
||||
aParticleChange.ProposeTrackStatus(fStopAndKill);
|
||||
else
|
||||
aParticleChange.ProposeTrackStatus(fStopButAlive);
|
||||
if(incidentEnergy-eRecoil < master->GetRecoilCutoff()*a1) {
|
||||
aParticleChange.ProposeEnergy(0.0);
|
||||
master->AddToNIEL(incidentEnergy-eRecoil);
|
||||
master->DepositEnergy(int(screen->z1), a1, kin.targetMaterial, incidentEnergy-eRecoil);
|
||||
}
|
||||
|
||||
if(master->GetEnableRecoils() && eRecoil > master->GetRecoilCutoff()) {
|
||||
if(master->GetEnableRecoils() && eRecoil > master->GetRecoilCutoff() * kin.a2) {
|
||||
kin.recoilIon=recoilIon;
|
||||
} else {
|
||||
kin.recoilIon=0; // this flags no recoil to be generated
|
||||
master->AddToNIEL(eRecoil) ;
|
||||
master->DepositEnergy(Z, A, kin.targetMaterial, eRecoil) ;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -703,7 +720,7 @@ DumpPhysicsTable(const G4ParticleDefinition&)
|
||||
#include "G4ElementVector.hh"
|
||||
#include <vector>
|
||||
|
||||
static c2_function<G4double> &ZBLScreening(G4int z1, G4int z2, size_t npoints, G4double rMax, G4double *auval)
|
||||
G4_c2_function &ZBLScreening(G4int z1, G4int z2, size_t npoints, G4double rMax, G4double *auval)
|
||||
{
|
||||
static const size_t ncoef=4;
|
||||
static G4double scales[ncoef]={-3.2, -0.9432, -0.4028, -0.2016};
|
||||
@@ -726,10 +743,10 @@ static c2_function<G4double> &ZBLScreening(G4int z1, G4int z2, size_t npoints, G
|
||||
phiprime0*=(1.0/au); // put back in natural units;
|
||||
|
||||
*auval=au;
|
||||
return *static_cast<c2_function<G4double> *>(new lin_log_interpolating_function<G4double>(r, phi, false, phiprime0));
|
||||
return c2.lin_log_interpolating_function().load(r, phi, false, phiprime0,true,0);
|
||||
}
|
||||
|
||||
static c2_function<G4double> &MoliereScreening(G4int z1, G4int z2, size_t npoints, G4double rMax, G4double *auval)
|
||||
G4_c2_function &MoliereScreening(G4int z1, G4int z2, size_t npoints, G4double rMax, G4double *auval)
|
||||
{
|
||||
static const size_t ncoef=3;
|
||||
static G4double scales[ncoef]={-6.0, -1.2, -0.3};
|
||||
@@ -752,10 +769,10 @@ static c2_function<G4double> &MoliereScreening(G4int z1, G4int z2, size_t npoint
|
||||
phiprime0*=(1.0/au); // put back in natural units;
|
||||
|
||||
*auval=au;
|
||||
return *static_cast<c2_function<G4double> *>(new lin_log_interpolating_function<G4double>(r, phi, false, phiprime0));
|
||||
return c2.lin_log_interpolating_function().load(r, phi, false, phiprime0,true,0);
|
||||
}
|
||||
|
||||
static c2_function<G4double> &LJScreening(G4int z1, G4int z2, size_t npoints, G4double rMax, G4double *auval)
|
||||
G4_c2_function &LJScreening(G4int z1, G4int z2, size_t npoints, G4double rMax, G4double *auval)
|
||||
{
|
||||
//from Loftager, Besenbacher, Jensen & Sorensen
|
||||
//PhysRev A20, 1443++, 1979
|
||||
@@ -778,7 +795,33 @@ static c2_function<G4double> &LJScreening(G4int z1, G4int z2, size_t npoints, G4
|
||||
logphiprime0 *= (1.0/au); // #put back in natural units
|
||||
|
||||
*auval=au;
|
||||
return *static_cast<c2_function<G4double> *>(new lin_log_interpolating_function<G4double>(r, phi, false, logphiprime0*phi[0]));
|
||||
return c2.lin_log_interpolating_function().load(r, phi, false, logphiprime0*phi[0],true,0);
|
||||
}
|
||||
|
||||
G4_c2_function &LJZBLScreening(G4int z1, G4int z2, size_t npoints, G4double rMax, G4double *auval)
|
||||
{
|
||||
// hybrid of LJ and ZBL, uses LJ if x < 0.25*auniv, ZBL if x > 1.5*auniv, and
|
||||
/// connector in between. These numbers are selected so the switchover
|
||||
// is very near the point where the functions naturally cross.
|
||||
G4double auzbl, aulj;
|
||||
|
||||
c2p zbl=ZBLScreening(z1, z2, npoints, rMax, &auzbl);
|
||||
c2p lj=LJScreening(z1, z2, npoints, rMax, &aulj);
|
||||
|
||||
G4double au=(auzbl+aulj)*0.5;
|
||||
lj->set_domain(lj->xmin(), 0.25*au);
|
||||
zbl->set_domain(1.5*au,zbl->xmax());
|
||||
|
||||
c2p conn=c2.connector_function(lj->xmax(), lj, zbl->xmin(), zbl, true,0);
|
||||
c2_piecewise_function_p<G4double> &pw=c2.piecewise_function();
|
||||
c2p keepit(pw);
|
||||
pw.append_function(lj);
|
||||
pw.append_function(conn);
|
||||
pw.append_function(zbl);
|
||||
|
||||
*auval=au;
|
||||
keepit.release_for_return();
|
||||
return pw;
|
||||
}
|
||||
|
||||
G4NativeScreenedCoulombCrossSection::~G4NativeScreenedCoulombCrossSection() {
|
||||
@@ -788,6 +831,7 @@ G4NativeScreenedCoulombCrossSection::G4NativeScreenedCoulombCrossSection() {
|
||||
AddScreeningFunction("zbl", ZBLScreening);
|
||||
AddScreeningFunction("lj", LJScreening);
|
||||
AddScreeningFunction("mol", MoliereScreening);
|
||||
AddScreeningFunction("ljzbl", LJZBLScreening);
|
||||
}
|
||||
|
||||
std::vector<G4String> G4NativeScreenedCoulombCrossSection::GetScreeningKeys() const {
|
||||
@@ -852,10 +896,10 @@ void G4NativeScreenedCoulombCrossSection::LoadData(G4String screeningKey, G4int
|
||||
ScreeningFunc sfunc=(*sfunciter).second;
|
||||
|
||||
G4double au;
|
||||
c2_function<G4double> &screen=sfunc(z1, Z, 200, 50.0*angstrom, &au); // generate the screening data
|
||||
|
||||
G4_c2_ptr screen=sfunc(z1, Z, 200, 50.0*angstrom, &au); // generate the screening data
|
||||
G4ScreeningTables st;
|
||||
st.EMphiData=&screen; // this is our phi table
|
||||
|
||||
st.EMphiData=screen; //save our phi table
|
||||
st.z1=z1; st.m1=a1; st.z2=Z; st.m2=a2; st.emin=recoilCutoff;
|
||||
st.au=au;
|
||||
|
||||
@@ -866,10 +910,13 @@ void G4NativeScreenedCoulombCrossSection::LoadData(G4String screeningKey, G4int
|
||||
//Since we don't need exact sigma values, this is good enough (within a factor of 2 almost always)
|
||||
//this rearranges to phi(x0)/(x0*eps) = 2*theta/pi - theta^2/pi^2
|
||||
|
||||
c2_linear<G4double> c2au(0.0, 0.0, au);
|
||||
c2_composed_function<G4double> phiau(screen, c2au); // build phi(x*au) for dimensionless phi
|
||||
c2_linear<G4double> c2eps(0.0, 0.0, 0.0); // will store an appropriate eps inside this in loop
|
||||
c2_ratio<G4double> x0func(phiau, c2eps); // this will be phi(x)/(x*eps) when c2eps is correctly set
|
||||
c2_linear_p<G4double> &c2eps=c2.linear(0.0, 0.0, 0.0); // will store an appropriate eps inside this in loop
|
||||
G4_c2_ptr phiau=screen(c2.linear(0.0, 0.0, au));
|
||||
G4_c2_ptr x0func(phiau/c2eps); // this will be phi(x)/(x*eps) when c2eps is correctly set
|
||||
x0func->set_domain(1e-6*angstrom/au, 0.9999*screen->xmax()/au); // needed for inverse function
|
||||
// use the c2_inverse_function interface for the root finder... it is more efficient for an ordered
|
||||
// computation of values.
|
||||
G4_c2_ptr x0_solution(c2.inverse_function(x0func));
|
||||
|
||||
G4double m1c2=a1*amu_c2;
|
||||
G4double escale=z1*Z*elm_coupling/au; // energy at screening distance
|
||||
@@ -894,16 +941,25 @@ void G4NativeScreenedCoulombCrossSection::LoadData(G4String screeningKey, G4int
|
||||
|
||||
G4double q=theta/pi;
|
||||
// G4cout << ee << " " << m1c2 << " " << gamma << " " << eps << " " << theta << " " << q << G4endl;
|
||||
G4double x0= x0func.find_root(1e-6*angstrom/au, 0.9999*screen.xmax()/au, 1.0, 2*q-q*q);
|
||||
// old way using root finder
|
||||
// G4double x0= x0func->find_root(1e-6*angstrom/au, 0.9999*screen.xmax()/au, 1.0, 2*q-q*q);
|
||||
// new way using c2_inverse_function which caches useful information so should be a bit faster
|
||||
// since we are scanning this in strict order.
|
||||
G4double x0=0;
|
||||
try {
|
||||
x0=x0_solution(2*q-q*q);
|
||||
} catch(c2_exception e) {
|
||||
G4Exception(
|
||||
G4String("G4ScreenedNuclearRecoil: failure in inverse solution to generate MFP Tables: ")+e.what()
|
||||
);
|
||||
}
|
||||
G4double betasquared=x0*x0 - x0*phiau(x0)/eps;
|
||||
G4double sigma=pi*betasquared*au*au;
|
||||
energies[idx]=ee;
|
||||
data[idx]=sigma;
|
||||
}
|
||||
|
||||
screeningData[Z]=st;
|
||||
sigmaMap[Z] = static_cast<c2_function<G4double> *>(new log_log_interpolating_function<G4double>(
|
||||
energies, data));
|
||||
sigmaMap[Z] = c2.log_log_interpolating_function().load(energies, data, true,0,true,0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,267 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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. *
|
||||
// ********************************************************************
|
||||
//
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
// ClassName: Histo - Generic histogram/ntuple manager class
|
||||
//
|
||||
//
|
||||
// Author: V.Ivanchenko 30.10.03
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
//
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
|
||||
|
||||
#include "Histo.hh"
|
||||
|
||||
#ifdef G4ANALYSIS_USE
|
||||
|
||||
#include "AIDA/AIDA.h"
|
||||
#include "HistoMessenger.hh"
|
||||
|
||||
#endif
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
|
||||
|
||||
Histo::Histo()
|
||||
{
|
||||
verbose = 0;
|
||||
histName = "testem9";
|
||||
histType = "root";
|
||||
nHisto = 0;
|
||||
defaultAct = 1;
|
||||
tupleName = "tuple9";
|
||||
tupleId = "100";
|
||||
tupleList = "";
|
||||
ntup = 0;
|
||||
messenger = 0;
|
||||
|
||||
#ifdef G4ANALYSIS_USE
|
||||
tree = 0;
|
||||
af = 0;
|
||||
messenger = new HistoMessenger(this);
|
||||
#endif
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
|
||||
|
||||
Histo::~Histo()
|
||||
{
|
||||
#ifdef G4ANALYSIS_USE
|
||||
delete messenger;
|
||||
delete af;
|
||||
#endif
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
|
||||
|
||||
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();
|
||||
|
||||
// Creating a tree mapped to a new hbook file.
|
||||
|
||||
G4String nam = histName + "." + histType;
|
||||
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;
|
||||
}
|
||||
// Creating a histogram factory, whose histograms will be handled by the tree
|
||||
AIDA::IHistogramFactory* hf = af->createHistogramFactory( *tree );
|
||||
|
||||
// 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]);
|
||||
}
|
||||
}
|
||||
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;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
|
||||
|
||||
void Histo::save()
|
||||
{
|
||||
#ifdef G4ANALYSIS_USE
|
||||
// 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;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
|
||||
|
||||
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
|
||||
<< " " << nb << " " << x1 << " " << x2 << " " << u
|
||||
<< G4endl;
|
||||
}
|
||||
nHisto++;
|
||||
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);
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
|
||||
|
||||
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
|
||||
<< " " << nb << " " << x1 << " " << x2 << " " << u
|
||||
<< G4endl;
|
||||
}
|
||||
bins[i] = nb;
|
||||
xmin[i] = x1;
|
||||
xmax[i] = x2;
|
||||
unit[i] = u;
|
||||
} else {
|
||||
G4cout << "Histo::setHisto1D: WARNING! wrong histogram index " << i << G4endl;
|
||||
}
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
|
||||
|
||||
void Histo::fill(G4int i, G4double x, G4double w)
|
||||
{
|
||||
if(verbose > 1) {
|
||||
G4cout << "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);
|
||||
} else {
|
||||
G4cout << "Histo::fill: WARNING! wrong histogram index " << i << G4endl;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
|
||||
|
||||
void Histo::scale(G4int i, G4double x)
|
||||
{
|
||||
if(verbose > 0) {
|
||||
G4cout << "Scale histogram: #" << i << " by factor " << x << G4endl;
|
||||
}
|
||||
#ifdef G4ANALYSIS_USE
|
||||
if(!tree) return;
|
||||
if(i>=0 && i<nHisto) {
|
||||
histo[i]->scale(x);
|
||||
} else {
|
||||
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)
|
||||
{
|
||||
tupleId = w1;
|
||||
tupleName = w2;
|
||||
tupleList = w3;
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
|
||||
|
||||
void Histo::fillTuple(const G4String& parname, G4double x)
|
||||
{
|
||||
if(verbose > 1) {
|
||||
G4cout << "fill tuple by parameter <" << parname << "> = " << x << G4endl;
|
||||
}
|
||||
#ifdef G4ANALYSIS_USE
|
||||
if(ntup) ntup->fill(ntup->findColumn(parname), (float)x);
|
||||
#endif
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
|
||||
|
||||
void Histo::addRow()
|
||||
{
|
||||
#ifdef G4ANALYSIS_USE
|
||||
if(ntup) ntup->addRow();
|
||||
#endif
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
|
||||
|
||||
void Histo::setFileName(const G4String& nam)
|
||||
{
|
||||
histName = nam;
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
|
||||
|
||||
void Histo::setFileType(const G4String& nam)
|
||||
{
|
||||
if(nam == "root" || nam == "hbook" || nam == "aida") histType = nam;
|
||||
else if(nam == "xml" || nam == "XML") histType = "aida";
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
|
||||
|
||||
@@ -0,0 +1,118 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * License and Disclaimer *
|
||||
// * *
|
||||
// * The Geant4 software is copyright of the Copyright Holders of *
|
||||
// * the Geant4 Collaboration. It is provided under the terms and *
|
||||
// * conditions of the Geant4 Software License, included in the file *
|
||||
// * LICENSE and available at http://cern.ch/geant4/license . These *
|
||||
// * include a list of copyright holders. *
|
||||
// * *
|
||||
// * Neither the authors of this software system, nor their employing *
|
||||
// * institutes,nor the agencies providing financial support for this *
|
||||
// * work make any representation or warranty, express or implied, *
|
||||
// * regarding this software system or assume any liability for its *
|
||||
// * use. Please see the license in the file LICENSE and URL above *
|
||||
// * for the full disclaimer and the limitation of liability. *
|
||||
// * *
|
||||
// * This code implementation is the result of the scientific and *
|
||||
// * technical work of the GEANT4 collaboration. *
|
||||
// * By using, copying, modifying or distributing the software (or *
|
||||
// * any work based on the software) you agree to acknowledge its *
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: HistoMessenger.cc,v 1.1 2008/08/22 18:30:27 vnivanch Exp $
|
||||
// GEANT4 tag $Name: geant4-09-02 $
|
||||
//
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
#include "HistoMessenger.hh"
|
||||
|
||||
#include <sstream>
|
||||
|
||||
#include "Histo.hh"
|
||||
#include "G4UIdirectory.hh"
|
||||
#include "G4UIcommand.hh"
|
||||
#include "G4UIparameter.hh"
|
||||
#include "G4UIcmdWithAString.hh"
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
HistoMessenger::HistoMessenger(Histo* manager)
|
||||
:histo (manager)
|
||||
{
|
||||
histoDir = new G4UIdirectory("/testem/histo/");
|
||||
histoDir->SetGuidance("histograms control");
|
||||
|
||||
factoryCmd = new G4UIcmdWithAString("/testem/histo/fileName",this);
|
||||
factoryCmd->SetGuidance("set name for the histograms file");
|
||||
|
||||
fileCmd = new G4UIcmdWithAString("/testem/histo/fileType",this);
|
||||
fileCmd->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)");
|
||||
//
|
||||
G4UIparameter* ih = new G4UIparameter("ih",'i',false);
|
||||
ih->SetGuidance("histo number : from 0 to MaxHisto-1");
|
||||
histoCmd->SetParameter(ih);
|
||||
//
|
||||
G4UIparameter* nbBins = new G4UIparameter("nbBins",'i',false);
|
||||
nbBins->SetGuidance("number of bins");
|
||||
nbBins->SetParameterRange("nbBins>0");
|
||||
histoCmd->SetParameter(nbBins);
|
||||
//
|
||||
G4UIparameter* valMin = new G4UIparameter("valMin",'d',false);
|
||||
valMin->SetGuidance("valMin, expressed in unit");
|
||||
histoCmd->SetParameter(valMin);
|
||||
//
|
||||
G4UIparameter* valMax = new G4UIparameter("valMax",'d',false);
|
||||
valMax->SetGuidance("valMax, expressed in unit");
|
||||
histoCmd->SetParameter(valMax);
|
||||
//
|
||||
G4UIparameter* unit = new G4UIparameter("unit",'s',true);
|
||||
unit->SetGuidance("if omitted, vmin and vmax are assumed dimensionless");
|
||||
unit->SetDefaultValue("none");
|
||||
histoCmd->SetParameter(unit);
|
||||
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
HistoMessenger::~HistoMessenger()
|
||||
{
|
||||
delete fileCmd;
|
||||
delete histoCmd;
|
||||
delete factoryCmd;
|
||||
delete histoDir;
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void HistoMessenger::SetNewValue(G4UIcommand* command,G4String newValues)
|
||||
{
|
||||
if (command == factoryCmd)
|
||||
histo->setFileName(newValues);
|
||||
|
||||
if (command == fileCmd)
|
||||
histo->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);
|
||||
}
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
@@ -25,7 +25,7 @@
|
||||
//
|
||||
//
|
||||
// $Id: PhysListEmLivermore.cc,v 1.2 2006/12/11 20:13:53 vnivanch Exp $
|
||||
// GEANT4 tag $Name: geant4-09-01 $
|
||||
// GEANT4 tag $Name: geant4-09-02 $
|
||||
//
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
//
|
||||
//
|
||||
// $Id: PhysListEmPenelope.cc,v 1.1 2006/11/22 18:56:21 vnivanch Exp $
|
||||
// GEANT4 tag $Name: geant4-09-01 $
|
||||
// GEANT4 tag $Name: geant4-09-02 $
|
||||
//
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
@@ -23,9 +23,8 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: PhysListEmStandard.cc,v 1.9 2007/07/28 16:39:31 vnivanch Exp $
|
||||
// GEANT4 tag $Name: geant4-09-01 $
|
||||
// $Id: PhysListEmStandard.cc,v 1.19 2008/11/20 20:34:50 vnivanch Exp $
|
||||
// GEANT4 tag $Name: geant4-09-02 $
|
||||
//
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
@@ -38,7 +37,7 @@
|
||||
#include "G4GammaConversion.hh"
|
||||
#include "G4PhotoElectricEffect.hh"
|
||||
|
||||
#include "G4MultipleScattering.hh"
|
||||
#include "G4eMultipleScattering.hh"
|
||||
#include "G4hMultipleScattering.hh"
|
||||
|
||||
#include "G4eIonisation.hh"
|
||||
@@ -50,9 +49,13 @@
|
||||
#include "G4MuPairProduction.hh"
|
||||
|
||||
#include "G4hIonisation.hh"
|
||||
#include "G4hBremsstrahlung.hh"
|
||||
#include "G4hPairProduction.hh"
|
||||
|
||||
#include "G4ionIonisation.hh"
|
||||
|
||||
#include "G4EmProcessOptions.hh"
|
||||
#include "G4MscStepLimitType.hh"
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
@@ -85,40 +88,49 @@ void PhysListEmStandard::ConstructProcess()
|
||||
|
||||
} else if (particleName == "e-") {
|
||||
//electron
|
||||
pmanager->AddProcess(new G4MultipleScattering, -1, 1,1);
|
||||
pmanager->AddProcess(new G4eIonisation, -1, 2,2);
|
||||
pmanager->AddProcess(new G4eBremsstrahlung, -1, 3,3);
|
||||
pmanager->AddProcess(new G4eMultipleScattering, -1, 1, 1);
|
||||
pmanager->AddProcess(new G4eIonisation, -1, 2, 2);
|
||||
pmanager->AddProcess(new G4eBremsstrahlung, -1, 3, 3);
|
||||
|
||||
} else if (particleName == "e+") {
|
||||
//positron
|
||||
pmanager->AddProcess(new G4MultipleScattering, -1, 1,1);
|
||||
pmanager->AddProcess(new G4eIonisation, -1, 2,2);
|
||||
pmanager->AddProcess(new G4eBremsstrahlung, -1, 3,3);
|
||||
pmanager->AddProcess(new G4eplusAnnihilation, 0,-1,4);
|
||||
pmanager->AddProcess(new G4eMultipleScattering, -1, 1, 1);
|
||||
pmanager->AddProcess(new G4eIonisation, -1, 2, 2);
|
||||
pmanager->AddProcess(new G4eBremsstrahlung, -1, 3, 3);
|
||||
pmanager->AddProcess(new G4eplusAnnihilation, 0,-1, 4);
|
||||
|
||||
} else if( particleName == "mu+" ||
|
||||
particleName == "mu-" ) {
|
||||
//muon
|
||||
pmanager->AddProcess(new G4hMultipleScattering,-1, 1,1);
|
||||
pmanager->AddProcess(new G4MuIonisation, -1, 2,2);
|
||||
pmanager->AddProcess(new G4MuBremsstrahlung, -1, 3,3);
|
||||
pmanager->AddProcess(new G4MuPairProduction, -1, 4,4);
|
||||
pmanager->AddProcess(new G4hMultipleScattering, -1, 1, 1);
|
||||
pmanager->AddProcess(new G4MuIonisation, -1, 2, 2);
|
||||
pmanager->AddProcess(new G4MuBremsstrahlung, -1, 3, 3);
|
||||
pmanager->AddProcess(new G4MuPairProduction, -1, 4, 4);
|
||||
|
||||
} else if( particleName == "proton" ||
|
||||
particleName == "pi-" ||
|
||||
particleName == "pi+" ) {
|
||||
//proton
|
||||
pmanager->AddProcess(new G4hMultipleScattering, -1, 1, 1);
|
||||
pmanager->AddProcess(new G4hIonisation, -1, 2, 2);
|
||||
pmanager->AddProcess(new G4hBremsstrahlung, -1, 3, 3);
|
||||
pmanager->AddProcess(new G4hPairProduction, -1, 4, 4);
|
||||
|
||||
} else if( particleName == "alpha" || particleName == "GenericIon" ) {
|
||||
pmanager->AddProcess(new G4hMultipleScattering,-1, 1,1);
|
||||
pmanager->AddProcess(new G4ionIonisation, -1, 2,2);
|
||||
} else if( particleName == "alpha" ||
|
||||
particleName == "He3" ||
|
||||
particleName == "GenericIon" ) {
|
||||
//Ions
|
||||
pmanager->AddProcess(new G4hMultipleScattering, -1, 1, 1);
|
||||
pmanager->AddProcess(new G4ionIonisation, -1, 2, 2);
|
||||
|
||||
} else if ((!particle->IsShortLived()) &&
|
||||
(particle->GetPDGCharge() != 0.0) &&
|
||||
(particle->GetParticleName() != "chargedgeantino")) {
|
||||
//all others charged particles except geantino
|
||||
pmanager->AddProcess(new G4hMultipleScattering,-1,1,1);
|
||||
pmanager->AddProcess(new G4hIonisation, -1,2,2);
|
||||
pmanager->AddProcess(new G4hMultipleScattering, -1, 1, 1);
|
||||
pmanager->AddProcess(new G4hIonisation, -1, 2, 2);
|
||||
}
|
||||
}
|
||||
G4EmProcessOptions opt;
|
||||
opt.SetStepFunction(0.2, 100*um);
|
||||
opt.SetSkin(1.);
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
+54
-9
@@ -23,15 +23,16 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// $Id: PhysListEmStandardIG.cc,v 1.3 2007/11/07 19:41:32 vnivanch Exp $
|
||||
// GEANT4 tag $Name: geant4-09-01 $
|
||||
// $Id: PhysListEmStandardNR.cc,v 1.3 2008/05/09 08:30:59 vnivanch Exp $
|
||||
// GEANT4 tag $Name: geant4-09-02 $
|
||||
//
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
#include "PhysListEmStandardIG.hh"
|
||||
#include "PhysListEmStandardNR.hh"
|
||||
#include "G4ParticleDefinition.hh"
|
||||
#include "G4ProcessManager.hh"
|
||||
#include "G4EmProcessOptions.hh"
|
||||
|
||||
#include "G4ComptonScattering.hh"
|
||||
#include "G4GammaConversion.hh"
|
||||
@@ -51,26 +52,31 @@
|
||||
|
||||
#include "G4hIonisation.hh"
|
||||
#include "G4ionIonisation.hh"
|
||||
#include "G4IonFluctuations.hh"
|
||||
#include "G4CoulombScattering.hh"
|
||||
|
||||
#include "G4DummyModel.hh"
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
PhysListEmStandardIG::PhysListEmStandardIG(const G4String& name)
|
||||
PhysListEmStandardNR::PhysListEmStandardNR(const G4String& name)
|
||||
: G4VPhysicsConstructor(name)
|
||||
{}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
PhysListEmStandardIG::~PhysListEmStandardIG()
|
||||
PhysListEmStandardNR::~PhysListEmStandardNR()
|
||||
{}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void PhysListEmStandardIG::ConstructProcess()
|
||||
void PhysListEmStandardNR::ConstructProcess()
|
||||
{
|
||||
// Add standard EM Processes
|
||||
|
||||
G4ScreenedNuclearRecoil* nucr = new G4ScreenedNuclearRecoil();
|
||||
G4double energyLimit = 100.*MeV;
|
||||
nucr->SetMaxEnergyForScattering(energyLimit);
|
||||
|
||||
theParticleIterator->reset();
|
||||
while( (*theParticleIterator)() ){
|
||||
@@ -106,17 +112,50 @@ void PhysListEmStandardIG::ConstructProcess()
|
||||
pmanager->AddProcess(new G4MuPairProduction, -1, 4,4);
|
||||
|
||||
} else if (particleName == "alpha" || particleName == "He3") {
|
||||
pmanager->AddProcess(new G4ionIonisation, -1, 1,1);
|
||||
G4hMultipleScattering* msc = new G4hMultipleScattering();
|
||||
G4DummyModel* dm = new G4DummyModel();
|
||||
dm->SetLowEnergyLimit(0.0);
|
||||
dm->SetHighEnergyLimit(energyLimit);
|
||||
msc->AddEmModel(0, dm);
|
||||
pmanager->AddProcess(msc, -1, 1,1);
|
||||
|
||||
G4ionIonisation* ion = new G4ionIonisation();
|
||||
ion->ActivateNuclearStopping(false);
|
||||
pmanager->AddProcess(ion, -1, 2, 2);
|
||||
|
||||
pmanager->AddDiscreteProcess(nucr);
|
||||
|
||||
} else if (particleName == "GenericIon" ) {
|
||||
pmanager->AddProcess(new G4ionIonisation, -1, 1,1);
|
||||
G4hMultipleScattering* msc = new G4hMultipleScattering();
|
||||
G4DummyModel* dm = new G4DummyModel();
|
||||
dm->SetLowEnergyLimit(0.0);
|
||||
dm->SetHighEnergyLimit(energyLimit);
|
||||
msc->AddEmModel(0, dm);
|
||||
pmanager->AddProcess(msc, -1, 1,1);
|
||||
|
||||
G4ionIonisation* ion = new G4ionIonisation();
|
||||
ion->ActivateNuclearStopping(false);
|
||||
ion->SetStepFunction(0.1, um);
|
||||
pmanager->AddProcess(ion, -1, 2, 2);
|
||||
|
||||
pmanager->AddDiscreteProcess(nucr);
|
||||
|
||||
} else if (particleName == "proton" ||
|
||||
particleName == "deuteron" ||
|
||||
particleName == "triton") {
|
||||
pmanager->AddProcess(new G4hIonisation, -1, 1,1);
|
||||
G4hMultipleScattering* msc = new G4hMultipleScattering();
|
||||
G4DummyModel* dm = new G4DummyModel();
|
||||
dm->SetLowEnergyLimit(0.0);
|
||||
dm->SetHighEnergyLimit(energyLimit);
|
||||
msc->AddEmModel(0, dm);
|
||||
pmanager->AddProcess(msc, -1, 1,1);
|
||||
|
||||
G4hIonisation* hion = new G4hIonisation();
|
||||
hion->SetFluctModel(new G4IonFluctuations());
|
||||
hion->SetStepFunction(0.1, 10.*um);
|
||||
hion->ActivateNuclearStopping(false);
|
||||
pmanager->AddProcess(hion, -1, 2, 2);
|
||||
|
||||
pmanager->AddDiscreteProcess(nucr);
|
||||
|
||||
} else if ((!particle->IsShortLived()) &&
|
||||
@@ -127,6 +166,12 @@ void PhysListEmStandardIG::ConstructProcess()
|
||||
pmanager->AddProcess(new G4hIonisation, -1, 2,2);
|
||||
}
|
||||
}
|
||||
G4EmProcessOptions opt;
|
||||
opt.SetMinEnergy(0.1*keV);
|
||||
opt.SetMaxEnergy(100.*GeV);
|
||||
opt.SetDEDXBinning(360);
|
||||
opt.SetLambdaBinning(360);
|
||||
opt.SetLinearLossLimit(1.e-6);
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
@@ -23,8 +23,8 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// $Id: PhysListEmStandardSS.cc,v 1.4 2007/11/07 19:41:32 vnivanch Exp $
|
||||
// GEANT4 tag $Name: geant4-09-01 $
|
||||
// $Id: PhysListEmStandardSS.cc,v 1.8 2008/11/16 19:17:39 maire Exp $
|
||||
// GEANT4 tag $Name: geant4-09-02 $
|
||||
//
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
@@ -37,7 +37,7 @@
|
||||
#include "G4GammaConversion.hh"
|
||||
#include "G4PhotoElectricEffect.hh"
|
||||
|
||||
#include "G4MultipleScattering.hh"
|
||||
#include "G4CoulombScattering.hh"
|
||||
|
||||
#include "G4eIonisation.hh"
|
||||
#include "G4eBremsstrahlung.hh"
|
||||
@@ -49,8 +49,8 @@
|
||||
|
||||
#include "G4hIonisation.hh"
|
||||
#include "G4ionIonisation.hh"
|
||||
#include "G4ionGasIonisation.hh"
|
||||
#include "G4CoulombScattering.hh"
|
||||
|
||||
#include "G4EmProcessOptions.hh"
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
@@ -83,44 +83,63 @@ void PhysListEmStandardSS::ConstructProcess()
|
||||
|
||||
} else if (particleName == "e-") {
|
||||
//electron
|
||||
pmanager->AddProcess(new G4eIonisation, -1, 1,1);
|
||||
pmanager->AddProcess(new G4eBremsstrahlung, -1, 2,2);
|
||||
pmanager->AddDiscreteProcess(new G4CoulombScattering);
|
||||
pmanager->AddProcess(new G4eIonisation, -1, 1, 1);
|
||||
pmanager->AddProcess(new G4eBremsstrahlung, -1, 2, 2);
|
||||
|
||||
} else if (particleName == "e+") {
|
||||
//positron
|
||||
pmanager->AddProcess(new G4eIonisation, -1, 1,1);
|
||||
pmanager->AddProcess(new G4eBremsstrahlung, -1, 2,2);
|
||||
pmanager->AddProcess(new G4eplusAnnihilation, 0,-1,3);
|
||||
pmanager->AddDiscreteProcess(new G4CoulombScattering);
|
||||
pmanager->AddProcess(new G4eIonisation, -1, 1, 1);
|
||||
pmanager->AddProcess(new G4eBremsstrahlung, -1, 2, 2);
|
||||
pmanager->AddProcess(new G4eplusAnnihilation, 0,-1, 3);
|
||||
|
||||
} else if (particleName == "mu+" ||
|
||||
particleName == "mu-" ) {
|
||||
//muon
|
||||
pmanager->AddProcess(new G4MuIonisation, -1, 1,1);
|
||||
pmanager->AddProcess(new G4MuBremsstrahlung, -1, 2,2);
|
||||
pmanager->AddProcess(new G4MuPairProduction, -1, 3,3);
|
||||
pmanager->AddDiscreteProcess(new G4CoulombScattering);
|
||||
//muon
|
||||
pmanager->AddDiscreteProcess(new G4CoulombScattering);
|
||||
pmanager->AddProcess(new G4MuIonisation, -1, 1, 1);
|
||||
pmanager->AddProcess(new G4MuBremsstrahlung, -1, 2, 2);
|
||||
pmanager->AddProcess(new G4MuPairProduction, -1, 3, 3);
|
||||
|
||||
} else if (particleName == "alpha" || particleName == "He3") {
|
||||
pmanager->AddProcess(new G4ionIonisation, -1, 1,1);
|
||||
pmanager->AddDiscreteProcess(new G4CoulombScattering);
|
||||
|
||||
} else if (particleName == "GenericIon" ) {
|
||||
pmanager->AddProcess(new G4ionGasIonisation, -1, 1,1);
|
||||
G4CoulombScattering* cs = new G4CoulombScattering();
|
||||
cs->SetBuildTableFlag(false);
|
||||
pmanager->AddDiscreteProcess(cs);
|
||||
|
||||
} else if (particleName == "alpha" ||
|
||||
particleName == "He3" ||
|
||||
particleName == "GenericIon") {
|
||||
pmanager->AddDiscreteProcess(new G4CoulombScattering);
|
||||
pmanager->AddProcess(new G4ionIonisation, -1, 1, 1);
|
||||
|
||||
} else if ((!particle->IsShortLived()) &&
|
||||
(particle->GetPDGCharge() != 0.0) &&
|
||||
(particle->GetParticleName() != "chargedgeantino")) {
|
||||
//all others charged particles except geantino
|
||||
pmanager->AddProcess(new G4hIonisation, -1,1,1);
|
||||
pmanager->AddDiscreteProcess(new G4CoulombScattering);
|
||||
pmanager->AddProcess(new G4hIonisation, -1, 1, 1);
|
||||
}
|
||||
}
|
||||
|
||||
// Em options
|
||||
//
|
||||
// Main options and setting parameters are shown here.
|
||||
// Several of them have default values.
|
||||
//
|
||||
G4EmProcessOptions emOptions;
|
||||
|
||||
//physics tables
|
||||
//
|
||||
emOptions.SetMinEnergy(100*eV); //default
|
||||
emOptions.SetMaxEnergy(100*TeV); //default
|
||||
emOptions.SetDEDXBinning(12*20); //default=12*7
|
||||
emOptions.SetLambdaBinning(12*20); //default=12*7
|
||||
emOptions.SetSplineFlag(true); //default
|
||||
|
||||
//energy loss
|
||||
//
|
||||
emOptions.SetStepFunction(0.2,50*um); //default=(0.2, 1*mm)
|
||||
emOptions.SetLinearLossLimit(1.e-2); //default
|
||||
|
||||
//ionization
|
||||
//
|
||||
emOptions.SetSubCutoff(false); //default
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
@@ -23,8 +23,8 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// $Id: PhysicsList.cc,v 1.27 2007/11/19 15:02:04 vnivanch Exp $
|
||||
// GEANT4 tag $Name: geant4-09-01 $
|
||||
// $Id: PhysicsList.cc,v 1.36 2008/11/21 12:53:13 vnivanch Exp $
|
||||
// GEANT4 tag $Name: geant4-09-02 $
|
||||
//
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
@@ -34,12 +34,15 @@
|
||||
|
||||
#include "PhysListEmStandard.hh"
|
||||
#include "PhysListEmStandardSS.hh"
|
||||
#include "PhysListEmStandardIG.hh"
|
||||
#include "PhysListEmStandardNR.hh"
|
||||
#include "PhysListEmLivermore.hh"
|
||||
#include "PhysListEmPenelope.hh"
|
||||
#include "G4EmStandardPhysics.hh"
|
||||
#include "G4EmStandardPhysics_option1.hh"
|
||||
#include "G4EmStandardPhysics_option2.hh"
|
||||
#include "G4EmStandardPhysics_option3.hh"
|
||||
|
||||
#include "G4DecayPhysics.hh"
|
||||
|
||||
#include "G4HadronElasticPhysics.hh"
|
||||
#include "G4HadronDElasticPhysics.hh"
|
||||
@@ -48,14 +51,17 @@
|
||||
#include "G4HadronInelasticQBBC.hh"
|
||||
#include "G4IonBinaryCascadePhysics.hh"
|
||||
|
||||
#include "G4EmProcessOptions.hh"
|
||||
|
||||
#include "G4LossTableManager.hh"
|
||||
#include "G4UnitsTable.hh"
|
||||
|
||||
#include "G4ProcessManager.hh"
|
||||
#include "G4Decay.hh"
|
||||
|
||||
#include "StepMax.hh"
|
||||
|
||||
#include "G4IonFluctuations.hh"
|
||||
#include "G4IonParametrisedLossModel.hh"
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
PhysicsList::PhysicsList() : G4VModularPhysicsList()
|
||||
@@ -77,8 +83,11 @@ PhysicsList::PhysicsList() : G4VModularPhysicsList()
|
||||
SetVerboseLevel(1);
|
||||
|
||||
// EM physics
|
||||
emPhysicsList = new PhysListEmStandard(emName = "standard");
|
||||
emPhysicsList = new G4EmStandardPhysics(1);
|
||||
emName = G4String("emstandard");
|
||||
|
||||
// Deacy physics and all particles
|
||||
decPhysicsList = new G4DecayPhysics();
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
@@ -87,68 +96,19 @@ PhysicsList::~PhysicsList()
|
||||
{
|
||||
delete pMessenger;
|
||||
delete emPhysicsList;
|
||||
for(size_t i=0; i<hadronPhys.size(); i++) delete hadronPhys[i];
|
||||
delete decPhysicsList;
|
||||
for(size_t i=0; i<hadronPhys.size(); i++) {delete hadronPhys[i];}
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
// Bosons
|
||||
#include "G4ChargedGeantino.hh"
|
||||
#include "G4Geantino.hh"
|
||||
#include "G4Gamma.hh"
|
||||
|
||||
// leptons
|
||||
#include "G4MuonPlus.hh"
|
||||
#include "G4MuonMinus.hh"
|
||||
#include "G4NeutrinoMu.hh"
|
||||
#include "G4AntiNeutrinoMu.hh"
|
||||
|
||||
#include "G4Electron.hh"
|
||||
#include "G4Positron.hh"
|
||||
#include "G4NeutrinoE.hh"
|
||||
#include "G4AntiNeutrinoE.hh"
|
||||
|
||||
// Hadrons
|
||||
#include "G4MesonConstructor.hh"
|
||||
#include "G4BaryonConstructor.hh"
|
||||
#include "G4IonConstructor.hh"
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void PhysicsList::ConstructParticle()
|
||||
{
|
||||
// pseudo-particles
|
||||
G4Geantino::GeantinoDefinition();
|
||||
G4ChargedGeantino::ChargedGeantinoDefinition();
|
||||
|
||||
// gamma
|
||||
G4Gamma::GammaDefinition();
|
||||
|
||||
// leptons
|
||||
G4Electron::ElectronDefinition();
|
||||
G4Positron::PositronDefinition();
|
||||
G4MuonPlus::MuonPlusDefinition();
|
||||
G4MuonMinus::MuonMinusDefinition();
|
||||
|
||||
G4NeutrinoE::NeutrinoEDefinition();
|
||||
G4AntiNeutrinoE::AntiNeutrinoEDefinition();
|
||||
G4NeutrinoMu::NeutrinoMuDefinition();
|
||||
G4AntiNeutrinoMu::AntiNeutrinoMuDefinition();
|
||||
|
||||
// mesons
|
||||
G4MesonConstructor mConstructor;
|
||||
mConstructor.ConstructParticle();
|
||||
|
||||
// barions
|
||||
G4BaryonConstructor bConstructor;
|
||||
bConstructor.ConstructParticle();
|
||||
|
||||
// ions
|
||||
G4IonConstructor iConstructor;
|
||||
iConstructor.ConstructParticle();
|
||||
decPhysicsList->ConstructParticle();
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void PhysicsList::ConstructProcess()
|
||||
{
|
||||
// transportation
|
||||
@@ -158,49 +118,33 @@ void PhysicsList::ConstructProcess()
|
||||
// electromagnetic physics list
|
||||
//
|
||||
emPhysicsList->ConstructProcess();
|
||||
em_config.AddModels();
|
||||
|
||||
// decay physics list
|
||||
//
|
||||
decPhysicsList->ConstructProcess();
|
||||
|
||||
// hadronic physics lists
|
||||
for(size_t i=0; i<hadronPhys.size(); i++) hadronPhys[i]->ConstructProcess();
|
||||
|
||||
// decay process
|
||||
//
|
||||
G4Decay* fDecayProcess = new G4Decay();
|
||||
|
||||
theParticleIterator->reset();
|
||||
while( (*theParticleIterator)() ){
|
||||
G4ParticleDefinition* particle = theParticleIterator->value();
|
||||
G4ProcessManager* pmanager = particle->GetProcessManager();
|
||||
|
||||
if (fDecayProcess->IsApplicable(*particle) && !particle->IsShortLived()) {
|
||||
|
||||
pmanager ->AddProcess(fDecayProcess);
|
||||
|
||||
// set ordering for PostStepDoIt and AtRestDoIt
|
||||
pmanager ->SetProcessOrdering(fDecayProcess, idxPostStep);
|
||||
pmanager ->SetProcessOrdering(fDecayProcess, idxAtRest);
|
||||
|
||||
}
|
||||
for(size_t i=0; i<hadronPhys.size(); i++) {
|
||||
hadronPhys[i]->ConstructProcess();
|
||||
}
|
||||
|
||||
// step limitation (as a full process)
|
||||
//
|
||||
AddStepMax();
|
||||
|
||||
G4EmProcessOptions opt;
|
||||
opt.SetDEDXBinning(480);
|
||||
AddStepMax();
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void PhysicsList::AddPhysicsList(const G4String& name)
|
||||
{
|
||||
if (verboseLevel>-1) {
|
||||
if (verboseLevel>1) {
|
||||
G4cout << "PhysicsList::AddPhysicsList: <" << name << ">" << G4endl;
|
||||
}
|
||||
|
||||
if (name == emName) return;
|
||||
|
||||
if (name == "standard") {
|
||||
if (name == "standard_local") {
|
||||
|
||||
emName = name;
|
||||
delete emPhysicsList;
|
||||
@@ -210,7 +154,7 @@ void PhysicsList::AddPhysicsList(const G4String& name)
|
||||
|
||||
emName = name;
|
||||
delete emPhysicsList;
|
||||
emPhysicsList = new G4EmStandardPhysics();
|
||||
emPhysicsList = new G4EmStandardPhysics(1);
|
||||
|
||||
} else if (name == "emstandard_opt1") {
|
||||
|
||||
@@ -223,6 +167,12 @@ void PhysicsList::AddPhysicsList(const G4String& name)
|
||||
emName = name;
|
||||
delete emPhysicsList;
|
||||
emPhysicsList = new G4EmStandardPhysics_option2();
|
||||
|
||||
} else if (name == "emstandard_opt3") {
|
||||
|
||||
emName = name;
|
||||
delete emPhysicsList;
|
||||
emPhysicsList = new G4EmStandardPhysics_option3();
|
||||
|
||||
} else if (name == "standardSS") {
|
||||
|
||||
@@ -234,7 +184,18 @@ void PhysicsList::AddPhysicsList(const G4String& name)
|
||||
|
||||
emName = name;
|
||||
delete emPhysicsList;
|
||||
emPhysicsList = new PhysListEmStandardIG(name);
|
||||
emPhysicsList = new PhysListEmStandardNR(name);
|
||||
|
||||
} else if (name == "standardICRU73") {
|
||||
|
||||
emName = name;
|
||||
delete emPhysicsList;
|
||||
emPhysicsList = new PhysListEmStandard(name);
|
||||
em_config.SetExtraEmModel("GenericIon","ionIoni",
|
||||
new G4IonParametrisedLossModel(),
|
||||
"",0.0, 100.0*TeV,
|
||||
new G4IonFluctuations());
|
||||
G4cout << "standardICRU73" << G4endl;
|
||||
|
||||
} else if (name == "livermore") {
|
||||
emName = name;
|
||||
@@ -280,8 +241,6 @@ void PhysicsList::AddPhysicsList(const G4String& name)
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
#include "StepMax.hh"
|
||||
|
||||
void PhysicsList::AddStepMax()
|
||||
{
|
||||
// Step limitation seen as a process
|
||||
@@ -289,13 +248,13 @@ void PhysicsList::AddStepMax()
|
||||
|
||||
theParticleIterator->reset();
|
||||
while ((*theParticleIterator)()){
|
||||
G4ParticleDefinition* particle = theParticleIterator->value();
|
||||
G4ProcessManager* pmanager = particle->GetProcessManager();
|
||||
G4ParticleDefinition* particle = theParticleIterator->value();
|
||||
G4ProcessManager* pmanager = particle->GetProcessManager();
|
||||
|
||||
if (stepMaxProcess->IsApplicable(*particle) && pmanager)
|
||||
{
|
||||
pmanager ->AddDiscreteProcess(stepMaxProcess);
|
||||
}
|
||||
if (stepMaxProcess->IsApplicable(*particle) && pmanager)
|
||||
{
|
||||
pmanager ->AddDiscreteProcess(stepMaxProcess);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
// $Id: PhysicsListMessenger.cc,v 1.3 2006/06/29 16:58:37 gunter Exp $
|
||||
// GEANT4 tag $Name: geant4-09-01 $
|
||||
// GEANT4 tag $Name: geant4-09-02 $
|
||||
//
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
// $Id: PrimaryGeneratorAction.cc,v 1.2 2006/06/29 16:58:39 gunter Exp $
|
||||
// GEANT4 tag $Name: geant4-09-01 $
|
||||
// GEANT4 tag $Name: geant4-09-02 $
|
||||
//
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
// $Id: PrimaryGeneratorMessenger.cc,v 1.3 2006/06/29 16:58:41 gunter Exp $
|
||||
// GEANT4 tag $Name: geant4-09-01 $
|
||||
// GEANT4 tag $Name: geant4-09-02 $
|
||||
//
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
@@ -23,8 +23,8 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// $Id: RunAction.cc,v 1.20 2007/06/12 14:01:13 vnivanch Exp $
|
||||
// GEANT4 tag $Name: geant4-09-01 $
|
||||
// $Id: RunAction.cc,v 1.24 2008/08/22 18:30:27 vnivanch Exp $
|
||||
// GEANT4 tag $Name: geant4-09-02 $
|
||||
//
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
@@ -41,30 +41,21 @@
|
||||
#include "G4ios.hh"
|
||||
|
||||
#include "Randomize.hh"
|
||||
|
||||
#ifdef G4ANALYSIS_USE
|
||||
#include "AIDA/AIDA.h"
|
||||
#endif
|
||||
#include "Histo.hh"
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
RunAction::RunAction(DetectorConstruction* det, PhysicsList* phys,
|
||||
PrimaryGeneratorAction* kin)
|
||||
:detector(det), physics(phys), kinematic(kin), af(0), tree(0)
|
||||
:detector(det), physics(phys), kinematic(kin)
|
||||
{
|
||||
tallyEdep = new G4double[MaxTally];
|
||||
binLength = offsetX = 0.;
|
||||
histo[0] = 0;
|
||||
|
||||
#ifdef G4ANALYSIS_USE
|
||||
// Creating the analysis factory
|
||||
af = AIDA_createAnalysisFactory();
|
||||
if(!af) {
|
||||
G4cout << "RunAction::RunAction() :"
|
||||
<< " problem creating the AIDA analysis factory."
|
||||
<< G4endl;
|
||||
}
|
||||
#endif
|
||||
histo = new Histo();
|
||||
histo->setFileName("testem7");
|
||||
histo->add1D("1","Edep (MeV/mm) along absorber (mm)", 100, 0, 100);
|
||||
histo->add1D("2","Edep (MeV/mm) along absorber zoomed (mm)", 100, 0, 100);
|
||||
histo->add1D("3","Projectile range (mm)", 100, 0, 100);
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
@@ -72,74 +63,14 @@ RunAction::RunAction(DetectorConstruction* det, PhysicsList* phys,
|
||||
RunAction::~RunAction()
|
||||
{
|
||||
delete [] tallyEdep;
|
||||
|
||||
#ifdef G4ANALYSIS_USE
|
||||
delete af;
|
||||
#endif
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void RunAction::bookHisto()
|
||||
{
|
||||
length = detector->GetAbsorSizeX();
|
||||
G4double stepMax = physics->GetStepMaxProcess()->GetMaxStep();
|
||||
const G4int nbmin = 100;
|
||||
G4int nbBins = (int)(0.5 + length/stepMax);
|
||||
if (nbBins < nbmin) nbBins = nbmin;
|
||||
binLength = length/nbBins;
|
||||
offsetX = 0.5*length;
|
||||
|
||||
#ifdef G4ANALYSIS_USE
|
||||
if (!af) return;
|
||||
|
||||
// Create a tree mapped to an hbook file.
|
||||
G4bool readOnly = false;
|
||||
G4bool createNew = true;
|
||||
G4String options = "--noErrors uncompress";
|
||||
AIDA::ITreeFactory* tf = af->createTreeFactory();
|
||||
tree = tf->create("testem7.hbook","hbook", readOnly, createNew, options);
|
||||
//tree = tf->create("testem7.root", "root",readOnly, createNew, options);
|
||||
//tree = tf->create("testem7.XML" , "XML" ,readOnly, createNew, options);
|
||||
delete tf;
|
||||
if (!tree) {
|
||||
G4cout << "RunAction::bookHisto()" << G4endl;
|
||||
return;
|
||||
}
|
||||
|
||||
// Create a histogram factory, whose histograms will be handled by the tree
|
||||
AIDA::IHistogramFactory* hf = af->createHistogramFactory(*tree);
|
||||
|
||||
// Create histogram
|
||||
histo[0] = hf->createHistogram1D("1","Edep (MeV/mm) along absorber (mm)",
|
||||
nbBins, 0, length/mm);
|
||||
|
||||
delete hf;
|
||||
G4cout << "\n----> Histogram Tree opened" << G4endl;
|
||||
#endif
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void RunAction::cleanHisto()
|
||||
{
|
||||
#ifdef G4ANALYSIS_USE
|
||||
tree->commit(); // Writing the histograms to the file
|
||||
tree->close(); // and closing the tree (and the file)
|
||||
delete tree;
|
||||
tree = 0;
|
||||
|
||||
G4cout << "\n----> Histogram Tree saved" << G4endl;
|
||||
#endif
|
||||
delete histo;
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void RunAction::FillHisto(G4int ih, G4double x, G4double weight)
|
||||
{
|
||||
#ifdef G4ANALYSIS_USE
|
||||
if(histo[ih]) histo[ih]->fill(x, weight);
|
||||
#endif
|
||||
histo->fill(ih, x, weight);
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
@@ -155,10 +86,26 @@ void RunAction::BeginOfRunAction(const G4Run* aRun)
|
||||
//initialize projected range, tallies, Ebeam, and book histograms
|
||||
//
|
||||
nPrimarySteps = 0;
|
||||
nRange = 0;
|
||||
projRange = projRange2 = 0.;
|
||||
edeptot = eniel = 0.;
|
||||
for (G4int j=0; j<MaxTally; j++) tallyEdep[j] = 0.;
|
||||
kinematic->ResetEbeamCumul();
|
||||
bookHisto();
|
||||
|
||||
// define "1" histogram binning
|
||||
length = detector->GetAbsorSizeX();
|
||||
G4double stepMax = physics->GetStepMaxProcess()->GetMaxStep();
|
||||
const G4int nbmin = 100;
|
||||
G4int nbBins = (G4int)(0.5 + length/stepMax);
|
||||
if (nbBins < nbmin) nbBins = nbmin;
|
||||
binLength = length/nbBins;
|
||||
offsetX = 0.5*length;
|
||||
|
||||
// histogram "1" is defined by the length of the target
|
||||
// zoomed histograms are defined by UI command
|
||||
histo->setHisto1D(0, nbBins, 0, length, mm);
|
||||
|
||||
histo->book();
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
@@ -184,17 +131,29 @@ void RunAction::EndOfRunAction(const G4Run* aRun)
|
||||
|
||||
//compute projected range and straggling
|
||||
//
|
||||
projRange /= NbofEvents; projRange2 /= NbofEvents;
|
||||
if(nRange > 0) {
|
||||
projRange /= nRange;
|
||||
projRange2 /= nRange;
|
||||
}
|
||||
G4double rms = projRange2 - projRange*projRange;
|
||||
if (rms>0.) rms = std::sqrt(rms); else rms = 0.;
|
||||
|
||||
G4double nstep = G4double(nPrimarySteps)/G4double(NbofEvents);
|
||||
|
||||
G4cout.precision(6);
|
||||
G4cout << "\n projected Range= "<< G4BestUnit(projRange,"Length")
|
||||
G4cout << "\n Projected Range= "<< G4BestUnit(projRange,"Length")
|
||||
<< " rms= " << G4BestUnit( rms,"Length")
|
||||
<< G4endl;
|
||||
G4cout << " mean number of primary steps = "<< nstep << G4endl;
|
||||
G4cout << " Mean number of primary steps = "<< nstep << G4endl;
|
||||
|
||||
//compute energy deposition and NIEL
|
||||
//
|
||||
edeptot /= NbofEvents;
|
||||
G4cout << " Total energy deposit= "<< G4BestUnit(edeptot,"Energy")
|
||||
<< G4endl;
|
||||
eniel /= NbofEvents;
|
||||
G4cout << " NIEL energy deposit = "<< G4BestUnit(eniel,"Energy")
|
||||
<< G4endl;
|
||||
|
||||
//print dose in tallies
|
||||
//
|
||||
@@ -216,15 +175,12 @@ void RunAction::EndOfRunAction(const G4Run* aRun)
|
||||
G4cout << G4endl;
|
||||
}
|
||||
|
||||
#ifdef G4ANALYSIS_USE
|
||||
// normalize histogram
|
||||
G4double fac = (mm/MeV)/(NbofEvents * binLength);
|
||||
histo[0]->scale(fac);
|
||||
#endif
|
||||
|
||||
for (G4int j=0; j<3; j++) {histo->scale(j, fac);}
|
||||
|
||||
// save and clean histo
|
||||
cleanHisto();
|
||||
histo->save();
|
||||
|
||||
// show Rndm status
|
||||
CLHEP::HepRandom::showEngineStatus();
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
// $Id: StepMax.cc,v 1.5 2006/06/29 16:58:45 gunter Exp $
|
||||
// GEANT4 tag $Name: geant4-09-01 $
|
||||
// GEANT4 tag $Name: geant4-09-02 $
|
||||
//
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
// $Id: StepMaxMessenger.cc,v 1.3 2006/06/29 16:58:47 gunter Exp $
|
||||
// GEANT4 tag $Name: geant4-09-01 $
|
||||
// GEANT4 tag $Name: geant4-09-02 $
|
||||
//
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
@@ -23,8 +23,8 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// $Id: SteppingAction.cc,v 1.11 2007/06/12 14:01:13 vnivanch Exp $
|
||||
// GEANT4 tag $Name: geant4-09-01 $
|
||||
// $Id: SteppingAction.cc,v 1.14 2008/08/22 18:30:27 vnivanch Exp $
|
||||
// GEANT4 tag $Name: geant4-09-02 $
|
||||
//
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
@@ -50,26 +50,31 @@ SteppingAction::~SteppingAction()
|
||||
|
||||
void SteppingAction::UserSteppingAction(const G4Step* aStep)
|
||||
{
|
||||
G4double edep = aStep->GetTotalEnergyDeposit();
|
||||
if (edep <= 0.) return;
|
||||
G4double edep = aStep->GetTotalEnergyDeposit();
|
||||
if (edep <= 0.) return;
|
||||
|
||||
if(aStep->GetTrack()->GetTrackID() == 1) runAction->AddPrimaryStep();
|
||||
// G4cout << "edep= " << edep << "NIEL= " << aStep->GetNonIonizingEnergyDeposit()<<G4endl;
|
||||
|
||||
runAction->FillEdep(edep,aStep->GetNonIonizingEnergyDeposit());
|
||||
|
||||
if(aStep->GetTrack()->GetTrackID() == 1) runAction->AddPrimaryStep();
|
||||
|
||||
//Bragg curve
|
||||
//
|
||||
G4StepPoint* prePoint = aStep->GetPreStepPoint();
|
||||
G4StepPoint* postPoint = aStep->GetPostStepPoint();
|
||||
//Bragg curve
|
||||
//
|
||||
G4StepPoint* prePoint = aStep->GetPreStepPoint();
|
||||
G4StepPoint* postPoint = aStep->GetPostStepPoint();
|
||||
|
||||
G4double x1 = prePoint->GetPosition().x(), x2 = postPoint->GetPosition().x();
|
||||
G4double x = runAction->GetOffsetX() + x1 + G4UniformRand()*(x2-x1);
|
||||
runAction->FillHisto(0, x/mm , edep);
|
||||
G4double x1 = prePoint->GetPosition().x(), x2 = postPoint->GetPosition().x();
|
||||
G4double x = runAction->GetOffsetX() + x1 + G4UniformRand()*(x2-x1);
|
||||
runAction->FillHisto(0, x/mm , edep);
|
||||
runAction->FillHisto(1, x/mm , edep);
|
||||
|
||||
//fill tallies
|
||||
//
|
||||
G4TouchableHandle touchable = prePoint->GetTouchableHandle();
|
||||
G4LogicalVolume* lVolume = touchable->GetVolume()->GetLogicalVolume();
|
||||
if (lVolume == detector->GetLogicalTally())
|
||||
runAction->FillTallyEdep(touchable->GetCopyNumber(), edep);
|
||||
//fill tallies
|
||||
//
|
||||
G4TouchableHandle touchable = prePoint->GetTouchableHandle();
|
||||
G4LogicalVolume* lVolume = touchable->GetVolume()->GetLogicalVolume();
|
||||
if (lVolume == detector->GetLogicalTally())
|
||||
runAction->FillTallyEdep(touchable->GetCopyNumber(), edep);
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
// $Id: SteppingVerbose.cc,v 1.3 2006/06/29 16:58:51 gunter Exp $
|
||||
// GEANT4 tag $Name: geant4-09-01 $
|
||||
// GEANT4 tag $Name: geant4-09-02 $
|
||||
//
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
@@ -23,8 +23,8 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// $Id: TrackingAction.cc,v 1.3 2006/11/22 17:58:11 vnivanch Exp $
|
||||
// GEANT4 tag $Name: geant4-09-01 $
|
||||
// $Id: TrackingAction.cc,v 1.5 2008/08/22 18:30:27 vnivanch Exp $
|
||||
// GEANT4 tag $Name: geant4-09-02 $
|
||||
//
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
@@ -49,7 +49,10 @@ void TrackingAction::PostUserTrackingAction(const G4Track* aTrack)
|
||||
if (aTrack->GetTrackID() == 1) {
|
||||
G4double x = aTrack->GetPosition().x() + runAction->GetOffsetX();
|
||||
if(x > runAction->GetLength()) x = runAction->GetLength();
|
||||
runAction->AddProjRange(x);
|
||||
//G4cout << " range= " << x << " x= " << aTrack->GetPosition().x()
|
||||
// << " ofset= " << runAction->GetOffsetX() << G4endl;
|
||||
if(x > 0.0) runAction->AddProjRange(x);
|
||||
runAction->FillHisto(2, x/mm, 1.0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user