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