source: trunk/examples/advanced/cosmicray_charging/src/LISAStackingAction.cc @ 1313

Last change on this file since 1313 was 807, checked in by garnier, 16 years ago

update

File size: 5.8 KB
Line 
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// * LISAStackingAction class                                        *
35// *                                                                  *
36// ********************************************************************
37//
38// HISTORY
39// 22/02/2004: migrated from LISA-V04
40//
41// ********************************************************************
42
43
44#include "LISAStackingAction.hh"
45
46#include "LISAStackingActionMessenger.hh"
47
48#include "G4Track.hh"
49#include "G4TrackStatus.hh"
50#include "G4ParticleDefinition.hh"
51#include "G4ParticleTypes.hh"
52#include <fstream>
53
54LISAStackingAction::LISAStackingAction() {
55
56  // messenger defaults 
57  PrimarySurveyFlag  = false;
58  ParticleSurveyFlag = false;
59
60  // create messenger
61  stackingMessenger = new LISAStackingActionMessenger(this);
62
63}
64
65
66LISAStackingAction::~LISAStackingAction() {
67
68  delete stackingMessenger;
69
70}
71
72
73G4ClassificationOfNewTrack LISAStackingAction::ClassifyNewTrack
74(const G4Track* aTrack) {
75
76
77  // write primary spectrum to file
78  if(PrimarySurveyFlag) {
79    if(!aTrack->GetParentID()) {
80      G4double energy = aTrack->GetKineticEnergy();
81      std::ofstream primaries("primaries.out",std::ios::app);
82      primaries << energy/MeV << G4endl;
83      return (G4ClassificationOfNewTrack) fKill;
84    }
85  }
86
87  // Particle Survey
88  if(ParticleSurveyFlag) {
89    G4String particle = aTrack->GetDefinition()->GetParticleName();
90    G4double energy = aTrack->GetKineticEnergy();
91    //
92    // gammas above 1 MeV
93    if(particle=="gamma" && energy>1*MeV) {
94      std::ofstream gammas("gammas.out",std::ios::app);
95      gammas << energy/MeV << G4endl;
96    }
97    // electrons and positrons above 1 MeV
98    else if((particle=="e-" || particle=="e+") && energy>1.*MeV) {
99      std::ofstream electrons("electrons.out",std::ios::app);
100      electrons << energy/MeV << G4endl;
101    }
102    // delta electrons
103    //  else if(particle=="e-" && aTrack->GetParentID()>0) {
104    //    std::ofstream deltas("deltas.out",std::ios::app);
105    //    deltas << energy/eV << G4endl;
106    //    return (G4ClassificationOfNewTrack) fKill;
107    //  }
108    //
109    // neutrons
110    else if(particle=="neutron") {
111      std::ofstream neutrons("neutrons.out",std::ios::app);
112      neutrons << energy/MeV << G4endl;
113    }
114    // pions
115    else if(particle=="pi+" || particle=="pi-" || particle=="pi0") {
116      std::ofstream pions("pions.out",std::ios::app);
117      pions << energy/MeV << G4endl;
118    }
119    // fragments (energy per nucleon)
120    else if(particle=="deuteron" || particle=="triton" || 
121            particle=="He3" || particle=="alpha") {
122      G4int A = aTrack->GetDefinition()->GetBaryonNumber();
123      std::ofstream fragments("fragments.out",std::ios::app);
124      fragments << energy/A/MeV << G4endl;
125    }
126    // muons
127    else if(particle=="mu+" || particle=="mu-") {
128      std::ofstream muons("muons.out",std::ios::app);
129      muons << energy/MeV << G4endl;
130    }
131    // kaons
132    else if(particle=="kaon+"  || particle=="kaon-" ||
133            particle=="kaon0S" || particle=="kaon0L" ) {
134      std::ofstream kaons("kaons.out",std::ios::app);
135      kaons << energy/MeV << G4endl;
136    }
137    // nuclei (energy per nucleon)
138    else if(aTrack->GetDefinition()->GetParticleType()=="nucleus") {
139      G4int A = aTrack->GetDefinition()->GetBaryonNumber();
140      std::ofstream nuclei("nuclei.out",std::ios::app);
141      nuclei << energy/A/MeV << "\t" << particle << G4endl;
142    }
143    // others
144    else if(particle!="proton" && energy>1.*MeV) {
145      std::ofstream others("others.out",std::ios::app);
146      others << energy/MeV << "\t" << particle << G4endl;
147    }
148
149  }
150
151
152  return (G4ClassificationOfNewTrack) fWaiting;
153 
154}
155
156
157void LISAStackingAction::NewStage() {;}
158
159   
160void LISAStackingAction::PrepareNewEvent() {;}
161
162
163
164
165
166
167
Note: See TracBrowser for help on using the repository browser.