Geant4  10.01.p02
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 86064 2014-11-07 08:49:32Z 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
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) {
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
DetectorConstruction * fDetector
CLHEP::Hep3Vector G4ThreeVector
G4double z
Definition: TRTMaterials.hh:39
G4Material * GetWallMaterial()
const G4ThreeVector & GetPosition() const
RunAction * fRunAction
G4double GetKineticEnergy() const
#define position
Definition: xmlparse.cc:605
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:61
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
G4double GetPDGCharge() const