]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG4/macros/AddTaskPWG4HighPtSpectra.C
add flag for the number of leading jets excluded for random cones
[u/mrichter/AliRoot.git] / PWG4 / macros / AddTaskPWG4HighPtSpectra.C
1 //DEFINITION OF A FEW CONSTANTS
2 const Float_t phimin = 0.;
3 const Float_t phimax = 2.*TMath::Pi();
4 const Float_t etamin = -0.9;
5 const Float_t etamax = 0.9;
6
7 const Int_t   mintrackrefsTPC = 1;
8 const Int_t   mintrackrefsITS = 1;
9
10 AliPWG4HighPtSpectra* AddTaskPWG4HighPtSpectra(char *prodType = "LHC10e14",Int_t trackType = 0)
11 {
12   // Creates HighPtSpectra analysis task and adds it to the analysis manager.
13   
14   // A. Get the pointer to the existing analysis manager via the static access method.
15   //==============================================================================
16   AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
17   if (!mgr) {
18     Error("AddTaskPWG4HighPtSpectra", "No analysis manager to connect to.");
19     return NULL;
20   }  
21
22   // B. Check the analysis type using the event handlers connected to the analysis
23   //    manager. The availability of MC handler can also be checked here.
24   //==============================================================================
25   if (!mgr->GetInputEventHandler()) {
26     ::Error("AddTaskPWG4HighPtSpectra", "This task requires an input event handler");
27     return NULL;
28   }  
29   TString type = mgr->GetInputEventHandler()->GetDataType(); // can be "ESD" or "AOD"
30   const char *analysisType = "ESD";//"TPC"
31
32   // C. Create the task, add it to manager.
33   //===========================================================================
34  //CONTAINER DEFINITION
35   Info("AliPWG4HighPtSpectra","SETUP CONTAINER");
36   //the sensitive variables, their indices
37   UInt_t ipt   = 0;
38   UInt_t iphi  = 1;
39   UInt_t ieta  = 2;
40
41   //Setting up the container grid... 
42   UInt_t nstep = 6; //Steps/Modes for containers
43   Int_t kStepReconstructed = 0;
44   Int_t kStepReconstructedTPCOnly = 1;
45   Int_t kStepSecondaries = 2;
46   Int_t kStepReconstructedMC = 3;
47   Int_t kStepMCAcceptance = 4;
48   Int_t kStepReconstructedTPCOnlyMC = 5;
49
50   //redefine pt ranges in case of Jet-Jet production
51   Float_t ptBinEdges[2][2];
52   Float_t ptmin =  2.0 ;
53   Float_t ptmax =  50.0 ;
54   Float_t binWidth3 = 5.;
55   if(!strcmp(prodType, "LHC10e14")) { 
56     ptmin =  0.0 ;
57     ptmax =  500.0 ;
58
59     ptBinEdges[0][0] = 100.;
60     ptBinEdges[0][1] = 5.;
61     ptBinEdges[1][0] = 300.;
62     ptBinEdges[1][1] = 10.;
63     binWidth3 = 20.;
64   } else { 
65     ptmin =  2.0 ;
66     ptmax =  50.0 ;
67     
68     ptBinEdges[0][0] = 10.;
69     ptBinEdges[0][1] = 0.5;
70     ptBinEdges[1][0] = 60.;
71     ptBinEdges[1][1] = 2.;
72     binWidth3 = 5.;
73   }
74     
75   const Int_t nvar   = 3; //number of variables on the grid: pt:phi:eta
76   const Int_t nbin11 = (int)((ptBinEdges[0][0]-ptmin)/ptBinEdges[0][1]);
77   const Int_t nbin12 = (int)((ptBinEdges[1][0]-ptBinEdges[0][0])/ptBinEdges[1][1])+nbin11;
78   const Int_t nbin13 = (int)((ptmax-ptBinEdges[1][0])/binWidth3)+nbin12;
79   const Int_t nbin1  = nbin13; //bins in pt 
80   const Int_t nbin2  =  18;    //bins in phi
81   const Int_t nbin3  =  2;     //bins in eta
82
83   //arrays for the number of bins in each dimension
84   Int_t iBin[nvar];
85   iBin[0]=nbin1;
86   iBin[1]=nbin2;
87   iBin[2]=nbin3;
88    
89   //arrays for lower bounds :
90   Double_t *binLim1=new Double_t[nbin1+1];
91   Double_t *binLim2=new Double_t[nbin2+1];
92   Double_t *binLim3=new Double_t[nbin3+1];
93   
94   //values for bin lower bounds 
95   for(Int_t i=0; i<=nbin1; i++) {
96     if(i<=nbin11) binLim1[i]=(Double_t)ptmin + (ptBinEdges[0][0]-ptmin)/nbin11*(Double_t)i ;  
97     if(i<=nbin12 && i>nbin11) binLim1[i]=(Double_t)ptBinEdges[0][0] + (ptBinEdges[1][0]-ptBinEdges[0][0])/(nbin12-nbin11)*((Double_t)i-(Double_t)nbin11) ;  
98     if(i<=nbin13 && i>nbin12) binLim1[i]=(Double_t)ptBinEdges[1][0] + (ptmax-ptBinEdges[1][0])/(nbin13-nbin12)*((Double_t)i-(Double_t)nbin12) ;  
99   }
100   for(Int_t i=0; i<=nbin2; i++) binLim2[i]=(Double_t)phimin + (phimax-phimin)/nbin2*(Double_t)i ;
101   for(Int_t i=0; i<=nbin3; i++) binLim3[i]=(Double_t)etamin + (etamax-etamin)/nbin3*(Double_t)i ;  
102   
103
104   AliCFContainer* containerPos = new AliCFContainer("containerPos","container for positive tracks",nstep,nvar,iBin);
105   //setting the bin limits
106   containerPos -> SetBinLimits(ipt,binLim1);
107   containerPos -> SetBinLimits(iphi,binLim2);
108   containerPos -> SetBinLimits(ieta,binLim3);
109
110   AliCFContainer* containerNeg = new AliCFContainer("containerNeg","container for negative tracks",nstep,nvar,iBin);
111   //setting the bin limits
112   containerNeg -> SetBinLimits(ipt,binLim1);
113   containerNeg -> SetBinLimits(iphi,binLim2);
114   containerNeg -> SetBinLimits(ieta,binLim3);
115   
116   //CREATE THE  CUTS -----------------------------------------------
117   //Use AliESDtrackCuts
118   AliESDtrackCuts *trackCuts = new AliESDtrackCuts("AliESDtrackCuts","Standard Cuts");
119   if(trackType==0) {
120     trackCuts = trackCuts->GetStandardITSTPCTrackCuts2010(kTRUE);//Primary Track Quality Selection for Global tracks
121   }
122   else if(trackType==1) {
123     //Cuts global tracks with ITSrefit requirement
124     // TPC  
125     trackCuts->SetMinNClustersTPC(70);
126     trackCuts->SetMaxChi2PerClusterTPC(4);
127     trackCuts->SetAcceptKinkDaughters(kFALSE);
128     trackCuts->SetRequireTPCRefit(kTRUE);
129     // ITS
130     trackCuts->SetRequireITSRefit(kTRUE);
131     
132     trackCuts->SetMaxDCAToVertexXYPtDep("0.0182+0.0350/pt^1.01");
133     trackCuts->SetMaxDCAToVertexZ(2);
134     trackCuts->SetDCAToVertex2D(kFALSE);
135     trackCuts->SetRequireSigmaToVertex(kFALSE);
136   }
137   trackCuts->SetEtaRange(-0.9,0.9);
138   trackCuts->SetPtRange(0.15, 1e10);
139
140   AliESDtrackCuts *trackCutsTPConly = new AliESDtrackCuts("AliESDtrackCuts","Standard Cuts TPC only tracks");
141   trackCutsTPConly = trackCutsTPConly->GetStandardTPCOnlyTrackCuts();//TPC only Track Quality Cuts
142   trackCutsTPConly->SetMinNClustersTPC(70);
143   trackCutsTPConly->SetEtaRange(-0.9,0.9);
144   trackCutsTPConly->SetPtRange(0.15, 1e10);
145
146   // Gen-Level kinematic cuts
147   AliCFTrackKineCuts *mcKineCuts = new AliCFTrackKineCuts("mcKineCuts","MC-level kinematic cuts");
148   mcKineCuts->SetPtRange(0.15,1e10);
149   mcKineCuts->SetRapidityRange(-0.9,0.9);//-0.5,0.5);
150   mcKineCuts->SetRequireIsCharged(kTRUE);
151
152   //Acceptance Cuts
153   AliCFAcceptanceCuts *mcAccCuts = new AliCFAcceptanceCuts("mcAccCuts","MC acceptance cuts");
154   // mcAccCuts->SetMinNHitITS(mintrackrefsITS);
155   mcAccCuts->SetMinNHitTPC(mintrackrefsTPC);
156
157   TObjArray* recList = new TObjArray(0);
158   TObjArray* recTPConlyList = new TObjArray(0);
159   TObjArray* secList = new TObjArray(0) ;
160   TObjArray* recMCList = new TObjArray(0);
161   TObjArray* recTPConlyMCList = new TObjArray(0);
162
163   printf("CREATE MC KINE CUTS\n");
164   TObjArray* mcList = new TObjArray(0) ;
165   mcList->AddLast(mcKineCuts);
166   mcList->AddLast(mcAccCuts);
167
168   //CREATE THE INTERFACE TO CORRECTION FRAMEWORK USED IN THE TASK
169   printf("CREATE INTERFACE AND CUTS\n");
170   AliCFManager* manPos = new AliCFManager("manPos","Manager for Positive tracks") ;
171   manPos->SetParticleContainer(containerPos);
172   manPos->SetParticleCutsList(kStepReconstructed,recList);
173   manPos->SetParticleCutsList(kStepReconstructedTPCOnly,recTPConlyList);
174   manPos->SetParticleCutsList(kStepSecondaries,secList);
175   manPos->SetParticleCutsList(kStepReconstructedMC,recMCList);
176   manPos->SetParticleCutsList(kStepMCAcceptance,mcList);
177   manPos->SetParticleCutsList(kStepReconstructedTPCOnlyMC,recTPConlyMCList);
178
179   AliCFManager* manNeg = new AliCFManager("manNeg","Manager for Negative tracks") ;
180   manNeg->SetParticleContainer(containerNeg);
181   manNeg->SetParticleCutsList(kStepReconstructed,recList);
182   manNeg->SetParticleCutsList(kStepReconstructedTPCOnly,recTPConlyList);
183   manNeg->SetParticleCutsList(kStepSecondaries,secList);
184   manNeg->SetParticleCutsList(kStepReconstructedMC,recMCList);
185   manNeg->SetParticleCutsList(kStepMCAcceptance,mcList);
186   manNeg->SetParticleCutsList(kStepReconstructedTPCOnlyMC,recTPConlyMCList);
187
188
189   printf("Create task AliPWG4HighPtSpectra\n");
190   AliPWG4HighPtSpectra *taskPWG4HighPtSpectra = new AliPWG4HighPtSpectra(Form("AliPWG4HighPtSpectra%d",trackType));
191   taskPWG4HighPtSpectra->SetTrackType(trackType);
192   taskPWG4HighPtSpectra->SetCuts(trackCuts);
193   taskPWG4HighPtSpectra->SetCutsTPConly(trackCutsTPConly);
194   taskPWG4HighPtSpectra->SetCFManagerPos(manPos); //here is set the CF manager +
195   taskPWG4HighPtSpectra->SetCFManagerNeg(manNeg); //here is set the CF manager -
196
197
198   // E. Create ONLY the output containers for the data produced by the task.
199   // Get and connect other common input/output containers via the manager as below
200   //==============================================================================
201
202   //------ output containers ------
203   TString outputfile = AliAnalysisManager::GetCommonFileName();
204   outputfile += Form(":PWG4_HighPtSpectra%d",trackType);
205
206   AliAnalysisDataContainer *coutput0 = mgr->CreateContainer(Form("chist0HighPtSpectra%d",trackType), TList::Class(),AliAnalysisManager::kOutputContainer,outputfile);
207   AliAnalysisDataContainer *coutput1 = mgr->CreateContainer(Form("ccontainer0HighPtSpectra%d",trackType), AliCFContainer::Class(),AliAnalysisManager::kOutputContainer,outputfile);
208   AliAnalysisDataContainer *coutput2 = mgr->CreateContainer(Form("ccontainer1HighPtSpectra%d",trackType), AliCFContainer::Class(),AliAnalysisManager::kOutputContainer,outputfile);
209   AliAnalysisDataContainer *cout_cuts0 = mgr->CreateContainer(Form("qa_SpectraTrackCuts%d",trackType), AliESDtrackCuts::Class(), AliAnalysisManager::kParamContainer,outputfile);
210   AliAnalysisDataContainer *cout_cuts1 = mgr->CreateContainer(Form("qa_SpectraTrackCutsTPConly%d",trackType), AliESDtrackCuts::Class(), AliAnalysisManager::kParamContainer,outputfile);
211
212   mgr->AddTask(taskPWG4HighPtSpectra);
213
214   mgr->ConnectInput(taskPWG4HighPtSpectra,0,mgr->GetCommonInputContainer());
215   mgr->ConnectOutput(taskPWG4HighPtSpectra,0,coutput0);
216   mgr->ConnectOutput(taskPWG4HighPtSpectra,1,coutput1);
217   mgr->ConnectOutput(taskPWG4HighPtSpectra,2,coutput2);
218   mgr->ConnectOutput(taskPWG4HighPtSpectra,3,cout_cuts0);
219   mgr->ConnectOutput(taskPWG4HighPtSpectra,4,cout_cuts1);
220
221   // Return task pointer at the end
222   return taskPWG4HighPtSpectra;
223 }