]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWG/FLOW/Tasks/AliFlowEvent.cxx
initial checkin of the new flow development - from an OLD diff!
[u/mrichter/AliRoot.git] / PWG / FLOW / Tasks / AliFlowEvent.cxx
CommitLineData
24373b38 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)
24373b38 20*****************************************************************/
21
22#include "Riostream.h"
24373b38 23#include "TList.h"
24373b38 24#include "TH2F.h"
24373b38 25#include "AliMCEvent.h"
26#include "AliMCParticle.h"
27#include "AliCFManager.h"
28#include "AliESDtrack.h"
29#include "AliESDPmdTrack.h"
30#include "AliESDEvent.h"
31#include "AliAODEvent.h"
24373b38 32#include "AliGenCocktailEventHeader.h"
33#include "AliGenEposEventHeader.h"
34#include "AliGenHijingEventHeader.h"
35#include "AliGenGeVSimEventHeader.h"
36#include "AliCollisionGeometry.h"
37#include "AliMultiplicity.h"
38#include "AliFlowTrackCuts.h"
39#include "AliFlowEventSimple.h"
40#include "AliFlowTrack.h"
24373b38 41#include "AliFlowEvent.h"
42#include "AliLog.h"
43
44using std::endl;
45using std::cout;
46ClassImp(AliFlowEvent)
47
48//-----------------------------------------------------------------------
49AliFlowEvent::AliFlowEvent():
8fa6a5fa 50 AliFlowEventSimple()
24373b38 51{
24373b38 52 //ctor
53 cout << "AliFlowEvent: Default constructor to be used only by root for io" << endl;
54}
55
56//-----------------------------------------------------------------------
57AliFlowEvent::AliFlowEvent(Int_t n):
8fa6a5fa 58 AliFlowEventSimple(n)
24373b38 59{
8fa6a5fa 60 //ctor
24373b38 61}
62
63//-----------------------------------------------------------------------
64AliFlowEvent::AliFlowEvent(const AliFlowEvent& event):
8fa6a5fa 65 AliFlowEventSimple(event)
24373b38 66{
8fa6a5fa 67 //cpy ctor
24373b38 68}
69
70//-----------------------------------------------------------------------
71AliFlowEvent& AliFlowEvent::operator=(const AliFlowEvent& event)
72{
24373b38 73 //assignment operator
24373b38 74 AliFlowEventSimple::operator=(event);
75 return *this;
76}
77
78//-----------------------------------------------------------------------
79AliFlowTrack* AliFlowEvent::GetTrack(Int_t i)
80{
81 //get track i from collection
82 if (i>=fNumberOfTracks) return NULL;
83 AliFlowTrack* pTrack = static_cast<AliFlowTrack*>(fTrackCollection->At(i)) ;
84 return pTrack;
85}
86
87//-----------------------------------------------------------------------
88void AliFlowEvent::SetMCReactionPlaneAngle(const AliMCEvent* mcEvent)
89{
90 //sets the event plane angle from the proper header in the MC
91
92 //COCKTAIL with HIJING
93 if (!strcmp(mcEvent-> GenEventHeader()->GetName(),"Cocktail Header")) //returns 0 if matches
94 {
95 AliGenCocktailEventHeader *headerC = dynamic_cast<AliGenCocktailEventHeader *> (mcEvent-> GenEventHeader());
96 if (headerC)
97 {
98 TList *lhd = headerC->GetHeaders();
99 if (lhd)
100 {
101 AliGenHijingEventHeader *hdh = dynamic_cast<AliGenHijingEventHeader *> (lhd->At(0));
102 if (hdh) AliFlowEventSimple::SetMCReactionPlaneAngle( hdh->ReactionPlaneAngle() );
103 }
104 }
105 }
106 //THERMINATOR
107 else if (!strcmp(mcEvent-> GenEventHeader()->GetName(),"Therminator")) //returns 0 if matches
108 {
109 AliGenHijingEventHeader* headerH = dynamic_cast<AliGenHijingEventHeader*>(mcEvent->GenEventHeader());
110 if (headerH) AliFlowEventSimple::SetMCReactionPlaneAngle( headerH->ReactionPlaneAngle() );
111 }
112 //GEVSIM
113 else if (!strcmp(mcEvent-> GenEventHeader()->GetName(),"GeVSim header")) //returns 0 if matches
114 {
115 AliGenGeVSimEventHeader* headerG = dynamic_cast<AliGenGeVSimEventHeader*>(mcEvent->GenEventHeader());
116 if (headerG) AliFlowEventSimple::SetMCReactionPlaneAngle( headerG->GetEventPlane() );
117 }
118 //HIJING
119 else if (!strcmp(mcEvent-> GenEventHeader()->GetName(),"Hijing")) //returns 0 if matches
120 {
121 AliGenHijingEventHeader* headerH = dynamic_cast<AliGenHijingEventHeader*>(mcEvent->GenEventHeader());
122 if (headerH) AliFlowEventSimple::SetMCReactionPlaneAngle( headerH->ReactionPlaneAngle() );
123 }
124 //AMPT
125 else if (!strcmp(mcEvent-> GenEventHeader()->GetName(),"Ampt")) //returns 0 if matches
126 {
127 AliGenHijingEventHeader* headerH = dynamic_cast<AliGenHijingEventHeader*>(mcEvent->GenEventHeader());
128 if (headerH) AliFlowEventSimple::SetMCReactionPlaneAngle( headerH->ReactionPlaneAngle() );
129 }
130 //EPOS
131 else if (!strcmp(mcEvent->GenEventHeader()->GetName(),"EPOS"))
132 {
133 AliGenEposEventHeader* headerE = dynamic_cast<AliGenEposEventHeader*>(mcEvent->GenEventHeader());
134 if (headerE) AliFlowEventSimple::SetMCReactionPlaneAngle( headerE->ReactionPlaneAngle() );
135 }
136 //Hydjet
137 else
138 {
139 AliCollisionGeometry* header = dynamic_cast<AliCollisionGeometry*>(mcEvent->GenEventHeader());
140 if (header) AliFlowEventSimple::SetMCReactionPlaneAngle( header->ReactionPlaneAngle() );
141 }
142}
143
144//-----------------------------------------------------------------------
145AliFlowEvent::AliFlowEvent( const AliMCEvent* anInput,
146 const AliCFManager* rpCFManager,
147 const AliCFManager* poiCFManager):
8fa6a5fa 148 AliFlowEventSimple(20)
24373b38 149{
24373b38 150 //Fills the event from the MC kinematic information
151
152 Int_t iNumberOfInputTracks = anInput->GetNumberOfTracks() ;
153
154 //loop over tracks
155 for (Int_t itrkN=0; itrkN<iNumberOfInputTracks; itrkN++)
156 {
157 //get input particle
158 AliMCParticle* pParticle = dynamic_cast<AliMCParticle*>(anInput->GetTrack(itrkN));
159 if (!pParticle) continue;
160
161 //check if pParticle passes the cuts
162 Bool_t rpOK = kTRUE;
163 Bool_t poiOK = kTRUE;
164 if (rpCFManager && poiCFManager)
165 {
166 rpOK = rpCFManager->CheckParticleCuts(AliCFManager::kPartGenCuts,pParticle);
167 poiOK = poiCFManager->CheckParticleCuts(AliCFManager::kPartGenCuts,pParticle);
168 }
169 if (!(rpOK||poiOK)) continue;
170
171 AliFlowTrack* pTrack = new AliFlowTrack(pParticle);
172 pTrack->SetSource(AliFlowTrack::kFromMC);
173
174 if (rpOK && rpCFManager)
175 {
176 pTrack->SetForRPSelection(kTRUE);
8fa6a5fa 177 IncrementNumberOfPOIs(0);
24373b38 178 }
179 if (poiOK && poiCFManager)
180 {
181 pTrack->SetForPOISelection(kTRUE);
8fa6a5fa 182 IncrementNumberOfPOIs(1);
24373b38 183 }
184
185 AddTrack(pTrack) ;
186 }//for all tracks
187 SetMCReactionPlaneAngle(anInput);
188}
189
190//-----------------------------------------------------------------------
191AliFlowEvent::AliFlowEvent( const AliESDEvent* anInput,
192 const AliCFManager* rpCFManager,
193 const AliCFManager* poiCFManager ):
8fa6a5fa 194 AliFlowEventSimple(20)
24373b38 195{
24373b38 196 //Fills the event from the ESD
197
198 Int_t iNumberOfInputTracks = anInput->GetNumberOfTracks() ;
199
200 //loop over tracks
201 for (Int_t itrkN=0; itrkN<iNumberOfInputTracks; itrkN++)
202 {
203 AliESDtrack* pParticle = anInput->GetTrack(itrkN); //get input particle
204
205 //check if pParticle passes the cuts
206 Bool_t rpOK = kTRUE;
207 Bool_t poiOK = kTRUE;
208 if (rpCFManager && poiCFManager)
209 {
210 rpOK = ( rpCFManager->CheckParticleCuts(AliCFManager::kPartRecCuts,pParticle) &&
211 rpCFManager->CheckParticleCuts(AliCFManager::kPartSelCuts,pParticle));
212 poiOK = ( poiCFManager->CheckParticleCuts(AliCFManager::kPartRecCuts,pParticle) &&
213 poiCFManager->CheckParticleCuts(AliCFManager::kPartSelCuts,pParticle));
214 }
215 if (!(rpOK || poiOK)) continue;
216
217 //make new AliFLowTrack
218 AliFlowTrack* pTrack = new AliFlowTrack(pParticle);
219 pTrack->SetSource(AliFlowTrack::kFromESD);
220
221 //marking the particles used for int. flow:
222 if(rpOK && rpCFManager)
223 {
224 pTrack->SetForRPSelection(kTRUE);
8fa6a5fa 225 IncrementNumberOfPOIs(0);
24373b38 226 }
227 //marking the particles used for diff. flow:
228 if(poiOK && poiCFManager)
229 {
230 pTrack->SetForPOISelection(kTRUE);
8fa6a5fa 231 IncrementNumberOfPOIs(1);
24373b38 232 }
233
234 AddTrack(pTrack);
235 }//end of while (itrkN < iNumberOfInputTracks)
236}
237
238//-----------------------------------------------------------------------
239AliFlowEvent::AliFlowEvent( const AliAODEvent* anInput,
240 const AliCFManager* rpCFManager,
241 const AliCFManager* poiCFManager):
8fa6a5fa 242 AliFlowEventSimple(20)
24373b38 243{
24373b38 244 //Fills the event from the AOD
245 Int_t iNumberOfInputTracks = anInput->GetNumberOfTracks() ;
246
247 //loop over tracks
248 for (Int_t itrkN=0; itrkN<iNumberOfInputTracks; itrkN++)
249 {
250 AliAODTrack* pParticle = anInput->GetTrack(itrkN); //get input particle
251
252 //check if pParticle passes the cuts
253 Bool_t rpOK = kTRUE;
254 Bool_t poiOK = kTRUE;
255 if (rpCFManager && poiCFManager)
256 {
257 rpOK = ( rpCFManager->CheckParticleCuts(AliCFManager::kPartRecCuts,pParticle) &&
258 rpCFManager->CheckParticleCuts(AliCFManager::kPartSelCuts,pParticle));
259 poiOK = ( poiCFManager->CheckParticleCuts(AliCFManager::kPartRecCuts,pParticle) &&
260 poiCFManager->CheckParticleCuts(AliCFManager::kPartSelCuts,pParticle));
261 }
262 if (!(rpOK || poiOK)) continue;
263
264 //make new AliFlowTrack
265 AliFlowTrack* pTrack = new AliFlowTrack(pParticle);
266 pTrack->SetSource(AliFlowTrack::kFromAOD);
267
268 if (rpOK /* && rpCFManager */ ) // to be fixed - with CF managers uncommented only empty events (NULL in header files)
269 {
270 pTrack->SetForRPSelection(kTRUE);
8fa6a5fa 271 IncrementNumberOfPOIs(0);
24373b38 272 }
273 if (poiOK /* && poiCFManager*/ )
274 {
275 pTrack->SetForPOISelection(kTRUE);
8fa6a5fa 276 IncrementNumberOfPOIs(1);
24373b38 277 }
278 AddTrack(pTrack);
279 }
280
281 // if (iSelParticlesRP >= fMinMult && iSelParticlesRP <= fMaxMult)
282 // {
283 // if ( (++fCount % 100) == 0)
284 // {
285 // if (!fMCReactionPlaneAngle == 0) cout<<" MC Reaction Plane Angle = "<< fMCReactionPlaneAngle << endl;
286 // else cout<<" MC Reaction Plane Angle = unknown "<< endl;
287 // cout<<" iGoodTracks = "<<iGoodTracks<<endl;
288 // cout<<" # of RP selected tracks = "<<iSelParticlesRP<<endl;
289 // cout<<" # of POI selected tracks = "<<iSelParticlesPOI<<endl;
290 // cout << "# " << fCount << " events processed" << endl;
291 // }
292 // return pEvent;
293 // }
294 // else
295 // {
296 // cout<<"Not enough tracks in the FlowEventSimple"<<endl;
297 // return 0;
298 // }
299 //}
300 //else
301 //{
302 // cout<<"Event does not pass multiplicity cuts"<<endl;
303 // return 0;
304 //}
305
306}
307
308//-----------------------------------------------------------------------
309AliFlowEvent::AliFlowEvent( const AliESDEvent* anInput,
310 const AliMCEvent* anInputMc,
311 KineSource anOption,
312 const AliCFManager* rpCFManager,
313 const AliCFManager* poiCFManager ):
8fa6a5fa 314 AliFlowEventSimple(20)
24373b38 315{
24373b38 316 //fills the event with tracks from the ESD and kinematics from the MC info via the track label
317 if (anOption==kNoKine)
318 {
319 AliFatal("WRONG OPTION IN AliFlowEventMaker::FillTracks(AliESDEvent* anInput, AliMCEvent* anInputMc, KineSource anOption)");
320 exit(1);
321 }
322
323 Int_t iNumberOfInputTracks = anInput->GetNumberOfTracks() ;
324
325 Int_t iNumberOfInputTracksMC = anInputMc->GetNumberOfTracks() ;
326 if (iNumberOfInputTracksMC==-1)
327 {
328 AliError("Skipping Event -- No MC information available for this event");
329 return;
330 }
331
332 //loop over ESD tracks
333 for (Int_t itrkN=0; itrkN<iNumberOfInputTracks; itrkN++)
334 {
335 AliESDtrack* pParticle = anInput->GetTrack(itrkN); //get input particle
336 //get Label
337 Int_t iLabel = pParticle->GetLabel();
338 //match to mc particle
339 AliMCParticle* pMcParticle = (AliMCParticle*) anInputMc->GetTrack(TMath::Abs(iLabel));
340
341 //check
342 if (TMath::Abs(pParticle->GetLabel())!=pMcParticle->Label())
343 AliWarning(Form("pParticle->GetLabel()!=pMcParticle->Label(), %i, %i", pParticle->GetLabel(), pMcParticle->Label()));
344
345 //check if pParticle passes the cuts
346 Bool_t rpOK = kFALSE;
347 Bool_t poiOK = kFALSE;
348 if (rpCFManager && poiCFManager)
349 {
350 if(anOption == kESDkine)
351 {
352 if (rpCFManager->CheckParticleCuts(AliCFManager::kPartGenCuts,pMcParticle,"mcGenCuts1") &&
353 rpCFManager->CheckParticleCuts(AliCFManager::kPartRecCuts,pParticle))
354 rpOK=kTRUE;
355 if (poiCFManager->CheckParticleCuts(AliCFManager::kPartGenCuts,pMcParticle,"mcGenCuts2") &&
356 poiCFManager->CheckParticleCuts(AliCFManager::kPartRecCuts,pParticle))
357 poiOK=kTRUE;
358 }
359 else if (anOption == kMCkine)
360 {
361 if (rpCFManager->CheckParticleCuts(AliCFManager::kPartGenCuts,pMcParticle))
362 rpOK=kTRUE;
363 if (poiCFManager->CheckParticleCuts(AliCFManager::kPartGenCuts,pMcParticle))
364 poiOK=kTRUE;
365 }
366 }
367
368 if (!(rpOK || poiOK)) continue;
369
370 //make new AliFlowTrack
371 AliFlowTrack* pTrack = NULL;
372 if(anOption == kESDkine) //take the PID from the MC & the kinematics from the ESD
373 {
374 pTrack = new AliFlowTrack(pParticle);
375 }
376 else if (anOption == kMCkine) //take the PID and kinematics from the MC
377 {
378 pTrack = new AliFlowTrack(pMcParticle);
379 }
380
381 if (rpOK && rpCFManager)
382 {
8fa6a5fa 383 IncrementNumberOfPOIs(0);
24373b38 384 pTrack->SetForRPSelection();
385 }
386 if (poiOK && poiCFManager)
387 {
8fa6a5fa 388 IncrementNumberOfPOIs(1);
24373b38 389 pTrack->SetForPOISelection();
390 }
391
392 AddTrack(pTrack);
393 }
394 SetMCReactionPlaneAngle(anInputMc);
395}
396
397//-----------------------------------------------------------------------
398AliFlowEvent::AliFlowEvent( const AliESDEvent* anInput,
399 const AliMultiplicity* anInputTracklets,
400 const AliCFManager* poiCFManager ):
8fa6a5fa 401 AliFlowEventSimple(20)
24373b38 402{
24373b38 403
404 //Select the particles of interest from the ESD
405 Int_t iNumberOfInputTracks = anInput->GetNumberOfTracks() ;
406
407 //loop over tracks
408 for (Int_t itrkN=0; itrkN<iNumberOfInputTracks; itrkN++)
409 {
410 AliESDtrack* pParticle = anInput->GetTrack(itrkN); //get input particle
411
412 //check if pParticle passes the cuts
413 Bool_t poiOK = kTRUE;
414 if (poiCFManager)
415 {
416 poiOK = ( poiCFManager->CheckParticleCuts(AliCFManager::kPartRecCuts,pParticle) &&
417 poiCFManager->CheckParticleCuts(AliCFManager::kPartSelCuts,pParticle));
418 }
419 if (!poiOK) continue;
420
421 //make new AliFLowTrack
422 AliFlowTrack* pTrack = new AliFlowTrack(pParticle);
423
424 //marking the particles used for the particle of interest (POI) selection:
425 if(poiOK && poiCFManager)
426 {
8fa6a5fa 427 IncrementNumberOfPOIs(1);
24373b38 428 pTrack->SetForPOISelection(kTRUE);
429 pTrack->SetSource(AliFlowTrack::kFromESD);
430 }
431
432 AddTrack(pTrack);
433 }//end of while (itrkN < iNumberOfInputTracks)
434
435 //Select the reference particles from the SPD tracklets
436 anInputTracklets = anInput->GetMultiplicity();
437 Int_t multSPD = anInputTracklets->GetNumberOfTracklets();
438
439 //loop over tracklets
440 for (Int_t itracklet=0; itracklet<multSPD; ++itracklet) {
441 Float_t thetaTr= anInputTracklets->GetTheta(itracklet);
442 Float_t phiTr= anInputTracklets->GetPhi(itracklet);
443 // calculate eta
444 Float_t etaTr = -TMath::Log(TMath::Tan(thetaTr/2.));
445
446 //make new AliFLowTrackSimple
447 AliFlowTrack* pTrack = new AliFlowTrack();
448 pTrack->SetPt(0.0);
449 pTrack->SetEta(etaTr);
450 pTrack->SetPhi(phiTr);
451 //marking the particles used for the reference particle (RP) selection:
8fa6a5fa 452 IncrementNumberOfPOIs(0);
24373b38 453 pTrack->SetForRPSelection(kTRUE);
454 pTrack->SetSource(AliFlowTrack::kFromTracklet);
455
456 //Add the track to the flowevent
457 AddTrack(pTrack);
458 }
459
460}
461
462//-----------------------------------------------------------------------
463AliFlowEvent::AliFlowEvent( const AliESDEvent* esd,
464 const AliCFManager* poiCFManager,
465 Bool_t hybrid):
8fa6a5fa 466 AliFlowEventSimple(20)
24373b38 467{
24373b38 468
469 //Select the particles of interest from the ESD
470 Int_t iNumberOfInputTracks = esd->GetNumberOfTracks() ;
471
472 //Double_t gPt = 0.0, gP = 0.0;
473 Double_t dca[2] = {0.0,0.0}, cov[3] = {0.0,0.0,0.0}; //The impact parameters and their covariance.
8fa6a5fa 474 //Double_t dca3D = 0.0;
24373b38 475
476 AliESDtrack trackTPC;
477
478 //loop over tracks
479 for (Int_t itrkN=0; itrkN<iNumberOfInputTracks; itrkN++)
480 {
481
482 if (!esd->GetTrack(itrkN)) continue;
483
484 Bool_t useTPC = kFALSE;
485
486 AliESDtrack* pParticle = esd->GetTrack(itrkN); //get input particle
487
488 //check if pParticle passes the cuts
489 Bool_t poiOK = kTRUE;
490
491 if (poiCFManager)
492 {
493 poiOK = ( poiCFManager->CheckParticleCuts(AliCFManager::kPartRecCuts,pParticle) &&
494 poiCFManager->CheckParticleCuts(AliCFManager::kPartSelCuts,pParticle));
495 }
496
497 if (!(poiOK)) continue;
498
499 AliExternalTrackParam *tpcTrack = (AliExternalTrackParam *)pParticle->GetTPCInnerParam();
500
501 if (tpcTrack)
502 {
503
504// gPt = tpcTrack->Pt();
505// gP = tpcTrack->P();
506
507 useTPC = kTRUE;
508
509 const AliESDVertex *vertexSPD = esd->GetPrimaryVertexSPD();
510 const AliESDVertex *vertexTPC = esd->GetPrimaryVertexTPC();
511
512 if(hybrid)
513 tpcTrack->PropagateToDCA(vertexSPD,esd->GetMagneticField(),100.,dca,cov);
514 else
515 tpcTrack->PropagateToDCA(vertexTPC,esd->GetMagneticField(),100.,dca,cov);
516
8fa6a5fa 517 //dca3D = TMath::Sqrt(TMath::Power(dca[0],2)+TMath::Power(dca[1],2));
24373b38 518
519 }
520
521 //make new AliFLowTrack
522 AliFlowTrack* pTrack = new AliFlowTrack(pParticle);
523
524 pTrack->SetSource(AliFlowTrack::kFromESD);
525
526 //marking the particles used for diff. flow:
527 if(poiOK && poiCFManager)
528 {
529 pTrack->SetForPOISelection(kTRUE);
8fa6a5fa 530 IncrementNumberOfPOIs(1);
24373b38 531 }
532
533 if(useTPC)
534 {
535 pTrack->SetForRPSelection(kTRUE);
8fa6a5fa 536 IncrementNumberOfPOIs(0);
24373b38 537 }
538
539 AddTrack(pTrack);
540
541 }//end of while (itrkN < iNumberOfInputTracks)
542
543}
544
545//-----------------------------------------------------------------------
546AliFlowEvent::AliFlowEvent( const AliESDEvent* anInput,
547 const TH2F* anInputFMDhist,
548 const AliCFManager* poiCFManager ):
8fa6a5fa 549 AliFlowEventSimple(20)
24373b38 550{
24373b38 551
552 //Select the particles of interest from the ESD
553 Int_t iNumberOfInputTracks = anInput->GetNumberOfTracks() ;
554
555 //loop over tracks
556 for (Int_t itrkN=0; itrkN<iNumberOfInputTracks; itrkN++)
557 {
558 AliESDtrack* pParticle = anInput->GetTrack(itrkN); //get input particle
559
560 //check if pParticle passes the cuts
561 Bool_t poiOK = kTRUE;
562 if (poiCFManager)
563 {
564 poiOK = ( poiCFManager->CheckParticleCuts(AliCFManager::kPartRecCuts,pParticle) &&
565 poiCFManager->CheckParticleCuts(AliCFManager::kPartSelCuts,pParticle));
566 }
567 if (!poiOK) continue;
568
569 //make new AliFLowTrack
570 AliFlowTrack* pTrack = new AliFlowTrack(pParticle);
571
572 //marking the particles used for the particle of interest (POI) selection:
573 if(poiOK && poiCFManager)
574 {
8fa6a5fa 575 IncrementNumberOfPOIs(1);
24373b38 576 pTrack->SetForPOISelection(kTRUE);
577 pTrack->SetSource(AliFlowTrack::kFromESD);
578 }
579
580 AddTrack(pTrack);
581 }//end of while (itrkN < iNumberOfInputTracks)
582
583 //Select the reference particles from the FMD hits
584 //loop over FMD histogram
585 Int_t iBinsEta = anInputFMDhist->GetNbinsX();
586 Int_t iBinsPhi = anInputFMDhist->GetNbinsY();
587
588 for (Int_t iEta = 1; iEta <= iBinsEta; iEta++){
589 Double_t etaFMD = anInputFMDhist->GetXaxis()->GetBinCenter(iEta);
590 for (Int_t iPhi = 1; iPhi <= iBinsPhi; iPhi++){
591 Double_t phiFMD = anInputFMDhist->GetYaxis()->GetBinCenter(iPhi);
592 Double_t weightFMD = anInputFMDhist->GetBinContent(iEta,iPhi);
593
594 if (weightFMD > 0.0) { //do not add empty bins
595 //make new AliFLowTrackSimple
596 AliFlowTrack* pTrack = new AliFlowTrack();
597 pTrack->SetPt(0.0);
598 pTrack->SetEta(etaFMD);
599 pTrack->SetPhi(phiFMD);
600 pTrack->SetWeight(weightFMD);
601 //marking the particles used for the reference particle (RP) selection:
602 pTrack->TagRP();
8fa6a5fa 603 IncrementNumberOfPOIs(0);
24373b38 604 pTrack->SetSource(AliFlowTrack::kFromFMD);
605
606 //Add the track to the flowevent
607 AddTrack(pTrack);
608
609 }
610 }
611 }
612
613}
614
8fa6a5fa
MK
615//-----------------------------------------------------------------------
616void AliFlowEvent::FindDaughters(Bool_t keepDaughtersInRPselection)
617{
618 //each flow track holds it's esd track index as well as its daughters esd index.
619 //fill the array of daughters for every track with the pointers to flow tracks
620 //to associate the mothers with daughters directly
621 for (Int_t iTrack=0; iTrack<fMothersCollection->GetEntriesFast(); iTrack++)
622 {
623 AliFlowTrack* mother = static_cast<AliFlowTrack*>(fMothersCollection->At(iTrack));
624 if (!mother) continue;
625 if (mother->GetNDaughters()<1) continue;
626 for (Int_t iDaughterCandidate=0; iDaughterCandidate<fNumberOfTracks; iDaughterCandidate++)
627 {
628 AliFlowTrack* daughterCandidate = static_cast<AliFlowTrack*>(fTrackCollection->At(iDaughterCandidate));
629 Int_t esdIndexDaughterCandidate = daughterCandidate->GetID();
630 for (Int_t iDaughter=0; iDaughter<mother->GetNDaughters(); iDaughter++)
631 {
632 Int_t esdIndexDaughter = mother->GetIDDaughter(iDaughter);
633 if (esdIndexDaughter==esdIndexDaughterCandidate)
634 {
635 mother->SetDaughter(iDaughter,daughterCandidate);
636 daughterCandidate->SetForRPSelection(keepDaughtersInRPselection);
637 }
638 }
639 }
640 }
641}
642
24373b38 643//-----------------------------------------------------------------------
644void AliFlowEvent::Fill( AliFlowTrackCuts* rpCuts,
645 AliFlowTrackCuts* poiCuts )
646{
647 //Fills the event from a vevent: AliESDEvent,AliAODEvent,AliMCEvent
648 //the input data needs to be attached to the cuts
649 //we have two cases, if we're cutting the same collection of tracks
650 //(same param type) then we can have tracks that are both rp and poi
651 //in the other case we want to have two exclusive sets of rps and pois
652 //e.g. one tracklets, the other PMD or global - USER IS RESPOSIBLE
653 //FOR MAKING SURE THEY DONT OVERLAP OR ELSE THE SAME PARTICLE WILL BE
654 //TAKEN TWICE
655
656 ClearFast();
657
658 if (!rpCuts || !poiCuts) return;
659 AliFlowTrackCuts::trackParameterType sourceRP = rpCuts->GetParamType();
660 AliFlowTrackCuts::trackParameterType sourcePOI = poiCuts->GetParamType();
661 AliFlowTrack* pTrack=NULL;
8fa6a5fa 662
24373b38 663 if (sourceRP==sourcePOI)
664 {
665 //loop over tracks
8fa6a5fa
MK
666 Int_t numberOfInputObjects = rpCuts->GetNumberOfInputObjects();
667 for (Int_t i=0; i<numberOfInputObjects; i++)
24373b38 668 {
669 //get input object (particle)
670 TObject* particle = rpCuts->GetInputObject(i);
671
672 Bool_t rp = rpCuts->IsSelected(particle,i);
8fa6a5fa 673 Int_t poiClass = poiCuts->IsSelected(particle,i);
24373b38 674
8fa6a5fa
MK
675 if (!(rp||poiClass>0)) continue;
676
677 //make new AliFlowTrack
24373b38 678 if (rp)
679 {
8fa6a5fa
MK
680 pTrack = rpCuts->FillFlowTrack(fTrackCollection,fNumberOfTracks);
681 if (!pTrack) continue;
682 pTrack->TagRP(); IncrementNumberOfPOIs(0);
683 if (poiClass>0) {pTrack->Tag(poiClass); IncrementNumberOfPOIs(poiClass);}
684 if (pTrack->GetNDaughters()>0) fMothersCollection->Add(pTrack);
24373b38 685 }
8fa6a5fa 686 else if (poiClass>0)
24373b38 687 {
8fa6a5fa
MK
688 pTrack = poiCuts->FillFlowTrack(fTrackCollection,fNumberOfTracks);
689 if (!pTrack) continue;
690 pTrack->Tag(poiClass); IncrementNumberOfPOIs(poiClass);
691 if (pTrack->GetNDaughters()>0) fMothersCollection->Add(pTrack);
24373b38 692 }
693 fNumberOfTracks++;
694 }//end of while (i < numberOfTracks)
695 }
696 else if (sourceRP!=sourcePOI)
697 {
698 //here we have two different sources of particles, so we fill
699 //them independently
8fa6a5fa
MK
700 //POI
701 for (Int_t i=0; i<poiCuts->GetNumberOfInputObjects(); i++)
702 {
703 TObject* particle = poiCuts->GetInputObject(i);
704 Int_t poiClass = poiCuts->IsSelected(particle,i);
705 if (poiClass<=0) continue;
706 pTrack = poiCuts->FillFlowTrack(fTrackCollection,fNumberOfTracks);
707 if (!pTrack) continue;
708 pTrack->Tag(poiClass);
709 IncrementNumberOfPOIs(poiClass);
710 fNumberOfTracks++;
711 if (pTrack->GetNDaughters()>0) fMothersCollection->Add(pTrack);
712 }
24373b38 713 //RP
8fa6a5fa
MK
714 Int_t numberOfInputObjects = rpCuts->GetNumberOfInputObjects();
715 for (Int_t i=0; i<numberOfInputObjects; i++)
24373b38 716 {
717 TObject* particle = rpCuts->GetInputObject(i);
8fa6a5fa
MK
718 Int_t rp = rpCuts->IsSelected(particle,i);
719 if (rp<1) continue;
720 pTrack = rpCuts->FillFlowTrack(fTrackCollection,fNumberOfTracks);
721 if (!pTrack) continue;
24373b38 722 pTrack->TagRP();
8fa6a5fa 723 IncrementNumberOfPOIs(0);
24373b38 724 fNumberOfTracks++;
8fa6a5fa 725 if (pTrack->GetNDaughters()>0) fMothersCollection->Add(pTrack);
24373b38 726 }
727 }
728}
729
730//-----------------------------------------------------------------------
8fa6a5fa 731void AliFlowEvent::InsertTrack(AliFlowTrack *track) {
24373b38 732 // adds a flow track at the end of the container
733 AliFlowTrack *pTrack = ReuseTrack( fNumberOfTracks++ );
8fa6a5fa
MK
734 *pTrack = *track;
735 if (track->GetNDaughters()>0)
736 {
737 fMothersCollection->Add(track);
738 }
739 //pTrack->SetPt( track->Pt() );
740 //pTrack->SetPhi( track->Phi() );
741 //pTrack->SetEta( track->Eta() );
742 //pTrack->SetWeight( track->Weight() );
743 //pTrack->SetCharge( track->Charge() );
744 //pTrack->SetMass( track->Mass() );
745 //pTrack->SetForRPSelection( track->InRPSelection() );
746 //pTrack->SetForPOISelection( track->InPOISelection() );
747 //if(track->InSubevent(0)) pTrack->SetForSubevent(0);
748 //if(track->InSubevent(1)) pTrack->SetForSubevent(1);
749 //pTrack->SetID( track->GetID() );
24373b38 750 return;
751}
752
753//-----------------------------------------------------------------------
754AliFlowTrack* AliFlowEvent::ReuseTrack(Int_t i)
755{
756 //try to reuse an existing track, if empty, make new one
757 AliFlowTrack* pTrack = static_cast<AliFlowTrack*>(fTrackCollection->At(i));
758 if (pTrack)
759 {
760 pTrack->Clear();
761 }
762 else
763 {
764 pTrack = new AliFlowTrack();
765 fTrackCollection->AddAtAndExpand(pTrack,i);
766 }
767 return pTrack;
768}
769
770//-----------------------------------------------------------------------
771AliFlowEvent::AliFlowEvent( AliFlowTrackCuts* rpCuts,
772 AliFlowTrackCuts* poiCuts ):
8fa6a5fa 773 AliFlowEventSimple(20)
24373b38 774{
24373b38 775 //Fills the event from a vevent: AliESDEvent,AliAODEvent,AliMCEvent
776 //the input data needs to be attached to the cuts
777 //we have two cases, if we're cutting the same collection of tracks
778 //(same param type) then we can have tracks that are both rp and poi
779 //in the other case we want to have two exclusive sets of rps and pois
780 //e.g. one tracklets, the other PMD or global - USER IS RESPOSIBLE
781 //FOR MAKING SURE THEY DONT OVERLAP OR ELSE THE SAME PARTICLE WILL BE
782 //TAKEN TWICE
783
784 if (!rpCuts || !poiCuts) return;
785 AliFlowTrackCuts::trackParameterType sourceRP = rpCuts->GetParamType();
786 AliFlowTrackCuts::trackParameterType sourcePOI = poiCuts->GetParamType();
787
788 if (sourceRP==sourcePOI)
789 {
790 //loop over tracks
8fa6a5fa
MK
791 Int_t numberOfInputObjects = rpCuts->GetNumberOfInputObjects();
792 for (Int_t i=0; i<numberOfInputObjects; i++)
24373b38 793 {
794 //get input object (particle)
795 TObject* particle = rpCuts->GetInputObject(i);
796
797 Bool_t rp = rpCuts->IsSelected(particle,i);
8fa6a5fa 798 Int_t poiClass = poiCuts->IsSelected(particle,i);
24373b38 799
8fa6a5fa 800 if (!(rp||poiClass>0)) continue;
24373b38 801
802 //make new AliFLowTrack
803 AliFlowTrack* pTrack = NULL;
804 if (rp)
805 {
8fa6a5fa 806 pTrack = rpCuts->FillFlowTrack(fTrackCollection,fNumberOfTracks);
24373b38 807 if (!pTrack) continue;
8fa6a5fa
MK
808 pTrack->TagRP(); IncrementNumberOfPOIs(0);
809 if (poiClass>0) {pTrack->Tag(poiClass); IncrementNumberOfPOIs(poiClass);}
24373b38 810 }
811 else
8fa6a5fa 812 if (poiClass>0)
24373b38 813 {
8fa6a5fa 814 pTrack = poiCuts->FillFlowTrack(fTrackCollection,fNumberOfTracks);
24373b38 815 if (!pTrack) continue;
8fa6a5fa 816 pTrack->Tag(poiClass); IncrementNumberOfPOIs(poiClass);
24373b38 817 }
8fa6a5fa 818 TrackAdded();
24373b38 819 }//end of while (i < numberOfTracks)
820 }
821 else if (sourceRP!=sourcePOI)
822 {
823 //here we have two different sources of particles, so we fill
824 //them independently
825 AliFlowTrack* pTrack = NULL;
826 //RP
8fa6a5fa
MK
827 Int_t numberOfInputObjects = rpCuts->GetNumberOfInputObjects();
828 for (Int_t i=0; i<numberOfInputObjects; i++)
24373b38 829 {
830 TObject* particle = rpCuts->GetInputObject(i);
831 Bool_t rp = rpCuts->IsSelected(particle,i);
832 if (!rp) continue;
8fa6a5fa 833 pTrack = rpCuts->FillFlowTrack(fTrackCollection,fNumberOfTracks);
24373b38 834 if (!pTrack) continue;
8fa6a5fa
MK
835 pTrack->TagRP(); IncrementNumberOfPOIs(0);
836 TrackAdded();
24373b38 837 }
838 //POI
8fa6a5fa
MK
839 numberOfInputObjects = poiCuts->GetNumberOfInputObjects();
840 for (Int_t i=0; i<numberOfInputObjects; i++)
24373b38 841 {
842 TObject* particle = poiCuts->GetInputObject(i);
8fa6a5fa
MK
843 Int_t poiClass = poiCuts->IsSelected(particle,i);
844 if (poiClass<=0) continue;
845 pTrack = poiCuts->FillFlowTrack(fTrackCollection,fNumberOfTracks);
24373b38 846 if (!pTrack) continue;
8fa6a5fa
MK
847 pTrack->Tag(poiClass); IncrementNumberOfPOIs(poiClass);
848 TrackAdded();
24373b38 849 }
850 }
851}
852
853//-------------------------------------------------------------------//
854//---- Including PMD tracks as RP --------------------------//
855
856AliFlowEvent::AliFlowEvent( const AliESDEvent* anInput,
857 const AliESDPmdTrack *pmdtracks,
858 const AliCFManager* poiCFManager ):
8fa6a5fa 859 AliFlowEventSimple(20)
24373b38 860{
24373b38 861 Float_t GetPmdEta(Float_t xPos, Float_t yPos, Float_t zPos);
862 Float_t GetPmdPhi(Float_t xPos, Float_t yPos);
863 //Select the particles of interest from the ESD
864 Int_t iNumberOfInputTracks = anInput->GetNumberOfTracks() ;
865
866 //loop over tracks
867 for (Int_t itrkN=0; itrkN<iNumberOfInputTracks; itrkN++)
868 {
869 AliESDtrack* pParticle = anInput->GetTrack(itrkN); //get input particle
870 //check if pParticle passes the cuts
871 Bool_t poiOK = kTRUE;
872 if (poiCFManager)
873 {
874 poiOK = ( poiCFManager->CheckParticleCuts(AliCFManager::kPartRecCuts,pParticle) &&
875 poiCFManager->CheckParticleCuts(AliCFManager::kPartSelCuts,pParticle));
876 }
877 if (!poiOK) continue;
878
879 //make new AliFLowTrack
880 AliFlowTrack* pTrack = new AliFlowTrack(pParticle);
881
882 //marking the particles used for the particle of interest (POI) selection:
883 if(poiOK && poiCFManager)
884 {
8fa6a5fa 885 IncrementNumberOfPOIs(1);
24373b38 886 pTrack->SetForPOISelection(kTRUE);
887 pTrack->SetSource(AliFlowTrack::kFromESD);
888 }
889
890 AddTrack(pTrack);
891 }//end of while (itrkN < iNumberOfInputTracks)
892
893 //Select the reference particles from the PMD tracks
894 Int_t npmdcl = anInput->GetNumberOfPmdTracks();
895 printf("======There are %d PMD tracks in this event\n-------",npmdcl);
896 //loop over clusters
897 for(Int_t iclust=0; iclust < npmdcl; iclust++){
898 //AliESDPmdTrack *pmdtr = anInput->GetPmdTrack(iclust);
899 pmdtracks = anInput->GetPmdTrack(iclust);
900 Int_t det = pmdtracks->GetDetector();
901 //Int_t smn = pmdtracks->GetSmn();
902 Float_t clsX = pmdtracks->GetClusterX();
903 Float_t clsY = pmdtracks->GetClusterY();
904 Float_t clsZ = pmdtracks->GetClusterZ();
905 Float_t ncell = pmdtracks->GetClusterCells();
906 Float_t adc = pmdtracks->GetClusterADC();
907 //Float_t pid = pmdtracks->GetClusterPID();
908 Float_t etacls = GetPmdEta(clsX,clsY,clsZ);
909 Float_t phicls = GetPmdPhi(clsX,clsY);
910 //make new AliFLowTrackSimple
911 AliFlowTrack* pTrack = new AliFlowTrack();
912 //if(det == 0){ //selecting preshower plane only
913 if(det == 0 && adc > 270 && ncell > 1){ //selecting preshower plane only
914 //pTrack->SetPt(adc);//cluster adc
915 pTrack->SetPt(0.0);
916 pTrack->SetEta(etacls);
917 pTrack->SetPhi(phicls);
918 //marking the particles used for the reference particle (RP) selection:
8fa6a5fa 919 IncrementNumberOfPOIs(0);
24373b38 920 pTrack->SetForRPSelection(kTRUE);
921 pTrack->SetSource(AliFlowTrack::kFromPMD);
922 //Add the track to the flowevent
923 AddTrack(pTrack);
924 }//if det
925 }
926}
927//----------------------------------------------------------------------------//
928Float_t GetPmdEta(Float_t xPos, Float_t yPos, Float_t zPos)
929{
930 Float_t rpxpy, theta, eta;
931 rpxpy = TMath::Sqrt(xPos*xPos + yPos*yPos);
932 theta = TMath::ATan2(rpxpy,zPos);
933 eta = -TMath::Log(TMath::Tan(0.5*theta));
934 return eta;
935}
936//--------------------------------------------------------------------------//
937Float_t GetPmdPhi(Float_t xPos, Float_t yPos)
938{
939 Float_t pybypx, phi = 0., phi1;
940 if(xPos==0)
941 {
942 if(yPos>0) phi = 90.;
943 if(yPos<0) phi = 270.;
944 }
945 if(xPos != 0)
946 {
947 pybypx = yPos/xPos;
948 if(pybypx < 0) pybypx = - pybypx;
949 phi1 = TMath::ATan(pybypx)*180./3.14159;
950
951 if(xPos > 0 && yPos > 0) phi = phi1; // 1st Quadrant
952 if(xPos < 0 && yPos > 0) phi = 180 - phi1; // 2nd Quadrant
953 if(xPos < 0 && yPos < 0) phi = 180 + phi1; // 3rd Quadrant
954 if(xPos > 0 && yPos < 0) phi = 360 - phi1; // 4th Quadrant
955
956 }
957 phi = phi*3.14159/180.;
958 return phi;
959}
960//---------------------------------------------------------------//
961
962