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