]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG/FLOW/Tasks/AliFlowEventSimpleMaker.cxx
e218a0b27918b6a0b468f979fd4579b2a0890e17
[u/mrichter/AliRoot.git] / PWG / FLOW / Tasks / 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 /////////////////////////////////////////////////////////////////////////
16 // AliFlowEventSimpleMaker:
17 //
18 // Class to fill the AliFlowEventSimple
19 // with AliFlowTrackSimple objects
20 // Has fill methods for TTree, AliMCEvent, AliESDEvent and AliAODEvent
21 // author: N. van der Kolk (kolk@nikhef.nl)
22 /////////////////////////////////////////////////////////////////////////
23
24 #include "Riostream.h"
25 #include "TTree.h"
26 #include "TParticle.h"
27 #include "AliFlowEventSimpleMaker.h"
28 #include "AliFlowEventSimple.h"
29 #include "AliFlowTrackSimple.h"
30 #include "AliMCEvent.h"
31 #include "AliMCParticle.h"
32 #include "AliESDEvent.h"
33 #include "AliESDtrack.h"
34 #include "AliAODEvent.h"
35 #include "AliAODTrack.h"
36 #include "AliCFManager.h"
37 #include "AliFlowTrackSimpleCuts.h"
38
39 using std::endl;
40 using std::cout;
41 ClassImp(AliFlowEventSimpleMaker)
42 //----------------------------------------------------------------------- 
43 AliFlowEventSimpleMaker::AliFlowEventSimpleMaker() :
44   fMCReactionPlaneAngle(0.),
45   fCount(0),
46   fNoOfLoops(1),
47   fEllipticFlowValue(0.),
48   fMultiplicityOfEvent(1000000000),
49   fMinMult(0),
50   fMaxMult(1000000000),
51   fEtaMinA(-1.0),
52   fEtaMaxA(-0.01),
53   fEtaMinB(0.01),
54   fEtaMaxB(1.0)
55 {
56   //constructor
57 }
58
59 //-----------------------------------------------------------------------   
60 AliFlowEventSimpleMaker::~AliFlowEventSimpleMaker()
61 {
62   //destructor
63 }
64
65 //-----------------------------------------------------------------------   
66 AliFlowEventSimple* AliFlowEventSimpleMaker::FillTracks( AliMCEvent* anInput, const AliCFManager* intCFManager, const AliCFManager* diffCFManager)
67 {
68   //Fills the event from the MC kinematic information
69   
70   Int_t iNumberOfInputTracks = anInput->GetNumberOfTracks() ;
71
72   if (iNumberOfInputTracks==-1) {
73     cout<<"Skipping Event -- No MC information available for this event"<<endl;
74     return 0;
75   }
76
77   Int_t iN = iNumberOfInputTracks; //maximum number of tracks in AliFlowEventSimple
78   Int_t iGoodTracks = 0;           //number of good tracks
79   Int_t itrkN = 0;                 //track counter
80   Int_t iSelParticlesPOI = 0;     //number of tracks selected for Diff
81   Int_t iSelParticlesRP = 0;      //number of tracks selected for Int
82
83   // cut on the multiplicity
84   if (intCFManager->CheckEventCuts(AliCFManager::kEvtGenCuts,anInput)) {
85     // cout<<"iNumberOfInputTracks = "<<iNumberOfInputTracks<<endl;
86     // create an AliFlowEventSimple
87     AliFlowEventSimple* pEvent = new AliFlowEventSimple(10);
88        
89     //loop over tracks
90     while (iGoodTracks < iN && itrkN < iNumberOfInputTracks) {
91       //get input particle
92       AliMCParticle* pParticle = (AliMCParticle*) anInput->GetTrack(itrkN);   
93       //make new AliFlowTrackSimple
94       AliFlowTrackSimple* pTrack = new AliFlowTrackSimple();
95       pTrack->SetPt(pParticle->Pt() );
96       pTrack->SetEta(pParticle->Eta() );
97       pTrack->SetPhi(pParticle->Phi() );
98     
99       //check if pParticle passes the cuts
100       if (intCFManager->CheckParticleCuts(AliCFManager::kPartGenCuts,pParticle)) {
101         pTrack->SetForRPSelection(kTRUE);
102         //cout<<"integrated selection. PID = "<<pParticle->Particle()->GetPdgCode()<<endl; 
103       }
104       if (diffCFManager->CheckParticleCuts(AliCFManager::kPartGenCuts,pParticle)) {
105         pTrack->SetForPOISelection(kTRUE);
106         //cout<<"differential selection. PID = "<<pParticle->Particle()->GetPdgCode()<<endl; 
107       }
108       
109       //check if any bits are set
110       const TBits* bFlowBits = pTrack->GetFlowBits();
111       if (bFlowBits->CountBits() ==0) {
112         delete pTrack; } //track will not be used anymore
113       else {
114         pEvent->AddTrack(pTrack) ; 
115         iGoodTracks++;
116
117         if (pTrack->InRPSelection())
118           { iSelParticlesRP++; }
119         if (pTrack->InPOISelection())
120           { iSelParticlesPOI++; }
121       }
122       
123       itrkN++; 
124     }
125     
126     pEvent-> SetEventNSelTracksRP(iSelParticlesRP);  
127     pEvent->SetMCReactionPlaneAngle(fMCReactionPlaneAngle);
128         
129     if (iSelParticlesRP >= fMinMult && iSelParticlesRP <= fMaxMult) { 
130       if ( (++fCount % 100) == 0) {
131         cout<<" MC Reaction Plane Angle = "<<  fMCReactionPlaneAngle << endl;
132         //
133         cout<<" iGoodTracks = "<<iGoodTracks<<endl;
134         cout<<" # of RP selected tracks = "<<iSelParticlesRP<<endl;
135         cout<<" # of POI selected tracks = "<<iSelParticlesPOI<<endl;  
136         cout << "# " << fCount << " events processed" << endl;
137       }
138       return pEvent;
139     }
140     else { 
141       cout<<"Not enough tracks in the FlowEventSimple"<<endl;
142       return 0;
143     }
144   }
145   else {
146     cout<<"Event does not pass multiplicity cuts"<<endl; 
147     return 0;
148   }
149   
150 }
151
152 //-----------------------------------------------------------------------   
153
154 AliFlowEventSimple* AliFlowEventSimpleMaker::FillTracks(AliESDEvent* anInput, const AliCFManager* intCFManager, const AliCFManager* diffCFManager)
155 {
156   //Fills the event from the ESD
157   
158   //flags for particles passing int. and diff. flow cuts
159   Bool_t bPassedRPFlowCuts  = kFALSE;
160   Bool_t bPassedPOIFlowCuts = kFALSE;
161   
162   Int_t iNumberOfInputTracks = anInput->GetNumberOfTracks() ;
163   
164   Int_t iGoodTracks = 0;           //number of good tracks
165   Int_t itrkN = 0;                 //track counter
166   Int_t iSelParticlesRP = 0;      //number of tracks selected for Int
167   Int_t iSelParticlesPOI = 0;     //number of tracks selected for Diff
168   
169   // cut on the multiplicity
170   if (intCFManager->CheckEventCuts(AliCFManager::kEvtRecCuts,anInput)) {
171     // cout<<"iNumberOfInputTracks = "<<iNumberOfInputTracks<<endl; 
172     // create an AliFlowEventSimple
173     AliFlowEventSimple* pEvent = new AliFlowEventSimple(10);
174
175     //loop over tracks
176     while (itrkN < iNumberOfInputTracks) {
177       AliESDtrack* pParticle = anInput->GetTrack(itrkN);   //get input particle
178       
179       //check if pParticle passes the cuts
180       if (intCFManager->CheckParticleCuts(AliCFManager::kPartRecCuts,pParticle) && 
181           intCFManager->CheckParticleCuts(AliCFManager::kPartSelCuts,pParticle)) {
182         bPassedRPFlowCuts = kTRUE;
183       }
184       if (diffCFManager->CheckParticleCuts(AliCFManager::kPartRecCuts,pParticle) && 
185           diffCFManager->CheckParticleCuts(AliCFManager::kPartSelCuts,pParticle)) {
186         bPassedPOIFlowCuts = kTRUE;
187       }
188       
189       if (bPassedRPFlowCuts || bPassedPOIFlowCuts) {
190         //make new AliFLowTrackSimple
191         AliFlowTrackSimple* pTrack = new AliFlowTrackSimple();
192         pTrack->SetPt(pParticle->Pt() );
193         pTrack->SetEta(pParticle->Eta() );
194         if (fEllipticFlowValue>0.) 
195           { pTrack->SetPhi(pParticle->Phi()-fEllipticFlowValue*TMath::Sin(2*(pParticle->Phi()-fMCReactionPlaneAngle))); cout<<"Added flow to particle"<<endl; }
196         else { pTrack->SetPhi(pParticle->Phi() ); }     
197
198         //marking the particles used for int. flow:
199         if(bPassedRPFlowCuts) {  
200           pTrack->SetForRPSelection(kTRUE);
201           iSelParticlesRP++;
202           // assign particles to subevents
203           if (pTrack->Eta()>=fEtaMinA && pTrack->Eta()<=fEtaMaxA) {
204             pTrack->SetForSubevent(0);
205           }
206           if (pTrack->Eta()>=fEtaMinB && pTrack->Eta()<=fEtaMaxB) {
207             pTrack->SetForSubevent(1);
208           }
209
210         }
211         //marking the particles used for diff. flow:
212         if(bPassedPOIFlowCuts) {
213           pTrack->SetForPOISelection(kTRUE);
214           iSelParticlesPOI++;
215         }
216         //adding particles which were used either for int. or diff. flow to the list
217         pEvent->AddTrack(pTrack);
218         iGoodTracks++;
219       }//end of if(bPassedIntFlowCuts || bPassedDiffFlowCuts) 
220       itrkN++; 
221       bPassedRPFlowCuts  = kFALSE;
222       bPassedPOIFlowCuts = kFALSE;
223     }//end of while (itrkN < iNumberOfInputTracks)
224     
225     pEvent->SetEventNSelTracksRP(iSelParticlesRP);  
226     pEvent->SetMCReactionPlaneAngle(fMCReactionPlaneAngle);
227     
228     
229     if (iSelParticlesRP >= fMinMult && iSelParticlesRP <= fMaxMult) { 
230       if ( (++fCount % 100) == 0) {
231         if (!fMCReactionPlaneAngle == 0) cout<<" MC Reaction Plane Angle = "<<  fMCReactionPlaneAngle << endl;
232         else cout<<" MC Reaction Plane Angle = unknown "<< endl;
233         cout<<" iGoodTracks = "<<iGoodTracks<<endl;
234         cout<<" # of RP selected tracks = "<<iSelParticlesRP<<endl;
235         cout<<" # of POI selected tracks = "<<iSelParticlesPOI<<endl;  
236         cout << "# " << fCount << " events processed" << endl;
237       }
238       return pEvent;
239     }
240     else {
241       cout<<"Not enough tracks in the FlowEventSimple"<<endl;
242       return 0;
243     }
244   }
245   else {
246     cout<<"Event does not pass multiplicity cuts"<<endl; 
247     return 0;
248   }
249   
250 }
251
252 //-----------------------------------------------------------------------   
253 AliFlowEventSimple* AliFlowEventSimpleMaker::FillTracks(AliAODEvent* anInput,  const AliCFManager* intCFManager, const AliCFManager* diffCFManager)
254 {
255   //Fills the event from the AOD
256   
257   Int_t iNumberOfInputTracks = anInput->GetNumberOfTracks() ;
258   
259   Int_t iN = iNumberOfInputTracks; //maximum number of tracks in AliFlowEventSimple
260   Int_t iGoodTracks = 0;           //number of good tracks
261   Int_t itrkN = 0;                 //track counter
262   Int_t iSelParticlesPOI = 0;     //number of tracks selected for Diff
263   Int_t iSelParticlesRP = 0;      //number of tracks selected for Int
264
265   // cut on the multiplicity
266   if (intCFManager->CheckEventCuts(AliCFManager::kEvtRecCuts,anInput)) {
267     // cout<<"iNumberOfInputTracks = "<<iNumberOfInputTracks<<endl; 
268     // create an AliFlowEventSimple
269     AliFlowEventSimple* pEvent = new AliFlowEventSimple(10);
270
271     //loop over tracks
272     while (iGoodTracks < iN && itrkN < iNumberOfInputTracks) {
273       AliAODTrack* pParticle = anInput->GetTrack(itrkN);   //get input particle
274       //make new AliFlowTrackSimple
275       AliFlowTrackSimple* pTrack = new AliFlowTrackSimple();
276       pTrack->SetPt(pParticle->Pt() );
277       pTrack->SetEta(pParticle->Eta() );
278       pTrack->SetPhi(pParticle->Phi() );
279       
280       //check if pParticle passes the cuts
281       if (intCFManager->CheckParticleCuts(AliCFManager::kPartRecCuts,pParticle) &&
282           intCFManager->CheckParticleCuts(AliCFManager::kPartSelCuts,pParticle)) {          
283         pTrack->SetForRPSelection(kTRUE); }
284       if (diffCFManager->CheckParticleCuts(AliCFManager::kPartRecCuts,pParticle) &&
285           diffCFManager->CheckParticleCuts(AliCFManager::kPartSelCuts,pParticle)) {
286         pTrack->SetForPOISelection(kTRUE);}     
287       
288       
289       //check if any bits are set
290       const TBits* bFlowBits = pTrack->GetFlowBits();
291       if (bFlowBits->CountBits() ==0) {
292         delete pTrack; } //track will not be used anymore
293       else {
294         pEvent->AddTrack(pTrack) ; 
295         iGoodTracks++;
296         
297         if (pTrack->InRPSelection())
298           { iSelParticlesRP++; }
299         if (pTrack->InPOISelection())
300           { iSelParticlesPOI++; }
301         
302       }
303       
304       itrkN++; 
305     }
306     
307     pEvent-> SetEventNSelTracksRP(iSelParticlesRP);  
308     pEvent->SetMCReactionPlaneAngle(fMCReactionPlaneAngle);
309     
310     if (iSelParticlesRP >= fMinMult && iSelParticlesRP <= fMaxMult) { 
311       if ( (++fCount % 100) == 0) {
312         if (!fMCReactionPlaneAngle == 0) cout<<" MC Reaction Plane Angle = "<<  fMCReactionPlaneAngle << endl;
313         else cout<<" MC Reaction Plane Angle = unknown "<< endl;
314         cout<<" iGoodTracks = "<<iGoodTracks<<endl;
315         cout<<" # of RP selected tracks = "<<iSelParticlesRP<<endl;
316         cout<<" # of POI selected tracks = "<<iSelParticlesPOI<<endl;  
317         cout << "# " << fCount << " events processed" << endl;
318       }
319       return pEvent;
320     }
321     else {
322       cout<<"Not enough tracks in the FlowEventSimple"<<endl;
323       return 0;
324     }
325   }
326   else {
327     cout<<"Event does not pass multiplicity cuts"<<endl; 
328     return 0;
329   }
330   
331 }
332
333 //-----------------------------------------------------------------------   
334 AliFlowEventSimple*  AliFlowEventSimpleMaker::FillTracks(AliESDEvent* anInput, const AliMCEvent* anInputMc, const AliCFManager* intCFManager, const AliCFManager* diffCFManager, Int_t anOption)
335 {
336   //fills the event with tracks from the ESD and kinematics from the MC info via the track label
337
338   
339   if (!(anOption ==0 || anOption ==1)) {
340     cout<<"WRONG OPTION IN AliFlowEventSimpleMaker::FillTracks(AliESDEvent* anInput, AliMCEvent* anInputMc, Int_t anOption)"<<endl;
341     exit(1);
342   }
343
344   Int_t iNumberOfInputTracks = anInput->GetNumberOfTracks() ;
345
346   Int_t iNumberOfInputTracksMC = anInputMc->GetNumberOfTracks() ;
347   if (iNumberOfInputTracksMC==-1) {
348     cout<<"Skipping Event -- No MC information available for this event"<<endl;
349     return 0;
350   }
351
352   Int_t iN = iNumberOfInputTracks; //maximum number of tracks in AliFlowEventSimple
353   Int_t iGoodTracks = 0;           //number of good tracks
354   Int_t itrkN = 0;                 //track counter
355   Int_t iSelParticlesPOI = 0;     //number of tracks selected for Diff
356   Int_t iSelParticlesRP = 0;      //number of tracks selected for Int
357
358   // cut on the multiplicity
359   if (intCFManager->CheckEventCuts(AliCFManager::kEvtRecCuts,anInput)) {
360     // cout<<"iNumberOfInputTracks = "<<iNumberOfInputTracks<<endl; 
361     // create an AliFlowEventSimple
362     AliFlowEventSimple* pEvent = new AliFlowEventSimple(10);
363
364     //loop over ESD tracks
365     while (iGoodTracks < iN && itrkN < iNumberOfInputTracks) {
366       AliESDtrack* pParticle = anInput->GetTrack(itrkN);   //get input particle
367       //get Label
368       Int_t iLabel = pParticle->GetLabel();
369       //match to mc particle
370       AliMCParticle* pMcParticle = (AliMCParticle*) anInputMc->GetTrack(TMath::Abs(iLabel));
371       
372       //check
373       if (TMath::Abs(pParticle->GetLabel())!=pMcParticle->Label()) cout<<"pParticle->GetLabel()!=pMcParticle->Label() "<<pParticle->GetLabel()<<"  "<<pMcParticle->Label()<<endl;
374       
375       //make new AliFlowTrackSimple
376       AliFlowTrackSimple* pTrack = new AliFlowTrackSimple();
377       if(anOption == 0) { //take the PID from the MC & the kinematics from the ESD
378         pTrack->SetPt(pParticle->Pt() );
379         pTrack->SetEta(pParticle->Eta() );
380         pTrack->SetPhi(pParticle->Phi() );
381       }
382       else if (anOption == 1) { //take the PID and kinematics from the MC
383         pTrack->SetPt(pMcParticle->Pt() );
384         pTrack->SetEta(pMcParticle->Eta() );
385         pTrack->SetPhi(pMcParticle->Phi() );
386       }
387       else { cout<<"Not a valid option"<<endl; }
388       
389       //check if pParticle passes the cuts
390       if(anOption == 0) { 
391         //cout<<"take the PID from the MC & the kinematics from the ESD"<<endl;
392         if (intCFManager->CheckParticleCuts(AliCFManager::kPartGenCuts,pMcParticle,"mcGenCuts1") && 
393             intCFManager->CheckParticleCuts(AliCFManager::kPartRecCuts,pParticle)) {  
394           pTrack->SetForRPSelection(kTRUE); }
395         if (diffCFManager->CheckParticleCuts(AliCFManager::kPartGenCuts,pMcParticle,"mcGenCuts2") &&
396             diffCFManager->CheckParticleCuts(AliCFManager::kPartRecCuts,pParticle)) {  
397           pTrack->SetForPOISelection(kTRUE);}
398       }
399       else if (anOption == 1) { 
400         //cout<<"take the PID and kinematics from the MC"<<endl;
401         if (intCFManager->CheckParticleCuts(AliCFManager::kPartGenCuts,pMcParticle)) {  
402           pTrack->SetForRPSelection(kTRUE); }
403         if (diffCFManager->CheckParticleCuts(AliCFManager::kPartGenCuts,pMcParticle)) {  
404           pTrack->SetForPOISelection(kTRUE);}
405       }
406       else { cout<<"Not a valid option"<<endl; }
407       
408       //check if any bits are set
409       const TBits* bFlowBits = pTrack->GetFlowBits();
410       if (bFlowBits->CountBits() ==0) {
411         delete pTrack; } //track will not be used anymore
412       else {
413         pEvent->AddTrack(pTrack) ; 
414         iGoodTracks++;  
415         
416         if (pTrack->InRPSelection())
417           { iSelParticlesRP++; }
418         if (pTrack->InPOISelection())
419           { iSelParticlesPOI++; }
420         
421       }
422       
423       itrkN++; 
424     }
425     
426     pEvent->SetEventNSelTracksRP(iSelParticlesRP);  
427     pEvent->SetMCReactionPlaneAngle(fMCReactionPlaneAngle);
428         
429     if (iSelParticlesRP >= fMinMult && iSelParticlesRP <= fMaxMult) { 
430       if ( (++fCount % 100) == 0) {
431         if (!fMCReactionPlaneAngle == 0) cout<<" MC Reaction Plane Angle = "<<  fMCReactionPlaneAngle << endl;
432         else cout<<" MC Reaction Plane Angle = unknown "<< endl;
433         cout << " Number of MC input tracks = " << iNumberOfInputTracksMC << endl;
434         cout<<" iGoodTracks = "<<iGoodTracks<<endl;
435         cout<<" # of RP selected tracks = "<<iSelParticlesRP<<endl;
436         cout<<" # of POI selected tracks = "<<iSelParticlesPOI<<endl;  
437         cout << "# " << fCount << " events processed" << endl;
438       }
439       return pEvent;
440     }
441     else {
442       cout<<"Not enough tracks in the FlowEventSimple"<<endl;
443       return 0;
444     }
445   }
446   else {
447     cout<<"Event does not pass multiplicity cuts"<<endl; 
448     return 0;
449   }
450     
451 }
452
453 //local methods
454 //-----------------------------------------------------------------------   
455 AliFlowEventSimple* AliFlowEventSimpleMaker::FillTracks(TTree* anInput, const AliFlowTrackSimpleCuts* rpCuts, const AliFlowTrackSimpleCuts* poiCuts)
456 {
457   //fills the event from a TTree of kinematic.root files
458   
459   // number of times to use the same particle (trick to introduce nonflow)
460   
461   //flags for particles passing int. and diff. flow cuts
462   Bool_t bPassedRPFlowCuts  = kFALSE;
463   Bool_t bPassedPOIFlowCuts = kFALSE;
464   
465   //track cut values
466   Double_t dPtMaxRP  = rpCuts->GetPtMax();
467   Double_t dPtMinRP  = rpCuts->GetPtMin();
468   Double_t dEtaMaxRP = rpCuts->GetEtaMax();
469   Double_t dEtaMinRP = rpCuts->GetEtaMin();
470   Double_t dPhiMaxRP = rpCuts->GetPhiMax();
471   Double_t dPhiMinRP = rpCuts->GetPhiMin();
472   Int_t iPIDRP       = rpCuts->GetPID();
473   
474   Double_t dPtMaxPOI  = poiCuts->GetPtMax();
475   Double_t dPtMinPOI  = poiCuts->GetPtMin();
476   Double_t dEtaMaxPOI = poiCuts->GetEtaMax();
477   Double_t dEtaMinPOI = poiCuts->GetEtaMin();
478   Double_t dPhiMaxPOI = poiCuts->GetPhiMax();
479   Double_t dPhiMinPOI = poiCuts->GetPhiMin();
480   Int_t iPIDPOI       = poiCuts->GetPID();
481   
482   Int_t iNumberOfInputTracks = anInput->GetEntries() ;
483
484   TParticle* pParticle = new TParticle();
485   anInput->SetBranchAddress("Particles",&pParticle);  
486   //  AliFlowEventSimple* pEvent = new AliFlowEventSimple(iNumberOfInputTracks);
487   AliFlowEventSimple* pEvent = new AliFlowEventSimple(10);
488   
489   //  Int_t fMultiplicityOfEvent = 576; //multiplicity for chi=1.5
490   //  Int_t fMultiplicityOfEvent = 256; //multiplicity for chi=1
491   //  Int_t fMultiplicityOfEvent = 164; //multiplicity for chi=0.8
492
493   Int_t iGoodTracks = 0;
494   Int_t itrkN = 0;
495   Int_t iSelParticlesRP = 0;
496   Int_t iSelParticlesPOI = 0;
497   
498   while (itrkN < iNumberOfInputTracks) {
499     anInput->GetEntry(itrkN);   //get input particle
500     if (pParticle->IsPrimary()) {
501       //checking the cuts for int. and diff. flow
502       if (pParticle->Pt() > dPtMinRP && pParticle->Pt() < dPtMaxRP &&
503           pParticle->Eta() > dEtaMinRP && pParticle->Eta() < dEtaMaxRP &&
504           pParticle->Phi() > dPhiMinRP && pParticle->Phi() < dPhiMaxRP &&
505           TMath::Abs(pParticle->GetPdgCode()) == iPIDRP) { 
506         bPassedRPFlowCuts = kTRUE;
507       } 
508     
509       if (pParticle->Pt() > dPtMinPOI && pParticle->Pt() < dPtMaxPOI &&
510           pParticle->Eta() > dEtaMinPOI && pParticle->Eta() < dEtaMaxPOI &&
511           pParticle->Phi() > dPhiMinPOI && pParticle->Phi() < dPhiMaxPOI &&
512           TMath::Abs(pParticle->GetPdgCode()) == iPIDPOI){ 
513         bPassedPOIFlowCuts = kTRUE; 
514       }
515     }
516     if (bPassedRPFlowCuts || bPassedPOIFlowCuts) {
517       for(Int_t d=0;d<fNoOfLoops;d++) {
518         AliFlowTrackSimple* pTrack = new AliFlowTrackSimple();
519         pTrack->SetPt(pParticle->Pt());
520         pTrack->SetEta(pParticle->Eta());
521         pTrack->SetPhi(pParticle->Phi()-fEllipticFlowValue*TMath::Sin(2*(pParticle->Phi()-fMCReactionPlaneAngle)));
522         
523         //marking the particles used for int. flow:
524         if(bPassedRPFlowCuts && iSelParticlesRP < fMultiplicityOfEvent) {  
525           pTrack->SetForRPSelection(kTRUE);
526           iSelParticlesRP++;
527         }
528         //marking the particles used for diff. flow:
529         if(bPassedPOIFlowCuts && iGoodTracks%fNoOfLoops==0) {
530           pTrack->SetForPOISelection(kTRUE);
531           iSelParticlesPOI++;
532         }
533         //adding a particles which were used either for int. or diff. flow to the list
534         pEvent->AddTrack(pTrack);
535         iGoodTracks++;
536       }//end of for(Int_t d=0;d<iLoops;d++)
537     }//end of if(bPassedIntFlowCuts || bPassedDiffFlowCuts) 
538     itrkN++;  
539     bPassedRPFlowCuts  = kFALSE;
540     bPassedPOIFlowCuts = kFALSE;
541   }//end of while (itrkN < iNumberOfInputTracks)
542   
543   pEvent->SetEventNSelTracksRP(iSelParticlesRP);  
544   pEvent->SetMCReactionPlaneAngle(fMCReactionPlaneAngle);
545
546   if ( (++fCount % 100) == 0) {
547     if (!fMCReactionPlaneAngle == 0) cout<<" MC Reaction Plane Angle = "<<  fMCReactionPlaneAngle << endl;
548     else cout<<" MC Reaction Plane Angle = unknown "<< endl;
549     cout<<" iGoodTracks = "<< iGoodTracks << endl;
550     cout<<" # of RP selected tracks = "<<iSelParticlesRP<<endl;
551     cout<<" # of POI selected tracks = "<<iSelParticlesPOI<<endl;  
552     cout << "# " << fCount << " events processed" << endl;
553   }
554
555   delete pParticle;
556   return pEvent;
557 }
558
559 //-----------------------------------------------------------------------   
560 AliFlowEventSimple* AliFlowEventSimpleMaker::FillTracks(AliMCEvent* anInput)
561 {
562   //Fills the event from the MC kinematic information
563   
564   Int_t iNumberOfInputTracks = anInput->GetNumberOfTracks() ;
565  
566   AliFlowEventSimple* pEvent = new AliFlowEventSimple(10);
567     
568   //Int_t iN = 256; //multiplicity for chi=1
569   Int_t iN = iNumberOfInputTracks;
570   Int_t iGoodTracks = 0;
571   Int_t itrkN = 0;
572   Int_t iSelParticlesPOI = 0;
573   Int_t iSelParticlesRP = 0;
574
575   //normal loop
576   while (iGoodTracks < iN && itrkN < iNumberOfInputTracks) {
577     AliMCParticle* pParticle = (AliMCParticle*) anInput->GetTrack(itrkN);   //get input particle
578     //cut on tracks
579     if (TMath::Abs(pParticle->Eta()) < 0.9)
580       {
581         if(
582            TMath::Abs(pParticle->Particle()->GetPdgCode()) == 211
583            //         TMath::Abs(pParticle->Particle()->GetPdgCode()) == 211 ||
584            //         TMath::Abs(pParticle->Particle()->GetPdgCode()) == 321 ||
585            //         TMath::Abs(pParticle->Particle()->GetPdgCode()) == 2212
586            )
587           {
588             AliFlowTrackSimple* pTrack = new AliFlowTrackSimple();
589             pTrack->SetPt(pParticle->Pt() );
590             pTrack->SetEta(pParticle->Eta() );
591             pTrack->SetPhi(pParticle->Phi() );
592             pTrack->SetForRPSelection(kTRUE);
593             pTrack->SetForPOISelection(kTRUE);
594
595             if (pTrack->InRPSelection())
596               { iSelParticlesRP++; }
597             if (pTrack->InPOISelection())
598               { iSelParticlesPOI++; }
599             iGoodTracks++;
600             pEvent->AddTrack(pTrack) ;               
601           }
602         /*        else if(
603                   TMath::Abs(pParticle->Particle()->GetPdgCode()) == 211
604                   )
605             {
606               AliFlowTrackSimple* pTrack = new AliFlowTrackSimple();
607               pTrack->SetPt(pParticle->Pt() );
608               pTrack->SetEta(pParticle->Eta() );
609               pTrack->SetPhi(pParticle->Phi() );
610               pTrack->SetForRPSelection(kFALSE);
611               pTrack->SetForPOISelection(kTRUE);
612
613               if (pTrack->InRPSelection())
614                 { iSelParticlesRP++; }
615               if (pTrack->InPOISelection())
616                 { iSelParticlesPOI++; }
617               iGoodTracks++;
618               pEvent->AddTrack(pTrack);              
619             }
620           */
621       }
622       
623     itrkN++; 
624   }
625   
626   pEvent-> SetEventNSelTracksRP(iSelParticlesRP);  
627   pEvent->SetMCReactionPlaneAngle(fMCReactionPlaneAngle);
628
629   if ( (++fCount % 100) == 0) {
630     if (!fMCReactionPlaneAngle == 0) cout<<" MC Reaction Plane Angle = "<<  fMCReactionPlaneAngle << endl;
631     else cout<<" MC Reaction Plane Angle = unknown "<< endl;
632     cout<<" iGoodTracks = "<<iGoodTracks<<endl;
633     cout<<" # of RP selected tracks = "<<iSelParticlesRP<<endl;
634     cout<<" # of POI selected tracks = "<<iSelParticlesPOI<<endl;  
635     cout << "# " << fCount << " events processed" << endl;
636   }
637
638   return pEvent;
639
640 }
641
642 //-----------------------------------------------------------------------   
643 AliFlowEventSimple* AliFlowEventSimpleMaker::FillTracks(AliESDEvent* anInput)
644 {
645   //Fills the event from the ESD
646   
647   Int_t iNumberOfInputTracks = anInput->GetNumberOfTracks() ;
648   
649   AliFlowEventSimple* pEvent = new AliFlowEventSimple(10);
650     
651   //Int_t iN = 256; //multiplicity for chi=1
652   Int_t iN = iNumberOfInputTracks;
653   Int_t iGoodTracks = 0;
654   Int_t itrkN = 0;
655   Int_t iSelParticlesPOI = 0;
656   Int_t iSelParticlesRP = 0;
657
658  
659   
660   //normal loop
661   while (iGoodTracks < iN && itrkN < iNumberOfInputTracks) {
662     AliESDtrack* pParticle = anInput->GetTrack(itrkN);   //get input particle
663     //cut on tracks
664     if (TMath::Abs(pParticle->Eta()) < 0.9)
665     
666    
667     
668     {
669         AliFlowTrackSimple* pTrack = new AliFlowTrackSimple();
670         pTrack->SetPt(pParticle->Pt() );
671         pTrack->SetEta(pParticle->Eta() );
672         pTrack->SetPhi(pParticle->Phi() );
673         pTrack->SetForRPSelection(kTRUE);
674         pTrack->SetForPOISelection(kTRUE);
675
676         if (pTrack->InRPSelection())
677           { iSelParticlesRP++; }
678         if (pTrack->InPOISelection())
679           { iSelParticlesPOI++; }
680         iGoodTracks++;
681         pEvent->AddTrack(pTrack) ;           
682       }
683       
684     itrkN++; 
685   }
686   
687   pEvent-> SetEventNSelTracksRP(iSelParticlesRP);  
688   pEvent->SetMCReactionPlaneAngle(fMCReactionPlaneAngle);
689
690   if ( (++fCount % 100) == 0) {
691     if (!fMCReactionPlaneAngle == 0) cout<<" MC Reaction Plane Angle = "<<  fMCReactionPlaneAngle << endl;
692     else cout<<" MC Reaction Plane Angle = unknown "<< endl;
693     cout<<" iGoodTracks = "<<iGoodTracks<<endl;
694     cout<<" # of RP selected tracks = "<<iSelParticlesRP<<endl;
695     cout<<" # of POI selected tracks = "<<iSelParticlesPOI<<endl;  
696     cout << "# " << fCount << " events processed" << endl;
697   }
698
699   return pEvent;
700 }
701
702 //-----------------------------------------------------------------------   
703
704 AliFlowEventSimple* AliFlowEventSimpleMaker::FillTracks(AliAODEvent* anInput)
705 {
706   //Fills the event from the AOD
707   
708   Int_t iNumberOfInputTracks = anInput->GetNumberOfTracks() ;
709   
710   AliFlowEventSimple* pEvent = new AliFlowEventSimple(10);
711     
712   //Int_t iN = 256; //multiplicity for chi=1
713   Int_t iN = iNumberOfInputTracks;
714   Int_t iGoodTracks = 0;
715   Int_t itrkN = 0;
716   Int_t iSelParticlesPOI = 0;
717   Int_t iSelParticlesRP = 0;
718   
719   //normal loop
720   while (iGoodTracks < iN && itrkN < iNumberOfInputTracks) {
721     AliAODTrack* pParticle = anInput->GetTrack(itrkN);   //get input particle
722     //cut on tracks
723     if (TMath::Abs(pParticle->Eta()) < 0.9)
724       {
725         AliFlowTrackSimple* pTrack = new AliFlowTrackSimple();
726         pTrack->SetPt(pParticle->Pt() );
727         pTrack->SetEta(pParticle->Eta() );
728         pTrack->SetPhi(pParticle->Phi() );
729         pTrack->SetForRPSelection(kTRUE);
730         pTrack->SetForPOISelection(kTRUE);
731
732         if (pTrack->InRPSelection())
733           { iSelParticlesRP++; }
734         if (pTrack->InPOISelection())
735           { iSelParticlesPOI++; }
736         iGoodTracks++;
737         pEvent->AddTrack(pTrack) ;           
738       }
739       
740     itrkN++; 
741   }
742   
743   pEvent-> SetEventNSelTracksRP(iSelParticlesRP);  
744   pEvent->SetMCReactionPlaneAngle(fMCReactionPlaneAngle);
745
746   if ( (++fCount % 100) == 0) {
747     if (!fMCReactionPlaneAngle == 0) cout<<" MC Reaction Plane Angle = "<<  fMCReactionPlaneAngle << endl;
748     else cout<<" MC Reaction Plane Angle = unknown "<< endl;
749     cout<<" iGoodTracks = "<<iGoodTracks<<endl;
750     cout<<" # of RP selected tracks = "<<iSelParticlesRP<<endl;
751     cout<<" # of POI selected tracks = "<<iSelParticlesPOI<<endl;  
752     cout << "# " << fCount << " events processed" << endl;
753   }
754
755   return pEvent;
756 }
757
758 //-----------------------------------------------------------------------   
759 AliFlowEventSimple*  AliFlowEventSimpleMaker::FillTracks(AliESDEvent* anInput, const AliMCEvent* anInputMc, Int_t anOption)
760 {
761   //fills the event with tracks from the ESD and kinematics from the MC info via the track label
762
763   if (!(anOption ==0 || anOption ==1)) {
764     cout<<"WRONG OPTION IN AliFlowEventSimpleMaker::FillTracks(AliESDEvent* anInput, AliMCEvent* anInputMc, Int_t anOption)"<<endl;
765     exit(1);
766   }
767
768   Int_t iNumberOfInputTracks = anInput->GetNumberOfTracks() ;
769   
770   AliFlowEventSimple* pEvent = new AliFlowEventSimple(10);
771     
772   //Int_t iN = 256; //multiplicity for chi=1
773   Int_t iN = iNumberOfInputTracks;
774   Int_t iGoodTracks = 0;
775   Int_t itrkN = 0;
776   Int_t iSelParticlesPOI = 0;
777   Int_t iSelParticlesRP = 0;
778
779   //normal loop
780   while (iGoodTracks < iN && itrkN < iNumberOfInputTracks) {
781     AliESDtrack* pParticle = anInput->GetTrack(itrkN);   //get input particle
782     //get Label
783     Int_t iLabel = pParticle->GetLabel();
784     //match to mc particle
785     AliMCParticle* pMcParticle = (AliMCParticle*) anInputMc->GetTrack(TMath::Abs(iLabel));
786     
787     //check
788     if (TMath::Abs(pParticle->GetLabel())!=pMcParticle->Label()) cout<<"pParticle->GetLabel()!=pMcParticle->Label() "<<pParticle->GetLabel()<<"  "<<pMcParticle->Label()<<endl;
789     
790     //cut on tracks
791     if (TMath::Abs(pParticle->Eta()) < 0.2)
792       {
793         if(
794            TMath::Abs(pMcParticle->Particle()->GetPdgCode()) == 211 //pions
795            //         TMath::Abs(pMcParticle->Particle()->GetPdgCode()) == 211 ||
796            //         TMath::Abs(pMcParticle->Particle()->GetPdgCode()) == 321 ||
797            //         TMath::Abs(pMcParticle->Particle()->GetPdgCode()) == 2212
798            )
799           {
800             AliFlowTrackSimple* pTrack = new AliFlowTrackSimple();
801             if(anOption == 0) { //take the PID from the MC & the kinematics from the ESD
802               pTrack->SetPt(pParticle->Pt() );
803               pTrack->SetEta(pParticle->Eta() );
804               pTrack->SetPhi(pParticle->Phi() );
805               pTrack->SetForRPSelection(kTRUE);
806               pTrack->SetForPOISelection(kTRUE);
807             }
808             else if (anOption == 1) { //take the PID and kinematics from the MC
809               pTrack->SetPt(pMcParticle->Pt() );
810               pTrack->SetEta(pMcParticle->Eta() );
811               pTrack->SetPhi(pMcParticle->Phi() );
812               pTrack->SetForRPSelection(kTRUE);
813               pTrack->SetForPOISelection(kTRUE);
814             }
815             else { cout<<"Not a valid option"<<endl; }
816             if (pTrack->InRPSelection())
817               { iSelParticlesRP++; }
818             if (pTrack->InPOISelection())
819               { iSelParticlesPOI++; }
820             iGoodTracks++;
821             pEvent->AddTrack(pTrack) ;               
822           }
823       }
824     itrkN++; 
825   }
826   
827   pEvent-> SetEventNSelTracksRP(iSelParticlesRP);  
828   pEvent->SetMCReactionPlaneAngle(fMCReactionPlaneAngle);
829
830   if ( (++fCount % 100) == 0) {
831     if (!fMCReactionPlaneAngle == 0) cout<<" MC Reaction Plane Angle = "<<  fMCReactionPlaneAngle << endl;
832     else cout<<" MC Reaction Plane Angle = unknown "<< endl;
833     cout<<" iGoodTracks = "<<iGoodTracks<<endl;
834     cout<<" # of RP selected tracks = "<<iSelParticlesRP<<endl;
835     cout<<" # of POI selected tracks = "<<iSelParticlesPOI<<endl;  
836     cout << "# " << fCount << " events processed" << endl;
837   }
838
839   return pEvent;
840 }