Geant4  10.03.p03
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Par01PiModel.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 //
28 //
29 //
30 // $Id: Par01PiModel.cc 101151 2016-11-08 08:06:16Z gcosmo $
31 //
32 #include "Par01PiModel.hh"
33 
34 #include "G4PionMinus.hh"
35 #include "G4PionPlus.hh"
36 #include "G4Gamma.hh"
37 
38 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
39 
41  G4VFastSimulationModel("Par01PiModel",anEnvelope)
42 {;}
43 
44 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
45 
47 {;}
48 
49 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
50 
52 {
53  return
54  &particleType == G4PionMinus::PionMinusDefinition() ||
55  &particleType == G4PionPlus::PionPlusDefinition();
56 }
57 
58 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
59 
61  //-------------------------------------------------------------
62  // UserTrigger() method: method which has to decide if
63  // the parameterisation has to be applied.
64  // Here ModelTrigger() asks the user (ie you) a 0/1 answer.
65  //
66  // Note that quantities like the local/global position/direction etc..
67  // are available at this level via the fastTrack parameter (allowing
68  // to check distance from boundaries, see below to allow the decision)
69  //--------------------------------------------------------------
70  G4cout << "\nPar01PiModel::ModelTrigger() called:" << G4endl;
71  G4cout << "--------------------------------" << G4endl;
72  G4cout << "(particle is a " << fastTrack.GetPrimaryTrack()->
73  GetDefinition()->GetParticleName() << " )\n" << G4endl;
74 
75  // -- Examples of available informations:
76 
77  // -- position:
78  G4cout << " Track position: " <<
79  fastTrack.GetPrimaryTrack()->GetPosition() << "(global coord.)" <<
80  fastTrack.GetPrimaryTrackLocalPosition() << "(in envelope coord.)"
81  << G4endl;
82 
83  // -- direction:
84  G4cout << " Track direction:" <<
85  fastTrack.GetPrimaryTrack()->GetMomentum().unit() <<
86  "(global coord.)" <<
87  fastTrack.GetPrimaryTrackLocalDirection() << "(in envelope coord.)" <<
88  G4endl;
89 
90  return true;
91 }
92 
93 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
94 
95 void Par01PiModel::DoIt(const G4FastTrack& fastTrack,
96  G4FastStep& fastStep)
97  //--------------------------------------------------------
98  //
99  // User method to code the parameterisation properly said.
100  //
101  //--------------------------------------------------------
102 {
103 
104  //------------------------------------------------
105  // The primary track continues along its direction.
106  // One secondary (a photon) is added:
107  //------------------------------------------------
108  G4cout << " Pion `model' applied\n" << G4endl;
109 
110  //------------------------------
111  // Primary:
112  // idem as in "DefaultModel":
113  //
114  //------------------------------
116  G4double distance;
117  distance = fastTrack.GetEnvelopeSolid()->
118  DistanceToOut(fastTrack.GetPrimaryTrackLocalPosition(),
119  fastTrack.GetPrimaryTrackLocalDirection());
120  position = fastTrack.GetPrimaryTrackLocalPosition() +
121  distance*fastTrack.GetPrimaryTrackLocalDirection();
122 
123  // -- set final position:
124  fastStep.ProposePrimaryTrackFinalPosition(position);
125 
126  //---------------------------
127  // Secondary:
128  // Adds one "secondary":
129  //---------------------------
130  // -- First, user has to say how many secondaries will be created:
131  fastStep.SetNumberOfSecondaryTracks(1);
132 
133  //------------------------
134  // -- Build the secondary:
135  //------------------------
136  // -- direction:
137  G4ParticleMomentum direction(fastTrack.GetPrimaryTrackLocalDirection());
138  direction.setZ(direction.z()*0.5);
139  direction.setY(direction.y()+direction.z()*0.1);
140  direction = direction.unit(); // necessary ?
141 
142  // -- dynamics (Note that many constructors exists for G4DynamicParticle
143  // -- see prototype/particle+matter/particles/management/include/G4DynamicParticle.hh)
145  direction,
146  fastTrack.GetPrimaryTrack()->
147  GetKineticEnergy()/2.);
148  // -- position:
149  G4double Dist;
150  Dist = fastTrack.GetEnvelopeSolid()->
151  DistanceToOut(fastTrack.GetPrimaryTrackLocalPosition(),
152  direction);
153  G4ThreeVector posi;
154  posi = fastTrack.GetPrimaryTrackLocalPosition() + Dist*direction;
155 
156  //------------------------------------
157  //-- Creation of the secondary Track:
158  //------------------------------------
159  fastStep.CreateSecondaryTrack(dynamique, posi,
160  fastTrack.GetPrimaryTrack()->GetGlobalTime());
161 }
G4ThreeVector GetPrimaryTrackLocalPosition() const
Definition: G4FastTrack.hh:213
const G4Track * GetPrimaryTrack() const
Definition: G4FastTrack.hh:208
G4ThreeVector GetPrimaryTrackLocalDirection() const
Definition: G4FastTrack.hh:223
virtual G4bool IsApplicable(const G4ParticleDefinition &)
Definition: Par01PiModel.cc:51
const G4ThreeVector & GetPosition() const
void SetNumberOfSecondaryTracks(G4int)
virtual G4bool ModelTrigger(const G4FastTrack &)
Definition: Par01PiModel.cc:60
Definition of the Par01PiModel class.
G4Track * CreateSecondaryTrack(const G4DynamicParticle &, G4ThreeVector, G4ThreeVector, G4double, G4bool localCoordinates=true)
Definition: G4FastStep.cc:203
void setZ(double)
virtual void DoIt(const G4FastTrack &, G4FastStep &)
Definition: Par01PiModel.cc:95
void ProposePrimaryTrackFinalPosition(const G4ThreeVector &, G4bool localCoordinates=true)
Definition: G4FastStep.cc:99
#define position
Definition: xmlparse.cc:622
G4GLOB_DLL std::ostream G4cout
static G4PionMinus * PionMinusDefinition()
Definition: G4PionMinus.cc:93
bool G4bool
Definition: G4Types.hh:79
static G4PionPlus * PionPlusDefinition()
Definition: G4PionPlus.cc:93
G4double GetGlobalTime() const
G4VSolid * GetEnvelopeSolid() const
Definition: G4FastTrack.hh:203
G4ThreeVector GetMomentum() const
Hep3Vector unit() const
Par01PiModel(G4Region *anEnvelope)
Definition: Par01PiModel.cc:40
#define G4endl
Definition: G4ios.hh:61
double G4double
Definition: G4Types.hh:76
static G4Gamma * GammaDefinition()
Definition: G4Gamma.cc:81