]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - STEER/AliStack.h
In AliStack: TClonesArray* fParticles replaced by TClonesArray
[u/mrichter/AliRoot.git] / STEER / AliStack.h
index d0bdc6ad59f1033fa5f44b6fd7ed65b403424c92..70d089b90f0dcfb46194c1ea21793ed897bb46b9 100644 (file)
@@ -5,55 +5,65 @@
 
 /* $Id$ */
 
-#include <TObject.h>
-#include <TArrayI.h>
-#include <TStopwatch.h>
-#include <TVirtualMCStack.h>
-#include <TMCProcess.h>
+//  Particles stack class
+//  Implements the TMCVirtualStack of the Virtual Monte Carlo
+//  Author A.Morsch
 
-class TObjArray;
 class TClonesArray;
-class TParticle;
-class AliHeader;
 class TFile;
+class TObjArray;
+class TParticle;
+class TString;
 class TTree;
+#include <TClonesArray.h>
+#include <TArrayI.h>
+#include <TVirtualMCStack.h>
 
+class AliHeader;
 
+enum {kKeepBit=1, kDaughtersBit=2, kDoneBit=4, kTransportBit=BIT(14)};
 
 class AliStack : public TVirtualMCStack
 {
   public:
     // creators, destructors
-    AliStack(Int_t size);
+    AliStack(Int_t size, const char* name = "");
     AliStack();
+    AliStack(const AliStack& st);
     virtual ~AliStack();
+    AliStack& operator=(const AliStack& st)
+      {st.Copy(*this); return(*this);}
 
     // methods
-    virtual void  SetTrack(Int_t done, Int_t parent, Int_t pdg, 
-                     Float_t *pmom, Float_t *vpos, Float_t *polar, 
-                      Float_t tof, TMCProcess mech, Int_t &ntr,
-                      Float_t weight, Int_t is);
-    virtual void  SetTrack(Int_t done, 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);
-    virtual TParticle* GetNextTrack(Int_t& track);
-    virtual TParticle* GetPrimaryForTracking(Int_t i);    
-
-    void  MakeTree(Int_t event, const char *file);
-    void  BeginEvent(Int_t event);
-    void  FinishRun();
-    Bool_t GetEvent(Int_t nevent);
-    void  PurifyKine();
-    void  FinishEvent();
-    void  FlagTrack(Int_t track);
-    void  KeepTrack(Int_t itrack); 
-    void  Reset(Int_t size = 0);
-    void  DumpPart(Int_t i) const;
-    void  DumpPStack ();
-    void  DumpLoadedStack () const;
+
+    virtual void  PushTrack(Int_t done, Int_t parent, Int_t pdg, 
+                           Float_t *pmom, Float_t *vpos, Float_t *polar, 
+                           Float_t tof, TMCProcess mech, Int_t &ntr,
+                           Float_t weight, Int_t is);
+
+    virtual void  PushTrack(Int_t done, 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);
+
+    virtual TParticle* PopNextTrack(Int_t& track);
+    virtual TParticle* GetCurrentTrack() const {return fCurrentTrack;}
+    virtual TParticle* PopPrimaryForTracking(Int_t i);    
+
+    void   ConnectTree(TTree* tree);
+    Bool_t GetEvent();
+    Bool_t PurifyKine();
+    Bool_t ReorderKine();
+    void   FinishEvent();
+    void   FlagTrack(Int_t track);
+    void   KeepTrack(Int_t itrack); 
+    void   Clean(Int_t size = 0);
+    void   Reset(Int_t size = 0);
+    void   DumpPart(Int_t i) const;
+    void   DumpPStack ();
+    void   DumpLoadedStack () const;
 
     // set methods
     void  SetNtrack(Int_t ntrack);
@@ -62,11 +72,17 @@ class AliStack : public TVirtualMCStack
     // get methods
     virtual Int_t GetNtrack() const;
     Int_t       GetNprimary() const;
-    virtual Int_t CurrentTrack() const;
-    TObjArray*  Particles() const;
+    virtual Int_t GetCurrentTrackNumber() const;
+    virtual Int_t GetCurrentParentTrackNumber() const;
     TParticle*  Particle(Int_t id);
     Int_t       GetPrimary(Int_t id);
-    TTree*      TreeK() const {return fTreeK;}
+    TTree*      TreeK();
+    TParticle*  ParticleFromTreeK(Int_t id) const;
+    Int_t       TreeKEntry(Int_t id) const;
+    Bool_t      IsPhysicalPrimary(Int_t i);
+    Int_t       TrackLabel(Int_t label) {return fTrackLabelMap[label];}
+    Int_t*      TrackLabelMap() {return fTrackLabelMap.GetArray();}
+    const TObjArray*  Particles() const;
     
   protected:
     // methods
@@ -74,13 +90,16 @@ class AliStack : public TVirtualMCStack
     void  ResetArrays(Int_t size);
     TParticle* GetNextParticle();
     Bool_t KeepPhysics(TParticle* part);
-    
+    Bool_t IsStable(Int_t pdg) const;
   private:
+    void Copy(TObject &st) const;
+
     // data members
-    TClonesArray  *fParticles;         //! Pointer to list of particles
-    TObjArray     *fParticleMap;       //! Map of particles in the supporting TClonesArray
+    TClonesArray   fParticles;         //! Pointer to list of particles
+    TObjArray      fParticleMap;       //! Map of particles in the supporting TClonesArray
     TArrayI        fParticleFileMap;   //  Map for particle ids 
     TParticle     *fParticleBuffer;    //! Pointer to current particle for writing
+    TParticle     *fCurrentTrack;      //! Pointer to particle currently transported
     TTree         *fTreeK;             //! Particle stack  
     Int_t          fNtrack;            //  Number of tracks
     Int_t          fNprimary;          //  Number of primaries
@@ -88,8 +107,8 @@ class AliStack : public TVirtualMCStack
     Int_t          fCurrentPrimary;    //! Last primary track returned from the stack
     Int_t          fHgwmk;             //! Last track purified
     Int_t          fLoadPoint;         //! Next free position in the particle buffer
-    
-    ClassDef(AliStack,3) //Particles stack
+    TArrayI        fTrackLabelMap;     //! Map of track labels
+    ClassDef(AliStack,5) //Particles stack
 };
 
 // inline
@@ -106,10 +125,10 @@ inline Int_t AliStack::GetNtrack() const
 inline Int_t AliStack::GetNprimary() const
 { return fNprimary; }
 
-inline Int_t AliStack::CurrentTrack() const 
+inline Int_t AliStack::GetCurrentTrackNumber() const 
 { return fCurrent; }
 
-inline TObjArray* AliStack::Particles() const
-{ return fParticleMap; }
+inline const TObjArray* AliStack::Particles() const
+{ return &fParticleMap; }
 
 #endif //ALI_STACK_H