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