1 /*************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: A.Abrahantes, E.Lopez, S.Vallero *
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 //#include <TBranch.h>
16 //#include <TCanvas.h>
23 //#include <TLorentzVector.h>
25 #include <TObjArray.h>
27 //#include <TProfile.h>
28 //#include <TRandom.h>
29 //#include <TSystem.h>
33 #include "AliAnalyseLeadingTrackUE.h"
34 //#include "AliAnalysisTask.h"
36 //#include "AliAnalysisHelperJetTasks.h"
37 //#include "AliAnalysisManager.h"
38 #include "AliAODEvent.h"
39 //#include "AliAODHandler.h"
40 //#include "AliAODJet.h"
41 #include "AliAODMCParticle.h"
42 #include "AliAODTrack.h"
43 #include "AliESDEvent.h"
44 #include "AliESDtrack.h"
45 #include "AliESDtrackCuts.h"
46 //#include "AliGenPythiaEventHeader.h"
47 #include "AliInputEventHandler.h"
48 //#include "AliKFVertex.h"
50 #include "AliMCEvent.h"
51 #include "AliVParticle.h"
52 #include "AliAODMCHeader.h"
54 #include "AliAnalysisManager.h"
55 #include "AliMCEventHandler.h"
59 ////////////////////////////////////////////////
60 //---------------------------------------------
61 // Class for transverse regions analysis
62 //---------------------------------------------
63 ////////////////////////////////////////////////
68 ClassImp(AliAnalyseLeadingTrackUE)
70 //-------------------------------------------------------------------
71 AliAnalyseLeadingTrackUE::AliAnalyseLeadingTrackUE() :
78 fEventSelection(AliVEvent::kMB|AliVEvent::kUserDefined),
80 fEsdTrackCutsSPD(0x0),
87 //-------------------------------------------------------------------
88 AliAnalyseLeadingTrackUE & AliAnalyseLeadingTrackUE::operator = (const AliAnalyseLeadingTrackUE & /*source*/)
90 // assignment operator
95 //-------------------------------------------------------------------
96 AliAnalyseLeadingTrackUE::~AliAnalyseLeadingTrackUE()
104 //____________________________________________________________________
105 Bool_t AliAnalyseLeadingTrackUE::ApplyCuts(TObject* track)
108 // select track according to set of cuts
109 if (!fEsdTrackCuts->IsSelected(track) )return kFALSE;
110 if (fEsdTrackCutsSPD && fEsdTrackCutsSDD && !fEsdTrackCutsSPD->IsSelected(track) && fEsdTrackCutsSDD->IsSelected(track)) return kFALSE;
116 //____________________________________________________________________
117 void AliAnalyseLeadingTrackUE::DefineESDCuts(Int_t filterbit) {
119 // Reproduces the cuts of the corresponding bit in the ESD->AOD filtering
120 // (see $ALICE_ROOT/ANALYSIS/macros/AddTaskESDFilter.C)
123 filterbit = fFilterBit;
125 if (filterbit == 128)
127 fEsdTrackCuts = AliESDtrackCuts::GetStandardTPCOnlyTrackCuts();
128 fEsdTrackCuts->SetMinNClustersTPC(70);
130 else if (filterbit == 256)
133 fEsdTrackCuts = AliESDtrackCuts::GetStandardTPCOnlyTrackCuts();
134 fEsdTrackCuts->SetMinNClustersTPC(80);
135 fEsdTrackCuts->SetMaxChi2PerClusterTPC(3);
136 fEsdTrackCuts->SetMaxDCAToVertexZ(2.7);
137 fEsdTrackCuts->SetMaxDCAToVertexXY(1.9);
139 else if (filterbit == 512)
142 fEsdTrackCuts = AliESDtrackCuts::GetStandardTPCOnlyTrackCuts();
143 fEsdTrackCuts->SetMinNClustersTPC(60);
144 fEsdTrackCuts->SetMaxChi2PerClusterTPC(5);
145 fEsdTrackCuts->SetMaxDCAToVertexZ(3.7);
146 fEsdTrackCuts->SetMaxDCAToVertexXY(2.9);
148 else if (filterbit == 1024)
150 fEsdTrackCuts = AliESDtrackCuts::GetStandardTPCOnlyTrackCuts();
151 fEsdTrackCuts->SetMinNClustersTPC(-1);
152 fEsdTrackCuts->SetMinNCrossedRowsTPC(70);
153 fEsdTrackCuts->SetMinRatioCrossedRowsOverFindableClustersTPC(0.8);
157 fEsdTrackCuts = AliESDtrackCuts::GetStandardITSTPCTrackCuts2010();
158 fEsdTrackCuts->SetClusterRequirementITS(AliESDtrackCuts::kSPD, AliESDtrackCuts::kNone);
160 // Add SPD requirement
161 fEsdTrackCutsSPD = new AliESDtrackCuts("SPD", "Require 1 cluster in SPD");
162 fEsdTrackCutsSPD->SetClusterRequirementITS(AliESDtrackCuts::kSPD,AliESDtrackCuts::kAny);
164 // Add SDD requirement
165 fEsdTrackCutsSDD = new AliESDtrackCuts("SDD", "Require 1 cluster in first layer SDD");
166 fEsdTrackCutsSDD->SetClusterRequirementITS(AliESDtrackCuts::kSDD,AliESDtrackCuts::kFirst);
170 //____________________________________________________________________
171 TObjArray* AliAnalyseLeadingTrackUE::FindLeadingObjects(TObject *obj)
174 // Returns an array of charged particles (or jets) ordered according to their pT.
176 Int_t nTracks = NParticles(obj);
179 if( !nTracks ) return 0;
181 // Define array of AliVParticle objects
182 TObjArray* tracks = new TObjArray(nTracks);
184 // Loop over tracks or jets
185 for (Int_t ipart=0; ipart<nTracks; ++ipart) {
186 AliVParticle* part = ParticleWithCuts( obj, ipart );
188 // Accept leading-tracks in a limited pseudo-rapidity range
189 if( TMath::Abs(part->Eta()) > fTrackEtaCut ) continue;
190 tracks->AddLast( part );
192 // Order tracks by pT
193 QSortTracks( *tracks, 0, tracks->GetEntriesFast() );
195 nTracks = tracks->GetEntriesFast();
196 if( !nTracks ) return 0;
202 void AliAnalyseLeadingTrackUE::RemoveInjectedSignals(TObjArray* tracks, TObject* mcObj, Int_t maxLabel)
204 // remove injected signals (primaries above <maxLabel>)
205 // <tracks> can be the following cases:
206 // a. tracks: in this case the label is taken and then case b.
207 // b. particles: the first stable mother is searched and checked if it is <= <maxLabel>
208 // <mcObj> can be AOD (TClonesArray) or ESD (AliMCEvent)
210 TClonesArray* arrayMC = 0;
211 AliMCEvent* mcEvent = 0;
212 if (mcObj->InheritsFrom("AliMCEvent"))
213 mcEvent = static_cast<AliMCEvent*>(mcObj);
214 else if (mcObj->InheritsFrom("TClonesArray"))
215 arrayMC = static_cast<TClonesArray*>(mcObj);
219 AliFatal("Invalid object passed");
222 Int_t before = tracks->GetEntriesFast();
224 for (Int_t i=0; i<before; ++i)
226 AliVParticle* part = (AliVParticle*) tracks->At(i);
228 if (part->InheritsFrom("AliESDtrack") || part->InheritsFrom("AliAODTrack"))
229 part = ((mcEvent) ? mcEvent->GetTrack(TMath::Abs(part->GetLabel())) : (AliVParticle*)arrayMC->At(TMath::Abs(part->GetLabel())));
231 AliVParticle* mother = part;
234 while (!mcEvent->IsPhysicalPrimary(mother->GetLabel()))
236 if (((AliMCParticle*)mother)->GetMother() < 0)
242 mother = (AliMCParticle*) mcEvent->GetTrack(((AliMCParticle*)mother)->GetMother());
249 // find the primary mother
250 while (!((AliAODMCParticle*)mother)->IsPhysicalPrimary())
252 if (((AliAODMCParticle*)mother)->GetMother() < 0)
258 mother = (AliVParticle*) arrayMC->At(((AliAODMCParticle*)mother)->GetMother());
266 Printf("WARNING: No mother found for particle %d:", part->GetLabel());
270 if (mother->GetLabel() > maxLabel)
272 // Printf("Removing %d with label %d", i, part->GetLabel()); part->Dump();
273 TObject* object = tracks->RemoveAt(i);
274 if (tracks->IsOwner())
281 AliInfo(Form("Reduced from %d to %d", before, tracks->GetEntriesFast()));
284 //-------------------------------------------------------------------
285 TObjArray* AliAnalyseLeadingTrackUE::GetAcceptedParticles(TObject* obj, TObject* arrayMC, Bool_t onlyprimaries, Int_t particleSpecies, Bool_t useEtaPtCuts)
287 // Returns an array of particles that pass the cuts, if arrayMC is given each reconstructed particle is replaced by its corresponding MC particles, depending on the parameter onlyprimaries only for primaries
288 // particleSpecies: -1 all particles are returned
289 // 0 (pions) 1 (kaons) 2 (protons) 3 (others) particles
291 Int_t nTracks = NParticles(obj);
292 TObjArray* tracks = new TObjArray;
294 // for TPC only tracks
295 Bool_t hasOwnership = kFALSE;
296 if ((fFilterBit == 128 || fFilterBit == 256 || fFilterBit == 512 || fFilterBit == 1024) && obj->InheritsFrom("AliESDEvent"))
297 hasOwnership = kTRUE;
300 tracks->SetOwner(hasOwnership);
302 // Loop over tracks or jets
303 for (Int_t ipart=0; ipart<nTracks; ++ipart) {
304 AliVParticle* part = ParticleWithCuts( obj, ipart, onlyprimaries, particleSpecies );
308 if (TMath::Abs(part->Eta()) > fTrackEtaCut || part->Pt() < fTrackPtMin)
316 Int_t label = part->GetLabel();
319 // re-define part as the matched MC particle
320 part = ParticleWithCuts(arrayMC, TMath::Abs(label),onlyprimaries, particleSpecies);
330 //-------------------------------------------------------------------
331 TObjArray* AliAnalyseLeadingTrackUE::GetMinMaxRegion(TList *transv1, TList *transv2)
334 // Returns two lists of particles, one for MIN and one for MAX region
335 Double_t sumpT1 = 0.;
336 Double_t sumpT2 = 0.;
338 Int_t particles1 = transv1->GetEntries();
339 Int_t particles2 = transv2->GetEntries();
341 // Loop on transverse region 1
342 for (Int_t i=0; i<particles1; i++){
343 AliVParticle *part = (AliVParticle*)transv1->At(i);
344 sumpT1 += part->Pt();
347 // Loop on transverse region 2
348 for (Int_t i=0; i<particles2; i++){
349 AliVParticle *part = (AliVParticle*)transv2->At(i);
350 sumpT2 += part->Pt();
353 TObjArray *regionParticles = new TObjArray;
354 if ( sumpT2 >= sumpT1 ){
355 regionParticles->AddLast(transv1); // MIN
356 regionParticles->AddLast(transv2); // MAX
358 regionParticles->AddLast(transv2); // MIN
359 regionParticles->AddLast(transv1); // MAX
362 return regionParticles;
365 //-------------------------------------------------------------------
366 Int_t AliAnalyseLeadingTrackUE::NParticles(TObject* obj)
369 //Returns the number of particles in AliAODMCParticle array or AliAODTracks or AliESDTracks
373 if (obj->InheritsFrom("TClonesArray")){ // MC particles
374 TClonesArray *arrayMC = static_cast<TClonesArray*>(obj);
375 nTracks = arrayMC->GetEntriesFast();
376 }else if (obj->InheritsFrom("TObjArray")){ // list of AliVParticle
377 TObjArray *array = static_cast<TObjArray*>(obj);
378 nTracks = array->GetEntriesFast();
379 }else if (obj->InheritsFrom("AliAODEvent")){ // RECO AOD tracks
380 AliAODEvent *aodEvent = static_cast<AliAODEvent*>(obj);
381 nTracks = aodEvent->GetNTracks();
382 }else if (obj->InheritsFrom("AliESDEvent")){ // RECO ESD tracks
383 AliESDEvent *esdEvent = static_cast<AliESDEvent*>(obj);
384 nTracks = esdEvent->GetNumberOfTracks();
385 }else if (obj->InheritsFrom("AliMCEvent")){ // RECO ESD tracks
386 AliMCEvent *mcEvent = static_cast<AliMCEvent*>(obj);
387 nTracks = mcEvent->GetNumberOfTracks();
389 if (fDebug > 1) AliFatal(" Analysis type not defined !!! ");
397 //-------------------------------------------------------------------
398 AliVParticle* AliAnalyseLeadingTrackUE::ParticleWithCuts(TObject* obj, Int_t ipart, Bool_t onlyprimaries, Int_t particleSpecies)
400 // Returns track or MC particle at position "ipart" if passes selection criteria
401 // particleSpecies: -1 all particles are returned
402 // 0 (pions) 1 (kaons) 2 (protons) 3 (others) particles
403 AliVParticle *part=0;
405 if (obj->InheritsFrom("TClonesArray")){ // AOD-MC PARTICLE
406 TClonesArray *arrayMC = static_cast<TClonesArray*>(obj);
407 part = (AliVParticle*)arrayMC->At( ipart );
409 // eventually only primaries
410 if (onlyprimaries && !( ((AliAODMCParticle*)part)->IsPhysicalPrimary()) )return 0;
411 // eventually only hadrons
413 Int_t pdgCode = ((AliAODMCParticle*)part)->GetPdgCode();
414 Bool_t isHadron = TMath::Abs(pdgCode)==211 || // Pion
415 TMath::Abs(pdgCode)==2212 || // Proton
416 TMath::Abs(pdgCode)==321; // Kaon
417 if (!isHadron) return 0;
419 if (particleSpecies != -1) {
420 // find the primary mother
421 AliVParticle* mother = part;
422 while (!((AliAODMCParticle*)mother)->IsPhysicalPrimary())
424 if (((AliAODMCParticle*)mother)->GetMother() < 0)
430 mother = (AliVParticle*) arrayMC->At(((AliAODMCParticle*)mother)->GetMother());
437 Int_t pdgCode = ((AliAODMCParticle*)mother)->GetPdgCode();
438 if (particleSpecies == 0 && TMath::Abs(pdgCode)!=211)
440 if (particleSpecies == 1 && TMath::Abs(pdgCode)!=321)
442 if (particleSpecies == 2 && TMath::Abs(pdgCode)!=2212)
444 if (particleSpecies == 3 && (TMath::Abs(pdgCode)==211 || TMath::Abs(pdgCode)==321 || TMath::Abs(pdgCode)==2212))
449 // if mother not found, accept particle only in case of particleSpecies == 3. To include it in all or no sample is no solution
450 Printf("WARNING: No mother found for particle %d:", part->GetLabel());
454 // this code prints the details of the mother that is missing in the AOD
455 AliMCEventHandler* fMcHandler = dynamic_cast<AliMCEventHandler*> (AliAnalysisManager::GetAnalysisManager()->GetMCtruthEventHandler());
457 AliMCEvent* fMcEvent = fMcHandler->MCEvent();
459 fMcEvent->Stack()->Particle(fMcEvent->Stack()->Particle(part->GetLabel())->GetMother(0))->Print();
460 fMcEvent->Stack()->Particle(fMcEvent->Stack()->Particle(fMcEvent->Stack()->Particle(part->GetLabel())->GetMother(0))->GetMother(0))->Print();
461 Printf("eta = %f", fMcEvent->Stack()->Particle(fMcEvent->Stack()->Particle(fMcEvent->Stack()->Particle(part->GetLabel())->GetMother(0))->GetMother(0))->Eta());
464 if (particleSpecies != 3)
469 }else if (obj->InheritsFrom("TObjArray")){ // list of AliVParticle
470 TObjArray *array = static_cast<TObjArray*>(obj);
471 part = (AliVParticle*)array->At( ipart );
473 }else if (obj->InheritsFrom("AliMCEvent")){ // MC PARTICLE
474 AliMCEvent* mcEvent = static_cast<AliMCEvent*>(obj);
475 part = mcEvent->GetTrack( ipart );
477 // eventually only primaries
478 if (onlyprimaries && !( mcEvent->IsPhysicalPrimary(ipart)) )return 0;
479 // eventually only hadrons
482 Int_t pdgCode = part->GetPdgCode();
483 Bool_t isHadron = TMath::Abs(pdgCode)==211 || // Pion
484 TMath::Abs(pdgCode)==2212 || // Proton
485 TMath::Abs(pdgCode)==321; // Kaon
486 if (!isHadron) return 0;
489 if (particleSpecies != -1) {
490 // find the primary mother
491 AliMCParticle* mother = (AliMCParticle*) part;
493 while (!mcEvent->IsPhysicalPrimary(mother->GetLabel()))
495 // Printf("pdg = %d; mother = %d", mother->PdgCode(), mother->GetMother());
496 if (mother->GetMother() < 0)
502 mother = (AliMCParticle*) mcEvent->GetTrack(mother->GetMother());
509 Int_t pdgCode = mother->PdgCode();
510 if (particleSpecies == 0 && TMath::Abs(pdgCode)!=211)
512 if (particleSpecies == 1 && TMath::Abs(pdgCode)!=321)
514 if (particleSpecies == 2 && TMath::Abs(pdgCode)!=2212)
516 if (particleSpecies == 3 && (TMath::Abs(pdgCode)==211 || TMath::Abs(pdgCode)==321 || TMath::Abs(pdgCode)==2212))
521 // if mother not found, accept particle only in case of particleSpecies == 3. To include it in all or no sample is no solution
522 Printf("WARNING: No mother found for particle %d:", part->GetLabel());
527 // this code prints the details of the mother that is missing in the AOD
528 AliMCEventHandler* fMcHandler = dynamic_cast<AliMCEventHandler*> (AliAnalysisManager::GetAnalysisManager()->GetMCtruthEventHandler());
530 AliMCEvent* fMcEvent = fMcHandler->MCEvent();
532 fMcEvent->Stack()->Particle(fMcEvent->Stack()->Particle(part->GetLabel())->GetMother(0))->Print();
533 fMcEvent->Stack()->Particle(fMcEvent->Stack()->Particle(fMcEvent->Stack()->Particle(part->GetLabel())->GetMother(0))->GetMother(0))->Print();
534 Printf("eta = %f", fMcEvent->Stack()->Particle(fMcEvent->Stack()->Particle(fMcEvent->Stack()->Particle(part->GetLabel())->GetMother(0))->GetMother(0))->Eta());
537 if (particleSpecies != 3)
541 }else if (obj->InheritsFrom("AliAODEvent")){ // RECO AOD TRACKS
542 AliAODEvent *aodEvent = static_cast<AliAODEvent*>(obj);
543 part = aodEvent->GetTrack(ipart);
544 // track selection cuts
545 if ( !(((AliAODTrack*)part)->TestFilterBit(fFilterBit)) ) return 0;
546 //if ( !(((AliAODTrack*)part)->TestFilterBit(fFilterBit)) && !(((AliAODTrack*)part)->TestFilterBit(32)) ) return 0;
547 // only primary candidates
548 //if ( ((AliAODTrack*)part)->IsPrimaryCandidate() )return 0;
549 // eventually only hadrons
551 Bool_t isHadron = ((AliAODTrack*)part)->GetMostProbablePID()==AliAODTrack::kPion ||
552 ((AliAODTrack*)part)->GetMostProbablePID()==AliAODTrack::kKaon ||
553 ((AliAODTrack*)part)->GetMostProbablePID()==AliAODTrack::kProton;
554 if (!isHadron) return 0;
557 }else if (obj->InheritsFrom("AliESDEvent")){ // RECO ESD TRACKS
558 AliESDEvent *esdEvent = static_cast<AliESDEvent*>(obj);
559 part = esdEvent->GetTrack(ipart);
561 // track selection cuts
563 if (!( ApplyCuts(part)) )
566 if (fFilterBit == 128 || fFilterBit == 256 || fFilterBit == 512 || fFilterBit == 1024)
568 // create TPC only tracks constrained to the SPD vertex
570 const AliESDVertex *vtxSPD = esdEvent->GetPrimaryVertexSPD();
572 AliESDtrack* track = AliESDtrackCuts::GetTPCOnlyTrack(esdEvent, ipart);
576 // only constrain tracks above threshold
577 AliExternalTrackParam exParam;
578 // take the B-feild from the ESD, no 3D fieldMap available at this point
579 Bool_t relate = kFALSE;
580 relate = track->RelateToVertexTPC(vtxSPD,esdEvent->GetMagneticField(),kVeryBig,&exParam);
583 // Printf("relating failed");
587 track->Set(exParam.GetX(),exParam.GetAlpha(),exParam.GetParameter(),exParam.GetCovariance());
593 // eventually only hadrons
596 Bool_t isHadron = ((AliAODTrack*)part)->GetMostProbablePID()==AliAODTrack::kPion ||
597 ((AliAODTrack*)part)->GetMostProbablePID()==AliAODTrack::kKaon ||
598 ((AliAODTrack*)part)->GetMostProbablePID()==AliAODTrack::kProton;
599 if (!isHadron) return 0;
603 if (fDebug > 1) AliFatal(" Analysis type not defined !!! ");
608 if (!part->Charge())return 0;
614 //-------------------------------------------------------------------
615 void AliAnalyseLeadingTrackUE::QSortTracks(TObjArray &a, Int_t first, Int_t last)
617 // Sort array of TObjArray of tracks by Pt using a quicksort algorithm.
620 static int i; // "static" to save stack space
623 while (last - first > 1) {
627 while (++i < last && ((AliVParticle*)a[i])->Pt() > ((AliVParticle*)a[first])->Pt() )
629 while (--j > first && ((AliVParticle*)a[j])->Pt() < ((AliVParticle*)a[first])->Pt() )
645 if (j - first < last - (j + 1)) {
646 QSortTracks(a, first, j);
647 first = j + 1; // QSortTracks(j + 1, last);
649 QSortTracks(a, j + 1, last);
650 last = j; // QSortTracks(first, j);
655 //____________________________________________________________________
656 TObjArray* AliAnalyseLeadingTrackUE::SortRegions(const AliVParticle* leading, TObject* obj, TObject* arrayMC, Bool_t onlyprimaries)
659 // Assign particles to towards, away or transverse regions.
660 // Returns a lists of particles for each region.
662 static const Double_t k60rad = 60.*TMath::Pi()/180.;
663 static const Double_t k120rad = 120.*TMath::Pi()/180.;
665 // Define output lists of particles
666 TList *toward = new TList();
667 TList *away = new TList();
668 // Two transverse regions, for the moment those are not yet MIN and MAX!!!
669 // MIN and MAX can be sorted in GetMinMaxRegion function
670 TList *transverse1 = new TList();
671 TList *transverse2 = new TList();
673 TObjArray *regionParticles = new TObjArray;
674 regionParticles->SetOwner(kTRUE);
676 regionParticles->AddLast(toward);
677 regionParticles->AddLast(away);
678 regionParticles->AddLast(transverse1);
679 regionParticles->AddLast(transverse2);
682 return regionParticles;
684 // Switch to vector for leading particle
685 TVector3 leadVect(leading->Px(),leading->Py(),leading->Pz());
687 Int_t nTracks = NParticles(obj);
688 if( !nTracks ) return 0;
690 for (Int_t ipart=0; ipart<nTracks; ++ipart) {
691 AliVParticle* part = ParticleWithCuts(obj, ipart);
693 //Switch to vectors for particles
694 TVector3 partVect(part->Px(), part->Py(), part->Pz());
697 if( TMath::Abs(partVect.Eta()) > fTrackEtaCut ) continue;
698 // transverse regions
699 if (leadVect.DeltaPhi(partVect) < -k60rad && leadVect.DeltaPhi(partVect) > -k120rad )region = -1; //left
700 if (leadVect.DeltaPhi(partVect) > k60rad && leadVect.DeltaPhi(partVect) < k120rad ) region = 1; //right
702 if (TMath::Abs(leadVect.DeltaPhi(partVect)) < k60rad ) region = 2; //forward
703 if (TMath::Abs(leadVect.DeltaPhi(partVect)) > k120rad ) region = -2; //backward
705 // skip leading particle
709 if (!region)continue;
710 if (arrayMC && arrayMC->InheritsFrom("TClonesArray") && obj->InheritsFrom("AliAODEvent")){
711 Int_t label = ((AliAODTrack*)part)->GetLabel();
712 // re-define part as the matched MC particle
713 part = (AliAODMCParticle*)ParticleWithCuts(arrayMC, TMath::Abs(label),onlyprimaries);
715 // skip leading particle
719 if (arrayMC && arrayMC->InheritsFrom("AliMCEvent") && obj->InheritsFrom("AliESDEvent")){
720 Int_t label = ((AliESDtrack*)part)->GetLabel();
721 // look for the matched MC particle (but do not re-define part)
722 if (!ParticleWithCuts(arrayMC, TMath::Abs(label),onlyprimaries)) continue;
725 if ( region == 1 ) transverse1->Add(part);
726 if ( region == -1 ) transverse2->Add(part);
727 if ( region == 2 ) toward->Add(part);
728 if ( region == -2 ) away->Add(part);
730 }//end loop on tracks
732 return regionParticles;
737 //____________________________________________________________________
738 Bool_t AliAnalyseLeadingTrackUE::TriggerSelection(const TObject* obj)
743 // Use AliPhysicsSelection to select good events, works for ESD and AOD
744 if (!(((AliInputEventHandler*)obj)->IsEventSelected()&(fEventSelection)))
750 //____________________________________________________________________
751 Bool_t AliAnalyseLeadingTrackUE::VertexSelection(const TObject* obj, Int_t ntracks, Double_t zed)
754 //Require 1 vertex (no TPC stand-alone) with a minimum number of tracks and z-coordinate in a limited range
756 if (obj->InheritsFrom("AliAODEvent")){
757 Int_t nVertex = ((AliAODEvent*)obj)->GetNumberOfVertices();
759 AliAODVertex* vertex = (AliAODVertex*)((AliAODEvent*)obj)->GetPrimaryVertex();
760 Int_t nTracksPrim = vertex->GetNContributors();
761 Double_t zVertex = vertex->GetZ();
762 if (fDebug > 1)AliInfo(Form(" Vertex in = %f with %d particles by %s data ...",zVertex,nTracksPrim,vertex->GetName()));
763 // Reject TPC only vertex
764 TString name(vertex->GetName());
765 if (name.CompareTo("PrimaryVertex") && name.CompareTo("SPDVertex"))return kFALSE;
767 // Select a quality vertex by number of tracks?
768 if( nTracksPrim < ntracks || TMath::Abs(zVertex) > zed ) {
769 if (fDebug > 1) AliInfo(" Primary-vertex Selection: event REJECTED ...");
772 // TODO remove vertexer Z events with dispersion > 0.02: Doesn't work for AOD at present
773 //if (strcmp(vertex->GetTitle(), "AliVertexerZ") == 0 && vertex->GetDispersion() > 0.02)
775 if (fDebug > 1) AliInfo(" Primary-vertex Selection: event ACCEPTED...");
777 if (fDebug > 1) AliInfo(" Primary-vertex Selection: event REJECTED ...");
782 if (obj->InheritsFrom("AliMCEvent"))
784 if (TMath::Abs(((AliMCEvent*) obj)->GetPrimaryVertex()->GetZ()) > zed)
786 if (fDebug > 1) AliInfo(" Primary-vertex Selection: event (based on MC) REJECTED ...");
791 if (obj->InheritsFrom("AliAODMCHeader"))
793 if (TMath::Abs(((AliAODMCHeader*) obj)->GetVtxZ()) > zed)
795 if (fDebug > 1) AliInfo(" Primary-vertex Selection: event (based on MC) REJECTED ...");
800 // ESD case for DCA studies
801 if (obj->InheritsFrom("AliESDEvent")){
802 AliESDVertex* vertex = (AliESDVertex*)((AliESDEvent*)obj)->GetPrimaryVertex();
804 Int_t nTracksPrim = vertex->GetNContributors();
805 Double_t zVertex = vertex->GetZ();
806 if (fDebug > 1)AliInfo(Form(" Vertex in = %f with %d particles by %s data ...",zVertex,nTracksPrim,vertex->GetName()));
807 // Reject SPD or TPC only vertex
808 TString name(vertex->GetName());
809 if (name.CompareTo("PrimaryVertex") && name.CompareTo("SPDVertex"))return kFALSE;
811 // Select a quality vertex by number of tracks?
812 if( nTracksPrim < ntracks || TMath::Abs(zVertex) > zed ) {
813 if (fDebug > 1) AliInfo(" Primary-vertex Selection: event REJECTED ...");
816 // TODO remove vertexer Z events with dispersion > 0.02: Doesn't work for AOD at present
817 //if (strcmp(vertex->GetTitle(), "AliVertexerZ") == 0 && vertex->GetDispersion() > 0.02)
819 if (fDebug > 1) AliInfo(" Primary-vertex Selection: event ACCEPTED...");
821 if (fDebug > 1) AliInfo(" Primary-vertex Selection: event REJECTED ...");