Geant4 9.6.0
Toolkit for the simulation of the passage of particles through matter
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
G4ErrorTrackLengthTarget.cc
Go to the documentation of this file.
1//
2// ********************************************************************
3// * License and Disclaimer *
4// * *
5// * The Geant4 software is copyright of the Copyright Holders of *
6// * the Geant4 Collaboration. It is provided under the terms and *
7// * conditions of the Geant4 Software License, included in the file *
8// * LICENSE and available at http://cern.ch/geant4/license . These *
9// * include a list of copyright holders. *
10// * *
11// * Neither the authors of this software system, nor their employing *
12// * institutes,nor the agencies providing financial support for this *
13// * work make any representation or warranty, express or implied, *
14// * regarding this software system or assume any liability for its *
15// * use. Please see the license in the file LICENSE and URL above *
16// * for the full disclaimer and the limitation of liability. *
17// * *
18// * This code implementation is the result of the scientific and *
19// * technical work of the GEANT4 collaboration. *
20// * By using, copying, modifying or distributing the software (or *
21// * any work based on the software) you agree to acknowledge its *
22// * use in resulting scientific publications, and indicate your *
23// * acceptance of all terms of the Geant4 Software license. *
24// ********************************************************************
25//
26// $Id$
27//
28// ------------------------------------------------------------
29// GEANT 4 class implementation file
30// ------------------------------------------------------------
31//
32
34
35#include "G4ParticleTable.hh"
37#include "G4VProcess.hh"
38#include "G4ProcessVector.hh"
39#include "G4ProcessManager.hh"
40
41#ifdef G4VERBOSE
42#include "G4ErrorPropagatorData.hh" //for verbosity checking
43#endif
44
45//----------------------------------------------------------------------------
47G4ErrorTrackLengthTarget(const G4double maxTrkLength )
48 : G4VDiscreteProcess ("G4ErrorTrackLengthTarget"),
49 theMaximumTrackLength( maxTrkLength )
50{
52
53 G4ParticleTable::G4PTblDicIterator* theParticleIterator
55
56 // loop over all particles in G4ParticleTable
57
58 theParticleIterator->reset();
59 while( (*theParticleIterator)() )
60 {
61 G4ParticleDefinition* particle = theParticleIterator->value();
62 G4ProcessManager* pmanager = particle->GetProcessManager();
63 if (!particle->IsShortLived())
64 {
65 // Add transportation process for all particles other than "shortlived"
66 if ( pmanager == 0)
67 {
68 // Error !! no process manager
69 G4String particleName = particle->GetParticleName();
70 G4Exception("G4ErrorTrackLengthTarget::G4ErrorTrackLengthTarget",
71 "No process manager", RunMustBeAborted, particleName );
72 }
73 else
74 {
75 G4ProcessVector* procvec = pmanager->GetProcessList();
76 size_t isiz = procvec->size();
77
78 for( size_t ii=0; ii < isiz; ii++ )
79 {
80 if( ((*procvec)[ii])->GetProcessName() == "G4ErrorTrackLengthTarget")
81 {
82 pmanager->RemoveProcess( (*procvec)[ii] );
83 }
84 }
85 pmanager ->AddDiscreteProcess(this,4);
86 isiz = procvec->size();
87 }
88 }
89 else
90 {
91 // shortlived particle case
92 }
93 }
94}
95
96
97//-----------------------------------------------------------------------
101{
103 return GetMeanFreePath( track, 0., condition );
104}
105
106
107//-----------------------------------------------------------------------
109GetMeanFreePath(const class G4Track & track, G4double, enum G4ForceCondition *)
110{
111#ifdef G4VERBOSE
113 {
114 G4cout << " G4ErrorTrackLengthTarget::GetMeanFreePath "
115 << theMaximumTrackLength - track.GetTrackLength() << G4endl;
116 }
117#endif
118
119 return theMaximumTrackLength - track.GetTrackLength();
120}
121
122
124PostStepDoIt(const G4Track& aTrack, const G4Step& )
125{
126 theParticleChange.Initialize(aTrack);
127 return &theParticleChange;
128}
129
130
131//-----------------------------------------------------------------------
133{
134 G4cout << msg << "G4ErrorTrackLengthTarget: max track length = "
135 << theMaximumTrackLength << G4endl;
136}
G4double condition(const G4ErrorSymMatrix &m)
@ G4ErrorTarget_TrkL
@ RunMustBeAborted
G4ForceCondition
@ NotForced
double G4double
Definition: G4Types.hh:64
#define G4endl
Definition: G4ios.hh:52
G4DLLIMPORT std::ostream G4cout
G4ErrorTargetType theType
virtual G4double GetMeanFreePath(const class G4Track &track, G4double, G4ForceCondition *)
G4ErrorTrackLengthTarget(const G4double maxTrkLength)
virtual G4VParticleChange * PostStepDoIt(const G4Track &, const G4Step &)
virtual G4double PostStepGetPhysicalInteractionLength(const G4Track &track, G4double previousStepSize, G4ForceCondition *condition)
virtual void Dump(const G4String &msg) const
G4ProcessManager * GetProcessManager() const
const G4String & GetParticleName() const
G4PTblDicIterator * GetIterator()
static G4ParticleTable * GetParticleTable()
G4int AddDiscreteProcess(G4VProcess *aProcess, G4int ord=ordDefault)
G4ProcessVector * GetProcessList() const
G4VProcess * RemoveProcess(G4VProcess *aProcess)
G4int size() const
Definition: G4Step.hh:78
G4double GetTrackLength() const
virtual void Initialize(const G4Track &)
const G4String & GetProcessName() const
Definition: G4VProcess.hh:379
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41