]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG2/FLOW/AliFlowEventSimpleMaker.cxx
First implementation of phi, pt and eta weights for the Q vector
[u/mrichter/AliRoot.git] / PWG2 / FLOW / AliFlowEventSimpleMaker.cxx
1 /**************************************************************************
2  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3  *                                                                        *
4  * Author: The ALICE Off-line Project.                                    *
5  * Contributors are mentioned in the code where appropriate.              *
6  *                                                                        *
7  * Permission to use, copy, modify and distribute this software and its   *
8  * documentation strictly for non-commercial purposes is hereby granted   *
9  * without fee, provided that the above copyright notice appears in all   *
10  * copies and that both the copyright notice and this permission notice   *
11  * appear in the supporting documentation. The authors make no claims     *
12  * about the suitability of this software for any purpose. It is          *
13  * provided "as is" without express or implied warranty.                  *
14  **************************************************************************/
15 /* $Id */
16
17 #include "Riostream.h"
18 #include "AliFlowEventSimpleMaker.h"
19 #include "AliFlowEventSimple.h"
20 #include "AliFlowTrackSimple.h"
21 #include "TTree.h"
22 #include "TParticle.h"
23 #include "AliMCEvent.h"
24 #include "AliMCParticle.h"
25 #include "AliESDEvent.h"
26 #include "AliESDtrack.h"
27 #include "AliAODEvent.h"
28 #include "AliAODTrack.h"
29 #include "../../CORRFW/AliCFManager.h"
30 #include "AliFlowTrackSimpleCuts.h"
31
32
33 // AliFlowEventSimpleMaker:
34 // Class to fill the AliFlowEventSimple
35 // with AliFlowTrackSimple objects
36 // Has fill methods for TTree, AliMCEvent, AliESDEvent and AliAODEvent
37 // author: N. van der Kolk (kolk@nikhef.nl)
38
39 ClassImp(AliFlowEventSimpleMaker)
40 //----------------------------------------------------------------------- 
41 AliFlowEventSimpleMaker::AliFlowEventSimpleMaker():
42  fUseWeightsPhi(kFALSE),
43  fUseWeightsPt(kFALSE),
44  fUseWeightsEta(kFALSE),
45  fPhiWeights(NULL),
46  fPtWeights(NULL),   
47  fEtaWeights(NULL)
48 {
49   //constructor
50 }
51
52 //-----------------------------------------------------------------------   
53 AliFlowEventSimpleMaker::~AliFlowEventSimpleMaker()
54 {
55   //destructor
56 }
57
58 //----------------------------------------------------------------------- 
59 void AliFlowEventSimpleMaker::Init(TFile *file)
60 {
61  //initialize weights' histograms 
62  if(file)
63  {
64   if(fUseWeightsPhi)
65   {
66    file->GetObject("phi_weights",fPhiWeights);
67   }
68   if(fUseWeightsPt)
69   { 
70    file->GetObject("pt_weights",fPtWeights);
71   } 
72   if(fUseWeightsEta)
73   {
74    file->GetObject("eta_weights",fEtaWeights);
75   } 
76  }//end of if(file)
77 }
78
79 //-----------------------------------------------------------------------   
80 AliFlowEventSimple* AliFlowEventSimpleMaker::FillTracks(TTree* anInput, AliFlowTrackSimpleCuts* intCuts, AliFlowTrackSimpleCuts* diffCuts)
81 {
82   //fills the event from a TTree of kinematic.root files
83   
84   // number of times to use the same particle (trick to introduce nonflow)
85   Int_t iLoops = 1;
86   
87   //flags for particles passing int. and diff. flow cuts
88   Bool_t bPassedIntFlowCuts  = kFALSE;
89   Bool_t bPassedDiffFlowCuts = kFALSE;
90   
91   //track cut values
92   Double_t dPtMaxInt  = intCuts->GetPtMax();
93   Double_t dPtMinInt  = intCuts->GetPtMin();
94   Double_t dEtaMaxInt = intCuts->GetEtaMax();
95   Double_t dEtaMinInt = intCuts->GetEtaMin();
96   Double_t dPhiMaxInt = intCuts->GetPhiMax();
97   Double_t dPhiMinInt = intCuts->GetPhiMin();
98   Int_t iPIDInt       = intCuts->GetPID();
99   
100   Double_t dPtMaxDiff  = diffCuts->GetPtMax();
101   Double_t dPtMinDiff  = diffCuts->GetPtMin();
102   Double_t dEtaMaxDiff = diffCuts->GetEtaMax();
103   Double_t dEtaMinDiff = diffCuts->GetEtaMin();
104   Double_t dPhiMaxDiff = diffCuts->GetPhiMax();
105   Double_t dPhiMinDiff = diffCuts->GetPhiMin();
106   Int_t iPIDDiff       = diffCuts->GetPID();
107   
108   Int_t iNumberOfInputTracks = anInput->GetEntries() ;
109   //cerr<<"iNumberOfInputTracks = "<<iNumberOfInputTracks<<endl;
110   TParticle* pParticle = new TParticle();
111   anInput->SetBranchAddress("Particles",&pParticle);  
112   //  AliFlowEventSimple* pEvent = new AliFlowEventSimple(iNumberOfInputTracks);
113   AliFlowEventSimple* pEvent = new AliFlowEventSimple(10);
114   //cerr<<pEvent<<" pEvent "<<endl;
115   
116   //needed if weights are used:
117   pEvent->SetUseWeightsPhi(fUseWeightsPhi);
118   pEvent->SetUseWeightsPt(fUseWeightsPt);
119   pEvent->SetUseWeightsEta(fUseWeightsEta);
120   pEvent->SetPhiWeights(fPhiWeights); 
121   pEvent->SetPtWeights(fPtWeights); 
122   pEvent->SetEtaWeights(fEtaWeights); 
123
124   Int_t iN = iNumberOfInputTracks; // additional variable to artificially fix the number of tracks
125   //  Int_t iN = 576; //multiplicity for chi=1.5
126   //  Int_t iN = 256; //multiplicity for chi=1
127   //  Int_t iN = 164; //multiplicity for chi=0.8
128   
129   Int_t iGoodTracks = 0;
130   Int_t itrkN = 0;
131   Int_t iSelParticlesDiff = 0;
132   Int_t iSelParticlesInt = 0;
133   
134   while (itrkN < iNumberOfInputTracks) {
135     anInput->GetEntry(itrkN);   //get input particle
136     //checking the cuts for int. and diff. flow
137     if (pParticle->Pt() > dPtMinInt && pParticle->Pt() < dPtMaxInt &&
138         pParticle->Eta() > dEtaMinInt && pParticle->Eta() < dEtaMaxInt &&
139         pParticle->Phi() > dPhiMinInt && pParticle->Phi() < dPhiMaxInt &&
140         TMath::Abs(pParticle->GetPdgCode()) == iPIDInt) { 
141       bPassedIntFlowCuts = kTRUE; 
142     } 
143     
144     if (pParticle->Pt() > dPtMinDiff && pParticle->Pt() < dPtMaxDiff &&
145         pParticle->Eta() > dEtaMinDiff && pParticle->Eta() < dEtaMaxDiff &&
146         pParticle->Phi() > dPhiMinDiff && pParticle->Phi() < dPhiMaxDiff &&
147         TMath::Abs(pParticle->GetPdgCode()) == iPIDDiff){ 
148       bPassedDiffFlowCuts = kTRUE; 
149     }
150     
151     if (bPassedIntFlowCuts || bPassedDiffFlowCuts) {
152       for(Int_t d=0;d<iLoops;d++) {
153         AliFlowTrackSimple* pTrack = new AliFlowTrackSimple();
154         pTrack->SetPt(pParticle->Pt());
155         pTrack->SetEta(pParticle->Eta());
156         pTrack->SetPhi(pParticle->Phi());
157         
158         //marking the particles used for int. flow:
159         if(bPassedIntFlowCuts && iSelParticlesInt < iN*iLoops) {  
160           pTrack->SetForIntegratedFlow(kTRUE);
161           iSelParticlesInt++;
162         }
163         //marking the particles used for diff. flow:
164         if(bPassedDiffFlowCuts) {
165           pTrack->SetForDifferentialFlow(kTRUE);
166           iSelParticlesDiff++;
167         }
168         //adding a particles which were used either for int. or diff. flow to the list
169         pEvent->TrackCollection()->Add(pTrack);
170         iGoodTracks++;
171       }//end of for(Int_t d=0;d<iLoops;d++)
172     }//end of if(bPassedIntFlowCuts || bPassedDiffFlowCuts) 
173     itrkN++;  
174     bPassedIntFlowCuts  = kFALSE;
175     bPassedDiffFlowCuts = kFALSE;
176   }//end of while (itrkN < iNumberOfInputTracks)
177   
178   pEvent->SetEventNSelTracksIntFlow(iSelParticlesInt);  
179   pEvent->SetNumberOfTracks(iGoodTracks);//tracks used either for int. or for diff. flow
180
181   cout<<" iGoodTracks = "<<iGoodTracks<<endl;
182   cout<<" # of selected tracks for int. flow  = "<<iSelParticlesInt<<endl;
183   cout<<" # of selected tracks for diff. flow = "<<iSelParticlesDiff<<endl;  
184
185   delete pParticle;
186   return pEvent;
187 }
188
189 //-----------------------------------------------------------------------   
190 AliFlowEventSimple* AliFlowEventSimpleMaker::FillTracks(AliMCEvent* anInput)
191 {
192   //Fills the event from the MC kinematic information
193   
194   Int_t iNumberOfInputTracks = anInput->GetNumberOfTracks() ;
195   cerr<<"anInput->GetNumberOfTracks() = "<<iNumberOfInputTracks<<endl;
196  
197   AliFlowEventSimple* pEvent = new AliFlowEventSimple(10);
198     
199   //Int_t iN = 256; //multiplicity for chi=1
200   Int_t iN = iNumberOfInputTracks;
201   Int_t iGoodTracks = 0;
202   Int_t itrkN = 0;
203   Int_t iSelParticlesDiff = 0;
204   Int_t iSelParticlesInt = 0;
205
206   //normal loop
207   while (iGoodTracks < iN && itrkN < iNumberOfInputTracks) {
208     AliMCParticle* pParticle = anInput->GetTrack(itrkN);   //get input particle
209     //cut on tracks
210     if (TMath::Abs(pParticle->Eta()) < 0.9)
211       {
212         if(
213            TMath::Abs(pParticle->Particle()->GetPdgCode()) == 211
214            //         TMath::Abs(pParticle->Particle()->GetPdgCode()) == 211 ||
215            //         TMath::Abs(pParticle->Particle()->GetPdgCode()) == 321 ||
216            //         TMath::Abs(pParticle->Particle()->GetPdgCode()) == 2212
217            )
218           {
219             AliFlowTrackSimple* pTrack = new AliFlowTrackSimple();
220             pTrack->SetPt(pParticle->Pt() );
221             pTrack->SetEta(pParticle->Eta() );
222             pTrack->SetPhi(pParticle->Phi() );
223             pTrack->SetForIntegratedFlow(kTRUE);
224             pTrack->SetForDifferentialFlow(kTRUE);
225
226             if (pTrack->UseForIntegratedFlow())
227               { iSelParticlesInt++; }
228             if (pTrack->UseForDifferentialFlow())
229               { iSelParticlesDiff++; }
230             iGoodTracks++;
231             pEvent->TrackCollection()->Add(pTrack) ;         
232           }
233         /*        else if(
234                   TMath::Abs(pParticle->Particle()->GetPdgCode()) == 211
235                   )
236             {
237               AliFlowTrackSimple* pTrack = new AliFlowTrackSimple();
238               pTrack->SetPt(pParticle->Pt() );
239               pTrack->SetEta(pParticle->Eta() );
240               pTrack->SetPhi(pParticle->Phi() );
241               pTrack->SetForIntegratedFlow(kFALSE);
242               pTrack->SetForDifferentialFlow(kTRUE);
243
244               if (pTrack->UseForIntegratedFlow())
245                 { iSelParticlesInt++; }
246               if (pTrack->UseForDifferentialFlow())
247                 { iSelParticlesDiff++; }
248               iGoodTracks++;
249               pEvent->TrackCollection()->Add(pTrack);        
250             }
251           */
252       }
253       
254     itrkN++; 
255   }
256   
257   pEvent-> SetEventNSelTracksIntFlow(iSelParticlesInt);  
258   pEvent->SetNumberOfTracks(iGoodTracks);
259   cout<<" iGoodTracks = "<<iGoodTracks<<endl;
260   //cout << "  iSelectedTracksInt = " << iSelParticlesInt << endl;  
261   return pEvent;
262
263 }
264
265
266 //-----------------------------------------------------------------------   
267 AliFlowEventSimple* AliFlowEventSimpleMaker::FillTracks(AliMCEvent* anInput, AliCFManager* intCFManager, AliCFManager* diffCFManager)
268 {
269   //Fills the event from the MC kinematic information
270   
271   Int_t iNumberOfInputTracks = anInput->GetNumberOfTracks() ;
272   cerr<<"anInput->GetNumberOfTracks() = "<<iNumberOfInputTracks<<endl;
273   if (iNumberOfInputTracks==-1) {
274     cout<<"Skipping Event -- No MC information available for this event"<<endl;
275     return 0;
276   }
277
278   AliFlowEventSimple* pEvent = new AliFlowEventSimple(10);
279     
280   Int_t iN = iNumberOfInputTracks; //maximum number of tracks in AliFlowEventSimple
281   Int_t iGoodTracks = 0;           //number of good tracks
282   Int_t itrkN = 0;                 //track counter
283   Int_t iSelParticlesDiff = 0;     //number of tracks selected for Diff
284   Int_t iSelParticlesInt = 0;      //number of tracks selected for Int
285
286    
287   //normal loop
288   while (iGoodTracks < iN && itrkN < iNumberOfInputTracks) {
289     //get input particle
290     AliMCParticle* pParticle = anInput->GetTrack(itrkN);   
291     //make new AliFlowTrackSimple
292     AliFlowTrackSimple* pTrack = new AliFlowTrackSimple();
293     pTrack->SetPt(pParticle->Pt() );
294     pTrack->SetEta(pParticle->Eta() );
295     pTrack->SetPhi(pParticle->Phi() );
296
297     //check if pParticle passes the cuts
298     if (intCFManager->CheckParticleCuts(AliCFManager::kPartGenCuts,pParticle)) {
299       pTrack->SetForIntegratedFlow(kTRUE);
300       //cout<<"integrated selection. PID = "<<pParticle->Particle()->GetPdgCode()<<endl; 
301     }
302     if (diffCFManager->CheckParticleCuts(AliCFManager::kPartGenCuts,pParticle)) {
303       pTrack->SetForDifferentialFlow(kTRUE);
304       //cout<<"differential selection. PID = "<<pParticle->Particle()->GetPdgCode()<<endl; 
305     }
306
307     //check if any bits are set
308     TBits bFlowBits = pTrack->GetFlowBits();
309     if (bFlowBits.CountBits() ==0) {
310       delete pTrack; } //track will not be used anymore
311     else {
312       pEvent->TrackCollection()->Add(pTrack) ; 
313       iGoodTracks++;
314
315       if (pTrack->UseForIntegratedFlow())
316         { iSelParticlesInt++; }
317       if (pTrack->UseForDifferentialFlow())
318         { iSelParticlesDiff++; }
319     }
320     
321     itrkN++; 
322   }
323   
324   pEvent-> SetEventNSelTracksIntFlow(iSelParticlesInt);  
325   pEvent-> SetNumberOfTracks(iGoodTracks);
326   cout<<" iGoodTracks = "<<iGoodTracks<<endl;
327   //cout << "  iSelectedTracksInt = " << iSelParticlesInt << endl;  
328   return pEvent;
329
330 }
331
332
333 //-----------------------------------------------------------------------   
334 AliFlowEventSimple* AliFlowEventSimpleMaker::FillTracks(AliESDEvent* anInput)
335 {
336   //Fills the event from the ESD
337   
338   Int_t iNumberOfInputTracks = anInput->GetNumberOfTracks() ;
339   cerr<<"anInput->GetNumberOfTracks() = "<<iNumberOfInputTracks<<endl;
340   
341   AliFlowEventSimple* pEvent = new AliFlowEventSimple(10);
342     
343   //Int_t iN = 256; //multiplicity for chi=1
344   Int_t iN = iNumberOfInputTracks;
345   Int_t iGoodTracks = 0;
346   Int_t itrkN = 0;
347   Int_t iSelParticlesDiff = 0;
348   Int_t iSelParticlesInt = 0;
349
350  
351   
352   //normal loop
353   while (iGoodTracks < iN && itrkN < iNumberOfInputTracks) {
354     AliESDtrack* pParticle = anInput->GetTrack(itrkN);   //get input particle
355     //cut on tracks
356     if (TMath::Abs(pParticle->Eta()) < 0.9)
357     
358    
359     
360     {
361         AliFlowTrackSimple* pTrack = new AliFlowTrackSimple();
362         pTrack->SetPt(pParticle->Pt() );
363         pTrack->SetEta(pParticle->Eta() );
364         pTrack->SetPhi(pParticle->Phi() );
365         pTrack->SetForIntegratedFlow(kTRUE);
366         pTrack->SetForDifferentialFlow(kTRUE);
367
368         if (pTrack->UseForIntegratedFlow())
369           { iSelParticlesInt++; }
370         if (pTrack->UseForDifferentialFlow())
371           { iSelParticlesDiff++; }
372         iGoodTracks++;
373         pEvent->TrackCollection()->Add(pTrack) ;             
374       }
375       
376     itrkN++; 
377   }
378   
379   pEvent-> SetEventNSelTracksIntFlow(iSelParticlesInt);  
380   pEvent->SetNumberOfTracks(iGoodTracks);
381   cout<<" iGoodTracks = "<<iGoodTracks<<endl;
382   //cout << "  iSelectedTracksInt = " << iSelParticlesInt << endl;  
383   return pEvent;
384
385
386 }
387
388
389 //-----------------------------------------------------------------------   
390 AliFlowEventSimple* AliFlowEventSimpleMaker::FillTracks(AliESDEvent* anInput, AliCFManager* intCFManager, AliCFManager* diffCFManager)
391 {
392   //Fills the event from the ESD
393   
394   Int_t iNumberOfInputTracks = anInput->GetNumberOfTracks() ;
395   cerr<<"anInput->GetNumberOfTracks() = "<<iNumberOfInputTracks<<endl;
396   
397   AliFlowEventSimple* pEvent = new AliFlowEventSimple(10);
398     
399   Int_t iN = iNumberOfInputTracks; //maximum number of tracks in AliFlowEventSimple
400   Int_t iGoodTracks = 0;           //number of good tracks
401   Int_t itrkN = 0;                 //track counter
402   Int_t iSelParticlesDiff = 0;     //number of tracks selected for Diff
403   Int_t iSelParticlesInt = 0;      //number of tracks selected for Int
404
405   //normal loop
406   while (iGoodTracks < iN && itrkN < iNumberOfInputTracks) {
407     AliESDtrack* pParticle = anInput->GetTrack(itrkN);   //get input particle
408     //make new AliFLowTrackSimple
409     AliFlowTrackSimple* pTrack = new AliFlowTrackSimple();
410     pTrack->SetPt(pParticle->Pt() );
411     pTrack->SetEta(pParticle->Eta() );
412     pTrack->SetPhi(pParticle->Phi() );
413     //check if pParticle passes the cuts
414
415     if (intCFManager->CheckParticleCuts(AliCFManager::kPartRecCuts,pParticle) && 
416         intCFManager->CheckParticleCuts(AliCFManager::kPartSelCuts,pParticle)) {
417       pTrack->SetForIntegratedFlow(kTRUE);
418     }
419     if (diffCFManager->CheckParticleCuts(AliCFManager::kPartRecCuts,pParticle) && 
420         diffCFManager->CheckParticleCuts(AliCFManager::kPartSelCuts,pParticle)) {
421       pTrack->SetForDifferentialFlow(kTRUE);}
422
423     //check if any bits are set
424     TBits bFlowBits = pTrack->GetFlowBits();
425     if (bFlowBits.CountBits() ==0) {
426       delete pTrack; } //track will not be used anymore
427     else {
428       pEvent->TrackCollection()->Add(pTrack) ;  
429       iGoodTracks++;
430
431       if (pTrack->UseForIntegratedFlow())
432         { iSelParticlesInt++; }
433       if (pTrack->UseForDifferentialFlow())
434         { iSelParticlesDiff++; }
435       
436     }
437     
438     itrkN++; 
439   }
440   
441   pEvent-> SetEventNSelTracksIntFlow(iSelParticlesInt);  
442   pEvent->SetNumberOfTracks(iGoodTracks);
443   cout<<" iGoodTracks = "<<iGoodTracks<<endl;
444   //cout << "  iSelectedTracksInt = " << iSelParticlesInt << endl;  
445   return pEvent;
446
447
448 }
449
450 //-----------------------------------------------------------------------   
451 AliFlowEventSimple* AliFlowEventSimpleMaker::FillTracks(AliAODEvent* anInput)
452 {
453   //Fills the event from the AOD
454   
455   Int_t iNumberOfInputTracks = anInput->GetNumberOfTracks() ;
456   cerr<<"anInput->GetNumberOfTracks() = "<<iNumberOfInputTracks<<endl;
457   
458   AliFlowEventSimple* pEvent = new AliFlowEventSimple(10);
459     
460   //Int_t iN = 256; //multiplicity for chi=1
461   Int_t iN = iNumberOfInputTracks;
462   Int_t iGoodTracks = 0;
463   Int_t itrkN = 0;
464   Int_t iSelParticlesDiff = 0;
465   Int_t iSelParticlesInt = 0;
466   
467   //normal loop
468   while (iGoodTracks < iN && itrkN < iNumberOfInputTracks) {
469     AliAODTrack* pParticle = anInput->GetTrack(itrkN);   //get input particle
470     //cut on tracks
471     if (TMath::Abs(pParticle->Eta()) < 0.9)
472       {
473         AliFlowTrackSimple* pTrack = new AliFlowTrackSimple();
474         pTrack->SetPt(pParticle->Pt() );
475         pTrack->SetEta(pParticle->Eta() );
476         pTrack->SetPhi(pParticle->Phi() );
477         pTrack->SetForIntegratedFlow(kTRUE);
478         pTrack->SetForDifferentialFlow(kTRUE);
479
480         if (pTrack->UseForIntegratedFlow())
481           { iSelParticlesInt++; }
482         if (pTrack->UseForDifferentialFlow())
483           { iSelParticlesDiff++; }
484         iGoodTracks++;
485         pEvent->TrackCollection()->Add(pTrack) ;             
486       }
487       
488     itrkN++; 
489   }
490   
491   pEvent-> SetEventNSelTracksIntFlow(iSelParticlesInt);  
492   pEvent->SetNumberOfTracks(iGoodTracks);
493   cout<<" iGoodTracks = "<<iGoodTracks<<endl;
494   //cout << "  iSelectedTracksInt = " << iSelParticlesInt << endl;  
495   return pEvent;
496   
497 }
498
499
500 //-----------------------------------------------------------------------   
501 AliFlowEventSimple* AliFlowEventSimpleMaker::FillTracks(AliAODEvent* anInput,  AliCFManager* intCFManager, AliCFManager* diffCFManager)
502 {
503   //Fills the event from the AOD
504   
505   Int_t iNumberOfInputTracks = anInput->GetNumberOfTracks() ;
506   cerr<<"anInput->GetNumberOfTracks() = "<<iNumberOfInputTracks<<endl;
507   
508   AliFlowEventSimple* pEvent = new AliFlowEventSimple(10);
509   
510   Int_t iN = iNumberOfInputTracks; //maximum number of tracks in AliFlowEventSimple
511   Int_t iGoodTracks = 0;           //number of good tracks
512   Int_t itrkN = 0;                 //track counter
513   Int_t iSelParticlesDiff = 0;     //number of tracks selected for Diff
514   Int_t iSelParticlesInt = 0;      //number of tracks selected for Int
515
516   //normal loop
517   while (iGoodTracks < iN && itrkN < iNumberOfInputTracks) {
518     AliAODTrack* pParticle = anInput->GetTrack(itrkN);   //get input particle
519     //make new AliFlowTrackSimple
520     AliFlowTrackSimple* pTrack = new AliFlowTrackSimple();
521     pTrack->SetPt(pParticle->Pt() );
522     pTrack->SetEta(pParticle->Eta() );
523     pTrack->SetPhi(pParticle->Phi() );
524
525     //check if pParticle passes the cuts
526     if (intCFManager->CheckParticleCuts(AliCFManager::kPartRecCuts,pParticle) &&
527         intCFManager->CheckParticleCuts(AliCFManager::kPartSelCuts,pParticle)) {          
528       pTrack->SetForIntegratedFlow(kTRUE); }
529     if (diffCFManager->CheckParticleCuts(AliCFManager::kPartRecCuts,pParticle) &&
530         diffCFManager->CheckParticleCuts(AliCFManager::kPartSelCuts,pParticle)) {
531       pTrack->SetForDifferentialFlow(kTRUE);}   
532
533     //check if any bits are set
534     TBits bFlowBits = pTrack->GetFlowBits();
535     if (bFlowBits.CountBits() ==0) {
536       delete pTrack; } //track will not be used anymore
537     else {
538       pEvent->TrackCollection()->Add(pTrack) ; 
539       iGoodTracks++;
540
541       if (pTrack->UseForIntegratedFlow())
542         { iSelParticlesInt++; }
543       if (pTrack->UseForDifferentialFlow())
544         { iSelParticlesDiff++; }
545              
546     }
547        
548     itrkN++; 
549   }
550   
551   pEvent-> SetEventNSelTracksIntFlow(iSelParticlesInt);  
552   pEvent->SetNumberOfTracks(iGoodTracks);
553   cout<<" iGoodTracks = "<<iGoodTracks<<endl;
554   //cout << "  iSelectedTracksInt = " << iSelParticlesInt << endl;  
555   return pEvent;
556   
557 }
558
559 //-----------------------------------------------------------------------   
560 AliFlowEventSimple*  AliFlowEventSimpleMaker::FillTracks(AliESDEvent* anInput, AliMCEvent* anInputMc, Int_t anOption)
561 {
562   //fills the event with tracks from the ESD and kinematics from the MC info via the track label
563
564   if (!(anOption ==0 || anOption ==1)) {
565     cout<<"WRONG OPTION IN AliFlowEventSimpleMaker::FillTracks(AliESDEvent* anInput, AliMCEvent* anInputMc, Int_t anOption)"<<endl;
566     exit(1);
567   }
568
569   Int_t iNumberOfInputTracks = anInput->GetNumberOfTracks() ;
570   cerr<<"anInput->GetNumberOfTracks() = "<<iNumberOfInputTracks<<endl;
571   
572   AliFlowEventSimple* pEvent = new AliFlowEventSimple(10);
573     
574   //Int_t iN = 256; //multiplicity for chi=1
575   Int_t iN = iNumberOfInputTracks;
576   Int_t iGoodTracks = 0;
577   Int_t itrkN = 0;
578   Int_t iSelParticlesDiff = 0;
579   Int_t iSelParticlesInt = 0;
580
581   //normal loop
582   while (iGoodTracks < iN && itrkN < iNumberOfInputTracks) {
583     AliESDtrack* pParticle = anInput->GetTrack(itrkN);   //get input particle
584     //get Label
585     Int_t iLabel = pParticle->GetLabel();
586     //match to mc particle
587     AliMCParticle* pMcParticle = anInputMc->GetTrack(TMath::Abs(iLabel));
588     
589     //check
590     if (TMath::Abs(pParticle->GetLabel())!=pMcParticle->Label()) cout<<"pParticle->GetLabel()!=pMcParticle->Label() "<<pParticle->GetLabel()<<"  "<<pMcParticle->Label()<<endl;
591     
592     //cut on tracks
593     if (TMath::Abs(pParticle->Eta()) < 0.2)
594       {
595         if(
596            TMath::Abs(pMcParticle->Particle()->GetPdgCode()) == 211 //pions
597            //         TMath::Abs(pMcParticle->Particle()->GetPdgCode()) == 211 ||
598            //         TMath::Abs(pMcParticle->Particle()->GetPdgCode()) == 321 ||
599            //         TMath::Abs(pMcParticle->Particle()->GetPdgCode()) == 2212
600            )
601           {
602             AliFlowTrackSimple* pTrack = new AliFlowTrackSimple();
603             if(anOption == 0) { //take the PID from the MC & the kinematics from the ESD
604               pTrack->SetPt(pParticle->Pt() );
605               pTrack->SetEta(pParticle->Eta() );
606               pTrack->SetPhi(pParticle->Phi() );
607               pTrack->SetForIntegratedFlow(kTRUE);
608               pTrack->SetForDifferentialFlow(kTRUE);
609             }
610             else if (anOption == 1) { //take the PID and kinematics from the MC
611               pTrack->SetPt(pMcParticle->Pt() );
612               pTrack->SetEta(pMcParticle->Eta() );
613               pTrack->SetPhi(pMcParticle->Phi() );
614               pTrack->SetForIntegratedFlow(kTRUE);
615               pTrack->SetForDifferentialFlow(kTRUE);
616             }
617             else { cout<<"Not a valid option"<<endl; }
618             if (pTrack->UseForIntegratedFlow())
619               { iSelParticlesInt++; }
620             if (pTrack->UseForDifferentialFlow())
621               { iSelParticlesDiff++; }
622             iGoodTracks++;
623             pEvent->TrackCollection()->Add(pTrack) ;         
624           }
625       }
626     itrkN++; 
627   }
628   
629   pEvent-> SetEventNSelTracksIntFlow(iSelParticlesInt);  
630   pEvent->SetNumberOfTracks(iGoodTracks);
631   cout<<" iGoodTracks = "<<iGoodTracks<<endl;
632   //cout << "  iSelectedTracksInt = " << iSelParticlesInt << endl;  
633   return pEvent;
634
635
636 }
637
638 //-----------------------------------------------------------------------   
639 AliFlowEventSimple*  AliFlowEventSimpleMaker::FillTracks(AliESDEvent* anInput, AliMCEvent* anInputMc, AliCFManager* intCFManager, AliCFManager* diffCFManager, Int_t anOption)
640 {
641   //fills the event with tracks from the ESD and kinematics from the MC info via the track label
642
643   
644   if (!(anOption ==0 || anOption ==1)) {
645     cout<<"WRONG OPTION IN AliFlowEventSimpleMaker::FillTracks(AliESDEvent* anInput, AliMCEvent* anInputMc, Int_t anOption)"<<endl;
646     exit(1);
647   }
648
649   Int_t iNumberOfInputTracks = anInput->GetNumberOfTracks() ;
650   cerr<<"anInput->GetNumberOfTracks() = "<<iNumberOfInputTracks<<endl;
651   Int_t iNumberOfInputTracksMC = anInputMc->GetNumberOfTracks() ;
652   cerr<<"anInputMc->GetNumberOfTracks() = "<<iNumberOfInputTracksMC<<endl;
653   if (iNumberOfInputTracksMC==-1) {
654     cout<<"Skipping Event -- No MC information available for this event"<<endl;
655     return 0;
656   }
657
658   AliFlowEventSimple* pEvent = new AliFlowEventSimple(10);
659     
660   Int_t iN = iNumberOfInputTracks; //maximum number of tracks in AliFlowEventSimple
661   Int_t iGoodTracks = 0;           //number of good tracks
662   Int_t itrkN = 0;                 //track counter
663   Int_t iSelParticlesDiff = 0;     //number of tracks selected for Diff
664   Int_t iSelParticlesInt = 0;      //number of tracks selected for Int
665
666  
667   //normal loop
668   while (iGoodTracks < iN && itrkN < iNumberOfInputTracks) {
669     AliESDtrack* pParticle = anInput->GetTrack(itrkN);   //get input particle
670     //get Label
671     Int_t iLabel = pParticle->GetLabel();
672     //match to mc particle
673     AliMCParticle* pMcParticle = anInputMc->GetTrack(TMath::Abs(iLabel));
674     
675     //check
676     if (TMath::Abs(pParticle->GetLabel())!=pMcParticle->Label()) cout<<"pParticle->GetLabel()!=pMcParticle->Label() "<<pParticle->GetLabel()<<"  "<<pMcParticle->Label()<<endl;
677     
678     //make new AliFlowTrackSimple
679     AliFlowTrackSimple* pTrack = new AliFlowTrackSimple();
680     if(anOption == 0) { //take the PID from the MC & the kinematics from the ESD
681       pTrack->SetPt(pParticle->Pt() );
682       pTrack->SetEta(pParticle->Eta() );
683       pTrack->SetPhi(pParticle->Phi() );
684     }
685     else if (anOption == 1) { //take the PID and kinematics from the MC
686       pTrack->SetPt(pMcParticle->Pt() );
687       pTrack->SetEta(pMcParticle->Eta() );
688       pTrack->SetPhi(pMcParticle->Phi() );
689     }
690     else { cout<<"Not a valid option"<<endl; }
691
692     //check if pParticle passes the cuts
693     if(anOption == 0) { 
694       //cout<<"take the PID from the MC & the kinematics from the ESD"<<endl;
695       if (intCFManager->CheckParticleCuts(AliCFManager::kPartGenCuts,pMcParticle,"mcGenCuts1") && 
696           intCFManager->CheckParticleCuts(AliCFManager::kPartRecCuts,pParticle)) {  
697         pTrack->SetForIntegratedFlow(kTRUE); }
698       if (diffCFManager->CheckParticleCuts(AliCFManager::kPartGenCuts,pMcParticle,"mcGenCuts2") &&
699           diffCFManager->CheckParticleCuts(AliCFManager::kPartRecCuts,pParticle)) {  
700         pTrack->SetForDifferentialFlow(kTRUE);}
701     }
702     else if (anOption == 1) { 
703       //cout<<"take the PID and kinematics from the MC"<<endl;
704       if (intCFManager->CheckParticleCuts(AliCFManager::kPartGenCuts,pMcParticle)) {  
705         pTrack->SetForIntegratedFlow(kTRUE); }
706       if (diffCFManager->CheckParticleCuts(AliCFManager::kPartGenCuts,pMcParticle)) {  
707         pTrack->SetForDifferentialFlow(kTRUE);}
708     }
709     else { cout<<"Not a valid option"<<endl; }
710       
711     //check if any bits are set
712     TBits bFlowBits = pTrack->GetFlowBits();
713     if (bFlowBits.CountBits() ==0) {
714       delete pTrack; } //track will not be used anymore
715     else {
716       pEvent->TrackCollection()->Add(pTrack) ; 
717       iGoodTracks++;  
718     
719       if (pTrack->UseForIntegratedFlow())
720         { iSelParticlesInt++; }
721       if (pTrack->UseForDifferentialFlow())
722         { iSelParticlesDiff++; }
723              
724     }
725     
726     itrkN++; 
727   }
728   
729   pEvent-> SetEventNSelTracksIntFlow(iSelParticlesInt);  
730   pEvent->SetNumberOfTracks(iGoodTracks);
731   cout<<" iGoodTracks = "<<iGoodTracks<<endl;
732   //cout << "  iSelectedTracksInt = " << iSelParticlesInt << endl;  
733   return pEvent;
734
735 }
736
737
738
739
740
741