MpdStack.h 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266
  1. // -------------------------------------------------------------------------
  2. // ----- FairStack header file -----
  3. // ----- Created 10/08/04 by D. Bertini / V. Friese -----
  4. // ----- adopted for NICA/MPD 29/03/10 (litvin) -----
  5. // ----- adopted for NICA/MPD 20/12/19 (ABychkov) -----
  6. // ----- added external decayer 30/04/20 (AZinchenko) -----
  7. // -------------------------------------------------------------------------
  8. /** MpdStack.h
  9. *@author D.Bertini <d.bertini@gsi.de>
  10. *@author V.Friese <v.friese@gsi.de>
  11. **
  12. ** Version 14/06/07 by V. Friese
  13. **
  14. ** This class handles the particle stack for the transport simulation.
  15. ** For the stack FILO functunality, it uses the STL stack. To store
  16. ** the tracks during transport, a TParticle arry is used.
  17. ** At the end of the event, tracks satisfying the filter criteria
  18. ** are copied to a FairMCTrack array, which is stored in the output.
  19. **
  20. ** The filtering criteria for the output tracks are:
  21. ** - primary tracks are stored in any case.
  22. ** - secondary tracks are stored if they have a minimal number of
  23. ** points (sum of all detectors) and a minimal energy, or are the
  24. **
  25. ** The storage of secondaries can be switched off.
  26. ** The storage of all mothers can be switched off.
  27. ** By default, the minimal number of points is 1 and the energy cut is 0.
  28. **/
  29. #ifndef MPDSTACK_H
  30. #define MPDSTACK_H
  31. #include "MpdDetectorList.h"
  32. #include "FairGenericStack.h"
  33. #include "TClonesArray.h"
  34. #include "TVirtualMCStack.h"
  35. #include <map>
  36. #include <stack>
  37. class MpdStack : public FairGenericStack
  38. {
  39. public:
  40. /** Default constructor
  41. *param size Estimated track number
  42. **/
  43. MpdStack(Int_t size = 100);
  44. /** Destructor **/
  45. virtual ~MpdStack();
  46. /** Add a TParticle to the stack.
  47. ** Declared in TVirtualMCStack
  48. *@param toBeDone Flag for tracking
  49. *@param parentID Index of mother particle
  50. *@param pdgCode Particle type (PDG encoding)
  51. *@param px,py,pz Momentum components at start vertex [GeV]
  52. *@param e Total energy at start vertex [GeV]
  53. *@param vx,vy,vz Coordinates of start vertex [cm]
  54. *@param time Start time of track [s]
  55. *@param polx,poly,polz Polarisation vector
  56. *@param proc Production mechanism (VMC encoding)
  57. *@param ntr Track number (filled by the stack)
  58. *@param weight Particle weight
  59. *@param is Generation status code (whatever that means)
  60. **/
  61. virtual void PushTrack(Int_t toBeDone, Int_t parentID, Int_t pdgCode,
  62. Double_t px, Double_t py, Double_t pz,
  63. Double_t e, Double_t vx, Double_t vy,
  64. Double_t vz, Double_t time, Double_t polx,
  65. Double_t poly, Double_t polz, TMCProcess proc,
  66. Int_t& ntr, Double_t weight, Int_t is);
  67. virtual void PushTrack(Int_t toBeDone, Int_t parentID, Int_t pdgCode,
  68. Double_t px, Double_t py, Double_t pz,
  69. Double_t e, Double_t vx, Double_t vy,
  70. Double_t vz, Double_t time, Double_t polx,
  71. Double_t poly, Double_t polz, TMCProcess proc,
  72. Int_t& ntr, Double_t weight, Int_t is, Int_t secondparentID);
  73. /** Get next particle for tracking from the stack.
  74. ** Declared in TVirtualMCStack
  75. *@param iTrack index of popped track (return)
  76. *@return Pointer to the TParticle of the track
  77. **/
  78. virtual TParticle* PopNextTrack(Int_t& iTrack);
  79. /** Get primary particle by index for tracking from stack
  80. ** Declared in TVirtualMCStack
  81. *@param iPrim index of primary particle
  82. *@return Pointer to the TParticle of the track
  83. **/
  84. virtual TParticle* PopPrimaryForTracking(Int_t iPrim);
  85. /** Set the current track number
  86. ** Declared in TVirtualMCStack
  87. *@param iTrack track number
  88. **/
  89. virtual void SetCurrentTrack(Int_t iTrack) { fCurrentTrack = iTrack; }
  90. /** Get total number of tracks
  91. ** Declared in TVirtualMCStack
  92. **/
  93. virtual Int_t GetNtrack() const { return fNParticles; }
  94. //virtual Int_t GetNtrack() const { return fStack.size(); } //AZ 30.04.20
  95. /** Get number of primary tracks
  96. ** Declared in TVirtualMCStack
  97. **/
  98. virtual Int_t GetNprimary() const { return fNPrimaries; }
  99. /** Get the current track's particle
  100. ** Declared in TVirtualMCStack
  101. **/
  102. virtual TParticle* GetCurrentTrack() const;
  103. /** Get the number of the current track
  104. ** Declared in TVirtualMCStack
  105. **/
  106. virtual Int_t GetCurrentTrackNumber() const { return fCurrentTrack; }
  107. /** Get the track number of the parent of the current track
  108. ** Declared in TVirtualMCStack
  109. **/
  110. virtual Int_t GetCurrentParentTrackNumber() const;
  111. /** Add a TParticle to the fParticles array **/
  112. virtual void AddParticle(TParticle* part);
  113. /** Fill the MCTrack output array, applying filter criteria **/
  114. virtual void FillTrackArray();
  115. /** Update the track index in the MCTracks and MCPoints **/
  116. virtual void UpdateTrackIndex(TRefArray* detArray);
  117. /** Resets arrays and stack and deletes particles and tracks **/
  118. virtual void Reset();
  119. /** Register the MCTrack array to the Root Manager **/
  120. virtual void Register();
  121. /** Output to screen
  122. **@param iVerbose: 0=events summary, 1=track info
  123. **/
  124. virtual void Print(Int_t iVerbose=0) const;
  125. /** Modifiers **/
  126. void StoreSecondaries(Bool_t choice = kTRUE) { fStoreSecondaries = choice; }
  127. void SetMinPoints(Int_t min) { fMinPoints = min; }
  128. void SetEnergyCut(Double_t eMin) { fEnergyCut = eMin; }
  129. void StoreMothers(Bool_t choice = kTRUE) { fStoreMothers = choice; }
  130. void SetRCut(Double_t rMin) { fRadiusCut = rMin; }
  131. void SetZCut(Double_t zMin) { fVzCut = zMin; }
  132. void NoZdcTracks(Bool_t choice = kTRUE) { fNoZDC = choice; }
  133. void SetMomMassCut(Double_t mMin, Double_t mMax) {fMinMotherMass = mMin; fMaxMotherMass = mMax; }
  134. /** Increment number of points for the current track in a given detector
  135. *@param iDet Detector unique identifier
  136. **/
  137. void AddPoint(DetectorIdMPD iDet);
  138. /** Increment number of points for an arbitrary track in a given detector
  139. *@param iDet Detector unique identifier
  140. *@param iTrack Track number
  141. **/
  142. void AddPoint(DetectorIdMPD iDet, Int_t iTrack);
  143. /** Accessors **/
  144. TParticle* GetParticle(Int_t trackId) const;
  145. TClonesArray* GetListOfParticles() { return fParticles; }
  146. // Enable/disable decay of unstable particles
  147. void SetDecayUnstable(Int_t decay = 1) { fDecayFlag = decay; }
  148. private:
  149. /** STL stack (FILO) used to handle the TParticles for tracking **/
  150. std::stack<TParticle*> fStack; //!
  151. /** Array of TParticles (contains all TParticles put into or created
  152. ** by the transport
  153. **/
  154. TClonesArray* fParticles; //!
  155. /** Array of FairMCTracks containg the tracks written to the output **/
  156. TClonesArray* fTracks;
  157. //** Array of TParticle containg particles produced from decays of
  158. //** unstable particles (if this option is activated)
  159. TClonesArray* fDecays; //!
  160. /** STL map from particle index to storage flag **/
  161. std::map<Int_t, Bool_t> fStoreMap; //!
  162. std::map<Int_t, Bool_t>::iterator fStoreIter; //!
  163. /** STL map from particle index to track index **/
  164. std::map<Int_t, Int_t> fIndexMap; //!
  165. std::map<Int_t, Int_t>::iterator fIndexIter; //!
  166. /** STL map from track index and detector ID to number of MCPoints **/
  167. std::map<std::pair<Int_t, Int_t>, Int_t> fPointsMap; //!
  168. /** Some indizes and counters **/
  169. Int_t fCurrentTrack; //! Index of current track
  170. Int_t fNPrimaries; //! Number of primary particles
  171. Int_t fNParticles; //! Number of entries in fParticles
  172. Int_t fNTracks; //! Number of entries in fTracks
  173. Int_t fIndex; //! Used for merging
  174. Int_t fDecayFlag; //! flag to decay unstable particles
  175. /** Variables defining the criteria for output selection **/
  176. Bool_t fStoreSecondaries;
  177. Int_t fMinPoints;
  178. Double32_t fEnergyCut;
  179. Bool_t fStoreMothers;
  180. Double32_t fMinMotherMass;
  181. Double32_t fMaxMotherMass;
  182. Double32_t fRadiusCut;//NG xy radius of mc track origin
  183. Double32_t fVzCut;//NG z of mc track origin
  184. Bool_t fNoZDC;//NG
  185. /** Mark tracks for output using selection criteria **/
  186. void SelectTracks();
  187. ClassDef(MpdStack,1)
  188. };
  189. #endif