]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TUHKMgen/UHKM/Particle.h
Change ... in order to be able to redo the matching with AODs we need to store the...
[u/mrichter/AliRoot.git] / TUHKMgen / UHKM / Particle.h
1 //                                                                            
2 //                                                                            
3 //        Nikolai Amelin, Ludmila Malinina, Timur Pocheptsov (C) JINR/Dubna
4 //      amelin@sunhe.jinr.ru, malinina@sunhe.jinr.ru, pocheptsov@sunhe.jinr.ru 
5 //                           November. 2, 2005                                
6 //
7 //
8
9 #ifndef PARTICLE_H
10 #define PARTICLE_H
11
12 #include <list>
13 #include <iostream>
14 using namespace std;
15
16 #include <TLorentzRotation.h>
17 #include <TLorentzVector.h>
18 #include <TVector3.h>
19 #include "ParticlePDG.h"
20
21 class Particle {
22  public:
23   Particle(const TLorentzVector &, const TLorentzVector &);
24   Particle(const Particle& copy);
25   Particle& operator=(const Particle&);
26   virtual ~Particle() {};
27   Particle(ParticlePDG *pdg = 0);
28   Particle(ParticlePDG *pdg, const TLorentzVector &pos, const TLorentzVector &mom,
29            Double_t lastInterTime = 0., Int_t lastInterNum = 0, Int_t type=0);
30   Particle(ParticlePDG *pdg, const TLorentzVector &pos, const TLorentzVector &mom,
31            Double_t lastInterTime, Int_t lastInterNum, Int_t type, Int_t motherPdg, 
32            const TLorentzVector &motherPos, const TLorentzVector &motherMom);
33
34   Double_t X()const{return fPosition.X();}
35   Double_t X(Double_t val){fPosition.SetX(val); return val;}
36   Double_t Y()const{return fPosition.Y();}
37   Double_t Y(Double_t val){fPosition.SetY(val); return val;}
38   Double_t Z()const{return fPosition.Z();}
39   Double_t Z(Double_t val){fPosition.SetZ(val); return val;}
40   Double_t T()const{return fPosition.T();}
41   Double_t T(Double_t val){fPosition.SetT(val); return val;}
42   Double_t Px()const{return fMomentum.Px();}
43   Double_t Px(Double_t val){fMomentum.SetPx(val); return val;}
44   Double_t Py()const{return fMomentum.Py();}
45   Double_t Py(Double_t val){fMomentum.SetPy(val); return val;}
46   Double_t Pz()const{return fMomentum.Pz();}
47   Double_t Pz(Double_t val){fMomentum.SetPz(val); return val;}
48   Double_t E()const{return fMomentum.E();}
49   Double_t E(Double_t val){fMomentum.SetE(val); return val;}
50
51   TLorentzVector &Pos(){return fPosition;}
52   const TLorentzVector &Pos()const{return fPosition;}
53   TLorentzVector &Pos(const TLorentzVector &val){return fPosition = val;}
54   TLorentzVector &Mom(){return fMomentum;}
55   const TLorentzVector &Mom()const{return fMomentum;}
56   TLorentzVector &Mom(const TLorentzVector &val){return fMomentum = val;}
57
58   void SetDecayed() {fDecayed = kTRUE;}
59   Bool_t GetDecayed() const {return fDecayed;}
60                 
61   void Boost(const TVector3 &val){fMomentum.Boost(val);}
62   void Boost(const TLorentzVector &val){fMomentum.Boost(val.BoostVector());}
63   void TransformMomentum(const TRotation &rotator){fMomentum *= rotator;}
64   void TransformPosition(const TRotation &rotator){fPosition *= rotator;}
65   void Shift(const TVector3 &val){fPosition += TLorentzVector(val, 0.);}
66
67   //Pseudorapidity
68   Double_t Eta ()const;
69   //Rapidity
70   Double_t Rapidity()const;
71   Double_t Phi()const;
72   Double_t Theta()const;
73   Double_t Pt()const;
74
75   Int_t Encoding() const;
76   Double_t TableMass() const;
77   ParticlePDG* Def() const {return fParticleProperties;}
78   void Def(ParticlePDG *newProp) {fParticleProperties = newProp;}
79   //mother   
80   void SetLastMotherPdg(Int_t value){fLastMotherPdg = value;}
81   Int_t GetLastMotherPdg() const {return fLastMotherPdg;}
82
83   // aic(2008/08/08): functions added in order to enable tracking of mother/daughter particles by a unique index
84   // The index coincides with the position of the particle in the secondaries list.
85   Int_t SetIndex() {
86     fIndex = ++fgLastIndex; 
87     return fIndex;
88   }
89   Int_t GetIndex() const {return fIndex;}
90   static Int_t GetLastIndex() {return fgLastIndex;}
91   static void InitIndexing() {
92     fgLastIndex = -1;
93   }
94   void SetMother(Int_t value) {fMotherIndex = value;}
95   Int_t GetMother() const {return fMotherIndex;}
96   void SetFirstDaughterIndex(Int_t index) {fFirstDaughterIndex = index;}
97   void SetLastDaughterIndex(Int_t index) {fLastDaughterIndex = index;}
98   void SetPythiaStatusCode(Int_t code) {fPythiaStatusCode = code;}
99   Int_t GetPythiaStatusCode() const {return fPythiaStatusCode;}
100
101   Int_t GetNDaughters() const {
102     if(fFirstDaughterIndex==-1 || fLastDaughterIndex==-1) return 0;
103     else return fLastDaughterIndex-fFirstDaughterIndex+1;
104   }
105   Int_t GetFirstDaughterIndex() const {return fFirstDaughterIndex;}
106   Int_t GetLastDaughterIndex() const {return fLastDaughterIndex;}
107
108   TLorentzVector &SetLastMotherDecayCoor(const TLorentzVector &val){return fLastMotherDecayCoor = val;}
109   const TLorentzVector &GetLastMotherDecayCoor()const{return fLastMotherDecayCoor;}
110   TLorentzVector &SetLastMotherDecayMom(const TLorentzVector &val){return fLastMotherDecayMom = val;}
111   const TLorentzVector &GetLastMotherDecayMom()const{return fLastMotherDecayMom;}
112
113   void SetLastInterTime(Double_t value){fLastInteractionTime = value;}
114   Double_t GetLastInterTime()const{return fLastInteractionTime;}
115   void SetLastInterNumber(Int_t value){fInteractionNumber = value;}
116   Int_t GetLastInterNumber()const{return fInteractionNumber;}
117   void IncInter(){++fInteractionNumber;}
118
119   void SetType(Int_t value){fType = value;}
120   Int_t GetType()const{return fType;}
121
122  protected:
123   TLorentzVector   fPosition;               // 4-position vector
124   TLorentzVector   fMomentum;               // 4-momentum vector
125   TLorentzVector   fLastMotherDecayCoor;    // 4-position vector of mother 
126   TLorentzVector   fLastMotherDecayMom;     // 4-momentum vector of mother
127   ParticlePDG     *fParticleProperties;     // particle PDG properties
128   Double_t         fLastInteractionTime;    // last interaction time
129   Int_t            fInteractionNumber;      // interaction number
130   Int_t            fPythiaStatusCode;       // PYTHIA status code
131   Int_t            fLastMotherPdg;          // mother's PDG code
132   Int_t            fType;                   // particle type: 0-hydro, 1-jets
133   Int_t            fIndex;                    // index (0 based) of particle in the final particle list which will contain both primaries and secondaries
134   Int_t            fMotherIndex;              // index of the mother (-1 if its a primary particle)
135   Int_t            fNDaughters;               // number of daughter particles (0 if the particle had not decayed)
136   Int_t            fFirstDaughterIndex;       // index for the first daughter particle (-1 if non-existing)
137   Int_t            fLastDaughterIndex;        // index for the last daughter particle (-1 if non-existing)
138   Bool_t           fDecayed;                  // true if the decay procedure already applied
139   static Int_t     fgLastIndex;                // the last index assigned
140 };
141
142 Double_t S(const TLorentzVector &, const TLorentzVector &);
143 Double_t T(const TLorentzVector &, const TLorentzVector &);
144
145 typedef std::list<Particle> List_t;
146 typedef std::list<Particle>::iterator LPIT_t;
147
148 class ParticleAllocator {
149  public:
150   ParticleAllocator() : fFreeNodes() {};
151   void AddParticle(const Particle & particle, List_t & list);
152   void FreeListNode(List_t & list, LPIT_t it);
153   void FreeList(List_t & list);
154
155  private:
156   List_t fFreeNodes;          // list
157 };
158
159 #endif