Geant4 10.7.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
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//
27// ------------------------------------------------------------
28// GEANT 4 class implementation file
29// ------------------------------------------------------------
30//
31
33
34#include "G4ParticleTable.hh"
36#include "G4VProcess.hh"
37#include "G4ProcessVector.hh"
38#include "G4ProcessManager.hh"
39
40#ifdef G4VERBOSE
41#include "G4ErrorPropagatorData.hh" //for verbosity checking
42#endif
43
44//----------------------------------------------------------------------------
46G4ErrorTrackLengthTarget(const G4double maxTrkLength )
47 : G4VDiscreteProcess ("G4ErrorTrackLengthTarget"),
48 theMaximumTrackLength( maxTrkLength )
49{
51
54
55 // loop over all particles in G4ParticleTable
56
57 theParticleIterator->reset();
58 while( (*theParticleIterator)() ) // Loop checking, 06.08.2015, G.Cosmo
59 {
60 G4ParticleDefinition* particle = theParticleIterator->value();
61 G4ProcessManager* pmanager = particle->GetProcessManager();
62 if (!particle->IsShortLived())
63 {
64 // Add transportation process for all particles other than "shortlived"
65 if ( pmanager == 0)
66 {
67 // Error !! no process manager
68 G4String particleName = particle->GetParticleName();
69 G4Exception("G4ErrorTrackLengthTarget::G4ErrorTrackLengthTarget",
70 "No process manager", RunMustBeAborted, particleName );
71 }
72 else
73 {
74 G4ProcessVector* procvec = pmanager->GetProcessList();
75 size_t isiz = procvec->size();
76
77 for( size_t ii=0; ii < isiz; ii++ )
78 {
79 if( ((*procvec)[ii])->GetProcessName() == "G4ErrorTrackLengthTarget")
80 {
81 pmanager->RemoveProcess( (*procvec)[ii] );
82 }
83 }
84 pmanager ->AddDiscreteProcess(this,4);
85 isiz = procvec->size();
86 }
87 }
88 else
89 {
90 // shortlived particle case
91 }
92 }
93}
94
95
96//-----------------------------------------------------------------------
100{
102 return GetMeanFreePath( track, 0., condition );
103}
104
105
106//-----------------------------------------------------------------------
108GetMeanFreePath(const class G4Track & track, G4double, enum G4ForceCondition *)
109{
110#ifdef G4VERBOSE
112 {
113 G4cout << " G4ErrorTrackLengthTarget::GetMeanFreePath "
114 << theMaximumTrackLength - track.GetTrackLength() << G4endl;
115 }
116#endif
117
118 return theMaximumTrackLength - track.GetTrackLength();
119}
120
121
123PostStepDoIt(const G4Track& aTrack, const G4Step& )
124{
125 theParticleChange.Initialize(aTrack);
126 return &theParticleChange;
127}
128
129
130//-----------------------------------------------------------------------
132{
133 G4cout << msg << "G4ErrorTrackLengthTarget: max track length = "
134 << theMaximumTrackLength << G4endl;
135}
G4double condition(const G4ErrorSymMatrix &m)
@ G4ErrorTarget_TrkL
@ RunMustBeAborted
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
Definition: G4Exception.cc:35
G4ForceCondition
@ NotForced
double G4double
Definition: G4Types.hh:83
#define theParticleIterator
#define G4endl
Definition: G4ios.hh:57
G4GLOB_DLL 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() const
static G4ParticleTable * GetParticleTable()
G4int AddDiscreteProcess(G4VProcess *aProcess, G4int ord=ordDefault)
G4ProcessVector * GetProcessList() const
G4VProcess * RemoveProcess(G4VProcess *aProcess)
std::size_t size() const
Definition: G4Step.hh:62
G4double GetTrackLength() const
virtual void Initialize(const G4Track &)
const G4String & GetProcessName() const
Definition: G4VProcess.hh:382