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