Geant4  10.02
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 90848 2015-06-10 13:44:30Z 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
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) {
78  fEmCal = new G4EmCalculator();
79  first = false;
80  }
81 
82 
83 
84 
86 
87  //keep primary particle or neutral
88  //
89  G4ParticleDefinition* particle = track->GetDefinition();
90  G4bool neutral = (particle->GetPDGCharge() == 0.);
91  if ((track->GetParentID() == 0) || neutral) return status;
92 
93 
94  Run* run = static_cast<Run*>(
96 
97  //energy spectrum of charged secondaries
98  //
99  G4double energy = track->GetKineticEnergy();
100  run->sumEsecond(energy);
101 
102  // kill e- which cannot reach Cavity
103  //
104  G4double position = (track->GetPosition()).z();
105  G4double safe = std::abs(position) - fZcav;
106  G4double range = fEmCal->GetRangeFromRestricteDEDX(energy,particle,fMatWall);
107  if (fKillTrack) {
108  if (range < 0.8*safe) status = fKill;
109  }
110 
111  //histograms
112  //
113  G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
114  analysisManager->FillH1(1,position);
115  analysisManager->FillH1(2,energy);
116  G4ThreeVector direction = track->GetMomentumDirection();
117  analysisManager->FillH1(3,std::acos(direction.z()));
118 
119  return status;
120 }
121 
122 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4ParticleDefinition * GetDefinition() const
G4int GetParentID() const
DetectorConstruction * fDetector
CLHEP::Hep3Vector G4ThreeVector
void sumEsecond(G4double e)
Definition: Run.hh:66
G4double z
Definition: TRTMaterials.hh:39
G4Material * GetWallMaterial()
const G4ThreeVector & GetPosition() const
G4double GetKineticEnergy() const
#define position
Definition: xmlparse.cc:622
virtual G4ClassificationOfNewTrack ClassifyNewTrack(const G4Track *)
bool G4bool
Definition: G4Types.hh:79
G4EmCalculator * fEmCal
G4double GetRangeFromRestricteDEDX(G4double kinEnergy, const G4ParticleDefinition *, const G4Material *, const G4Region *r=0)
StackingMessenger * fStackMessenger
ExG4HbookAnalysisManager G4AnalysisManager
Definition: g4hbook_defs.hh:66
static G4RunManager * GetRunManager()
Definition: G4RunManager.cc:79
const G4ThreeVector & GetMomentumDirection() const
G4double energy(const ThreeVector &p, const G4double m)
Detector construction class to demonstrate various ways of placement.
G4Material * fMatWall
double G4double
Definition: G4Types.hh:76
Definition: Run.hh:46
G4double GetPDGCharge() const
G4Run * GetNonConstCurrentRun() const