Geant4  10.03.p02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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 98764 2016-08-09 14:12:17Z 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 "G4RunManager.hh"
40 #include "StackingMessenger.hh"
41 #include "Run.hh"
42 
43 #include "G4Track.hh"
44 #include "G4EmCalculator.hh"
45 
46 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
47 
49 :fDetector(det),fStackMessenger(0)
50 {
51  fMatWall = 0;
52  fZcav = 0.;
53  fEmCal = 0;
54  first = true;
55  fKillTrack = true;
56 
57  //create a messenger for this class
58  fStackMessenger = new StackingMessenger(this);
59 }
60 
61 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
62 
64 {
65  delete fEmCal;
66  delete fStackMessenger;
67 }
68 
69 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
70 
73 {
74  //get fDetector informations
75  if (first) {
76  fMatWall = fDetector->GetWallMaterial();
77  fZcav = 0.5*(fDetector->GetCavityThickness());
78  fEmCal = new G4EmCalculator();
79  first = false;
80  }
81 
83 
84  //keep primary particle or neutral
85  //
86  G4ParticleDefinition* particle = track->GetDefinition();
87  G4bool neutral = (particle->GetPDGCharge() == 0.);
88  if ((track->GetParentID() == 0) || neutral) return status;
89 
90  Run* run = static_cast<Run*>(
92 
93  //energy spectrum of charged secondaries
94  //
95  G4double energy = track->GetKineticEnergy();
96  run->SumEsecond(energy);
97 
98  // kill e- which cannot reach Cavity
99  //
100  G4double position = (track->GetPosition()).z();
101  G4double safe = std::abs(position) - fZcav;
102  G4double range = fEmCal->GetRangeFromRestricteDEDX(energy,particle,fMatWall);
103  if (fKillTrack) {
104  if (range < 0.8*safe) status = fKill;
105  }
106 
107  //histograms
108  //
109  G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
110  analysisManager->FillH1(1,position);
111  analysisManager->FillH1(2,energy);
112  G4ThreeVector direction = track->GetMomentumDirection();
113  analysisManager->FillH1(3,std::acos(direction.z()));
114 
115  return status;
116 }
117 
118 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4ParticleDefinition * GetDefinition() const
G4int GetParentID() const
G4Material * GetWallMaterial()
const G4ThreeVector & GetPosition() const
void SumEsecond(G4double e)
Definition: Run.hh:62
double z() const
G4double GetKineticEnergy() const
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=nullptr)
static G4RunManager * GetRunManager()
Definition: G4RunManager.cc:79
const G4ThreeVector & GetMomentumDirection() const
G4double energy(const ThreeVector &p, const G4double m)
tuple z
Definition: test.py:28
Detector construction class to define materials and geometry.
double G4double
Definition: G4Types.hh:76
Definition: Run.hh:46
G4double GetPDGCharge() const
G4CsvAnalysisManager G4AnalysisManager
Definition: g4csv_defs.hh:77
G4Run * GetNonConstCurrentRun() const