Bug corrected in DeltaPhi
[u/mrichter/AliRoot.git] / HBTAN / AliHBTPair.h
CommitLineData
1b446896 1#ifndef ALIHBTPAIR_H
2#define ALIHBTPAIR_H
58ee8590 3//_________________________________________________________________________
4///////////////////////////////////////////////////////////////////////////
5//
6// class AliHBTPair
7//
8// class implements pair of particles and taking care of caluclation (almost)
9// all of pair properties (Qinv, InvMass,...)
10// more info: http://alisoft.cern.ch/people/skowron/analyzer/index.html
11//
12////////////////////////////////////////////////////////////////////////////
1b446896 13
14#include <TObject.h>
1b446896 15#include "AliHBTParticle.h"
58ee8590 16
1b446896 17
18class AliHBTPair: public TObject
19{
20 public:
21 AliHBTPair(Bool_t rev = kFALSE); //contructor
ec6e4013 22 AliHBTPair(AliHBTParticle* part1, AliHBTParticle* part2, Bool_t rev = kFALSE); //contructor
d012b7d0 23 AliHBTPair(const AliHBTPair& in);
24
4ca0f301 25 virtual ~AliHBTPair(){}
d012b7d0 26
34914285 27 AliHBTPair& operator=(const AliHBTPair& in);
d012b7d0 28
29 void SetParticles(AliHBTParticle* p1,AliHBTParticle* p2); //sets particles in the pair
1b446896 30 AliHBTPair* GetSwapedPair() {return fSwapedPair;} //returns pair with swapped particles
31
32 AliHBTParticle* Particle1() const {return fPart1;} //returns pointer to first particle
33 AliHBTParticle* Particle2() const {return fPart2;} //returns pointer to decond particle
34
ec6e4013 35 void Changed();
1b446896 36 //Center Mass System - Longitudinally Comoving
37
951aadb9 38 virtual Double_t GetInvMass(); //returns invariant mass of the pair
39 virtual Double_t GetMt();
40 virtual Double_t GetQInv(); //returns Q invariant
41 virtual Double_t GetQSideCMSLC(); //returns Q Side CMS longitudionally co-moving
42 virtual Double_t GetQOutCMSLC(); //returns Q out CMS longitudionally co-moving
43 virtual Double_t GetQLongCMSLC(); //returns Q Long CMS longitudionally co-moving
1b446896 44
45
951aadb9 46 virtual Double_t GetKt(); //returns K transverse
47 virtual Double_t GetKStar();
1b446896 48
087f87e7 49 virtual Double_t GetAvarageDistance();//returns avarage distnace between two tracks
50
951aadb9 51 virtual Double_t GetDeltaP(); //return difference of momenta
e4eb7775 52 virtual Double_t GetDeltaPt();
951aadb9 53 virtual Double_t GetDeltaPx();
54 virtual Double_t GetDeltaPy();
55 virtual Double_t GetDeltaPz();
1b446896 56
e4eb7775 57 virtual Double_t GetDeltaTheta();
58 virtual Double_t GetDeltaPhi();
59
951aadb9 60 virtual Double_t GetGammaToCMSLC();
becde6ce 61 virtual Double_t GetWeight();
62 virtual Double_t GetPIDProb() const {return fPart1->GetPidProb()*fPart2->GetPidProb();}
63
1b446896 64 protected:
65 AliHBTParticle* fPart1; //pointer to first particle
66 AliHBTParticle* fPart2; //pointer to second particle
67
68 AliHBTPair* fSwapedPair; //pointer to swapped pair
69
70/************************************************************/
71/************CMS (LC) Q's *********************************/
72/************************************************************/
73 //Center Mass System - Longitudinally Comoving
74
75 Double_t fQSideCMSLC; //value of Q side CMS longitudially co-moving
76 Bool_t fQSideCMSLCNotCalc; //flag indicating if fQSideCMSLC is already calculated for this pair
77
78 Double_t fQOutCMSLC; //value of Q out CMS longitudially co-moving
79 Bool_t fQOutCMSLCNotCalc;//flag indicating if fQOutCMSLC is already calculated for this pair
80
81 Double_t fQLongCMSLC; //value of Q long CMS longitudially co-moving
82 Bool_t fQLongCMSLCNotCalc;//flag indicating if fQLongCMSLC is already calculated for this pair
83/************************************************************/
84/************************************************************/
85 Double_t fQInv; //half of differnece of 4-momenta
86 Bool_t fQInvNotCalc;//flag indicating if fQInv is already calculated for this pair
87
88 Double_t fInvMass; //invariant mass
89 Bool_t fInvMassNotCalc;//flag indicating if fInvMass is already calculated for this pair
90
91 Double_t fKt; //K == sum vector of particle's momenta. Kt transverse component
92 Bool_t fKtNotCalc;//flag indicating if fKt is already calculated for this pair
93
d012b7d0 94 Double_t fKStar; // KStar
95 Bool_t fKStarNotCalc;// flag indicating if fKStar is calculated
1b446896 96
97 Double_t fPInv; //invariant momentum
951aadb9 98
1b446896 99 Double_t fQSide; //Q Side
100 Double_t fOut;//Q Out
101 Double_t fQLong;//Q Long
102
951aadb9 103 Double_t fMt;//Transverse coordinate of Inv. Mass
58ee8590 104 Bool_t fMtNotCalc;//flag indicating if Mt is calculated for current pair
951aadb9 105
1b446896 106 Double_t fInvMassSqr;//squre of invariant mass
d012b7d0 107 Bool_t fMassSqrNotCalc; //flag indicating if fInvMassSqr for this pair
1b446896 108 void CalculateInvMassSqr();
109
58ee8590 110 Double_t fQInvL; //Qinv in longitudional direction
111 Bool_t fQInvLNotCalc;//flag indicating if fQInvL is calculated for current pair
1b446896 112 void CalculateQInvL();
47d9a058 113
58ee8590 114 Double_t fWeight;//Value of the weight
115 Bool_t fWeightNotCalc;//flag indicating if fWeight is calculated for current pair
116
6d7ee019 117 Double_t fAvarageDistance;//value of the avarage distance calculated out of track points
118 Bool_t fAvarageDistanceNotCalc;//flag indicating if the avarage distance is calculated
119
58ee8590 120 Double_t fPxSum;// Sum of Px momenta
121 Double_t fPySum;// Sum of Py momenta
122 Double_t fPzSum;// Sum of Pz momenta
123 Double_t fESum;// Sum of energies
124 Bool_t fSumsNotCalc;//flag indicating if fPxSum,fPxSum,fPxSum and fESum is calculated for current pair
1b446896 125 void CalculateSums();
126
58ee8590 127 Double_t fPxDiff;// Difference of Px momenta
128 Double_t fPyDiff;// Difference of Px momenta
129 Double_t fPzDiff;// Difference of Px momenta
130 Double_t fEDiff;// Difference of Px momenta
131 Bool_t fDiffsNotCalc;//flag indicating if fPxDiff,fPxDiff,fPxDiff and fEDiff is calculated for current pair
1b446896 132 void CalculateDiffs();
133
58ee8590 134 Double_t fGammaCMSLC;//gamma of boost in CMSLC
135 Bool_t fGammaCMSLCNotCalc;//flag indicating if fGammaCMSLC is calculated for current pair
1b446896 136 /***************************************************/
6d7ee019 137 Bool_t fChanged;//flag indicating if object has been changed
138
139 void CalculateBase();
140 Double_t AvDistance();
1b446896 141
142
143 private:
1b446896 144 ClassDef(AliHBTPair,1)
145};
146/****************************************************************/
147inline
148void AliHBTPair::SetParticles(AliHBTParticle* p1,AliHBTParticle* p2)
149{
150 //sets the particle to the pair
151
152 fPart1 = p1;
153 fPart2 = p2;
154 if (fSwapedPair) //if we have Swaped (so we are not)
155 fSwapedPair->SetParticles(p2,p1); //set particles for him too
ec6e4013 156 Changed();
157 //and do nothing until will be asked for
158}
159/****************************************************************/
1b446896 160
ec6e4013 161inline
162void AliHBTPair::Changed()
163{
164 // Resel all calculations (flags)
1b446896 165 fChanged = kTRUE;
166 fSumsNotCalc = kTRUE;
167 fDiffsNotCalc = kTRUE;
168 fMassSqrNotCalc = kTRUE;
169 fInvMassNotCalc = kTRUE;
170 fQInvNotCalc = kTRUE;
951aadb9 171 fMtNotCalc = kTRUE;
1b446896 172 fQSideCMSLCNotCalc = kTRUE;
173 fQOutCMSLCNotCalc = kTRUE;
174 fQLongCMSLCNotCalc = kTRUE;
175 fKtNotCalc = kTRUE;
176 fKStarNotCalc = kTRUE;
177 fQInvLNotCalc = kTRUE;
951aadb9 178 fGammaCMSLCNotCalc = kTRUE;
dd82cadc 179 fWeightNotCalc = kTRUE;
6d7ee019 180 fAvarageDistanceNotCalc = kTRUE;
1b446896 181}
182/****************************************************************/
1b446896 183inline
184void AliHBTPair::CalculateInvMassSqr()
185 {
58ee8590 186 //calculates square of qinv
1b446896 187 if (fMassSqrNotCalc)
188 {
189 CalculateSums();
190
191 Double_t fPart12s= (fPxSum*fPxSum) + (fPySum*fPySum) + (fPzSum*fPzSum);
192
193 fInvMassSqr=fESum*fESum-fPart12s;
194
195 fMassSqrNotCalc = kFALSE;
196 }
197 }
198/****************************************************************/
199inline
200void AliHBTPair::CalculateQInvL()
201 {
7836ee94 202 //Calculates square root of Qinv
1b446896 203 if (fQInvLNotCalc)
204 {
205 CalculateDiffs();
206 fQInvL = fEDiff*fEDiff - ( fPxDiff*fPxDiff + fPyDiff*fPyDiff + fPzDiff*fPzDiff );
207 fQInvLNotCalc = kFALSE;
208 }
209 }
210/****************************************************************/
211inline
212void AliHBTPair::CalculateSums()
213 {
58ee8590 214 //calculates momenta and energy sums
1b446896 215 if(fSumsNotCalc)
216 {
217 fPxSum = fPart1->Px()+fPart2->Px();
218 fPySum = fPart1->Py()+fPart2->Py();
219 fPzSum = fPart1->Pz()+fPart2->Pz();
220 fESum = fPart1->Energy() + fPart2->Energy();
221 fSumsNotCalc = kFALSE;
222 }
223 }
224/****************************************************************/
225inline
226void AliHBTPair::CalculateDiffs()
227 {
58ee8590 228 //calculates momenta and energy differences
1b446896 229 if(fDiffsNotCalc)
230 {
231 fPxDiff = fPart1->Px()-fPart2->Px();
232 fPyDiff = fPart1->Py()-fPart2->Py();
233 fPzDiff = fPart1->Pz()-fPart2->Pz();
234 fEDiff = fPart1->Energy() - fPart2->Energy();
235 fDiffsNotCalc = kFALSE;
236 }
237 }
238
7836ee94 239/****************************************************************/
240inline
241Double_t AliHBTPair::GetDeltaP() //return difference of momenta
242{
e4eb7775 243 //returns difference of momenta (length of vector)
7836ee94 244 CalculateDiffs();
245 return TMath::Sqrt(fPxDiff*fPxDiff + fPyDiff*fPyDiff + fPzDiff*fPzDiff);
246}
247/****************************************************************/
e4eb7775 248
249inline
250Double_t AliHBTPair::GetDeltaPt()
251 {
252 //returns difference of Pz
253 return fPart1->Pt()-fPart2->Pt();
254 }
255/****************************************************************/
256
7836ee94 257inline
258Double_t AliHBTPair::GetDeltaPx()
259 {
58ee8590 260 //returns difference of Pz
7836ee94 261 CalculateDiffs();
262 return fPxDiff;
263 }
264/****************************************************************/
265inline
266Double_t AliHBTPair::GetDeltaPy()
267 {
58ee8590 268 //returns difference of Py
7836ee94 269 CalculateDiffs();
270 return fPyDiff;
271 }
272
273/****************************************************************/
274inline
275Double_t AliHBTPair::GetDeltaPz()
276 {
58ee8590 277 //returns difference of Pz
7836ee94 278 CalculateDiffs();
279 return fPzDiff;
280 }
e4eb7775 281/****************************************************************/
282
283inline
284Double_t AliHBTPair::GetDeltaPhi()
285 {
eb890d59 286 //returns difference of Phi
287 Double_t phi1 = fPart1->Phi();
288 Double_t phi2 = fPart2->Phi();
289 Double_t diff = phi1-phi2;
290 if (TMath::Abs(diff) > TMath::Pi())
291 {
292 if (phi1 > TMath::Pi())
293 {
3ab81cf4 294 phi1-=TMath::TwoPi();
eb890d59 295 }
296 else
297 {
3ab81cf4 298 phi2-=TMath::TwoPi();
eb890d59 299 }
300 diff = phi1-phi2;
301 }
302 return diff;
e4eb7775 303 }
304/****************************************************************/
305
306inline
307Double_t AliHBTPair::GetDeltaTheta()
308 {
eb890d59 309 //returns difference of Theta
e4eb7775 310 return fPart1->Theta()-fPart2->Theta();
311 }
312/****************************************************************/
7836ee94 313
314
1b446896 315#endif