Import Geant4 8.2.0 source tree

This commit is contained in:
Gabriele Cosmo
2016-06-09 14:55:03 +02:00
parent 216a75eeb1
commit fe73f43734
6714 changed files with 118229 additions and 68144 deletions
@@ -0,0 +1,67 @@
//
// ********************************************************************
// * 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: G4GCellFinder.cc,v 1.1 2006/11/20 10:02:15 ahoward Exp $
// GEANT4 tag $Name: geant4-08-02 $
//
// ----------------------------------------------------------------------
// GEANT 4 class source file
//
// G4GCellFinder.cc
//
// ----------------------------------------------------------------------
#include "G4GCellFinder.hh"
#include "G4TouchableHandle.hh"
#include "G4Step.hh"
G4GCellFinder::G4GCellFinder()
{
}
G4GCellFinder::~G4GCellFinder()
{
}
G4GeometryCell
G4GCellFinder::GetPreGeometryCell(const G4Step &aStep) const
{
const G4TouchableHandle& th =
aStep.GetPreStepPoint()->GetTouchableHandle();
G4GeometryCell g(*th->GetVolume(), th->GetReplicaNumber());
return g;
}
G4GeometryCell
G4GCellFinder::GetPostGeometryCell(const G4Step &aStep) const
{
const G4TouchableHandle& th =
aStep.GetPostStepPoint()->GetTouchableHandle();
G4GeometryCell g(*th->GetVolume(), th->GetReplicaNumber());
return g;
}
@@ -0,0 +1,263 @@
//
// ********************************************************************
// * 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: G4GeometrySampler.cc,v 1.1 2006/11/20 10:02:16 ahoward Exp $
// GEANT4 tag $Name: geant4-08-02 $
//
// ----------------------------------------------------------------------
// GEANT 4 class source file
//
// G4GeometrySampler.cc
//
// ----------------------------------------------------------------------
#include "G4GeometrySampler.hh"
#include "G4VIStore.hh"
#include "G4WeightWindowStore.hh"
#include "G4VScorer.hh"
#include "G4VPhysicalVolume.hh"
#include "G4ScoreConfigurator.hh"
#include "G4ImportanceConfigurator.hh"
#include "G4WeightWindowConfigurator.hh"
#include "G4NewWeightCutOffConfigurator.hh"
#include "G4GCellFinder.hh"
G4GeometrySampler::
G4GeometrySampler(G4VPhysicalVolume *parallelworld, const G4String &particlename)
: fParticleName(particlename),
fWorld(parallelworld),
fImportanceConfigurator(0),
fScoreConfigurator(0),
fGCellFinder(0),
fNewWeightCutOffConfigurator(0),
fIStore(0),
fWeightWindowConfigurator(0),
fWWStore(0),
fIsConfigured(false)
{
paraflag = false;
}
G4GeometrySampler::~G4GeometrySampler()
{
ClearSampling();
}
void G4GeometrySampler::ClearSampling()
{
if (fImportanceConfigurator)
{
delete fImportanceConfigurator;
fImportanceConfigurator = 0;
}
if (fWeightWindowConfigurator)
{
delete fWeightWindowConfigurator;
fWeightWindowConfigurator = 0;
}
if (fScoreConfigurator)
{
delete fScoreConfigurator;
fScoreConfigurator = 0;
}
if (fNewWeightCutOffConfigurator)
{
delete fNewWeightCutOffConfigurator;
fNewWeightCutOffConfigurator = 0;
}
if (fGCellFinder)
{
delete fGCellFinder;
fGCellFinder = 0;
}
fIStore = 0;
fConfigurators.clear();
fIsConfigured = false;
}
G4bool G4GeometrySampler::IsConfigured() const
{
G4bool isconf = false;
if (fIsConfigured)
{
G4cout << "WARNING - G4GeometrySampler::IsConfigured()"
<< " Some initalization exists, use ClearSampling()"
<< " before a new initialization !" << G4endl;
isconf = true;
}
return isconf;
}
void G4GeometrySampler::PrepareScoring(G4VScorer *scorer)
{
G4cout << " preparing scoring configurator " << G4endl;
G4cout << G4endl;
G4cout << G4endl;
G4cout << G4endl;
G4cout << " new fWorld Name: " << fWorld->GetName() << G4endl;
G4cout << G4endl;
G4cout << G4endl;
G4cout << G4endl;
fScoreConfigurator = new G4ScoreConfigurator(fWorld, fParticleName, *scorer, paraflag);
G4cout << " configured scoring " << G4endl;
if (!fScoreConfigurator)
{
G4Exception("G4GeometrySampler::PrepareScoring()",
"FatalError", FatalException,
"Failed allocation of G4ScoreConfigurator !");
}
}
void
G4GeometrySampler::PrepareImportanceSampling(G4VIStore *istore,
const G4VImportanceAlgorithm *ialg)
{
G4cout << " preparing importance sampling " << G4endl;
fIStore = istore;
G4cout << " creating istore " << G4endl;
fImportanceConfigurator =
new G4ImportanceConfigurator(fWorld, fParticleName, *fIStore, ialg, paraflag);
G4cout << " creating importance configurator " << G4endl;
if (!fImportanceConfigurator)
{
G4Exception("G4GeometrySampler::PrepareImportanceSampling()",
"FatalError", FatalException,
"Failed allocation of G4ImportanceConfigurator !");
}
}
void
G4GeometrySampler::PrepareWeightRoulett(G4double wsurvive,
G4double wlimit,
G4double isource)
{
// fGCellFinder = new G4GCellFinder(fWorld);
G4cout << " preparing weight roulette" << G4endl;
fGCellFinder = new G4GCellFinder();
if (!fGCellFinder)
{
G4Exception("G4GeometrySampler::PrepareWeightRoulett()",
"FatalError", FatalException,
"Failed allocation of G4GCellFinder !");
}
fNewWeightCutOffConfigurator =
new G4NewWeightCutOffConfigurator(fWorld, fParticleName,
wsurvive,
wlimit,
isource,
fIStore,
*fGCellFinder, paraflag);
if (!fNewWeightCutOffConfigurator)
{
G4Exception("G4GeometrySampler::PrepareWeightRoulett()",
"FatalError", FatalException,
"Failed allocation of G4NewWeightCutOffConfigurator !");
}
}
void
G4GeometrySampler::PrepareWeightWindow(G4VWeightWindowStore *wwstore,
G4VWeightWindowAlgorithm *wwAlg,
G4PlaceOfAction placeOfAction)
{
G4cout << " preparing weight window" << G4endl;
fWWStore = wwstore;
fWeightWindowConfigurator =
new G4WeightWindowConfigurator(fWorld, fParticleName,
*fWWStore,
wwAlg,
placeOfAction, paraflag);
}
void G4GeometrySampler::Configure()
{
G4cout << " entering configure " << G4endl;
if (!IsConfigured())
{
fIsConfigured = true;
if (fScoreConfigurator)
{
G4cout << " score configurator push_back " << G4endl;
fConfigurators.push_back(fScoreConfigurator);
G4cout << " pushed " << G4endl;
}
if (fImportanceConfigurator)
{
G4cout << " importance configurator push_back " << G4endl;
fConfigurators.push_back(fImportanceConfigurator);
G4cout << " pushed " << G4endl;
}
if (fWeightWindowConfigurator)
{
G4cout << " weight window configurator push_back " << G4endl;
fConfigurators.push_back(fWeightWindowConfigurator);
G4cout << " pushed " << G4endl;
}
G4cout << " vsampler configurator loop " << G4endl;
G4VSamplerConfigurator *preConf = 0;
G4int i = 0;
for (G4Configurators::iterator it = fConfigurators.begin();
it != fConfigurators.end(); it++)
{
i++;
G4cout << " looping " << i << G4endl;
G4VSamplerConfigurator *currConf =*it;
G4cout << " sampler configurator " << G4endl;
currConf->Configure(preConf);
G4cout << " configure preconf " << G4endl;
preConf = *it;
}
if (fNewWeightCutOffConfigurator)
{
G4cout << " NEW weight window configure " << G4endl;
fNewWeightCutOffConfigurator->Configure(0);
G4cout << " configured " << G4endl;
}
}
return;
}
void G4GeometrySampler::SetParallel(G4bool para)
{
paraflag = para;
}
void G4GeometrySampler::SetParticle(const G4String &particlename)
{
fParticleName = particlename;
}
@@ -0,0 +1,102 @@
//
// ********************************************************************
// * 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: G4ImportanceConfigurator.cc,v 1.1 2006/11/20 10:02:16 ahoward Exp $
// GEANT4 tag $Name: geant4-08-02 $
//
// ----------------------------------------------------------------------
// Class G4ImportanceConfigurator
//
// Author: Michael Dressel (Michael.Dressel@cern.ch)
// ----------------------------------------------------------------------
#include "G4ImportanceConfigurator.hh"
#include "G4ImportanceProcess.hh"
#include "G4NewProcessPlacer.hh"
#include "G4ImportanceAlgorithm.hh"
G4ImportanceConfigurator::
G4ImportanceConfigurator(G4VPhysicalVolume* worldvolume,
const G4String &particlename,
G4VIStore &istore,
const G4VImportanceAlgorithm *ialg, G4bool para)
: fWorld(worldvolume),
fPlacer(particlename),
fIStore(istore),
fDeleteIalg( ( ! ialg) ),
fIalgorithm(( (fDeleteIalg) ?
new G4ImportanceAlgorithm : ialg)),
fImportanceProcess(0),
paraflag(para)
{
}
G4ImportanceConfigurator::~G4ImportanceConfigurator()
{
if (fImportanceProcess)
{
fPlacer.RemoveProcess(fImportanceProcess);
delete fImportanceProcess;
}
if (fDeleteIalg)
{
delete fIalgorithm;
}
}
void
G4ImportanceConfigurator::Configure(G4VSamplerConfigurator *preConf)
{
G4cout << " entering importance configure, paraflag " << paraflag << G4endl;
const G4VTrackTerminator *terminator = 0;
if (preConf)
{
terminator = preConf->GetTrackTerminator();
};
G4cout << " creating importance process, paraflag is: " << paraflag << G4endl;
fImportanceProcess =
new G4ImportanceProcess(*fIalgorithm,
fIStore,
terminator,"ImportanceProcess",paraflag);
if (!fImportanceProcess)
{
G4Exception("G4ImportanceConfigurator::Configure()",
"FatalError", FatalException,
"Failed allocation of G4ImportanceProcess !");
}
if(paraflag) fImportanceProcess->SetParallelWorld(fWorld);
fPlacer.AddProcessAsSecondDoIt(fImportanceProcess);
}
const G4VTrackTerminator *G4ImportanceConfigurator::
GetTrackTerminator() const
{
return fImportanceProcess;
}
@@ -0,0 +1,471 @@
//
// ********************************************************************
// * 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: G4ImportanceProcess.cc,v 1.1 2006/11/20 10:02:16 ahoward Exp $
// GEANT4 tag $Name: geant4-08-02 $
//
// ----------------------------------------------------------------------
// GEANT 4 class source file
//
// G4ImportanceProcess.cc
//
// ----------------------------------------------------------------------
#include "G4ImportanceProcess.hh"
#include "G4VImportanceAlgorithm.hh"
#include "G4GeometryCell.hh"
#include "G4SamplingPostStepAction.hh"
#include "G4VTrackTerminator.hh"
#include "G4VIStore.hh"
#include "G4Step.hh"
#include "G4Navigator.hh"
#include "G4VTouchable.hh"
#include "G4VPhysicalVolume.hh"
#include "G4ParticleChange.hh"
#include "G4PathFinder.hh"
#include "G4TransportationManager.hh"
#include "G4StepPoint.hh"
#include "G4FieldTrackUpdator.hh"
G4ImportanceProcess::
G4ImportanceProcess(const G4VImportanceAlgorithm &aImportanceAlgorithm,
const G4VIStore &aIstore,
const G4VTrackTerminator *TrackTerminator,
const G4String &aName, G4bool para)
: G4VProcess(aName),
fParticleChange(new G4ParticleChange),
fImportanceAlgorithm(aImportanceAlgorithm),
fIStore(aIstore),
fPostStepAction(0),
fGhostNavigator(0), fNavigatorID(-1), fFieldTrack('0'),
paraflag(para)
{
if (TrackTerminator)
{
fPostStepAction = new G4SamplingPostStepAction(*TrackTerminator);
}
else
{
fPostStepAction = new G4SamplingPostStepAction(*this);
}
if (!fParticleChange)
{
G4Exception("G4ImportanceProcess::G4ImportanceProcess()",
"FatalError", FatalException,
"Failed allocation of G4ParticleChange !");
}
G4VProcess::pParticleChange = fParticleChange;
fGhostStep = new G4Step();
fGhostPreStepPoint = fGhostStep->GetPreStepPoint();
fGhostPostStepPoint = fGhostStep->GetPostStepPoint();
fTransportationManager = G4TransportationManager::GetTransportationManager();
fPathFinder = G4PathFinder::GetInstance();
if (verboseLevel>0)
{
G4cout << GetProcessName() << " is created " << G4endl;
}
G4cout << " importance process paraflag is: " << paraflag << G4endl;
}
G4ImportanceProcess::~G4ImportanceProcess()
{
delete fPostStepAction;
delete fParticleChange;
delete fGhostStep;
}
//------------------------------------------------------
//
// SetParallelWorld
//
//------------------------------------------------------
void G4ImportanceProcess::
SetParallelWorld(G4String parallelWorldName)
{
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// Get pointers of the parallel world and its navigator
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
fGhostWorldName = parallelWorldName;
fGhostWorld = fTransportationManager->GetParallelWorld(fGhostWorldName);
fGhostNavigator = fTransportationManager->GetNavigator(fGhostWorld);
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
}
void G4ImportanceProcess::
SetParallelWorld(G4VPhysicalVolume* parallelWorld)
{
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// Get pointer of navigator
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
fGhostWorldName = parallelWorld->GetName();
fGhostWorld = parallelWorld;
fGhostNavigator = fTransportationManager->GetNavigator(fGhostWorld);
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
}
//------------------------------------------------------
//
// StartTracking
//
//------------------------------------------------------
void G4ImportanceProcess::StartTracking(G4Track* trk)
{
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// Activate navigator and get the navigator ID
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// G4cout << " G4ParallelWorldScoringProcess::StartTracking" << G4endl;
if(paraflag) {
if(fGhostNavigator)
{ fNavigatorID = fTransportationManager->ActivateNavigator(fGhostNavigator); }
else
{
G4Exception("G4ImportanceProcess::StartTracking",
"ProcParaWorld000",FatalException,
"G4ImportanceProcess is used for tracking without having a parallel world assigned");
}
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// G4cout << "G4ParallelWorldScoringProcess::StartTracking <<<<<<<<<<<<<<<<<< " << G4endl;
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// Let PathFinder initialize
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
fPathFinder->PrepareNewTrack(trk->GetPosition(),trk->GetMomentumDirection());
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// Setup initial touchables for the first step
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
fOldGhostTouchable = fPathFinder->CreateTouchableHandle(fNavigatorID);
fGhostPreStepPoint->SetTouchableHandle(fOldGhostTouchable);
fNewGhostTouchable = fOldGhostTouchable;
fGhostPostStepPoint->SetTouchableHandle(fNewGhostTouchable);
// Initialize
fGhostSafety = -1.;
fOnBoundary = false;
}
}
G4double G4ImportanceProcess::
PostStepGetPhysicalInteractionLength(const G4Track& ,
G4double ,
G4ForceCondition* condition)
{
// *condition = Forced;
// return kInfinity;
// *condition = StronglyForced;
*condition = Forced;
return DBL_MAX;
}
G4VParticleChange *
G4ImportanceProcess::PostStepDoIt(const G4Track &aTrack,
const G4Step &aStep)
{
fParticleChange->Initialize(aTrack);
if(paraflag) {
fOldGhostTouchable = fGhostPostStepPoint->GetTouchableHandle();
//xbug? fOnBoundary = false;
CopyStep(aStep);
if(fOnBoundary)
{
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// Locate the point and get new touchable
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//?? fPathFinder->Locate(step.GetPostStepPoint()->GetPosition(),
//?? step.GetPostStepPoint()->GetMomentumDirection());
fNewGhostTouchable = fPathFinder->CreateTouchableHandle(fNavigatorID);
//AH G4cout << " on boundary " << G4endl;
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
}
else
{
// Do I need this ??????????????????????????????????????????????????????????
// fGhostNavigator->LocateGlobalPointWithinVolume(track.GetPosition());
// ?????????????????????????????????????????????????????????????????????????
// fPathFinder->ReLocate(track.GetPosition());
// reuse the touchable
fNewGhostTouchable = fOldGhostTouchable;
//AH G4cout << " NOT on boundary " << G4endl;
}
fGhostPreStepPoint->SetTouchableHandle(fOldGhostTouchable);
fGhostPostStepPoint->SetTouchableHandle(fNewGhostTouchable);
// if ( (aStep.GetPostStepPoint()->GetStepStatus() == fGeomBoundary)
// && (aStep.GetStepLength() > kCarTolerance) )
// {
// if (aTrack.GetTrackStatus()==fStopAndKill)
// {
// G4cout << "WARNING - G4ImportanceProcess::PostStepDoIt()"
// << " StopAndKill track." << G4endl;
// }
// G4StepPoint *prepoint = aStep.GetPreStepPoint();
// G4StepPoint *postpoint = aStep.GetPostStepPoint();
// G4GeometryCell prekey(*(prepoint->GetPhysicalVolume()),
// prepoint->GetTouchable()->GetReplicaNumber());
// G4GeometryCell postkey(*(postpoint->GetPhysicalVolume()),
// postpoint->GetTouchable()->GetReplicaNumber());
if ( (fGhostPostStepPoint->GetStepStatus() == fGeomBoundary)
&& (aStep.GetStepLength() > kCarTolerance) )
{
if (aTrack.GetTrackStatus()==fStopAndKill)
{
G4cout << "WARNING - G4ImportanceProcess::PostStepDoIt()"
<< " StopAndKill track. on boundary" << G4endl;
}
G4GeometryCell prekey(*(fGhostPreStepPoint->GetPhysicalVolume()),
fGhostPreStepPoint->GetTouchable()->GetReplicaNumber());
G4GeometryCell postkey(*(fGhostPostStepPoint->GetPhysicalVolume()),
fGhostPostStepPoint->GetTouchable()->GetReplicaNumber());
//AH
/*
G4cout << G4endl;
G4cout << G4endl;
G4cout << " inside parallel importance process " << aTrack.GetCurrentStepNumber() << G4endl;
G4cout << G4endl;
G4cout << G4endl;
G4cout << " prekey: " << fGhostPreStepPoint->GetPhysicalVolume()->GetName() << " replica:"
<< fGhostPreStepPoint->GetTouchable()->GetReplicaNumber() << G4endl;
G4cout << " prekey ISTORE: " << fIStore.GetImportance(prekey) << G4endl;
G4cout << " postkey: " << G4endl;
G4cout << " postkey ISTORE: " << fIStore.GetImportance(postkey) << G4endl;
*/
//AH
G4Nsplit_Weight nw = fImportanceAlgorithm.
Calculate(fIStore.GetImportance(prekey),
fIStore.GetImportance(postkey),
aTrack.GetWeight());
//AH
/*
G4cout << " prekey weight: " << fIStore.GetImportance(prekey)
<< " postkey weight: " << fIStore.GetImportance(postkey)
<< " split weight: " << nw << G4endl;
G4cout << " before poststepaction " << G4endl;
*/
//AH
fPostStepAction->DoIt(aTrack, fParticleChange, nw);
//AH G4cout << " after post step do it " << G4endl;
}
} else {
if ( (aStep.GetPostStepPoint()->GetStepStatus() == fGeomBoundary)
&& (aStep.GetStepLength() > kCarTolerance) )
{
//AH G4cout << " inside non-parallel importance process " << G4endl;
if (aTrack.GetTrackStatus()==fStopAndKill)
{
G4cout << "WARNING - G4ImportanceProcess::PostStepDoIt()"
<< " StopAndKill track. on boundary non-parallel" << G4endl;
}
G4StepPoint *prepoint = aStep.GetPreStepPoint();
G4StepPoint *postpoint = aStep.GetPostStepPoint();
G4GeometryCell prekey(*(prepoint->GetPhysicalVolume()),
prepoint->GetTouchable()->GetReplicaNumber());
G4GeometryCell postkey(*(postpoint->GetPhysicalVolume()),
postpoint->GetTouchable()->GetReplicaNumber());
G4Nsplit_Weight nw = fImportanceAlgorithm.
Calculate(fIStore.GetImportance(prekey),
fIStore.GetImportance(postkey),
aTrack.GetWeight());
//AH
/*
G4cout << " prekey weight: " << fIStore.GetImportance(prekey)
<< " postkey weight: " << fIStore.GetImportance(postkey)
<< " split weight: " << nw << G4endl;
G4cout << " before poststepaction 2 " << G4endl;
*/
//AH
fPostStepAction->DoIt(aTrack, fParticleChange, nw);
//AH G4cout << " after poststepaction 2 " << G4endl;
}
}
return fParticleChange;
}
void G4ImportanceProcess::KillTrack() const
{
fParticleChange->ProposeTrackStatus(fStopAndKill);
}
const G4String &G4ImportanceProcess::GetName() const
{
return theProcessName;
}
G4double G4ImportanceProcess::
AlongStepGetPhysicalInteractionLength(
const G4Track& track, G4double previousStepSize, G4double currentMinimumStep,
G4double& proposedSafety, G4GPILSelection* selection)
{
//AH G4cout << " along step physical interaction length " << G4endl;
if(paraflag) {
static G4FieldTrack endTrack('0');
static ELimited eLimited;
*selection = NotCandidateForSelection;
G4double returnedStep = DBL_MAX;
if (previousStepSize > 0.)
{ fGhostSafety -= previousStepSize; }
// else
// { fGhostSafety = -1.; }
if (fGhostSafety < 0.) fGhostSafety = 0.0;
// ------------------------------------------
// Determination of the proposed STEP LENGTH:
// ------------------------------------------
if (currentMinimumStep <= fGhostSafety && currentMinimumStep > 0.)
{
// I have no chance to limit
returnedStep = currentMinimumStep;
fOnBoundary = false;
proposedSafety = fGhostSafety - currentMinimumStep;
//AH G4cout << " step not limited, why? " << G4endl;
}
else // (currentMinimumStep > fGhostSafety: I may limit the Step)
{
G4FieldTrackUpdator::Update(&fFieldTrack,&track);
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// ComputeStep
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
returnedStep
= fPathFinder->ComputeStep(fFieldTrack,currentMinimumStep,fNavigatorID,
track.GetCurrentStepNumber(),fGhostSafety,eLimited,
endTrack,track.GetVolume());
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
if(eLimited == kDoNot)
{
//AH G4cout << " computestep came back with not-boundary " << G4endl;
// Track is not on the boundary
fOnBoundary = false;
fGhostSafety = fGhostNavigator->ComputeSafety(endTrack.GetPosition());
}
else
{
// Track is on the boundary
//AH G4cout << " FOUND A BOUNDARY ! " << track.GetCurrentStepNumber() << G4endl;
fOnBoundary = true;
// proposedSafety = fGhostSafety;
}
proposedSafety = fGhostSafety;
if(eLimited == kUnique || eLimited == kSharedOther) {
*selection = CandidateForSelection;
}else if (eLimited == kSharedTransport) {
returnedStep *= (1.0 + 1.0e-9);
// Expand to disable its selection in Step Manager comparison
}
}
// ----------------------------------------------
// Returns the fGhostSafety as the proposedSafety
// The SteppingManager will take care of keeping
// the smallest one.
// ----------------------------------------------
return returnedStep;
} else {
return DBL_MAX;
}
}
G4double G4ImportanceProcess::
AtRestGetPhysicalInteractionLength(const G4Track& ,
G4ForceCondition*)
{
return -1.0;
}
G4VParticleChange* G4ImportanceProcess::
AtRestDoIt(const G4Track&, const G4Step&)
{
return 0;
}
G4VParticleChange* G4ImportanceProcess::
AlongStepDoIt(const G4Track& aTrack, const G4Step& )
{
// Dummy ParticleChange ie: does nothing
// Expecting G4Transportation to move the track
//AH G4cout << " along step do it " << G4endl;
pParticleChange->Initialize(aTrack);
return pParticleChange;
// return 0;
}
void G4ImportanceProcess::CopyStep(const G4Step & step)
{
fGhostStep->SetTrack(step.GetTrack());
fGhostStep->SetStepLength(step.GetStepLength());
fGhostStep->SetTotalEnergyDeposit(step.GetTotalEnergyDeposit());
fGhostStep->SetControlFlag(step.GetControlFlag());
*fGhostPreStepPoint = *(step.GetPreStepPoint());
*fGhostPostStepPoint = *(step.GetPostStepPoint());
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// Set StepStatus for ghost world
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
if(fOnBoundary)
{ fGhostPostStepPoint->SetStepStatus(fGeomBoundary); }
else if(fGhostPostStepPoint->GetStepStatus()==fGeomBoundary)
{ fGhostPostStepPoint->SetStepStatus(fPostStepDoItProc); }
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
}
@@ -0,0 +1,207 @@
//
// ********************************************************************
// * 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: G4NewProcessPlacer.cc,v 1.1 2006/11/20 10:02:16 ahoward Exp $
// GEANT4 tag $Name: geant4-08-02 $
//
// ----------------------------------------------------------------------
// GEANT 4 class source file
//
// G4NewProcessPlacer.cc
//
// ----------------------------------------------------------------------
#include "G4NewProcessPlacer.hh"
#include "G4ProcessManager.hh"
#include "G4VProcess.hh"
#include "G4ParticleTable.hh"
G4NewProcessPlacer::G4NewProcessPlacer(const G4String &particlename)
: fParticleName(particlename)
{
}
G4NewProcessPlacer::~G4NewProcessPlacer()
{
}
void G4NewProcessPlacer::RemoveProcess(G4VProcess *process)
{
G4cout << "=== G4NewProcessPlacer::RemoveProcess: for: " << fParticleName
<< G4endl;
G4cout << " ProcessName: " << process->GetProcessName()
<< ", will be removed!" << G4endl;
G4cout << " The initial Vectors: " << G4endl;
PrintPostStepGPILVec();
PrintPostStepDoItVec();
GetProcessManager()->RemoveProcess(process);
G4cout << " The final Vectors: " << G4endl;
PrintPostStepGPILVec();
PrintPostStepDoItVec();
G4cout << "================================================" << G4endl;
}
void G4NewProcessPlacer::AddProcessAs(G4VProcess *process, SecondOrLast sol)
{
G4cout << " ProcessName: " << process->GetProcessName() << G4endl;
G4cout << "The initial Vectors: " << G4endl;
PrintPostStepGPILVec();
PrintPostStepDoItVec();
if (sol == eLast)
{
GetProcessManager()->AddProcess(process, ordInActive, ordInActive, ordLast);
}
else if (sol == eSecond)
{
// get transportation process
G4VProcess *transportation =
(* (GetProcessManager()->GetProcessList()))[0];
if (!transportation)
{
G4Exception(" G4NewProcessPlacer:: could not get process id=0");
}
if (transportation->GetProcessName() != "Transportation" && transportation->GetProcessName() != "CoupledTransportation")
{
// G4cout << " GOT HERE CoupledTransportation" << G4endl;
G4cout << transportation->GetProcessName() << G4endl;
G4Exception(" G4NewProcessPlacer:: process id=0 is not Transportation");
}
// place the given proces as first for the moment
GetProcessManager()->AddProcess(process);
GetProcessManager()->SetProcessOrderingToFirst(process,
idxPostStep);
// xx test
// if(process->GetProcessName() == "ImportanceProcess")
GetProcessManager()->SetProcessOrdering(process,
idxAlongStep, 1);
// place transportation first again
GetProcessManager()->SetProcessOrderingToFirst(transportation,
idxPostStep);
}
// for verification inly
G4cout << "The final Vectors: " << G4endl;
PrintPostStepGPILVec();
PrintPostStepDoItVec();
G4cout << "================================================" << G4endl;
}
void G4NewProcessPlacer::AddProcessAsSecondDoIt(G4VProcess *process)
{
G4cout << "=== G4NewProcessPlacer::AddProcessAsSecondDoIt: for: "
<< fParticleName << G4endl;
AddProcessAs(process, eSecond);
}
void G4NewProcessPlacer::AddProcessAsLastDoIt(G4VProcess *process)
{
G4cout << "=== G4NewProcessPlacer::AddProcessAsLastDoIt: for: "
<< fParticleName << G4endl;
AddProcessAs(process, eLast);
}
G4ProcessManager *G4NewProcessPlacer::GetProcessManager()
{
// get particle iterator to add processes ---------------------
G4ParticleTable* theParticleTable = 0;
G4ParticleTable::G4PTblDicIterator* theParticleIterator = 0;
theParticleTable = G4ParticleTable::GetParticleTable();
theParticleIterator = theParticleTable->GetIterator();
// -------------------------------------------------------
G4ProcessManager *processmanager = 0;
// find process manager ---------------------------
theParticleIterator->reset();
while( (*theParticleIterator)() )
{
G4ParticleDefinition* particle = theParticleIterator->value();
if (particle->GetParticleName() == fParticleName)
{
processmanager = particle->GetProcessManager();
break;
}
}
// ---------------------------------------------------------
if (!processmanager)
{
G4Exception("G4NewProcessPlacer::GetProcessManager()", "InvalidSetup",
FatalException, "NULL pointer to Process Manager !");
}
return processmanager;
}
void G4NewProcessPlacer::PrintPostStepGPILVec()
{
G4cout << "GPIL Vector: " << G4endl;
G4ProcessVector* processGPILVec =
GetProcessManager()->GetPostStepProcessVector(typeGPIL);
PrintProcVec(processGPILVec);
}
void G4NewProcessPlacer::PrintPostStepDoItVec()
{
G4cout << "DoIt Vector: " << G4endl;
G4ProcessVector* processDoItVec =
GetProcessManager()->GetPostStepProcessVector(typeDoIt);
PrintProcVec(processDoItVec);
}
void G4NewProcessPlacer::PrintProcVec(G4ProcessVector* processVec)
{
if (!processVec)
{
G4Exception("G4NewProcessPlacer::G4NewProcessPlacer()", "InvalidArgument",
FatalException, "NULL pointer to process-vector !");
}
G4int len = processVec->length();
if (len==0)
{
G4Exception("G4NewProcessPlacer::G4NewProcessPlacer()", "InvalidSetup",
FatalException, "Length of process-vector is zero !");
}
for (int pi=0; pi<len; pi++)
{
G4VProcess *p = (*processVec)[pi];
if (p)
{
G4cout << " " << p->GetProcessName() << G4endl;
}
else
{
G4cout << " " << "no process found for position: " << pi
<< ", in vector of length: " << len << G4endl;
}
}
}
@@ -0,0 +1,86 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
// $Id: G4NewWeightCutOffConfigurator.cc,v 1.1 2006/11/20 10:02:16 ahoward Exp $
// GEANT4 tag $Name: geant4-08-02 $
//
// ----------------------------------------------------------------------
// Class G4NewWeightCutOffConfigurator
//
// Author: Michael Dressel (Michael.Dressel@cern.ch)
// ----------------------------------------------------------------------
#include "G4NewWeightCutOffConfigurator.hh"
#include "G4NewWeightCutOffProcess.hh"
G4NewWeightCutOffConfigurator::
G4NewWeightCutOffConfigurator(G4VPhysicalVolume* worldvolume,
const G4String &particlename,
G4double wsurvival,
G4double wlimit,
G4double isource,
G4VIStore *istore,
const G4VGCellFinder &aGCellfinder, G4bool para)
: fWorld(worldvolume),
fPlacer(particlename),
fPlaced(false),
paraflag(para)
{
fNewWeightCutOffProcess =
new G4NewWeightCutOffProcess(wsurvival,wlimit,isource,istore,aGCellfinder,"NewWeightCutOffProcess",paraflag);
if (!fNewWeightCutOffProcess)
{
G4Exception("G4NewWeightCutOffConfigurator::G4NewWeightCutOffConfigurator()",
"FatalError", FatalException,
"Failed to allocate G4NewWeightCutOffProcess !");
}
}
G4NewWeightCutOffConfigurator::~G4NewWeightCutOffConfigurator()
{
if (fPlaced)
{
fPlacer.RemoveProcess(fNewWeightCutOffProcess);
delete fNewWeightCutOffProcess;
}
}
void G4NewWeightCutOffConfigurator::Configure(G4VSamplerConfigurator *)
{
G4cout << " entering new weight window configure " << G4endl;
if(paraflag) fNewWeightCutOffProcess->SetParallelWorld(fWorld);
fPlacer.AddProcessAsLastDoIt(fNewWeightCutOffProcess);
fPlaced = true;
}
const G4VTrackTerminator
*G4NewWeightCutOffConfigurator::GetTrackTerminator() const
{
return 0;
}
@@ -0,0 +1,378 @@
//
// ********************************************************************
// * 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: G4NewWeightCutOffProcess.cc,v 1.1 2006/11/20 10:02:17 ahoward Exp $
// GEANT4 tag $Name: geant4-08-02 $
//
// ----------------------------------------------------------------------
// GEANT 4 class source file
//
// G4NewWeightCutOffProcess.cc
//
// ----------------------------------------------------------------------
#include "G4NewWeightCutOffProcess.hh"
#include "G4VScorer.hh"
#include "G4GeometryCellStep.hh"
#include "G4GCellFinder.hh"
#include "G4TouchableHandle.hh"
#include "G4VIStore.hh"
#include "G4Step.hh"
#include "G4Navigator.hh"
#include "G4VTouchable.hh"
#include "G4VPhysicalVolume.hh"
#include "G4ParticleChange.hh"
#include "G4PathFinder.hh"
#include "G4TransportationManager.hh"
#include "G4StepPoint.hh"
#include "G4FieldTrackUpdator.hh"
G4NewWeightCutOffProcess::
G4NewWeightCutOffProcess(G4double wsurvival,
G4double wlimit,
G4double isource,
G4VIStore *istore,
const G4VGCellFinder &aGCellFinder,
const G4String &aName, G4bool para)
: G4VProcess(aName),
fParticleChange(new G4ParticleChange),
fWeightSurvival(wsurvival),
fWeightLimit(wlimit),
fSourceImportance(isource),
fIStore(istore),
fGCellFinder(aGCellFinder),
fGhostNavigator(0), fNavigatorID(-1), fFieldTrack('0')
{
if (!fParticleChange)
{
G4Exception("G4NewWeightCutOffProcess::G4NewWeightCutOffProcess()",
"FatalError", FatalException,
"Failed to allocate G4ParticleChange !");
}
G4VProcess::pParticleChange = fParticleChange;
fGhostStep = new G4Step();
fGhostPreStepPoint = fGhostStep->GetPreStepPoint();
fGhostPostStepPoint = fGhostStep->GetPostStepPoint();
fTransportationManager = G4TransportationManager::GetTransportationManager();
fPathFinder = G4PathFinder::GetInstance();
if (verboseLevel>0)
{
G4cout << GetProcessName() << " is created " << G4endl;
}
paraflag = para;
}
G4NewWeightCutOffProcess::~G4NewWeightCutOffProcess()
{
delete fParticleChange;
delete fGhostStep;
}
//------------------------------------------------------
//
// SetParallelWorld
//
//------------------------------------------------------
void G4NewWeightCutOffProcess::
SetParallelWorld(G4String parallelWorldName)
{
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// Get pointers of the parallel world and its navigator
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
fGhostWorldName = parallelWorldName;
fGhostWorld = fTransportationManager->GetParallelWorld(fGhostWorldName);
fGhostNavigator = fTransportationManager->GetNavigator(fGhostWorld);
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
}
void G4NewWeightCutOffProcess::
SetParallelWorld(G4VPhysicalVolume* parallelWorld)
{
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// Get pointer of navigator
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
fGhostWorldName = parallelWorld->GetName();
fGhostWorld = parallelWorld;
fGhostNavigator = fTransportationManager->GetNavigator(fGhostWorld);
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
}
//------------------------------------------------------
//
// StartTracking
//
//------------------------------------------------------
void G4NewWeightCutOffProcess::StartTracking(G4Track* trk)
{
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// Activate navigator and get the navigator ID
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// G4cout << " G4ParallelWorldScoringProcess::StartTracking" << G4endl;
if(paraflag) {
if(fGhostNavigator)
{ fNavigatorID = fTransportationManager->ActivateNavigator(fGhostNavigator); }
else
{
G4Exception("G4NewWeightCutOffProcess::StartTracking",
"ProcParaWorld000",FatalException,
"G4NewWeightCutOffProcess is used for tracking without having a parallel world assigned");
}
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// G4cout << "G4ParallelWorldScoringProcess::StartTracking <<<<<<<<<<<<<<<<<< " << G4endl;
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// Let PathFinder initialize
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
fPathFinder->PrepareNewTrack(trk->GetPosition(),trk->GetMomentumDirection());
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// Setup initial touchables for the first step
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
fOldGhostTouchable = fPathFinder->CreateTouchableHandle(fNavigatorID);
fGhostPreStepPoint->SetTouchableHandle(fOldGhostTouchable);
fNewGhostTouchable = fOldGhostTouchable;
fGhostPostStepPoint->SetTouchableHandle(fNewGhostTouchable);
// Initialize
fGhostSafety = -1.;
fOnBoundary = false;
}
}
G4double G4NewWeightCutOffProcess::
PostStepGetPhysicalInteractionLength(const G4Track &,
G4double, G4ForceCondition* condition)
{
// *condition = Forced;
// return kInfinity;
// *condition = StronglyForced;
*condition = Forced;
return DBL_MAX;
}
G4VParticleChange *
G4NewWeightCutOffProcess::PostStepDoIt(const G4Track& aTrack,
const G4Step &aStep)
{
fParticleChange->Initialize(aTrack);
if(paraflag) {
fOldGhostTouchable = fGhostPostStepPoint->GetTouchableHandle();
//xbug? fOnBoundary = false;
CopyStep(aStep);
if(fOnBoundary)
{
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// Locate the point and get new touchable
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//?? fPathFinder->Locate(step.GetPostStepPoint()->GetPosition(),
//?? step.GetPostStepPoint()->GetMomentumDirection());
fNewGhostTouchable = fPathFinder->CreateTouchableHandle(fNavigatorID);
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
}
else
{
// Do I need this ??????????????????????????????????????????????????????????
// fGhostNavigator->LocateGlobalPointWithinVolume(track.GetPosition());
// ?????????????????????????????????????????????????????????????????????????
// fPathFinder->ReLocate(track.GetPosition());
// reuse the touchable
fNewGhostTouchable = fOldGhostTouchable;
}
fGhostPreStepPoint->SetTouchableHandle(fOldGhostTouchable);
fGhostPostStepPoint->SetTouchableHandle(fNewGhostTouchable);
}
G4GeometryCell postCell = fGCellFinder.GetPostGeometryCell(aStep);
// G4GeometryCell postCell = fGCellFinder.GetPostGeometryCell(fGhostStep);
G4double R = fSourceImportance;
if (fIStore)
{
G4double i = fIStore->GetImportance(postCell);
if (i>0)
{
R/=i;
}
}
G4double w = aTrack.GetWeight();
if (w<R*fWeightLimit)
{
G4double ws = fWeightSurvival*R;
G4double p = w/(ws);
if (G4UniformRand()<p)
{
fParticleChange->ProposeTrackStatus(fStopAndKill);
}
else
{
fParticleChange->ProposeWeight(ws);
}
}
return fParticleChange;
}
const G4String &G4NewWeightCutOffProcess::GetName() const
{
return theProcessName;
}
G4double G4NewWeightCutOffProcess::
AlongStepGetPhysicalInteractionLength(
const G4Track& track, G4double previousStepSize, G4double currentMinimumStep,
G4double& proposedSafety, G4GPILSelection* selection)
{
if(paraflag) {
static G4FieldTrack endTrack('0');
static ELimited eLimited;
*selection = NotCandidateForSelection;
G4double returnedStep = DBL_MAX;
if (previousStepSize > 0.)
{ fGhostSafety -= previousStepSize; }
// else
// { fGhostSafety = -1.; }
if (fGhostSafety < 0.) fGhostSafety = 0.0;
// ------------------------------------------
// Determination of the proposed STEP LENGTH:
// ------------------------------------------
if (currentMinimumStep <= fGhostSafety && currentMinimumStep > 0.)
{
// I have no chance to limit
returnedStep = currentMinimumStep;
fOnBoundary = false;
proposedSafety = fGhostSafety - currentMinimumStep;
}
else // (currentMinimumStep > fGhostSafety: I may limit the Step)
{
G4FieldTrackUpdator::Update(&fFieldTrack,&track);
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// ComputeStep
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
returnedStep
= fPathFinder->ComputeStep(fFieldTrack,currentMinimumStep,fNavigatorID,
track.GetCurrentStepNumber(),fGhostSafety,eLimited,
endTrack,track.GetVolume());
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
if(eLimited == kDoNot)
{
// Track is not on the boundary
fOnBoundary = false;
fGhostSafety = fGhostNavigator->ComputeSafety(endTrack.GetPosition());
}
else
{
// Track is on the boundary
fOnBoundary = true;
proposedSafety = fGhostSafety;
}
//xbug? proposedSafety = fGhostSafety;
if(eLimited == kUnique || eLimited == kSharedOther) {
*selection = CandidateForSelection;
}else if (eLimited == kSharedTransport) {
returnedStep *= (1.0 + 1.0e-9);
// Expand to disable its selection in Step Manager comparison
}
}
// ----------------------------------------------
// Returns the fGhostSafety as the proposedSafety
// The SteppingManager will take care of keeping
// the smallest one.
// ----------------------------------------------
return returnedStep;
} else {
return DBL_MAX;
//not sensible! return -1.0;
}
}
G4double G4NewWeightCutOffProcess::
AtRestGetPhysicalInteractionLength(const G4Track& ,
G4ForceCondition*)
{
return -1.0;
}
G4VParticleChange*
G4NewWeightCutOffProcess::AtRestDoIt(const G4Track&, const G4Step&)
{
return 0;
}
G4VParticleChange*
G4NewWeightCutOffProcess::AlongStepDoIt(const G4Track& track, const G4Step&)
{
// Dummy ParticleChange ie: does nothing
// Expecting G4Transportation to move the track
pParticleChange->Initialize(track);
return pParticleChange;
// return 0;
}
void G4NewWeightCutOffProcess::CopyStep(const G4Step & step)
{
fGhostStep->SetTrack(step.GetTrack());
fGhostStep->SetStepLength(step.GetStepLength());
fGhostStep->SetTotalEnergyDeposit(step.GetTotalEnergyDeposit());
fGhostStep->SetControlFlag(step.GetControlFlag());
*fGhostPreStepPoint = *(step.GetPreStepPoint());
*fGhostPostStepPoint = *(step.GetPostStepPoint());
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// Set StepStatus for ghost world
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
if(fOnBoundary)
{ fGhostPostStepPoint->SetStepStatus(fGeomBoundary); }
else if(fGhostPostStepPoint->GetStepStatus()==fGeomBoundary)
{ fGhostPostStepPoint->SetStepStatus(fPostStepDoItProc); }
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
}
@@ -0,0 +1,449 @@
//
// ********************************************************************
// * 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: G4ParallelWorldScoringProcess.cc,v 1.5 2006/11/13 20:16:53 asaim Exp $
// GEANT4 tag $Name: geant4-08-02 $
//
//
#include "G4ios.hh"
#include "G4ParallelWorldScoringProcess.hh"
#include "G4Step.hh"
#include "G4Navigator.hh"
#include "G4VTouchable.hh"
#include "G4VPhysicalVolume.hh"
#include "G4ParticleChange.hh"
#include "G4PathFinder.hh"
#include "G4TransportationManager.hh"
#include "G4ParticleChange.hh"
#include "G4StepPoint.hh"
#include "G4FieldTrackUpdator.hh"
#include "G4SDManager.hh"
#include "G4VSensitiveDetector.hh"
//--------------------------------
// Constructor with name and type:
//--------------------------------
G4ParallelWorldScoringProcess::
G4ParallelWorldScoringProcess(const G4String& processName,G4ProcessType theType)
:G4VProcess(processName,theType), fGhostNavigator(0), fNavigatorID(-1), fFieldTrack('0')
{
pParticleChange = &aDummyParticleChange;
fGhostStep = new G4Step();
fGhostPreStepPoint = fGhostStep->GetPreStepPoint();
fGhostPostStepPoint = fGhostStep->GetPostStepPoint();
fTransportationManager = G4TransportationManager::GetTransportationManager();
fPathFinder = G4PathFinder::GetInstance();
if (verboseLevel>0)
{
G4cout << GetProcessName() << " is created " << G4endl;
}
}
// -----------
// Destructor:
// -----------
G4ParallelWorldScoringProcess::~G4ParallelWorldScoringProcess()
{
delete fGhostStep;
}
//------------------------------------------------------
//
// SetParallelWorld
//
//------------------------------------------------------
void G4ParallelWorldScoringProcess::
SetParallelWorld(G4String parallelWorldName)
{
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// Get pointers of the parallel world and its navigator
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
fGhostWorldName = parallelWorldName;
fGhostWorld = fTransportationManager->GetParallelWorld(fGhostWorldName);
fGhostNavigator = fTransportationManager->GetNavigator(fGhostWorld);
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
}
void G4ParallelWorldScoringProcess::
SetParallelWorld(G4VPhysicalVolume* parallelWorld)
{
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// Get pointer of navigator
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
fGhostWorldName = parallelWorld->GetName();
fGhostWorld = parallelWorld;
fGhostNavigator = fTransportationManager->GetNavigator(fGhostWorld);
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
}
//------------------------------------------------------
//
// StartTracking
//
//------------------------------------------------------
void G4ParallelWorldScoringProcess::StartTracking(G4Track* trk)
{
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// Activate navigator and get the navigator ID
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// G4cout << " G4ParallelWorldScoringProcess::StartTracking" << G4endl;
if(fGhostNavigator)
{ fNavigatorID = fTransportationManager->ActivateNavigator(fGhostNavigator); }
else
{
G4Exception("G4ParallelWorldScoringProcess::StartTracking",
"ProcParaWorld000",FatalException,
"G4ParallelWorldScoringProcess is used for tracking without having a parallel world assigned");
}
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// G4cout << "G4ParallelWorldScoringProcess::StartTracking <<<<<<<<<<<<<<<<<< " << G4endl;
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// Let PathFinder initialize
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
fPathFinder->PrepareNewTrack(trk->GetPosition(),trk->GetMomentumDirection());
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// Setup initial touchables for the first step
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
fOldGhostTouchable = fPathFinder->CreateTouchableHandle(fNavigatorID);
fGhostPreStepPoint->SetTouchableHandle(fOldGhostTouchable);
fNewGhostTouchable = fOldGhostTouchable;
fGhostPostStepPoint->SetTouchableHandle(fNewGhostTouchable);
// Initialize
fGhostSafety = -1.;
fOnBoundary = false;
}
//----------------------------------------------------------
//
// AtRestGetPhysicalInteractionLength()
//
//----------------------------------------------------------
G4double
G4ParallelWorldScoringProcess::AtRestGetPhysicalInteractionLength(
const G4Track& /*track*/,
G4ForceCondition* condition)
{
*condition = Forced;
return DBL_MAX;
}
//------------------------------------
//
// AtRestDoIt()
//
//------------------------------------
G4VParticleChange* G4ParallelWorldScoringProcess::AtRestDoIt(
const G4Track& track,
const G4Step& step)
{
fOldGhostTouchable = fGhostPostStepPoint->GetTouchableHandle();
G4VSensitiveDetector* aSD = 0;
if(fOldGhostTouchable->GetVolume())
{ aSD = fOldGhostTouchable->GetVolume()->GetLogicalVolume()->GetSensitiveDetector(); }
fOnBoundary = false;
CopyStep(step);
fGhostPreStepPoint->SetSensitiveDetector(aSD);
fNewGhostTouchable = fOldGhostTouchable;
fGhostPreStepPoint->SetTouchableHandle(fOldGhostTouchable);
fGhostPostStepPoint->SetTouchableHandle(fNewGhostTouchable);
if(fNewGhostTouchable->GetVolume())
{
fGhostPostStepPoint->SetSensitiveDetector(
fNewGhostTouchable->GetVolume()->GetLogicalVolume()->GetSensitiveDetector());
}
else
{ fGhostPostStepPoint->SetSensitiveDetector(0); }
if (verboseLevel>1) Verbose(step);
G4VSensitiveDetector* sd = fGhostPreStepPoint->GetSensitiveDetector();
if(sd)
{
sd->Hit(fGhostStep);
}
pParticleChange->Initialize(track);
return pParticleChange;
}
//----------------------------------------------------------
//
// PostStepGetPhysicalInteractionLength()
//
//----------------------------------------------------------
G4double
G4ParallelWorldScoringProcess::PostStepGetPhysicalInteractionLength(
const G4Track& /*track*/,
G4double /*previousStepSize*/,
G4ForceCondition* condition)
{
// I must be invoked anyway to score the hit.
*condition = StronglyForced;
return DBL_MAX;
}
//------------------------------------
//
// PostStepDoIt()
//
//------------------------------------
G4VParticleChange* G4ParallelWorldScoringProcess::PostStepDoIt(
const G4Track& track,
const G4Step& step)
{
fOldGhostTouchable = fGhostPostStepPoint->GetTouchableHandle();
G4VSensitiveDetector* aSD = 0;
if(fOldGhostTouchable->GetVolume())
{ aSD = fOldGhostTouchable->GetVolume()->GetLogicalVolume()->GetSensitiveDetector(); }
CopyStep(step);
fGhostPreStepPoint->SetSensitiveDetector(aSD);
// fPathFinder->Locate( track.GetPosition(),
// track.GetMomentumDirection(),
// true);
// fPathFinder->Locate(step.GetPostStepPoint()->GetPosition(),
// step.GetPostStepPoint()->GetMomentumDirection());
if(fOnBoundary)
{
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// Locate the point and get new touchable
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//?? fPathFinder->Locate(step.GetPostStepPoint()->GetPosition(),
//?? step.GetPostStepPoint()->GetMomentumDirection());
fNewGhostTouchable = fPathFinder->CreateTouchableHandle(fNavigatorID);
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
}
else
{
// Do I need this ??????????????????????????????????????????????????????????
// fGhostNavigator->LocateGlobalPointWithinVolume(track.GetPosition());
// ?????????????????????????????????????????????????????????????????????????
// fPathFinder->ReLocate(track.GetPosition());
// reuse the touchable
fNewGhostTouchable = fOldGhostTouchable;
}
fGhostPreStepPoint->SetTouchableHandle(fOldGhostTouchable);
fGhostPostStepPoint->SetTouchableHandle(fNewGhostTouchable);
if(fNewGhostTouchable->GetVolume())
{
fGhostPostStepPoint->SetSensitiveDetector(
fNewGhostTouchable->GetVolume()->GetLogicalVolume()->GetSensitiveDetector());
}
else
{ fGhostPostStepPoint->SetSensitiveDetector(0); }
if (verboseLevel>1) Verbose(step);
G4VSensitiveDetector* sd = fGhostPreStepPoint->GetSensitiveDetector();
if(sd)
{
sd->Hit(fGhostStep);
}
pParticleChange->Initialize(track); // Does not change the track properties
return pParticleChange;
}
//---------------------------------------
//
// AlongStepGetPhysicalInteractionLength
//
//---------------------------------------
G4double G4ParallelWorldScoringProcess::AlongStepGetPhysicalInteractionLength(
const G4Track& track, G4double previousStepSize, G4double currentMinimumStep,
G4double& proposedSafety, G4GPILSelection* selection)
{
static G4FieldTrack endTrack('0');
static ELimited eLimited;
*selection = NotCandidateForSelection;
G4double returnedStep = DBL_MAX;
if (previousStepSize > 0.)
{ fGhostSafety -= previousStepSize; }
// else
// { fGhostSafety = -1.; }
if (fGhostSafety < 0.) fGhostSafety = 0.0;
// ------------------------------------------
// Determination of the proposed STEP LENGTH:
// ------------------------------------------
if (currentMinimumStep <= fGhostSafety && currentMinimumStep > 0.)
{
// I have no chance to limit
returnedStep = currentMinimumStep;
fOnBoundary = false;
proposedSafety = fGhostSafety - currentMinimumStep;
}
else // (currentMinimumStep > fGhostSafety: I may limit the Step)
{
G4FieldTrackUpdator::Update(&fFieldTrack,&track);
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// ComputeStep
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
returnedStep
= fPathFinder->ComputeStep(fFieldTrack,currentMinimumStep,fNavigatorID,
track.GetCurrentStepNumber(),fGhostSafety,eLimited,
endTrack,track.GetVolume());
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
if(eLimited == kDoNot)
{
// Track is not on the boundary
fOnBoundary = false;
fGhostSafety = fGhostNavigator->ComputeSafety(endTrack.GetPosition());
}
else
{
// Track is on the boundary
fOnBoundary = true;
// proposedSafety = fGhostSafety;
}
proposedSafety = fGhostSafety;
if(eLimited == kUnique || eLimited == kSharedOther) {
*selection = CandidateForSelection;
}else if (eLimited == kSharedTransport) {
returnedStep *= (1.0 + 1.0e-9);
// Expand to disable its selection in Step Manager comparison
}
}
// ----------------------------------------------
// Returns the fGhostSafety as the proposedSafety
// The SteppingManager will take care of keeping
// the smallest one.
// ----------------------------------------------
return returnedStep;
}
G4VParticleChange* G4ParallelWorldScoringProcess::AlongStepDoIt(
const G4Track& track, const G4Step& )
{
// Dummy ParticleChange ie: does nothing
// Expecting G4Transportation to move the track
pParticleChange->Initialize(track);
return pParticleChange;
}
void G4ParallelWorldScoringProcess::CopyStep(const G4Step & step)
{
fGhostStep->SetTrack(step.GetTrack());
fGhostStep->SetStepLength(step.GetStepLength());
fGhostStep->SetTotalEnergyDeposit(step.GetTotalEnergyDeposit());
fGhostStep->SetControlFlag(step.GetControlFlag());
*fGhostPreStepPoint = *(step.GetPreStepPoint());
*fGhostPostStepPoint = *(step.GetPostStepPoint());
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// Set StepStatus for ghost world
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
if(fOnBoundary)
{ fGhostPostStepPoint->SetStepStatus(fGeomBoundary); }
else if(fGhostPostStepPoint->GetStepStatus()==fGeomBoundary)
{ fGhostPostStepPoint->SetStepStatus(fPostStepDoItProc); }
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
}
void G4ParallelWorldScoringProcess::Verbose(const G4Step& step) const
{
G4cout << "In mass geometry ------------------------------------------------" << G4endl;
G4cout << " StepLength : " << step.GetStepLength()/mm << " TotalEnergyDeposit : "
<< step.GetTotalEnergyDeposit()/MeV << G4endl;
G4cout << " PreStepPoint : "
<< step.GetPreStepPoint()->GetPhysicalVolume()->GetName() << " - ";
if(step.GetPreStepPoint()->GetProcessDefinedStep())
{ G4cout << step.GetPreStepPoint()->GetProcessDefinedStep()->GetProcessName(); }
else
{ G4cout << "NoProcessAssigned"; }
G4cout << G4endl;
G4cout << " " << step.GetPreStepPoint()->GetPosition() << G4endl;
G4cout << " PostStepPoint : ";
if(step.GetPostStepPoint()->GetPhysicalVolume())
{ G4cout << step.GetPostStepPoint()->GetPhysicalVolume()->GetName(); }
else
{ G4cout << "OutOfWorld"; }
G4cout << " - ";
if(step.GetPostStepPoint()->GetProcessDefinedStep())
{ G4cout << step.GetPostStepPoint()->GetProcessDefinedStep()->GetProcessName(); }
else
{ G4cout << "NoProcessAssigned"; }
G4cout << G4endl;
G4cout << " " << step.GetPostStepPoint()->GetPosition() << G4endl;
G4cout << "In ghost geometry ------------------------------------------------" << G4endl;
G4cout << " StepLength : " << fGhostStep->GetStepLength()/mm
<< " TotalEnergyDeposit : "
<< fGhostStep->GetTotalEnergyDeposit()/MeV << G4endl;
G4cout << " PreStepPoint : "
<< fGhostStep->GetPreStepPoint()->GetPhysicalVolume()->GetName() << " ["
<< fGhostStep->GetPreStepPoint()->GetTouchable()->GetReplicaNumber()
<< " ]" << " - ";
if(fGhostStep->GetPreStepPoint()->GetProcessDefinedStep())
{ G4cout << fGhostStep->GetPreStepPoint()->GetProcessDefinedStep()->GetProcessName(); }
else
{ G4cout << "NoProcessAssigned"; }
G4cout << G4endl;
G4cout << " " << fGhostStep->GetPreStepPoint()->GetPosition() << G4endl;
G4cout << " PostStepPoint : ";
if(fGhostStep->GetPostStepPoint()->GetPhysicalVolume())
{
G4cout << fGhostStep->GetPostStepPoint()->GetPhysicalVolume()->GetName() << " ["
<< fGhostStep->GetPostStepPoint()->GetTouchable()->GetReplicaNumber()
<< " ]";
}
else
{ G4cout << "OutOfWorld"; }
G4cout << " - ";
if(fGhostStep->GetPostStepPoint()->GetProcessDefinedStep())
{ G4cout << fGhostStep->GetPostStepPoint()->GetProcessDefinedStep()->GetProcessName(); }
else
{ G4cout << "NoProcessAssigned"; }
G4cout << G4endl;
G4cout << " " << fGhostStep->GetPostStepPoint()->GetPosition() << " == "
<< fGhostStep->GetTrack()->GetMomentumDirection()
<< G4endl;
}
@@ -0,0 +1,84 @@
//
// ********************************************************************
// * 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: G4ScoreConfigurator.cc,v 1.1 2006/11/20 10:02:17 ahoward Exp $
// GEANT4 tag $Name: geant4-08-02 $
//
// ----------------------------------------------------------------------
// Class G4ScoreConfigurator
//
// Author: Michael Dressel (Michael.Dressel@cern.ch)
// ----------------------------------------------------------------------
#include "G4ScoreConfigurator.hh"
#include "G4VScorer.hh"
#include "G4VTrackTerminator.hh"
#include "G4ScoreProcess.hh"
G4ScoreConfigurator::
G4ScoreConfigurator(G4VPhysicalVolume* worldvolume, const G4String &particlename,
G4VScorer &scorer, G4bool para)
: fWorld(worldvolume),
fPlacer(particlename),
fScorer(scorer),
fScoreProcess(0)
{
paraflag = para;
}
G4ScoreConfigurator::~G4ScoreConfigurator()
{
if (fScoreProcess)
{
fPlacer.RemoveProcess(fScoreProcess);
delete fScoreProcess;
}
}
const G4VTrackTerminator *
G4ScoreConfigurator::GetTrackTerminator() const
{
return fScoreProcess;
}
void G4ScoreConfigurator::Configure(G4VSamplerConfigurator *)
{
G4cout << " entering scoring configure " << G4endl;
fScoreProcess = new G4ScoreProcess(fScorer,"ScoringProcess",paraflag);
G4cout << " creating score process " << G4endl;
if (!fScoreProcess)
{
G4Exception("G4ScoreConfigurator::Configure()",
"FatalError", FatalException,
"Failed allocation of G4ScoreProcess !");
}
G4cout << " setting parallel world " << G4endl;
if(paraflag) fScoreProcess->SetParallelWorld(fWorld);
G4cout << " set " << G4endl;
fPlacer.AddProcessAsSecondDoIt(fScoreProcess);
}
@@ -0,0 +1,413 @@
//
// ********************************************************************
// * 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: G4ScoreProcess.cc,v 1.1 2006/11/20 10:02:18 ahoward Exp $
// GEANT4 tag $Name: geant4-08-02 $
//
// ----------------------------------------------------------------------
// GEANT 4 class source file
//
// G4ScoreProcess.cc
//
// ----------------------------------------------------------------------
#include "G4ScoreProcess.hh"
#include "G4VScorer.hh"
#include "G4GeometryCellStep.hh"
#include "G4Step.hh"
#include "G4Navigator.hh"
#include "G4VTouchable.hh"
#include "G4VPhysicalVolume.hh"
#include "G4ParticleChange.hh"
#include "G4PathFinder.hh"
#include "G4TransportationManager.hh"
#include "G4StepPoint.hh"
#include "G4FieldTrackUpdator.hh"
G4ScoreProcess::G4ScoreProcess(G4VScorer &aScorer,
const G4String &aName, G4bool para)
: G4VProcess(aName),
fParticleChange(new G4ParticleChange),
fScorer(aScorer),
fKillTrack(false),
fGhostNavigator(0), fNavigatorID(-1), fFieldTrack('0')
{
if (!fParticleChange)
{
G4Exception("G4ScoreProcess::G4ScoreProcess()", "Fatal Error",
FatalException, "Failed to allocate G4ParticleChange !");
}
G4VProcess::pParticleChange = fParticleChange;
fGhostStep = new G4Step();
fGhostPreStepPoint = fGhostStep->GetPreStepPoint();
fGhostPostStepPoint = fGhostStep->GetPostStepPoint();
fTransportationManager = G4TransportationManager::GetTransportationManager();
fPathFinder = G4PathFinder::GetInstance();
if (verboseLevel>0)
{
G4cout << GetProcessName() << " is created " << G4endl;
}
paraflag = para;
}
G4ScoreProcess::~G4ScoreProcess()
{
delete fParticleChange;
delete fGhostStep;
}
//------------------------------------------------------
//
// SetParallelWorld
//
//------------------------------------------------------
void G4ScoreProcess::
SetParallelWorld(G4String parallelWorldName)
{
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// Get pointers of the parallel world and its navigator
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
fGhostWorldName = parallelWorldName;
fGhostWorld = fTransportationManager->GetParallelWorld(fGhostWorldName);
fGhostNavigator = fTransportationManager->GetNavigator(fGhostWorld);
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
}
void G4ScoreProcess::
SetParallelWorld(G4VPhysicalVolume* parallelWorld)
{
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// Get pointer of navigator
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
G4cout << " Getting Name: " << G4endl;
fGhostWorldName = parallelWorld->GetName();
G4cout << " Get Name :" << fGhostWorldName << G4endl;
fGhostWorld = parallelWorld;
fGhostNavigator = fTransportationManager->GetNavigator(fGhostWorld);
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
}
//------------------------------------------------------
//
// StartTracking
//
//------------------------------------------------------
void G4ScoreProcess::StartTracking(G4Track* trk)
{
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// Activate navigator and get the navigator ID
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// G4cout << " G4ParallelWorldScoringProcess::StartTracking" << G4endl;
if(paraflag) {
if(fGhostNavigator)
{ fNavigatorID = fTransportationManager->ActivateNavigator(fGhostNavigator); }
else
{
G4Exception("G4ScoreProcess::StartTracking",
"ProcParaWorld000",FatalException,
"G4ScoreProcess is used for tracking without having a parallel world assigned");
}
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// G4cout << "G4ParallelWorldScoringProcess::StartTracking <<<<<<<<<<<<<<<<<< " << G4endl;
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// Let PathFinder initialize
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
fPathFinder->PrepareNewTrack(trk->GetPosition(),trk->GetMomentumDirection());
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// Setup initial touchables for the first step
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
fOldGhostTouchable = fPathFinder->CreateTouchableHandle(fNavigatorID);
fGhostPreStepPoint->SetTouchableHandle(fOldGhostTouchable);
fNewGhostTouchable = fOldGhostTouchable;
fGhostPostStepPoint->SetTouchableHandle(fNewGhostTouchable);
// Initialize
fGhostSafety = -1.;
fOnBoundary = false;
}
}
G4double G4ScoreProcess::
PostStepGetPhysicalInteractionLength(const G4Track&,
G4double ,
G4ForceCondition* condition)
{
// *condition = Forced;
// return kInfinity;
// *condition = StronglyForced;
*condition = Forced;
return DBL_MAX;
}
G4VParticleChange *
G4ScoreProcess::PostStepDoIt(const G4Track& aTrack, const G4Step &aStep)
{
//AH G4cout << " inside scoring post-step, track: " << aTrack.GetTrackID() << " step: " << aTrack.GetCurrentStepNumber() << G4endl;
//AH G4cout << " and fOnBoundary " << fOnBoundary << G4endl;
fParticleChange->Initialize(aTrack);
if(paraflag) {
fOldGhostTouchable = fGhostPostStepPoint->GetTouchableHandle();
//xbug? fOnBoundary = false;
CopyStep(aStep);
if(fOnBoundary)
{
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// Locate the point and get new touchable
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//?? fPathFinder->Locate(step.GetPostStepPoint()->GetPosition(),
//?? step.GetPostStepPoint()->GetMomentumDirection());
//AH G4cout << " GOT HERE? inside post step " << G4endl;
fNewGhostTouchable = fPathFinder->CreateTouchableHandle(fNavigatorID);
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
}
else
{
// Do I need this ??????????????????????????????????????????????????????????
// fGhostNavigator->LocateGlobalPointWithinVolume(track.GetPosition());
// ?????????????????????????????????????????????????????????????????????????
// fPathFinder->ReLocate(track.GetPosition());
// reuse the touchable
fNewGhostTouchable = fOldGhostTouchable;
}
fGhostPreStepPoint->SetTouchableHandle(fOldGhostTouchable);
fGhostPostStepPoint->SetTouchableHandle(fNewGhostTouchable);
}
// G4StepPoint *prepoint = aStep.GetPreStepPoint();
// G4StepPoint *postpoint = aStep.GetPostStepPoint();
// G4GeometryCell prekey(*(prepoint->GetPhysicalVolume()),
// prepoint->GetTouchable()->GetReplicaNumber());
// G4GeometryCell postkey(*(postpoint->GetPhysicalVolume()),
// postpoint->GetTouchable()->GetReplicaNumber());
if(paraflag) {
if (fGhostStep->GetStepLength() > kCarTolerance)
{
G4GeometryCell prekey(*(fGhostPreStepPoint->GetPhysicalVolume()),
fGhostPreStepPoint->GetTouchable()->GetReplicaNumber());
G4GeometryCell postkey(*(fGhostPostStepPoint->GetPhysicalVolume()),
fGhostPostStepPoint->GetTouchable()->GetReplicaNumber());
G4GeometryCellStep pstep(prekey, postkey);
pstep.SetCrossBoundary(false);
//xxtest pstep.SetCrossBoundary(true);
if (prekey != postkey)
{
pstep.SetCrossBoundary(true);
}
fScorer.Score(aStep, pstep);
} else {
if (aStep.GetStepLength() > kCarTolerance)
{
G4StepPoint *prepoint = aStep.GetPreStepPoint();
G4StepPoint *postpoint = aStep.GetPostStepPoint();
G4GeometryCell prekey(*(prepoint->GetPhysicalVolume()),
prepoint->GetTouchable()->GetReplicaNumber());
G4GeometryCell postkey(*(postpoint->GetPhysicalVolume()),
postpoint->GetTouchable()->GetReplicaNumber());
G4GeometryCellStep pstep(prekey, postkey);
pstep.SetCrossBoundary(false);
if (prekey != postkey)
{
pstep.SetCrossBoundary(true);
}
fScorer.Score(aStep, pstep);
}
}
}
if (fKillTrack)
{
//AH G4cout << " score process is killing track - why? " << G4endl;
fKillTrack = false;
fParticleChange->ProposeTrackStatus(fStopAndKill);
}
return fParticleChange;
// return G4VProcess::pParticleChange;
}
const G4String &G4ScoreProcess::GetName() const
{
return theProcessName;
}
G4double G4ScoreProcess::
AlongStepGetPhysicalInteractionLength(
const G4Track& track, G4double previousStepSize, G4double currentMinimumStep,
G4double& proposedSafety, G4GPILSelection* selection)
{
//AH G4cout << " inside scoring along-step GPIL, track : " << track.GetTrackID() << " step#: " << track.GetCurrentStepNumber() << G4endl;
if(paraflag) {
static G4FieldTrack endTrack('0');
static ELimited eLimited;
*selection = NotCandidateForSelection;
G4double returnedStep = DBL_MAX;
if (previousStepSize > 0.)
{ fGhostSafety -= previousStepSize; }
// else
// { fGhostSafety = -1.; }
if (fGhostSafety < 0.) fGhostSafety = 0.0;
// ------------------------------------------
// Determination of the proposed STEP LENGTH:
// ------------------------------------------
if (currentMinimumStep <= fGhostSafety && currentMinimumStep > 0.)
{
// I have no chance to limit
returnedStep = currentMinimumStep;
fOnBoundary = false;
proposedSafety = fGhostSafety - currentMinimumStep;
}
else // (currentMinimumStep > fGhostSafety: I may limit the Step)
{
G4FieldTrackUpdator::Update(&fFieldTrack,&track);
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// ComputeStep
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
returnedStep
= fPathFinder->ComputeStep(fFieldTrack,currentMinimumStep,fNavigatorID,
track.GetCurrentStepNumber(),fGhostSafety,eLimited,
endTrack,track.GetVolume());
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
if(eLimited == kDoNot)
{
// Track is not on the boundary
fOnBoundary = false;
fGhostSafety = fGhostNavigator->ComputeSafety(endTrack.GetPosition());
}
else
{
// Track is on the boundary
//AH G4cout << " GOT HERE " << G4endl;
fOnBoundary = true;
proposedSafety = fGhostSafety;
}
//xbug? proposedSafety = fGhostSafety;
if(eLimited == kUnique || eLimited == kSharedOther) {
*selection = CandidateForSelection;
}else if (eLimited == kSharedTransport) {
returnedStep *= (1.0 + 1.0e-9);
// Expand to disable its selection in Step Manager comparison
}
}
// ----------------------------------------------
// Returns the fGhostSafety as the proposedSafety
// The SteppingManager will take care of keeping
// the smallest one.
// ----------------------------------------------
return returnedStep;
} else {
return DBL_MAX;
// not sensible! return -1.0;
}
}
G4double G4ScoreProcess::
AtRestGetPhysicalInteractionLength(const G4Track&,
G4ForceCondition*)
{
return -1.0;
}
G4VParticleChange* G4ScoreProcess::AtRestDoIt(const G4Track&,
const G4Step&)
{
return 0;
}
G4VParticleChange* G4ScoreProcess::AlongStepDoIt(const G4Track& track,
const G4Step&)
{
// Dummy ParticleChange ie: does nothing
// Expecting G4Transportation to move the track
pParticleChange->Initialize(track);
return pParticleChange;
// return 0;
}
void G4ScoreProcess::KillTrack() const
{
fKillTrack = true;
}
void G4ScoreProcess::CopyStep(const G4Step & step)
{
fGhostStep->SetTrack(step.GetTrack());
fGhostStep->SetStepLength(step.GetStepLength());
fGhostStep->SetTotalEnergyDeposit(step.GetTotalEnergyDeposit());
fGhostStep->SetControlFlag(step.GetControlFlag());
*fGhostPreStepPoint = *(step.GetPreStepPoint());
*fGhostPostStepPoint = *(step.GetPostStepPoint());
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// Set StepStatus for ghost world
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
if(fOnBoundary)
{ fGhostPostStepPoint->SetStepStatus(fGeomBoundary); }
else if(fGhostPostStepPoint->GetStepStatus()==fGeomBoundary)
{ fGhostPostStepPoint->SetStepStatus(fPostStepDoItProc); }
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
}
@@ -0,0 +1,97 @@
//
// ********************************************************************
// * 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: G4WeightWindowConfigurator.cc,v 1.1 2006/11/20 10:02:19 ahoward Exp $
// GEANT4 tag $Name: geant4-08-02 $
//
// ----------------------------------------------------------------------
// Class G4WeightWindowConfigurator
//
// Author: Michael Dressel (Michael.Dressel@cern.ch)
// ----------------------------------------------------------------------
#include "G4WeightWindowConfigurator.hh"
#include "G4WeightWindowAlgorithm.hh"
#include "G4WeightWindowProcess.hh"
G4WeightWindowConfigurator::
G4WeightWindowConfigurator(G4VPhysicalVolume* worldvolume,
const G4String &particlename,
G4VWeightWindowStore &wwstore,
const G4VWeightWindowAlgorithm *wwAlg,
G4PlaceOfAction placeOfAction, G4bool para)
: fWorld(worldvolume),
fPlacer(particlename),
fWeightWindowStore(wwstore),
fDeleteWWalg( ( ! wwAlg) ),
fWWalgorithm(( (fDeleteWWalg) ?
new G4WeightWindowAlgorithm(5,3,5) : wwAlg)),
fWeightWindowProcess(0),
fPlaceOfAction(placeOfAction)
{
paraflag = para;
}
G4WeightWindowConfigurator::~G4WeightWindowConfigurator()
{
if (fWeightWindowProcess)
{
fPlacer.RemoveProcess(fWeightWindowProcess);
delete fWeightWindowProcess;
}
if (fDeleteWWalg)
{
delete fWWalgorithm;
}
}
void
G4WeightWindowConfigurator::Configure(G4VSamplerConfigurator *preConf)
{
G4cout << " entering weight window configure " << G4endl;
const G4VTrackTerminator *terminator = 0;
if (preConf)
{
terminator = preConf->GetTrackTerminator();
};
fWeightWindowProcess =
new G4WeightWindowProcess(*fWWalgorithm,
fWeightWindowStore,
terminator,
fPlaceOfAction,"WeightWindowProcess",paraflag);
if(paraflag) fWeightWindowProcess->SetParallelWorld(fWorld);
fPlacer.AddProcessAsSecondDoIt(fWeightWindowProcess);
}
const G4VTrackTerminator *
G4WeightWindowConfigurator::GetTrackTerminator() const
{
return fWeightWindowProcess;
}
@@ -0,0 +1,417 @@
//
// ********************************************************************
// * 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: G4WeightWindowProcess.cc,v 1.1 2006/11/20 10:02:19 ahoward Exp $
// GEANT4 tag $Name: geant4-08-02 $
//
// ----------------------------------------------------------------------
// GEANT 4 class source file
//
// G4WeightWindowProcess.cc
//
// ----------------------------------------------------------------------
#include "G4WeightWindowProcess.hh"
#include "G4VWeightWindowAlgorithm.hh"
#include "G4GeometryCell.hh"
#include "G4SamplingPostStepAction.hh"
#include "G4VTrackTerminator.hh"
#include "G4PlaceOfAction.hh"
#include "G4VWeightWindowStore.hh"
#include "G4Step.hh"
#include "G4Navigator.hh"
#include "G4VTouchable.hh"
#include "G4VPhysicalVolume.hh"
#include "G4ParticleChange.hh"
#include "G4PathFinder.hh"
#include "G4TransportationManager.hh"
#include "G4StepPoint.hh"
#include "G4FieldTrackUpdator.hh"
G4WeightWindowProcess::G4WeightWindowProcess(
const G4VWeightWindowAlgorithm &aWeightWindowAlgorithm,
const G4VWeightWindowStore &aWWStore,
const G4VTrackTerminator *TrackTerminator,
G4PlaceOfAction placeOfAction,
const G4String &aName, G4bool para)
: G4VProcess(aName),
fParticleChange(new G4ParticleChange),
fWeightWindowAlgorithm(aWeightWindowAlgorithm),
fWeightWindowStore(aWWStore),
fPostStepAction(0),
fPlaceOfAction(placeOfAction),
fGhostNavigator(0), fNavigatorID(-1), fFieldTrack('0')
{
if (TrackTerminator)
{
fPostStepAction = new G4SamplingPostStepAction(*TrackTerminator);
}
else
{
fPostStepAction = new G4SamplingPostStepAction(*this);
}
if (!fParticleChange)
{
G4Exception("G4WeightWindowProcess::G4WeightWindowProcess()",
"FatalError", FatalException,
"Failed allocation of G4ParticleChange !");
}
G4VProcess::pParticleChange = fParticleChange;
fGhostStep = new G4Step();
fGhostPreStepPoint = fGhostStep->GetPreStepPoint();
fGhostPostStepPoint = fGhostStep->GetPostStepPoint();
fTransportationManager = G4TransportationManager::GetTransportationManager();
fPathFinder = G4PathFinder::GetInstance();
if (verboseLevel>0)
{
G4cout << GetProcessName() << " is created " << G4endl;
}
paraflag = para;
}
G4WeightWindowProcess::~G4WeightWindowProcess()
{
delete fPostStepAction;
delete fParticleChange;
delete fGhostStep;
}
//------------------------------------------------------
//
// SetParallelWorld
//
//------------------------------------------------------
void G4WeightWindowProcess::
SetParallelWorld(G4String parallelWorldName)
{
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// Get pointers of the parallel world and its navigator
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
fGhostWorldName = parallelWorldName;
fGhostWorld = fTransportationManager->GetParallelWorld(fGhostWorldName);
fGhostNavigator = fTransportationManager->GetNavigator(fGhostWorld);
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
}
void G4WeightWindowProcess::
SetParallelWorld(G4VPhysicalVolume* parallelWorld)
{
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// Get pointer of navigator
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
fGhostWorldName = parallelWorld->GetName();
fGhostWorld = parallelWorld;
fGhostNavigator = fTransportationManager->GetNavigator(fGhostWorld);
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
}
//------------------------------------------------------
//
// StartTracking
//
//------------------------------------------------------
void G4WeightWindowProcess::StartTracking(G4Track* trk)
{
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// Activate navigator and get the navigator ID
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// G4cout << " G4ParallelWorldScoringProcess::StartTracking" << G4endl;
if(paraflag) {
if(fGhostNavigator)
{ fNavigatorID = fTransportationManager->ActivateNavigator(fGhostNavigator); }
else
{
G4Exception("G4WeightWindowProcess::StartTracking",
"ProcParaWorld000",FatalException,
"G4WeightWindowProcess is used for tracking without having a parallel world assigned");
}
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// G4cout << "G4ParallelWorldScoringProcess::StartTracking <<<<<<<<<<<<<<<<<< " << G4endl;
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// Let PathFinder initialize
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
fPathFinder->PrepareNewTrack(trk->GetPosition(),trk->GetMomentumDirection());
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// Setup initial touchables for the first step
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
fOldGhostTouchable = fPathFinder->CreateTouchableHandle(fNavigatorID);
fGhostPreStepPoint->SetTouchableHandle(fOldGhostTouchable);
fNewGhostTouchable = fOldGhostTouchable;
fGhostPostStepPoint->SetTouchableHandle(fNewGhostTouchable);
// Initialize
fGhostSafety = -1.;
fOnBoundary = false;
}
}
G4double G4WeightWindowProcess::
PostStepGetPhysicalInteractionLength(const G4Track& ,
G4double ,
G4ForceCondition* condition)
{
// *condition = Forced;
// return kInfinity;
// *condition = StronglyForced;
*condition = Forced;
return DBL_MAX;
}
G4VParticleChange *
G4WeightWindowProcess::PostStepDoIt(const G4Track &aTrack,
const G4Step &aStep)
{
fParticleChange->Initialize(aTrack);
if(paraflag) {
fOldGhostTouchable = fGhostPostStepPoint->GetTouchableHandle();
//xbug? fOnBoundary = false;
CopyStep(aStep);
if(fOnBoundary)
{
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// Locate the point and get new touchable
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//?? fPathFinder->Locate(step.GetPostStepPoint()->GetPosition(),
//?? step.GetPostStepPoint()->GetMomentumDirection());
fNewGhostTouchable = fPathFinder->CreateTouchableHandle(fNavigatorID);
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
}
else
{
// Do I need this ??????????????????????????????????????????????????????????
// fGhostNavigator->LocateGlobalPointWithinVolume(track.GetPosition());
// ?????????????????????????????????????????????????????????????????????????
// fPathFinder->ReLocate(track.GetPosition());
// reuse the touchable
fNewGhostTouchable = fOldGhostTouchable;
}
fGhostPreStepPoint->SetTouchableHandle(fOldGhostTouchable);
fGhostPostStepPoint->SetTouchableHandle(fNewGhostTouchable);
}
if (aStep.GetStepLength() > kCarTolerance)
{
// if ( ( fPlaceOfAction == onBoundaryAndCollision)
// || ( (fPlaceOfAction == onBoundary) &&
// (aStep.GetPostStepPoint()->GetStepStatus() == fGeomBoundary) )
// || ( (fPlaceOfAction == onCollision) &&
// (aStep.GetPostStepPoint()->GetStepStatus() != fGeomBoundary) ) )
if(paraflag) {
if ( ( fPlaceOfAction == onBoundaryAndCollision)
|| ( (fPlaceOfAction == onBoundary) &&
(fGhostPostStepPoint->GetStepStatus() == fGeomBoundary) )
|| ( (fPlaceOfAction == onCollision) &&
(fGhostPostStepPoint->GetStepStatus() != fGeomBoundary) ) )
{
// G4StepPoint *postpoint = aStep.GetPostStepPoint();
// G4GeometryCell postCell(*(postpoint->GetPhysicalVolume()),
// postpoint->GetTouchable()->GetReplicaNumber());
G4GeometryCell postCell(*(fGhostPostStepPoint->GetPhysicalVolume()),
fGhostPostStepPoint->GetTouchable()->GetReplicaNumber());
G4Nsplit_Weight nw =
fWeightWindowAlgorithm.Calculate(aTrack.GetWeight(),
fWeightWindowStore.GetLowerWeitgh(postCell,
aTrack.GetKineticEnergy()));
fPostStepAction->DoIt(aTrack, fParticleChange, nw);
}
} else {
if ( ( fPlaceOfAction == onBoundaryAndCollision)
|| ( (fPlaceOfAction == onBoundary) &&
(aStep.GetPostStepPoint()->GetStepStatus() == fGeomBoundary) )
|| ( (fPlaceOfAction == onCollision) &&
(aStep.GetPostStepPoint()->GetStepStatus() != fGeomBoundary) ) )
{
G4StepPoint *postpoint = aStep.GetPostStepPoint();
G4GeometryCell postCell(*(postpoint->GetPhysicalVolume()),
postpoint->GetTouchable()->GetReplicaNumber());
G4Nsplit_Weight nw =
fWeightWindowAlgorithm.Calculate(aTrack.GetWeight(),
fWeightWindowStore.GetLowerWeitgh(postCell,
aTrack.GetKineticEnergy()));
fPostStepAction->DoIt(aTrack, fParticleChange, nw);
}
}
}
return fParticleChange;
}
void G4WeightWindowProcess::KillTrack() const
{
fParticleChange->ProposeTrackStatus(fStopAndKill);
}
const G4String &G4WeightWindowProcess::GetName() const
{
return G4VProcess::GetProcessName();
}
G4double G4WeightWindowProcess::
AlongStepGetPhysicalInteractionLength(
const G4Track& track, G4double previousStepSize, G4double currentMinimumStep,
G4double& proposedSafety, G4GPILSelection* selection)
{
if(paraflag) {
static G4FieldTrack endTrack('0');
static ELimited eLimited;
*selection = NotCandidateForSelection;
G4double returnedStep = DBL_MAX;
if (previousStepSize > 0.)
{ fGhostSafety -= previousStepSize; }
// else
// { fGhostSafety = -1.; }
if (fGhostSafety < 0.) fGhostSafety = 0.0;
// ------------------------------------------
// Determination of the proposed STEP LENGTH:
// ------------------------------------------
if (currentMinimumStep <= fGhostSafety && currentMinimumStep > 0.)
{
// I have no chance to limit
returnedStep = currentMinimumStep;
fOnBoundary = false;
proposedSafety = fGhostSafety - currentMinimumStep;
}
else // (currentMinimumStep > fGhostSafety: I may limit the Step)
{
G4FieldTrackUpdator::Update(&fFieldTrack,&track);
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// ComputeStep
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
returnedStep
= fPathFinder->ComputeStep(fFieldTrack,currentMinimumStep,fNavigatorID,
track.GetCurrentStepNumber(),fGhostSafety,eLimited,
endTrack,track.GetVolume());
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
if(eLimited == kDoNot)
{
// Track is not on the boundary
fOnBoundary = false;
fGhostSafety = fGhostNavigator->ComputeSafety(endTrack.GetPosition());
}
else
{
// Track is on the boundary
fOnBoundary = true;
proposedSafety = fGhostSafety;
}
//xbug? proposedSafety = fGhostSafety;
if(eLimited == kUnique || eLimited == kSharedOther) {
*selection = CandidateForSelection;
}else if (eLimited == kSharedTransport) {
returnedStep *= (1.0 + 1.0e-9);
// Expand to disable its selection in Step Manager comparison
}
}
// ----------------------------------------------
// Returns the fGhostSafety as the proposedSafety
// The SteppingManager will take care of keeping
// the smallest one.
// ----------------------------------------------
return returnedStep;
} else {
return DBL_MAX;
// not sensible - time goes backwards! return -1.0;
}
}
G4double G4WeightWindowProcess::
AtRestGetPhysicalInteractionLength(const G4Track& ,
G4ForceCondition*)
{
return -1.0;
}
G4VParticleChange* G4WeightWindowProcess::
AtRestDoIt(const G4Track&, const G4Step&)
{
return 0;
}
G4VParticleChange* G4WeightWindowProcess::
AlongStepDoIt(const G4Track& track, const G4Step&)
{
// Dummy ParticleChange ie: does nothing
// Expecting G4Transportation to move the track
pParticleChange->Initialize(track);
return pParticleChange;
// return 0;
}
void G4WeightWindowProcess::CopyStep(const G4Step & step)
{
fGhostStep->SetTrack(step.GetTrack());
fGhostStep->SetStepLength(step.GetStepLength());
fGhostStep->SetTotalEnergyDeposit(step.GetTotalEnergyDeposit());
fGhostStep->SetControlFlag(step.GetControlFlag());
*fGhostPreStepPoint = *(step.GetPreStepPoint());
*fGhostPostStepPoint = *(step.GetPostStepPoint());
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// Set StepStatus for ghost world
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
if(fOnBoundary)
{ fGhostPostStepPoint->SetStepStatus(fGeomBoundary); }
else if(fGhostPostStepPoint->GetStepStatus()==fGeomBoundary)
{ fGhostPostStepPoint->SetStepStatus(fPostStepDoItProc); }
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
}