Bug Correction
[u/mrichter/AliRoot.git] / ANALYSIS / AliAODPair.h
CommitLineData
78d7c6d3 1#ifndef AliAODPair_H
2#define AliAODPair_H
3//_________________________________________________________________________
4///////////////////////////////////////////////////////////////////////////
5//
6// class AliAODPair
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////////////////////////////////////////////////////////////////////////////
13
14#include <TObject.h>
15#include "AliVAODParticle.h"
16
17
18class AliAODPair: public TObject
19{
20 public:
21 AliAODPair(Bool_t rev = kFALSE); //contructor
22 AliAODPair(AliVAODParticle* part1, AliVAODParticle* part2, Bool_t rev = kFALSE); //contructor
23 AliAODPair(const AliAODPair& in);
24
25 virtual ~AliAODPair(){}
26
27 AliAODPair& operator=(const AliAODPair& in);
28
29 void SetParticles(AliVAODParticle* p1,AliVAODParticle* p2); //sets particles in the pair
30 AliAODPair* GetSwappedPair() {return fSwappedPair;} //returns pair with swapped particles
31
32 AliVAODParticle* Particle1() const {return fPart1;} //returns pointer to first particle
33 AliVAODParticle* Particle2() const {return fPart2;} //returns pointer to decond particle
34
35 virtual void Changed();
36 //Center Mass System - Longitudinally Comoving
37
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 GetQSideLCMS(); //returns Q Side CMS longitudionally co-moving
42 virtual Double_t GetQOutLCMS(); //returns Q out CMS longitudionally co-moving
43 virtual Double_t GetQLongLCMS(); //returns Q Long CMS longitudionally co-moving
f422a7da 44 virtual Double_t GetQtLCMS(); //returns Q transverse CMS longitudionally co-moving
45
78d7c6d3 46
47
48 virtual Double_t GetKt(); //returns K transverse
49 virtual Double_t GetKStar();
50
51 virtual Double_t GetAvarageDistance();//returns avarage distnace between two tracks
52
53 virtual Double_t GetDeltaP(); //return difference of momenta
54 virtual Double_t GetDeltaPt();
55 virtual Double_t GetDeltaPx();
56 virtual Double_t GetDeltaPy();
57 virtual Double_t GetDeltaPz();
58
59 virtual Double_t GetDeltaTheta();
60 virtual Double_t GetDeltaPhi();
61
62 virtual Double_t GetGammaToLCMS();
63 virtual Double_t GetPIDProb() const {return fPart1->GetPidProb()*fPart2->GetPidProb();}
64
65 protected:
66 AliVAODParticle* fPart1; //pointer to first particle
67 AliVAODParticle* fPart2; //pointer to second particle
68
69 AliAODPair* fSwappedPair; //pointer to swapped pair
70
71/************************************************************/
72/************CMS (LC) Q's *********************************/
73/************************************************************/
74 //Center Mass System - Longitudinally Comoving
75
76 Double_t fQSideLCMS; //value of Q side CMS longitudially co-moving
77 Bool_t fQSideLCMSNotCalc; //flag indicating if fQSideLCMS is already calculated for this pair
78
79 Double_t fQOutLCMS; //value of Q out CMS longitudially co-moving
80 Bool_t fQOutLCMSNotCalc;//flag indicating if fQOutLCMS is already calculated for this pair
81
82 Double_t fQLongLCMS; //value of Q long CMS longitudially co-moving
83 Bool_t fQLongLCMSNotCalc;//flag indicating if fQLongLCMS is already calculated for this pair
f422a7da 84
85 Double_t fQtLCMS; //value of Q long CMS longitudially co-moving
86 Bool_t fQtLCMSNotCalc;//flag indicating if fQLongLCMS is already calculated for this pair
78d7c6d3 87/************************************************************/
88/************************************************************/
89 Double_t fQInv; //half of differnece of 4-momenta
90 Bool_t fQInvNotCalc;//flag indicating if fQInv is already calculated for this pair
91
92 Double_t fInvMass; //invariant mass
93 Bool_t fInvMassNotCalc;//flag indicating if fInvMass is already calculated for this pair
94
95 Double_t fKt; //K == sum vector of particle's momenta. Kt transverse component
96 Bool_t fKtNotCalc;//flag indicating if fKt is already calculated for this pair
97
98 Double_t fKStar; // KStar
99 Bool_t fKStarNotCalc;// flag indicating if fKStar is calculated
100
101 Double_t fPInv; //invariant momentum
102
103 Double_t fQSide; //Q Side
104 Double_t fOut;//Q Out
105 Double_t fQLong;//Q Long
106
107 Double_t fMt;//Transverse coordinate of Inv. Mass
108 Bool_t fMtNotCalc;//flag indicating if Mt is calculated for current pair
109
110 Double_t fInvMassSqr;//squre of invariant mass
111 Bool_t fMassSqrNotCalc; //flag indicating if fInvMassSqr for this pair
112 void CalculateInvMassSqr();
113
114 Double_t fQInvL; //Qinv in longitudional direction
115 Bool_t fQInvLNotCalc;//flag indicating if fQInvL is calculated for current pair
116 void CalculateQInvL();
117
118 Double_t fAvarageDistance;//value of the avarage distance calculated out of track points
119 Bool_t fAvarageDistanceNotCalc;//flag indicating if the avarage distance is calculated
120
121 Double_t fPxSum;// Sum of Px momenta
122 Double_t fPySum;// Sum of Py momenta
123 Double_t fPzSum;// Sum of Pz momenta
124 Double_t fESum;// Sum of energies
125 Bool_t fSumsNotCalc;//flag indicating if fPxSum,fPxSum,fPxSum and fESum is calculated for current pair
126 void CalculateSums();
127
128 Double_t fPxDiff;// Difference of Px momenta
129 Double_t fPyDiff;// Difference of Px momenta
130 Double_t fPzDiff;// Difference of Px momenta
131 Double_t fEDiff;// Difference of Px momenta
132 Bool_t fDiffsNotCalc;//flag indicating if fPxDiff,fPxDiff,fPxDiff and fEDiff is calculated for current pair
133 void CalculateDiffs();
134
135 Double_t fGammaLCMS;//gamma of boost in LCMS
136 Bool_t fGammaLCMSNotCalc;//flag indicating if fGammaLCMS is calculated for current pair
137 /***************************************************/
138 Bool_t fChanged;//flag indicating if object has been changed
139
140 void CalculateBase();
141 Double_t AvDistance();
142
143
144 private:
145 ClassDef(AliAODPair,1)
146};
147/****************************************************************/
148inline
149void AliAODPair::SetParticles(AliVAODParticle* p1,AliVAODParticle* p2)
150{
151 //sets the particle to the pair
152
153 fPart1 = p1;
154 fPart2 = p2;
155 if (fSwappedPair) //if we have Swapped (so we are not)
156 fSwappedPair->SetParticles(p2,p1); //set particles for him too
157 Changed();
158 //and do nothing until will be asked for
159}
160/****************************************************************/
161
162inline
163void AliAODPair::Changed()
164{
165 // Resel all calculations (flags)
166 fChanged = kTRUE;
167 fSumsNotCalc = kTRUE;
168 fDiffsNotCalc = kTRUE;
169 fMassSqrNotCalc = kTRUE;
170 fInvMassNotCalc = kTRUE;
171 fQInvNotCalc = kTRUE;
172 fMtNotCalc = kTRUE;
173 fQSideLCMSNotCalc = kTRUE;
174 fQOutLCMSNotCalc = kTRUE;
175 fQLongLCMSNotCalc = kTRUE;
176 fKtNotCalc = kTRUE;
177 fKStarNotCalc = kTRUE;
178 fQInvLNotCalc = kTRUE;
179 fGammaLCMSNotCalc = kTRUE;
180 fAvarageDistanceNotCalc = kTRUE;
181}
182/****************************************************************/
183inline
184void AliAODPair::CalculateInvMassSqr()
185 {
186 //calculates square of qinv
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 AliAODPair::CalculateQInvL()
201 {
202 //Calculates square root of Qinv
203 if (fQInvLNotCalc)
204 {
205 CalculateDiffs();
206 fQInvL = fEDiff*fEDiff - ( fPxDiff*fPxDiff + fPyDiff*fPyDiff + fPzDiff*fPzDiff );
207 fQInvLNotCalc = kFALSE;
208 }
209 }
210/****************************************************************/
211inline
212void AliAODPair::CalculateSums()
213 {
214 //calculates momenta and energy sums
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->E() + fPart2->E();
221 fSumsNotCalc = kFALSE;
222 }
223 }
224/****************************************************************/
225inline
226void AliAODPair::CalculateDiffs()
227 {
228 //calculates momenta and energy differences
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->E() - fPart2->E();
235 fDiffsNotCalc = kFALSE;
236 }
237 }
238
239/****************************************************************/
240inline
241Double_t AliAODPair::GetDeltaP() //return difference of momenta
242{
243 //returns difference of momenta (length of vector)
244 CalculateDiffs();
245 return TMath::Sqrt(fPxDiff*fPxDiff + fPyDiff*fPyDiff + fPzDiff*fPzDiff);
246}
247/****************************************************************/
248
249inline
250Double_t AliAODPair::GetDeltaPt()
251 {
252 //returns difference of Pz
253 return fPart1->Pt()-fPart2->Pt();
254 }
255/****************************************************************/
256
257inline
258Double_t AliAODPair::GetDeltaPx()
259 {
260 //returns difference of Pz
261 CalculateDiffs();
262 return fPxDiff;
263 }
264/****************************************************************/
265inline
266Double_t AliAODPair::GetDeltaPy()
267 {
268 //returns difference of Py
269 CalculateDiffs();
270 return fPyDiff;
271 }
272
273/****************************************************************/
274inline
275Double_t AliAODPair::GetDeltaPz()
276 {
277 //returns difference of Pz
278 CalculateDiffs();
279 return fPzDiff;
280 }
281/****************************************************************/
282
283inline
284Double_t AliAODPair::GetDeltaPhi()
285 {
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 {
294 phi1-=TMath::TwoPi();
295 }
296 else
297 {
298 phi2-=TMath::TwoPi();
299 }
300 diff = phi1-phi2;
301 }
302 return diff;
303 }
304/****************************************************************/
305
306inline
307Double_t AliAODPair::GetDeltaTheta()
308 {
309 //returns difference of Theta
310 return fPart1->Theta()-fPart2->Theta();
311 }
312/****************************************************************/
313
314
315#endif