Geant4 Cross Reference |
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 /// \file Par01/src/Par01PiModel.cc 27 /// \brief Implementation of the Par01PiModel class 28 // 29 // 30 // 31 #include "Par01PiModel.hh" 32 33 #include "G4Gamma.hh" 34 #include "G4PionMinus.hh" 35 #include "G4PionPlus.hh" 36 37 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 38 39 Par01PiModel::Par01PiModel(G4Region* anEnvelope) 40 : G4VFastSimulationModel("Par01PiModel", anEnvelope) 41 { 42 ; 43 } 44 45 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 46 47 Par01PiModel::~Par01PiModel() 48 { 49 ; 50 } 51 52 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 53 54 G4bool Par01PiModel::IsApplicable(const G4ParticleDefinition& particleType) 55 { 56 return &particleType == G4PionMinus::PionMinusDefinition() 57 || &particleType == G4PionPlus::PionPlusDefinition(); 58 } 59 60 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 61 62 G4bool Par01PiModel::ModelTrigger(const G4FastTrack& fastTrack) 63 { 64 //------------------------------------------------------------- 65 // UserTrigger() method: method which has to decide if 66 // the parameterisation has to be applied. 67 // Here ModelTrigger() asks the user (ie you) a 0/1 answer. 68 // 69 // Note that quantities like the local/global position/direction etc.. 70 // are available at this level via the fastTrack parameter (allowing 71 // to check distance from boundaries, see below to allow the decision) 72 //-------------------------------------------------------------- 73 G4cout << "\nPar01PiModel::ModelTrigger() called:" << G4endl; 74 G4cout << "--------------------------------" << G4endl; 75 G4cout << "(particle is a " << fastTrack.GetPrimaryTrack()->GetDefinition()->GetParticleName() 76 << " )\n" 77 << G4endl; 78 79 // -- Examples of available informations: 80 81 // -- position: 82 G4cout << " Track position: " << fastTrack.GetPrimaryTrack()->GetPosition() 83 << "(global coord.)" << fastTrack.GetPrimaryTrackLocalPosition() << "(in envelope coord.)" 84 << G4endl; 85 86 // -- direction: 87 G4cout << " Track direction:" << fastTrack.GetPrimaryTrack()->GetMomentum().unit() 88 << "(global coord.)" << fastTrack.GetPrimaryTrackLocalDirection() << "(in envelope coord.)" 89 << G4endl; 90 91 return true; 92 } 93 94 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 95 96 void Par01PiModel::DoIt(const G4FastTrack& fastTrack, G4FastStep& fastStep) 97 //-------------------------------------------------------- 98 // 99 // User method to code the parameterisation properly said. 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 //------------------------------ 114 G4ThreeVector position; 115 G4double distance; 116 distance = fastTrack.GetEnvelopeSolid()->DistanceToOut(fastTrack.GetPrimaryTrackLocalPosition(), 117 fastTrack.GetPrimaryTrackLocalDirection()); 118 position = 119 fastTrack.GetPrimaryTrackLocalPosition() + distance * fastTrack.GetPrimaryTrackLocalDirection(); 120 121 // -- set final position: 122 fastStep.ProposePrimaryTrackFinalPosition(position); 123 124 //--------------------------- 125 // Secondary: 126 // Adds one "secondary": 127 //--------------------------- 128 // -- First, user has to say how many secondaries will be created: 129 fastStep.SetNumberOfSecondaryTracks(1); 130 131 //------------------------ 132 // -- Build the secondary: 133 //------------------------ 134 // -- direction: 135 G4ParticleMomentum direction(fastTrack.GetPrimaryTrackLocalDirection()); 136 direction.setZ(direction.z() * 0.5); 137 direction.setY(direction.y() + direction.z() * 0.1); 138 direction = direction.unit(); // necessary ? 139 140 // -- dynamics (Note that many constructors exists for G4DynamicParticle 141 // -- see prototype/particle+matter/particles/management/include/G4DynamicParticle.hh) 142 G4DynamicParticle dynamique(G4Gamma::GammaDefinition(), direction, 143 fastTrack.GetPrimaryTrack()->GetKineticEnergy() / 2.); 144 // -- position: 145 G4double Dist; 146 Dist = fastTrack.GetEnvelopeSolid()->DistanceToOut(fastTrack.GetPrimaryTrackLocalPosition(), 147 direction); 148 G4ThreeVector posi; 149 posi = fastTrack.GetPrimaryTrackLocalPosition() + Dist * direction; 150 151 //------------------------------------ 152 //-- Creation of the secondary Track: 153 //------------------------------------ 154 fastStep.CreateSecondaryTrack(dynamique, posi, fastTrack.GetPrimaryTrack()->GetGlobalTime()); 155 } 156