[807] | 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 | // * cosmicray_charging advanced example for Geant4 * |
---|
| 29 | // * (adapted simulation of test-mass charging in the LISA mission) * |
---|
| 30 | // * * |
---|
| 31 | // * Henrique Araujo (h.araujo@imperial.ac.uk) & Peter Wass * |
---|
| 32 | // * Imperial College London * |
---|
| 33 | // * * |
---|
| 34 | // * LISASteppingAction class * |
---|
| 35 | // * * |
---|
| 36 | // ******************************************************************** |
---|
| 37 | // |
---|
| 38 | // HISTORY |
---|
| 39 | // 22/02/2004: migrated from LISA-V04 |
---|
| 40 | // |
---|
| 41 | // ******************************************************************** |
---|
| 42 | |
---|
| 43 | |
---|
| 44 | #include "LISASteppingAction.hh" |
---|
| 45 | |
---|
| 46 | #include "LISASteppingActionMessenger.hh" |
---|
| 47 | |
---|
| 48 | #include "G4Step.hh" |
---|
| 49 | #include "G4Track.hh" |
---|
| 50 | #include "G4TrackStatus.hh" |
---|
| 51 | #include "G4StepPoint.hh" |
---|
| 52 | #include "G4ParticleDefinition.hh" |
---|
| 53 | #include "G4DynamicParticle.hh" |
---|
| 54 | #include "G4ParticleTypes.hh" |
---|
| 55 | #include "G4VPhysicalVolume.hh" |
---|
| 56 | #include "G4VTouchable.hh" |
---|
| 57 | #include "G4TouchableHistory.hh" |
---|
| 58 | |
---|
| 59 | #include "globals.hh" |
---|
| 60 | #include "G4ios.hh" |
---|
| 61 | #include <fstream> |
---|
| 62 | |
---|
| 63 | |
---|
| 64 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... |
---|
| 65 | LISASteppingAction::LISASteppingAction() { |
---|
| 66 | |
---|
| 67 | charge_in[0] = 0; |
---|
| 68 | charge_in[1] = 0; |
---|
| 69 | charge_out[0] = 0; |
---|
| 70 | charge_out[1] = 0; |
---|
| 71 | |
---|
| 72 | // defaults |
---|
| 73 | FlagSpectrum = false; |
---|
| 74 | |
---|
| 75 | // create messenger |
---|
| 76 | steppingMessenger = new LISASteppingActionMessenger(this); |
---|
| 77 | |
---|
| 78 | } |
---|
| 79 | |
---|
| 80 | |
---|
| 81 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... |
---|
| 82 | LISASteppingAction::~LISASteppingAction() { |
---|
| 83 | |
---|
| 84 | delete steppingMessenger; |
---|
| 85 | |
---|
| 86 | } |
---|
| 87 | |
---|
| 88 | |
---|
| 89 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... |
---|
| 90 | void LISASteppingAction::UserSteppingAction(const G4Step* fStep) { |
---|
| 91 | |
---|
| 92 | if(fStep->GetTrack()->GetNextVolume()) { |
---|
| 93 | |
---|
| 94 | // step points |
---|
| 95 | G4TouchableHistory* thePreTouchable = |
---|
| 96 | (G4TouchableHistory*)(fStep->GetPreStepPoint()->GetTouchable()); |
---|
| 97 | G4TouchableHistory* thePostTouchable = |
---|
| 98 | (G4TouchableHistory*)(fStep->GetPostStepPoint()->GetTouchable()); |
---|
| 99 | G4String PreVol = thePreTouchable->GetVolume()->GetName(); |
---|
| 100 | G4String PosVol = thePostTouchable->GetVolume()->GetName(); |
---|
| 101 | |
---|
| 102 | // particle |
---|
| 103 | G4double charge = fStep->GetTrack()->GetDefinition()->GetPDGCharge(); |
---|
| 104 | G4String pName = fStep->GetTrack()->GetDefinition()->GetParticleName(); |
---|
| 105 | G4double energy = fStep->GetTrack()->GetKineticEnergy(); |
---|
| 106 | |
---|
| 107 | G4int tm = -1; |
---|
| 108 | |
---|
| 109 | |
---|
| 110 | // *** entering a test mass *** |
---|
| 111 | if(PreVol!="tmass_phys" && PosVol=="tmass_phys") { |
---|
| 112 | |
---|
| 113 | tm = thePostTouchable->GetReplicaNumber(6); |
---|
| 114 | |
---|
| 115 | charge_in[tm] += (int)charge; |
---|
| 116 | |
---|
| 117 | // energy spectra at test-mass boundary |
---|
| 118 | if(FlagSpectrum) { |
---|
| 119 | // electrons entering test mass |
---|
| 120 | if(pName=="e-") { |
---|
| 121 | std::ofstream electrons_in("electrons_in.out",std::ios::app); |
---|
| 122 | electrons_in << energy/eV << G4endl; |
---|
| 123 | } |
---|
| 124 | // hadrons entering test mass |
---|
| 125 | else if(pName=="proton" || |
---|
| 126 | pName=="pi+" || pName=="pi-" || |
---|
| 127 | pName=="deuteron" || pName=="He3" || |
---|
| 128 | pName=="alpha" || pName=="triton") { |
---|
| 129 | std::ofstream hadrons_in("hadrons_in.out",std::ios::app); |
---|
| 130 | hadrons_in << energy/eV << G4endl; |
---|
| 131 | } |
---|
| 132 | } |
---|
| 133 | |
---|
| 134 | } // *** entering a test mass *** |
---|
| 135 | |
---|
| 136 | |
---|
| 137 | // *** leaving a test mass *** |
---|
| 138 | else if(PreVol!=PosVol && PreVol=="tmass_phys") { |
---|
| 139 | |
---|
| 140 | tm = thePreTouchable->GetReplicaNumber(6); |
---|
| 141 | |
---|
| 142 | charge_out[tm] += (int)charge; |
---|
| 143 | |
---|
| 144 | // energy spectra at test-mass boundary |
---|
| 145 | if(FlagSpectrum) { |
---|
| 146 | // electrons leaving test mass |
---|
| 147 | if(pName=="e-") { |
---|
| 148 | std::ofstream electrons_out("electrons_out.out",std::ios::app); |
---|
| 149 | electrons_out << energy/eV << G4endl; |
---|
| 150 | } |
---|
| 151 | // hadrons leaving test mass |
---|
| 152 | else if(pName=="proton" || |
---|
| 153 | pName=="pi+" || pName=="pi-" || |
---|
| 154 | pName=="deuteron" || pName=="He3" || |
---|
| 155 | pName=="alpha" || pName=="triton") { |
---|
| 156 | std::ofstream hadrons_out("hadrons_out.out",std::ios::app); |
---|
| 157 | hadrons_out << energy/eV << G4endl; |
---|
| 158 | } |
---|
| 159 | } |
---|
| 160 | |
---|
| 161 | } // *** leaving a test mass *** |
---|
| 162 | |
---|
| 163 | |
---|
| 164 | } // if(next volume) |
---|
| 165 | |
---|
| 166 | |
---|
| 167 | // count particles hitting probe volume |
---|
| 168 | // if(fStep->GetTrack()->GetNextVolume()) { |
---|
| 169 | // static int i=0; |
---|
| 170 | // G4String PosVol=fStep->GetPostStepPoint() |
---|
| 171 | // ->GetPhysicalVolume()->GetName(); |
---|
| 172 | // if(PosVol=="probe_phys") { |
---|
| 173 | // fStep->GetTrack()->SetTrackStatus(fStopAndKill); |
---|
| 174 | // G4cout << i++ << G4endl; |
---|
| 175 | // } |
---|
| 176 | // } |
---|
| 177 | |
---|
| 178 | } |
---|
| 179 | |
---|
| 180 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... |
---|
| 181 | |
---|