Implemented ZDC time cut in phsyics selection and in trigger analysis for MC. Trackle...
[u/mrichter/AliRoot.git] / CORRFW / test / AliCFSingleTrackTaskCAF.C
CommitLineData
eaadd12e 1//DEFINITION OF A FEW CONSTANTS
2const Double_t ymin = -1.0 ;
3const Double_t ymax = 1.0 ;
4const Double_t ptmin = 0.0 ;
5const Double_t ptmax = 8.0 ;
6const Int_t mintrackrefsTPC = 2 ;
7const Int_t mintrackrefsITS = 3 ;
8const Int_t charge = 1 ;
9const Int_t PDG = 2212;
10const Int_t minclustersTPC = 50 ;
11//----------------------------------------------------
12
d2b20d9c 13Bool_t AliCFSingleTrackTaskCAF()
eaadd12e 14{
15
eaadd12e 16 TBenchmark benchmark;
d2b20d9c 17 benchmark.Start("AliSingleTrackTaskCAF");
18
eaadd12e 19 //
20 // Connect to proof
21 //
d2b20d9c 22
23 TProof::Reset("proof://user@lxb6046.cern.ch");
24 TProof::Open("proof://user@lxb6046.cern.ch");
25
26 // gProof->ClearPackage("STEERBase");
27 // gProof->ClearPackage("ESD");
28 // gProof->ClearPackage("AOD");
29 // gProof->ClearPackage("ANALYSIS");
30 // gProof->ClearPackage("ANALYSISalice");
31
eaadd12e 32 // Enable the STEERBase Package
33 gProof->UploadPackage("STEERBase.par");
34 gProof->EnablePackage("STEERBase");
35 // Enable the ESD Package
36 gProof->UploadPackage("ESD.par");
37 gProof->EnablePackage("ESD");
38 // Enable the AOD Package
39 gProof->UploadPackage("AOD.par");
40 gProof->EnablePackage("AOD");
41 // Enable the Analysis Package
42 gProof->UploadPackage("ANALYSIS.par");
d2b20d9c 43 gProof->EnablePackage("ANALYSIS");
44 gProof->UploadPackage("ANALYSISalice.par");
45 gProof->EnablePackage("ANALYSISalice");
eaadd12e 46 // Enable the CORRFW Package
47 // gProof->ClearPackage("CORRFW");
48 gProof->UploadPackage("CORRFW.par");
49 gProof->EnablePackage("CORRFW");
d2b20d9c 50
eaadd12e 51 gProof->ShowEnabledPackages();
52 gProof->Load("./AliCFSingleTrackTask.cxx+g");
d2b20d9c 53
eaadd12e 54 //
55 // Create the chain
56 //
57 gROOT->LoadMacro("CreateESDChain.C");
d2b20d9c 58 TChain* analysisChain = CreateESDChain("ESD1503X_v1.txt", 2);
59
60
eaadd12e 61 //CONTAINER DEFINITION
d2b20d9c 62 Info("AliCFSingleTrackTaskCAF","SETUP CONTAINER");
eaadd12e 63 //the sensitive variables (2 in this example), their indices
d2b20d9c 64 UInt_t ipt = 0;
65 UInt_t iy = 1;
eaadd12e 66 //Setting up the container grid...
d2b20d9c 67 UInt_t nstep = 4 ; //number of selection steps MC
eaadd12e 68 const Int_t nvar = 2 ; //number of variables on the grid:pt,y
69 const Int_t nbin1 = 8 ; //bins in pt
70 const Int_t nbin2 = 8 ; //bins in y
d2b20d9c 71
eaadd12e 72 //arrays for the number of bins in each dimension
d2b20d9c 73 Int_t iBin[nvar];
74 iBin[0]=nbin1;
75 iBin[1]=nbin2;
76
eaadd12e 77 //arrays for lower bounds :
d2b20d9c 78 Double_t *binLim1=new Double_t[nbin1+1];
79 Double_t *binLim2=new Double_t[nbin2+1];
80
eaadd12e 81 //values for bin lower bounds
82 for(Int_t i=0; i<=nbin1; i++) binLim1[i]=(Double_t)ptmin + (ptmax-ptmin)/nbin1*(Double_t)i ;
83 for(Int_t i=0; i<=nbin2; i++) binLim2[i]=(Double_t)ymin + (ymax-ymin) /nbin2*(Double_t)i ;
84 //one "container" for MC
85 AliCFContainer* container = new AliCFContainer("container","container for tracks",nstep,nvar,iBin);
86 //setting the bin limits
87 container -> SetBinLimits(ipt,binLim1);
88 container -> SetBinLimits(iy,binLim2);
89
90
d2b20d9c 91 // SET TLIST FOR QA HISTOS
92 TList* qaList = new TList();
93
eaadd12e 94 //CREATE THE CUTS -----------------------------------------------
eaadd12e 95
96 // Gen-Level kinematic cuts
97 AliCFTrackKineCuts *mcKineCuts = new AliCFTrackKineCuts("mcKineCuts","MC-level kinematic cuts");
98 mcKineCuts->SetPtRange(ptmin,ptmax);
99 mcKineCuts->SetRapidityRange(ymin,ymax);
100 mcKineCuts->SetChargeMC(charge);
d2b20d9c 101 mcKineCuts->SetQAOn(qaList);
eaadd12e 102
d2b20d9c 103 //Particle-Level cuts:
eaadd12e 104 AliCFParticleGenCuts* mcGenCuts = new AliCFParticleGenCuts("mcGenCuts","MC particle generation cuts");
105 mcGenCuts->SetRequireIsPrimary();
106 mcGenCuts->SetRequirePdgCode(PDG);
d2b20d9c 107 mcGenCuts->SetQAOn(qaList);
108
eaadd12e 109 //Acceptance Cuts
110 AliCFAcceptanceCuts *mcAccCuts = new AliCFAcceptanceCuts("mcAccCuts","MC acceptance cuts");
111 mcAccCuts->SetMinNHitITS(mintrackrefsITS);
112 mcAccCuts->SetMinNHitTPC(mintrackrefsTPC);
d2b20d9c 113 mcAccCuts->SetQAOn(qaList);
eaadd12e 114
115 // Rec-Level kinematic cuts
116 AliCFTrackKineCuts *recKineCuts = new AliCFTrackKineCuts("recKineCuts","rec-level kine cuts");
117 recKineCuts->SetPtRange(ptmin,ptmax);
118 recKineCuts->SetRapidityRange(ymin,ymax);
119 recKineCuts->SetChargeRec(charge);
d2b20d9c 120 recKineCuts->SetQAOn(qaList);
eaadd12e 121
122 AliCFTrackQualityCuts *recQualityCuts = new AliCFTrackQualityCuts("recQualityCuts","rec-level quality cuts");
123 recQualityCuts->SetMinNClusterTPC(minclustersTPC);
124 recQualityCuts->SetRequireITSRefit(kTRUE);
d2b20d9c 125 recQualityCuts->SetQAOn(qaList);
eaadd12e 126
127 AliCFTrackIsPrimaryCuts *recIsPrimaryCuts = new AliCFTrackIsPrimaryCuts("recIsPrimaryCuts","rec-level isPrimary cuts");
128 recIsPrimaryCuts->SetMaxNSigmaToVertex(3);
d2b20d9c 129 recIsPrimaryCuts->SetQAOn(qaList);
eaadd12e 130
131 AliCFTrackCutPid* cutPID = new AliCFTrackCutPid("cutPID","ESD_PID") ;
d2b20d9c 132 int n_species = AliPID::kSPECIES ;
133 Double_t* prior = new Double_t[n_species];
134
135 prior[0] = 0.0244519 ;
136 prior[1] = 0.0143988 ;
137 prior[2] = 0.805747 ;
138 prior[3] = 0.0928785 ;
139 prior[4] = 0.0625243 ;
140
eaadd12e 141 cutPID->SetPriors(prior);
142 cutPID->SetProbabilityCut(0.0);
143 cutPID->SetDetectors("TPC TOF");
144 switch(TMath::Abs(PDG)) {
145 case 11 : cutPID->SetParticleType(AliPID::kElectron, kTRUE); break;
146 case 13 : cutPID->SetParticleType(AliPID::kMuon , kTRUE); break;
147 case 211 : cutPID->SetParticleType(AliPID::kPion , kTRUE); break;
148 case 321 : cutPID->SetParticleType(AliPID::kKaon , kTRUE); break;
149 case 2212 : cutPID->SetParticleType(AliPID::kProton , kTRUE); break;
150 default : printf("UNDEFINED PID\n"); break;
151 }
d2b20d9c 152 cutPID->SetQAOn(qaList);
eaadd12e 153
154 printf("CREATE MC KINE CUTS\n");
155 TObjArray* mcList = new TObjArray(0) ;
156 mcList->AddLast(mcKineCuts);
157 mcList->AddLast(mcGenCuts);
158
159 printf("CREATE ACCEPTANCE CUTS\n");
160 TObjArray* accList = new TObjArray(0) ;
161 accList->AddLast(mcAccCuts);
162
163 printf("CREATE RECONSTRUCTION CUTS\n");
164 TObjArray* recList = new TObjArray(0) ;
165 recList->AddLast(recKineCuts);
166 recList->AddLast(recQualityCuts);
167 recList->AddLast(recIsPrimaryCuts);
168
169 printf("CREATE PID CUTS\n");
170 TObjArray* fPIDCutList = new TObjArray(0) ;
171 fPIDCutList->AddLast(cutPID);
172
eaadd12e 173 //CREATE THE INTERFACE TO CORRECTION FRAMEWORK USED IN THE TASK
174 printf("CREATE INTERFACE AND CUTS\n");
175 AliCFManager* man = new AliCFManager() ;
176 man->SetParticleContainer (container);
177 man->SetParticleCutsList(AliCFManager::kPartGenCuts,mcList);
178 man->SetParticleCutsList(AliCFManager::kPartAccCuts,accList);
179 man->SetParticleCutsList(AliCFManager::kPartRecCuts,recList);
180 man->SetParticleCutsList(AliCFManager::kPartSelCuts,fPIDCutList);
181
182
183 //CREATE THE TASK
184 printf("CREATE TASK\n");
185 // create the task
186 AliCFSingleTrackTask *task = new AliCFSingleTrackTask("AliSingleTrackTask");
187 task->SetCFManager(man); //here is set the CF manager
d2b20d9c 188 task->SetQAList(qaList);
eaadd12e 189
190 //SETUP THE ANALYSIS MANAGER TO READ INPUT CHAIN AND WRITE DESIRED OUTPUTS
191 printf("CREATE ANALYSIS MANAGER\n");
192 // Make the analysis manager
193 AliAnalysisManager *mgr = new AliAnalysisManager("TestManager");
194
d2b20d9c 195 AliMCEventHandler* mcHandler = new AliMCEventHandler();
196 AliESDInputHandler* esdHandler = new AliESDInputHandler();
197 mgr->SetMCtruthEventHandler(mcHandler);
198 mgr->SetInputEventHandler(esdHandler);
199
eaadd12e 200 // Create and connect containers for input/output
d2b20d9c 201
202 //------ input data ------
eaadd12e 203 AliAnalysisDataContainer *cinput0 = mgr->CreateContainer("cchain0",TChain::Class(),AliAnalysisManager::kInputContainer);
d2b20d9c 204
205 // ----- output data -----
206
207 //slot 0 : default output tree (by default handled by AliAnalysisTaskSE)
208 AliAnalysisDataContainer *coutput0 = mgr->CreateContainer("ctree0", TTree::Class(),AliAnalysisManager::kOutputContainer,"output.root");
209
210 //now comes user's output objects :
211
212 // output TH1I for event counting
213 AliAnalysisDataContainer *coutput1 = mgr->CreateContainer("chist0", TH1I::Class(),AliAnalysisManager::kOutputContainer,"output.root");
eaadd12e 214 // output Correction Framework Container (for acceptance & efficiency calculations)
d2b20d9c 215 AliAnalysisDataContainer *coutput2 = mgr->CreateContainer("ccontainer0", AliCFContainer::Class(),AliAnalysisManager::kOutputContainer,"output.root");
eaadd12e 216 // output QA histograms
d2b20d9c 217 AliAnalysisDataContainer *coutput3 = mgr->CreateContainer("clist0", TList::Class(),AliAnalysisManager::kOutputContainer,"output.root");
218
219 cinput0->SetData(analysisChain);
eaadd12e 220
221 mgr->AddTask(task);
222 mgr->ConnectInput(task,0,cinput0);
223 mgr->ConnectOutput(task,0,coutput0);
224 mgr->ConnectOutput(task,1,coutput1);
225 mgr->ConnectOutput(task,2,coutput2);
d2b20d9c 226 mgr->ConnectOutput(task,3,coutput3);
eaadd12e 227
228 printf("READY TO RUN\n");
229 //RUN !!!
230 if (mgr->InitAnalysis()) {
231 mgr->PrintStatus();
232 mgr->StartAnalysis("proof",analysisChain);
233 }
234
d2b20d9c 235 benchmark.Stop("AliSingleTrackTaskCAF");
236 benchmark.Show("AliSingleTrackTaskCAF");
237
eaadd12e 238 return kTRUE ;
239}
240