]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWG4/JetTasks/AliAnalyseLeadingTrackUE.cxx
add new time cut, time histograms
[u/mrichter/AliRoot.git] / PWG4 / JetTasks / AliAnalyseLeadingTrackUE.cxx
CommitLineData
a75aacd6 1/*************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: A.Abrahantes, E.Lopez, S.Vallero *
5 * Version 1.0 *
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 **************************************************************************/
a75aacd6 15//#include <TBranch.h>
16//#include <TCanvas.h>
17//#include <TChain.h>
18//#include <TFile.h>
19//#include <TH1F.h>
20//#include <TH1I.h>
21//#include <TH2F.h>
22#include <TList.h>
23//#include <TLorentzVector.h>
24#include <TMath.h>
25#include <TObjArray.h>
26#include <TObject.h>
27//#include <TProfile.h>
28//#include <TRandom.h>
29//#include <TSystem.h>
30//#include <TTree.h>
31#include <TVector3.h>
32
33#include "AliAnalyseLeadingTrackUE.h"
34//#include "AliAnalysisTask.h"
35
36//#include "AliAnalysisHelperJetTasks.h"
37//#include "AliAnalysisManager.h"
38#include "AliAODEvent.h"
39//#include "AliAODHandler.h"
a75aacd6 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"
144bd037 49//#include "AliLog.h"
a75aacd6 50#include "AliMCEvent.h"
a75aacd6 51#include "AliVParticle.h"
52
ea1919ac 53#include "AliAnalysisManager.h"
54#include "AliMCEventHandler.h"
55#include "AliStack.h"
56
57
a75aacd6 58////////////////////////////////////////////////
59//---------------------------------------------
60// Class for transverse regions analysis
61//---------------------------------------------
62////////////////////////////////////////////////
63
64
65using namespace std;
66
67ClassImp(AliAnalyseLeadingTrackUE)
68
69//-------------------------------------------------------------------
70AliAnalyseLeadingTrackUE::AliAnalyseLeadingTrackUE() :
71 TObject(),
72 fDebug(0),
73 fFilterBit(16),
74 fOnlyHadrons(kFALSE),
3712ba26 75 fTrackEtaCut(0.8),
e0331fd9 76 fTrackPtMin(0),
3712ba26 77 fEsdTrackCuts(0x0),
78 fEsdTrackCutsSPD(0x0),
79 fEsdTrackCutsSDD(0x0)
a75aacd6 80{
81 // constructor
82}
83
84
85//-------------------------------------------------------------------
86AliAnalyseLeadingTrackUE & AliAnalyseLeadingTrackUE::operator = (const AliAnalyseLeadingTrackUE & /*source*/)
87{
88 // assignment operator
89 return *this;
90}
91
92
93//-------------------------------------------------------------------
94AliAnalyseLeadingTrackUE::~AliAnalyseLeadingTrackUE()
95{
96
97 //clear memory
98
99}
100
101
102//____________________________________________________________________
3712ba26 103Bool_t AliAnalyseLeadingTrackUE::ApplyCuts(TObject* track)
a75aacd6 104{
a75aacd6 105
106 // select track according to set of cuts
85bfac17 107 if (!fEsdTrackCuts->IsSelected(track) )return kFALSE;
108 if (fEsdTrackCutsSPD && fEsdTrackCutsSDD && !fEsdTrackCutsSPD->IsSelected(track) && fEsdTrackCutsSDD->IsSelected(track)) return kFALSE;
3712ba26 109
a75aacd6 110 return kTRUE;
111}
112
113
3712ba26 114//____________________________________________________________________
115void AliAnalyseLeadingTrackUE::DefineESDCuts(Int_t /*filterbit*/){
116
85bfac17 117 // Reproduces the cuts of the corresponding bit in the ESD->AOD filtering
118 // (see $ALICE_ROOT/ANALYSIS/macros/AddTaskESDFilter.C)
a75aacd6 119
85bfac17 120 if (fFilterBit == 128)
121 {
122 fEsdTrackCuts = AliESDtrackCuts::GetStandardTPCOnlyTrackCuts();
123 fEsdTrackCuts->SetMinNClustersTPC(70);
124 }
125 else
126 {
127 fEsdTrackCuts = AliESDtrackCuts::GetStandardITSTPCTrackCuts2010();
128 fEsdTrackCuts->SetClusterRequirementITS(AliESDtrackCuts::kSPD, AliESDtrackCuts::kNone);
129
130 // Add SPD requirement
131 fEsdTrackCutsSPD = new AliESDtrackCuts("SPD", "Require 1 cluster in SPD");
132 fEsdTrackCutsSPD->SetClusterRequirementITS(AliESDtrackCuts::kSPD,AliESDtrackCuts::kAny);
133
134 // Add SDD requirement
135 fEsdTrackCutsSDD = new AliESDtrackCuts("SDD", "Require 1 cluster in first layer SDD");
136 fEsdTrackCutsSDD->SetClusterRequirementITS(AliESDtrackCuts::kSDD,AliESDtrackCuts::kFirst);
137 }
3712ba26 138}
a75aacd6 139
a75aacd6 140//____________________________________________________________________
141TObjArray* AliAnalyseLeadingTrackUE::FindLeadingObjects(TObject *obj)
142{
143
144 // Returns an array of charged particles (or jets) ordered according to their pT.
145
146 Int_t nTracks = NParticles(obj);
147
148
149 if( !nTracks ) return 0;
150
151 // Define array of AliVParticle objects
152 TObjArray* tracks = new TObjArray(nTracks);
153
154 // Loop over tracks or jets
155 for (Int_t ipart=0; ipart<nTracks; ++ipart) {
156 AliVParticle* part = ParticleWithCuts( obj, ipart );
157 if (!part) continue;
158 // Accept leading-tracks in a limited pseudo-rapidity range
159 if( TMath::Abs(part->Eta()) > fTrackEtaCut ) continue;
160 tracks->AddLast( part );
161 }
162 // Order tracks by pT
163 QSortTracks( *tracks, 0, tracks->GetEntriesFast() );
164
165 nTracks = tracks->GetEntriesFast();
166 if( !nTracks ) return 0;
167
168 return tracks;
169 }
170
171
b1831bcb 172//-------------------------------------------------------------------
e0331fd9 173TObjArray* AliAnalyseLeadingTrackUE::GetAcceptedParticles(TObject* obj, TObject* arrayMC, Bool_t onlyprimaries, Int_t particleSpecies, Bool_t useEtaPtCuts)
b1831bcb 174{
175 // 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
176 // particleSpecies: -1 all particles are returned
177 // 0 (pions) 1 (kaons) 2 (protons) 3 (others) particles
178
179 Int_t nTracks = NParticles(obj);
180 TObjArray* tracks = new TObjArray;
85bfac17 181
182 // for TPC only tracks
183 if (fFilterBit == 128 && obj->InheritsFrom("AliESDEvent"))
184 tracks->SetOwner(kTRUE);
b1831bcb 185
186 // Loop over tracks or jets
187 for (Int_t ipart=0; ipart<nTracks; ++ipart) {
188 AliVParticle* part = ParticleWithCuts( obj, ipart, onlyprimaries, particleSpecies );
189 if (!part) continue;
190
e0331fd9 191 if (useEtaPtCuts)
192 if (TMath::Abs(part->Eta()) > fTrackEtaCut || part->Pt() < fTrackPtMin)
193 continue;
194
b1831bcb 195 if (arrayMC && arrayMC->InheritsFrom("TClonesArray") && obj->InheritsFrom("AliAODEvent")) {
196 Int_t label = ((AliAODTrack*)part)->GetLabel();
197 // re-define part as the matched MC particle
198 part = (AliAODMCParticle*)ParticleWithCuts(arrayMC, TMath::Abs(label),onlyprimaries, particleSpecies);
199 if (!part)continue;
200 }
201
202 tracks->Add(part);
203 }
204
205 return tracks;
206}
207
a75aacd6 208//-------------------------------------------------------------------
209TObjArray* AliAnalyseLeadingTrackUE::GetMinMaxRegion(TList *transv1, TList *transv2)
210{
211
212 // Returns two lists of particles, one for MIN and one for MAX region
213 Double_t sumpT1 = 0.;
214 Double_t sumpT2 = 0.;
215
216 Int_t particles1 = transv1->GetEntries();
217 Int_t particles2 = transv2->GetEntries();
218
219 // Loop on transverse region 1
220 for (Int_t i=0; i<particles1; i++){
221 AliVParticle *part = (AliVParticle*)transv1->At(i);
222 sumpT1 += part->Pt();
223 }
224
225 // Loop on transverse region 2
226 for (Int_t i=0; i<particles2; i++){
227 AliVParticle *part = (AliVParticle*)transv2->At(i);
228 sumpT2 += part->Pt();
229 }
230
231 TObjArray *regionParticles = new TObjArray;
232 if ( sumpT2 >= sumpT1 ){
233 regionParticles->AddLast(transv1); // MIN
234 regionParticles->AddLast(transv2); // MAX
235 }else {
236 regionParticles->AddLast(transv2); // MIN
237 regionParticles->AddLast(transv1); // MAX
238 }
239
240 return regionParticles;
241}
242
243//-------------------------------------------------------------------
244Int_t AliAnalyseLeadingTrackUE::NParticles(TObject* obj)
245{
246
247 //Returns the number of particles in AliAODMCParticle array or AliAODTracks or AliESDTracks
248
249 Int_t nTracks;
250
251 if (obj->InheritsFrom("TClonesArray")){ // MC particles
ea1919ac 252 TClonesArray *arrayMC = static_cast<TClonesArray*>(obj);
a75aacd6 253 nTracks = arrayMC->GetEntriesFast();
254 }else if (obj->InheritsFrom("TObjArray")){ // list of AliVParticle
ea1919ac 255 TObjArray *array = static_cast<TObjArray*>(obj);
a75aacd6 256 nTracks = array->GetEntriesFast();
257 }else if (obj->InheritsFrom("AliAODEvent")){ // RECO AOD tracks
ea1919ac 258 AliAODEvent *aodEvent = static_cast<AliAODEvent*>(obj);
a75aacd6 259 nTracks = aodEvent->GetNTracks();
260 }else if (obj->InheritsFrom("AliESDEvent")){ // RECO ESD tracks
ea1919ac 261 AliESDEvent *esdEvent = static_cast<AliESDEvent*>(obj);
a75aacd6 262 nTracks = esdEvent->GetNumberOfTracks();
3712ba26 263 }else if (obj->InheritsFrom("AliMCEvent")){ // RECO ESD tracks
ea1919ac 264 AliMCEvent *mcEvent = static_cast<AliMCEvent*>(obj);
3712ba26 265 nTracks = mcEvent->GetNumberOfTracks();
a75aacd6 266 }else {
267 if (fDebug > 1) AliFatal(" Analysis type not defined !!! ");
268 return 0;
269 }
270
271 return nTracks;
272}
273
274
275//-------------------------------------------------------------------
b1831bcb 276AliVParticle* AliAnalyseLeadingTrackUE::ParticleWithCuts(TObject* obj, Int_t ipart, Bool_t onlyprimaries, Int_t particleSpecies)
a75aacd6 277{
278 // Returns track or MC particle at position "ipart" if passes selection criteria
b1831bcb 279 // particleSpecies: -1 all particles are returned
280 // 0 (pions) 1 (kaons) 2 (protons) 3 (others) particles
a75aacd6 281 AliVParticle *part=0;
282
283 if (obj->InheritsFrom("TClonesArray")){ // AOD-MC PARTICLE
ea1919ac 284 TClonesArray *arrayMC = static_cast<TClonesArray*>(obj);
a75aacd6 285 part = (AliVParticle*)arrayMC->At( ipart );
286 if (!part)return 0;
287 // eventually only primaries
288 if (onlyprimaries && !( ((AliAODMCParticle*)part)->IsPhysicalPrimary()) )return 0;
289 // eventually only hadrons
290 if (fOnlyHadrons){
291 Int_t pdgCode = ((AliAODMCParticle*)part)->GetPdgCode();
292 Bool_t isHadron = TMath::Abs(pdgCode)==211 || // Pion
293 TMath::Abs(pdgCode)==2212 || // Proton
294 TMath::Abs(pdgCode)==321; // Kaon
295 if (!isHadron) return 0;
296 }
b1831bcb 297 if (particleSpecies != -1) {
298 // find the primary mother
299 AliVParticle* mother = part;
300 while (!((AliAODMCParticle*)mother)->IsPhysicalPrimary())
301 {
302 if (((AliAODMCParticle*)mother)->GetMother() < 0)
303 {
304 mother = 0;
305 break;
306 }
307
308 mother = (AliVParticle*) arrayMC->At(((AliAODMCParticle*)mother)->GetMother());
309 if (!mother)
310 break;
311 }
312
313 if (mother)
314 {
315 Int_t pdgCode = ((AliAODMCParticle*)mother)->GetPdgCode();
316 if (particleSpecies == 0 && TMath::Abs(pdgCode)!=211)
317 return 0;
318 if (particleSpecies == 1 && TMath::Abs(pdgCode)!=321)
319 return 0;
320 if (particleSpecies == 2 && TMath::Abs(pdgCode)!=2212)
321 return 0;
322 if (particleSpecies == 3 && (TMath::Abs(pdgCode)==211 || TMath::Abs(pdgCode)==321 || TMath::Abs(pdgCode)==2212))
323 return 0;
324 }
1c6b6c97 325 else
326 {
327 // if mother not found, accept particle only in case of particleSpecies == 3. To include it in all or no sample is no solution
ea1919ac 328 Printf("WARNING: No mother found for particle %d:", part->GetLabel());
329 part->Print();
330
331 /*
332 // this code prints the details of the mother that is missing in the AOD
333 AliMCEventHandler* fMcHandler = dynamic_cast<AliMCEventHandler*> (AliAnalysisManager::GetAnalysisManager()->GetMCtruthEventHandler());
334
335 AliMCEvent* fMcEvent = fMcHandler->MCEvent();
336
337 fMcEvent->Stack()->Particle(fMcEvent->Stack()->Particle(part->GetLabel())->GetMother(0))->Print();
338 fMcEvent->Stack()->Particle(fMcEvent->Stack()->Particle(fMcEvent->Stack()->Particle(part->GetLabel())->GetMother(0))->GetMother(0))->Print();
339 Printf("eta = %f", fMcEvent->Stack()->Particle(fMcEvent->Stack()->Particle(fMcEvent->Stack()->Particle(part->GetLabel())->GetMother(0))->GetMother(0))->Eta());
340 */
341
1c6b6c97 342 if (particleSpecies != 3)
343 return 0;
344 }
b1831bcb 345 }
a75aacd6 346
347 }else if (obj->InheritsFrom("TObjArray")){ // list of AliVParticle
ea1919ac 348 TObjArray *array = static_cast<TObjArray*>(obj);
a75aacd6 349 part = (AliVParticle*)array->At( ipart );
350 if (!part)return 0;
351 }else if (obj->InheritsFrom("AliMCEvent")){ // MC PARTICLE
ea1919ac 352 AliMCEvent* mcEvent = static_cast<AliMCEvent*>(obj);
a75aacd6 353 part = mcEvent->GetTrack( ipart );
354 if (!part) return 0;
355 // eventually only primaries
356 if (onlyprimaries && !( mcEvent->IsPhysicalPrimary(ipart)) )return 0;
357 // eventually only hadrons
358 //TO-DO
359 /*if (fOnlyHadrons){
360 Int_t pdgCode = part->GetPdgCode();
361 Bool_t isHadron = TMath::Abs(pdgCode)==211 || // Pion
362 TMath::Abs(pdgCode)==2212 || // Proton
363 TMath::Abs(pdgCode)==321; // Kaon
364 if (!isHadron) return 0;
365 }
366 */
367
368 }else if (obj->InheritsFrom("AliAODEvent")){ // RECO AOD TRACKS
ea1919ac 369 AliAODEvent *aodEvent = static_cast<AliAODEvent*>(obj);
a75aacd6 370 part = aodEvent->GetTrack(ipart);
371 // track selection cuts
144bd037 372 if ( !(((AliAODTrack*)part)->TestFilterBit(fFilterBit)) ) return 0;
373 //if ( !(((AliAODTrack*)part)->TestFilterBit(fFilterBit)) && !(((AliAODTrack*)part)->TestFilterBit(32)) ) return 0;
a75aacd6 374 // only primary candidates
375 //if ( ((AliAODTrack*)part)->IsPrimaryCandidate() )return 0;
376 // eventually only hadrons
377 if (fOnlyHadrons){
378 Bool_t isHadron = ((AliAODTrack*)part)->GetMostProbablePID()==AliAODTrack::kPion ||
379 ((AliAODTrack*)part)->GetMostProbablePID()==AliAODTrack::kKaon ||
380 ((AliAODTrack*)part)->GetMostProbablePID()==AliAODTrack::kProton;
381 if (!isHadron) return 0;
382 }
383
384 }else if (obj->InheritsFrom("AliESDEvent")){ // RECO ESD TRACKS
ea1919ac 385 AliESDEvent *esdEvent = static_cast<AliESDEvent*>(obj);
a75aacd6 386 part = esdEvent->GetTrack(ipart);
387 if (!part)return 0;
388 // track selection cuts
e0331fd9 389
390 if (!( ApplyCuts(part)) )
391 return 0;
a75aacd6 392
85bfac17 393 if (fFilterBit == 128)
394 {
395 // create TPC only tracks constrained to the SPD vertex
396
397 const AliESDVertex *vtxSPD = esdEvent->GetPrimaryVertexSPD();
398
399 AliESDtrack* track = AliESDtrackCuts::GetTPCOnlyTrack(esdEvent, ipart);
400 if(!track) return 0;
401
402 // laser warm up tracks
403 if (track->GetTPCsignal() < 10.)
c32a0ca9 404 {
405 delete track;
85bfac17 406 return 0;
c32a0ca9 407 }
85bfac17 408
409 if(track->Pt()>0.){
410 // only constrain tracks above threshold
411 AliExternalTrackParam exParam;
412 // take the B-feild from the ESD, no 3D fieldMap available at this point
413 Bool_t relate = kFALSE;
414 relate = track->RelateToVertex(vtxSPD,esdEvent->GetMagneticField(),kVeryBig,&exParam);
415 if(!relate)
416 {
417// Printf("relating failed");
418 delete track;
419 return 0;
420 }
421 track->Set(exParam.GetX(),exParam.GetAlpha(),exParam.GetParameter(),exParam.GetCovariance());
422 }
423
424 part = track;
425 }
a75aacd6 426
427 // eventually only hadrons
428 //TO-DO
429 /*if (fOnlyHadrons){
430 Bool_t isHadron = ((AliAODTrack*)part)->GetMostProbablePID()==AliAODTrack::kPion ||
431 ((AliAODTrack*)part)->GetMostProbablePID()==AliAODTrack::kKaon ||
432 ((AliAODTrack*)part)->GetMostProbablePID()==AliAODTrack::kProton;
433 if (!isHadron) return 0;
434 }
435 */
436 }else {
437 if (fDebug > 1) AliFatal(" Analysis type not defined !!! ");
438 return 0;
439 }
440
441 // only charged
442 if (!part->Charge())return 0;
443
444 return part;
445}
446
447
448//-------------------------------------------------------------------
449void AliAnalyseLeadingTrackUE::QSortTracks(TObjArray &a, Int_t first, Int_t last)
450{
451 // Sort array of TObjArray of tracks by Pt using a quicksort algorithm.
452
453 static TObject *tmp;
454 static int i; // "static" to save stack space
455 int j;
456
457 while (last - first > 1) {
458 i = first;
459 j = last;
460 for (;;) {
461 while (++i < last && ((AliVParticle*)a[i])->Pt() > ((AliVParticle*)a[first])->Pt() )
462 ;
463 while (--j > first && ((AliVParticle*)a[j])->Pt() < ((AliVParticle*)a[first])->Pt() )
464 ;
465 if (i >= j)
466 break;
467
468 tmp = a[i];
469 a[i] = a[j];
470 a[j] = tmp;
471 }
472 if (j == first) {
473 ++first;
474 continue;
475 }
476 tmp = a[first];
477 a[first] = a[j];
478 a[j] = tmp;
479 if (j - first < last - (j + 1)) {
480 QSortTracks(a, first, j);
481 first = j + 1; // QSortTracks(j + 1, last);
482 } else {
483 QSortTracks(a, j + 1, last);
484 last = j; // QSortTracks(first, j);
485 }
486 }
487}
488
489//____________________________________________________________________
490TObjArray* AliAnalyseLeadingTrackUE::SortRegions(const AliVParticle* leading, TObject* obj, TObject* arrayMC, Bool_t onlyprimaries)
491{
492
493 // Assign particles to towards, away or transverse regions.
494 // Returns a lists of particles for each region.
495
496 static const Double_t k60rad = 60.*TMath::Pi()/180.;
497 static const Double_t k120rad = 120.*TMath::Pi()/180.;
498
499 // Define output lists of particles
500 TList *toward = new TList();
501 TList *away = new TList();
502 // Two transverse regions, for the moment those are not yet MIN and MAX!!!
503 // MIN and MAX can be sorted in GetMinMaxRegion function
504 TList *transverse1 = new TList();
505 TList *transverse2 = new TList();
506
507 TObjArray *regionParticles = new TObjArray;
05c47aff 508 regionParticles->SetOwner(kTRUE);
509
a75aacd6 510 regionParticles->AddLast(toward);
511 regionParticles->AddLast(away);
512 regionParticles->AddLast(transverse1);
513 regionParticles->AddLast(transverse2);
514
515 if (!leading)
516 return regionParticles;
517
518 // Switch to vector for leading particle
519 TVector3 leadVect(leading->Px(),leading->Py(),leading->Pz());
520
521 Int_t nTracks = NParticles(obj);
522 if( !nTracks ) return 0;
523 // Loop over tracks
524 for (Int_t ipart=0; ipart<nTracks; ++ipart) {
525 AliVParticle* part = ParticleWithCuts(obj, ipart);
526 if (!part)continue;
527 //Switch to vectors for particles
528 TVector3 partVect(part->Px(), part->Py(), part->Pz());
529
530 Int_t region = 0;
531 if( TMath::Abs(partVect.Eta()) > fTrackEtaCut ) continue;
532 // transverse regions
533 if (leadVect.DeltaPhi(partVect) < -k60rad && leadVect.DeltaPhi(partVect) > -k120rad )region = -1; //left
534 if (leadVect.DeltaPhi(partVect) > k60rad && leadVect.DeltaPhi(partVect) < k120rad ) region = 1; //right
535
536 if (TMath::Abs(leadVect.DeltaPhi(partVect)) < k60rad ) region = 2; //forward
537 if (TMath::Abs(leadVect.DeltaPhi(partVect)) > k120rad ) region = -2; //backward
538
539 // skip leading particle
b1831bcb 540 if (leading == part)
a75aacd6 541 continue;
542
543 if (!region)continue;
544 if (arrayMC && arrayMC->InheritsFrom("TClonesArray") && obj->InheritsFrom("AliAODEvent")){
545 Int_t label = ((AliAODTrack*)part)->GetLabel();
546 // re-define part as the matched MC particle
547 part = (AliAODMCParticle*)ParticleWithCuts(arrayMC, TMath::Abs(label),onlyprimaries);
548 if (!part)continue;
549 // skip leading particle
550 if (leading == part)
551 continue;
552 }
553 if (arrayMC && arrayMC->InheritsFrom("AliMCEvent") && obj->InheritsFrom("AliESDEvent")){
554 Int_t label = ((AliESDtrack*)part)->GetLabel();
555 // look for the matched MC particle (but do not re-define part)
556 if (!ParticleWithCuts(arrayMC, TMath::Abs(label),onlyprimaries)) continue;
557 }
558
559 if ( region == 1 ) transverse1->Add(part);
560 if ( region == -1 ) transverse2->Add(part);
561 if ( region == 2 ) toward->Add(part);
562 if ( region == -2 ) away->Add(part);
563
564 }//end loop on tracks
565
566 return regionParticles;
567
568}
569
570
571//____________________________________________________________________
572Bool_t AliAnalyseLeadingTrackUE::TriggerSelection(const TObject* obj)
573{
1c6b6c97 574 if (!obj) // MC
575 return kFALSE;
a75aacd6 576
85bfac17 577 // Use AliPhysicsSelection to select good events, works for ESD and AOD
578 if (!(((AliInputEventHandler*)obj)->IsEventSelected()&(AliVEvent::kMB|AliVEvent::kUserDefined)))
579 return kFALSE;
05c47aff 580
a75aacd6 581 return kTRUE;
a75aacd6 582}
583
584//____________________________________________________________________
585Bool_t AliAnalyseLeadingTrackUE::VertexSelection(const TObject* obj, Int_t ntracks, Double_t zed)
586{
587
588 //Require 1 vertex (no TPC stand-alone) with a minimum number of tracks and z-coordinate in a limited range
589
590 if (obj->InheritsFrom("AliAODEvent")){
591 Int_t nVertex = ((AliAODEvent*)obj)->GetNumberOfVertices();
592 if( nVertex > 0 ) {
593 AliAODVertex* vertex = (AliAODVertex*)((AliAODEvent*)obj)->GetPrimaryVertex();
144bd037 594 Int_t nTracksPrim = vertex->GetNContributors();
a75aacd6 595 Double_t zVertex = vertex->GetZ();
596 if (fDebug > 1)AliInfo(Form(" Vertex in = %f with %d particles by %s data ...",zVertex,nTracksPrim,vertex->GetName()));
144bd037 597 // Reject TPC only vertex
598 TString name(vertex->GetName());
599 if (name.CompareTo("PrimaryVertex") && name.CompareTo("SPDVertex"))return kFALSE;
600
601 // Select a quality vertex by number of tracks?
a75aacd6 602 if( nTracksPrim < ntracks || TMath::Abs(zVertex) > zed ) {
603 if (fDebug > 1) AliInfo(" Primary-vertex Selection: event REJECTED ...");
604 return kFALSE;
605 }
606 // TODO remove vertexer Z events with dispersion > 0.02: Doesn't work for AOD at present
607 //if (strcmp(vertex->GetTitle(), "AliVertexerZ") == 0 && vertex->GetDispersion() > 0.02)
608 // return kFALSE;
609 if (fDebug > 1) AliInfo(" Primary-vertex Selection: event ACCEPTED...");
610 } else {
611 if (fDebug > 1) AliInfo(" Primary-vertex Selection: event REJECTED ...");
612 return kFALSE;
613 }
614 }
615
616 if (obj->InheritsFrom("AliMCEvent"))
617 {
618 if (TMath::Abs(((AliMCEvent*) obj)->GetPrimaryVertex()->GetZ()) > zed)
619 {
620 if (fDebug > 1) AliInfo(" Primary-vertex Selection: event (based on MC) REJECTED ...");
621 return kFALSE;
622 }
623 }
144bd037 624
625 // ESD case for DCA studies
626 if (obj->InheritsFrom("AliESDEvent")){
627 AliESDVertex* vertex = (AliESDVertex*)((AliESDEvent*)obj)->GetPrimaryVertex();
628 if ( vertex){
629 Int_t nTracksPrim = vertex->GetNContributors();
630 Double_t zVertex = vertex->GetZ();
631 if (fDebug > 1)AliInfo(Form(" Vertex in = %f with %d particles by %s data ...",zVertex,nTracksPrim,vertex->GetName()));
632 // Reject SPD or TPC only vertex
633 TString name(vertex->GetName());
634 if (name.CompareTo("PrimaryVertex") && name.CompareTo("SPDVertex"))return kFALSE;
635
636 // Select a quality vertex by number of tracks?
637 if( nTracksPrim < ntracks || TMath::Abs(zVertex) > zed ) {
638 if (fDebug > 1) AliInfo(" Primary-vertex Selection: event REJECTED ...");
639 return kFALSE;
640 }
641 // TODO remove vertexer Z events with dispersion > 0.02: Doesn't work for AOD at present
642 //if (strcmp(vertex->GetTitle(), "AliVertexerZ") == 0 && vertex->GetDispersion() > 0.02)
643 // return kFALSE;
644 if (fDebug > 1) AliInfo(" Primary-vertex Selection: event ACCEPTED...");
645 } else {
646 if (fDebug > 1) AliInfo(" Primary-vertex Selection: event REJECTED ...");
647 return kFALSE;
648 }
649 }
a75aacd6 650
651 return kTRUE;
652}