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