]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG2/FLOW/AliFlowEventSimpleMaker.cxx
enabling MC comparison
[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
30 // AliFlowEventSimpleMaker:
31 // Class to fill the AliFlowEventSimple
32 // with AliFlowTrackSimple objects
33 // Has fill methods for TTree, AliMCEvent, AliESDEvent and AliAODEvent
34 // author: N. van der Kolk (kolk@nikhef.nl)
35
36
37
38 ClassImp(AliFlowEventSimpleMaker)
39 //----------------------------------------------------------------------- 
40 AliFlowEventSimpleMaker::AliFlowEventSimpleMaker():
41   fEvent(0),
42   fTrack(0),
43   fParticle(0)
44 {
45
46   //constructor
47
48 }
49
50
51 //-----------------------------------------------------------------------   
52 AliFlowEventSimpleMaker::~AliFlowEventSimpleMaker()
53 {
54   //desstructor
55 }
56
57
58 //-----------------------------------------------------------------------   
59 AliFlowEventSimple* AliFlowEventSimpleMaker::FillTracks(TTree* fInput)
60 {
61   //fills the event from a TTree of kinematic.root files
62   Bool_t  fDoubleLoop = kFALSE; 
63
64   Int_t fNumberOfInputTracks = fInput->GetEntries() ;
65   //cerr<<"fNumberOfInputTracks = "<<fNumberOfInputTracks<<endl;
66   fParticle = new TParticle();
67   fInput->SetBranchAddress("Particles",&fParticle);  
68   //  fEvent = new AliFlowEventSimple(fNumberOfInputTracks);
69   fEvent = new AliFlowEventSimple(10);
70   //cerr<<fEvent<<" fEvent "<<endl;
71   
72   Int_t fN = fNumberOfInputTracks;
73   //  Int_t fN = 576; //multiplicity for chi=1.5
74   //  Int_t fN = 256; //multiplicity for chi=1
75   //  Int_t fN = 164; //multiplicity for chi=0.8
76   Int_t fGoodTracks = 0;
77   Int_t ftrkN = 0;
78   Int_t fSelParticlesDiff = 0;
79   Int_t fSelParticlesInt = 0;
80   
81   if (fDoubleLoop)
82     {                   //double loop
83       while (fGoodTracks < fN*2 && ftrkN < fNumberOfInputTracks) 
84         {
85           fInput->GetEntry(ftrkN);   //get input particle
86           //cut on tracks
87           if(TMath::Abs(fParticle->Eta()) < 0.9) 
88             {
89               //              Int_t fLoop = floor(2.*fParticle->Pt())+2;
90               //              for(Int_t d=0;d<fLoop;d++) 
91               for(Int_t d=0;d<2;d++) 
92                 {
93                   if(
94                      TMath::Abs(fParticle->GetPdgCode()) == 211
95                      //       TMath::Abs(fParticle->GetPdgCode()) == 211 ||
96                      //       TMath::Abs(fParticle->GetPdgCode()) == 321 ||
97                      //       TMath::Abs(fParticle->GetPdgCode()) == 2212
98                      )
99                     {
100                       fTrack = new AliFlowTrackSimple();
101                       fTrack->SetPt(fParticle->Pt() );
102                       fTrack->SetEta(fParticle->Eta() );
103                       fTrack->SetPhi(fParticle->Phi() );
104                       fTrack->SetForIntegratedFlow(kTRUE);
105                       fTrack->SetForDifferentialFlow(kTRUE);
106
107                       if (fTrack->UseForIntegratedFlow())
108                         { fSelParticlesInt++; }
109                       if (fTrack->UseForDifferentialFlow())
110                         { fSelParticlesDiff++; }
111                       fGoodTracks++;
112                       fEvent->TrackCollection()->Add(fTrack);
113                     }
114                         /*
115                   else if(
116                           TMath::Abs(fParticle->GetPdgCode()) == 2212
117                           )
118                     {
119                       fTrack = new AliFlowTrackSimple();
120                       fTrack->SetPt(fParticle->Pt() );
121                       fTrack->SetEta(fParticle->Eta() );
122                       fTrack->SetPhi(fParticle->Phi() );
123                       fTrack->SetForIntegratedFlow(kFALSE);
124                       fTrack->SetForDifferentialFlow(kTRUE);
125
126                       if (fTrack->UseForIntegratedFlow())
127                         { fSelParticlesInt++; }
128                       if (fTrack->UseForDifferentialFlow())
129                         { fSelParticlesDiff++; }
130                       fGoodTracks++;
131                       fEvent->TrackCollection()->Add(fTrack);     
132                     }
133                         */
134                 }
135             }
136           ftrkN++; 
137         }
138     }
139
140   else {                                  //normal loop
141     while (fGoodTracks < fN && ftrkN < fNumberOfInputTracks) {
142       fInput->GetEntry(ftrkN);   //get input particle
143       //cut on tracks
144       if (TMath::Abs(fParticle->Eta()) < 0.2)
145         {
146           if(
147              TMath::Abs(fParticle->GetPdgCode()) == 211
148              //       TMath::Abs(fParticle->GetPdgCode()) == 211 ||
149              //       TMath::Abs(fParticle->GetPdgCode()) == 321 ||
150              //       TMath::Abs(fParticle->GetPdgCode()) == 2212
151              )
152             {
153               fTrack = new AliFlowTrackSimple() ;
154               fTrack->SetPt(fParticle->Pt() );
155               fTrack->SetEta(fParticle->Eta() );
156               fTrack->SetPhi(fParticle->Phi() );
157               fTrack->SetForIntegratedFlow(kTRUE);
158               fTrack->SetForDifferentialFlow(kTRUE);
159
160               if (fTrack->UseForIntegratedFlow())
161                 { fSelParticlesInt++; }
162               if (fTrack->UseForDifferentialFlow())
163                 { fSelParticlesDiff++; }
164               fGoodTracks++;
165               fEvent->TrackCollection()->Add(fTrack) ;               
166             }
167           /*      else if(
168                   TMath::Abs(fParticle->GetPdgCode()) == 211
169                   )
170             {
171               fTrack = new AliFlowTrackSimple();
172               fTrack->SetPt(fParticle->Pt() );
173               fTrack->SetEta(fParticle->Eta() );
174               fTrack->SetPhi(fParticle->Phi() );
175               fTrack->SetForIntegratedFlow(kFALSE);
176               fTrack->SetForDifferentialFlow(kTRUE);
177
178               if (fTrack->UseForIntegratedFlow())
179                 { fSelParticlesInt++; }
180               if (fTrack->UseForDifferentialFlow())
181                 { fSelParticlesDiff++; }
182               fGoodTracks++;
183               fEvent->TrackCollection()->Add(fTrack);        
184             }
185           */
186         }
187       
188       ftrkN++; 
189     }
190   }
191
192   fEvent-> SetEventNSelTracksIntFlow(fSelParticlesInt);  
193   fEvent->SetNumberOfTracks(fGoodTracks);
194   cout<<" fGoodTracks = "<<fGoodTracks<<endl;
195   cout << "  fSelectedTracksInt = " << fSelParticlesInt << endl;  
196   return fEvent;
197   
198 }
199
200 //-----------------------------------------------------------------------   
201 AliFlowEventSimple* AliFlowEventSimpleMaker::FillTracks(AliMCEvent* fInput)
202 {
203   //Fills the event from the MC kinematic information
204   
205   Int_t fNumberOfInputTracks = fInput->GetNumberOfTracks() ;
206   cerr<<"fInput->GetNumberOfTracks() = "<<fNumberOfInputTracks<<endl;
207  
208   fEvent = new AliFlowEventSimple(10);
209     
210   //Int_t fN = 256; //multiplicity for chi=1
211   Int_t fN = fNumberOfInputTracks;
212   Int_t fGoodTracks = 0;
213   Int_t ftrkN = 0;
214   Int_t fSelParticlesDiff = 0;
215   Int_t fSelParticlesInt = 0;
216
217    
218   //normal loop
219   while (fGoodTracks < fN && ftrkN < fNumberOfInputTracks) {
220     AliMCParticle* fParticle = fInput->GetTrack(ftrkN);   //get input particle
221     //cut on tracks
222     if (TMath::Abs(fParticle->Eta()) < 0.2)
223       {
224         if(
225            TMath::Abs(fParticle->Particle()->GetPdgCode()) == 211
226            //         TMath::Abs(fParticle->Particle()->GetPdgCode()) == 211 ||
227            //         TMath::Abs(fParticle->Particle()->GetPdgCode()) == 321 ||
228            //         TMath::Abs(fParticle->Particle()->GetPdgCode()) == 2212
229            )
230           {
231             fTrack = new AliFlowTrackSimple() ;
232             fTrack->SetPt(fParticle->Pt() );
233             fTrack->SetEta(fParticle->Eta() );
234             fTrack->SetPhi(fParticle->Phi() );
235             fTrack->SetForIntegratedFlow(kTRUE);
236             fTrack->SetForDifferentialFlow(kTRUE);
237
238             if (fTrack->UseForIntegratedFlow())
239               { fSelParticlesInt++; }
240             if (fTrack->UseForDifferentialFlow())
241               { fSelParticlesDiff++; }
242             fGoodTracks++;
243             fEvent->TrackCollection()->Add(fTrack) ;         
244           }
245           /*      else if(
246                   TMath::Abs(fParticle->Particle()->GetPdgCode()) == 211
247                   )
248             {
249               fTrack = new AliFlowTrackSimple();
250               fTrack->SetPt(fParticle->Pt() );
251               fTrack->SetEta(fParticle->Eta() );
252               fTrack->SetPhi(fParticle->Phi() );
253               fTrack->SetForIntegratedFlow(kFALSE);
254               fTrack->SetForDifferentialFlow(kTRUE);
255
256               if (fTrack->UseForIntegratedFlow())
257                 { fSelParticlesInt++; }
258               if (fTrack->UseForDifferentialFlow())
259                 { fSelParticlesDiff++; }
260               fGoodTracks++;
261               fEvent->TrackCollection()->Add(fTrack);        
262             }
263           */
264       }
265       
266     ftrkN++; 
267   }
268   
269   fEvent-> SetEventNSelTracksIntFlow(fSelParticlesInt);  
270   fEvent->SetNumberOfTracks(fGoodTracks);
271   cout<<" fGoodTracks = "<<fGoodTracks<<endl;
272   cout << "  fSelectedTracksInt = " << fSelParticlesInt << endl;  
273   return fEvent;
274   
275
276 }
277
278
279 //-----------------------------------------------------------------------   
280 AliFlowEventSimple* AliFlowEventSimpleMaker::FillTracks(AliESDEvent* fInput)
281 {
282   //Fills the event from the ESD
283   
284   Int_t fNumberOfInputTracks = fInput->GetNumberOfTracks() ;
285   cerr<<"fInput->GetNumberOfTracks() = "<<fNumberOfInputTracks<<endl;
286   
287   fEvent = new AliFlowEventSimple(10);
288     
289   //Int_t fN = 256; //multiplicity for chi=1
290   Int_t fN = fNumberOfInputTracks;
291   Int_t fGoodTracks = 0;
292   Int_t ftrkN = 0;
293   Int_t fSelParticlesDiff = 0;
294   Int_t fSelParticlesInt = 0;
295
296
297   //normal loop
298   while (fGoodTracks < fN && ftrkN < fNumberOfInputTracks) {
299     AliESDtrack* fParticle = fInput->GetTrack(ftrkN);   //get input particle
300     //cut on tracks
301     if (TMath::Abs(fParticle->Eta()) < 0.2)
302       {
303         fTrack = new AliFlowTrackSimple() ;
304         fTrack->SetPt(fParticle->Pt() );
305         fTrack->SetEta(fParticle->Eta() );
306         fTrack->SetPhi(fParticle->Phi() );
307         fTrack->SetForIntegratedFlow(kTRUE);
308         fTrack->SetForDifferentialFlow(kTRUE);
309
310         if (fTrack->UseForIntegratedFlow())
311           { fSelParticlesInt++; }
312         if (fTrack->UseForDifferentialFlow())
313           { fSelParticlesDiff++; }
314         fGoodTracks++;
315         fEvent->TrackCollection()->Add(fTrack) ;             
316       }
317       
318     ftrkN++; 
319   }
320   
321   fEvent-> SetEventNSelTracksIntFlow(fSelParticlesInt);  
322   fEvent->SetNumberOfTracks(fGoodTracks);
323   cout<<" fGoodTracks = "<<fGoodTracks<<endl;
324   cout << "  fSelectedTracksInt = " << fSelParticlesInt << endl;  
325   return fEvent;
326
327
328 }
329
330
331
332 //-----------------------------------------------------------------------   
333 AliFlowEventSimple* AliFlowEventSimpleMaker::FillTracks(AliAODEvent* fInput)
334 {
335   //Fills the event from the AOD
336   
337   Int_t fNumberOfInputTracks = fInput->GetNumberOfTracks() ;
338   cerr<<"fInput->GetNumberOfTracks() = "<<fNumberOfInputTracks<<endl;
339   
340   fEvent = new AliFlowEventSimple(10);
341     
342   //Int_t fN = 256; //multiplicity for chi=1
343   Int_t fN = fNumberOfInputTracks;
344   Int_t fGoodTracks = 0;
345   Int_t ftrkN = 0;
346   Int_t fSelParticlesDiff = 0;
347   Int_t fSelParticlesInt = 0;
348
349   
350   //normal loop
351   while (fGoodTracks < fN && ftrkN < fNumberOfInputTracks) {
352     AliAODTrack* fParticle = fInput->GetTrack(ftrkN);   //get input particle
353     //cut on tracks
354     if (TMath::Abs(fParticle->Eta()) < 0.2)
355       {
356         fTrack = new AliFlowTrackSimple() ;
357         fTrack->SetPt(fParticle->Pt() );
358         fTrack->SetEta(fParticle->Eta() );
359         fTrack->SetPhi(fParticle->Phi() );
360         fTrack->SetForIntegratedFlow(kTRUE);
361         fTrack->SetForDifferentialFlow(kTRUE);
362
363         if (fTrack->UseForIntegratedFlow())
364           { fSelParticlesInt++; }
365         if (fTrack->UseForDifferentialFlow())
366           { fSelParticlesDiff++; }
367         fGoodTracks++;
368         fEvent->TrackCollection()->Add(fTrack) ;             
369       }
370       
371     ftrkN++; 
372   }
373   
374   fEvent-> SetEventNSelTracksIntFlow(fSelParticlesInt);  
375   fEvent->SetNumberOfTracks(fGoodTracks);
376   cout<<" fGoodTracks = "<<fGoodTracks<<endl;
377   cout << "  fSelectedTracksInt = " << fSelParticlesInt << endl;  
378   return fEvent;
379   
380 }
381 //-----------------------------------------------------------------------   
382 AliFlowEventSimple*  AliFlowEventSimpleMaker::FillTracks(AliESDEvent* fInput, AliMCEvent* fInputMc, Int_t fOption)
383 {
384   //fills the event with tracks from the ESD and kinematics from the MC info via the track label
385
386   if (!(fOption ==0 || fOption ==1)) {
387     cout<<"WRONG OPTION IN AliFlowEventSimpleMaker::FillTracks(AliESDEvent* fInput, AliMCEvent* fInputMc, Int_t fOption)"<<endl;
388     exit(1);
389   }
390
391   Int_t fNumberOfInputTracks = fInput->GetNumberOfTracks() ;
392   cerr<<"fInput->GetNumberOfTracks() = "<<fNumberOfInputTracks<<endl;
393   
394   fEvent = new AliFlowEventSimple(10);
395     
396   //Int_t fN = 256; //multiplicity for chi=1
397   Int_t fN = fNumberOfInputTracks;
398   Int_t fGoodTracks = 0;
399   Int_t ftrkN = 0;
400   Int_t fSelParticlesDiff = 0;
401   Int_t fSelParticlesInt = 0;
402
403   //normal loop
404   while (fGoodTracks < fN && ftrkN < fNumberOfInputTracks) {
405     AliESDtrack* fParticle = fInput->GetTrack(ftrkN);   //get input particle
406     //get Label
407     Int_t fLabel = fParticle->GetLabel();
408     //match to mc particle
409     AliMCParticle* fMcParticle = fInputMc->GetTrack(TMath::Abs(fLabel));
410     
411     //check
412     if (TMath::Abs(fParticle->GetLabel())!=fMcParticle->Label()) cout<<"fParticle->GetLabel()!=fMcParticle->Label() "<<fParticle->GetLabel()<<"  "<<fMcParticle->Label()<<endl;
413     
414     //cut on tracks
415     if (TMath::Abs(fParticle->Eta()) < 0.2)
416       {
417         if(
418            TMath::Abs(fMcParticle->Particle()->GetPdgCode()) == 211 //pions
419            //         TMath::Abs(fMcParticle->Particle()->GetPdgCode()) == 211 ||
420            //         TMath::Abs(fMcParticle->Particle()->GetPdgCode()) == 321 ||
421            //         TMath::Abs(fMcParticle->Particle()->GetPdgCode()) == 2212
422            )
423           {
424             if(fOption == 0) { //take the PID from the MC & the kinematics from the ESD
425               fTrack = new AliFlowTrackSimple() ;
426               fTrack->SetPt(fParticle->Pt() );
427               fTrack->SetEta(fParticle->Eta() );
428               fTrack->SetPhi(fParticle->Phi() );
429               fTrack->SetForIntegratedFlow(kTRUE);
430               fTrack->SetForDifferentialFlow(kTRUE);
431             }
432             else if (fOption == 1) { //take the PID and kinematics from the MC
433               fTrack = new AliFlowTrackSimple() ;
434               fTrack->SetPt(fMcParticle->Pt() );
435               fTrack->SetEta(fMcParticle->Eta() );
436               fTrack->SetPhi(fMcParticle->Phi() );
437               fTrack->SetForIntegratedFlow(kTRUE);
438               fTrack->SetForDifferentialFlow(kTRUE);
439             }
440             else { cout<<"Not a valid option"<<endl; }
441             if (fTrack->UseForIntegratedFlow())
442               { fSelParticlesInt++; }
443             if (fTrack->UseForDifferentialFlow())
444               { fSelParticlesDiff++; }
445             fGoodTracks++;
446             fEvent->TrackCollection()->Add(fTrack) ;         
447           }
448       }
449     ftrkN++; 
450   }
451   
452   fEvent-> SetEventNSelTracksIntFlow(fSelParticlesInt);  
453   fEvent->SetNumberOfTracks(fGoodTracks);
454   cout<<" fGoodTracks = "<<fGoodTracks<<endl;
455   cout << "  fSelectedTracksInt = " << fSelParticlesInt << endl;  
456   return fEvent;
457
458
459 }
460
461
462
463 /*
464 $Log$
465 */ 
466