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