some cleanup+ fix QA histos (I.Kraus)
[u/mrichter/AliRoot.git] / CORRFW / AliCFSingleTrackTask.C
CommitLineData
563113d0 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 = 211;
10const Int_t minclustersTPC = 50 ;
11//----------------------------------------------------
12
13Bool_t AliCFSingleTrackTask(
14 const Bool_t useGrid = 1,
15 const char * kTagXMLFile="wn.xml", // XML file containing tags
16 Long64_t nentries=TChain::kBigNumber
17 )
18{
19
20 TBenchmark benchmark;
21 benchmark.Start("AliSingleTrackTask");
22
23 AliLog::SetGlobalDebugLevel(0);
24
25 Load() ; //load the required libraries
26
27 TChain * analysisChain ;
28
29 if (useGrid) { //data located on AliEn
30 TGrid::Connect("alien://") ; // Create an AliRunTagCuts and an AliEventTagCuts Object and impose some selection criteria
31 AliRunTagCuts *runCuts = new AliRunTagCuts();
32 AliEventTagCuts *eventCuts = new AliEventTagCuts();
33 AliLHCTagCuts *lhcCuts = new AliLHCTagCuts();
34 AliDetectorTagCuts *detCuts = new AliDetectorTagCuts();
35 eventCuts->SetMultiplicityRange(0,20000);
36 // Create an AliTagAnalysis Object and chain the tags
37 AliTagAnalysis *tagAna = new AliTagAnalysis();
38 tagAna->SetType("ESD"); //for aliroot > v4-05
39 TAlienCollection *coll = TAlienCollection::Open(kTagXMLFile);
40 TGridResult *tagResult = coll->GetGridResult("",0,0);
41 tagResult->Print();
42 tagAna->ChainGridTags(tagResult);
43 // Create a new esd chain and assign the chain that is returned by querying the tags
44 analysisChain = tagAna->QueryTags(runCuts,lhcCuts,detCuts,eventCuts);
45 }
46 else {// local data
47 analysisChain = new TChain("esdTree");
48 //here put your input data path
49 analysisChain->Add("AliESDs.root");
50 }
51
52
53 Info("AliCFSingleTrackTask",Form("CHAIN HAS %d ENTRIES",(Int_t)analysisChain->GetEntries()));
54
55 //CONTAINER DEFINITION
56 Info("AliCFSingleTrackTask","SETUP CONTAINER");
57 //the sensitive variables, their indices
58 Int_t ipt = 0;
59 Int_t iy = 1;
60 //Setting up the container grid...
61 Int_t nstep = 4 ; //number of selection steps MC
62 const Int_t nvar = 2 ; //number of variables on the grid:pt,y,phi,vtx
63 const Int_t nbin1 = 8 ; //bins in pt
64 const Int_t nbin2 = 8 ; //bins in y
65 //arrays for the number of bins in each dimension
66 const Int_t iBin[nvar] ={nbin1,nbin2};
67 //arrays for lower bounds :
68 Float_t binLim1[nbin1+1];
69 Float_t binLim2[nbin2+1];
70 //values for bin lower bounds
71 for(Int_t i=0; i<=nbin1; i++) binLim1[i]=(Float_t)ptmin + (ptmax-ptmin)/nbin1*(Float_t)i ;
72 for(Int_t i=0; i<=nbin2; i++) binLim2[i]=(Float_t)ymin + (ymax-ymin) /nbin2*(Float_t)i ;
73 //one "container" for MC
74 AliCFContainer* container = new AliCFContainer("container","container for tracks",nstep,nvar,iBin);
75 //setting the bin limits
76 container -> SetBinLimits(ipt,binLim1);
77 container -> SetBinLimits(iy,binLim2);
78
79
80 //CREATE THE CUTS -----------------------------------------------
81
82 // Gen-Level kinematic cuts
83 AliCFTrackKineCuts *mcKineCuts = new AliCFTrackKineCuts("mcKineCuts","MC-level kinematic cuts");
84 mcKineCuts->SetPtRange(ptmin,ptmax);
85 mcKineCuts->SetRapidityRange(ymin,ymax);
86 mcKineCuts->SetChargeMC(charge);
87
88 AliCFParticleGenCuts* mcGenCuts = new AliCFParticleGenCuts("mcGenCuts","MC particle generation cuts");
89 mcGenCuts->SetRequireIsPrimary();
90 mcGenCuts->SetRequirePdgCode(PDG);
91
92 //Acceptance Cuts
93 AliCFAcceptanceCuts *mcAccCuts = new AliCFAcceptanceCuts("mcAccCuts","MC acceptance cuts");
94 mcAccCuts->SetMinNHitITS(mintrackrefsITS);
95 mcAccCuts->SetMinNHitTPC(mintrackrefsTPC);
96
97 // Rec-Level kinematic cuts
98 AliCFTrackKineCuts *recKineCuts = new AliCFTrackKineCuts("recKineCuts","rec-level kine cuts");
99 recKineCuts->SetPtRange(ptmin,ptmax);
100 recKineCuts->SetRapidityRange(ymin,ymax);
101 recKineCuts->SetChargeRec(charge);
102 // QA histograms for rec-level kinematic cuts
103 recKineCuts->SetQAOn(kTRUE);
104
105 AliCFTrackQualityCuts *recQualityCuts = new AliCFTrackQualityCuts("recQualityCuts","rec-level quality cuts");
106 recQualityCuts->SetMinNClusterTPC(minclustersTPC);
107 recQualityCuts->SetRequireITSRefit(kTRUE);
108 // QA histograms for rec-level quality cuts
109 recQualityCuts->SetQAOn(kTRUE);
110
111 AliCFTrackIsPrimaryCuts *recIsPrimaryCuts = new AliCFTrackIsPrimaryCuts("recIsPrimaryCuts","rec-level isPrimary cuts");
112 recIsPrimaryCuts->SetMaxNSigmaToVertex(3);
113 // QA histograms for rec-level primary-check cuts
114 recIsPrimaryCuts->SetQAOn(kTRUE);
115
116 AliCFTrackCutPid* cutPID = new AliCFTrackCutPid("cutPID","ESD_PID") ;
117 Double_t prior[AliPID::kSPECIES] = {0.0244519,
118 0.0143988,
119 0.805747 ,
120 0.0928785,
121 0.0625243 };
122 cutPID->SetPriors(prior);
123 cutPID->SetDetectors("TPC TOF");
124 cutPID->SetProbabilityCut(0.0);
125 switch(TMath::Abs(PDG)) {
126 case 11 : cutPID->SetParticleType(AliPID::kElectron, kTRUE); break;
127 case 13 : cutPID->SetParticleType(AliPID::kMuon , kTRUE); break;
128 case 211 : cutPID->SetParticleType(AliPID::kPion , kTRUE); break;
129 case 321 : cutPID->SetParticleType(AliPID::kKaon , kTRUE); break;
130 case 2212 : cutPID->SetParticleType(AliPID::kProton , kTRUE); break;
131 default : printf("UNDEFINED PID\n"); break;
132 }
133 cutPID->SetQAOn(kTRUE);
134
135 printf("CREATE MC KINE CUTS\n");
136 TObjArray* mcList = new TObjArray(0) ;
137 mcList->AddLast(mcKineCuts);
138 mcList->AddLast(mcGenCuts);
139
140 printf("CREATE ACCEPTANCE CUTS\n");
141 TObjArray* accList = new TObjArray(0) ;
142 accList->AddLast(mcAccCuts);
143
144 printf("CREATE RECONSTRUCTION CUTS\n");
145 TObjArray* recList = new TObjArray(0) ;
146 recList->AddLast(recKineCuts);
147 recList->AddLast(recQualityCuts);
148
149 printf("CREATE PID CUTS\n");
150 TObjArray* fPIDCutList = new TObjArray(0) ;
151 fPIDCutList->AddLast(cutPID);
152
153
154 //CREATE THE INTERFACE TO CORRECTION FRAMEWORK USED IN THE TASK
155 printf("CREATE INTERFACE AND CUTS\n");
156 AliCFManager* man = new AliCFManager() ;
157 man->SetParticleContainer (container);
158 man->SetParticleCutsList(AliCFManager::kPartGenCuts,mcList);
159 man->SetParticleCutsList(AliCFManager::kPartAccCuts,accList);
160 man->SetParticleCutsList(AliCFManager::kPartRecCuts,recList);
161 man->SetParticleCutsList(AliCFManager::kPartSelCuts,fPIDCutList);
162
163
164 //CREATE THE TASK
165 printf("CREATE TASK\n");
166 // create the task
167 AliCFSingleTrackTask *task = new AliCFSingleTrackTask("AliSingleTrackTask");
168 task->SetCFManager(man); //here is set the CF manager
169
170
171 //SETUP THE ANALYSIS MANAGER TO READ INPUT CHAIN AND WRITE DESIRED OUTPUTS
172 printf("CREATE ANALYSIS MANAGER\n");
173 // Make the analysis manager
174 AliAnalysisManager *mgr = new AliAnalysisManager("TestManager");
175
176 // Create and connect containers for input/output
177
178 //input data
179 AliAnalysisDataContainer *cinput0 = mgr->CreateContainer("cchain0",TChain::Class(),AliAnalysisManager::kInputContainer);
180 // output histo (number of events processed)
181 AliAnalysisDataContainer *coutput0 = mgr->CreateContainer("chist0", TH1I::Class(),AliAnalysisManager::kOutputContainer,"output.root");
182 // output Correction Framework Container (for acceptance & efficiency calculations)
183 AliAnalysisDataContainer *coutput1 = mgr->CreateContainer("ccontainer0", AliCFContainer::Class(),AliAnalysisManager::kOutputContainer,"output.root");
184 // output QA histograms
185 AliAnalysisDataContainer *coutput2 = mgr->CreateContainer("clist0", TList::Class(),AliAnalysisManager::kOutputContainer,"output.root");
186
187 mgr->AddTask(task);
188 mgr->ConnectInput(task,0,cinput0);
189 mgr->ConnectOutput(task,0,coutput0);
190 mgr->ConnectOutput(task,1,coutput1);
191 mgr->ConnectOutput(task,2,coutput2);
192 cinput0->SetData(analysisChain);
193
194 //NEW INTERFACE TO MC INFORMATION
195 AliMCEventHandler* mcHandler = new AliMCEventHandler();
196 mgr->SetMCtruthEventHandler(mcHandler);
197
198 printf("READY TO RUN\n");
199 //RUN !!!
200 if (mgr->InitAnalysis()) {
201 mgr->PrintStatus();
202 mgr->StartAnalysis("local",analysisChain);
203 }
204
205 benchmark.Stop("AliSingleTrackTask");
206 benchmark.Show("AliSingleTrackTask");
207
208 return kTRUE ;
209}
210
211void Load() {
212 //remove this file which can cause problems
213 gSystem->Exec("rm $ALICE_ROOT/ANALYSIS/AliAnalysisSelector_cxx.so");
214
215 //load the required aliroot libraries
216 gSystem->Load("libANALYSIS") ;
217 gSystem->Load("libANALYSISRL") ;
218 gSystem->Load("$ALICE_ROOT/CORRFW/libCORRFW.so") ;
219
220 //compile online the task class
221 gSystem->SetIncludePath("-I. -I$ALICE_ROOT/include -I$ROOTSYS/include");
222 gROOT->LoadMacro("./AliCFSingleTrackTask.cxx+");
223}