1 /**************************************************************************
2 * Copyright(c) 1998-2008, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
16 //*****************************************************
17 // Class AliEPSelectionTask
18 // Class to determine event plane
19 // author: Alberica Toia, Johanna Gramling
20 //*****************************************************
22 #include "AliEPSelectionTask.h"
28 #include <THnSparse.h>
31 #include <TObjString.h>
35 #include <TDirectory.h>
41 #include "AliAnalysisManager.h"
42 #include "AliVEvent.h"
44 #include "AliESDEvent.h"
45 #include "AliMCEvent.h"
46 #include "AliESDtrack.h"
47 #include "AliESDtrackCuts.h"
48 #include "AliESDHeader.h"
49 #include "AliESDInputHandler.h"
50 #include "AliAODHandler.h"
51 #include "AliAODEvent.h"
52 #include "AliHeader.h"
53 #include "AliGenHijingEventHeader.h"
54 #include "AliAnalysisTaskSE.h"
55 #include "AliPhysicsSelectionTask.h"
56 #include "AliPhysicsSelection.h"
57 #include "AliBackgroundSelection.h"
58 #include "AliESDUtils.h"
59 #include "AliOADBContainer.h"
60 #include "AliAODMCHeader.h"
61 #include "AliAODTrack.h"
62 #include "AliVTrack.h"
63 #include "AliEventplane.h"
65 ClassImp(AliEPSelectionTask)
67 //________________________________________________________________________
68 AliEPSelectionTask::AliEPSelectionTask():
70 fAnalysisInput("ESD"),
74 fUsePhiWeight(kFALSE),
76 fSaveTrackContribution(kFALSE),
104 // Default constructor
105 AliInfo("Event Plane Selection enabled.");
106 for(Int_t i = 0; i < 4; ++i) {
111 //________________________________________________________________________
112 AliEPSelectionTask::AliEPSelectionTask(const char *name):
113 AliAnalysisTaskSE(name),
114 fAnalysisInput("ESD"),
118 fUsePhiWeight(kFALSE),
119 fUsePtWeight(kFALSE),
120 fSaveTrackContribution(kFALSE),
121 fUserphidist(kFALSE),
148 // Default constructor
149 AliInfo("Event Plane Selection enabled.");
150 DefineOutput(1, TList::Class());
151 for(Int_t i = 0; i < 4; i++) {
156 //________________________________________________________________________
157 AliEPSelectionTask::~AliEPSelectionTask()
160 if (fOutputList && !AliAnalysisManager::GetAnalysisManager()->IsProofMode()){
165 delete fESDtrackCuts;
178 if (fPeriod.CompareTo("LHC11h")==0){
179 for(Int_t i = 0; i < 4; i++) {
185 if(fHruns) delete fHruns;
189 //________________________________________________________________________
190 void AliEPSelectionTask::UserCreateOutputObjects()
192 // Create the output containers
193 if (fDebug>1) printf("AliEPSelectionTask::UserCreateOutputObjects() \n");
194 AliLog::SetClassDebugLevel("AliEPSelectionTask", AliLog::kInfo);
196 fOutputList = new TList();
197 fOutputList->SetOwner();
198 fHOutEventplaneQ = new TH1F("fHOutEventplaneQ","fHOutEventplaneQ; Event Plane Q",100,0,TMath::Pi());
199 fHOutPhi = new TH1F("fHOutPhi","fHOutPhi; Phi Distribution",100,0,TMath::TwoPi());
200 fHOutPhiCorr = new TH1F("fHOutPhiCorr","fHOutPhiCorr; Corrected Phi Distribution",100,0,TMath::TwoPi());
201 fHOutsub1sub2 = new TH2F("fHOutsub1sub2","fHOutsub1sub2; EP1; EP2",100,0,TMath::Pi(),100,0,TMath::Pi());
202 fHOutNTEPRes = new TH2F("fHOutNTEPRes","fHOutNTEPRes; Number of Tracks; Event Plane Resolution",100,0,5000,100,-TMath::Pi(),TMath::Pi());
203 fHOutPTPsi = new TH2F("fHOutPTPsi","fHOutPTPsi; PT; Phi-EP",100,0,20,100,0,TMath::Pi());
204 fHOutDiff = new TH2F("fHOutDiff","fHOutDiff; EP; MCEP",100,0,TMath::Pi(),100,0,TMath::Pi());
205 fHOutleadPTPsi = new TH2F("fHOutleadPTPsi","fHOutleadPTPsi; leadPT; EP",100,0,TMath::Pi(),100,0,TMath::Pi());
207 fOutputList->Add(fHOutEventplaneQ);
208 fOutputList->Add(fHOutPhi);
209 fOutputList->Add(fHOutPhiCorr);
210 fOutputList->Add(fHOutsub1sub2);
211 fOutputList->Add(fHOutNTEPRes);
212 fOutputList->Add(fHOutPTPsi);
213 fOutputList->Add(fHOutleadPTPsi);
214 fOutputList->Add(fHOutDiff);
216 PostData(1, fOutputList);
221 //________________________________________________________________________
222 void AliEPSelectionTask::UserExec(Option_t */*option*/)
224 // Execute analysis for current event:
225 if (fDebug>1) printf(" **** AliEPSelectionTask::UserExec() \n");
229 AliEventplane *esdEP;
232 Double_t fRP = 0.; // monte carlo reaction plane angle
234 if (fAnalysisInput.CompareTo("ESD")==0){
236 AliVEvent* event = InputEvent();
237 AliESDEvent* esd = dynamic_cast<AliESDEvent*>(event);
239 if (!(fRunNumber == esd->GetRunNumber())) {
240 fRunNumber = esd->GetRunNumber();
241 AliInfo(Form("Changing Phi-distribution to run %d",fRunNumber));
248 AliMCEvent* mcEvent = MCEvent();
249 if (mcEvent && mcEvent->GenEventHeader()) {
250 AliGenHijingEventHeader* headerH = dynamic_cast<AliGenHijingEventHeader*>(mcEvent->GenEventHeader());
251 if (headerH) fRP = headerH->ReactionPlaneAngle();
255 esdEP = esd->GetEventplane();
256 if (fSaveTrackContribution) {
257 esdEP->GetQContributionXArray()->Set(esd->GetNumberOfTracks());
258 esdEP->GetQContributionYArray()->Set(esd->GetNumberOfTracks());
259 esdEP->GetQContributionXArraysub1()->Set(esd->GetNumberOfTracks());
260 esdEP->GetQContributionYArraysub1()->Set(esd->GetNumberOfTracks());
261 esdEP->GetQContributionXArraysub2()->Set(esd->GetNumberOfTracks());
262 esdEP->GetQContributionYArraysub2()->Set(esd->GetNumberOfTracks());
265 TObjArray* tracklist = new TObjArray;
266 if (fTrackType.CompareTo("GLOBAL")==0) tracklist = fESDtrackCuts->GetAcceptedTracks(esd,kFALSE);
267 if (fTrackType.CompareTo("TPC")==0 && fPeriod.CompareTo("LHC10h")==0) tracklist = fESDtrackCuts->GetAcceptedTracks(esd,kTRUE);
268 else if (fTrackType.CompareTo("TPC")==0 && fPeriod.CompareTo("LHC11h")==0) tracklist = GetTracksForLHC11h(esd);
269 const int nt = tracklist->GetEntries();
272 fQVector = new TVector2(GetQ(esdEP,tracklist));
273 fEventplaneQ = fQVector->Phi()/2;
274 GetQsub(qq1, qq2, tracklist, esdEP);
275 fQsub1 = new TVector2(qq1);
276 fQsub2 = new TVector2(qq2);
277 fQsubRes = (fQsub1->Phi()/2 - fQsub2->Phi()/2);
279 esdEP->SetQVector(fQVector);
280 esdEP->SetEventplaneQ(fEventplaneQ);
281 esdEP->SetQsub(fQsub1,fQsub2);
282 esdEP->SetQsubRes(fQsubRes);
284 fHOutEventplaneQ->Fill(fEventplaneQ);
285 fHOutsub1sub2->Fill(fQsub1->Phi()/2,fQsub2->Phi()/2);
286 fHOutNTEPRes->Fill(nt,fQsubRes);
288 if (fUseMCRP) fHOutDiff->Fill(fEventplaneQ, fRP);
290 for (int iter = 0; iter<nt;iter++){
291 AliESDtrack* track = dynamic_cast<AliESDtrack*> (tracklist->At(iter));
293 float delta = track->Phi()-fEventplaneQ;
294 while (delta < 0) delta += TMath::Pi();
295 while (delta > TMath::Pi()) delta -= TMath::Pi();
296 fHOutPTPsi->Fill(track->Pt(),delta);
297 fHOutPhi->Fill(track->Phi());
298 fHOutPhiCorr->Fill(track->Phi(),GetPhiWeight(track));
302 AliESDtrack* trmax = esd->GetTrack(0);
303 for (int iter = 1; iter<nt;iter++){
304 AliESDtrack* track = dynamic_cast<AliESDtrack*> (tracklist->At(iter));
305 if (track && (track->Pt() > trmax->Pt())) trmax = track;
307 fHOutleadPTPsi->Fill(trmax->Phi(),fEventplaneQ);
315 else if (fAnalysisInput.CompareTo("AOD")==0){
316 AliVEvent* event = InputEvent();
317 AliAODEvent* aod = dynamic_cast<AliAODEvent*>(event);
320 if (!(fRunNumber == aod->GetRunNumber())) {
321 fRunNumber = aod->GetRunNumber();
322 AliInfo(Form("Changing Phi-distribution to run %d",fRunNumber));
328 AliAODMCHeader *headerH = dynamic_cast<AliAODMCHeader*>(aod->GetList()->FindObject(AliAODMCHeader::StdBranchName()));
329 if (headerH) fRP = headerH->GetReactionPlaneAngle();
332 esdEP = aod->GetHeader()->GetEventplaneP();
336 TObjArray* tracklist = GetAODTracksAndMaxID(aod,maxID);
338 if (fSaveTrackContribution) {
339 esdEP->GetQContributionXArray()->Set(maxID+1);
340 esdEP->GetQContributionYArray()->Set(maxID+1);
341 esdEP->GetQContributionXArraysub1()->Set(maxID+1);
342 esdEP->GetQContributionYArraysub1()->Set(maxID+1);
343 esdEP->GetQContributionXArraysub2()->Set(maxID+1);
344 esdEP->GetQContributionYArraysub2()->Set(maxID+1);
347 const int NT = tracklist->GetEntries();
350 fQVector = new TVector2(GetQ(esdEP,tracklist));
351 fEventplaneQ = fQVector->Phi()/2.;
352 GetQsub(qq1, qq2, tracklist, esdEP);
353 fQsub1 = new TVector2(qq1);
354 fQsub2 = new TVector2(qq2);
355 fQsubRes = (fQsub1->Phi()/2. - fQsub2->Phi()/2.);
357 esdEP->SetQVector(fQVector);
358 esdEP->SetEventplaneQ(fEventplaneQ);
359 esdEP->SetQsub(fQsub1,fQsub2);
360 esdEP->SetQsubRes(fQsubRes);
362 fHOutEventplaneQ->Fill(fEventplaneQ);
363 fHOutsub1sub2->Fill(fQsub1->Phi()/2.,fQsub2->Phi()/2.);
364 fHOutNTEPRes->Fill(NT,fQsubRes);
366 if (fUseMCRP) fHOutDiff->Fill(fEventplaneQ, fRP);
368 for (int iter = 0; iter<NT;iter++){
369 AliAODTrack* track = dynamic_cast<AliAODTrack*> (tracklist->At(iter));
371 float delta = track->Phi()-fEventplaneQ;
372 while (delta < 0) delta += TMath::Pi();
373 while (delta > TMath::Pi()) delta -= TMath::Pi();
374 fHOutPTPsi->Fill(track->Pt(),delta);
375 fHOutPhi->Fill(track->Phi());
376 fHOutPhiCorr->Fill(track->Phi(),GetPhiWeight(track));
380 AliAODTrack* trmax = aod->GetTrack(0);
381 for (int iter = 1; iter<NT;iter++){
382 AliAODTrack* track = dynamic_cast<AliAODTrack*> (tracklist->At(iter));
383 if (track && (track->Pt() > trmax->Pt())) trmax = track;
385 fHOutleadPTPsi->Fill(trmax->Phi(),fEventplaneQ);
396 printf(" Analysis Input not known!\n\n ");
399 PostData(1, fOutputList);
402 //________________________________________________________________________
403 void AliEPSelectionTask::Terminate(Option_t */*option*/)
405 // Terminate analysis
408 //__________________________________________________________________________
409 TVector2 AliEPSelectionTask::GetQ(AliEventplane* EP, TObjArray* tracklist)
418 int nt = tracklist->GetEntries();
420 for (int i=0; i<nt; i++){
422 track = dynamic_cast<AliVTrack*> (tracklist->At(i));
424 weight = GetWeight(track);
425 if (fSaveTrackContribution){
426 idtemp = track->GetID();
427 if ((fAnalysisInput.CompareTo("AOD")==0) && (fAODfilterbit == 128)) idtemp = idtemp*(-1) - 1;
428 EP->GetQContributionXArray()->AddAt(weight*cos(2*track->Phi()),idtemp);
429 EP->GetQContributionYArray()->AddAt(weight*sin(2*track->Phi()),idtemp);
431 mQx += (weight*cos(2*track->Phi()));
432 mQy += (weight*sin(2*track->Phi()));
439 //________________________________________________________________________
440 void AliEPSelectionTask::GetQsub(TVector2 &Q1, TVector2 &Q2, TObjArray* tracklist,AliEventplane* EP)
444 float mQx1=0, mQy1=0, mQx2=0, mQy2=0;
450 int nt = tracklist->GetEntries();
451 int trackcounter1=0, trackcounter2=0;
454 if (fSplitMethod == AliEPSelectionTask::kRandom){
456 for (Int_t i = 0; i < nt; i++) {
458 track = dynamic_cast<AliVTrack*> (tracklist->At(i));
459 if (!track) continue;
460 weight = GetWeight(track);
461 idtemp = track->GetID();
462 if ((fAnalysisInput.CompareTo("AOD")==0) && (fAODfilterbit == 128)) idtemp = idtemp*(-1) - 1;
464 // This loop splits the track set into 2 random subsets
465 if( trackcounter1 < int(nt/2.) && trackcounter2 < int(nt/2.)){
466 float random = rn.Rndm();
468 mQx1 += (weight*cos(2*track->Phi()));
469 mQy1 += (weight*sin(2*track->Phi()));
470 if (fSaveTrackContribution){
471 EP->GetQContributionXArraysub1()->AddAt(weight*cos(2*track->Phi()),idtemp);
472 EP->GetQContributionYArraysub1()->AddAt(weight*sin(2*track->Phi()),idtemp);
477 mQx2 += (weight*cos(2*track->Phi()));
478 mQy2 += (weight*sin(2*track->Phi()));
479 if (fSaveTrackContribution){
480 EP->GetQContributionXArraysub2()->AddAt(weight*cos(2*track->Phi()),idtemp);
481 EP->GetQContributionYArraysub2()->AddAt(weight*sin(2*track->Phi()),idtemp);
486 else if( trackcounter1 >= int(nt/2.)){
487 mQx2 += (weight*cos(2*track->Phi()));
488 mQy2 += (weight*sin(2*track->Phi()));
489 if (fSaveTrackContribution){
490 EP->GetQContributionXArraysub2()->AddAt(weight*cos(2*track->Phi()),idtemp);
491 EP->GetQContributionYArraysub2()->AddAt(weight*sin(2*track->Phi()),idtemp);
496 mQx1 += (weight*cos(2*track->Phi()));
497 mQy1 += (weight*sin(2*track->Phi()));
498 if (fSaveTrackContribution){
499 EP->GetQContributionXArraysub1()->AddAt(weight*cos(2*track->Phi()),idtemp);
500 EP->GetQContributionYArraysub1()->AddAt(weight*sin(2*track->Phi()),idtemp);
505 } else if (fSplitMethod == AliEPSelectionTask::kEta) {
507 for (Int_t i = 0; i < nt; i++) {
509 track = dynamic_cast<AliVTrack*> (tracklist->At(i));
510 if (!track) continue;
511 weight = GetWeight(track);
512 Double_t eta = track->Eta();
513 idtemp = track->GetID();
514 if ((fAnalysisInput.CompareTo("AOD")==0) && (fAODfilterbit == 128)) idtemp = idtemp*(-1) - 1;
516 if (eta > fEtaGap/2.) {
517 mQx1 += (weight*cos(2*track->Phi()));
518 mQy1 += (weight*sin(2*track->Phi()));
519 if (fSaveTrackContribution){
520 EP->GetQContributionXArraysub1()->AddAt(weight*cos(2*track->Phi()),idtemp);
521 EP->GetQContributionYArraysub1()->AddAt(weight*sin(2*track->Phi()),idtemp);
523 } else if (eta < -1.*fEtaGap/2.) {
524 mQx2 += (weight*cos(2*track->Phi()));
525 mQy2 += (weight*sin(2*track->Phi()));
526 if (fSaveTrackContribution){
527 EP->GetQContributionXArraysub2()->AddAt(weight*cos(2*track->Phi()),idtemp);
528 EP->GetQContributionYArraysub2()->AddAt(weight*sin(2*track->Phi()),idtemp);
533 printf("plane resolution determination method not available!\n\n ");
537 mQ[0].Set(mQx1,mQy1);
538 mQ[1].Set(mQx2,mQy2);
543 //________________________________________________________________________
544 void AliEPSelectionTask::SetPersonalESDtrackCuts(AliESDtrackCuts* trackcuts){
547 delete fESDtrackCuts;
550 if (fAnalysisInput.CompareTo("AOD")==0){
551 AliInfo("ESD track cuts not possible for AOD analysis; please use SetPersonalAODtrackCuts(); using TPC only track cuts");
557 fESDtrackCuts = trackcuts;
560 //________________________________________________________________________
561 void AliEPSelectionTask::SetPersonalAODtrackCuts(UInt_t filterbit, Float_t etalow, Float_t etaup, Float_t ptlow, Float_t ptup){
564 delete fESDtrackCuts;
567 if (fAnalysisInput.CompareTo("ESD")==0){
568 AliInfo("AOD track cuts not possible for ESD analysis; please use SetPersonalESDtrackCuts(); using TPC only track cuts");
574 fESDtrackCuts = new AliESDtrackCuts();
575 fESDtrackCuts->SetPtRange(ptlow,ptup);
576 fESDtrackCuts->SetEtaRange(etalow,etaup);
577 fAODfilterbit = filterbit;
580 //_____________________________________________________________________________
582 void AliEPSelectionTask::SetTrackType(TString tracktype){
583 fTrackType = tracktype;
585 if (fTrackType.CompareTo("GLOBAL")==0){
586 fESDtrackCuts = AliESDtrackCuts::GetStandardITSTPCTrackCuts2010(kTRUE);
589 if (fTrackType.CompareTo("TPC")==0){
590 fESDtrackCuts = AliESDtrackCuts::GetStandardTPCOnlyTrackCuts();
593 fESDtrackCuts->SetPtRange(0.15,20.);
594 fESDtrackCuts->SetEtaRange(-0.8,0.8);
598 //________________________________________________________________________
599 Double_t AliEPSelectionTask::GetWeight(TObject* track1)
602 AliVTrack* track = dynamic_cast<AliVTrack*>(track1);
603 if (fUsePtWeight && track) {
604 if (track->Pt()<2) ptweight=track->Pt();
607 return ptweight*GetPhiWeight(track);
610 //________________________________________________________________________
611 Double_t AliEPSelectionTask::GetPhiWeight(TObject* track1)
613 Double_t phiweight=1;
614 AliVTrack* track = dynamic_cast<AliVTrack*>(track1);
617 if(track) phiDist = SelectPhiDist(track);
619 if (fUsePhiWeight && phiDist && track) {
620 Double_t nParticles = phiDist->Integral();
621 Double_t nPhibins = phiDist->GetNbinsX();
623 Double_t Phi = track->Phi();
625 while (Phi<0) Phi += TMath::TwoPi();
626 while (Phi>TMath::TwoPi()) Phi -= TMath::TwoPi();
628 Double_t PhiDistValue = phiDist->GetBinContent(1+TMath::FloorNint((track->Phi())*nPhibins/TMath::TwoPi()));
630 if (PhiDistValue > 0) phiweight = nParticles/nPhibins/PhiDistValue;
635 //__________________________________________________________________________
636 void AliEPSelectionTask::SetPhiDist()
638 if(!fUserphidist) { // if it's already set and custom class is required, we use the one provided by the user
640 if (fPeriod.CompareTo("LHC10h")==0)
642 fPhiDist[0] = (TH1F*) fEPContainer->GetObject(fRunNumber, "Default");}
643 else if(fPeriod.CompareTo("LHC11h")==0){
644 Int_t runbin=fHruns->FindBin(fRunNumber);
645 if (fHruns->GetBinContent(runbin) > 1){
646 fSparseDist->GetAxis(0)->SetRange(runbin,runbin);
648 else if(fHruns->GetBinContent(runbin) < 2){
649 fSparseDist->GetAxis(0)->SetRange(1,2901); // not calibrated run, use integrated phi-weights
650 AliInfo("Using integrated Phi-weights for this run");
652 for (Int_t i = 0; i<4 ;i++)
659 fSparseDist->GetAxis(1)->SetRange(1,1); // neg charge
660 fSparseDist->GetAxis(2)->SetRange(1,1);} // neg eta
662 fSparseDist->GetAxis(1)->SetRange(2,2); // pos charge
663 fSparseDist->GetAxis(2)->SetRange(1,1);} // neg eta
665 fSparseDist->GetAxis(1)->SetRange(1,1); // neg charge
666 fSparseDist->GetAxis(2)->SetRange(2,2);} // pos eta
668 fSparseDist->GetAxis(1)->SetRange(2,2); // pos charge
669 fSparseDist->GetAxis(2)->SetRange(2,2);} // pos eta
670 fPhiDist[i] = (TH1F*)fSparseDist->Projection(3); // Projection on Phi
671 fPhiDist[i]->SetName(Form("phidist%d%d",i,fRunNumber));
672 fSparseDist->GetAxis(1)->SetRange(1,2); // reset axes
673 fSparseDist->GetAxis(2)->SetRange(1,2);
675 fSparseDist->GetAxis(0)->SetRange(1,2901);// reset run axis
678 if (!fPhiDist[0]) AliFatal(Form("Cannot find OADB phi distribution for run %d", fRunNumber));
682 AliInfo("Using Custom Phi Distribution");
685 if (fPeriod.CompareTo("LHC10h")==0 || fUserphidist){
692 for (int i=1; i<fPhiDist[0]->GetNbinsX(); i++){
693 if (!((fPhiDist[0]->GetBinContent(i))>0)) {
698 cout << "empty bins - rebinning!" << endl;
699 fPhiDist[0]->Rebin();
706 AliError("After Maximum of rebinning still empty Phi-bins!!!");
711 //__________________________________________________________________________
712 void AliEPSelectionTask::SetPersonalPhiDistribution(const char* infilename, char* listname)
715 fUserphidist = kTRUE;
718 TObject* list = f.Get(listname);
719 fPhiDist[0] = (TH1F*)list->FindObject("fHOutPhi");
720 if (!fPhiDist[0]) AliFatal("Phi Distribution not found!!!");
726 //_________________________________________________________________________
727 TObjArray* AliEPSelectionTask::GetAODTracksAndMaxID(AliAODEvent* aod, Int_t& maxid)
729 TObjArray *acctracks = new TObjArray();
733 Int_t maxidtemp = -1;
738 fESDtrackCuts->GetPtRange(ptlow,ptup);
739 fESDtrackCuts->GetEtaRange(etalow,etaup);
741 for (Int_t i = 0; i < aod->GetNumberOfTracks() ; i++){
742 tr = aod->GetTrack(i);
743 maxidtemp = tr->GetID();
744 if(maxidtemp < 0 && fAODfilterbit != 128) continue;
745 if(maxidtemp > -1 && fAODfilterbit == 128) continue;
746 if (fAODfilterbit == 128) maxidtemp = maxidtemp*(-1) - 1;
747 if (maxidtemp > maxid1) maxid1 = maxidtemp;
748 if(tr->TestFilterBit(fAODfilterbit) && tr->Pt() < ptup && tr->Pt() > ptlow && tr->Eta() < etaup && tr->Eta() > etalow){
759 //_________________________________________________________________________
760 void AliEPSelectionTask::SetOADBandPeriod()
762 TString oadbfilename;
764 if (fRunNumber >= 136851 && fRunNumber <= 139515) // LHC10h
766 if (!fUserphidist) { // if it's already set and custom class is required, we use the one provided by the user
768 if (fAnalysisInput.CompareTo("AOD")==0){
769 oadbfilename = (Form("%s/COMMON/EVENTPLANE/data/epphidist.aod.root", AliAnalysisManager::GetOADBPath()));
770 } else if (fAnalysisInput.CompareTo("ESD")==0){
771 oadbfilename = (Form("%s/COMMON/EVENTPLANE/data/epphidist.root", AliAnalysisManager::GetOADBPath()));
774 TFile foadb(oadbfilename);
775 if(!foadb.IsOpen()) AliFatal(Form("Cannot open OADB file %s", oadbfilename.Data()));
777 AliInfo("Using Standard OADB");
778 fEPContainer = (AliOADBContainer*) foadb.Get("epphidist");
779 if (!fEPContainer) AliFatal("Cannot fetch OADB container for EP selection");
784 if (fRunNumber >= 166529 && fRunNumber <= 170593) // LHC11h
787 // if it's already set and custom class is required, we use the one provided by the user
789 oadbfilename = (Form("%s/COMMON/EVENTPLANE/data/epphidist2011.root", AliAnalysisManager::GetOADBPath()));
790 TFile *foadb = TFile::Open(oadbfilename);
791 if(!foadb->IsOpen()) AliFatal(Form("Cannot open OADB file %s", oadbfilename.Data()));
793 AliInfo("Using Standard OADB");
794 fSparseDist = (THnSparse*) foadb->Get("Default");
795 if (!fSparseDist) AliFatal("Cannot fetch OADB container for EP selection");
798 fHruns = (TH1F*)fSparseDist->Projection(0); //projection on run axis;
799 fHruns->SetName("runsHisto");
805 //_________________________________________________________________________
806 TH1F* AliEPSelectionTask::SelectPhiDist(AliVTrack *track)
808 if (fPeriod.CompareTo("LHC10h")==0 || fUserphidist) return fPhiDist[0];
809 else if(fPeriod.CompareTo("LHC11h")==0)
811 if (track->Charge() < 0)
813 if(track->Eta() < 0.) return fPhiDist[0];
814 else if (track->Eta() > 0.) return fPhiDist[2];
816 else if (track->Charge() > 0)
818 if(track->Eta() < 0.) return fPhiDist[1];
819 else if (track->Eta() > 0.) return fPhiDist[3];
826 TObjArray* AliEPSelectionTask::GetTracksForLHC11h(AliESDEvent* esd)
828 // Need to do this hack beacuse only this type of TPC only tracks in AOD is available and one type of Phi-weights is used
829 TObjArray *acctracks = new TObjArray();
830 acctracks->SetOwner(kTRUE);
832 const AliESDVertex *vtxSPD = esd->GetPrimaryVertexSPD();
838 fESDtrackCuts->GetPtRange(ptlow,ptup);
839 fESDtrackCuts->GetEtaRange(etalow,etaup);
841 Double_t pDCA[3] = { 0. }; // momentum at DCA
842 Double_t rDCA[3] = { 0. }; // position at DCA
843 Float_t dDCA[2] = {0.}; // DCA to the vertex d and z
844 Float_t cDCA[3] = {0.}; // covariance of impact parameters
848 for (Int_t i = 0; i < esd->GetNumberOfTracks() ; i++){
850 AliESDtrack* esdTrack = esd->GetTrack(i); //carefull do not modify it othwise need to work with a copy
853 if (!fESDtrackCuts->AcceptTrack(esdTrack)) continue;
855 // create a tpc only tracl
856 AliESDtrack *track = AliESDtrackCuts::GetTPCOnlyTrack(const_cast<AliESDEvent*>(esd),esdTrack->GetID());
861 // only constrain tracks above threshold
862 AliExternalTrackParam exParam;
863 // take the B-field from the ESD, no 3D fieldMap available at this point
864 Bool_t relate = false;
865 relate = track->RelateToVertexTPC(vtxSPD,esd->GetMagneticField(),kVeryBig,&exParam);
870 // fetch the track parameters at the DCA (unconstraint)
871 if(track->GetTPCInnerParam()){
872 track->GetTPCInnerParam()->GetPxPyPz(pDCA);
873 track->GetTPCInnerParam()->GetXYZ(rDCA);
875 // get the DCA to the vertex:
876 track->GetImpactParametersTPC(dDCA,cDCA);
877 // set the constrained parameters to the track
878 track->Set(exParam.GetX(),exParam.GetAlpha(),exParam.GetParameter(),exParam.GetCovariance());
882 Float_t eta = track->Eta();
883 Float_t pT = track->Pt();
885 if(pT < ptlow || pT > ptup || eta < etalow || eta > etaup){
890 acctracks->Add(track);