]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWGCF/FLOW/Attic/AliFlowMaker.cxx
Merge branch 'feature-movesplit'
[u/mrichter/AliRoot.git] / PWGCF / FLOW / Attic / AliFlowMaker.cxx
1 //////////////////////////////////////////////////////////////////////
2 //
3 // $Id: AliFlowMaker.cxx 18618 2007-05-16 15:38:22Z snelling $
4 //
5 // Author: Emanuele Simili
6 //
7 //////////////////////////////////////////////////////////////////////
8 //_____________________________________________________________
9 //
10 // Description: 
11 //        AliFlowMaker provides the method to create AliFlowEvent(s) 
12 // from AliESD(s). Very basic track cuts are applyed.
13 // The present class can be used in a simple AliRoot macro or in a 
14 // more complex enviroment such as AliSelector or AliTask.
15 //
16 //////////////////////////////////////////////////////////////////////
17
18 #ifndef ALIFLOWMAKER_CXX
19 #define ALIFLOWMAKER_CXX
20
21 // ROOT things
22 #include <TROOT.h>
23 #include <TFile.h>
24 #include <TString.h>
25 #include <TMath.h>
26 #include "TClonesArray.h"
27
28 // AliRoot things
29 #include "AliESD.h"
30 #include "AliESDVertex.h"
31 #include "AliESDtrack.h"
32 #include "AliESDv0.h"
33 //#include "AliKalmanTrack.h"
34
35 // Flow things
36 #include "AliFlowEvent.h"
37 #include "AliFlowTrack.h"
38 #include "AliFlowV0.h"
39 #include "AliFlowConstants.h"
40 #include "AliFlowMaker.h"
41
42 // ANSI things
43 #include <stdlib.h>
44 #include <vector>
45
46 using namespace std; //required for resolving the 'cout' symbol
47
48 ClassImp(AliFlowMaker) 
49 //-----------------------------------------------------------------------
50 AliFlowMaker::AliFlowMaker():
51   fEventNumber(0), fTrackNumber(0), fV0Number(0), fGoodTracks(0), fGoodV0s(0),
52   fGoodTracksEta(0), fPosiTracks(0), fNegaTracks(0), fUnconstrained(0),
53   fSumAll(0), fCutEvts(0), fCutTrks(0), fCutV0s(0), fCounter(0), fMovedTr(0x0),
54   fNewAli(kFALSE), fLoopTrks(kTRUE), fLoopV0s(kTRUE),
55   fESD(0x0), fTrack(0x0), fV0(0x0), fVertex(0x0),
56   fRunID(0), fNumberOfEvents(0), fNumberOfTracks(0), 
57   fNumberOfV0s(0), fMagField(0), 
58   fFlowEvent(0x0), fFlowTrack(0x0), fFlowV0(0x0),
59   fNHits(0), fElow(0.001), fEup(1000.)
60 {
61  // default constructor 
62  // resets counters , sets defaults
63  
64  for(Int_t bb=0;bb<5;bb++) { fBayesianAll[bb] = 0 ; } ;
65
66  // trak cuts
67  fLabel[0] = 0 ; fLabel[1] = -1 ;
68 }
69 //-----------------------------------------------------------------------
70 AliFlowMaker::~AliFlowMaker()
71 {
72  // default destructor (no actions) 
73 }
74 //-----------------------------------------------------------------------
75
76 //-----------------------------------------------------------------------
77 AliFlowEvent* AliFlowMaker::FillFlowEvent(AliESD* fESD)
78 {
79  // From the AliESD (input) fills the AliFlowEvent (output) . 
80  // It loops on track & v0 and calls the methods to fill the arrays . 
81  // ... . 
82
83  fFlowEvent = new AliFlowEvent(10000) ; if(!fFlowEvent) { return 0 ; }
84  //cout << " -evt- " << fFlowEvent << endl ;
85
86  fRunID = fESD->GetRunNumber() ;
87  fEventNumber = -1 ;
88  // fEventNumber = fESD->GetEventNumber() ;
89  fNumberOfTracks = fESD->GetNumberOfTracks() ;
90  fNumberOfV0s = fESD->GetNumberOfV0s() ;
91  //
92  cout << " *evt n. " << fEventNumber << " (run " << fRunID << ")  -  tracks: " << fNumberOfTracks << " ,   v0s " << fNumberOfV0s << endl ;
93  
94  // Clean the vector of links esd-flowEvt
95  fMovedTr.clear(); // Remove all elements
96
97  // Event id 
98  fFlowEvent->SetRunID(fRunID) ;                
99  fFlowEvent->SetEventID(fEventNumber) ;         
100  fFlowEvent->SetOrigMult((UInt_t)fNumberOfTracks) ;
101
102  // Run information (fixed - ???)
103  fMagField = fESD->GetMagneticField() ; // cout << " *fMagField " << fMagField << endl ;
104  fFlowEvent->SetMagneticField(fMagField) ;      
105  fFlowEvent->SetCenterOfMassEnergy(AliFlowConstants::fgCenterOfMassEnergy) ;  
106  fFlowEvent->SetBeamMassNumberEast(AliFlowConstants::fgBeamMassNumberEast) ;  
107  fFlowEvent->SetBeamMassNumberWest(AliFlowConstants::fgBeamMassNumberWest) ;  
108
109  // Trigger information (now is: ULon64_t - some trigger mask)
110  fFlowEvent->SetL0TriggerWord((Int_t)fESD->GetTriggerMask()); 
111  
112  // Get primary vertex position
113  fVertex = (AliESDVertex*)fESD->GetVertex() ;
114  Double_t position[3] ; 
115  fVertex->GetXYZ(position) ;
116  fFlowEvent->SetVertexPos((Float_t)position[0],(Float_t)position[1],(Float_t)position[2]) ; 
117
118  // Zero Degree Calorimeter information
119  Int_t zdcp = fESD->GetZDCParticipants() ; 
120  Float_t zdce[3] ; 
121  zdce[0] = fESD->GetZDCN1Energy() + fESD->GetZDCN2Energy(); 
122  zdce[1] = fESD->GetZDCP1Energy() + fESD->GetZDCP2Energy() ; 
123  zdce[2] = fESD->GetZDCEMEnergy() ;
124  fFlowEvent->SetZDCpart(zdcp);                          
125  fFlowEvent->SetZDCenergy(zdce[0],zdce[1],zdce[2]);     
126
127  // Track loop
128  if(fLoopTrks)
129  {
130   Int_t badTrks = 0 ;   
131   for(fTrackNumber=0;fTrackNumber<fNumberOfTracks;fTrackNumber++) 
132   {
133    fTrack = fESD->GetTrack(fTrackNumber) ;
134    if(CheckTrack(fTrack))
135    {
136     FillFlowTrack(fTrack) ;   
137     fGoodTracks++ ;                                   
138     fMovedTr.push_back(fFlowEvent->TrackCollection()->GetLast()) ; 
139    }
140    else { fMovedTr.push_back(-1) ; badTrks++ ; continue ; }
141   }
142   fCutTrks += badTrks ;
143  } // cout << " -track number- :  " << fTrackNumber << endl ;
144
145  // V0 loop
146  if(fLoopV0s)
147  {
148   Int_t badV0s = 0 ;
149   for(fV0Number=0;fV0Number<fNumberOfV0s;fV0Number++) 
150   {
151    fV0 = fESD->GetV0(fV0Number) ;                       
152    if(CheckV0(fV0))
153    {
154     FillFlowV0(fV0) ;
155     fGoodV0s++ ;                        
156    }
157    else { badV0s++ ; continue ; }
158   }
159   fCutV0s += badV0s ;
160  } // cout << " -v0 number- :  " << fV0Number << endl ;
161
162  // Evt setting stuff
163  fFlowEvent->SetCentrality();   
164                                 
165  fCounter++ ; 
166  return fFlowEvent ;
167 }
168 //----------------------------------------------------------------------
169 AliFlowTrack* AliFlowMaker::FillFlowTrack(AliESDtrack* fTrack)
170 {
171  // From the AliESDtrack (input) fills the AliFlowTrack (output) .
172
173  TString name = "" ; name += fTrackNumber ;
174  Int_t idx = fFlowEvent->TrackCollection()->GetEntries() ;
175  fFlowTrack = (AliFlowTrack*)(fFlowEvent->TrackCollection()->New(idx)) ;
176  fFlowTrack->SetName(name.Data()) ;
177  
178  // cout << " -tr- " << name.Data() << "(" << idx << ")"  << endl ;
179
180  // ESD particle label (link: KineTree-ESD)
181  Int_t label = TMath::Abs(fTrack->GetLabel());
182  fFlowTrack->SetLabel(label) ;                  
183
184  // signed DCA from ESDtrack
185  Float_t xy = 0 ; Float_t z = 0 ; 
186  fTrack->GetImpactParameters(xy,z) ; 
187  fFlowTrack->SetDcaSigned(xy,z) ;                   
188
189  // error on the DCA
190  Float_t dcaBis[2] ; Float_t dcaCov[3] ; 
191  for(Int_t dd=0;dd<3;dd++) { dcaCov[dd] = 0. ; }
192  fTrack->GetImpactParameters(dcaBis, dcaCov) ;
193  fFlowTrack->SetDcaError(dcaCov[0],dcaCov[1],dcaCov[2]) ;                   
194
195  // UnConstrained (global) first
196  Double_t gD[3] ;                               
197  fTrack->GetPxPyPz(gD) ;                        
198  // -
199  Float_t phiGl = (Float_t)Phi(gD) ;  
200  if(phiGl<0) { phiGl += 2*TMath::Pi() ; }
201  fFlowTrack->SetPhiGlobal(phiGl) ;              
202  Float_t ptGl = (Float_t)Pt(gD) ;  if(ptGl<=0) { cout << " !!! ptGlobal = " << ptGl << endl ; }
203  fFlowTrack->SetPtGlobal(ptGl) ;                
204  Float_t etaGl = (Float_t)Eta(gD) ; 
205  fFlowTrack->SetEtaGlobal(etaGl) ;              
206
207  // Constrained (NEW)
208  Double_t cD[3] ;
209  Double_t par1 ; Double_t par2 ;  Double_t par3[3] ;
210  if(fTrack->GetConstrainedExternalParameters(par1,par2,par3))
211  {
212   fTrack->GetConstrainedPxPyPz(cD) ;     
213  }
214  else { for(Int_t iii=0;iii<3;iii++) { cD[iii] =0 ; } }
215
216  if(Norm(cD)!=0.)   // ConstrainedPxPyPz != 0 if ConstrainedChi2 < something ...
217  {                                                      
218   Float_t phi = (Float_t)Phi(cD) ; 
219   if(phi<0) { phi += 2*TMath::Pi() ; }
220   fFlowTrack->SetPhi(phi) ;                             
221   Float_t pt = (Float_t)Pt(cD) ;   if(pt<=0) { cout << " !!! pt = " << pt << endl ; }
222   fFlowTrack->SetPt(pt) ;                               
223   Float_t eta = (Float_t)Eta(cD) ; 
224   fFlowTrack->SetEta(eta) ;                             
225  
226   // number of constrainable tracks with |eta| < AliFlowConstants::fgEtaGood (0.9)
227   if(TMath::Abs(eta) < AliFlowConstants::fgEtaMid)  { fGoodTracksEta++ ; }
228  }
229  else  // in case Constriction impossible for track, fill the UnConstrained (global)
230  {
231   fUnconstrained++ ;    
232   fFlowTrack->SetPhi(0.) ;
233   fFlowTrack->SetPt(0.) ;   
234   fFlowTrack->SetEta(0.) ; 
235  }           
236
237  // positive - negative tracks
238  Int_t trkSign = (Int_t)fTrack->GetSign() ; 
239  fFlowTrack->SetCharge(trkSign) ;               
240  if(trkSign>0)  { fPosiTracks++ ; }
241  else if(trkSign<0)     { fNegaTracks++ ; }
242  else                   { return 0 ; }
243
244  // Tracking parameters (fit , TPC , ITS , dE/dx)
245  fFlowTrack->SetChi2(fTrack->GetConstrainedChi2()) ;            
246  fFlowTrack->SetTrackLength(fTrack->GetIntegratedLength()) ;    
247  // -
248  Int_t idXt[180] ; // used for Cluster Map ( see AliESDtrack::GetTPCclusters() )    // old:    Int
249  Int_t idX[6] ;    // used for Cluster Map ( see AliESDtrack::GetITSclusters() )    // old:    UInt
250  Int_t idxr[130] ; // used for Cluster Map ( see AliESDtrack::GetTRDclusters() )    // old:    UInt
251  Int_t nClus = 0 ;      
252  Int_t fNFound = 0 ;                                    // *!* fNFoundable (in AliTPCtrack) ... added by M.Ianov 
253  // -
254  Double_t detPid[5] ;           
255  Float_t  detPid6[AliFlowConstants::kPid] ; 
256
257  Double_t pVecAt[3] ; 
258  for(Int_t gg=0;gg<3;gg++) { pVecAt[gg] = gD[gg] ; }
259  Bool_t boh ; Float_t pAt = 0 ;                         // to get p at each detector
260  // -
261  if(fNewAli) { boh = fTrack->GetPxPyPzAt(AliFlowConstants::fgTPCx, fMagField, pVecAt) ; }
262  else        { boh = fTrack->GetInnerParam()->GetPxPyPzAt(AliFlowConstants::fgTPCx, fMagField, pVecAt) ; }
263  pAt = (Float_t)Norm(pVecAt) ; if(!pAt) { pAt = (Float_t)Norm(gD) ; }
264  nClus = fTrack->GetTPCclusters(idXt) ;
265  fNFound = fTrack->GetTPCNclsF() ;  // was 160
266  if( (fTrack->GetStatus() & AliESDtrack::kTPCpid) != 0 )
267  {
268   fTrack->GetTPCpid(detPid) ; 
269   for(Int_t bb=0;bb<5;bb++) { detPid6[bb] = detPid[bb] ; } detPid6[5] = 0. ; 
270   fFlowTrack->SetRespFunTPC(detPid6) ; 
271  }
272  fFlowTrack->SetMaxPtsTPC(fNFound) ;                            
273  fFlowTrack->SetFitPtsTPC(nClus) ;                              
274  fFlowTrack->SetDedxTPC(fTrack->GetTPCsignal()) ;               
275  fFlowTrack->SetChi2TPC((Float_t)(fTrack->GetTPCchi2())) ;      
276  fFlowTrack->SetPatTPC(pAt) ;                                   
277  // -
278  if(fNewAli) { boh = fTrack->GetPxPyPzAt(AliFlowConstants::fgITSx, fMagField, pVecAt) ; }
279  else        { boh = fTrack->GetInnerParam()->GetPxPyPzAt(AliFlowConstants::fgITSx, fMagField, pVecAt) ; }
280  pAt = (Float_t)Norm(pVecAt) ; if(!pAt) { pAt = (Float_t)Norm(gD) ; }
281  nClus = fTrack->GetITSclusters(idX) ;
282  fNFound = 6 ; // ? fixed
283  if( (fTrack->GetStatus() & AliESDtrack::kITSpid) != 0 )
284  {
285   fTrack->GetITSpid(detPid) ; 
286   for(Int_t bb=0;bb<5;bb++) { detPid6[bb] = detPid[bb] ; } detPid6[5] = 0. ; 
287   fFlowTrack->SetRespFunITS(detPid6) ; 
288  } 
289  fFlowTrack->SetMaxPtsITS(fNFound) ;                            
290  fFlowTrack->SetFitPtsITS(nClus) ;                              
291  fFlowTrack->SetDedxITS(fTrack->GetITSsignal()) ;               
292  fFlowTrack->SetChi2ITS((Float_t)(fTrack->GetITSchi2())) ;      
293  fFlowTrack->SetPatITS(pAt) ;                                   
294  // -
295  if(fNewAli) { boh = fTrack->GetPxPyPzAt(AliFlowConstants::fgTRDx, fMagField, pVecAt) ; } 
296  else        { boh = fTrack->GetInnerParam()->GetPxPyPzAt(AliFlowConstants::fgTRDx, fMagField, pVecAt) ; } 
297  pAt = (Float_t)Norm(pVecAt) ; if(!pAt) { pAt = (Float_t)Norm(gD) ; }
298  nClus = fTrack->GetTRDclusters(idxr) ;
299  fNFound = fTrack->GetTRDncls() ;  // was 130
300  if( (fTrack->GetStatus() & AliESDtrack::kTRDpid) != 0 )
301  {
302   fTrack->GetTRDpid(detPid) ; 
303   for(Int_t bb=0;bb<5;bb++) { detPid6[bb] = detPid[bb] ; } detPid6[5] = 0. ; 
304   fFlowTrack->SetRespFunTRD(detPid6) ; 
305  }
306  fFlowTrack->SetMaxPtsTRD(fNFound) ;                            
307  fFlowTrack->SetNhitsTRD(nClus) ;                               
308  fFlowTrack->SetSigTRD(fTrack->GetTRDsignal()) ;                
309  fFlowTrack->SetChi2TRD((Float_t)fTrack->GetTRDchi2()) ;        
310  fFlowTrack->SetPatTRD(pAt) ;                                   
311  // -
312  if(fNewAli) { boh = fTrack->GetPxPyPzAt(AliFlowConstants::fgTOFx, fMagField, pVecAt) ; }
313  else        { boh = fTrack->GetInnerParam()->GetPxPyPzAt(AliFlowConstants::fgTOFx, fMagField, pVecAt) ; }
314  pAt = (Float_t)Norm(pVecAt) ; if(!pAt) { pAt = (Float_t)Norm(gD) ; }
315  nClus = fTrack->GetTOFcluster() ;
316  fNFound = 0 ; if(fTrack->GetTOFCalChannel() > 0) { fNFound = 1 ; }
317  if( (fTrack->GetStatus() & AliESDtrack::kTOFpid) != 0 )
318  {
319   fTrack->GetTOFpid(detPid) ; 
320   for(Int_t bb=0;bb<5;bb++) { detPid6[bb] = detPid[bb] ; } detPid6[5] = 0. ; 
321   fFlowTrack->SetRespFunTOF(detPid6) ; 
322  }
323  fFlowTrack->SetMaxPtsTOF(fNFound) ;                            
324  fFlowTrack->SetNhitsTOF(nClus) ;                               
325  fFlowTrack->SetTofTOF(fTrack->GetTOFsignal()) ;                
326  fFlowTrack->SetChi2TOF(fTrack->GetTOFchi2()) ;                 
327  fFlowTrack->SetPatTOF(pAt) ;                                   
328  // -
329  Double_t rIn[3]  ; rIn[0] = 0.  ;  rIn[1] = 0. ;  rIn[2] = 0. ;
330  Double_t rOut[3] ; rOut[0] = 0. ; rOut[1] = 0. ; rOut[2] = 0. ;
331  // -
332  fTrack->GetInnerXYZ(rIn) ;                                     
333  fFlowTrack->SetZFirstPoint(rIn[2]) ; 
334  //fTrack->GetXYZAt(AliFlowConstants::fgTPCx,fMagField,rOut) ;          
335  fTrack->GetOuterXYZ(rOut) ;                                    
336  fFlowTrack->SetZLastPoint(rOut[2]) ; 
337  
338  // ESD-P.Id. = 5-vector of Best detectors probabilities for [e , mu , pi , K , p] 
339  Double_t trkPid[5] ; fTrack->GetESDpid(trkPid) ;               
340  Double_t trkPid6[AliFlowConstants::kPid] ; 
341  for(Int_t bb=0;bb<5;bb++) { trkPid6[bb] = trkPid[bb] ; } 
342  trkPid6[5] = 0. ;                                              // *!* implement P.Id. for Deuterim
343
344  // Bayesian P.Id. method (weighted probabilities for [e , mu , pi , K , p , d])
345  Double_t bsum = 0 ; 
346  Double_t bayePid[AliFlowConstants::kPid] ;    // normalized P.id
347  Double_t storedPid[AliFlowConstants::kPid] ;  // stored P.id
348  for(Int_t nB=0;nB<AliFlowConstants::kPid;nB++)  { bsum += trkPid6[nB]*AliFlowConstants::fgBayesian[nB] ; }
349  if(bsum)
350  {
351   for(Int_t nB=0;nB<AliFlowConstants::kPid;nB++) 
352   { 
353    bayePid[nB] = trkPid6[nB]*AliFlowConstants::fgBayesian[nB] / bsum ; 
354    storedPid[nB] = trkPid6[nB] ; 
355   }
356  }
357  else { cout << " ERROR - Empty Bayesian Vector !!! " << endl ; }
358  
359  fFlowTrack->SetElectronPositronProb(storedPid[0]);               
360  fFlowTrack->SetMuonPlusMinusProb(storedPid[1]);
361  fFlowTrack->SetPionPlusMinusProb(storedPid[2]);
362  fFlowTrack->SetKaonPlusMinusProb(storedPid[3]);
363  fFlowTrack->SetProtonPbarProb(storedPid[4]);
364  fFlowTrack->SetDeuteriumAntiDeuteriumProb(storedPid[5]);       // *!* implement P.Id. for Deuterim
365
366  // P.id. label given via the weighted prob.
367  const Int_t kCode[]   =  {11,13,211,321,2212,10010020} ;
368  Int_t kkk = 2 ;                        // if No id. -> then is a Pi
369  Float_t pidMax = bayePid[2] ;  // (if all equal, Pi probability get's the advantage to be the first)
370  for(Int_t iii=0; iii<5; iii++) 
371  {
372   if(bayePid[iii]>pidMax) { kkk = iii ; pidMax = bayePid[iii] ; }  // !!! Bayesian as well !!!
373  }
374  fBayesianAll[kkk]++ ; fSumAll++ ;      // goes on filling the vector of observed abundance 
375  //-
376  Int_t pdgCode = trkSign*kCode[kkk] ;
377  fFlowTrack->SetMostLikelihoodPID(pdgCode);
378  
379  return fFlowTrack ; 
380 }
381 //-----------------------------------------------------------------------
382 AliFlowV0* AliFlowMaker::FillFlowV0(AliESDv0* fV0)
383 {
384  // From the AliESDv0 (input) fills the AliFlowV0 (output) .
385
386  TString name = "" ; name += fV0Number ;
387  Int_t idx = fFlowEvent->V0Collection()->GetEntries() ;
388  fFlowV0 = (AliFlowV0*)(fFlowEvent->V0Collection()->New(idx)) ;
389  fFlowV0->SetName(name.Data()) ;
390  
391  // cout << " -v0- " << name.Data() << "(" << idx << ")"  << endl ;
392
393  // ESD particle label (link: KineTree-ESD)
394  Int_t label = -1 ; // TMath::Abs(fV0->GetLabel());
395  fFlowV0->SetLabel(label) ;                     
396
397  // reconstructed momentum of the V0
398  Double_t pxyz[3] ;
399  fV0->GetPxPyPz(pxyz[0],pxyz[1],pxyz[2]) ;
400
401  Float_t phi = (Float_t)Phi(pxyz) ; if(phi<0) { phi += 2*TMath::Pi() ; }
402  fFlowV0->SetPhi(phi) ;         
403  Float_t pt = (Float_t)Pt(pxyz) ; 
404  fFlowV0->SetPt(pt) ;           
405  Float_t eta = (Float_t)Eta(pxyz) ; 
406  fFlowV0->SetEta(eta) ;         
407
408  // reconstructed position of the V0 
409  Double_t xyz[3] ;              
410  fV0->GetXYZ(xyz[0],xyz[1],xyz[2]) ;            
411  fFlowV0->SetCrossPoint(xyz[0],xyz[1],xyz[2]) ;
412
413  // V0's impact parameter & error (chi2 , DCA , sigma , pointing angle)  
414  //fFlowV0->SetDca((Float_t)fV0->GetD()) ;    // GetDistNorm 
415  //fFlowV0->SetSigma((Float_t)fV0->GetDistSigma()) ;
416  //fFlowV0->SetCosPointingAngle((Float_t)fV0->GetV0CosineOfPointingAngle()) ;  
417  //fFlowV0->SetDaughtersDca(fV0->GetDcaV0Daughters()) ;
418  //fFlowV0->SetChi2((Float_t)fV0->GetChi2V0()) ;     // AliRoot v4-04-Release (December 2006)  
419  //fFlowV0->SetChi2((Float_t)fV0->GetChi2()) ;       // AliRoot v4-04-Release (old)
420  // ...when they'll stop changing the methods I'll enable the above lines. For now:
421  fFlowV0->SetDca(0.);
422  fFlowV0->SetSigma(0.1); 
423  fFlowV0->SetCosPointingAngle(1.) ;     
424  fFlowV0->SetDaughtersDca(0.) ;
425  fFlowV0->SetChi2(1.) ;
426
427  // P.id. 
428  Int_t pdgCode = fV0->GetPdgCode() ;
429  fFlowV0->SetMostLikelihoodPID(pdgCode);        
430
431  // mass 
432  fFlowV0->SetVmass((Float_t)fV0->GetEffMass()) ; 
433  
434  // daughters 
435  Int_t pN = fV0->GetPindex() ;
436  Int_t nN = fV0->GetNindex() ;
437  fFlowV0->SetDaughters(fMovedTr[pN],fMovedTr[nN]) ;
438
439  return fFlowV0 ;
440 }
441 //-----------------------------------------------------------------------
442 Bool_t AliFlowMaker::CheckTrack(AliESDtrack* fTrack) const
443 {
444  // applies track cuts (pE , nHits , label)
445
446  if(!fTrack) { return kFALSE ; }
447
448  Int_t idXt[180] ;  // used for Cluster Map ( see AliESDtrack::GetTPCclusters() )
449  Int_t   nHits = fTrack->GetTPCclusters(idXt) ;
450  Float_t pE    = fTrack->GetP() ;
451  Int_t   label = fTrack->GetLabel() ;
452  
453  if(fNHits && (nHits<=fNHits))                                           { return kFALSE ; }
454  if((fElow < fEup) && ((pE<fElow) || (pE>fEup)))                         { return kFALSE ; }
455  if((fLabel[0] < fLabel[1]) && ((label<fLabel[0]) || (label>fLabel[1]))) { return kFALSE ; }
456  //if(fPrimary && ...)                                                   { return kFALSE ; }
457
458  return kTRUE ;
459 }
460 //-----------------------------------------------------------------------
461 Bool_t AliFlowMaker::CheckV0(AliESDv0* fV0) const
462 {
463  // applies v0 cuts (mass>fElow, daughters included in the tracks)
464  
465  if(!fV0) { return kFALSE ; }
466  
467  Int_t pN = fV0->GetPindex() ;
468  Int_t nN = fV0->GetNindex() ;
469  Float_t iMass = (Float_t)fV0->GetEffMass() ;
470  
471  if(iMass < fElow)      { return kFALSE ; }
472  if(fMovedTr[pN] < 0)   { return kFALSE ; }
473  if(fMovedTr[nN] < 0)   { return kFALSE ; }
474
475  return kTRUE ;
476 }
477 //-----------------------------------------------------------------------
478 Bool_t AliFlowMaker::CheckEvent(AliESD* fESD) const
479 {
480  // applies event cuts (dummy)
481  
482  if(!fESD) { return kFALSE ; }
483
484  return kTRUE ;
485 }
486 //-----------------------------------------------------------------------
487 void AliFlowMaker::PrintCutList()
488
489  // Prints the list of Cuts 
490
491  cout << " * ESD cuts list * " << endl ; 
492  if(fLabel[0]<fLabel[1])
493  { 
494   cout << "  Track Label [ " << fLabel[0] << " , " << fLabel[1] << " ] " << endl ; 
495  }
496  if(fNHits)
497  { 
498   cout << "  TPC clusters > " << fNHits << endl ; 
499  }
500  if(fElow<fEup)
501  { 
502   cout << "  Track Energy (P_total) [ " << fElow << " , " << fEup << " ] " << endl ; 
503  }
504  if(fElow>0.)
505  { 
506   cout << "  V0 invariant mass > " << fElow << endl ; 
507  }
508  cout << " *               * " << endl ;
509 }
510 //-----------------------------------------------------------------------
511
512 //-----------------------------------------------------------------------
513 //*** USEFULL METHODS for a 3-array of double (~ TVector3) ***
514 //-----------------------------------------------------------------------
515 Double_t AliFlowMaker::Norm(Double_t nu[3])
516
517  // returns the norm of a double[3] 
518
519  Double_t norm2 = nu[0]*nu[0] + nu[1]*nu[1] + nu[2]*nu[2] ;
520  return TMath::Sqrt(norm2) ; 
521 }
522 //-----------------------------------------------------------------------
523 Double_t AliFlowMaker::Phi(Double_t nu[3])
524 {
525  // returns the azimuthal angle of a double[3] 
526
527  if(nu[0]==0 && nu[1]==0) { return 0. ; }
528  else                     { return TMath::ATan2(nu[1],nu[0]) ; }
529 }
530 //-----------------------------------------------------------------------
531 Double_t AliFlowMaker::Pt(Double_t nu[3])
532 {
533  // returns the transvers momentum of a double[3] 
534
535  Double_t trans = nu[0]*nu[0] + nu[1]*nu[1] ;
536  return TMath::Sqrt(trans) ; 
537 }
538 //-----------------------------------------------------------------------
539 Double_t AliFlowMaker::Eta(Double_t nu[3])
540 {
541  // returns the PseudoRapidity of a double[3] 
542  // if transvers momentum = 0 --> returns +/- 1.000
543
544  Double_t m = Norm(nu) ;
545  if(nu[0]!=0 || nu[1]!=0) { return 0.5*TMath::Log((m+nu[2])/(m-nu[2])) ; }
546  else                     { return TMath::Sign((Double_t)1000.,nu[2]) ; }
547 }
548 //-----------------------------------------------------------------------
549
550 #endif