]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TUHKMgen/UHKM/Particle.h
42ffa5eab5e0e2d627885b7cc9b470fe98476bbb
[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_INCLUDED
10 #define PARTICLE_INCLUDED
11
12 #include <list>
13
14 #include <TLorentzRotation.h>
15 #include <TLorentzVector.h>
16 #include <TVector3.h>
17 #ifndef PARTICLE_PDG
18 #include "ParticlePDG.h"
19 #endif
20 #include <iostream>
21
22 //class ParticlePDG;
23
24 class Particle {
25  public:
26
27   Particle(const TLorentzVector &, const TLorentzVector &);
28  
29   Particle(const Particle& copy);
30   Particle& operator=(const Particle&);
31
32   virtual ~Particle() {};
33   Particle(ParticlePDG *pdg = 0);
34   Particle(ParticlePDG *pdg, const TLorentzVector &pos, const TLorentzVector &mom,
35            Double_t lastInterTime = 0., Int_t lastInterNum = 0, Int_t type=0);
36   Particle(ParticlePDG *pdg, const TLorentzVector &pos, const TLorentzVector &mom,
37            Double_t lastInterTime, Int_t lastInterNum, Int_t type, Int_t motherPdg, 
38            const TLorentzVector &motherPos, const TLorentzVector &motherMom);
39
40   Double_t X()const{return fPosition.X();}
41   Double_t X(Double_t val){fPosition.SetX(val); return val;}
42   Double_t Y()const{return fPosition.Y();}
43   Double_t Y(Double_t val){fPosition.SetY(val); return val;}
44   Double_t Z()const{return fPosition.Z();}
45   Double_t Z(Double_t val){fPosition.SetZ(val); return val;}
46   Double_t T()const{return fPosition.T();}
47   Double_t T(Double_t val){fPosition.SetT(val); return val;}
48   Double_t Px()const{return fMomentum.Px();}
49   Double_t Px(Double_t val){fMomentum.SetPx(val); return val;}
50   Double_t Py()const{return fMomentum.Py();}
51   Double_t Py(Double_t val){fMomentum.SetPy(val); return val;}
52   Double_t Pz()const{return fMomentum.Pz();}
53   Double_t Pz(Double_t val){fMomentum.SetPz(val); return val;}
54   Double_t E()const{return fMomentum.E();}
55   Double_t E(Double_t val){fMomentum.SetE(val); return val;}
56
57   TLorentzVector &Pos(){return fPosition;}
58   const TLorentzVector &Pos()const{return fPosition;}
59   TLorentzVector &Pos(const TLorentzVector &val){return fPosition = val;}
60   TLorentzVector &Mom(){return fMomentum;}
61   const TLorentzVector &Mom()const{return fMomentum;}
62   TLorentzVector &Mom(const TLorentzVector &val){return fMomentum = val;}
63                 
64   void Boost(const TVector3 &val){fMomentum.Boost(val);}
65   void Boost(const TLorentzVector &val){fMomentum.Boost(val.BoostVector());}
66   void TransformMomentum(const TRotation &rotator){fMomentum *= rotator;}
67   void TransformPosition(const TRotation &rotator){fPosition *= rotator;}
68   void Shift(const TVector3 &val){fPosition += TLorentzVector(val, 0.);}
69
70   //Pseudorapidity
71   Double_t Eta ()const;
72   //Rapidity
73   Double_t Rapidity()const;
74   Double_t Phi()const;
75   Double_t Theta()const;
76   Double_t Pt()const;
77
78   Int_t Encoding() const;
79   Double_t TableMass() const;
80   ParticlePDG *Def() const {return fParticleProperties;}
81   ParticlePDG *Def(ParticlePDG *newProp) {return fParticleProperties = newProp;}
82   //mother   
83   void SetLastMotherPdg(Int_t value){fLastMotherPdg = value;}
84   Int_t GetLastMotherPdg() const {return fLastMotherPdg;}
85
86   // aic(2008/08/08): functions added in order to enable tracking of mother/daughter particles by a unique index
87   // The index coincides with the position of the particle in the secondaries list.
88   Int_t SetIndex() {fIndex = ++fLastIndex; return fIndex;}
89   Int_t GetIndex() const {return fIndex;}
90   static Int_t GetLastIndex() {return fLastIndex;}
91   void InitIndexing() {fLastIndex = -1;}
92   void SetMother(Int_t value) {fMotherIndex = value;}
93   Int_t GetMother() const {return fMotherIndex;}
94   void SetDaughter(Int_t value) {
95     if(fNDaughters==3) {
96       std::cout << "Warning in Particle::SetDaughter() Already 3 daughters are set!! Check it out!!" << std::endl;
97       return;
98     }
99     fDaughterIndex[fNDaughters++] = value;
100   }
101   Int_t GetNDaughters() const {return fNDaughters;}
102   Int_t GetDaughter(Int_t value) const {
103     if(value<0 || value>fNDaughters-1) {
104       std::cout << "Warning in Particle::GetDaughter(Int_t) This particle has " << fNDaughters 
105                 << " daughters. The argument must range from 0 to " << fNDaughters-1 << std::endl;
106       return -1;
107     }
108     return fDaughterIndex[value];
109   }
110
111   // void SetLastMotherDecayCoor(TLorentzVector fLastMotherDecayCoor);
112   TLorentzVector &SetLastMotherDecayCoor(const TLorentzVector &val){return fLastMotherDecayCoor = val;}
113   const TLorentzVector &GetLastMotherDecayCoor()const{return fLastMotherDecayCoor;}
114   //  void SetLastMotherDecayMom(TLorentzVector fLastMotherDecayMom);
115   TLorentzVector &SetLastMotherDecayMom(const TLorentzVector &val){return fLastMotherDecayMom = val;}
116   const TLorentzVector &GetLastMotherDecayMom()const{return fLastMotherDecayMom;}
117
118   void SetLastInterTime(Double_t value){fLastInteractionTime = value;}
119   Double_t GetLastInterTime()const{return fLastInteractionTime;}
120   void SetLastInterNumber(Int_t value){fInteractionNumber = value;}
121   Int_t GetLastInterNumber()const{return fInteractionNumber;}
122   void IncInter(){++fInteractionNumber;}
123
124   void SetType(Int_t value){fType = value;}
125   Int_t GetType()const{return fType;}
126
127  protected:
128   TLorentzVector   fPosition;
129   TLorentzVector   fMomentum;
130   TLorentzVector   fLastMotherDecayCoor;
131   TLorentzVector   fLastMotherDecayMom;
132   ParticlePDG     *fParticleProperties;
133   Double_t         fLastInteractionTime;
134   Int_t            fInteractionNumber;
135   Int_t            fLastMotherPdg;
136   Int_t            fType; //0-hydro, 1-jets
137   Int_t            fIndex;                    // index (0 based) of particle in the final particle list which will contain both primaries and secondaries
138   Int_t            fMotherIndex;              // index of the mother (-1 if its a primary particle)
139   Int_t            fNDaughters;               // number of daughter particles (0 if the particle had not decayed)
140   Int_t            fDaughterIndex[3];         // array of indexes for the daughter particles (the indexes are -1 for non-existing daughters)
141   static Int_t     fLastIndex;                // the last index assigned
142
143 };
144
145 Double_t S(const TLorentzVector &, const TLorentzVector &);
146 Double_t T(const TLorentzVector &, const TLorentzVector &);
147
148 typedef std::list<Particle> List_t;
149 typedef std::list<Particle>::iterator LPIT_t;
150
151 class ParticleAllocator {
152  public:
153   void AddParticle(const Particle & particle, List_t & list);
154   void FreeListNode(List_t & list, LPIT_t it);
155   void FreeList(List_t & list);
156
157  private:
158   List_t fFreeNodes;
159 };
160
161 #endif