]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG2/FLOW/AliFlowTasks/AliFlowEvent.cxx
883fd496e7af4d820bb3397b62a5b2b820902c04
[u/mrichter/AliRoot.git] / PWG2 / FLOW / AliFlowTasks / AliFlowEvent.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 /*****************************************************************
17   AliFlowEvent: Event container for flow analysis
18
19   origin:   Mikolaj Krzewicki  (mikolaj.krzewicki@cern.ch)
20 *****************************************************************/
21
22 #include "Riostream.h"
23 #include "TList.h"
24 #include "AliMCEvent.h"
25 #include "AliMCParticle.h"
26 #include "AliCFManager.h"
27 #include "AliESDtrack.h"
28 #include "AliESDEvent.h"
29 #include "AliAODEvent.h"
30 #include "AliGenCocktailEventHeader.h"
31 #include "AliGenEposEventHeader.h"
32 #include "AliGenHijingEventHeader.h"
33 #include "AliGenGeVSimEventHeader.h"
34 #include "AliMultiplicity.h"
35 #include "AliFlowTrackSimpleCuts.h"
36 #include "AliFlowEventSimple.h"
37 #include "AliFlowTrack.h"
38 #include "AliFlowEvent.h"
39 #include "AliLog.h"
40
41 ClassImp(AliFlowEvent)
42
43 //-----------------------------------------------------------------------
44
45 AliFlowEvent::AliFlowEvent():
46   AliFlowEventSimple()
47 {
48   //ctor
49   cout << "AliFlowEvent: Default constructor to be used only by root for io" << endl;
50 }
51
52 //-----------------------------------------------------------------------
53 AliFlowEvent::AliFlowEvent(const AliFlowEvent& event):
54   AliFlowEventSimple(event)
55 {
56   //cpy ctor
57 }
58
59 //-----------------------------------------------------------------------
60 AliFlowEvent& AliFlowEvent::operator=(const AliFlowEvent& event)
61 {
62   //assignment operator
63   AliFlowEventSimple::operator=(event);
64   return *this;
65 }
66
67 //-----------------------------------------------------------------------
68 AliFlowTrack* AliFlowEvent::GetTrack(Int_t i)
69 {
70   //get track i from collection
71   if (i>=fNumberOfTracks) return NULL;
72   AliFlowTrack* pTrack = static_cast<AliFlowTrack*>(fTrackCollection->At(i)) ;
73   return pTrack;
74 }
75
76 //-----------------------------------------------------------------------
77 void AliFlowEvent::SetMCReactionPlaneAngle(const AliMCEvent* mcEvent)
78 {
79   //sets the event plane angle from the proper header in the MC
80
81   //COCKTAIL with HIJING
82   if (!strcmp(mcEvent-> GenEventHeader()->GetName(),"Cocktail Header"))   //returns 0 if matches
83   {
84     AliGenCocktailEventHeader *headerC = dynamic_cast<AliGenCocktailEventHeader *> (mcEvent-> GenEventHeader());
85     if (headerC)
86     {
87       TList *lhd = headerC->GetHeaders();
88       if (lhd)
89       {
90         AliGenHijingEventHeader *hdh = dynamic_cast<AliGenHijingEventHeader *> (lhd->At(0));
91         if (hdh) AliFlowEventSimple::SetMCReactionPlaneAngle( hdh->ReactionPlaneAngle() );
92       }
93     }
94   }
95   //GEVSIM
96   else if (!strcmp(mcEvent-> GenEventHeader()->GetName(),"GeVSim header"))   //returns 0 if matches
97   {
98     AliGenGeVSimEventHeader* headerG = dynamic_cast<AliGenGeVSimEventHeader*>(mcEvent->GenEventHeader());
99     if (headerG) AliFlowEventSimple::SetMCReactionPlaneAngle( headerG->GetEventPlane() );
100   }
101   //HIJING
102   else if (!strcmp(mcEvent-> GenEventHeader()->GetName(),"Hijing"))   //returns 0 if matches
103   {
104     AliGenHijingEventHeader* headerH = dynamic_cast<AliGenHijingEventHeader*>(mcEvent->GenEventHeader());
105     if (headerH) AliFlowEventSimple::SetMCReactionPlaneAngle( headerH->ReactionPlaneAngle() );
106   }
107   //EPOS
108   else if (!strcmp(mcEvent->GenEventHeader()->GetName(),"EPOS"))
109   {
110     AliGenEposEventHeader* headerE = dynamic_cast<AliGenEposEventHeader*>(mcEvent->GenEventHeader());
111     if (headerE) AliFlowEventSimple::SetMCReactionPlaneAngle( headerE->ReactionPlaneAngle() );
112   }
113 }
114
115 //-----------------------------------------------------------------------
116 AliFlowEvent::AliFlowEvent( const AliMCEvent* anInput,
117                             const AliCFManager* rpCFManager,
118                             const AliCFManager* poiCFManager):
119   AliFlowEventSimple(20)
120 {
121   //Fills the event from the MC kinematic information
122
123   Int_t iNumberOfInputTracks = anInput->GetNumberOfTracks() ;
124
125   //loop over tracks
126   for (Int_t itrkN=0; itrkN<iNumberOfInputTracks; itrkN++)
127   {
128     //get input particle
129     AliMCParticle* pParticle = dynamic_cast<AliMCParticle*>(anInput->GetTrack(itrkN));
130     if (!pParticle) continue;
131
132     //check if pParticle passes the cuts
133     Bool_t rpOK = kTRUE;
134     Bool_t poiOK = kTRUE;
135     if (rpCFManager && poiCFManager)
136     {
137       rpOK = rpCFManager->CheckParticleCuts(AliCFManager::kPartGenCuts,pParticle);
138       poiOK = poiCFManager->CheckParticleCuts(AliCFManager::kPartGenCuts,pParticle);
139     }
140     if (!(rpOK||poiOK)) continue;
141
142     AliFlowTrack* pTrack = new AliFlowTrack(pParticle);
143     pTrack->SetSource(AliFlowTrack::kFromMC);
144
145     if (rpOK && rpCFManager)
146     {
147       pTrack->SetForRPSelection(kTRUE);
148       fNumberOfRPs++;
149     }
150     if (poiOK && poiCFManager)
151     {
152       pTrack->SetForPOISelection(kTRUE);
153     }
154
155     AddTrack(pTrack) ;
156   }//for all tracks
157   SetMCReactionPlaneAngle(anInput);
158 }
159
160 //-----------------------------------------------------------------------
161 AliFlowEvent::AliFlowEvent( const AliESDEvent* anInput,
162                             const AliCFManager* rpCFManager,
163                             const AliCFManager* poiCFManager ):
164   AliFlowEventSimple(20)
165 {
166   //Fills the event from the ESD
167
168   Int_t iNumberOfInputTracks = anInput->GetNumberOfTracks() ;
169
170   //loop over tracks
171   for (Int_t itrkN=0; itrkN<iNumberOfInputTracks; itrkN++)
172   {
173     AliESDtrack* pParticle = anInput->GetTrack(itrkN);   //get input particle
174
175     //check if pParticle passes the cuts
176     Bool_t rpOK = kTRUE;
177     Bool_t poiOK = kTRUE;
178     if (rpCFManager && poiCFManager)
179     {
180       rpOK = ( rpCFManager->CheckParticleCuts(AliCFManager::kPartRecCuts,pParticle) &&
181                rpCFManager->CheckParticleCuts(AliCFManager::kPartSelCuts,pParticle));
182       poiOK = ( poiCFManager->CheckParticleCuts(AliCFManager::kPartRecCuts,pParticle) &&
183                 poiCFManager->CheckParticleCuts(AliCFManager::kPartSelCuts,pParticle));
184     }
185     if (!(rpOK || poiOK)) continue;
186
187     //make new AliFLowTrack
188     AliFlowTrack* pTrack = new AliFlowTrack(pParticle);
189     pTrack->SetSource(AliFlowTrack::kFromESD);
190
191     //marking the particles used for int. flow:
192     if(rpOK && rpCFManager)
193     {
194       pTrack->SetForRPSelection(kTRUE);
195       fNumberOfRPs++;
196     }
197     //marking the particles used for diff. flow:
198     if(poiOK && poiCFManager)
199     {
200       pTrack->SetForPOISelection(kTRUE);
201     }
202
203     AddTrack(pTrack);
204   }//end of while (itrkN < iNumberOfInputTracks)
205 }
206
207 //-----------------------------------------------------------------------
208 AliFlowEvent::AliFlowEvent( const AliAODEvent* anInput,
209                             const AliCFManager* rpCFManager,
210                             const AliCFManager* poiCFManager):
211   AliFlowEventSimple(20)
212 {
213   //Fills the event from the AOD
214   Int_t iNumberOfInputTracks = anInput->GetNumberOfTracks() ;
215
216   //loop over tracks
217   for (Int_t itrkN=0; itrkN<iNumberOfInputTracks; itrkN++)
218   {
219     AliAODTrack* pParticle = anInput->GetTrack(itrkN);   //get input particle
220
221     //check if pParticle passes the cuts
222     Bool_t rpOK = kTRUE;
223     Bool_t poiOK = kTRUE;
224     if (rpCFManager && poiCFManager)
225     {
226       rpOK = ( rpCFManager->CheckParticleCuts(AliCFManager::kPartRecCuts,pParticle) &&
227                rpCFManager->CheckParticleCuts(AliCFManager::kPartSelCuts,pParticle));
228       poiOK = ( poiCFManager->CheckParticleCuts(AliCFManager::kPartRecCuts,pParticle) &&
229                 poiCFManager->CheckParticleCuts(AliCFManager::kPartSelCuts,pParticle));
230     }
231     if (!(rpOK || poiOK)) continue;
232
233     //make new AliFlowTrack
234     AliFlowTrack* pTrack = new AliFlowTrack(pParticle);
235     pTrack->SetSource(AliFlowTrack::kFromAOD);
236
237     if (rpOK && rpCFManager)
238     {
239       pTrack->SetForRPSelection(kTRUE);
240       fNumberOfRPs++;
241     }
242     if (poiOK && poiCFManager)
243     {
244       pTrack->SetForPOISelection(kTRUE);
245     }
246     AddTrack(pTrack);
247   }
248
249   //  if (iSelParticlesRP >= fMinMult && iSelParticlesRP <= fMaxMult)
250   //  {
251   //    if ( (++fCount % 100) == 0)
252   //    {
253   //      if (!fMCReactionPlaneAngle == 0) cout<<" MC Reaction Plane Angle = "<<  fMCReactionPlaneAngle << endl;
254   //      else cout<<" MC Reaction Plane Angle = unknown "<< endl;
255   //      cout<<" iGoodTracks = "<<iGoodTracks<<endl;
256   //      cout<<" # of RP selected tracks = "<<iSelParticlesRP<<endl;
257   //      cout<<" # of POI selected tracks = "<<iSelParticlesPOI<<endl;
258   //      cout << "# " << fCount << " events processed" << endl;
259   //    }
260   //    return pEvent;
261   //  }
262   //  else
263   //  {
264   //    cout<<"Not enough tracks in the FlowEventSimple"<<endl;
265   //    return 0;
266   //  }
267   //}
268   //else
269   //{
270   //  cout<<"Event does not pass multiplicity cuts"<<endl;
271   //  return 0;
272   //}
273
274 }
275
276 //-----------------------------------------------------------------------
277 AliFlowEvent::AliFlowEvent( const AliESDEvent* anInput,
278                             const AliMCEvent* anInputMc,
279                             KineSource anOption,
280                             const AliCFManager* rpCFManager,
281                             const AliCFManager* poiCFManager ):
282   AliFlowEventSimple(20)
283 {
284   //fills the event with tracks from the ESD and kinematics from the MC info via the track label
285   if (anOption==kNoKine)
286   {
287     AliFatal("WRONG OPTION IN AliFlowEventMaker::FillTracks(AliESDEvent* anInput, AliMCEvent* anInputMc, KineSource anOption)");
288     exit(1);
289   }
290
291   Int_t iNumberOfInputTracks = anInput->GetNumberOfTracks() ;
292
293   Int_t iNumberOfInputTracksMC = anInputMc->GetNumberOfTracks() ;
294   if (iNumberOfInputTracksMC==-1)
295   {
296     AliError("Skipping Event -- No MC information available for this event");
297     return;
298   }
299
300   //loop over ESD tracks
301   for (Int_t itrkN=0; itrkN<iNumberOfInputTracks; itrkN++)
302   {
303     AliESDtrack* pParticle = anInput->GetTrack(itrkN);   //get input particle
304     //get Label
305     Int_t iLabel = pParticle->GetLabel();
306     //match to mc particle
307     AliMCParticle* pMcParticle = (AliMCParticle*) anInputMc->GetTrack(TMath::Abs(iLabel));
308
309     //check
310     if (TMath::Abs(pParticle->GetLabel())!=pMcParticle->Label())
311       AliWarning(Form("pParticle->GetLabel()!=pMcParticle->Label(), %i, %i", pParticle->GetLabel(), pMcParticle->Label()));
312
313     //check if pParticle passes the cuts
314     Bool_t rpOK = kTRUE;
315     Bool_t poiOK = kTRUE;
316     if (rpCFManager && poiCFManager)
317     {
318       if(anOption == kESDkine)
319       {
320         if (rpCFManager->CheckParticleCuts(AliCFManager::kPartGenCuts,pMcParticle,"mcGenCuts1") &&
321             rpCFManager->CheckParticleCuts(AliCFManager::kPartRecCuts,pParticle))
322           rpOK=kTRUE;
323         if (poiCFManager->CheckParticleCuts(AliCFManager::kPartGenCuts,pMcParticle,"mcGenCuts2") &&
324             poiCFManager->CheckParticleCuts(AliCFManager::kPartRecCuts,pParticle))
325           poiOK=kTRUE;
326       }
327       else if (anOption == kMCkine)
328       {
329         if (rpCFManager->CheckParticleCuts(AliCFManager::kPartGenCuts,pMcParticle))
330           rpOK=kTRUE;
331         if (poiCFManager->CheckParticleCuts(AliCFManager::kPartGenCuts,pMcParticle))
332           poiOK=kTRUE;
333       }
334     }
335
336     if (!(rpOK || poiOK)) continue;
337
338     //make new AliFlowTrack
339     AliFlowTrack* pTrack = new AliFlowTrack();
340     if(anOption == kESDkine)   //take the PID from the MC & the kinematics from the ESD
341     {
342       pTrack->SetPt(pParticle->Pt() );
343       pTrack->SetEta(pParticle->Eta() );
344       pTrack->SetPhi(pParticle->Phi() );
345     }
346     else if (anOption == kMCkine)   //take the PID and kinematics from the MC
347     {
348       pTrack->SetPt(pMcParticle->Pt() );
349       pTrack->SetEta(pMcParticle->Eta() );
350       pTrack->SetPhi(pMcParticle->Phi() );
351     }
352
353     if (rpOK && rpCFManager)
354     {
355       fNumberOfRPs++;
356       pTrack->SetForRPSelection();
357     }
358     if (poiOK && poiCFManager) pTrack->SetForPOISelection();
359
360     AddTrack(pTrack);
361   }
362   SetMCReactionPlaneAngle(anInputMc);
363 }
364
365 //-----------------------------------------------------------------------
366 AliFlowEvent::AliFlowEvent( const AliESDEvent* anInput,
367                                               const AliMultiplicity* anInputTracklets,
368                                               const AliCFManager* poiCFManager ):
369   AliFlowEventSimple(20)
370 {
371
372   //Select the particles of interest from the ESD
373   Int_t iNumberOfInputTracks = anInput->GetNumberOfTracks() ;
374
375   //loop over tracks
376   for (Int_t itrkN=0; itrkN<iNumberOfInputTracks; itrkN++)
377     {
378       AliESDtrack* pParticle = anInput->GetTrack(itrkN);   //get input particle
379
380       //check if pParticle passes the cuts
381       Bool_t poiOK = kTRUE;
382       if (poiCFManager)
383         {
384           poiOK = ( poiCFManager->CheckParticleCuts(AliCFManager::kPartRecCuts,pParticle) &&
385                     poiCFManager->CheckParticleCuts(AliCFManager::kPartSelCuts,pParticle));
386         }
387       if (!poiOK) continue;
388       
389       //make new AliFLowTrack
390       AliFlowTrack* pTrack = new AliFlowTrack();
391       pTrack->SetPt(pParticle->Pt() );
392       pTrack->SetEta(pParticle->Eta() );
393       pTrack->SetPhi(pParticle->Phi() );
394           
395       //marking the particles used for the particle of interest (POI) selection:
396       if(poiOK && poiCFManager)
397         {
398           pTrack->SetForPOISelection(kTRUE);
399           pTrack->SetSource(AliFlowTrack::kFromESD);
400         }
401
402       AddTrack(pTrack);
403     }//end of while (itrkN < iNumberOfInputTracks)
404
405   //Select the reference particles from the SPD tracklets
406   anInputTracklets = anInput->GetMultiplicity();
407   Int_t multSPD = anInputTracklets->GetNumberOfTracklets();
408
409   cout << "N tracklets: " << multSPD << endl; //for testing
410
411   //loop over tracklets
412   for (Int_t itracklet=0; itracklet<multSPD; ++itracklet) {
413     Float_t thetaTr= anInputTracklets->GetTheta(itracklet);
414     Float_t phiTr= anInputTracklets->GetPhi(itracklet);
415     // calculate eta
416     Float_t etaTr = -TMath::Log(TMath::Tan(thetaTr/2.));
417     
418     //make new AliFLowTrackSimple
419     AliFlowTrack* pTrack = new AliFlowTrack();
420     pTrack->SetPt(0.0);
421     pTrack->SetEta(etaTr);
422     pTrack->SetPhi(phiTr);
423     //marking the particles used for the reference particle (RP) selection:
424     fNumberOfRPs++;
425     pTrack->SetForRPSelection(kTRUE);
426     pTrack->SetSource(AliFlowTrack::kFromTracklet);
427
428     //Add the track to the flowevent
429     AddTrack(pTrack);
430   }
431
432 }
433
434