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,58 @@
//
// ********************************************************************
// * 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: GB01ActionInitialization.cc 68058 2013-03-13 14:47:43Z gcosmo $
//
/// \file GB01ActionInitialization.cc
/// \brief Implementation of the GB01ActionInitialization class
#include "GB01ActionInitialization.hh"
#include "GB01PrimaryGeneratorAction.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
GB01ActionInitialization::GB01ActionInitialization()
: G4VUserActionInitialization()
{}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
GB01ActionInitialization::~GB01ActionInitialization()
{;}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void GB01ActionInitialization::BuildForMaster() const
{
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void GB01ActionInitialization::Build() const
{
SetUserAction(new GB01PrimaryGeneratorAction);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -0,0 +1,181 @@
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
#include "GB01BOptrChangeCrossSection.hh"
#include "G4BiasingProcessInterface.hh"
#include "G4BOptnChangeCrossSection.hh"
#include "G4ParticleDefinition.hh"
#include "G4ParticleTable.hh"
#include "G4VProcess.hh"
#include "Randomize.hh"
GB01BOptrChangeCrossSection::GB01BOptrChangeCrossSection(G4String particleName,
G4String name)
: G4VBiasingOperator(name),
fFirstProcess(0),
fLastProcess(0),
fSetup(true)
{
fParticleToBias = G4ParticleTable::GetParticleTable()->FindParticle(particleName);
if ( fParticleToBias == 0 )
{
G4ExceptionDescription ed;
ed << "Particle `" << particleName << "' not found !" << G4endl;
G4Exception("GB01BOptrChangeCrossSection(...)",
"exGB01.01",
JustWarning,
ed);
}
}
GB01BOptrChangeCrossSection::~GB01BOptrChangeCrossSection()
{
for ( std::map< const G4BiasingProcessInterface*, G4BOptnChangeCrossSection* >::iterator
it = fChangeCrossSectionOperations.begin() ;
it != fChangeCrossSectionOperations.end() ;
it++ ) delete (*it).second;
}
G4VBiasingOperation*
GB01BOptrChangeCrossSection::ProposeOccurenceBiasingOperation(const G4Track* track,
const G4BiasingProcessInterface*
callingProcess)
{
// -- Check if current particle type is the one to bias:
if ( track->GetDefinition() != fParticleToBias ) return 0;
// -----------------------------------------------------------------------
// -- Setup stage ( Might consider moving this in a less called method. ):
// -----------------------------------------------------------------------
// -- Start by collecting processes under biasing, create needed biasing operations
// -- and assocation operations to these processes:
if ( fSetup )
{
if ( ( fFirstProcess == 0 ) &&
( callingProcess->GetIsFirstPostStepGPILInterface() ) ) fFirstProcess = callingProcess;
if ( fLastProcess == 0 )
{
G4String operationName = "XSchange-" +
callingProcess->GetWrappedProcess()->GetProcessName();
fChangeCrossSectionOperations[callingProcess] =
new G4BOptnChangeCrossSection(operationName);
if ( callingProcess->GetIsLastPostStepGPILInterface() )
{
fLastProcess = callingProcess;
fSetup = false;
}
}
}
// ---------------------------------------------------------------------
// -- select and setup the biasing operation for current callingProcess:
// ---------------------------------------------------------------------
// -- Check if the analog cross-section well defined : for example, the conversion
// -- process for a gamma below e+e- creation threshold has an DBL_MAX interaction
// -- length. Nothing is done in this case (ie, let analog process to deal with the case)
G4double analogInteractionLength =
callingProcess->GetWrappedProcess()->GetCurrentInteractionLength();
if ( analogInteractionLength > DBL_MAX/10. ) return 0;
// -- Analog cross-section is well-defined:
G4double analogXS = 1./analogInteractionLength;
// -- Choose a constant cross-section bias. But at this level, this factor can be made
// -- direction dependent, like in the exponential transform MCNP case, or it
// -- can be chosen differently, depending on the process, etc.
G4double XStransformation = 2.0 ;
// -- fetch the operation associated to this callingProcess:
G4BOptnChangeCrossSection* operation = fChangeCrossSectionOperations[callingProcess];
// -- get the operation that was proposed to the process in the previous step:
G4VBiasingOperation* previousOperation = callingProcess->GetPreviousOccurenceBiasingOperation();
// -- now setup the operation to be returned to the process: this
// -- consists in setting the biased cross-section, and in asking
// -- the operation to sample its exponential interaction law.
// -- To do this, to first order, the two lines:
// operation->SetBiasedCrossSection( XStransformation * analogXS );
// operation->Sample();
// -- are correct and sufficient.
// -- But, to avoid having to shoot a random number each time, we sample
// -- only on the first time the operation is proposed, or if the interaction
// -- occured. If the interaction did not occur for the process in the previous,
// -- we update the number of interaction length instead of resampling.
if ( previousOperation == 0 )
{
operation->SetBiasedCrossSection( XStransformation * analogXS );
operation->Sample();
}
else
{
if ( previousOperation != operation )
{
// -- should not happen !
G4ExceptionDescription ed;
ed << " Logic problem in operation handling !" << G4endl;
G4Exception("GB01BOptrChangeCrossSection::ProposeOccurenceBiasingOperation(...)",
"exGB01.02",
JustWarning,
ed);
return 0;
}
if ( operation->GetInteractionOccured() )
{
operation->SetBiasedCrossSection( XStransformation * analogXS );
operation->Sample();
}
else
{
operation->UpdateForStep( callingProcess->GetPreviousStepSize() );
operation->SetBiasedCrossSection( XStransformation * analogXS );
}
}
// operation->SetBiasedCrossSection( XStransformation * analogXS );
// operation->Sample();
return operation;
}
void GB01BOptrChangeCrossSection::
OperationApplied(const G4BiasingProcessInterface* callingProcess,
G4BiasingAppliedCase,
G4VBiasingOperation* occurenceOperationApplied,
G4double,
G4VBiasingOperation*,
const G4VParticleChange* )
{
G4BOptnChangeCrossSection* operation = fChangeCrossSectionOperations[callingProcess];
if ( operation == occurenceOperationApplied ) operation->SetInteractionOccured();
}
@@ -0,0 +1,109 @@
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
#include "GB01BOptrMultiParticleChangeCrossSection.hh"
#include "G4BiasingProcessInterface.hh"
#include "GB01BOptrChangeCrossSection.hh"
#include "G4ParticleDefinition.hh"
#include "G4ParticleTable.hh"
GB01BOptrMultiParticleChangeCrossSection::GB01BOptrMultiParticleChangeCrossSection()
: G4VBiasingOperator("TestManyExponentialTransform")
{}
void GB01BOptrMultiParticleChangeCrossSection::AddParticle(G4String particleName)
{
const G4ParticleDefinition* particle =
G4ParticleTable::GetParticleTable()->FindParticle( particleName );
if ( particle == 0 )
{
G4ExceptionDescription ed;
ed << "Particle `" << particleName << "' not found !" << G4endl;
G4Exception("GB01BOptrMultiParticleChangeCrossSection::AddParticle(...)",
"exGB01.02",
JustWarning,
ed);
return;
}
GB01BOptrChangeCrossSection* optr = new GB01BOptrChangeCrossSection(particleName);
fParticlesToBias.push_back( particle );
fBOptrForParticle[ particle ] = optr;
}
G4VBiasingOperation*
GB01BOptrMultiParticleChangeCrossSection::
ProposeOccurenceBiasingOperation(const G4Track* track,
const G4BiasingProcessInterface* callingProcess)
{
// -- examples of limitations imposed to applied the biasing:
// -- limit application of biasing to primary particles only:
if ( track->GetParentID() != 0 ) return 0;
// -- limit to at most 5 biased interactions:
if ( fnInteractions > 4 ) return 0;
// -- and limit to a weight of at least 0.05:
if ( track->GetWeight() < 0.05 ) return 0;
if ( fCurrentOperator ) return fCurrentOperator->
GetProposedOccurenceBiasingOperation(track, callingProcess);
else return 0;
}
void GB01BOptrMultiParticleChangeCrossSection::StartTracking( const G4Track* track )
{
// -- fetch the underneath biasing operator, if any, for the current particle type:
const G4ParticleDefinition* definition = track->GetParticleDefinition();
std::map < const G4ParticleDefinition*, GB01BOptrChangeCrossSection* > :: iterator
it = fBOptrForParticle.find( definition );
fCurrentOperator = 0;
if ( it != fBOptrForParticle.end() ) fCurrentOperator = (*it).second;
// -- reset count for number of biased interactions:
fnInteractions = 0;
}
void
GB01BOptrMultiParticleChangeCrossSection::
OperationApplied( const G4BiasingProcessInterface* callingProcess,
G4BiasingAppliedCase biasingCase,
G4VBiasingOperation* occurenceOperationApplied,
G4double weightForOccurenceInteraction,
G4VBiasingOperation* finalStateOperationApplied,
const G4VParticleChange* particleChangeProduced )
{
// -- count number of biased interactions:
fnInteractions++;
// -- inform the underneath biasing operator that a biased interaction occured:
if ( fCurrentOperator ) fCurrentOperator->ReportOperationApplied( callingProcess,
biasingCase,
occurenceOperationApplied,
weightForOccurenceInteraction,
finalStateOperationApplied,
particleChangeProduced );
}
@@ -0,0 +1,109 @@
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
#include "GB01DetectorConstruction.hh"
#include "G4SystemOfUnits.hh"
#include "G4Material.hh"
#include "G4NistManager.hh"
#include "G4Box.hh"
#include "G4LogicalVolume.hh"
#include "G4PVPlacement.hh"
#include "G4UniformMagField.hh"
#include "G4VisAttributes.hh"
#include "G4Colour.hh"
#include "G4NistManager.hh"
#include "GB01BOptrMultiParticleChangeCrossSection.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
GB01DetectorConstruction::GB01DetectorConstruction()
{}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
GB01DetectorConstruction::~GB01DetectorConstruction()
{}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4VPhysicalVolume* GB01DetectorConstruction::Construct()
{
G4Material* worldMaterial = G4NistManager::Instance()->FindOrBuildMaterial("G4_Galactic");
G4Material* defaultMaterial = G4NistManager::Instance()->FindOrBuildMaterial("G4_lN2");
G4VSolid* solidWorld = new G4Box("World", 10*m, 10*m, 10*m );
G4LogicalVolume* logicWorld = new G4LogicalVolume(solidWorld, //its solid
worldMaterial, //its material
"World"); //its name
G4PVPlacement* physiWorld = new G4PVPlacement(0, //no rotation
G4ThreeVector(), //at (0,0,0)
logicWorld, //its logical volume
"World", //its name
0, //its mother volume
false, //no boolean operation
0); //copy number
// -----------------------------------
// -- volume where biasing is applied:
// -----------------------------------
G4double halfZ = 10*cm;
G4VSolid* solidTest = new G4Box("test.solid", 1*m, 1*m, halfZ );
G4LogicalVolume* logicTest = new G4LogicalVolume(solidTest, //its solid
defaultMaterial, //its material
"test.logical"); //its name
new G4PVPlacement(0, // no rotation
G4ThreeVector(0,0, halfZ), // volume entrance at (0,0,0)
logicTest, // its logical volume
"test.phys", // its name
logicWorld, // its mother volume
false, // no boolean operation
0); // copy number
// ----------------------------------------------
// -- operator creation and attachment to volume:
// ----------------------------------------------
GB01BOptrMultiParticleChangeCrossSection* testMany =
new GB01BOptrMultiParticleChangeCrossSection();
testMany->AddParticle("gamma");
testMany->AddParticle("neutron");
testMany->AttachTo(logicTest);
G4cout << " Attaching biasing operator " << testMany->GetName()
<< " to logical volume " << logicTest->GetName()
<< G4endl;
return physiWorld;
}
@@ -0,0 +1,65 @@
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
#include "GB01PrimaryGeneratorAction.hh"
#include "G4SystemOfUnits.hh"
#include "G4Event.hh"
#include "G4ParticleGun.hh"
#include "G4ParticleTable.hh"
#include "G4ParticleDefinition.hh"
#include "Randomize.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
GB01PrimaryGeneratorAction::GB01PrimaryGeneratorAction()
{
G4int n_particle = 1;
particleGun = new G4ParticleGun(n_particle);
// default particle kinematic
G4ParticleTable* particleTable = G4ParticleTable::GetParticleTable();
G4String particleName;
G4ParticleDefinition* particle = particleTable->FindParticle(particleName="gamma");
particleGun->SetParticleDefinition(particle);
particleGun->SetParticleMomentumDirection(G4ThreeVector(0.,0.,1.));
particleGun->SetParticleEnergy(100.*MeV);
particleGun->SetParticlePosition(G4ThreeVector(0.,0.,-50*cm));
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
GB01PrimaryGeneratorAction::~GB01PrimaryGeneratorAction()
{
delete particleGun;
}
void GB01PrimaryGeneratorAction::GeneratePrimaries(G4Event* anEvent)
{
particleGun->GeneratePrimaryVertex(anEvent);
}