VMC Version 2.0
Loading...
Searching...
No Matches
TMCManagerStack.h
Go to the documentation of this file.
1// -----------------------------------------------------------------------
2// Copyright (C) 2019 CERN and copyright holders of VMC Project.
3// This software is distributed under the terms of the GNU General Public
4// License v3 (GPL Version 3), copied verbatim in the file "LICENSE".
5//
6// See https://github.com/vmc-project/vmc for full licensing information.
7// -----------------------------------------------------------------------
8
9// Authors: Benedikt Volkel 07/03/2019
10
11/*************************************************************************
12 * Copyright (C) 2019, Rene Brun and Fons Rademakers. *
13 * Copyright (C) 2019, ALICE Experiment at CERN. *
14 * All rights reserved. *
15 * *
16 * For the licensing terms see $ROOTSYS/LICENSE. *
17 * For the list of contributors see $ROOTSYS/README/CREDITS. *
18 *************************************************************************/
19
20#ifndef ROOT_TMCManagerStack
21#define ROOT_TMCManagerStack
22
23// Class TMCManagerStack
24// ---------------------
25// stack used by the TMCManager when handling multiple engines
26//
27
28#include <vector>
29#include <stack>
30#include <memory>
31
32#include "TMCtls.h"
33#include "TLorentzVector.h"
34#include "TMCProcess.h"
35
36#include "TVirtualMCStack.h"
37
39class TGeoBranchArray;
41
43
44public:
48 virtual ~TMCManagerStack() = default;
49
50 //
51 // Methods for stacking
52 //
53
69 void PushTrack(Int_t toBeDone, Int_t parent, Int_t pdg, Double_t px, Double_t py, Double_t pz, Double_t e,
70 Double_t vx, Double_t vy, Double_t vz, Double_t tof, Double_t polx, Double_t poly, Double_t polz,
71 TMCProcess mech, Int_t &ntr, Double_t weight, Int_t is) override final;
72
73 //
74 // Get methods
75 //
76
78 TParticle *PopNextTrack(Int_t &itrack) override final;
79
81 TParticle *PopPrimaryForTracking(Int_t i) override final;
82
85 TParticle *PopPrimaryForTracking(Int_t i, Int_t &itrack);
86
88 Int_t GetNtrack() const override final;
89
91 Int_t GetStackedNtrack() const;
92
94 Int_t GetNprimary() const override final;
95
97 Int_t GetStackedNprimary() const;
98
100 TParticle *GetCurrentTrack() const override final;
101
103 Int_t GetCurrentTrackNumber() const override final;
104
106 Int_t GetCurrentParentTrackNumber() const override final;
107
110 void SetCurrentTrack(Int_t trackId) override final;
111
113 const TMCParticleStatus *GetParticleStatus(Int_t trackId) const;
114
116 const TGeoBranchArray *GetGeoState(Int_t trackId) const;
117
119 const TGeoBranchArray *GetCurrentGeoState() const;
120
121private:
122 friend class TMCManager;
124 Bool_t HasTrackId(Int_t trackId) const;
126 void SetUserStack(TVirtualMCStack *stack);
128 void ConnectTrackContainers(std::vector<TParticle *> *particles,
129 std::vector<std::unique_ptr<TMCParticleStatus>> *tracksStatus,
130 TGeoMCBranchArrayContainer *branchArrayContainer, Int_t *totalNPrimaries,
131 Int_t *totalNTracks);
133 void PushPrimaryTrackId(Int_t trackId);
135 void PushSecondaryTrackId(Int_t trackId);
137 void ResetInternals();
138
139private:
149 std::vector<TParticle *> *fParticles;
151 std::vector<std::unique_ptr<TMCParticleStatus>> *fParticlesStatus;
155 std::stack<Int_t> fPrimariesStack;
157 std::stack<Int_t> fSecondariesStack;
158
159 ClassDefOverride(TMCManagerStack, 1)
160};
161
162#endif // ROOT_TMCManagerStack
TMCProcess
VMC physics process codes.
Definition: TMCProcess.h:30
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:43
Interface to a user defined particles stack.