source: trunk/source/geometry/magneticfield/test/field03/src/F03SteppingAction.cc @ 1347

Last change on this file since 1347 was 1347, checked in by garnier, 13 years ago

geant4 tag 9.4

File size: 8.2 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// $Id: F03SteppingAction.cc,v 1.4 2006/06/29 18:30:29 gunter Exp $
28// GEANT4 tag $Name: geant4-09-04-ref-00 $
29//
30//
31
32//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
33//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
34
35#include "F03DetectorConstruction.hh"
36#include "G4EnergyLossTables.hh"
37#include "G4SteppingManager.hh"
38#include "G4TrackVector.hh"
39#include "F03SteppingAction.hh"
40#include "F03PrimaryGeneratorAction.hh"
41#include "F03EventAction.hh"
42#include "F03RunAction.hh"
43#include "G4Event.hh"
44#include "G4EventManager.hh"
45#include "F03SteppingMessenger.hh"
46#include "G4ios.hh"
47#include <iomanip>
48#include "G4UImanager.hh"
49
50//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
51
52F03SteppingAction::F03SteppingAction(F03DetectorConstruction* DET,
53                                     F03EventAction* EA,
54                                     F03RunAction* RA)
55:detector (DET),eventaction (EA),runaction (RA),steppingMessenger(NULL),
56 IDold(-1) ,evnoold(-1)
57{
58  steppingMessenger = new F03SteppingMessenger(this);
59}
60
61//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
62
63F03SteppingAction::~F03SteppingAction()
64{
65  delete steppingMessenger ;
66 }
67
68//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
69
70void F03SteppingAction::UserSteppingAction(const G4Step* aStep)
71{ 
72
73  G4double Edep,Theta,Thetaback,Ttrans,Tback,Tsec,Egamma,xend,yend,zend,rend ;
74  G4double Tkin ;
75  G4int evno = eventaction->GetEventno() ; 
76
77  IDnow = evno+10000*(aStep->GetTrack()->GetTrackID())+
78          100000000*(aStep->GetTrack()->GetParentID()); 
79  if(IDnow != IDold)
80  {
81   IDold=IDnow ;
82   if(
83      (((aStep->GetTrack()->GetDynamicParticle()->GetDefinition()->
84        GetParticleName()) == "e-") &&
85       ((aStep->GetTrack()->GetTrackID() != 1) ||
86       (aStep->GetTrack()->GetParentID() != 0)) )
87       ||
88      (((aStep->GetTrack()->GetDynamicParticle()->GetDefinition()->
89        GetParticleName()) == "e+") &&
90       ((aStep->GetTrack()->GetTrackID() != 1) ||
91       (aStep->GetTrack()->GetParentID() != 0)) )
92     )
93        runaction->Fillvertexz(aStep->GetTrack()->GetVertexPosition().x());
94
95   if(aStep->GetPreStepPoint()->GetPhysicalVolume()->GetName()=="Absorber")
96   {
97    if(((aStep->GetTrack()->GetDynamicParticle()->GetDefinition()->
98        GetParticleName()) == "e-") &&
99       ((aStep->GetTrack()->GetTrackID() != 1) ||
100       (aStep->GetTrack()->GetParentID() != 0)) ) 
101    {
102        eventaction->AddCharged() ;
103        eventaction->AddE() ;
104        Tsec = aStep->GetTrack()->GetKineticEnergy() ;  // !!!!!!!!!!!!
105        Tsec += aStep->GetTotalEnergyDeposit() ;        // !!!!!!!!!!!!
106        runaction->FillTsec(Tsec) ;
107    }
108    else
109    if(((aStep->GetTrack()->GetDynamicParticle()->GetDefinition()->
110        GetParticleName()) == "e+") &&
111       ((aStep->GetTrack()->GetTrackID() != 1) ||
112       (aStep->GetTrack()->GetParentID() != 0)) ) 
113    {
114        eventaction->AddCharged() ;
115        eventaction->AddP() ;
116        Tsec = aStep->GetTrack()->GetKineticEnergy() ;  // !!!!!!!!!!!!
117        Tsec += aStep->GetTotalEnergyDeposit() ;        // !!!!!!!!!!!!
118        runaction->FillTsec(Tsec) ;
119    }
120    else
121    if(((aStep->GetTrack()->GetDynamicParticle()->GetDefinition()->
122        GetParticleName()) == "gamma") &&
123       ((aStep->GetTrack()->GetTrackID() != 1) ||
124       (aStep->GetTrack()->GetParentID() != 0)) ) 
125    {
126        eventaction->AddNeutral() ;
127    }
128   }
129  }
130
131  if(aStep->GetPreStepPoint()->GetPhysicalVolume()->GetName()=="Absorber")
132  {
133    if(((aStep->GetTrack()->GetDynamicParticle()->GetDefinition()->
134        GetParticleName()) == "e-") 
135              ||
136       ((aStep->GetTrack()->GetDynamicParticle()->GetDefinition()->
137        GetParticleName()) == "e+")) 
138          eventaction->CountStepsCharged() ;
139
140    if ((aStep->GetTrack()->GetDynamicParticle()->GetDefinition()->
141        GetParticleName()) == "gamma") 
142          eventaction->CountStepsNeutral() ;
143  }
144
145  if (
146      (((aStep->GetTrack()->GetTrackID() == 1) &&
147        (aStep->GetTrack()->GetParentID()== 0)) ||
148        (aStep->GetTrack()->GetDynamicParticle()->GetDefinition()->
149        GetParticleName() ==
150        F03PrimaryGeneratorAction::GetPrimaryName())) 
151        &&
152        (aStep->GetPreStepPoint()->GetPhysicalVolume()->GetName()=="Absorber")
153        &&
154        (aStep->GetTrack()->GetNextVolume()->GetName()=="World") &&
155        (aStep->GetPostStepPoint()->GetProcessDefinedStep()
156              ->GetProcessName() == "Transportation") &&
157        (aStep->GetTrack()->GetMomentumDirection().z()>0.)
158                                                        )
159     {
160       eventaction->SetTr();
161       Theta = std::acos(aStep->GetTrack()->GetMomentumDirection().x()) ;
162       runaction->FillTh(Theta) ;
163       Ttrans = aStep->GetTrack()->GetKineticEnergy() ;
164       runaction->FillTt(Ttrans) ;
165       yend= aStep->GetTrack()->GetPosition().y() ;
166       xend= aStep->GetTrack()->GetPosition().x() ;
167       rend = std::sqrt(yend*yend+xend*xend) ;
168       runaction->FillR(rend);
169     }
170       
171  if (
172      (((aStep->GetTrack()->GetTrackID() == 1) &&
173        (aStep->GetTrack()->GetParentID()== 0)) ||
174      (aStep->GetTrack()->GetDynamicParticle()->GetDefinition()->
175       GetParticleName() ==
176       F03PrimaryGeneratorAction::GetPrimaryName())) 
177       &&
178      (aStep->GetPreStepPoint()->GetPhysicalVolume()->GetName()=="Absorber") &&
179      (aStep->GetTrack()->GetNextVolume()->GetName()=="World") &&
180      (aStep->GetPostStepPoint()->GetProcessDefinedStep()
181               ->GetProcessName() == "Transportation") &&
182      (aStep->GetTrack()->GetMomentumDirection().z()<0.)
183                                                        )
184     {
185       eventaction->SetRef();
186       Thetaback = std::acos(aStep->GetTrack()->GetMomentumDirection().x()) ;
187       Thetaback -= 0.5*pi ;
188       runaction->FillThBack(Thetaback) ;
189       Tback  = aStep->GetTrack()->GetKineticEnergy() ;
190       runaction->FillTb(Tback) ;
191     }
192 
193
194  if (
195      ((aStep->GetPreStepPoint()->GetPhysicalVolume()->GetName()=="Absorber") &&
196      (aStep->GetTrack()->GetNextVolume()->GetName()=="World") &&
197      (aStep->GetPostStepPoint()->GetProcessDefinedStep()
198               ->GetProcessName() == "Transportation") &&
199      (aStep->GetTrack()->GetMomentumDirection().x()>0.) &&
200      (aStep->GetTrack()->GetDynamicParticle()->GetDefinition()
201       ->GetParticleName() == "gamma"))
202     )
203     {
204       Egamma = aStep->GetTrack()->GetKineticEnergy() ;
205       runaction->FillGammaSpectrum(Egamma) ;
206     }
207     
208}
209
210//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
211
Note: See TracBrowser for help on using the repository browser.