BOSS 8.0.0
BESIII Offline Software System
Loading...
Searching...
No Matches
Simulation/BOOST/TruSim/include/TruSim/BesSensitiveManager.hh
Go to the documentation of this file.
1//---------------------------------------------------------------------------//
2//////// BOOST --- BESIII Object_Oriented Simulation Tool //
3////////---------------------------------------------------------------------------//
4////////Description:
5////////Author : Dengzy
6////
7//// ////Created: Aug, 2004
8//// ////Modified:
9//// ////Comment:
10//// ////---------------------------------------------------------------------------//
11//// //// $Id: BesSensitiveManager.hh
12
13#ifndef BesSensitiveManager_hh
14#define BesSensitiveManager_hh
15
17#include "G4TrackingManager.hh"
18#include "HepMC/GenEvent.h"
19#include "globals.hh"
20
21class G4Svc;
22
23class G4VProcess;
24class G4Track;
25class G4Event;
26
27class BesTruthVertex;
28class BesTruthTrack;
29// Since G4 lacks a "permanent stack" feature like GEANT3,
30// we need to keep track of the complete parentage of particles
31
32class BesTStats {
33
34 friend class BesSensitiveManager;
35
36public:
38 : G4index( -1 )
39 , p4( 0 )
40 , time( 0 )
41 , trackIndex( -1 )
42 , originVertex( -1 )
43 , savedByDefault( false )
44 , vertices( 0 ) {
45 ;
46 }
47 BesTStats( const G4int index, const CLHEP::HepLorentzVector theP4, G4double theTime )
48 : G4index( index )
49 , p4( theP4 )
50 , time( theTime )
51 , trackIndex( -1 )
52 , originVertex( -1 )
53 , savedByDefault( false )
54 , vertices( 0 ) {
55 ;
56 }
57 ~BesTStats() { ; }
58
59 bool operator==( const BesTStats& other ) const { return G4index == other.G4index; }
60
61private:
62 G4int G4index; // Index as in G4Track::fTrackID
63 CLHEP::HepLorentzVector p4; // 4-Momentum at origin
64 G4double time; // Global time at origin
65 G4int trackIndex; // Index into trackList, or -1 if no such
66 G4int originVertex; // Index into vertexList of origin vertex
67 bool savedByDefault; // True if saved to BesTruthTrack by default
68
69 // A list of vertices (index into vertexList)
70 // associated with an interaction
71 // of this track.
72 std::vector<int> vertices;
73};
74
76public:
78 m_hepmcevt = 0;
79 if ( m_sensitiveManager ) G4cout << "BesSensitiveManager constructed twice." << G4endl;
80 m_sensitiveManager = this;
81 }
82
84
86
87 // Add a new client
89 clients.push_back( detector );
90 }
91
92 G4int GetCurrentTrackIndex() const { return m_trackIndex; }
93 std::vector<BesTruthTrack*>* GetTrackList() { return m_trackList; }
94 std::vector<BesTruthVertex*>* GetVertexList() { return m_vertexList; }
95
96 // Take care of things at the beginning and end
97 // of event, including dumping all required stuff
98 // at the end of the event
99 void BeginOfTruthEvent( const G4Event* );
100 void EndOfTruthEvent( const G4Event* );
101
102 G4int CheckType( const HepMC::GenEvent* hepmcevt );
104 void SetVertex0( const G4Event* );
105 void UpdatePrimaryTrack( const G4Track* );
106 G4bool CheckDecayTrack( const G4Track* );
107 void UpdateVertex( BesTStats, const G4Track* );
108 G4bool MatchDaughterTrack( const G4Track* );
109 void GetDaughterVertexes( BesTruthTrack* pTrack, std::vector<int>* vDau );
110 G4bool MatchVertex( G4int vIndex, std::vector<int>* vDau );
111
112 // Take care of things at the beginning and end
113 // of tracks
114 void BeginOfTrack( const G4Track* track );
115 void EndOfTrack( const G4Track* track, G4TrackingManager* );
116
117 // Find out how many tracks and vertices we have
118 G4int GetNumberTracks() const { return m_trackList ? m_trackList->size() : 0; }
119 G4int GetNumberVertices() const { return m_vertexList ? m_vertexList->size() : 0; }
120
122
123 void SetLogLevel( G4int level ) { m_logLevel = level; }
124
125protected:
127
128 std::vector<BesSensitiveDetector*>::iterator iter;
129 std::vector<BesSensitiveDetector*>::iterator iter_end;
130
131 // Current track indices
132 G4int m_trackIndex;
133 G4int m_trackFlag;
134
135 // The following are the BesTruthTrack, BesTruthVertex
136 // lists. Don't forget to delete them at the end of the event.
137 std::vector<BesTruthTrack*>* m_trackList;
138 std::vector<BesTruthVertex*>* m_vertexList;
139
140 // Here is a list of clients. Note that
141 // these objects are decendents of G4VSensitiveDetector
142 // and are thus owned by GEANT4. We must not delete
143 // them ourselves!
144 std::vector<BesSensitiveDetector*> clients;
145
146 std::vector<BesTStats> chain; // Stats on the decay chain
147
148 // Make a new TruthTrack (and TruthVertex if necessary)
149 void MakeNewTrack( BesTStats& stat, const G4Track* track );
150
151 // Update trackList, vertexList, for a new track, and return the new track's stats
152 BesTStats FollowTrack( const G4Track* track );
153
154 // this data member is set for recording trackIndex
155 G4int m_count;
156
157 G4ThreeVector m_pos0;
158 G4double m_t0;
159
160 G4int m_logLevel;
161 HepMC::GenEvent* m_hepmcevt;
162};
163
164#endif
Double_t time
EvtStreamInputIterator< typename Generator::result_type > iter(Generator gen, int N=0)
void EndOfTruthEvent(const G4Event *)
BesTStats FollowTrack(const G4Track *track)
void UpdatePrimaryTrack(const G4Track *)
void SetVertex0(const G4Event *)
G4bool MatchDaughterTrack(const G4Track *)
void MakeNewTrack(BesTStats &stat, const G4Track *track)
void BeginOfTrack(const G4Track *track)
void UpdateVertex(BesTStats, const G4Track *)
void EndOfTrack(const G4Track *track, G4TrackingManager *)
void BeginOfTruthEvent(const G4Event *)
G4bool MatchVertex(G4int vIndex, std::vector< int > *vDau)
void GetDaughterVertexes(BesTruthTrack *pTrack, std::vector< int > *vDau)
G4bool CheckDecayTrack(const G4Track *)
void SaveParticlesFromGenerator()
G4int CheckType(const HepMC::GenEvent *hepmcevt)
BesTStats(const G4int index, const CLHEP::HepLorentzVector theP4, G4double theTime)
Definition G4Svc.h:31