Geant4  10.00.p01
MCTruthTrackingAction.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 //
30 // $Id: MCTruthTrackingAction.cc 73446 2013-08-27 11:32:59Z gcosmo $
31 //
32 //
33 // --------------------------------------------------------------
34 // GEANT 4 - MCTruthTrackingAction class
35 // --------------------------------------------------------------
36 //
37 // Author: Witold POKORSKI (Witold.Pokorski@cern.ch)
38 //
39 // --------------------------------------------------------------
40 
41 #include <iostream>
42 
43 #include "G4Track.hh"
44 #include "G4TrackVector.hh"
45 #include "G4TrackingManager.hh"
46 #include "MCTruthTrackingAction.hh"
48 
50 {}
51 
53 {}
54 
56 {
57  fmom = G4LorentzVector(track->GetMomentum(), track->GetTotalEnergy());
58 
59  if(!track->GetUserInformation())
60  {
63  }
64 }
65 
67 {
68 
69  G4LorentzVector prodpos(track->GetGlobalTime() - track->GetLocalTime(),
70  track->GetVertexPosition());
71  G4LorentzVector endpos(track->GetGlobalTime(), track->GetPosition());
72 
73  // here (?) make all different checks to decide whether to store the particle
74  //
75  if (trackToBeStored(track))
76  {
79 
81  AddParticle(fmom, prodpos, endpos,
82  track->GetDefinition()->GetPDGEncoding(),
83  track->GetTrackID(),
84  track->GetParentID(), mcinf->GetDirectParent());
85  }
86  else
87  {
88  // If track is not to be stored, propagate it's parent ID (stored)
89  // to its secondaries
90  //
92 
93  for( unsigned int index = 0 ; index < childrens->size() ; ++index )
94  {
95  G4Track* tr = (*childrens)[index] ;
96  tr->SetParentID( track->GetParentID() );
97 
98  // set the flag saying that the direct mother is not stored
99  //
100  MCTruthTrackInformation* mcinf =
102  if(!mcinf)
104 
105  mcinf->SetDirectParent(false);
106  }
107  }
108 }
109 
111 {
113 
114  // check energy
115  if (fmom.e() > config->GetMinE()) return true;
116 
117  // particle type
118  std::vector<G4int> types = config->GetParticleTypes();
119 
120  if(std::find( types.begin(), types.end(),
121  track->GetDefinition()->GetPDGEncoding())
122  != types.end()) return true;
123 
124  // creator process
125 
126  // etc...
127 
128  return false;
129 }
G4ParticleDefinition * GetDefinition() const
G4TrackingManager * fpTrackingManager
G4int GetParentID() const
static MCTruthManager * GetInstance()
G4double GetLocalTime() const
MCTruthConfig * GetConfig() const
const G4ThreeVector & GetPosition() const
G4double GetMinE() const
void SetUserTrackInformation(G4VUserTrackInformation *aValue)
G4bool trackToBeStored(const G4Track *)
G4VUserTrackInformation * GetUserInformation() const
void SetDirectParent(G4bool value)
G4TrackVector * GimmeSecondaries() const
bool G4bool
Definition: G4Types.hh:79
Definition of the MCTruthTrackInformation class.
G4int GetTrackID() const
G4double GetGlobalTime() const
const G4ThreeVector & GetVertexPosition() const
std::vector< G4int > & GetParticleTypes()
G4ThreeVector GetMomentum() const
std::vector< G4Track * > G4TrackVector
void SetParentID(const G4int aValue)
G4double GetTotalEnergy() const
Definition of the MCTruthTrackingAction class.
void SetUserInformation(G4VUserTrackInformation *aValue)
void PostUserTrackingAction(const G4Track *)
void PreUserTrackingAction(const G4Track *)
CLHEP::HepLorentzVector G4LorentzVector