Geant4_10
StackingAction.cc
Go to the documentation of this file.
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 //
28 //
29 // $Id: StackingAction.cc 68996 2013-04-15 09:19:55Z gcosmo $
30 //
31 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
32 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
33 
34 #include "StackingAction.hh"
35 
36 #include "DetectorConstruction.hh"
37 #include "RunAction.hh"
38 #include "HistoManager.hh"
39 #include "StackingMessenger.hh"
40 
41 #include "G4Track.hh"
42 #include "G4EmCalculator.hh"
43 
44 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
45 
47 :fDetector(det),fRunAction(run),fStackMessenger(0)
48 {
49  fMatWall = 0;
50  fZcav = 0.;
51  fEmCal = 0;
52  first = true;
53  fKillTrack = true;
54 
55  //create a messenger for this class
56  fStackMessenger = new StackingMessenger(this);
57 }
58 
59 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
60 
62 {
63  delete fEmCal;
64  delete fStackMessenger;
65 }
66 
67 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
68 
71 {
72  //get fDetector informations
73  if (first) {
74  fMatWall = fDetector->GetWallMaterial();
75  fZcav = 0.5*(fDetector->GetCavityThickness());
76  fEmCal = new G4EmCalculator();
77  first = false;
78  }
79 
81 
82  //keep primary particle or neutral
83  //
84  G4ParticleDefinition* particle = track->GetDefinition();
85  G4bool neutral = (particle->GetPDGCharge() == 0.);
86  if ((track->GetParentID() == 0) || neutral) return status;
87 
88  //energy spectrum of charged secondaries
89  //
90  G4double energy = track->GetKineticEnergy();
91  fRunAction->sumEsecond(energy);
92 
93  // kill e- which cannot reach Cavity
94  //
95  G4double position = (track->GetPosition()).z();
96  G4double safe = std::abs(position) - fZcav;
97  G4double range = fEmCal->GetRangeFromRestricteDEDX(energy,particle,fMatWall);
98  if (fKillTrack) {
99  if (range < 0.8*safe) status = fKill;
100  }
101 
102  //histograms
103  //
104  G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
105  analysisManager->FillH1(1,position);
106  analysisManager->FillH1(2,energy);
107  G4ThreeVector direction = track->GetMomentumDirection();
108  analysisManager->FillH1(3,std::acos(direction.z()));
109 
110  return status;
111 }
112 
113 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4ParticleDefinition * GetDefinition() const
G4int GetParentID() const
void sumEsecond(G4double e)
Definition: RunAction.hh:63
G4Material * GetWallMaterial()
const G4ThreeVector & GetPosition() const
double z() const
G4double GetKineticEnergy() const
double energy
Definition: plottest35.C:25
const G4ParticleDefinition const G4Material *G4double range
virtual G4ClassificationOfNewTrack ClassifyNewTrack(const G4Track *)
bool G4bool
Definition: G4Types.hh:79
G4double GetRangeFromRestricteDEDX(G4double kinEnergy, const G4ParticleDefinition *, const G4Material *, const G4Region *r=0)
ExG4HbookAnalysisManager G4AnalysisManager
Definition: g4hbook_defs.hh:46
int status
Definition: tracer.cxx:24
const G4ThreeVector & GetMomentumDirection() const
tuple z
Definition: test.py:28
double G4double
Definition: G4Types.hh:76
G4double GetPDGCharge() const