Import Geant4 0.0.0 source tree
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
# $Id: GNUmakefile,v 2.0 1998/07/02 16:41:34 gunter Exp $
|
||||
# ------------------------------------------------------------
|
||||
# GNUmakefile for transportation library. G.Folger 10-Dec-97.
|
||||
# ------------------------------------------------------------
|
||||
|
||||
name := G4parameterisation
|
||||
|
||||
ifndef G4INSTALL
|
||||
G4INSTALL = ../../..
|
||||
endif
|
||||
|
||||
include $(G4INSTALL)/config/architecture.gmk
|
||||
|
||||
CPPFLAGS += -I$(G4BASE)/global/management/include \
|
||||
-I$(G4BASE)/global/HEPRandom/include \
|
||||
-I$(G4BASE)/global/HEPGeometry/include \
|
||||
-I$(G4BASE)/geometry/management/include \
|
||||
-I$(G4BASE)/geometry/volumes/include \
|
||||
-I$(G4BASE)/geometry/magneticfield/include \
|
||||
-I$(G4BASE)/geometry/solids/CSG/include \
|
||||
-I$(G4BASE)/intercoms/include \
|
||||
-I$(G4BASE)/track/include \
|
||||
-I$(G4BASE)/processes/management/include \
|
||||
-I$(G4BASE)/particles/management/include \
|
||||
-I$(G4BASE)/materials/include \
|
||||
|
||||
include $(G4INSTALL)/config/common.gmk
|
||||
@@ -0,0 +1,188 @@
|
||||
$Id: History,v 2.14 1998/12/08 04:06:31 verderi Exp $
|
||||
-------------------------------------------------------------------
|
||||
|
||||
=========================================================
|
||||
Geant4 - an Object-Oriented Toolkit for Simulation in HEP
|
||||
=========================================================
|
||||
|
||||
Category History file
|
||||
---------------------
|
||||
This file should be used by G4 developers and category coordinators
|
||||
to briefly summarize all major modifications introduced in the code
|
||||
and keep track of all category-tags.
|
||||
It DOES NOT substitute the CVS log-message one should put at every
|
||||
committal in the CVS repository !
|
||||
|
||||
----------------------------------------------------------
|
||||
* Reverse chronological order (last date on top), please *
|
||||
----------------------------------------------------------
|
||||
December 7, 1998 M. Verderi
|
||||
G4FastSimulationManagerProcess class:
|
||||
Fixes made for ghost navigation with
|
||||
mag-field:
|
||||
LocateGlobalPointAndUpdateTouchable is
|
||||
always used (in not the Locate...Setup
|
||||
method)
|
||||
In PostStepDoIt: correction of position and
|
||||
direction of the track are made when
|
||||
possible in case of mag-field.
|
||||
This correction comes from the fact that a
|
||||
small discrepancy appears on those quantities
|
||||
because of the numerical integration along
|
||||
the field on the track path: the G4FSMP
|
||||
proposes a curve-length, the transportation
|
||||
moves the track along this curve, however
|
||||
the end point position and direction are
|
||||
slightly different from those expected by
|
||||
the G4FSMP when it proposed the length.
|
||||
|
||||
November 20,1998 M. Verderi
|
||||
G4FastStep class:
|
||||
Remove track/G4BiasingTag.hh dependancy (obsolete).
|
||||
Adapted to new shceme of Event Biasing mechanism,
|
||||
consistently with track-00-04-01 tag.
|
||||
|
||||
November 11,1998 M. Verderi
|
||||
Merge of param-00-03-02 & param-00-03-02a into
|
||||
param-00-03-04a (hopefully...)
|
||||
The point is the chnage of signature in the
|
||||
LocateGlobalPointAndSetup(..) of the G4Navigator making use now
|
||||
of the track direction. The G4FastSimulationManagerProcess is
|
||||
changed accordingly:
|
||||
fGhostNavigator.LocateGlobalPointAndSetup(track.GetPosition(), &direction, true);
|
||||
|
||||
|
||||
November 6, 1998 M. Verderi
|
||||
- Extension of the G4FastStep to allow the biasing technic.
|
||||
Changes are made in:
|
||||
- G4FastStep.hh/.icc:
|
||||
new member G4BiasingTag fBiasTag;
|
||||
new method SetPrimaryTrackFinalBiasingTag
|
||||
( G4BiasingTag aTag );
|
||||
- G4FastStep.cc:
|
||||
Initialize();
|
||||
operator=;
|
||||
UpdateForPostStep();
|
||||
UpdateForAtRest();
|
||||
|
||||
October 26, 1998 P.Mora de Freitas
|
||||
- G4FastSimulationManagerProcess and G4FastSimulationManager adapted to deal
|
||||
with at rest parameterisations also when using parallel geometry.
|
||||
|
||||
October 8, 1998 P.Mora de Freitas
|
||||
- The G4VFastSimulationModel::IsApplicable() becomes a pure virtual
|
||||
methode.
|
||||
- G4FastSimulationManager optimisation:
|
||||
- New G4ParticleDefinition* fLastCrossedParticle data member, keeps
|
||||
the last particle type with touched the envelope;
|
||||
- New RWTPtrOrderedVector<G4VFastSimulationModel> fApplicableModelList
|
||||
data member, keeps the model list of the applicable models for
|
||||
the actual fLastCrossedParticle particle type;
|
||||
- Changes in the PostStepGetFastSimulationManagerTrigger() and
|
||||
AtRestGetFastSimulationManagerTrigger()methodes to update the
|
||||
fApplicableModelList when needed (fLastCrossedParticle !=
|
||||
the actual tracked particle);
|
||||
- Changes in the
|
||||
G4FastSimulationManager() (Constructor)
|
||||
ActivateFastSimulationModel(),
|
||||
InActivateFastSimulationModel(),
|
||||
AtRestGetFastSimulationManagerTrigger(),
|
||||
AddFastSimulationModel(),
|
||||
RemoveFastSimulationModel()
|
||||
methodes to set the fLastCrossedParticle to NULL, forcing the
|
||||
fApplicableModelList to be rebuilt.
|
||||
|
||||
September 22, 1998 P.Mora de Freitas
|
||||
Fixed bug in parallel navigation.
|
||||
File touched: G4FastSimulationManagerProcess.cc
|
||||
Tested on HP-aCC.
|
||||
|
||||
September 17, 1998 P.Mora de Freitas
|
||||
G4FastSimulationManager::RemoveFastSimulationModel() updated to look
|
||||
for also in the fInactivatedModels list.
|
||||
|
||||
Tested on HP-aCC.
|
||||
|
||||
September 16, 1998 P.Mora de Freitas
|
||||
New /param/ control commands:
|
||||
|
||||
/param/ActivateModel <ModelName>
|
||||
/param/InActivateModel <ModelName>
|
||||
|
||||
Activate or inactivate a given parameterisation model.
|
||||
|
||||
Tested on HP-aCC.
|
||||
|
||||
August 21, 1998 P.Mora de Freitas
|
||||
G4FastSimulationManagerProcess's G4ProcessType set to
|
||||
fParameterisation, accordingly with procman-00-02-03.
|
||||
|
||||
Tested on HP-aCC.
|
||||
|
||||
August 12, 1998 P.Mora de Freitas
|
||||
Improved the "close parameterisation control" to
|
||||
|
||||
1) avoid the close looping when unnecessary (mostly cases);
|
||||
2) force re-close when necessary (insert/remove ghosts).
|
||||
|
||||
Changes:
|
||||
|
||||
1) the G4GlobalFastSimulationManager::fClosed is now initialised
|
||||
to true by the G4GlobalFastSimulationManager constructor;
|
||||
|
||||
2) new method
|
||||
|
||||
void
|
||||
G4GlobalFastSimulationManager::FastSimulationNeedsToBeClosed();
|
||||
|
||||
called by the AddGhostPlacement and RemoveGhostPlacement
|
||||
G4FastSimulationManager methods to set false the fClosed flag;
|
||||
|
||||
3) changes in the G4GlobalFastSimulationManager::Notify method
|
||||
to deal with these changes.
|
||||
|
||||
Tested on HP-aCC.
|
||||
|
||||
August 11, 1998 P.Mora de Freitas
|
||||
Fix to the G4FastStep::KillPrimaryTrack() method to drop the
|
||||
nonsense line
|
||||
|
||||
SetMomentumChange(0.,0.,0.) ; /* necessary ? */
|
||||
|
||||
Tested on HP-aCC.
|
||||
(Thanks to Willy Langeveld)
|
||||
|
||||
|
||||
August 10, 1998 P.Mora de Freitas
|
||||
Fix to the SetPrimaryTrackFinalKineticEnergyAndDirection() method
|
||||
from the G4FastStep class the SetMomentumChange() call to insure that
|
||||
the new momentum direction is a unit vector (as asked by the
|
||||
G4DynamicParticle::SetMomentumDirection method).
|
||||
|
||||
Touched files: G4FastStep.hh (improved comments)
|
||||
G4FastStep.cc (fixed)
|
||||
|
||||
Tested on HP-aCC.
|
||||
(Thanks to Willy Langeveld)
|
||||
|
||||
August 7, 1998 P.Mora de Freitas
|
||||
New /param/ commands directory with the commands:
|
||||
|
||||
/param/listEnvelopes [ParticleName]
|
||||
|
||||
- List all the envelope names for a given particle
|
||||
(or for all particles if without parameters).
|
||||
|
||||
/param/listModels [EnvelopeName]
|
||||
|
||||
- List all the Model names for a given envelope
|
||||
(or for all envelopes if without parameters).
|
||||
|
||||
/param/listIsApplicable [ModelName]
|
||||
|
||||
- List all the particle names a given model is applicable
|
||||
(or for all models if without parameters).
|
||||
|
||||
|
||||
August 7, 1998 P.Mora de Freitas
|
||||
History file Created.
|
||||
@@ -0,0 +1,178 @@
|
||||
// This code implementation is the intellectual property of
|
||||
// the RD44 GEANT4 collaboration.
|
||||
//
|
||||
// By copying, distributing or modifying the Program (or any work
|
||||
// based on the Program) you indicate your acceptance of this statement,
|
||||
// and all its terms.
|
||||
//
|
||||
// $Id: G4FastSimulationManager.hh,v 2.7 1998/10/26 14:31:33 mora Exp $
|
||||
// GEANT4 tag $Name: geant4-00 $
|
||||
//
|
||||
//
|
||||
//---------------------------------------------------------------
|
||||
//
|
||||
// G4FastSimulationManager.hh
|
||||
//
|
||||
// Description:
|
||||
// Manages the Fast Simulation models attached to a envelope.
|
||||
//
|
||||
// History:
|
||||
// Oct 97: Verderi && MoraDeFreitas - First Implementation.
|
||||
//
|
||||
//---------------------------------------------------------------
|
||||
|
||||
|
||||
#ifndef G4FastSimulationManager_h
|
||||
#define G4FastSimulationManager_h 1
|
||||
|
||||
#include <rw/tpordvec.h>
|
||||
|
||||
#include "globals.hh"
|
||||
#include "G4LogicalVolume.hh"
|
||||
#include "G4VPhysicalVolume.hh"
|
||||
#include "G4ParticleTable.hh"
|
||||
#include "G4ParticleDefinition.hh"
|
||||
#include "G4VParticleChange.hh"
|
||||
#include "G4FastTrack.hh"
|
||||
#include "G4FastStep.hh"
|
||||
#include "G4VFastSimulationModel.hh"
|
||||
#include "G4RotationMatrix.hh"
|
||||
#include "G4ThreeVector.hh"
|
||||
#include "G4Transform3D.hh"
|
||||
|
||||
#include "G4ios.hh"
|
||||
|
||||
//---------------------------
|
||||
// For possible future needs:
|
||||
//---------------------------
|
||||
typedef G4LogicalVolume G4Envelope;
|
||||
|
||||
//-------------------------------------------
|
||||
//
|
||||
// G4FastSimulationManager class
|
||||
//
|
||||
//-------------------------------------------
|
||||
class G4FastSimulationManager
|
||||
{
|
||||
public:
|
||||
//------------------------
|
||||
// Constructor/Destructor
|
||||
//------------------------
|
||||
// Only one Constructor. By default the envelope can
|
||||
// be placed n-Times.
|
||||
// If the user is sure that it'll be placed just one time,
|
||||
// the IsUnique flag should be set TRUE to avoid the
|
||||
// G4AffineTransform re-calculations each time we reach
|
||||
// the envelope.
|
||||
G4FastSimulationManager(G4Envelope *anEnvelope,
|
||||
G4bool IsUnique=FALSE);
|
||||
~G4FastSimulationManager();
|
||||
|
||||
// Methods to add/remove models to/from the Model
|
||||
// List.
|
||||
//
|
||||
void AddFastSimulationModel(G4VFastSimulationModel*);
|
||||
void RemoveFastSimulationModel(G4VFastSimulationModel*);
|
||||
|
||||
// Methods to activate/inactivate models from the Model
|
||||
// List.
|
||||
|
||||
G4bool ActivateFastSimulationModel(const G4String&);
|
||||
G4bool InActivateFastSimulationModel(const G4String&);
|
||||
|
||||
// Methods to add/remove GhostPlacements to/from the
|
||||
// GhostPlacements List.
|
||||
//
|
||||
G4Transform3D* AddGhostPlacement(G4RotationMatrix*,
|
||||
const G4ThreeVector&);
|
||||
|
||||
G4Transform3D* AddGhostPlacement(G4Transform3D*);
|
||||
|
||||
G4bool RemoveGhostPlacement(const G4Transform3D*);
|
||||
|
||||
|
||||
// Methods for print/control commands
|
||||
void ListTitle() const;
|
||||
void ListModels() const;
|
||||
void ListModels(const G4ParticleDefinition*) const;
|
||||
void ListModels(const G4String& aName) const;
|
||||
const G4Envelope* GetEnvelope() const;
|
||||
|
||||
//
|
||||
//----------------------------------------------
|
||||
// Interface methods for the G4GlobalFastSimulationManager
|
||||
//----------------------------------------------
|
||||
// Parallel geometry placements
|
||||
|
||||
G4bool InsertGhostHereIfNecessary(G4VPhysicalVolume* ,
|
||||
const G4ParticleDefinition&);
|
||||
|
||||
//
|
||||
//----------------------------------------------
|
||||
// Interface methods for the
|
||||
// G4FastSimulationManagerProcess process.
|
||||
//----------------------------------------------
|
||||
// Trigger
|
||||
G4bool PostStepGetFastSimulationManagerTrigger(const G4Track &,
|
||||
const G4Navigator* a = NULL);
|
||||
// DoIt
|
||||
void InvokePostStepDoIt();
|
||||
|
||||
// AtRest methods:
|
||||
G4bool AtRestGetFastSimulationManagerTrigger(const G4Track &,
|
||||
const G4Navigator* a = NULL);
|
||||
void InvokeAtRestDoIt();
|
||||
|
||||
//Final G4VParticleChange* to return to the Stepping.
|
||||
G4VParticleChange* GettheParticleChange();
|
||||
|
||||
// For RW management
|
||||
G4bool operator == ( const G4FastSimulationManager&) const;
|
||||
|
||||
private:
|
||||
// Private members :
|
||||
G4FastTrack fFastTrack;
|
||||
G4FastStep fFastStep;
|
||||
G4VFastSimulationModel* fTriggedFastSimulationModel;
|
||||
RWTPtrOrderedVector<G4VFastSimulationModel> ModelList;
|
||||
RWTPtrOrderedVector<G4VFastSimulationModel> fInactivatedModels;
|
||||
RWTPtrOrderedVector<G4Transform3D> GhostPlacements;
|
||||
|
||||
G4ParticleDefinition* fLastCrossedParticle;
|
||||
RWTPtrOrderedVector<G4VFastSimulationModel> fApplicableModelList;
|
||||
};
|
||||
|
||||
inline void
|
||||
G4FastSimulationManager::AddFastSimulationModel(G4VFastSimulationModel* fsm)
|
||||
{
|
||||
ModelList.insert(fsm);
|
||||
// forces the fApplicableModelList to be rebuild
|
||||
fLastCrossedParticle=NULL;
|
||||
}
|
||||
|
||||
inline void
|
||||
G4FastSimulationManager::RemoveFastSimulationModel(G4VFastSimulationModel* fsm)
|
||||
{
|
||||
if(!ModelList.remove(fsm)) fInactivatedModels.remove(fsm);
|
||||
// forces the fApplicableModelList to be rebuild
|
||||
fLastCrossedParticle=NULL;
|
||||
}
|
||||
|
||||
inline G4VParticleChange* G4FastSimulationManager::GettheParticleChange()
|
||||
{
|
||||
return &fFastStep;
|
||||
}
|
||||
|
||||
inline G4bool
|
||||
G4FastSimulationManager::operator == (const G4FastSimulationManager& fsm) const
|
||||
{
|
||||
return (this==&fsm) ? true : false;
|
||||
}
|
||||
|
||||
inline const G4Envelope*
|
||||
G4FastSimulationManager::GetEnvelope() const
|
||||
{
|
||||
return fFastTrack.GetEnvelope();
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,164 @@
|
||||
// This code implementation is the intellectual property of
|
||||
// the RD44 GEANT4 collaboration.
|
||||
//
|
||||
// By copying, distributing or modifying the Program (or any work
|
||||
// based on the Program) you indicate your acceptance of this statement,
|
||||
// and all its terms.
|
||||
//
|
||||
// $Id: G4FastSimulationManagerProcess.hh,v 2.4 1998/12/08 04:06:44 verderi Exp $
|
||||
// GEANT4 tag $Name: geant4-00 $
|
||||
//
|
||||
//
|
||||
//---------------------------------------------------------------
|
||||
//
|
||||
// G4FastSimulationManagerProcess.hh
|
||||
//
|
||||
// Description:
|
||||
// The process that triggers parameterised simulations
|
||||
// if any.
|
||||
//
|
||||
// History:
|
||||
// Feb 98: Parallel geometry sensitivity. MoraDeFreitas.
|
||||
// Oct 97: "Fast" replaces "Parameterisation" in class/method names.
|
||||
// (release B.00 for parameterisation). MoraDeFreitas.
|
||||
// Aug 97: First implementation. Verderi && MoraDeFreitas.
|
||||
// Apr 98: modified for new particle change. H.Kurashige
|
||||
//
|
||||
//---------------------------------------------------------------
|
||||
|
||||
|
||||
#ifndef G4FastSimulationManagerProcess_h
|
||||
#define G4FastSimulationManagerProcess_h 1
|
||||
|
||||
#include <rw/tpordvec.h>
|
||||
|
||||
#include "globals.hh"
|
||||
#include "G4VProcess.hh"
|
||||
#include "G4FastSimulationManager.hh"
|
||||
#include "G4Step.hh"
|
||||
#include "G4Navigator.hh"
|
||||
#include "G4PropagatorInField.hh"
|
||||
#include "G4VTouchable.hh"
|
||||
#include "G4TouchableHistory.hh"
|
||||
#include "G4VPhysicalVolume.hh"
|
||||
#include "G4VParticleChange.hh"
|
||||
#include "G4FlavoredParallelWorld.hh"
|
||||
|
||||
//------------------------------------------
|
||||
//
|
||||
// G4FastSimulationManagerProcess class
|
||||
//
|
||||
//------------------------------------------
|
||||
class G4FastSimulationManagerProcess : public G4VProcess
|
||||
{
|
||||
public:
|
||||
|
||||
//------------------------
|
||||
// Constructor/Destructor
|
||||
//------------------------
|
||||
|
||||
G4FastSimulationManagerProcess(const G4String&
|
||||
processName =
|
||||
"G4FastSimulationManagerProcess",
|
||||
G4ProcessType
|
||||
theType = fParameterisation);
|
||||
~G4FastSimulationManagerProcess();
|
||||
|
||||
//--------------------------------------------------------------
|
||||
// Process interface
|
||||
//--------------------------------------------------------------
|
||||
|
||||
void StartTracking();
|
||||
|
||||
//---------------------------------------------------
|
||||
// GetPhysicalInteractionLength() and DoIt() methods:
|
||||
//---------------------------------------------------
|
||||
|
||||
G4double PostStepGetPhysicalInteractionLength(const G4Track& track,
|
||||
G4double previousStepSize,
|
||||
G4ForceCondition* condition);
|
||||
|
||||
G4VParticleChange* PostStepDoIt(const G4Track& ,const G4Step& );
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
// GetPhysicalInteractionLength() and DoIt() methods for AtRest particles:
|
||||
//------------------------------------------------------------------------
|
||||
|
||||
G4double AtRestGetPhysicalInteractionLength(
|
||||
const G4Track& ,
|
||||
G4ForceCondition*
|
||||
);
|
||||
|
||||
G4VParticleChange* AtRestDoIt(
|
||||
const G4Track& ,
|
||||
const G4Step&
|
||||
);
|
||||
|
||||
|
||||
// -- no operation in AlongStepDoIt --
|
||||
G4double AlongStepGetPhysicalInteractionLength(
|
||||
const G4Track&,
|
||||
G4double ,
|
||||
G4double ,
|
||||
G4double&,
|
||||
G4GPILSelection*
|
||||
);
|
||||
G4VParticleChange* AlongStepDoIt(
|
||||
const G4Track& ,
|
||||
const G4Step&
|
||||
);
|
||||
|
||||
|
||||
private:
|
||||
// When trigged, the *fFastSimulationManager holds
|
||||
// the pointer used to call the DoIt() method.
|
||||
G4FastSimulationManager* fFastSimulationManager;
|
||||
G4bool fFastSimulationTrigger;
|
||||
// this G4VParticleChange is used only when the safety limites the Step.
|
||||
G4VParticleChange aDummyParticleChange;
|
||||
G4ParticleChange xParticleChange;
|
||||
|
||||
// Flags that the track is starting
|
||||
G4bool fStartTracking;
|
||||
|
||||
// -------------------------------
|
||||
// Navigation in the Ghost World:
|
||||
// -------------------------------
|
||||
// Current parallel "ghost" world, related Navigator
|
||||
// and touchable history:
|
||||
G4VPhysicalVolume* fGhostWorld;
|
||||
G4Navigator fGhostNavigator;
|
||||
G4TouchableHistory* fGhostTouchable;
|
||||
G4bool fUpdateGhostTouchable;
|
||||
G4bool fOutOfGhostWorld;
|
||||
// Isotropic safety value to the next ghost volume
|
||||
// and allowed Step length:
|
||||
G4double fGhostSafety,
|
||||
fGhostStepLength;
|
||||
// Navigation with field:
|
||||
G4PropagatorInField* fGhostFieldPropagator;
|
||||
G4double fParticleCharge;
|
||||
G4bool fFieldExertsForce;
|
||||
|
||||
// Tracking Navigation used in PostStep, in case of mag-field:
|
||||
G4Navigator fTrackingNavigator;
|
||||
G4TouchableHistory fTrackingHistory;
|
||||
|
||||
// ******************************************************
|
||||
// ******************************************************
|
||||
//
|
||||
// For TESTS:
|
||||
//
|
||||
// ******************************************************
|
||||
// ******************************************************
|
||||
public:
|
||||
G4double GetPreSafety() {return fPreSafety;}
|
||||
G4double GetPreLinearSafety() {return fPreLinearSafety;}
|
||||
G4double GetSafety() {return fGhostSafety;}
|
||||
G4double GetLinearSafety() {return fGhostStepLength;}
|
||||
void Verbose() const;
|
||||
private:
|
||||
G4double fPreSafety, fPreLinearSafety;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,58 @@
|
||||
// This code implementation is the intellectual property of
|
||||
// the RD44 GEANT4 collaboration.
|
||||
//
|
||||
// By copying, distributing or modifying the Program (or any work
|
||||
// based on the Program) you indicate your acceptance of this statement,
|
||||
// and all its terms.
|
||||
//
|
||||
// $Id: G4FastSimulationMessenger.hh,v 2.3 1998/10/13 09:54:26 mora Exp $
|
||||
// GEANT4 tag $Name: geant4-00 $
|
||||
//
|
||||
//
|
||||
// GEANT 4 class header file
|
||||
//
|
||||
// This is a messenger class for G4FastSimulation.
|
||||
// Implemented commands are following;
|
||||
//
|
||||
// Commands :
|
||||
// BeamOn * Start a Run.
|
||||
//
|
||||
// History
|
||||
// first version by P.Mora de Freitas & M.Verderi
|
||||
// ------------------------------------------------------------
|
||||
|
||||
#ifndef G4FastSimulationMessenger_h
|
||||
#define G4FastSimulationMessenger_h 1
|
||||
|
||||
class G4UIdirectory;
|
||||
class G4UIcmdWithAString;
|
||||
class G4UIcmdWithoutParameter;
|
||||
|
||||
#include "G4UImessenger.hh"
|
||||
#include "globals.hh"
|
||||
#include "G4GlobalFastSimulationManager.hh"
|
||||
|
||||
class G4FastSimulationMessenger: public G4UImessenger
|
||||
{
|
||||
public:
|
||||
G4FastSimulationMessenger(G4GlobalFastSimulationManager* theGFSM);
|
||||
~G4FastSimulationMessenger();
|
||||
|
||||
public:
|
||||
void SetNewValue(G4UIcommand * command,G4String newValues);
|
||||
|
||||
private:
|
||||
G4GlobalFastSimulationManager* fGlobalFastSimulationManager;
|
||||
|
||||
//commands
|
||||
G4UIdirectory *fFSDirectory;
|
||||
G4UIcmdWithAString *fListEnvelopesCmd;
|
||||
G4UIcmdWithAString *fListModelsCmd;
|
||||
G4UIcmdWithAString *fListIsApplicableCmd;
|
||||
G4UIcmdWithAString *fActivateModel;
|
||||
G4UIcmdWithAString *fInActivateModel;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -0,0 +1,317 @@
|
||||
// This code implementation is the intellectual property of
|
||||
// the RD44 GEANT4 collaboration.
|
||||
//
|
||||
// By copying, distributing or modifying the Program (or any work
|
||||
// based on the Program) you indicate your acceptance of this statement,
|
||||
// and all its terms.
|
||||
//
|
||||
// $Id: G4FastStep.hh,v 2.6 1998/11/20 19:00:26 verderi Exp $
|
||||
// GEANT4 tag $Name: geant4-00 $
|
||||
//
|
||||
//
|
||||
//---------------------------------------------------------------
|
||||
//
|
||||
// G4FastStep.hh
|
||||
//
|
||||
// Description:
|
||||
// The G4FastStep class insures a friendly interface
|
||||
// to manage the primary/secondaries final state for
|
||||
// Fast Simulation Models. This includes final states of parent
|
||||
// particle (normalized direction of the momentum, energy, etc) and
|
||||
// secondary particles generated by the parameterisation.
|
||||
//
|
||||
// The G4FastStep class acts also as the G4ParticleChange
|
||||
// for the Fast Simulation Process. So it inherites from
|
||||
// the G4VParticleChange class and redefines the four virtual
|
||||
// methods :
|
||||
//
|
||||
// virtual G4Step* UpdateStepForAtRest(G4Step* Step);
|
||||
// virtual G4Step* UpdateStepForAlongStep(G4Step* Step);
|
||||
// virtual G4Step* UpdateStepForPostStep(G4Step* Step);
|
||||
// virtual void Initialize(const G4Track&);
|
||||
//
|
||||
// History:
|
||||
// Oct 97: Verderi && MoraDeFreitas - First Implementation.
|
||||
// Dec 97: Verderi - ForceSteppingHitInvocation(),
|
||||
// Set/GetTotalEnergyDeposited() methods.
|
||||
// Apr 98: MoraDeFreitas - G4FastStep becomes the G4ParticleChange
|
||||
// for the Fast Simulation Process.
|
||||
//
|
||||
//---------------------------------------------------------------
|
||||
|
||||
|
||||
#ifndef G4FastStep_h
|
||||
#define G4FastStep_h
|
||||
|
||||
#include "globals.hh"
|
||||
#include "G4ios.hh"
|
||||
#include "G4ThreeVector.hh"
|
||||
#include "G4ParticleMomentum.hh"
|
||||
class G4DynamicParticle;
|
||||
#include "G4VParticleChange.hh"
|
||||
#include "G4FastTrack.hh"
|
||||
|
||||
//-------------------------------------------
|
||||
//
|
||||
// G4FastStep class
|
||||
//
|
||||
//-------------------------------------------
|
||||
class G4FastStep: public G4VParticleChange
|
||||
{
|
||||
public:
|
||||
//===================================================
|
||||
//Fast Simulation Model Interface (section for users)
|
||||
//===================================================
|
||||
//
|
||||
// Particle management
|
||||
// -------------------
|
||||
//
|
||||
// The methods here provide an implementation of the
|
||||
// G4VParticleChange class for parameterisations.
|
||||
// They have to be filled to describe the FINAL STATE
|
||||
// of the particles.
|
||||
//
|
||||
// To facilitate the developers work, changes of
|
||||
// position/normalized direction of the momentum/polarization
|
||||
// can be specified in the local coordinate system of the envelope
|
||||
// or in the global one.
|
||||
//
|
||||
// The default is local system coordinates.
|
||||
|
||||
|
||||
// -- The KillPrimaryTrack() set the kinetic energy of the
|
||||
// -- primary to zero, and set the "fStopAndKill" signal
|
||||
// -- used by the stepping.
|
||||
void KillPrimaryTrack();
|
||||
|
||||
// -- Methods used to change the position, normalized direction of
|
||||
// the momentum, time etc... of the primary.
|
||||
// .. space and time:
|
||||
void SetPrimaryTrackFinalPosition (const G4ThreeVector &,
|
||||
G4bool localCoordinates = true);
|
||||
void SetPrimaryTrackFinalTime (G4double);
|
||||
void SetPrimaryTrackFinalProperTime (G4double);
|
||||
|
||||
// .. dynamics:
|
||||
// Be careful: the Track Final Momentum means the normalized direction
|
||||
// of the momentum!
|
||||
void SetPrimaryTrackFinalMomentum (const G4ThreeVector &,
|
||||
G4bool localCoordinates = true);
|
||||
void SetPrimaryTrackFinalKineticEnergy (G4double);
|
||||
void SetPrimaryTrackFinalKineticEnergyAndDirection(G4double,
|
||||
const G4ThreeVector &,
|
||||
G4bool localCoordinates
|
||||
= true);
|
||||
void SetPrimaryTrackFinalPolarization(const G4ThreeVector &,
|
||||
G4bool localCoordinates = true);
|
||||
|
||||
// .. true path length of the primary during the FastStep:
|
||||
void SetPrimaryTrackPathLength (G4double);
|
||||
|
||||
// Weight applied for event biasing mechanism:
|
||||
void SetPrimaryTrackFinalEventBiasingWeight (G4double);
|
||||
|
||||
|
||||
// ------------------------------
|
||||
// -- Management of secondaries:
|
||||
// ------------------------------
|
||||
|
||||
// ----------------------------------------------------
|
||||
// -- The creation of secondaries is Done in two steps:
|
||||
// -- 1) Give the total number of secondaries
|
||||
// -- that the FastStep returns
|
||||
// -- to the tracking using:
|
||||
// -- SetNumberOfSecondaryTracks()
|
||||
// --
|
||||
// -- 2) Invoke the CreateSecondaryTrack() method
|
||||
// -- to create one secondary at each time.
|
||||
// ----------------------------------------------------
|
||||
|
||||
// -- Total Number of secondaries to be created,
|
||||
// -- (to be called first)
|
||||
void SetNumberOfSecondaryTracks(G4int);
|
||||
|
||||
// -- Number of secondaries effectively stored:
|
||||
// -- (incremented at each CreateSecondaryTrack()
|
||||
// -- call)
|
||||
G4int GetNumberOfSecondaryTracks();
|
||||
|
||||
// -- Create a secondary: the arguments are:
|
||||
// -- * G4DynamicsParticle: see header file, many constructors exist
|
||||
// -- (allow to set particle type + energy +
|
||||
// -- the normalized direction of momentum...)
|
||||
// -- * G4ThreeVector : Polarization (not in G4ParticleChange constructor)
|
||||
// -- * G4ThreeVector : Position
|
||||
// -- * G4double : Time
|
||||
// -- * G4bool : says if Position/Momentum are given in the
|
||||
// -- local coordinate system (true by default)
|
||||
// -- Returned value: pointer to the track created.
|
||||
G4Track* CreateSecondaryTrack(const G4DynamicParticle&,
|
||||
G4ThreeVector,
|
||||
G4ThreeVector,
|
||||
G4double,
|
||||
G4bool localCoordinates=true);
|
||||
|
||||
//-- Create a secondary: the difference with he above declaration
|
||||
//-- is that the Polarization is not given and is assumed already set
|
||||
//-- in the G4DynamicParticle.
|
||||
//-- Returned value: pointer to the track created
|
||||
G4Track* CreateSecondaryTrack(const G4DynamicParticle&,
|
||||
G4ThreeVector,
|
||||
G4double,
|
||||
G4bool localCoordinates=true);
|
||||
|
||||
// -- Gives a pointer on the i-th secondary track created:
|
||||
G4Track* GetSecondaryTrack(G4int);
|
||||
|
||||
//------------------------------------------------
|
||||
//
|
||||
// Total energy deposit in the "fast Step"
|
||||
// (a default should be provided in future,
|
||||
// which can be:
|
||||
// delta energy of primary -
|
||||
// energy of the secondaries)
|
||||
// This allow the user to Store a consistent
|
||||
// information in the G4Trajectory.
|
||||
//
|
||||
//------------------------------------------------
|
||||
void SetTotalEnergyDeposited(G4double anEnergyPart);
|
||||
G4double GetTotalEnergyDeposited() const;
|
||||
|
||||
//----------------------------------------------------
|
||||
//
|
||||
// Control of the stepping manager Hit invocation:
|
||||
// -----------------------------------------------
|
||||
//
|
||||
// In a usual parameterisation, the control of
|
||||
// the hits production is under the user
|
||||
// responsability in his G4VFastSimulationModel
|
||||
// (he generally produces several hits at once.)
|
||||
//
|
||||
// However, in the particular case the G4Fast-
|
||||
// Simulation user's model acts as the physics
|
||||
// replacement only (ie replaces all the ***DoIt()
|
||||
// and leads to the construction of a meaningful
|
||||
// G4Step), the user can delegate to the
|
||||
// G4SteppingManager the responsability to invoke
|
||||
// the Hit()method of the current sensitive if any.
|
||||
//
|
||||
// By default, the G4SteppingManager is asked to
|
||||
// NOT invoke this Hit() method when parameterisation
|
||||
// is invoked. (See Initialize() method of G4FastStep)
|
||||
//
|
||||
//----------------------------------------------------
|
||||
void ForceSteppingHitInvocation();
|
||||
|
||||
|
||||
|
||||
//=======================================================
|
||||
// Implementation section and kernel interfaces.
|
||||
//=======================================================
|
||||
//------------------------
|
||||
// Constructor/Destructor
|
||||
//------------------------
|
||||
G4FastStep();
|
||||
~G4FastStep();
|
||||
|
||||
// equal/unequal operator
|
||||
G4bool operator==(const G4FastStep &right) const;
|
||||
G4bool operator!=(const G4FastStep &right) const;
|
||||
|
||||
protected:
|
||||
// hide copy constructor and assignment operator as protected
|
||||
G4FastStep (const G4FastStep &right);
|
||||
G4FastStep & operator= (const G4FastStep &right);
|
||||
|
||||
public:
|
||||
// ===============================================
|
||||
// Stepping interface.
|
||||
// ===============================================
|
||||
// --- the following methods are for updating G4Step -----
|
||||
// Return the pointer to the G4Step after updating the Step information
|
||||
// by using final state information of the track given by a Model.
|
||||
//
|
||||
// The Fast Simulation Mechanism doesn't change the track's final
|
||||
// state on the AlongDoIt loop, so the default one all we need.
|
||||
//virtual G4Step* UpdateStepForAlongStep(G4Step* Step);
|
||||
|
||||
G4Step* UpdateStepForAtRest(G4Step* Step);
|
||||
G4Step* UpdateStepForPostStep(G4Step* Step);
|
||||
|
||||
// A Model gives the final state of the particle
|
||||
// based on information of G4FastTrack. So the
|
||||
// Initialize method is an interface to the
|
||||
// G4FastSimulationManager to Initialize the
|
||||
// G4FastStep.
|
||||
|
||||
void Initialize(const G4FastTrack&);
|
||||
|
||||
private:
|
||||
//===================================================
|
||||
// Private Internal methods (implementation).
|
||||
//===================================================
|
||||
|
||||
// G4FastStep should never be Initialized in this way
|
||||
// but we must define it to avoid compiler warnings.
|
||||
void Initialize(const G4Track&);
|
||||
|
||||
// -- Utility functions --
|
||||
//--- methods to keep information of the final state--
|
||||
// IMPORTANT NOTE: Although the name of the class and methods are
|
||||
// "Change", what it stores (and returns in get) are the "FINAL"
|
||||
// values of the Position, the normalized direction of Momentum,
|
||||
// etc.
|
||||
|
||||
// Set theMomentumChange vector: it is the final unitary momentum
|
||||
// direction.
|
||||
void SetMomentumChange(G4double Px, G4double Py, G4double Pz);
|
||||
void SetMomentumChange(const G4ThreeVector& Pfinal);
|
||||
|
||||
//=====================================================
|
||||
// Data members.
|
||||
//=====================================================
|
||||
// theMomentumChange is the vector containing the final momentum
|
||||
// direction after the invoked process. The application of the change
|
||||
// of the momentum direction of the particle is not Done here.
|
||||
// The responsibility to apply the change is up the entity
|
||||
// which invoked the process.
|
||||
G4ParticleMomentum theMomentumChange;
|
||||
|
||||
// The changed (final) polarization of a given particle.
|
||||
G4ThreeVector thePolarizationChange;
|
||||
|
||||
// The final kinetic energy of the current particle.
|
||||
G4double theEnergyChange;
|
||||
|
||||
// The changed (final) position of a given particle.
|
||||
G4ThreeVector thePositionChange;
|
||||
|
||||
// The changed (final) global time of a given particle.
|
||||
G4double theTimeChange;
|
||||
|
||||
// The changed (final) proper time of a given particle.
|
||||
G4double theProperTimeChange;
|
||||
|
||||
// The reference G4FastTrack
|
||||
const G4FastTrack* fFastTrack;
|
||||
|
||||
// weight for event biasing mechanism:
|
||||
G4double theWeightChange;
|
||||
|
||||
|
||||
public:
|
||||
// for Debug
|
||||
void DumpInfo() const;
|
||||
G4bool debugFlag;
|
||||
G4bool CheckIt(const G4Track&);
|
||||
};
|
||||
|
||||
//*******************************************************************
|
||||
//
|
||||
// Inline functions
|
||||
//
|
||||
//*******************************************************************
|
||||
|
||||
#include "G4FastStep.icc"
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,102 @@
|
||||
// This code implementation is the intellectual property of
|
||||
// the RD44 GEANT4 collaboration.
|
||||
//
|
||||
// By copying, distributing or modifying the Program (or any work
|
||||
// based on the Program) you indicate your acceptance of this statement,
|
||||
// and all its terms.
|
||||
//
|
||||
// $Id: G4FastStep.icc,v 2.3 1998/11/20 19:00:27 verderi Exp $
|
||||
// GEANT4 tag $Name: geant4-00 $
|
||||
//
|
||||
// $id: G4ParticleChange.icc,v 1.6 1998/04/14 02:25:54 kurasige Exp $
|
||||
|
||||
inline void
|
||||
G4FastStep::SetPrimaryTrackFinalTime(G4double time)
|
||||
{
|
||||
theTimeChange = time;
|
||||
}
|
||||
|
||||
inline void
|
||||
G4FastStep::SetPrimaryTrackFinalProperTime(G4double properTime)
|
||||
{
|
||||
theProperTimeChange = properTime;
|
||||
}
|
||||
|
||||
inline void
|
||||
G4FastStep::
|
||||
SetPrimaryTrackFinalKineticEnergy(G4double kineticEnergy)
|
||||
{
|
||||
theEnergyChange = kineticEnergy;
|
||||
}
|
||||
|
||||
inline void
|
||||
G4FastStep::SetPrimaryTrackPathLength(G4double pathLength)
|
||||
{
|
||||
SetTrueStepLength(pathLength);
|
||||
}
|
||||
//-----------------------------------------
|
||||
//
|
||||
// Creation of eventual secondaries:
|
||||
//
|
||||
//-----------------------------------------
|
||||
|
||||
inline void
|
||||
G4FastStep::SetNumberOfSecondaryTracks(G4int nSecondaries)
|
||||
{
|
||||
SetNumberOfSecondaries(nSecondaries);
|
||||
}
|
||||
|
||||
inline G4int
|
||||
G4FastStep::GetNumberOfSecondaryTracks()
|
||||
{
|
||||
return GetNumberOfSecondaries();
|
||||
}
|
||||
|
||||
inline G4Track* G4FastStep::GetSecondaryTrack(G4int i)
|
||||
{
|
||||
return GetSecondary(i);
|
||||
}
|
||||
|
||||
|
||||
//---------------------------------------
|
||||
//
|
||||
//---------------------------------------
|
||||
inline void G4FastStep::SetTotalEnergyDeposited(G4double anEnergyPart)
|
||||
{
|
||||
SetLocalEnergyDeposit(anEnergyPart);
|
||||
}
|
||||
|
||||
|
||||
inline G4double G4FastStep::GetTotalEnergyDeposited() const
|
||||
{
|
||||
return GetLocalEnergyDeposit();
|
||||
}
|
||||
|
||||
|
||||
inline void G4FastStep::ForceSteppingHitInvocation()
|
||||
{
|
||||
SetSteppingControl(NormalCondition);
|
||||
}
|
||||
|
||||
inline
|
||||
void G4FastStep::SetMomentumChange(
|
||||
G4double Px,
|
||||
G4double Py,
|
||||
G4double Pz )
|
||||
{
|
||||
theMomentumChange.setX(Px);
|
||||
theMomentumChange.setY(Py);
|
||||
theMomentumChange.setZ(Pz);
|
||||
}
|
||||
|
||||
inline
|
||||
void G4FastStep::SetMomentumChange(const G4ThreeVector& P)
|
||||
{
|
||||
theMomentumChange = P;
|
||||
}
|
||||
|
||||
inline
|
||||
void G4FastStep::SetPrimaryTrackFinalEventBiasingWeight (G4double w)
|
||||
{
|
||||
theWeightChange = w;
|
||||
}
|
||||
@@ -0,0 +1,186 @@
|
||||
// This code implementation is the intellectual property of
|
||||
// the RD44 GEANT4 collaboration.
|
||||
//
|
||||
// By copying, distributing or modifying the Program (or any work
|
||||
// based on the Program) you indicate your acceptance of this statement,
|
||||
// and all its terms.
|
||||
//
|
||||
// $Id: G4FastTrack.hh,v 2.3 1998/10/13 09:54:30 mora Exp $
|
||||
// GEANT4 tag $Name: geant4-00 $
|
||||
//
|
||||
// $Id:
|
||||
//---------------------------------------------------------------
|
||||
//
|
||||
// G4FastTrack.hh
|
||||
//
|
||||
// Description:
|
||||
// Keeps the current track information and special features
|
||||
// for Parameterised Simulation Models.
|
||||
//
|
||||
// History:
|
||||
// Oct 97: Verderi && MoraDeFreitas - First Implementation.
|
||||
//
|
||||
//---------------------------------------------------------------
|
||||
|
||||
|
||||
#ifndef G4FastTrack_h
|
||||
#define G4FastTrack_h
|
||||
|
||||
#include "G4VSolid.hh"
|
||||
#include "G4LogicalVolume.hh"
|
||||
#include "G4AffineTransform.hh"
|
||||
#include "G4Track.hh"
|
||||
#include "G4Navigator.hh"
|
||||
|
||||
//---------------------------
|
||||
// For possible future needs:
|
||||
//---------------------------
|
||||
typedef G4LogicalVolume G4Envelope;
|
||||
|
||||
|
||||
//-------------------------------------------
|
||||
//
|
||||
// G4FastTrack class
|
||||
//
|
||||
//-------------------------------------------
|
||||
class G4FastTrack
|
||||
{
|
||||
public:
|
||||
//------------------------
|
||||
// Constructor/Destructor
|
||||
//------------------------
|
||||
// Only one Constructor. By default the envelope can
|
||||
// be placed n-Times. If the user is sure that it'll be
|
||||
// placed just one time, the IsUnique flag should be set
|
||||
// TRUE to avoid the G4AffineTransform re-calculations each
|
||||
// time we reach the envelope.
|
||||
G4FastTrack(G4Envelope *anEnvelope,
|
||||
G4bool IsUnique);
|
||||
~G4FastTrack();
|
||||
|
||||
//------------------------------------------------------------
|
||||
// The fast simulation manager uses the SetCurrentTrack
|
||||
// method to setup the current G4FastTrack object
|
||||
//------------------------------------------------------------
|
||||
void SetCurrentTrack(const G4Track&, const G4Navigator* a = NULL);
|
||||
|
||||
//------------------------------------------------------------
|
||||
// The fast simulation manager uses the OnTheBoundaryButExiting
|
||||
// method to test if the particle is leaving the envelope.
|
||||
//------------------------------------------------------------
|
||||
G4bool OnTheBoundaryButExiting() const;
|
||||
|
||||
//----------------------------------
|
||||
// Informations useful to the user :
|
||||
// General public get functions.
|
||||
//----------------------------------
|
||||
const G4Track* GetPrimaryTrack() const;
|
||||
G4Envelope* GetEnvelope() const;
|
||||
G4VPhysicalVolume* GetEnvelopePhysicalVolume() const;
|
||||
G4VSolid* GetEnvelopeSolid() const;
|
||||
|
||||
//-----------------------------------
|
||||
// Primary track informations in the
|
||||
// Envelope coordinate system.
|
||||
//-----------------------------------
|
||||
G4ThreeVector GetPrimaryTrackLocalPosition() const;
|
||||
G4ThreeVector GetPrimaryTrackLocalMomentum() const;
|
||||
G4ThreeVector GetPrimaryTrackLocalDirection() const;
|
||||
G4ThreeVector GetPrimaryTrackLocalPolarization() const;
|
||||
|
||||
//------------------------------------
|
||||
// 3D transformation of the envelope:
|
||||
//------------------------------------
|
||||
// Global -> Local
|
||||
const G4AffineTransform* GetAffineTransformation() const;
|
||||
// Local -> Global
|
||||
const G4AffineTransform* GetInverseAffineTransformation() const;
|
||||
|
||||
//-----------------
|
||||
// Private members
|
||||
//-----------------
|
||||
private:
|
||||
|
||||
// Current G4Track pointer
|
||||
const G4Track* fTrack;
|
||||
|
||||
//------------------------------------------------
|
||||
// Records the Affine/InverseAffine transformation
|
||||
// of the envelope.
|
||||
//------------------------------------------------
|
||||
void FRecordsAffineTransformation(const G4Navigator*);
|
||||
G4bool fAffineTransformationDefined;
|
||||
G4Envelope* fEnvelope;
|
||||
G4bool fIsUnique;
|
||||
G4VPhysicalVolume* fEnvelopePhysicalVolume;
|
||||
G4VSolid* fEnvelopeSolid;
|
||||
G4ThreeVector fLocalTrackPosition, fLocalTrackMomentum,
|
||||
fLocalTrackDirection, fLocalTrackPolarization;
|
||||
G4AffineTransform fAffineTransformation, fInverseAffineTransformation;
|
||||
};
|
||||
|
||||
//*******************************************************************
|
||||
//
|
||||
// Inline functions
|
||||
//
|
||||
//*******************************************************************
|
||||
|
||||
inline G4Envelope* G4FastTrack::GetEnvelope() const
|
||||
{
|
||||
return fEnvelope;
|
||||
}
|
||||
|
||||
inline G4VPhysicalVolume* G4FastTrack::GetEnvelopePhysicalVolume() const
|
||||
{
|
||||
return fEnvelopePhysicalVolume;
|
||||
}
|
||||
|
||||
inline G4VSolid* G4FastTrack::GetEnvelopeSolid() const
|
||||
{
|
||||
return fEnvelopeSolid;
|
||||
}
|
||||
|
||||
inline const G4Track* G4FastTrack::GetPrimaryTrack() const
|
||||
{
|
||||
return fTrack;
|
||||
}
|
||||
|
||||
inline G4ThreeVector G4FastTrack::GetPrimaryTrackLocalPosition() const
|
||||
{
|
||||
return fLocalTrackPosition;
|
||||
}
|
||||
|
||||
inline G4ThreeVector G4FastTrack::GetPrimaryTrackLocalMomentum() const
|
||||
{
|
||||
return fLocalTrackMomentum;
|
||||
}
|
||||
|
||||
inline G4ThreeVector G4FastTrack::GetPrimaryTrackLocalDirection() const
|
||||
{
|
||||
return fLocalTrackDirection;
|
||||
}
|
||||
|
||||
inline G4ThreeVector G4FastTrack::GetPrimaryTrackLocalPolarization() const
|
||||
{
|
||||
return fLocalTrackPolarization;
|
||||
}
|
||||
|
||||
inline const G4AffineTransform* G4FastTrack::GetAffineTransformation() const
|
||||
{
|
||||
return &fAffineTransformation;
|
||||
}
|
||||
|
||||
inline const G4AffineTransform* G4FastTrack::GetInverseAffineTransformation() const
|
||||
{
|
||||
return &fInverseAffineTransformation;
|
||||
}
|
||||
|
||||
inline G4bool G4FastTrack::OnTheBoundaryButExiting() const
|
||||
{
|
||||
// tests if particle are on the boundary and leaving.
|
||||
return GetEnvelopeSolid()->
|
||||
DistanceToOut(GetPrimaryTrackLocalPosition(),
|
||||
GetPrimaryTrackLocalDirection())==0.;
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,71 @@
|
||||
// This code implementation is the intellectual property of
|
||||
// the RD44 GEANT4 collaboration.
|
||||
//
|
||||
// By copying, distributing or modifying the Program (or any work
|
||||
// based on the Program) you indicate your acceptance of this statement,
|
||||
// and all its terms.
|
||||
//
|
||||
// $Id: G4FlavoredParallelWorld.hh,v 2.1 1998/10/13 09:54:32 mora Exp $
|
||||
// GEANT4 tag $Name: geant4-00 $
|
||||
//
|
||||
//
|
||||
//---------------------------------------------------------------
|
||||
//
|
||||
// G4FlavoredParallelWorld.hh
|
||||
//
|
||||
// Description:
|
||||
// Internal class to keep ParticleType X Parallel world
|
||||
// relationship.
|
||||
//
|
||||
// History:
|
||||
// June 98: Verderi && MoraDeFreitas - "G4ParallelWorld" becomes
|
||||
// "G4FlavoredParallelWorld".
|
||||
// Mars 98: Verderi && MoraDeFreitas - First Implementation.
|
||||
//
|
||||
//---------------------------------------------------------------
|
||||
|
||||
#ifndef G4FlavoredParallelWorld_hh
|
||||
#define G4FlavoredParallelWorld_hh
|
||||
|
||||
#include "globals.hh"
|
||||
#include "G4ParticleDefinition.hh"
|
||||
#include "G4VPhysicalVolume.hh"
|
||||
|
||||
class G4FlavoredParallelWorld
|
||||
{
|
||||
public:
|
||||
//
|
||||
// Constructor
|
||||
G4FlavoredParallelWorld(G4ParticleDefinition *pParticleType,
|
||||
G4VPhysicalVolume *pWorld) {
|
||||
ParticleType=pParticleType;
|
||||
World=pWorld;
|
||||
}
|
||||
//
|
||||
// Destructor
|
||||
~G4FlavoredParallelWorld() {
|
||||
delete [] World;
|
||||
}
|
||||
// Get/Set
|
||||
inline G4ParticleDefinition* GetTheParticleType() const {
|
||||
return ParticleType;
|
||||
}
|
||||
|
||||
inline G4VPhysicalVolume* GetThePhysicalVolumeWorld() const {
|
||||
return World;
|
||||
}
|
||||
|
||||
// operator ==
|
||||
inline G4bool
|
||||
operator == (const G4FlavoredParallelWorld& pw) const {
|
||||
return (this==&pw) ? true : false;
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
G4ParticleDefinition *ParticleType;
|
||||
G4VPhysicalVolume *World;
|
||||
};
|
||||
|
||||
#endif
|
||||
// end of #ifndef G4FlavoredParallelWorld_hh
|
||||
@@ -0,0 +1,106 @@
|
||||
// This code implementation is the intellectual property of
|
||||
// the RD44 GEANT4 collaboration.
|
||||
//
|
||||
// By copying, distributing or modifying the Program (or any work
|
||||
// based on the Program) you indicate your acceptance of this statement,
|
||||
// and all its terms.
|
||||
//
|
||||
// $Id: G4GlobalFastSimulationManager.hh,v 2.5 1998/10/13 09:54:33 mora Exp $
|
||||
// GEANT4 tag $Name: geant4-00 $
|
||||
//
|
||||
//
|
||||
//---------------------------------------------------------------
|
||||
//
|
||||
// G4GlobalFastSimulationManager.hh
|
||||
//
|
||||
// Description:
|
||||
// A singleton class which manages the Fast Simulation managers
|
||||
// attached to envelopes.
|
||||
//
|
||||
// History:
|
||||
// June 98: Verderi && MoraDeFreitas - "G4ParallelWorld" becomes
|
||||
// "G4FlavoredParallelWorld"; some method name changes;
|
||||
// GetFlavoredWorldForThis now returns a
|
||||
// G4FlavoredParallelWorld pointer.
|
||||
// Feb 98: Verderi && MoraDeFreitas - First Implementation.
|
||||
//
|
||||
//---------------------------------------------------------------
|
||||
|
||||
#ifndef G4GlobalFastSimulationManager_hh
|
||||
#define G4GlobalFastSimulationManager_hh
|
||||
|
||||
#include <rw/tpordvec.h>
|
||||
|
||||
#include "G4FastSimulationManager.hh"
|
||||
#include "G4FastSimulationManagerProcess.hh"
|
||||
#include "G4StateManager.hh"
|
||||
#include "G4VStateDependent.hh"
|
||||
#include "G4FlavoredParallelWorld.hh"
|
||||
|
||||
enum listType {
|
||||
NAMES_ONLY,
|
||||
MODELS,
|
||||
ISAPPLICABLE
|
||||
};
|
||||
|
||||
class G4FastSimulationMessenger;
|
||||
|
||||
class G4GlobalFastSimulationManager : public G4VStateDependent
|
||||
{
|
||||
public:
|
||||
// Global access to the GlobalFastSimulationManager
|
||||
static G4GlobalFastSimulationManager* GetGlobalFastSimulationManager();
|
||||
|
||||
// Destructor
|
||||
~G4GlobalFastSimulationManager();
|
||||
|
||||
// G4FastSimulationManager's management :
|
||||
//
|
||||
// Methods for a G4FastSimulationManager to register itself
|
||||
//
|
||||
void AddFastSimulationManager(G4FastSimulationManager*);
|
||||
void RemoveFastSimulationManager(G4FastSimulationManager*);
|
||||
|
||||
// Open/Close Parameterisation
|
||||
void FastSimulationNeedsToBeClosed();
|
||||
void CloseFastSimulation();
|
||||
|
||||
// print/control commands
|
||||
void ListEnvelopes(const G4String& aName = "all",
|
||||
listType aListType = NAMES_ONLY);
|
||||
void ListEnvelopes(const G4ParticleDefinition*);
|
||||
|
||||
void ActivateFastSimulationModel(const G4String&);
|
||||
void InActivateFastSimulationModel(const G4String&);
|
||||
|
||||
// G4FastSimulationProcess interface
|
||||
G4FlavoredParallelWorld* GetFlavoredWorldForThis(G4ParticleDefinition *);
|
||||
|
||||
// G4StateManager interface
|
||||
G4bool Notify(G4ApplicationState requestedState);
|
||||
|
||||
private:
|
||||
// Private construtor insures singleton class
|
||||
G4GlobalFastSimulationManager();
|
||||
|
||||
// The single instance.
|
||||
static G4GlobalFastSimulationManager* fGlobalFastSimulationManager;
|
||||
|
||||
// The G4FastSimulationMessenger
|
||||
G4FastSimulationMessenger* fTheFastSimulationMessenger;
|
||||
|
||||
// List of G4FastSimulationManagers
|
||||
RWTPtrOrderedVector<G4FastSimulationManager> ManagedManagers;
|
||||
|
||||
// fClosed flags if the NeededFlavoredWorlds List was Build.
|
||||
G4bool fClosed;
|
||||
|
||||
// List of needed ParallelWorlds after close
|
||||
RWTPtrOrderedVector<G4FlavoredParallelWorld> NeededFlavoredWorlds;
|
||||
|
||||
// Internal fonction to Build world volume clones.
|
||||
G4VPhysicalVolume* GiveMeAWorldVolumeClone();
|
||||
};
|
||||
|
||||
#endif
|
||||
// end of #ifndef G4GlobalFastSimulationManager_hh
|
||||
@@ -0,0 +1,111 @@
|
||||
// This code implementation is the intellectual property of
|
||||
// the RD44 GEANT4 collaboration.
|
||||
//
|
||||
// By copying, distributing or modifying the Program (or any work
|
||||
// based on the Program) you indicate your acceptance of this statement,
|
||||
// and all its terms.
|
||||
//
|
||||
// $Id: G4VFastSimulationModel.hh,v 2.2 1998/10/13 09:54:34 mora Exp $
|
||||
// GEANT4 tag $Name: geant4-00 $
|
||||
//
|
||||
//
|
||||
//---------------------------------------------------------------
|
||||
//
|
||||
// G4VFastSimulationModel.hh
|
||||
//
|
||||
// Description:
|
||||
// Base class for fast simulation models.
|
||||
//
|
||||
// History:
|
||||
// Oct 97: Verderi && MoraDeFreitas - First Implementation.
|
||||
//
|
||||
//---------------------------------------------------------------
|
||||
|
||||
|
||||
#ifndef G4VFastSimulationModel_h
|
||||
#define G4VFastSimulationModel_h
|
||||
|
||||
#include "G4FastTrack.hh"
|
||||
#include "G4FastStep.hh"
|
||||
|
||||
//---------------------------
|
||||
// For possible future needs:
|
||||
//---------------------------
|
||||
typedef G4LogicalVolume G4Envelope;
|
||||
|
||||
//-------------------------------------------
|
||||
//
|
||||
// G4VFastSimulationModel class
|
||||
//
|
||||
//-------------------------------------------
|
||||
class G4VFastSimulationModel
|
||||
{
|
||||
public:
|
||||
//------------------------
|
||||
// Constructor/Destructor
|
||||
//------------------------
|
||||
// constructors require at least the model name.
|
||||
G4VFastSimulationModel(const G4String& aName);
|
||||
|
||||
// About the IsUnique flag, by default the envelope can
|
||||
// be placed n-Times. If the user is sure that it'll be
|
||||
// placed just one time the IsUnique flag should be set
|
||||
// TRUE to avoid the G4AffineTransform re-calculations each
|
||||
// time we reach the envelope.
|
||||
G4VFastSimulationModel(const G4String& aName, G4Envelope*,
|
||||
G4bool IsUnique=FALSE);
|
||||
|
||||
~G4VFastSimulationModel() {};
|
||||
|
||||
//
|
||||
//----------------------------------------------
|
||||
// Interface IsApplicable virtual method for the
|
||||
// G4FastSimulationManager
|
||||
//----------------------------------------------
|
||||
virtual G4bool IsApplicable(const G4ParticleDefinition&) = 0;
|
||||
|
||||
//
|
||||
//----------------------------------------------
|
||||
// Interface trigger virtual method for the
|
||||
// G4FastSimulationManager
|
||||
//----------------------------------------------
|
||||
virtual G4bool ModelTrigger(const G4FastTrack &) = 0;
|
||||
|
||||
// -- Pure virtual DoIt() method : the FastSimulationModel
|
||||
// properly said. The user has to compute the detector
|
||||
// response and to manage the particle changes state:
|
||||
// -- * change position/momentum or kill the primary
|
||||
// -- * create secondaries
|
||||
virtual void DoIt(const G4FastTrack&, G4FastStep&) = 0;
|
||||
|
||||
// ---------------------------
|
||||
// -- Idem for AtRest methods:
|
||||
// ---------------------------
|
||||
// -- A default dummy implementation is provided.
|
||||
virtual
|
||||
G4bool AtRestModelTrigger(const G4FastTrack& fastTrack) {return false;}
|
||||
virtual
|
||||
void AtRestDoIt (const G4FastTrack& fastTrack, G4FastStep& fastStep) {}
|
||||
|
||||
// Useful public methods :
|
||||
const G4String GetName() const;
|
||||
G4bool operator == ( const G4VFastSimulationModel&) const;
|
||||
|
||||
private:
|
||||
//-------------
|
||||
// Model Name:
|
||||
//-------------
|
||||
G4String theModelName;
|
||||
};
|
||||
|
||||
inline const G4String G4VFastSimulationModel::GetName() const
|
||||
{
|
||||
return theModelName;
|
||||
}
|
||||
|
||||
inline G4bool
|
||||
G4VFastSimulationModel::operator == (const G4VFastSimulationModel& fsm) const
|
||||
{
|
||||
return (this==&fsm) ? true : false;
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,417 @@
|
||||
// This code implementation is the intellectual property of
|
||||
// the RD44 GEANT4 collaboration.
|
||||
//
|
||||
// By copying, distributing or modifying the Program (or any work
|
||||
// based on the Program) you indicate your acceptance of this statement,
|
||||
// and all its terms.
|
||||
//
|
||||
// $Id: G4FastSimulationManager.cc,v 2.7 1998/10/26 14:31:36 mora Exp $
|
||||
// GEANT4 tag $Name: geant4-00 $
|
||||
//
|
||||
//$Id:
|
||||
//---------------------------------------------------------------
|
||||
//
|
||||
// G4FastSimulationManager.cc
|
||||
//
|
||||
// Description:
|
||||
// Manages the Fast Simulation models attached to a envelope.
|
||||
//
|
||||
// History:
|
||||
// Oct 97: Verderi && MoraDeFreitas - First Implementation.
|
||||
//
|
||||
//---------------------------------------------------------------
|
||||
|
||||
#include "G4FastSimulationManager.hh"
|
||||
#include "G4GlobalFastSimulationManager.hh"
|
||||
#include "G4PVPlacement.hh"
|
||||
|
||||
// --------------------------------------------------
|
||||
// Constructor with envelope and IsUnique flag :
|
||||
// --------------------------------------------------
|
||||
//
|
||||
G4FastSimulationManager::
|
||||
G4FastSimulationManager(G4Envelope *anEnvelope,
|
||||
G4bool IsUnique) :
|
||||
fFastTrack(anEnvelope,IsUnique),fTriggedFastSimulationModel(NULL),
|
||||
fLastCrossedParticle(NULL)
|
||||
{
|
||||
// Communicates to the Logical Volume that it becomes a
|
||||
// envelope and with this fast simulation manager.
|
||||
anEnvelope->BecomeEnvelopeForFastSimulation(this);
|
||||
|
||||
// Add itself to the GlobalFastSimulationManager
|
||||
G4GlobalFastSimulationManager::GetGlobalFastSimulationManager()->
|
||||
AddFastSimulationManager(this);
|
||||
}
|
||||
|
||||
// -----------
|
||||
// Destructor:
|
||||
// -----------
|
||||
G4FastSimulationManager::~G4FastSimulationManager()
|
||||
{
|
||||
//
|
||||
// Check out the Envelope about this pointer. If in use,
|
||||
// resets the Logical Volume IsEnvelope flag to avoid clash.
|
||||
//
|
||||
if(fFastTrack.GetEnvelope()->GetFastSimulationManager()==this)
|
||||
fFastTrack.GetEnvelope()->ClearEnvelopeForFastSimulation();
|
||||
// Remove itself from the GlobalFastSimulationManager
|
||||
G4GlobalFastSimulationManager::GetGlobalFastSimulationManager()->
|
||||
RemoveFastSimulationManager(this);
|
||||
}
|
||||
|
||||
// ---------------------------------------
|
||||
// Methods to activate/inactivate models
|
||||
//----------------------------------------
|
||||
|
||||
G4bool
|
||||
G4FastSimulationManager::ActivateFastSimulationModel(const G4String& aName)
|
||||
{
|
||||
G4int iModel;
|
||||
|
||||
// If the model is already active, do nothing.
|
||||
for (iModel=0; iModel<ModelList.length(); iModel++)
|
||||
if(ModelList(iModel)->GetName() == aName)
|
||||
return true;
|
||||
|
||||
// Look for in the fInactivatedModels list, if found insert it back to
|
||||
// the ModelList
|
||||
for (iModel=0; iModel<fInactivatedModels.length(); iModel++)
|
||||
if(fInactivatedModels(iModel)->GetName() == aName) {
|
||||
ModelList.
|
||||
insert(fInactivatedModels.removeAt(iModel));
|
||||
// forces the fApplicableModelList to be rebuild
|
||||
fLastCrossedParticle=NULL;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
G4bool
|
||||
G4FastSimulationManager::InActivateFastSimulationModel(const G4String& aName)
|
||||
{
|
||||
// Look for in the ModelList, if found remove from it and keep the pointer
|
||||
// on the fInactivatedModels list.
|
||||
for (G4int iModel=0; iModel<ModelList.length(); iModel++)
|
||||
if(ModelList(iModel)->GetName() == aName) {
|
||||
fInactivatedModels.
|
||||
insert(ModelList.removeAt(iModel));
|
||||
// forces the fApplicableModelList to be rebuild
|
||||
fLastCrossedParticle=NULL;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//----------------------------------------
|
||||
// Methods to add/remove GhostPlacements
|
||||
//----------------------------------------
|
||||
|
||||
G4Transform3D*
|
||||
G4FastSimulationManager::AddGhostPlacement(G4RotationMatrix *prot,
|
||||
const G4ThreeVector &tlate)
|
||||
{
|
||||
G4Transform3D* newghostplace;
|
||||
if(prot==0) prot = new G4RotationMatrix();
|
||||
newghostplace = new G4Transform3D(*prot,tlate);
|
||||
AddGhostPlacement(newghostplace);
|
||||
return newghostplace;
|
||||
}
|
||||
|
||||
G4Transform3D*
|
||||
G4FastSimulationManager::AddGhostPlacement(G4Transform3D *trans3d)
|
||||
{
|
||||
GhostPlacements.insert(trans3d);
|
||||
G4GlobalFastSimulationManager::GetGlobalFastSimulationManager()->
|
||||
FastSimulationNeedsToBeClosed();
|
||||
return trans3d;
|
||||
}
|
||||
|
||||
G4bool
|
||||
G4FastSimulationManager::RemoveGhostPlacement(const G4Transform3D *trans3d)
|
||||
{
|
||||
G4bool found;
|
||||
if((found=(GhostPlacements.remove(trans3d) != NULL)))
|
||||
G4GlobalFastSimulationManager::GetGlobalFastSimulationManager()->
|
||||
FastSimulationNeedsToBeClosed();
|
||||
return found;
|
||||
}
|
||||
|
||||
//
|
||||
//-------------------------------------
|
||||
// Interface trigger method for the
|
||||
// G4ParameterisationManagerProcess
|
||||
//-------------------------------------
|
||||
// G4bool GetFastSimulationManagerTrigger(const G4Track &);
|
||||
//
|
||||
// This method is used to interface the G4FastSimulationManagerProcess
|
||||
// with the user Fast Simulation Models. It's called when the particle
|
||||
// is inside the envelope.
|
||||
//
|
||||
// It :
|
||||
//
|
||||
// 1) initialises the private members (fFastTrack and so
|
||||
// on);
|
||||
// 2) loops on the IsApplicable() methods to find out the
|
||||
// ones should be applied.
|
||||
// 2) for these, loops on the ModelTrigger() methods to find out
|
||||
// perhaps one that must be applied just now.
|
||||
//
|
||||
// If the a Fast Simulation Model is triggered then it returns
|
||||
// true, false otherwise.
|
||||
//
|
||||
//-----------------------------------------------------------
|
||||
G4bool
|
||||
G4FastSimulationManager::
|
||||
PostStepGetFastSimulationManagerTrigger(const G4Track& track,
|
||||
const G4Navigator* theNavigator)
|
||||
{
|
||||
G4int iModel;
|
||||
|
||||
// If particle type changed re-build the fApplicableModelList.
|
||||
if(fLastCrossedParticle!=track.GetDefinition()) {
|
||||
fLastCrossedParticle=track.GetDefinition();
|
||||
fApplicableModelList.clear();
|
||||
// If Model List is empty, do nothing !
|
||||
if(ModelList.length()==0) return false;
|
||||
for (iModel=0; iModel<ModelList.length(); iModel++)
|
||||
if(ModelList(iModel)->IsApplicable(*(track.GetDefinition())))
|
||||
fApplicableModelList.insert(ModelList(iModel));
|
||||
}
|
||||
|
||||
// If Applicable Model List is empty, do nothing !
|
||||
if(fApplicableModelList.length()==0) return false;
|
||||
|
||||
// -- Register current track
|
||||
fFastTrack.SetCurrentTrack(track,theNavigator);
|
||||
|
||||
// tests if particle are on the boundary and leaving,
|
||||
// in this case do nothing !
|
||||
if(fFastTrack.OnTheBoundaryButExiting()) return false;
|
||||
|
||||
// Loops on the ModelTrigger() methods
|
||||
for (iModel=0; iModel<fApplicableModelList.length(); iModel++)
|
||||
|
||||
//---------------------------------------------------
|
||||
// Asks the ModelTrigger method if it must be trigged now.
|
||||
//---------------------------------------------------
|
||||
|
||||
if(fApplicableModelList(iModel)->ModelTrigger(fFastTrack)) {
|
||||
//--------------------------------------------------
|
||||
// The model will be applied. Initializes the G4FastStep
|
||||
// with the current state of the G4Track and
|
||||
// same usefull parameters.
|
||||
// In particular it does SetLocalEnergyDeposit(0.0).
|
||||
//--------------------------------------------------
|
||||
fFastStep.Initialize(fFastTrack);
|
||||
|
||||
// Keeps the FastSimulationModel pointer to call the
|
||||
// DoIt() method.
|
||||
fTriggedFastSimulationModel=fApplicableModelList(iModel);
|
||||
return true;
|
||||
}
|
||||
|
||||
//--------------------------------------------
|
||||
// Nobody asks to gain control, returns false
|
||||
//--------------------------------------------
|
||||
return false;
|
||||
}
|
||||
|
||||
void G4FastSimulationManager::InvokePostStepDoIt()
|
||||
{
|
||||
// const G4FastTrack& parFastTrack=fFastTrack;
|
||||
fTriggedFastSimulationModel->DoIt(fFastTrack,fFastStep);
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------
|
||||
// -- Mostly the same as above, in the case of AtRest particles:
|
||||
// -------------------------------------------------------------
|
||||
G4bool
|
||||
G4FastSimulationManager::AtRestGetFastSimulationManagerTrigger(const G4Track& track,
|
||||
const G4Navigator* theNavigator)
|
||||
{
|
||||
G4int iModel;
|
||||
|
||||
// If particle type changed re-build the fApplicableModelList.
|
||||
if(fLastCrossedParticle!=track.GetDefinition()) {
|
||||
fLastCrossedParticle=track.GetDefinition();
|
||||
fApplicableModelList.clear();
|
||||
// If Model List is empty, do nothing !
|
||||
if(ModelList.length()==0) return false;
|
||||
for (iModel=0; iModel<ModelList.length(); iModel++)
|
||||
if(ModelList(iModel)->IsApplicable(*(track.GetDefinition())))
|
||||
fApplicableModelList.insert(ModelList(iModel));
|
||||
}
|
||||
|
||||
// If Applicable Model List is empty, do nothing !
|
||||
if(fApplicableModelList.length()==0) return false;
|
||||
|
||||
// -- Register current track
|
||||
fFastTrack.SetCurrentTrack(track,theNavigator);
|
||||
|
||||
// -- (note: compared to the PostStepGetFastSimulationManagerTrigger,
|
||||
// -- the test to see if the particle is on the boundary but leaving
|
||||
// -- is irrelevant here)
|
||||
|
||||
// Loops on the models to see if one of them wants to trigger:
|
||||
for (iModel=0; iModel < fApplicableModelList.length(); iModel++)
|
||||
if(fApplicableModelList(iModel)->AtRestModelTrigger(fFastTrack))
|
||||
{
|
||||
fFastStep.Initialize(fFastTrack);
|
||||
fTriggedFastSimulationModel=fApplicableModelList(iModel);
|
||||
return true;
|
||||
}
|
||||
|
||||
//--------------------------------------------
|
||||
// Nobody asks to gain control, returns false
|
||||
//--------------------------------------------
|
||||
return false;
|
||||
}
|
||||
|
||||
void G4FastSimulationManager::InvokeAtRestDoIt()
|
||||
{
|
||||
fTriggedFastSimulationModel->AtRestDoIt(fFastTrack,fFastStep);
|
||||
}
|
||||
|
||||
G4bool
|
||||
G4FastSimulationManager::
|
||||
InsertGhostHereIfNecessary(G4VPhysicalVolume* theClone,
|
||||
const G4ParticleDefinition& theParticle)
|
||||
{
|
||||
G4PVPlacement *GhostPhysical;
|
||||
// Not to do if there aren't glost placements
|
||||
if(GhostPlacements.length()==0) return false;
|
||||
|
||||
// If there are, verifies if at least one model is applicable
|
||||
// for theParticle.
|
||||
for (G4int iModel=0; iModel<ModelList.length(); iModel++)
|
||||
if(ModelList(iModel)->IsApplicable(theParticle)) {
|
||||
// Ok, we find one. Place the ghost(s).
|
||||
for (G4int ighost=0; ighost<GhostPlacements.length(); ighost++)
|
||||
GhostPhysical=new
|
||||
G4PVPlacement(*(GhostPlacements(ighost)),
|
||||
fFastTrack.GetEnvelope()->GetName(),
|
||||
fFastTrack.GetEnvelope(),
|
||||
theClone,
|
||||
false,0);
|
||||
// And answer true
|
||||
return true;
|
||||
}
|
||||
//otherwise answer false
|
||||
return false;
|
||||
}
|
||||
|
||||
void
|
||||
G4FastSimulationManager::ListTitle() const
|
||||
{
|
||||
G4cout << fFastTrack.GetEnvelope()->GetName();
|
||||
if(GhostPlacements.length()!=0) G4cout << " (ghost)";
|
||||
}
|
||||
|
||||
void
|
||||
G4FastSimulationManager::ListModels() const
|
||||
{
|
||||
G4int iModel;
|
||||
|
||||
G4cout << "Current Models for the ";
|
||||
ListTitle();
|
||||
G4cout << " Envelope:\n";
|
||||
|
||||
for (iModel=0; iModel<ModelList.length(); iModel++)
|
||||
G4cout << " " << ModelList(iModel)->GetName() << "\n";
|
||||
|
||||
for (iModel=0; iModel<fInactivatedModels.length(); iModel++)
|
||||
G4cout << " " << fInactivatedModels(iModel)->GetName()
|
||||
<< "(inactivated)\n";
|
||||
}
|
||||
|
||||
void
|
||||
G4FastSimulationManager::ListModels(const G4String& aName) const
|
||||
{
|
||||
G4int iModel;
|
||||
G4int titled = 0;
|
||||
G4ParticleTable* theParticleTable=
|
||||
G4ParticleTable::GetParticleTable();
|
||||
|
||||
// Active Models
|
||||
for (iModel=0; iModel<ModelList.length(); iModel++)
|
||||
if(ModelList(iModel)->GetName() == aName ||
|
||||
aName == "all" ) {
|
||||
if(!(titled++)){
|
||||
G4cout << "In the envelope ";
|
||||
ListTitle();
|
||||
G4cout << ",\n";
|
||||
}
|
||||
G4cout << " the model " << ModelList(iModel)->GetName()
|
||||
<< " is applicable for :\n ";
|
||||
|
||||
G4int list_started=0;
|
||||
for (G4int iParticle=0; iParticle<theParticleTable->entries();
|
||||
iParticle++)
|
||||
if(ModelList(iModel)->
|
||||
IsApplicable(*(theParticleTable->
|
||||
GetParticle(iParticle)))) {
|
||||
if(list_started++) G4cout << ", ";
|
||||
G4cout << theParticleTable->
|
||||
GetParticle(iParticle)->GetParticleName();
|
||||
}
|
||||
G4cout <<endl;
|
||||
}
|
||||
|
||||
// Inactive Models
|
||||
for (iModel=0; iModel<fInactivatedModels.length(); iModel++)
|
||||
if(fInactivatedModels(iModel)->GetName() == aName ||
|
||||
aName == "all" ) {
|
||||
if(!(titled++)){
|
||||
G4cout << "In the envelope ";
|
||||
ListTitle();
|
||||
G4cout << ",\n";
|
||||
}
|
||||
G4cout << " the model " << fInactivatedModels(iModel)->GetName()
|
||||
<< " (inactivated) is applicable for :\n ";
|
||||
|
||||
G4int list_started=0;
|
||||
for (G4int iParticle=0; iParticle<theParticleTable->entries();
|
||||
iParticle++)
|
||||
if(fInactivatedModels(iModel)->
|
||||
IsApplicable(*(theParticleTable->
|
||||
GetParticle(iParticle)))) {
|
||||
if(list_started++) G4cout << ", ";
|
||||
G4cout << theParticleTable->
|
||||
GetParticle(iParticle)->GetParticleName();
|
||||
}
|
||||
G4cout <<endl;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
G4FastSimulationManager::ListModels(const G4ParticleDefinition* aPD) const
|
||||
{
|
||||
G4int iModel;
|
||||
G4bool unique=true;
|
||||
|
||||
// Active Models
|
||||
for (iModel=0; iModel<ModelList.length(); iModel++)
|
||||
if(ModelList(iModel)->IsApplicable(*aPD)) {
|
||||
G4cout << "Envelope ";
|
||||
ListTitle();
|
||||
G4cout << ", Model "
|
||||
<< ModelList(iModel)->GetName()
|
||||
<< "." << endl;
|
||||
}
|
||||
// inactive Models
|
||||
for (iModel=0; iModel<fInactivatedModels.length(); iModel++)
|
||||
if(fInactivatedModels(iModel)->IsApplicable(*aPD)) {
|
||||
G4cout << "Envelope ";
|
||||
ListTitle();
|
||||
G4cout << ", Model "
|
||||
<< fInactivatedModels(iModel)->GetName()
|
||||
<< " (inactivated)." << endl;
|
||||
}
|
||||
|
||||
if(!unique)
|
||||
G4cout << "\a\n >>>>>>Warning: two or more Models for the same "
|
||||
<< "particle type attached to the same envelope!"
|
||||
<< endl;
|
||||
unique=false;
|
||||
}
|
||||
@@ -0,0 +1,530 @@
|
||||
// This code implementation is the intellectual property of
|
||||
// the RD44 GEANT4 collaboration.
|
||||
//
|
||||
// By copying, distributing or modifying the Program (or any work
|
||||
// based on the Program) you indicate your acceptance of this statement,
|
||||
// and all its terms.
|
||||
//
|
||||
// $Id: G4FastSimulationManagerProcess.cc,v 2.14 1998/12/08 04:06:48 verderi Exp $
|
||||
// GEANT4 tag $Name: geant4-00 $
|
||||
//
|
||||
//
|
||||
//---------------------------------------------------------------
|
||||
//
|
||||
// G4FastSimulationProcess.cc
|
||||
//
|
||||
// Description:
|
||||
// The process that triggers the parameterised simulations,
|
||||
// if any.
|
||||
//
|
||||
// History:
|
||||
// August 97: First implementation. Verderi && MoraDeFreitas.
|
||||
//---------------------------------------------------------------
|
||||
|
||||
#include "G4ios.hh"
|
||||
#include "G4FastSimulationManagerProcess.hh"
|
||||
#include "G4GlobalFastSimulationManager.hh"
|
||||
#include "G4TransportationManager.hh"
|
||||
#include "G4ParticleChange.hh"
|
||||
|
||||
//----------------------------
|
||||
// Constructor with only name:
|
||||
//----------------------------
|
||||
G4FastSimulationManagerProcess::
|
||||
G4FastSimulationManagerProcess(const G4String& processName,
|
||||
G4ProcessType theType) :
|
||||
G4VProcess(processName,theType)
|
||||
{
|
||||
pParticleChange = &aDummyParticleChange;
|
||||
|
||||
fGhostTouchable = new G4TouchableHistory();
|
||||
if (verboseLevel>0) {
|
||||
G4cout << GetProcessName() << " is created " << endl;
|
||||
}
|
||||
fGhostFieldPropagator = new G4PropagatorInField(&fGhostNavigator,
|
||||
G4TransportationManager::
|
||||
GetTransportationManager()->
|
||||
GetFieldManager());
|
||||
}
|
||||
|
||||
// -----------
|
||||
// Destructor:
|
||||
// -----------
|
||||
G4FastSimulationManagerProcess::~G4FastSimulationManagerProcess()
|
||||
{
|
||||
delete fGhostTouchable;
|
||||
delete fGhostFieldPropagator;
|
||||
}
|
||||
|
||||
|
||||
//----------------------------------------------------------
|
||||
//
|
||||
// PostStepGetPhysicalInteractionLength()
|
||||
//
|
||||
// This method is used to trigger the parameterised
|
||||
// simulation.
|
||||
//
|
||||
//----------------------------------------------------------
|
||||
//
|
||||
// To be triggered the conditions that must be
|
||||
// fullfilled are :
|
||||
//
|
||||
// 1) a call to track->GetVolume()->GetLogicalVolume()->
|
||||
// GetFastSimulationManager() returns a G4FastSimulationManager
|
||||
// not NULL pointer (kept in fFastSimulationManager);
|
||||
//
|
||||
// AND
|
||||
//
|
||||
// 2)a call to this fFastSimulationManager->GetTrigger() method
|
||||
/// returns a G4bool True.
|
||||
//
|
||||
//
|
||||
// If the fFastSimulationManager* is triggered then:
|
||||
//
|
||||
// * condition = ExclusivelyForced
|
||||
// * returns 0.0
|
||||
//
|
||||
// else:
|
||||
// * condition = NotForced
|
||||
// * returns DBL_MAX
|
||||
//
|
||||
//-----------------------------------------------------------
|
||||
G4double
|
||||
G4FastSimulationManagerProcess::PostStepGetPhysicalInteractionLength(
|
||||
const G4Track& track,
|
||||
G4double previousStepSize,
|
||||
G4ForceCondition* condition)
|
||||
{
|
||||
// ------------------------------
|
||||
// Prelude for initial Step only:
|
||||
// ------------------------------
|
||||
// ----------------------------------------------------------
|
||||
// -- If starting a track, check if there is a parallel World
|
||||
// -- for the new particle being tracked.
|
||||
// -- (may be Done more than once in very special cases,
|
||||
// -- since the fStarTracking is switched off lower.)
|
||||
// ----------------------------------------------------------
|
||||
if(fStartTracking)
|
||||
{
|
||||
G4FlavoredParallelWorld* flavoredWorld =
|
||||
G4GlobalFastSimulationManager::GetGlobalFastSimulationManager()->
|
||||
GetFlavoredWorldForThis(track.GetDynamicParticle()->GetDefinition());
|
||||
|
||||
fGhostWorld = NULL;
|
||||
if (flavoredWorld)
|
||||
fGhostWorld = flavoredWorld->GetThePhysicalVolumeWorld();
|
||||
|
||||
if (fGhostWorld)
|
||||
{
|
||||
fGhostNavigator.SetWorldVolume(fGhostWorld);
|
||||
fUpdateGhostTouchable = true;
|
||||
fGhostSafety = -1.;
|
||||
// Navigation in Field:
|
||||
fParticleCharge = track.GetDynamicParticle()->GetDefinition()->GetPDGCharge();
|
||||
}
|
||||
else
|
||||
{
|
||||
fOutOfGhostWorld = true;
|
||||
}
|
||||
}
|
||||
|
||||
// -------------------------------------------------------
|
||||
//
|
||||
// Parameterisation Trigger invokation sequence :
|
||||
//
|
||||
// -------------------------------------------------------
|
||||
fFastSimulationTrigger = false;
|
||||
|
||||
//---------------------------------------------
|
||||
// Normal Dispatcher (for tracking geometry) :
|
||||
//---------------------------------------------
|
||||
if(fFastSimulationManager =
|
||||
track.GetVolume()->GetLogicalVolume()->GetFastSimulationManager())
|
||||
{
|
||||
// Yes, so should us trigger a fast simulation model now ?
|
||||
if(fFastSimulationTrigger =
|
||||
fFastSimulationManager->PostStepGetFastSimulationManagerTrigger(track))
|
||||
{
|
||||
// Yes, lets take the control over the stepping !
|
||||
*condition = ExclusivelyForced;
|
||||
return 0.0;
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// * Parallel geometry Dispatcher if any.
|
||||
// * If no trigger in the parallel geometry
|
||||
// returns the Conditionally forced signal.
|
||||
//-----------------------------------------
|
||||
if(fGhostWorld)
|
||||
{
|
||||
// First, update the touchable history of ghost if necessary, ie when:
|
||||
// - this is first Step of tracking
|
||||
// - the last Step was limited by ghost geometry
|
||||
// otherwise performs a single Locate
|
||||
if (fUpdateGhostTouchable)
|
||||
{
|
||||
fUpdateGhostTouchable=false;
|
||||
if (fStartTracking)
|
||||
{
|
||||
fGhostNavigator.LocateGlobalPointAndUpdateTouchable(
|
||||
track.GetPosition(),
|
||||
track.GetMomentumDirection(),
|
||||
fGhostTouchable,
|
||||
false);
|
||||
fStartTracking = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
fGhostNavigator.SetGeometricallyLimitedStep();
|
||||
fGhostNavigator.LocateGlobalPointAndUpdateTouchable(
|
||||
track.GetPosition(),
|
||||
track.GetMomentumDirection(),
|
||||
fGhostTouchable);
|
||||
}
|
||||
fOutOfGhostWorld = (fGhostTouchable->GetVolume() == NULL);
|
||||
}
|
||||
else if (previousStepSize > 0.0)
|
||||
{
|
||||
// G4ThreeVector direction= track.GetMomentumDirection();
|
||||
// fGhostNavigator.LocateGlobalPointAndSetup(track.GetPosition(), &direction, true);
|
||||
// The above looks not enough in case of mag-field, not clear why ?!?
|
||||
fGhostNavigator.LocateGlobalPointAndUpdateTouchable(
|
||||
track.GetPosition(),
|
||||
track.GetMomentumDirection(),
|
||||
fGhostTouchable);
|
||||
}
|
||||
|
||||
|
||||
if (!fOutOfGhostWorld)
|
||||
{
|
||||
if(fFastSimulationManager =
|
||||
fGhostTouchable->GetVolume()->GetLogicalVolume()->GetFastSimulationManager())
|
||||
{
|
||||
// Yes, so should us trigger a fast simulation model now ?
|
||||
if(fFastSimulationTrigger =
|
||||
fFastSimulationManager->PostStepGetFastSimulationManagerTrigger(track,&fGhostNavigator))
|
||||
{
|
||||
// Yes, lets take the control over the stepping !
|
||||
*condition = ExclusivelyForced;
|
||||
return 0.0;
|
||||
}
|
||||
}
|
||||
// No ghost trigger has occured (ie no manager or a manager but no trigger)
|
||||
// Informs the stepping that PostStepDoIt may be called if the AlongGPIL
|
||||
// will limit the Step.
|
||||
// PostStepDoIt will switch on fUpdateGhostTouchable flag,
|
||||
// and eventually correct position and mometum in case of
|
||||
// mag-field.
|
||||
*condition = Conditionally;
|
||||
return DBL_MAX;
|
||||
}
|
||||
}
|
||||
|
||||
*condition = NotForced;
|
||||
return DBL_MAX;
|
||||
}
|
||||
|
||||
//------------------------------------
|
||||
//
|
||||
// PostStepDoIt()
|
||||
//
|
||||
//------------------------------------
|
||||
G4VParticleChange* G4FastSimulationManagerProcess::PostStepDoIt(
|
||||
const G4Track& track,
|
||||
const G4Step& Step)
|
||||
{
|
||||
if (fFastSimulationTrigger)
|
||||
{
|
||||
// Executes the ParameterisedSimulation code.
|
||||
fFastSimulationManager->InvokePostStepDoIt();
|
||||
// Gets the ParameterisedSimulation response.
|
||||
G4VParticleChange* Response=fFastSimulationManager->GettheParticleChange();
|
||||
// If the particle is still alive, suspend it
|
||||
// to re-initialise the other process.
|
||||
if (Response->GetStatusChange() != fStopAndKill)
|
||||
Response->SetStatusChange(fSuspend);
|
||||
// Returns the Response
|
||||
return Response;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (fOutOfGhostWorld) G4cout << " ????????????? Problem of logic in GHOST param !!! " << endl;
|
||||
// No FastSimulationManager has asked for trigger. That means here:
|
||||
// - the PostStep is "Conditionally" forced because
|
||||
// - the Step has been limited by the ALong of G4FSMP because
|
||||
// - the track has reached a ghost boundary
|
||||
// => the touchable history must be updated.
|
||||
// fUpdateGhostTouchable = true; : MOVED BELOW: COMPLICATIONS WITH MAG-FIELD !!
|
||||
|
||||
if (fFieldExertsForce)
|
||||
{
|
||||
// -----------------------------------------------------------
|
||||
// in case of field, correct for small discrepancy on position
|
||||
// and momentum computed by the Transportation.
|
||||
// HOWEVER, this correction can be somewhat problematic when
|
||||
// the end point, which is close here to a Ghost boundary by
|
||||
// construction, is also close to a boundary of the tracking
|
||||
// geometry.
|
||||
// Thus we correct when the safety in the tracking geometry
|
||||
// allows to move the point enough. Otherwise we issue
|
||||
// a warning.
|
||||
// ----------------------------------------------------------
|
||||
fTrackingNavigator.SetWorldVolume(G4TransportationManager::GetTransportationManager()->
|
||||
GetNavigatorForTracking()->GetWorldVolume());
|
||||
fTrackingNavigator.LocateGlobalPointAndUpdateTouchable(
|
||||
track.GetPosition(),
|
||||
track.GetMomentumDirection(),
|
||||
&fTrackingHistory);
|
||||
G4VPhysicalVolume* trackingVolume = fTrackingHistory.GetVolume();
|
||||
|
||||
G4double trackingSafety(0.0);
|
||||
G4double trackingLinearDistance =
|
||||
fTrackingNavigator.ComputeStep(
|
||||
track.GetPosition(),
|
||||
track.GetMomentumDirection(),
|
||||
DBL_MAX,
|
||||
trackingSafety);
|
||||
|
||||
xParticleChange.Initialize(track);
|
||||
G4ThreeVector deltaPos = fGhostFieldPropagator->EndPosition() - track.GetPosition();
|
||||
if (trackingSafety < deltaPos.mag())
|
||||
{
|
||||
fUpdateGhostTouchable = true; // What should we do here ?!?
|
||||
// false => lot a microscopic steps
|
||||
// is true rasonnably safe ?
|
||||
G4cout << GetProcessName() << " : WARNING: Can not correct for\ndifference between tracking and ghost mag-field computations." << endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
// easy case where we have enough room to displace the point where we need:
|
||||
fUpdateGhostTouchable = true;
|
||||
xParticleChange.SetPositionChange(fGhostFieldPropagator->EndPosition());
|
||||
xParticleChange.SetMomentumChange(fGhostFieldPropagator->EndMomentumDir());
|
||||
}
|
||||
return &xParticleChange;
|
||||
}
|
||||
else
|
||||
{
|
||||
fUpdateGhostTouchable = true;
|
||||
pParticleChange->Initialize(track);
|
||||
return pParticleChange;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
G4double G4FastSimulationManagerProcess::AlongStepGetPhysicalInteractionLength(
|
||||
const G4Track& track,
|
||||
G4double previousStepSize,
|
||||
G4double currentMinimumStep,
|
||||
G4double& proposedSafety,
|
||||
G4GPILSelection* selection
|
||||
)
|
||||
{
|
||||
// Informs the stepping that G4FastsimulationProcess wants
|
||||
// to be able to limit the Step.
|
||||
*selection = CandidateForSelection;
|
||||
|
||||
G4double returnedStep = DBL_MAX;
|
||||
|
||||
if (!fOutOfGhostWorld)
|
||||
{
|
||||
if (previousStepSize > 0.) fGhostSafety -= previousStepSize;
|
||||
else fGhostSafety = -1.;
|
||||
if (fGhostSafety < 0.) fGhostSafety = 0.0;
|
||||
|
||||
// ------------------------------------------
|
||||
// Determination of the proposed STEP LENGTH:
|
||||
// ------------------------------------------
|
||||
if (currentMinimumStep <= fGhostSafety)
|
||||
{
|
||||
returnedStep = currentMinimumStep;
|
||||
}
|
||||
else // (currentMinimumStep > fGhostSafety: GFSMP may limit the Step)
|
||||
{
|
||||
fFieldExertsForce = (fParticleCharge != 0.0) &&
|
||||
(G4TransportationManager::GetTransportationManager()->
|
||||
GetFieldManager()->DoesFieldExist());
|
||||
if ( !fFieldExertsForce )
|
||||
{
|
||||
fGhostStepLength = fGhostNavigator.ComputeStep(
|
||||
track.GetPosition(),
|
||||
track.GetMomentumDirection(),
|
||||
currentMinimumStep,
|
||||
fGhostSafety);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
fGhostFieldPropagator->SetChargeMomentumMass(
|
||||
fParticleCharge,
|
||||
track.GetDynamicParticle()->
|
||||
GetTotalMomentum(),
|
||||
track.GetDynamicParticle()->
|
||||
GetMass());
|
||||
|
||||
fGhostStepLength = fGhostFieldPropagator->ComputeStep(
|
||||
track.GetPosition(),
|
||||
track.GetMomentumDirection(),
|
||||
currentMinimumStep,
|
||||
fGhostSafety);
|
||||
}
|
||||
fPreSafety = fGhostSafety;
|
||||
returnedStep = fGhostStepLength;
|
||||
}
|
||||
|
||||
// ----------------------------------------------
|
||||
// Returns the fGhostSafety as the proposedSafety
|
||||
// The SteppingManager will take care of keeping
|
||||
// the smallest one.
|
||||
// ----------------------------------------------
|
||||
proposedSafety = fGhostSafety;
|
||||
}
|
||||
return returnedStep;
|
||||
}
|
||||
|
||||
G4VParticleChange* G4FastSimulationManagerProcess::AlongStepDoIt(
|
||||
const G4Track& track,
|
||||
const G4Step& Step
|
||||
)
|
||||
{
|
||||
// Dummy ParticleChange ie: does nothing
|
||||
pParticleChange->Initialize(track);
|
||||
return pParticleChange;
|
||||
}
|
||||
|
||||
//--------------------------------------------
|
||||
//
|
||||
// At Rest parameterisation:
|
||||
//
|
||||
//--------------------------------------------
|
||||
//
|
||||
// AtRestGetPhysiscalInteractionLength:
|
||||
//
|
||||
//--------------------------------------------
|
||||
G4double
|
||||
G4FastSimulationManagerProcess::AtRestGetPhysicalInteractionLength(
|
||||
const G4Track& track,
|
||||
G4ForceCondition* condition)
|
||||
{
|
||||
if ( (fFastSimulationManager =
|
||||
track.GetVolume()->GetLogicalVolume()->GetFastSimulationManager())
|
||||
!= NULL )
|
||||
if (fFastSimulationManager->AtRestGetFastSimulationManagerTrigger(track))
|
||||
{
|
||||
// "*condition = ExclusivelyForced;" Not yet available
|
||||
// for AtRest actions, so we use the trick below. However
|
||||
// it is not garantee to work in the situation the track is
|
||||
// alive after parameterisation.
|
||||
// NOTE: Problem: the present stepping doesn't care if the particle
|
||||
// has been killed between two AtRestDoIt() !!!
|
||||
*condition = NotForced;
|
||||
return -1.0; // TEMPORARY TRICK TO TAKE CONTROL !!!!
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// * Parallel geometry Dispatcher if any.
|
||||
// * If no trigger in the parallel geometry
|
||||
// * returns DBL_MAX and NotForced signal.
|
||||
//-----------------------------------------
|
||||
if(fGhostWorld)
|
||||
{
|
||||
// First, update the touchable history of ghost if necessary, ie when:
|
||||
// - this is first Step of tracking
|
||||
// - the last Step was limited by ghost geometry
|
||||
// otherwise performs a single Locate
|
||||
if (fUpdateGhostTouchable)
|
||||
{
|
||||
fUpdateGhostTouchable=false;
|
||||
if (fStartTracking)
|
||||
{
|
||||
fGhostNavigator.LocateGlobalPointAndUpdateTouchable(
|
||||
track.GetPosition(),
|
||||
fGhostTouchable,
|
||||
false);
|
||||
fStartTracking = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
fGhostNavigator.SetGeometricallyLimitedStep();
|
||||
fGhostNavigator.LocateGlobalPointAndUpdateTouchable(
|
||||
track.GetPosition(),
|
||||
fGhostTouchable);
|
||||
|
||||
}
|
||||
fOutOfGhostWorld = (fGhostTouchable->GetVolume() == NULL);
|
||||
}
|
||||
|
||||
if (!fOutOfGhostWorld)
|
||||
{
|
||||
if(fFastSimulationManager =
|
||||
fGhostTouchable->GetVolume()->GetLogicalVolume()->GetFastSimulationManager())
|
||||
{
|
||||
// Should it trigger a fast simulation model now ?
|
||||
if(fFastSimulationTrigger =
|
||||
fFastSimulationManager->
|
||||
AtRestGetFastSimulationManagerTrigger(track,&fGhostNavigator))
|
||||
{
|
||||
// "*condition = ExclusivelyForced;" Not yet available
|
||||
// for AtRest actions, so we use the trick below. However
|
||||
// it is not garantee to work in the situation the track is
|
||||
// alive after parameterisation.
|
||||
// NOTE: Problem: the present stepping doesn't care if the particle
|
||||
// has been killed between two AtRestDoIt() !!!
|
||||
*condition = NotForced;
|
||||
return -1.0; // TEMPORARY TRICK TO TAKE CONTROL !!!!
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// No, avoid to take control over the PostStepDoIt methods.
|
||||
*condition = NotForced;
|
||||
return DBL_MAX;
|
||||
}
|
||||
|
||||
//-----------------------------------------------
|
||||
//
|
||||
// AtRestDoIt:
|
||||
//
|
||||
//-----------------------------------------------
|
||||
G4VParticleChange* G4FastSimulationManagerProcess::AtRestDoIt(
|
||||
const G4Track& track,
|
||||
const G4Step& Step)
|
||||
{
|
||||
fFastSimulationManager->InvokeAtRestDoIt();
|
||||
G4VParticleChange* Response = fFastSimulationManager->GettheParticleChange();
|
||||
return Response;
|
||||
}
|
||||
|
||||
void G4FastSimulationManagerProcess::StartTracking()
|
||||
{
|
||||
fStartTracking = true;
|
||||
}
|
||||
|
||||
void G4FastSimulationManagerProcess::Verbose() const
|
||||
{
|
||||
/* G4cout << " >>>>> Trigger Status : ";
|
||||
switch(fFastSimulationManager->GetTriggerStatus())
|
||||
{
|
||||
case NoModel:
|
||||
G4cout << "NoModel" << endl;
|
||||
break;
|
||||
case OnBoundaryButLeaving:
|
||||
G4cout << "OnBoundaryButLeaving" << endl;
|
||||
break;
|
||||
case OneModelTrigger:
|
||||
G4cout << "OneModelTrigger" << endl;
|
||||
break;
|
||||
case NoModelTrigger:
|
||||
G4cout << "NoModelTrigger" << endl;
|
||||
break;
|
||||
case Undefined:
|
||||
G4cout << "Undefined" << endl;
|
||||
break;
|
||||
default:
|
||||
G4cout << " Bizarre..." << endl;
|
||||
break;
|
||||
}*/
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
// This code implementation is the intellectual property of
|
||||
// the RD44 GEANT4 collaboration.
|
||||
//
|
||||
// By copying, distributing or modifying the Program (or any work
|
||||
// based on the Program) you indicate your acceptance of this statement,
|
||||
// and all its terms.
|
||||
//
|
||||
// $Id: G4FastSimulationMessenger.cc,v 2.3 1998/10/13 09:54:40 mora Exp $
|
||||
// GEANT4 tag $Name: geant4-00 $
|
||||
//
|
||||
|
||||
#include "G4FastSimulationMessenger.hh"
|
||||
#include "G4UIdirectory.hh"
|
||||
#include "G4UIcmdWithAString.hh"
|
||||
#include "G4UIcmdWithoutParameter.hh"
|
||||
|
||||
#include "G4ios.hh"
|
||||
|
||||
G4FastSimulationMessenger::
|
||||
G4FastSimulationMessenger(G4GlobalFastSimulationManager* theGFSM)
|
||||
: fGlobalFastSimulationManager(theGFSM)
|
||||
{
|
||||
fFSDirectory = new G4UIdirectory("/param/");
|
||||
fFSDirectory->SetGuidance("Fast Simulation print/control commands.");
|
||||
|
||||
fListEnvelopesCmd =
|
||||
new G4UIcmdWithAString("/param/listEnvelopes", this);
|
||||
fListEnvelopesCmd->SetParameterName("ParticleName",true);
|
||||
fListEnvelopesCmd->SetDefaultValue("all");
|
||||
fListEnvelopesCmd->SetGuidance("List all the envelope names for a given Particle");
|
||||
fListEnvelopesCmd->SetGuidance("(or for all particles if without parameters).");
|
||||
fListEnvelopesCmd->AvailableForStates(PreInit,Idle);
|
||||
|
||||
fListModelsCmd =
|
||||
new G4UIcmdWithAString("/param/listModels", this);
|
||||
fListModelsCmd->SetParameterName("EnvelopeName",true);
|
||||
fListModelsCmd->SetDefaultValue("all");
|
||||
fListModelsCmd->SetGuidance("List all the Model names for a given Envelope");
|
||||
fListModelsCmd->SetGuidance("(or for all envelopes if without parameters).");
|
||||
fListModelsCmd->AvailableForStates(PreInit,Idle);
|
||||
|
||||
fListIsApplicableCmd =
|
||||
new G4UIcmdWithAString("/param/listIsApplicable", this);
|
||||
fListIsApplicableCmd->SetParameterName("ModelName",true);
|
||||
fListIsApplicableCmd->SetDefaultValue("all");
|
||||
fListIsApplicableCmd->SetGuidance("List all the Particle names a given Model is applicable");
|
||||
fListIsApplicableCmd->SetGuidance("(or for all Models if without parameters).");
|
||||
|
||||
fActivateModel =
|
||||
new G4UIcmdWithAString("/param/ActivateModel", this);
|
||||
fActivateModel->SetParameterName("ModelName",false);
|
||||
fActivateModel->SetGuidance("Activate a given Model.");
|
||||
|
||||
fInActivateModel =
|
||||
new G4UIcmdWithAString("/param/InActivateModel", this);
|
||||
fInActivateModel->SetParameterName("ModelName",false);
|
||||
fInActivateModel->SetGuidance("InActivate a given Model.");
|
||||
}
|
||||
|
||||
G4FastSimulationMessenger::~G4FastSimulationMessenger()
|
||||
{
|
||||
delete fListIsApplicableCmd;
|
||||
delete fActivateModel;
|
||||
delete fInActivateModel;
|
||||
delete fListModelsCmd;
|
||||
delete fListEnvelopesCmd;
|
||||
delete fFSDirectory;
|
||||
}
|
||||
|
||||
void G4FastSimulationMessenger::SetNewValue(G4UIcommand * command,G4String newValue)
|
||||
{
|
||||
if( command == fListEnvelopesCmd)
|
||||
if(newValue == "all")
|
||||
fGlobalFastSimulationManager->ListEnvelopes();
|
||||
else
|
||||
fGlobalFastSimulationManager->
|
||||
ListEnvelopes(G4ParticleTable::GetParticleTable()->
|
||||
FindParticle(newValue));
|
||||
if( command == fListModelsCmd)
|
||||
fGlobalFastSimulationManager->ListEnvelopes(newValue, MODELS);
|
||||
if( command == fListIsApplicableCmd)
|
||||
fGlobalFastSimulationManager->ListEnvelopes(newValue, ISAPPLICABLE);
|
||||
if( command == fActivateModel)
|
||||
fGlobalFastSimulationManager->ActivateFastSimulationModel(newValue);
|
||||
if( command == fInActivateModel)
|
||||
fGlobalFastSimulationManager->InActivateFastSimulationModel(newValue);
|
||||
}
|
||||
@@ -0,0 +1,450 @@
|
||||
// This code implementation is the intellectual property of
|
||||
// the RD44 GEANT4 collaboration.
|
||||
//
|
||||
// By copying, distributing or modifying the Program (or any work
|
||||
// based on the Program) you indicate your acceptance of this statement,
|
||||
// and all its terms.
|
||||
//
|
||||
// $Id: G4FastStep.cc,v 2.8 1998/11/20 19:00:46 verderi Exp $
|
||||
// GEANT4 tag $Name: geant4-00 $
|
||||
//
|
||||
//$Id:
|
||||
//---------------------------------------------------------------
|
||||
//
|
||||
// G4FastStep.cc
|
||||
//
|
||||
// Description:
|
||||
// Encapsulates a G4ParticleChange and insure friendly interface
|
||||
// methods to manage the primary/secondaries final state for
|
||||
// Fast Simulation Models.
|
||||
//
|
||||
// History:
|
||||
// Oct 97: Verderi && MoraDeFreitas - First Implementation.
|
||||
// Apr 98: MoraDeFreitas - G4FastStep becomes the G4ParticleChange
|
||||
// for the Fast Simulation Process.
|
||||
//
|
||||
//---------------------------------------------------------------
|
||||
|
||||
#include "G4FastStep.hh"
|
||||
#include "G4Track.hh"
|
||||
#include "G4Step.hh"
|
||||
#include "G4TrackFastVector.hh"
|
||||
#include "G4DynamicParticle.hh"
|
||||
|
||||
void G4FastStep::Initialize(const G4FastTrack& fastTrack)
|
||||
{
|
||||
// keeps the fastTrack reference
|
||||
fFastTrack=&fastTrack;
|
||||
|
||||
// currentTrack will be used to Initialize the other data members
|
||||
const G4Track& currentTrack = *(fFastTrack->GetPrimaryTrack());
|
||||
|
||||
// use base class's method at first
|
||||
G4VParticleChange::Initialize(currentTrack);
|
||||
|
||||
// set Energy/Momentum etc. equal to those of the parent particle
|
||||
const G4DynamicParticle* pParticle = currentTrack.GetDynamicParticle();
|
||||
theEnergyChange = pParticle->GetKineticEnergy();
|
||||
theMomentumChange = pParticle->GetMomentumDirection();
|
||||
thePolarizationChange = pParticle->GetPolarization();
|
||||
theProperTimeChange = pParticle->GetProperTime();
|
||||
|
||||
// set Position/Time etc. equal to those of the parent track
|
||||
thePositionChange = currentTrack.GetPosition();
|
||||
theTimeChange = currentTrack.GetGlobalTime();
|
||||
|
||||
// switch off stepping hit invokation by default:
|
||||
theSteppingControlFlag = AvoidHitInvocation;
|
||||
|
||||
// event biasing weigth:
|
||||
theWeightChange = currentTrack.GetWeight();
|
||||
}
|
||||
|
||||
//----------------------------------------
|
||||
// -- Set the StopAndKilled signal
|
||||
// -- and put kinetic energy to 0.0. in the
|
||||
// -- G4ParticleChange.
|
||||
//----------------------------------------
|
||||
void G4FastStep::KillPrimaryTrack()
|
||||
{
|
||||
SetPrimaryTrackFinalKineticEnergy(0.) ;
|
||||
SetStatusChange(fStopAndKill) ;
|
||||
}
|
||||
|
||||
//--------------------
|
||||
//
|
||||
//--------------------
|
||||
void
|
||||
G4FastStep::
|
||||
SetPrimaryTrackFinalPosition(const G4ThreeVector &position,
|
||||
G4bool localCoordinates)
|
||||
{
|
||||
// Compute the position coordinate in global
|
||||
// reference system if needed ...
|
||||
G4ThreeVector globalPosition = position;
|
||||
if (localCoordinates)
|
||||
globalPosition = fFastTrack->GetInverseAffineTransformation()->
|
||||
TransformPoint(position);
|
||||
// ...and feed the globalPosition:
|
||||
thePositionChange = globalPosition;
|
||||
}
|
||||
|
||||
//--------------------
|
||||
//
|
||||
//--------------------
|
||||
void
|
||||
G4FastStep::
|
||||
SetPrimaryTrackFinalMomentum(const G4ThreeVector &momentum,
|
||||
G4bool localCoordinates)
|
||||
{
|
||||
// Compute the momentum in global reference
|
||||
// system if needed ...
|
||||
G4ThreeVector globalMomentum = momentum;
|
||||
if (localCoordinates)
|
||||
globalMomentum = fFastTrack->GetInverseAffineTransformation()->
|
||||
TransformAxis(momentum);
|
||||
// ...and feed the globalMomentum (ensuring unitarity)
|
||||
SetMomentumChange(globalMomentum.unit());
|
||||
}
|
||||
|
||||
|
||||
//--------------------
|
||||
//
|
||||
//--------------------
|
||||
void
|
||||
G4FastStep::
|
||||
SetPrimaryTrackFinalKineticEnergyAndDirection(G4double kineticEnergy,
|
||||
const G4ThreeVector &direction,
|
||||
G4bool localCoordinates)
|
||||
{
|
||||
// Compute global direction if needed...
|
||||
G4ThreeVector globalDirection = direction;
|
||||
if (localCoordinates)
|
||||
globalDirection =fFastTrack->GetInverseAffineTransformation()->
|
||||
TransformAxis(direction);
|
||||
// ...and feed the globalMomentum (ensuring unitarity)
|
||||
SetMomentumChange(globalDirection.unit());
|
||||
SetPrimaryTrackFinalKineticEnergy(kineticEnergy);
|
||||
}
|
||||
|
||||
//--------------------
|
||||
//
|
||||
//--------------------
|
||||
void
|
||||
G4FastStep::
|
||||
SetPrimaryTrackFinalPolarization(const G4ThreeVector &polarization,
|
||||
G4bool localCoordinates)
|
||||
{
|
||||
// Compute polarization in global system if needed:
|
||||
G4ThreeVector globalPolarization(polarization);
|
||||
if (localCoordinates)
|
||||
globalPolarization = fFastTrack->GetInverseAffineTransformation()->
|
||||
TransformAxis(globalPolarization);
|
||||
// Feed the particle globalPolarization:
|
||||
thePolarizationChange = globalPolarization;
|
||||
}
|
||||
|
||||
//--------------------
|
||||
//
|
||||
//--------------------
|
||||
G4Track* G4FastStep::
|
||||
CreateSecondaryTrack(const G4DynamicParticle& dynamics,
|
||||
G4ThreeVector polarization,
|
||||
G4ThreeVector position,
|
||||
G4double time,
|
||||
G4bool localCoordinates )
|
||||
{
|
||||
G4DynamicParticle dummyDynamics(dynamics);
|
||||
|
||||
// ------------------------------------------
|
||||
// Add the polarization to the dummyDynamics:
|
||||
// ------------------------------------------
|
||||
dummyDynamics.SetPolarization(polarization.x(),
|
||||
polarization.y(),
|
||||
polarization.z());
|
||||
|
||||
return CreateSecondaryTrack(dummyDynamics, position, time, localCoordinates);
|
||||
}
|
||||
|
||||
//--------------------
|
||||
//
|
||||
//--------------------
|
||||
G4Track* G4FastStep::
|
||||
CreateSecondaryTrack(const G4DynamicParticle& dynamics,
|
||||
G4ThreeVector position,
|
||||
G4double time,
|
||||
G4bool localCoordinates )
|
||||
{
|
||||
// ----------------------------------------
|
||||
// Quantities in global coordinates system.
|
||||
//
|
||||
// The allocated globalDynamics is deleted
|
||||
// by the destructor of the G4Track.
|
||||
// ----------------------------------------
|
||||
G4DynamicParticle* globalDynamics =
|
||||
new G4DynamicParticle(dynamics);
|
||||
G4ThreeVector globalPosition(position);
|
||||
|
||||
// -----------------------------------
|
||||
// Convert to global system if needed:
|
||||
// -----------------------------------
|
||||
if (localCoordinates)
|
||||
{
|
||||
// -- Momentum Direction:
|
||||
globalDynamics->SetMomentumDirection(fFastTrack->
|
||||
GetInverseAffineTransformation()->
|
||||
TransformAxis(globalDynamics->
|
||||
GetMomentumDirection()));
|
||||
// -- Polarization:
|
||||
G4ThreeVector globalPolarization;
|
||||
globalPolarization = fFastTrack->GetInverseAffineTransformation()->
|
||||
TransformAxis(globalDynamics->GetPolarization());
|
||||
globalDynamics->SetPolarization(
|
||||
globalPolarization.x(),
|
||||
globalPolarization.y(),
|
||||
globalPolarization.z()
|
||||
);
|
||||
|
||||
// -- Position:
|
||||
globalPosition = fFastTrack->GetInverseAffineTransformation()->
|
||||
TransformPoint(globalPosition);
|
||||
}
|
||||
|
||||
//-------------------------------------
|
||||
// Create the G4Track of the secondary:
|
||||
//-------------------------------------
|
||||
G4Track* secondary = new G4Track(
|
||||
globalDynamics,
|
||||
time,
|
||||
globalPosition
|
||||
);
|
||||
|
||||
//-------------------------------
|
||||
// and feed the changes:
|
||||
//-------------------------------
|
||||
AddSecondary(secondary);
|
||||
|
||||
//--------------------------------------
|
||||
// returns the pointer on the secondary:
|
||||
//--------------------------------------
|
||||
return secondary;
|
||||
}
|
||||
|
||||
// G4FastStep should never be Initialized in this way
|
||||
// but we must define it to avoid warnings.
|
||||
void G4FastStep::Initialize(const G4Track&) {
|
||||
G4Exception("G4FastStep::Initialize(const G4Track&) should never be called,\nyou must use instead the G4FastStep::Initialize(const G4FastTrack&)\nmethod!");
|
||||
}
|
||||
|
||||
G4FastStep::G4FastStep():G4VParticleChange()
|
||||
{
|
||||
debugFlag = true;
|
||||
if (verboseLevel>2) {
|
||||
G4cerr << "G4FastStep::G4FastStep() " << endl;
|
||||
}
|
||||
}
|
||||
|
||||
G4FastStep::~G4FastStep()
|
||||
{
|
||||
if (verboseLevel>2) {
|
||||
G4cerr << "G4FastStep::~G4FastStep() " << endl;
|
||||
}
|
||||
}
|
||||
|
||||
// copy and assignment operators are implemented as "shallow copy"
|
||||
G4FastStep::G4FastStep(const G4FastStep &right)
|
||||
{
|
||||
*this = right;
|
||||
}
|
||||
|
||||
|
||||
G4FastStep & G4FastStep::operator=(const G4FastStep &right)
|
||||
{
|
||||
if (this != &right)
|
||||
{
|
||||
theListOfSecondaries = right.theListOfSecondaries;
|
||||
theSizeOftheListOfSecondaries = right.theSizeOftheListOfSecondaries;
|
||||
theNumberOfSecondaries = right.theNumberOfSecondaries;
|
||||
theStatusChange = right.theStatusChange;
|
||||
theMomentumChange = right.theMomentumChange;
|
||||
thePolarizationChange = right.thePolarizationChange;
|
||||
thePositionChange = right.thePositionChange;
|
||||
theTimeChange = right.theTimeChange;
|
||||
theEnergyChange = right.theEnergyChange;
|
||||
theTrueStepLength = right.theTrueStepLength;
|
||||
theLocalEnergyDeposit = right.theLocalEnergyDeposit;
|
||||
theSteppingControlFlag = right.theSteppingControlFlag;
|
||||
theWeightChange = right.theWeightChange;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
G4bool G4FastStep::operator==(const G4FastStep &right) const
|
||||
{
|
||||
return ((G4VParticleChange *)this == (G4VParticleChange *) &right);
|
||||
}
|
||||
|
||||
G4bool G4FastStep::operator!=(const G4FastStep &right) const
|
||||
{
|
||||
return ((G4VParticleChange *)this != (G4VParticleChange *) &right);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------
|
||||
// methods for updating G4Step
|
||||
//
|
||||
|
||||
G4Step* G4FastStep::UpdateStepForPostStep(G4Step* pStep)
|
||||
{
|
||||
// A physics process always calculates the final state of the particle
|
||||
|
||||
// Take note that the return type of GetMomentumChange is a
|
||||
// pointer to G4ParticleMometum. Also it is a normalized
|
||||
// momentum vector.
|
||||
|
||||
G4StepPoint* pPreStepPoint = pStep->GetPreStepPoint();
|
||||
G4StepPoint* pPostStepPoint = pStep->GetPostStepPoint();
|
||||
G4Track* aTrack = pStep->GetTrack();
|
||||
G4double mass = aTrack->GetDynamicParticle()->GetMass();
|
||||
|
||||
// update kinetic energy and momentum direction
|
||||
pPostStepPoint->SetMomentumDirection(theMomentumChange);
|
||||
pPostStepPoint->SetKineticEnergy( theEnergyChange );
|
||||
|
||||
// update polarization
|
||||
pPostStepPoint->SetPolarization( thePolarizationChange );
|
||||
|
||||
// update position and time
|
||||
pPostStepPoint->SetPosition( thePositionChange );
|
||||
pPostStepPoint->SetGlobalTime( theTimeChange );
|
||||
pPostStepPoint->AddLocalTime( theTimeChange
|
||||
- aTrack->GetGlobalTime());
|
||||
pPostStepPoint->SetProperTime( theProperTimeChange );
|
||||
|
||||
// update weight
|
||||
pPostStepPoint->SetWeight( theWeightChange );
|
||||
|
||||
|
||||
if (debugFlag) CheckIt(*aTrack);
|
||||
|
||||
// Update the G4Step specific attributes
|
||||
return UpdateStepInfo(pStep);
|
||||
}
|
||||
|
||||
G4Step* G4FastStep::UpdateStepForAtRest(G4Step* pStep)
|
||||
{
|
||||
// A physics process always calculates the final state of the particle
|
||||
|
||||
G4StepPoint* pPreStepPoint = pStep->GetPreStepPoint();
|
||||
G4StepPoint* pPostStepPoint = pStep->GetPostStepPoint();
|
||||
G4Track* aTrack = pStep->GetTrack();
|
||||
G4double mass = mass = aTrack->GetDynamicParticle()->GetMass();
|
||||
|
||||
// update kinetic energy and momentum direction
|
||||
pPostStepPoint->SetMomentumDirection(theMomentumChange);
|
||||
pPostStepPoint->SetKineticEnergy( theEnergyChange );
|
||||
|
||||
// update polarization
|
||||
pPostStepPoint->SetPolarization( thePolarizationChange );
|
||||
|
||||
// update position and time
|
||||
pPostStepPoint->SetPosition( thePositionChange );
|
||||
pPostStepPoint->SetGlobalTime( theTimeChange );
|
||||
pPostStepPoint->AddLocalTime( theTimeChange
|
||||
- aTrack->GetGlobalTime());
|
||||
pPostStepPoint->SetProperTime( theProperTimeChange );
|
||||
|
||||
// update weight
|
||||
pPostStepPoint->SetWeight( theWeightChange );
|
||||
|
||||
|
||||
if (debugFlag) CheckIt(*aTrack);
|
||||
|
||||
// Update the G4Step specific attributes
|
||||
return UpdateStepInfo(pStep);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------
|
||||
// methods for printing messages
|
||||
//
|
||||
|
||||
void G4FastStep::DumpInfo() const
|
||||
{
|
||||
// use base-class DumpInfo
|
||||
G4VParticleChange::DumpInfo();
|
||||
|
||||
G4cout.precision(3);
|
||||
G4cout << " Position - x (mm) : "
|
||||
<< setw(20) << thePositionChange.x()/mm
|
||||
<< endl;
|
||||
G4cout << " Position - y (mm) : "
|
||||
<< setw(20) << thePositionChange.y()/mm
|
||||
<< endl;
|
||||
G4cout << " Position - z (mm) : "
|
||||
<< setw(20) << thePositionChange.z()/mm
|
||||
<< endl;
|
||||
G4cout << " Time (ns) : "
|
||||
<< setw(20) << theTimeChange/ns
|
||||
<< endl;
|
||||
G4cout << " Proper Time (ns) : "
|
||||
<< setw(20) << theProperTimeChange/ns
|
||||
<< endl;
|
||||
G4cout << " Momentum Direct - x : "
|
||||
<< setw(20) << theMomentumChange.x()
|
||||
<< endl;
|
||||
G4cout << " Momentum Direct - y : "
|
||||
<< setw(20) << theMomentumChange.y()
|
||||
<< endl;
|
||||
G4cout << " Momentum Direct - z : "
|
||||
<< setw(20) << theMomentumChange.z()
|
||||
<< endl;
|
||||
G4cout << " Kinetic Energy (MeV): "
|
||||
<< setw(20) << theEnergyChange/MeV
|
||||
<< endl;
|
||||
G4cout << " Polarization - x : "
|
||||
<< setw(20) << thePolarizationChange.x()
|
||||
<< endl;
|
||||
G4cout << " Polarization - y : "
|
||||
<< setw(20) << thePolarizationChange.y()
|
||||
<< endl;
|
||||
G4cout << " Polarization - z : "
|
||||
<< setw(20) << thePolarizationChange.z()
|
||||
<< endl;
|
||||
}
|
||||
|
||||
G4bool G4FastStep::CheckIt(const G4Track& aTrack)
|
||||
{
|
||||
G4bool itsOK = true;
|
||||
if (theEnergyChange > aTrack.GetKineticEnergy()) {
|
||||
G4cout << " !!! the energy becomes larger than the initial energy !!!"
|
||||
<< " : " << (theEnergyChange -aTrack.GetKineticEnergy())/MeV
|
||||
<< "MeV " <<endl;
|
||||
itsOK = false;
|
||||
}
|
||||
if ( (theEnergyChange >0.) &&
|
||||
( abs(theMomentumChange.mag2()-1.0) > 1.0e-5 ) ){
|
||||
G4cout << " !!! the Momentum Change is not unit vector !!!!"
|
||||
<< " : " << theMomentumChange.mag()
|
||||
<< endl;
|
||||
itsOK = false;
|
||||
}
|
||||
if (theTimeChange < aTrack.GetGlobalTime()) {
|
||||
G4cout << " !!! the global time goes back !!!"
|
||||
<< " : " << aTrack.GetGlobalTime()/ns
|
||||
<< " -> " << theTimeChange/ns
|
||||
<< "[ns] " <<endl;
|
||||
itsOK = false;
|
||||
}
|
||||
if (theProperTimeChange < aTrack.GetProperTime()) {
|
||||
G4cout << " !!! the poper time goes back !!!"
|
||||
<< " : " << aTrack.GetProperTime()/ns
|
||||
<< " -> " << theProperTimeChange/ns
|
||||
<< "[ns] " <<endl;
|
||||
itsOK = false;
|
||||
}
|
||||
if (!itsOK) {
|
||||
G4cout << " G4FastStep::CheckIt " <<endl;
|
||||
G4cout << " pointer : " << this <<endl ;
|
||||
DumpInfo();
|
||||
}
|
||||
return itsOK;
|
||||
}
|
||||
@@ -0,0 +1,152 @@
|
||||
// This code implementation is the intellectual property of
|
||||
// the RD44 GEANT4 collaboration.
|
||||
//
|
||||
// By copying, distributing or modifying the Program (or any work
|
||||
// based on the Program) you indicate your acceptance of this statement,
|
||||
// and all its terms.
|
||||
//
|
||||
// $Id: G4FastTrack.cc,v 2.3 1998/10/13 09:54:43 mora Exp $
|
||||
// GEANT4 tag $Name: geant4-00 $
|
||||
//
|
||||
//$Id:
|
||||
//---------------------------------------------------------------
|
||||
//
|
||||
// G4FastTrack.cc
|
||||
//
|
||||
// Description:
|
||||
// Keeps the current track information and special features
|
||||
// for Parameterised Simulation Models.
|
||||
//
|
||||
// History:
|
||||
// Oct 97: Verderi && MoraDeFreitas - First Implementation.
|
||||
//
|
||||
//---------------------------------------------------------------
|
||||
|
||||
#include "G4ios.hh"
|
||||
#include "G4FastTrack.hh"
|
||||
#include "G4TransportationManager.hh"
|
||||
|
||||
// -----------
|
||||
// Constructor
|
||||
// -----------
|
||||
//
|
||||
G4FastTrack::G4FastTrack(G4Envelope *anEnvelope,
|
||||
G4bool IsUnique) :
|
||||
fEnvelope(anEnvelope),fEnvelopeSolid(fEnvelope->GetSolid()),
|
||||
fIsUnique(IsUnique), fAffineTransformationDefined(false)
|
||||
{}
|
||||
|
||||
// -----------
|
||||
// Destructor:
|
||||
// -----------
|
||||
G4FastTrack::~G4FastTrack()
|
||||
{}
|
||||
|
||||
//------------------------------------------------------------
|
||||
// The parameterised simulation manager uses the SetCurrentTrack
|
||||
// method to setup the current G4FastTrack object
|
||||
//------------------------------------------------------------
|
||||
void G4FastTrack::SetCurrentTrack(const G4Track& track,
|
||||
const G4Navigator* theNavigator)
|
||||
{
|
||||
|
||||
// -- Register track pointer (used everywhere):
|
||||
fTrack = &track;
|
||||
|
||||
//-----------------------------------------------------
|
||||
// First time the track enters the volume or if the
|
||||
// Logical Volume was placed n-Times in the geometry :
|
||||
//
|
||||
// Records the Rotation+Translation for the Envelope !
|
||||
// When the particle is inside or on the boundary, the
|
||||
// NavigationHistory IS UP TO DATE.
|
||||
//------------------------------------------------------
|
||||
if (!fAffineTransformationDefined || !fIsUnique)
|
||||
FRecordsAffineTransformation(theNavigator);
|
||||
|
||||
//-------------------------------------------
|
||||
// Records local position/momentum/direction
|
||||
// of the Track.
|
||||
// They are accessible to the user through a
|
||||
// set of Get functions and should be useful
|
||||
// to decide to trigger or not.
|
||||
//-------------------------------------------
|
||||
// -- local position:
|
||||
fLocalTrackPosition = fAffineTransformation.
|
||||
TransformPoint(fTrack->GetPosition());
|
||||
// -- local momentum:
|
||||
fLocalTrackMomentum = fAffineTransformation.
|
||||
TransformAxis(fTrack->GetMomentum());
|
||||
// -- local direction:
|
||||
fLocalTrackDirection = fLocalTrackMomentum.unit();
|
||||
// -- local polarization:
|
||||
fLocalTrackPolarization = fAffineTransformation.
|
||||
TransformAxis(fTrack->GetPolarization());
|
||||
}
|
||||
|
||||
//------------------------------------
|
||||
//
|
||||
// 3D transformation of the envelope
|
||||
// This is Done only one time.
|
||||
//
|
||||
//------------------------------------
|
||||
void
|
||||
G4FastTrack::FRecordsAffineTransformation(const G4Navigator* theNavigator)
|
||||
{
|
||||
|
||||
//--------------------------------------------------------
|
||||
// Get the touchable history which represents the current
|
||||
// volume hierachy the particle is in.
|
||||
// Note that TouchableHistory allocated by the Navigator
|
||||
// must be deleted by G4FastTrack.
|
||||
//--------------------------------------------------------
|
||||
const G4Navigator* NavigatorToUse;
|
||||
if(theNavigator != NULL ) NavigatorToUse=theNavigator;
|
||||
else
|
||||
NavigatorToUse=
|
||||
G4TransportationManager::GetTransportationManager()->
|
||||
GetNavigatorForTracking();
|
||||
|
||||
G4TouchableHistory *history =
|
||||
NavigatorToUse->CreateTouchableHistory();
|
||||
|
||||
//-----------------------------------------------------
|
||||
// Run accross the hierarchy to find the physical volume
|
||||
// associated with the envelope
|
||||
//-----------------------------------------------------
|
||||
int depth = history->GetHistory()->GetDepth();
|
||||
int idepth, Done = 0;
|
||||
for (idepth = 0; idepth <= depth; idepth++) {
|
||||
if (history->GetHistory()->GetVolume(idepth)->GetLogicalVolume() ==
|
||||
fEnvelope) {
|
||||
fEnvelopePhysicalVolume=history->GetHistory()->GetVolume(idepth);
|
||||
Done = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
//---------------------------------------------
|
||||
//-- Verification: should be removed in future:
|
||||
//---------------------------------------------
|
||||
if ( !Done )
|
||||
{
|
||||
G4cout << "\n\nERROR !!! can't find Transform for " <<
|
||||
fEnvelopePhysicalVolume->GetName() << "\n\n" << endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
//-------------------------------------------------------
|
||||
// Records the transformation and inverse transformation:
|
||||
//-------------------------------------------------------
|
||||
fAffineTransformation = history->GetHistory()->GetTransform(idepth);
|
||||
fInverseAffineTransformation = fAffineTransformation.Inverse();
|
||||
|
||||
fAffineTransformationDefined = true;
|
||||
}
|
||||
|
||||
//------------------------------------------------------
|
||||
// Delete the TouchableHistory created by the Navigator:
|
||||
//------------------------------------------------------
|
||||
delete history;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,236 @@
|
||||
// This code implementation is the intellectual property of
|
||||
// the RD44 GEANT4 collaboration.
|
||||
//
|
||||
// By copying, distributing or modifying the Program (or any work
|
||||
// based on the Program) you indicate your acceptance of this statement,
|
||||
// and all its terms.
|
||||
//
|
||||
// $Id: G4GlobalFastSimulationManager.cc,v 2.6 1998/10/13 09:54:44 mora Exp $
|
||||
// GEANT4 tag $Name: geant4-00 $
|
||||
//
|
||||
//
|
||||
//---------------------------------------------------------------
|
||||
//
|
||||
// G4GlobalFastSimulationManager.cc
|
||||
//
|
||||
// Description:
|
||||
// A singleton class which manages the Fast Simulation managers
|
||||
// attached to envelopes. Implementation.
|
||||
//
|
||||
// History:
|
||||
// June 98: Verderi && MoraDeFreitas - "G4ParallelWorld" becomes
|
||||
// "G4FlavoredParallelWorld"; some method name changes;
|
||||
// GetFlavoredWorldForThis now returns a
|
||||
// G4FlavoredParallelWorld pointer.
|
||||
// Feb 98: Verderi && MoraDeFreitas - First Implementation.
|
||||
// March 98: correction to instanciate dynamically the manager
|
||||
//
|
||||
//---------------------------------------------------------------
|
||||
|
||||
#include "G4GlobalFastSimulationManager.hh"
|
||||
#include "G4ParticleTable.hh"
|
||||
#include "G4ParticleDefinition.hh"
|
||||
#include "G4Material.hh"
|
||||
#include "G4ThreeVector.hh"
|
||||
#include "G4PVPlacement.hh"
|
||||
#include "G4TransportationManager.hh"
|
||||
#include "G4FastSimulationMessenger.hh"
|
||||
|
||||
G4GlobalFastSimulationManager*
|
||||
G4GlobalFastSimulationManager::fGlobalFastSimulationManager = 0;
|
||||
|
||||
|
||||
G4GlobalFastSimulationManager*
|
||||
G4GlobalFastSimulationManager::GetGlobalFastSimulationManager()
|
||||
{
|
||||
if(!fGlobalFastSimulationManager)
|
||||
{
|
||||
fGlobalFastSimulationManager = new G4GlobalFastSimulationManager;
|
||||
}
|
||||
return fGlobalFastSimulationManager;
|
||||
}
|
||||
|
||||
|
||||
G4GlobalFastSimulationManager::G4GlobalFastSimulationManager()
|
||||
{
|
||||
// It starts closed.
|
||||
fClosed=true;
|
||||
// Initialises the G4FastSimulationMessenger
|
||||
fTheFastSimulationMessenger=new G4FastSimulationMessenger(this);
|
||||
}
|
||||
|
||||
G4GlobalFastSimulationManager::~G4GlobalFastSimulationManager()
|
||||
{
|
||||
delete fTheFastSimulationMessenger;
|
||||
}
|
||||
|
||||
void G4GlobalFastSimulationManager::FastSimulationNeedsToBeClosed()
|
||||
{
|
||||
fClosed=false;
|
||||
}
|
||||
|
||||
void G4GlobalFastSimulationManager::
|
||||
AddFastSimulationManager(G4FastSimulationManager* fsmanager)
|
||||
{
|
||||
ManagedManagers.insert(fsmanager);
|
||||
}
|
||||
|
||||
void G4GlobalFastSimulationManager::
|
||||
RemoveFastSimulationManager(G4FastSimulationManager* fsmanager)
|
||||
{
|
||||
ManagedManagers.remove(fsmanager);
|
||||
}
|
||||
|
||||
|
||||
void G4GlobalFastSimulationManager::CloseFastSimulation()
|
||||
{
|
||||
if(fClosed) return;
|
||||
|
||||
G4ParticleTable* theParticleTable;
|
||||
|
||||
// Reset the NeededFlavoredWorlds List
|
||||
NeededFlavoredWorlds.clearAndDestroy();
|
||||
|
||||
// We'll look for models for all particle types
|
||||
theParticleTable=G4ParticleTable::GetParticleTable();
|
||||
|
||||
// Creates the first world volume clone.
|
||||
G4VPhysicalVolume* aClone=GiveMeAWorldVolumeClone();
|
||||
|
||||
G4cout << "Closing FastSimulation\n";
|
||||
for (G4int iParticle=0; iParticle<theParticleTable->entries(); iParticle++) {
|
||||
G4bool Needed = false;
|
||||
for (G4int ifsm=0; ifsm<ManagedManagers.length(); ifsm++)
|
||||
Needed = Needed || ManagedManagers(ifsm)->
|
||||
InsertGhostHereIfNecessary(aClone,
|
||||
*(theParticleTable->
|
||||
GetParticle(iParticle)));
|
||||
// if some FSM inserted a ghost, keep this clone.
|
||||
if(Needed) {
|
||||
NeededFlavoredWorlds.insert(new
|
||||
G4FlavoredParallelWorld(theParticleTable->
|
||||
GetParticle(iParticle),
|
||||
aClone));
|
||||
// and prepare a new one.
|
||||
aClone=GiveMeAWorldVolumeClone();
|
||||
}
|
||||
}
|
||||
fClosed=true;
|
||||
}
|
||||
|
||||
G4FlavoredParallelWorld*
|
||||
G4GlobalFastSimulationManager::
|
||||
GetFlavoredWorldForThis(G4ParticleDefinition* particle)
|
||||
{
|
||||
for (G4int ipw=0; ipw<NeededFlavoredWorlds.length(); ipw++)
|
||||
if(NeededFlavoredWorlds(ipw)->GetTheParticleType()==particle)
|
||||
return NeededFlavoredWorlds(ipw);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void
|
||||
G4GlobalFastSimulationManager::ActivateFastSimulationModel(const G4String& aName)
|
||||
{
|
||||
G4bool result = false;
|
||||
for (G4int ifsm=0; ifsm<ManagedManagers.length(); ifsm++)
|
||||
result = result || ManagedManagers(ifsm)->ActivateFastSimulationModel(aName);
|
||||
if(result)
|
||||
G4cout << "Model " << aName << " activated.";
|
||||
else
|
||||
G4cout << "Model " << aName << " not found.";
|
||||
G4cout << endl;
|
||||
}
|
||||
|
||||
void
|
||||
G4GlobalFastSimulationManager::InActivateFastSimulationModel(const G4String& aName)
|
||||
{
|
||||
G4bool result = false;
|
||||
for (G4int ifsm=0; ifsm<ManagedManagers.length(); ifsm++)
|
||||
result = result || ManagedManagers(ifsm)->InActivateFastSimulationModel(aName);
|
||||
if(result)
|
||||
G4cout << "Model " << aName << " inactivated.";
|
||||
else
|
||||
G4cout << "Model " << aName << " not found.";
|
||||
G4cout << endl;
|
||||
}
|
||||
|
||||
void
|
||||
G4GlobalFastSimulationManager::ListEnvelopes(const G4String& aName,
|
||||
listType theType)
|
||||
{
|
||||
if(theType == ISAPPLICABLE) {
|
||||
for (G4int ifsm=0; ifsm<ManagedManagers.length(); ifsm++)
|
||||
ManagedManagers(ifsm)->ListModels(aName);
|
||||
return;
|
||||
}
|
||||
|
||||
if(aName == "all") {
|
||||
G4int titled = 0;
|
||||
for (G4int ifsm=0; ifsm<ManagedManagers.length(); ifsm++) {
|
||||
if(theType == NAMES_ONLY) {
|
||||
if(!(titled++))
|
||||
G4cout << "Current Envelopes for Fast Simulation:\n";
|
||||
G4cout << " ";
|
||||
ManagedManagers(ifsm)->ListTitle();
|
||||
G4cout << endl;
|
||||
}
|
||||
else ManagedManagers(ifsm)->ListModels();
|
||||
}
|
||||
}
|
||||
else {
|
||||
for (G4int ifsm=0; ifsm<ManagedManagers.length(); ifsm++)
|
||||
if(aName == ManagedManagers(ifsm)->
|
||||
GetEnvelope()->GetName()){
|
||||
ManagedManagers(ifsm)->ListModels();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
G4GlobalFastSimulationManager::ListEnvelopes(const G4ParticleDefinition* aPD)
|
||||
{
|
||||
for (G4int ifsm=0; ifsm<ManagedManagers.length(); ifsm++)
|
||||
ManagedManagers(ifsm)->ListModels(aPD);
|
||||
}
|
||||
|
||||
G4VPhysicalVolume*
|
||||
G4GlobalFastSimulationManager::GiveMeAWorldVolumeClone()
|
||||
{
|
||||
G4VPhysicalVolume* theParallelWorldPhysical;
|
||||
|
||||
G4TransportationManager *transportationManager=
|
||||
G4TransportationManager::GetTransportationManager();
|
||||
|
||||
G4VSolid *parallelWorldSolid=transportationManager->
|
||||
GetNavigatorForTracking()->GetWorldVolume()->
|
||||
GetLogicalVolume()->GetSolid();
|
||||
|
||||
G4Material *parallelWorldMaterial=transportationManager->
|
||||
GetNavigatorForTracking()->GetWorldVolume()->
|
||||
GetLogicalVolume()->GetMaterial();
|
||||
|
||||
G4LogicalVolume *parallelWorldLog =
|
||||
new G4LogicalVolume(parallelWorldSolid,
|
||||
parallelWorldMaterial,
|
||||
"ParallelWorldLogical",
|
||||
0, 0, 0);
|
||||
|
||||
theParallelWorldPhysical= new G4PVPlacement(0,G4ThreeVector(),
|
||||
"ParallelWorldPhysical",
|
||||
parallelWorldLog,
|
||||
0,false,0);
|
||||
|
||||
return theParallelWorldPhysical;
|
||||
}
|
||||
|
||||
G4bool
|
||||
G4GlobalFastSimulationManager::Notify(G4ApplicationState requestedState)
|
||||
{
|
||||
G4StateManager * stateManager = G4StateManager::GetStateManager();
|
||||
if((stateManager->GetPreviousState()==Idle) &&
|
||||
(requestedState==GeomClosed) &&
|
||||
(!fClosed))
|
||||
G4Exception("G4GlobalFastSimulationManager fatal error : \n1) you are using ghost volumes;\n2) In this case the G4GlobalFastSimulationManager MUST be closed BEFORE\n closing the geometry;\n3) To do this put in your code the call \n G4GlobalFastSimulationManager::GetGlobalFastSimulationManager()->\n CloseFastSimulation();\n just before closing the geometry.");
|
||||
return true;
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
// This code implementation is the intellectual property of
|
||||
// the RD44 GEANT4 collaboration.
|
||||
//
|
||||
// By copying, distributing or modifying the Program (or any work
|
||||
// based on the Program) you indicate your acceptance of this statement,
|
||||
// and all its terms.
|
||||
//
|
||||
// $Id: G4VFastSimulationModel.cc,v 2.1 1998/10/13 09:54:45 mora Exp $
|
||||
// GEANT4 tag $Name: geant4-00 $
|
||||
//
|
||||
// $Id:
|
||||
//---------------------------------------------------------------
|
||||
//
|
||||
// G4VFastSimulationModel.cc
|
||||
//
|
||||
// Description:
|
||||
// Base class for fast simulation models.
|
||||
//
|
||||
// History:
|
||||
// Oct 97: Verderi && MoraDeFreitas - First Implementation.
|
||||
//
|
||||
//---------------------------------------------------------------
|
||||
|
||||
|
||||
#include "G4VFastSimulationModel.hh"
|
||||
#include "G4FastSimulationManager.hh"
|
||||
|
||||
//
|
||||
// Simple constructor.
|
||||
//
|
||||
G4VFastSimulationModel::
|
||||
G4VFastSimulationModel(const G4String& aName) : theModelName(aName) {}
|
||||
|
||||
//
|
||||
// Constructor for beginners. We do all the job, no matters...
|
||||
//
|
||||
G4VFastSimulationModel::
|
||||
G4VFastSimulationModel(const G4String& aName,
|
||||
G4Envelope* anEnvelope,
|
||||
G4bool IsUnique) : theModelName(aName)
|
||||
{
|
||||
// Retrieves the Fast Simulation Manager ou creates one
|
||||
// if needed.
|
||||
G4FastSimulationManager* theFastSimulationManager;
|
||||
if ((theFastSimulationManager=anEnvelope->GetFastSimulationManager())
|
||||
==NULL) theFastSimulationManager=
|
||||
new G4FastSimulationManager(anEnvelope,IsUnique);
|
||||
// adds this model to the Fast Simulation Manager.
|
||||
theFastSimulationManager->AddFastSimulationModel(this);
|
||||
}
|
||||
Reference in New Issue
Block a user