]> git.uio.no Git - u/mrichter/AliRoot.git/blame - ANALYSIS/AliAODPair.h
redirection and C++ streams added
[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
fb629e2d 46 virtual Double_t GetQt(); //returns Q transverse to Kt
78d7c6d3 47
48
49 virtual Double_t GetKt(); //returns K transverse
50 virtual Double_t GetKStar();
a40c0433 51 virtual Double_t GetKStarOut(); //z.ch.
52 virtual Double_t GetKStarSide(); //z.ch.
53 virtual Double_t GetKStarLong(); //z.ch.
78d7c6d3 54
a40c0433 55
78d7c6d3 56 virtual Double_t GetAvarageDistance();//returns avarage distnace between two tracks
57
b327f095 58 virtual Double_t GetDeltaE(); //return difference of Energies
59 virtual Double_t GetDeltaP(); //return difference of momenta (scalar difference)
60 virtual Double_t GetDeltaPvector(); //return legth of difference vector of momenta
78d7c6d3 61 virtual Double_t GetDeltaPt();
62 virtual Double_t GetDeltaPx();
63 virtual Double_t GetDeltaPy();
64 virtual Double_t GetDeltaPz();
65
66 virtual Double_t GetDeltaTheta();
67 virtual Double_t GetDeltaPhi();
68
69 virtual Double_t GetGammaToLCMS();
70 virtual Double_t GetPIDProb() const {return fPart1->GetPidProb()*fPart2->GetPidProb();}
71
72 protected:
73 AliVAODParticle* fPart1; //pointer to first particle
74 AliVAODParticle* fPart2; //pointer to second particle
75
76 AliAODPair* fSwappedPair; //pointer to swapped pair
77
78/************************************************************/
79/************CMS (LC) Q's *********************************/
80/************************************************************/
81 //Center Mass System - Longitudinally Comoving
82
83 Double_t fQSideLCMS; //value of Q side CMS longitudially co-moving
84 Bool_t fQSideLCMSNotCalc; //flag indicating if fQSideLCMS is already calculated for this pair
85
86 Double_t fQOutLCMS; //value of Q out CMS longitudially co-moving
87 Bool_t fQOutLCMSNotCalc;//flag indicating if fQOutLCMS is already calculated for this pair
88
89 Double_t fQLongLCMS; //value of Q long CMS longitudially co-moving
90 Bool_t fQLongLCMSNotCalc;//flag indicating if fQLongLCMS is already calculated for this pair
f422a7da 91
fb629e2d 92 Double_t fQtLCMS; //value of Qt CMS longitudially co-moving (hypot(qsidelcms,qoutlcms))
f422a7da 93 Bool_t fQtLCMSNotCalc;//flag indicating if fQLongLCMS is already calculated for this pair
fb629e2d 94
95 Double_t fQt; //value of Qt, projection of 3-mom diff to Kt
96 Bool_t fQtNotCalc;//flag indicating if fQt is already calculated for this pair
97
78d7c6d3 98/************************************************************/
99/************************************************************/
100 Double_t fQInv; //half of differnece of 4-momenta
101 Bool_t fQInvNotCalc;//flag indicating if fQInv is already calculated for this pair
102
103 Double_t fInvMass; //invariant mass
104 Bool_t fInvMassNotCalc;//flag indicating if fInvMass is already calculated for this pair
105
106 Double_t fKt; //K == sum vector of particle's momenta. Kt transverse component
107 Bool_t fKtNotCalc;//flag indicating if fKt is already calculated for this pair
108
109 Double_t fKStar; // KStar
110 Bool_t fKStarNotCalc;// flag indicating if fKStar is calculated
a40c0433 111 Double_t fKStarOut; // KStarOut z.ch.
112 Double_t fKStarSide;// KStarSide z.ch.
113 Double_t fKStarLong;// KStarLong z.ch.
114
115 Bool_t fKStarCompNotCalc; // flag indicating if CalcuteKStarComp() is calculated z.ch.
116
78d7c6d3 117 Double_t fPInv; //invariant momentum
118
119 Double_t fQSide; //Q Side
120 Double_t fOut;//Q Out
121 Double_t fQLong;//Q Long
122
123 Double_t fMt;//Transverse coordinate of Inv. Mass
124 Bool_t fMtNotCalc;//flag indicating if Mt is calculated for current pair
125
126 Double_t fInvMassSqr;//squre of invariant mass
127 Bool_t fMassSqrNotCalc; //flag indicating if fInvMassSqr for this pair
128 void CalculateInvMassSqr();
129
130 Double_t fQInvL; //Qinv in longitudional direction
131 Bool_t fQInvLNotCalc;//flag indicating if fQInvL is calculated for current pair
132 void CalculateQInvL();
133
134 Double_t fAvarageDistance;//value of the avarage distance calculated out of track points
135 Bool_t fAvarageDistanceNotCalc;//flag indicating if the avarage distance is calculated
136
137 Double_t fPxSum;// Sum of Px momenta
138 Double_t fPySum;// Sum of Py momenta
139 Double_t fPzSum;// Sum of Pz momenta
140 Double_t fESum;// Sum of energies
141 Bool_t fSumsNotCalc;//flag indicating if fPxSum,fPxSum,fPxSum and fESum is calculated for current pair
142 void CalculateSums();
a40c0433 143 void CalculateKStarComp();
78d7c6d3 144
145 Double_t fPxDiff;// Difference of Px momenta
146 Double_t fPyDiff;// Difference of Px momenta
147 Double_t fPzDiff;// Difference of Px momenta
148 Double_t fEDiff;// Difference of Px momenta
149 Bool_t fDiffsNotCalc;//flag indicating if fPxDiff,fPxDiff,fPxDiff and fEDiff is calculated for current pair
150 void CalculateDiffs();
151
152 Double_t fGammaLCMS;//gamma of boost in LCMS
153 Bool_t fGammaLCMSNotCalc;//flag indicating if fGammaLCMS is calculated for current pair
154 /***************************************************/
155 Bool_t fChanged;//flag indicating if object has been changed
156
157 void CalculateBase();
158 Double_t AvDistance();
159
160
161 private:
162 ClassDef(AliAODPair,1)
163};
164/****************************************************************/
165inline
166void AliAODPair::SetParticles(AliVAODParticle* p1,AliVAODParticle* p2)
167{
168 //sets the particle to the pair
169
170 fPart1 = p1;
171 fPart2 = p2;
172 if (fSwappedPair) //if we have Swapped (so we are not)
173 fSwappedPair->SetParticles(p2,p1); //set particles for him too
174 Changed();
175 //and do nothing until will be asked for
176}
177/****************************************************************/
178
179inline
180void AliAODPair::Changed()
181{
182 // Resel all calculations (flags)
183 fChanged = kTRUE;
184 fSumsNotCalc = kTRUE;
185 fDiffsNotCalc = kTRUE;
186 fMassSqrNotCalc = kTRUE;
187 fInvMassNotCalc = kTRUE;
188 fQInvNotCalc = kTRUE;
189 fMtNotCalc = kTRUE;
190 fQSideLCMSNotCalc = kTRUE;
191 fQOutLCMSNotCalc = kTRUE;
192 fQLongLCMSNotCalc = kTRUE;
fb629e2d 193 fQtLCMSNotCalc = kTRUE;
194 fQtNotCalc = kTRUE;
78d7c6d3 195 fKtNotCalc = kTRUE;
196 fKStarNotCalc = kTRUE;
a40c0433 197 fKStarCompNotCalc = kTRUE;
78d7c6d3 198 fQInvLNotCalc = kTRUE;
199 fGammaLCMSNotCalc = kTRUE;
200 fAvarageDistanceNotCalc = kTRUE;
201}
202/****************************************************************/
203inline
204void AliAODPair::CalculateInvMassSqr()
205 {
206 //calculates square of qinv
207 if (fMassSqrNotCalc)
208 {
209 CalculateSums();
210
211 Double_t fPart12s= (fPxSum*fPxSum) + (fPySum*fPySum) + (fPzSum*fPzSum);
212
213 fInvMassSqr=fESum*fESum-fPart12s;
214
215 fMassSqrNotCalc = kFALSE;
216 }
217 }
218/****************************************************************/
219inline
220void AliAODPair::CalculateQInvL()
221 {
222 //Calculates square root of Qinv
223 if (fQInvLNotCalc)
224 {
225 CalculateDiffs();
226 fQInvL = fEDiff*fEDiff - ( fPxDiff*fPxDiff + fPyDiff*fPyDiff + fPzDiff*fPzDiff );
227 fQInvLNotCalc = kFALSE;
228 }
229 }
230/****************************************************************/
231inline
232void AliAODPair::CalculateSums()
233 {
234 //calculates momenta and energy sums
235 if(fSumsNotCalc)
236 {
237 fPxSum = fPart1->Px()+fPart2->Px();
238 fPySum = fPart1->Py()+fPart2->Py();
239 fPzSum = fPart1->Pz()+fPart2->Pz();
240 fESum = fPart1->E() + fPart2->E();
241 fSumsNotCalc = kFALSE;
242 }
243 }
a40c0433 244/****************************************************************/
245inline
246void AliAODPair::CalculateKStarComp()
247{
248
249 if (fKStarCompNotCalc)
250 {
251 CalculateSums();
252
253 Double_t ptrans = fPxSum*fPxSum + fPySum*fPySum;
254 Double_t mtrans = fESum*fESum - fPzSum*fPzSum;
255 Double_t pinv = TMath::Sqrt(mtrans - ptrans);
256 ptrans = TMath::Sqrt(ptrans);
257 mtrans = TMath::Sqrt(mtrans);
258
259 Double_t px1 = fPart1->Px();
260 Double_t py1 = fPart1->Py();
261 Double_t pz1 = fPart1->Pz();
262 Double_t pE1 = fPart1->E();
263
264 // boost to LCMS
265 Double_t beta = fPzSum / fESum;
266 Double_t gamma = fESum / mtrans;
267
268 fKStarLong = gamma * (pz1 - beta * pE1);
269 double temp = gamma * (pE1 - beta * pz1);
270
271 // rotate in transverse plane
272 fKStarSide = (-px1*fPySum + py1*fPxSum)/ptrans;
273 fKStarOut = ( px1*fPxSum + py1*fPySum)/ptrans;
274
275 // go from LCMS to CMS
276 gamma = mtrans/pinv;
277 beta = ptrans/mtrans;
278 fKStarOut = gamma * (fKStarOut - beta * temp);
279
280 fKStarCompNotCalc = kFALSE;
281 }
282}
283
78d7c6d3 284/****************************************************************/
285inline
286void AliAODPair::CalculateDiffs()
287 {
288 //calculates momenta and energy differences
289 if(fDiffsNotCalc)
290 {
291 fPxDiff = fPart1->Px()-fPart2->Px();
292 fPyDiff = fPart1->Py()-fPart2->Py();
293 fPzDiff = fPart1->Pz()-fPart2->Pz();
294 fEDiff = fPart1->E() - fPart2->E();
295 fDiffsNotCalc = kFALSE;
296 }
297 }
298
299/****************************************************************/
b327f095 300
301inline
302Double_t AliAODPair::GetDeltaE()
303{
304 //returns difference of energies
305 return fPart1->E() - fPart2->E();
306}
307/****************************************************************/
308
309inline
310Double_t AliAODPair::GetDeltaP()
311{
312 //returns difference of momenta (scalars)
313 return fPart1->P() - fPart2->P();
314}
315/****************************************************************/
316
78d7c6d3 317inline
b327f095 318Double_t AliAODPair::GetDeltaPvector() //return difference of momenta
78d7c6d3 319{
b327f095 320 //returns legth of the momenta difference vector
78d7c6d3 321 CalculateDiffs();
322 return TMath::Sqrt(fPxDiff*fPxDiff + fPyDiff*fPyDiff + fPzDiff*fPzDiff);
323}
324/****************************************************************/
325
326inline
327Double_t AliAODPair::GetDeltaPt()
328 {
329 //returns difference of Pz
330 return fPart1->Pt()-fPart2->Pt();
331 }
332/****************************************************************/
333
334inline
335Double_t AliAODPair::GetDeltaPx()
336 {
337 //returns difference of Pz
338 CalculateDiffs();
339 return fPxDiff;
340 }
341/****************************************************************/
342inline
343Double_t AliAODPair::GetDeltaPy()
344 {
345 //returns difference of Py
346 CalculateDiffs();
347 return fPyDiff;
348 }
349
350/****************************************************************/
351inline
352Double_t AliAODPair::GetDeltaPz()
353 {
354 //returns difference of Pz
355 CalculateDiffs();
356 return fPzDiff;
357 }
358/****************************************************************/
359
360inline
361Double_t AliAODPair::GetDeltaPhi()
362 {
363 //returns difference of Phi
364 Double_t phi1 = fPart1->Phi();
365 Double_t phi2 = fPart2->Phi();
366 Double_t diff = phi1-phi2;
367 if (TMath::Abs(diff) > TMath::Pi())
368 {
369 if (phi1 > TMath::Pi())
370 {
371 phi1-=TMath::TwoPi();
372 }
373 else
374 {
375 phi2-=TMath::TwoPi();
376 }
377 diff = phi1-phi2;
378 }
379 return diff;
380 }
381/****************************************************************/
382
383inline
384Double_t AliAODPair::GetDeltaTheta()
385 {
386 //returns difference of Theta
387 return fPart1->Theta()-fPart2->Theta();
388 }
389/****************************************************************/
390
391
392#endif