Logo ROOT   6.18/05
Reference Guide
TMCManagerStack.h
Go to the documentation of this file.
1// @(#)root/vmc:$Id$
2// Authors: Benedikt Volkel 07/03/2019
3
4/*************************************************************************
5 * Copyright (C) 2019, Rene Brun and Fons Rademakers. *
6 * Copyright (C) 2019, ALICE Experiment at CERN. *
7 * All rights reserved. *
8 * *
9 * For the licensing terms see $ROOTSYS/LICENSE. *
10 * For the list of contributors see $ROOTSYS/README/CREDITS. *
11 *************************************************************************/
12
13#ifndef ROOT_TMCManagerStack
14#define ROOT_TMCManagerStack
15
16// Class TMCManagerStack
17// ---------------------
18// stack used by the TMCManager when handling multiple engines
19//
20
21#include <vector>
22#include <stack>
23#include <memory>
24
25#include "TMCtls.h"
26#include "TLorentzVector.h"
27#include "TMCProcess.h"
28
29#include "TVirtualMCStack.h"
30
32class TGeoBranchArray;
34
36
37public:
38 /// Default constructor
40 /// Destructor
41 virtual ~TMCManagerStack() = default;
42
43 //
44 // Methods for stacking
45 //
46
47 /// This will just forward the call to the fUserStack's PushTrack
48 ///
49 /// Create a new particle and push into stack;
50 /// - toBeDone - 1 if particles should go to tracking, 0 otherwise
51 /// - parent - number of the parent track, -1 if track is primary
52 /// - pdg - PDG encoding
53 /// - px, py, pz - particle momentum [GeV/c]
54 /// - e - total energy [GeV]
55 /// - vx, vy, vz - position [cm]
56 /// - tof - time of flight [s]
57 /// - polx, poly, polz - polarization
58 /// - mech - creator process VMC code
59 /// - ntr - track number (is filled by the stack
60 /// - weight - particle weight
61 /// - is - generation status code
62 void PushTrack(Int_t toBeDone, Int_t parent, Int_t pdg, Double_t px, Double_t py, Double_t pz, Double_t e,
63 Double_t vx, Double_t vy, Double_t vz, Double_t tof, Double_t polx, Double_t poly, Double_t polz,
64 TMCProcess mech, Int_t &ntr, Double_t weight, Int_t is) override final;
65
66 //
67 // Get methods
68 //
69
70 /// Pop next track
71 TParticle *PopNextTrack(Int_t &itrack) override final;
72
73 /// Pop i'th primar, that does not mean that this primariy also has ID==i
74 TParticle *PopPrimaryForTracking(Int_t i) override final;
75
76 /// Pop i'th primary, that does not mean that this primariy also has ID==i.
77 /// including actual index
79
80 /// Get number of tracks on current sub-stack
81 Int_t GetNtrack() const override final;
82
83 /// Get only the number of currently stacked tracks
84 Int_t GetStackedNtrack() const;
85
86 /// Get number of primaries on current sub-stack
87 Int_t GetNprimary() const override final;
88
89 /// Get only the number of currently stacked primaries
91
92 /// Current track
93 TParticle *GetCurrentTrack() const override final;
94
95 /// Current track number
96 Int_t GetCurrentTrackNumber() const override final;
97
98 /// Number of the parent of the current track
99 Int_t GetCurrentParentTrackNumber() const override final;
100
101 /// Set the current track id from the outside and forward this to the
102 /// user's stack
103 void SetCurrentTrack(Int_t trackId) override final;
104
105 /// Get TMCParticleStatus by trackId
106 const TMCParticleStatus *GetParticleStatus(Int_t trackId) const;
107
108 /// Get particle's geometry status by trackId
109 const TGeoBranchArray *GetGeoState(Int_t trackId) const;
110
111 /// Get current particle's geometry status
112 const TGeoBranchArray *GetCurrentGeoState() const;
113
114private:
115 friend class TMCManager;
116 /// Check whether track trackId exists
117 Bool_t HasTrackId(Int_t trackId) const;
118 /// Set the user stack
119 void SetUserStack(TVirtualMCStack *stack);
120 /// Set the pointer to vector with all particles and status
121 void ConnectTrackContainers(std::vector<TParticle *> *particles,
122 std::vector<std::unique_ptr<TMCParticleStatus>> *tracksStatus,
123 TGeoMCBranchArrayContainer *branchArrayContainer, Int_t *totalNPrimaries,
124 Int_t *totalNTracks);
125 /// Push primary id to be processed
126 void PushPrimaryTrackId(Int_t trackId);
127 /// Push secondary id to be processed
128 void PushSecondaryTrackId(Int_t trackId);
129 /// Reset internals, clear engine stack and fParticles and reset buffered values
130 void ResetInternals();
131
132private:
133 /// Pointer to current track
135 /// Pointer to user stack for forwarding PushTrack calls
137 /// Number of all primaries ever pushed linked from the TMCManager
139 /// Number of all tracks ever pushed linked from the TMCManager
141 /// All tracks linked from the TMCManager
142 std::vector<TParticle *> *fParticles;
143 /// All TMCParticleStatus linked from the TMCManager
144 std::vector<std::unique_ptr<TMCParticleStatus>> *fParticlesStatus;
145 /// Storage of TGeoBranchArray pointers
147 /// IDs of primaries to be tracked
149 /// IDs of secondaries to be trackedk
151
153};
154
155#endif // ROOT_TMCManagerStack
#define e(i)
Definition: RSha256.hxx:103
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
double Double_t
Definition: RtypesCore.h:55
#define ClassDefOverride(name, id)
Definition: Rtypes.h:330
TMCProcess
VMC physics process codes.
Definition: TMCProcess.h:24
An array of daughter indices making a geometry path.
Storing and re-using geometry states of the TGeoManager in use by storing them as TGeoBranchArrays.
Concrete implementation of particles stack used by the TMCManager.
Bool_t HasTrackId(Int_t trackId) const
Check whether track trackId exists.
void ResetInternals()
Reset internals, clear engine stack and fParticles and reset buffered values.
TParticle * PopPrimaryForTracking(Int_t i) override final
Pop i'th primar, that does not mean that this primariy also has ID==i.
Int_t * fTotalNTracks
Number of all tracks ever pushed linked from the TMCManager.
Int_t GetNtrack() const override final
Get number of tracks on current sub-stack.
std::vector< TParticle * > * fParticles
All tracks linked from the TMCManager.
void SetCurrentTrack(Int_t trackId) override final
Set the current track id from the outside and forward this to the user's stack.
TParticle * PopNextTrack(Int_t &itrack) override final
Pop next track.
Int_t GetStackedNtrack() const
Get only the number of currently stacked tracks.
void PushPrimaryTrackId(Int_t trackId)
Push primary id to be processed.
std::vector< std::unique_ptr< TMCParticleStatus > > * fParticlesStatus
All TMCParticleStatus linked from the TMCManager.
Int_t GetNprimary() const override final
Get number of primaries on current sub-stack.
std::stack< Int_t > fSecondariesStack
IDs of secondaries to be trackedk.
TVirtualMCStack * fUserStack
Pointer to user stack for forwarding PushTrack calls.
TParticle * GetCurrentTrack() const override final
Current track.
void PushSecondaryTrackId(Int_t trackId)
Push secondary id to be processed.
Int_t * fTotalNPrimaries
Number of all primaries ever pushed linked from the TMCManager.
Int_t GetCurrentTrackNumber() const override final
Current track number.
std::stack< Int_t > fPrimariesStack
IDs of primaries to be tracked.
const TGeoBranchArray * GetGeoState(Int_t trackId) const
Get particle's geometry status by trackId.
TGeoMCBranchArrayContainer * fBranchArrayContainer
Storage of TGeoBranchArray pointers.
void PushTrack(Int_t toBeDone, Int_t parent, Int_t pdg, Double_t px, Double_t py, Double_t pz, Double_t e, Double_t vx, Double_t vy, Double_t vz, Double_t tof, Double_t polx, Double_t poly, Double_t polz, TMCProcess mech, Int_t &ntr, Double_t weight, Int_t is) override final
This will just forward the call to the fUserStack's PushTrack.
TMCManagerStack()
Default constructor.
Int_t GetCurrentParentTrackNumber() const override final
Number of the parent of the current track.
virtual ~TMCManagerStack()=default
Destructor.
const TMCParticleStatus * GetParticleStatus(Int_t trackId) const
Get TMCParticleStatus by trackId.
Int_t fCurrentTrackId
Pointer to current track.
Int_t GetStackedNprimary() const
Get only the number of currently stacked primaries.
void ConnectTrackContainers(std::vector< TParticle * > *particles, std::vector< std::unique_ptr< TMCParticleStatus > > *tracksStatus, TGeoMCBranchArrayContainer *branchArrayContainer, Int_t *totalNPrimaries, Int_t *totalNTracks)
Set the pointer to vector with all particles and status.
void SetUserStack(TVirtualMCStack *stack)
Set the user stack.
const TGeoBranchArray * GetCurrentGeoState() const
Get current particle's geometry status.
Singleton manager class for handling and steering a run with multiple TVirtualMC engines sharing even...
Definition: TMCManager.h:36
Description of the dynamic properties of a particle.
Definition: TParticle.h:26
Interface to a user defined particles stack.