]>
Commit | Line | Data |
---|---|---|
563113d0 | 1 | //DEFINITION OF A FEW CONSTANTS |
2 | const Double_t ymin = -1.0 ; | |
3 | const Double_t ymax = 1.0 ; | |
4 | const Double_t ptmin = 0.0 ; | |
5 | const Double_t ptmax = 8.0 ; | |
6 | const Int_t mintrackrefsTPC = 2 ; | |
7 | const Int_t mintrackrefsITS = 3 ; | |
8 | const Int_t charge = 1 ; | |
9 | const Int_t PDG = 2212; | |
10 | const Int_t minclustersTPC = 50 ; | |
11 | //---------------------------------------------------- | |
12 | ||
13 | Bool_t AliCFSingleTrackTask( | |
14 | const Bool_t useGrid = 1, | |
d62f2321 | 15 | const Bool_t readAOD = 0, |
16 | const Bool_t readTPCTracks = 0, | |
8aa19d74 | 17 | const char * kTagXMLFile="wn.xml" // XML file containing tags |
563113d0 | 18 | ) |
19 | { | |
20 | ||
21 | TBenchmark benchmark; | |
22 | benchmark.Start("AliSingleTrackTask"); | |
23 | ||
24 | AliLog::SetGlobalDebugLevel(0); | |
25 | ||
26 | Load() ; //load the required libraries | |
27 | ||
28 | TChain * analysisChain ; | |
29 | ||
30 | if (useGrid) { //data located on AliEn | |
8aa19d74 | 31 | TGrid::Connect("alien://") ; // Create an AliRunTagCuts and an AliEventTagCuts Object |
32 | // and impose some selection criteria | |
563113d0 | 33 | AliRunTagCuts *runCuts = new AliRunTagCuts(); |
34 | AliEventTagCuts *eventCuts = new AliEventTagCuts(); | |
35 | AliLHCTagCuts *lhcCuts = new AliLHCTagCuts(); | |
36 | AliDetectorTagCuts *detCuts = new AliDetectorTagCuts(); | |
8aa19d74 | 37 | eventCuts->SetMultiplicityRange(0,2000); |
38 | ||
563113d0 | 39 | // Create an AliTagAnalysis Object and chain the tags |
40 | AliTagAnalysis *tagAna = new AliTagAnalysis(); | |
d62f2321 | 41 | if (readAOD) tagAna->SetType("AOD"); //for aliroot > v4-05 |
42 | else tagAna->SetType("ESD"); //for aliroot > v4-05 | |
563113d0 | 43 | TAlienCollection *coll = TAlienCollection::Open(kTagXMLFile); |
44 | TGridResult *tagResult = coll->GetGridResult("",0,0); | |
45 | tagResult->Print(); | |
46 | tagAna->ChainGridTags(tagResult); | |
8aa19d74 | 47 | |
563113d0 | 48 | // Create a new esd chain and assign the chain that is returned by querying the tags |
49 | analysisChain = tagAna->QueryTags(runCuts,lhcCuts,detCuts,eventCuts); | |
50 | } | |
8aa19d74 | 51 | |
563113d0 | 52 | else {// local data |
563113d0 | 53 | //here put your input data path |
8aa19d74 | 54 | printf("\n\nRunning on local file, please check the path\n\n"); |
d62f2321 | 55 | |
56 | if (readAOD) { | |
57 | analysisChain = new TChain("aodTree"); | |
58 | analysisChain->Add("AliAOD.root"); | |
59 | } | |
60 | else { | |
61 | analysisChain = new TChain("esdTree"); | |
62 | analysisChain->Add("AliESDs.root"); | |
63 | } | |
563113d0 | 64 | } |
65 | ||
8aa19d74 | 66 | |
563113d0 | 67 | Info("AliCFSingleTrackTask",Form("CHAIN HAS %d ENTRIES",(Int_t)analysisChain->GetEntries())); |
68 | ||
69 | //CONTAINER DEFINITION | |
70 | Info("AliCFSingleTrackTask","SETUP CONTAINER"); | |
1e9dad92 | 71 | //the sensitive variables (2 in this example), their indices |
8aa19d74 | 72 | UInt_t ipt = 0; |
73 | UInt_t iy = 1; | |
563113d0 | 74 | //Setting up the container grid... |
8aa19d74 | 75 | UInt_t nstep = 4 ; //number of selection steps MC |
1e9dad92 | 76 | const Int_t nvar = 2 ; //number of variables on the grid:pt,y |
563113d0 | 77 | const Int_t nbin1 = 8 ; //bins in pt |
78 | const Int_t nbin2 = 8 ; //bins in y | |
8aa19d74 | 79 | |
563113d0 | 80 | //arrays for the number of bins in each dimension |
8aa19d74 | 81 | Int_t iBin[nvar]; |
82 | iBin[0]=nbin1; | |
83 | iBin[1]=nbin2; | |
84 | ||
563113d0 | 85 | //arrays for lower bounds : |
8aa19d74 | 86 | Double_t *binLim1=new Double_t[nbin1+1]; |
87 | Double_t *binLim2=new Double_t[nbin2+1]; | |
88 | ||
563113d0 | 89 | //values for bin lower bounds |
1e9dad92 | 90 | for(Int_t i=0; i<=nbin1; i++) binLim1[i]=(Double_t)ptmin + (ptmax-ptmin)/nbin1*(Double_t)i ; |
91 | for(Int_t i=0; i<=nbin2; i++) binLim2[i]=(Double_t)ymin + (ymax-ymin) /nbin2*(Double_t)i ; | |
563113d0 | 92 | //one "container" for MC |
93 | AliCFContainer* container = new AliCFContainer("container","container for tracks",nstep,nvar,iBin); | |
94 | //setting the bin limits | |
95 | container -> SetBinLimits(ipt,binLim1); | |
96 | container -> SetBinLimits(iy,binLim2); | |
97 | ||
98 | ||
318a0e1f | 99 | // SET TLIST FOR QA HISTOS |
100 | TList* qaList = new TList(); | |
101 | ||
563113d0 | 102 | //CREATE THE CUTS ----------------------------------------------- |
563113d0 | 103 | |
104 | // Gen-Level kinematic cuts | |
105 | AliCFTrackKineCuts *mcKineCuts = new AliCFTrackKineCuts("mcKineCuts","MC-level kinematic cuts"); | |
106 | mcKineCuts->SetPtRange(ptmin,ptmax); | |
107 | mcKineCuts->SetRapidityRange(ymin,ymax); | |
108 | mcKineCuts->SetChargeMC(charge); | |
318a0e1f | 109 | mcKineCuts->SetQAOn(qaList); |
563113d0 | 110 | |
318a0e1f | 111 | //Particle-Level cuts: |
563113d0 | 112 | AliCFParticleGenCuts* mcGenCuts = new AliCFParticleGenCuts("mcGenCuts","MC particle generation cuts"); |
113 | mcGenCuts->SetRequireIsPrimary(); | |
114 | mcGenCuts->SetRequirePdgCode(PDG); | |
318a0e1f | 115 | mcGenCuts->SetQAOn(qaList); |
563113d0 | 116 | |
117 | //Acceptance Cuts | |
118 | AliCFAcceptanceCuts *mcAccCuts = new AliCFAcceptanceCuts("mcAccCuts","MC acceptance cuts"); | |
119 | mcAccCuts->SetMinNHitITS(mintrackrefsITS); | |
120 | mcAccCuts->SetMinNHitTPC(mintrackrefsTPC); | |
318a0e1f | 121 | mcAccCuts->SetQAOn(qaList); |
563113d0 | 122 | |
123 | // Rec-Level kinematic cuts | |
124 | AliCFTrackKineCuts *recKineCuts = new AliCFTrackKineCuts("recKineCuts","rec-level kine cuts"); | |
125 | recKineCuts->SetPtRange(ptmin,ptmax); | |
126 | recKineCuts->SetRapidityRange(ymin,ymax); | |
127 | recKineCuts->SetChargeRec(charge); | |
318a0e1f | 128 | recKineCuts->SetQAOn(qaList); |
563113d0 | 129 | |
130 | AliCFTrackQualityCuts *recQualityCuts = new AliCFTrackQualityCuts("recQualityCuts","rec-level quality cuts"); | |
131 | recQualityCuts->SetMinNClusterTPC(minclustersTPC); | |
132 | recQualityCuts->SetRequireITSRefit(kTRUE); | |
318a0e1f | 133 | recQualityCuts->SetQAOn(qaList); |
d62f2321 | 134 | |
563113d0 | 135 | AliCFTrackIsPrimaryCuts *recIsPrimaryCuts = new AliCFTrackIsPrimaryCuts("recIsPrimaryCuts","rec-level isPrimary cuts"); |
136 | recIsPrimaryCuts->SetMaxNSigmaToVertex(3); | |
318a0e1f | 137 | recIsPrimaryCuts->SetQAOn(qaList); |
563113d0 | 138 | |
139 | AliCFTrackCutPid* cutPID = new AliCFTrackCutPid("cutPID","ESD_PID") ; | |
8aa19d74 | 140 | int n_species = AliPID::kSPECIES ; |
141 | Double_t* prior = new Double_t[n_species]; | |
142 | ||
143 | prior[0] = 0.0244519 ; | |
144 | prior[1] = 0.0143988 ; | |
145 | prior[2] = 0.805747 ; | |
146 | prior[3] = 0.0928785 ; | |
147 | prior[4] = 0.0625243 ; | |
148 | ||
563113d0 | 149 | cutPID->SetPriors(prior); |
150 | cutPID->SetProbabilityCut(0.0); | |
d62f2321 | 151 | if (readTPCTracks) cutPID->SetDetectors("TPC"); |
152 | else cutPID->SetDetectors("ALL"); | |
153 | if (readAOD) cutPID->SetAODmode(kTRUE ); | |
154 | else cutPID->SetAODmode(kFALSE); | |
563113d0 | 155 | switch(TMath::Abs(PDG)) { |
156 | case 11 : cutPID->SetParticleType(AliPID::kElectron, kTRUE); break; | |
157 | case 13 : cutPID->SetParticleType(AliPID::kMuon , kTRUE); break; | |
158 | case 211 : cutPID->SetParticleType(AliPID::kPion , kTRUE); break; | |
159 | case 321 : cutPID->SetParticleType(AliPID::kKaon , kTRUE); break; | |
160 | case 2212 : cutPID->SetParticleType(AliPID::kProton , kTRUE); break; | |
161 | default : printf("UNDEFINED PID\n"); break; | |
162 | } | |
318a0e1f | 163 | cutPID->SetQAOn(qaList); |
563113d0 | 164 | |
165 | printf("CREATE MC KINE CUTS\n"); | |
166 | TObjArray* mcList = new TObjArray(0) ; | |
167 | mcList->AddLast(mcKineCuts); | |
168 | mcList->AddLast(mcGenCuts); | |
169 | ||
170 | printf("CREATE ACCEPTANCE CUTS\n"); | |
171 | TObjArray* accList = new TObjArray(0) ; | |
172 | accList->AddLast(mcAccCuts); | |
173 | ||
174 | printf("CREATE RECONSTRUCTION CUTS\n"); | |
175 | TObjArray* recList = new TObjArray(0) ; | |
176 | recList->AddLast(recKineCuts); | |
177 | recList->AddLast(recQualityCuts); | |
178 | recList->AddLast(recIsPrimaryCuts); | |
179 | ||
180 | printf("CREATE PID CUTS\n"); | |
181 | TObjArray* fPIDCutList = new TObjArray(0) ; | |
182 | fPIDCutList->AddLast(cutPID); | |
183 | ||
563113d0 | 184 | //CREATE THE INTERFACE TO CORRECTION FRAMEWORK USED IN THE TASK |
185 | printf("CREATE INTERFACE AND CUTS\n"); | |
186 | AliCFManager* man = new AliCFManager() ; | |
187 | man->SetParticleContainer (container); | |
188 | man->SetParticleCutsList(AliCFManager::kPartGenCuts,mcList); | |
189 | man->SetParticleCutsList(AliCFManager::kPartAccCuts,accList); | |
190 | man->SetParticleCutsList(AliCFManager::kPartRecCuts,recList); | |
191 | man->SetParticleCutsList(AliCFManager::kPartSelCuts,fPIDCutList); | |
192 | ||
193 | ||
194 | //CREATE THE TASK | |
195 | printf("CREATE TASK\n"); | |
196 | // create the task | |
197 | AliCFSingleTrackTask *task = new AliCFSingleTrackTask("AliSingleTrackTask"); | |
198 | task->SetCFManager(man); //here is set the CF manager | |
318a0e1f | 199 | task->SetQAList(qaList); |
d62f2321 | 200 | if (readAOD) task->SetReadAODData() ; |
201 | if (readTPCTracks) task->SetReadTPCTracks(); | |
563113d0 | 202 | |
203 | //SETUP THE ANALYSIS MANAGER TO READ INPUT CHAIN AND WRITE DESIRED OUTPUTS | |
204 | printf("CREATE ANALYSIS MANAGER\n"); | |
205 | // Make the analysis manager | |
206 | AliAnalysisManager *mgr = new AliAnalysisManager("TestManager"); | |
207 | ||
318a0e1f | 208 | if (useGrid) mgr->SetAnalysisType(AliAnalysisManager::kGridAnalysis); |
209 | else mgr->SetAnalysisType(AliAnalysisManager::kLocalAnalysis); | |
210 | ||
d62f2321 | 211 | |
318a0e1f | 212 | AliMCEventHandler* mcHandler = new AliMCEventHandler(); |
318a0e1f | 213 | mgr->SetMCtruthEventHandler(mcHandler); |
d62f2321 | 214 | |
215 | AliInputEventHandler* dataHandler ; | |
216 | ||
217 | if (readAOD) dataHandler = new AliAODInputHandler(); | |
218 | else dataHandler = new AliESDInputHandler(); | |
219 | mgr->SetInputEventHandler(dataHandler); | |
318a0e1f | 220 | |
563113d0 | 221 | // Create and connect containers for input/output |
222 | ||
318a0e1f | 223 | //------ input data ------ |
563113d0 | 224 | AliAnalysisDataContainer *cinput0 = mgr->CreateContainer("cchain0",TChain::Class(),AliAnalysisManager::kInputContainer); |
318a0e1f | 225 | |
226 | // ----- output data ----- | |
227 | ||
228 | //slot 0 : default output tree (by default handled by AliAnalysisTaskSE) | |
229 | AliAnalysisDataContainer *coutput0 = mgr->CreateContainer("ctree0", TTree::Class(),AliAnalysisManager::kOutputContainer,"output.root"); | |
230 | ||
231 | //now comes user's output objects : | |
232 | ||
233 | // output TH1I for event counting | |
234 | AliAnalysisDataContainer *coutput1 = mgr->CreateContainer("chist0", TH1I::Class(),AliAnalysisManager::kOutputContainer,"output.root"); | |
563113d0 | 235 | // output Correction Framework Container (for acceptance & efficiency calculations) |
318a0e1f | 236 | AliAnalysisDataContainer *coutput2 = mgr->CreateContainer("ccontainer0", AliCFContainer::Class(),AliAnalysisManager::kOutputContainer,"output.root"); |
563113d0 | 237 | // output QA histograms |
318a0e1f | 238 | AliAnalysisDataContainer *coutput3 = mgr->CreateContainer("clist0", TList::Class(),AliAnalysisManager::kOutputContainer,"output.root"); |
239 | ||
240 | cinput0->SetData(analysisChain); | |
563113d0 | 241 | |
242 | mgr->AddTask(task); | |
243 | mgr->ConnectInput(task,0,cinput0); | |
244 | mgr->ConnectOutput(task,0,coutput0); | |
245 | mgr->ConnectOutput(task,1,coutput1); | |
246 | mgr->ConnectOutput(task,2,coutput2); | |
318a0e1f | 247 | mgr->ConnectOutput(task,3,coutput3); |
563113d0 | 248 | |
563113d0 | 249 | printf("READY TO RUN\n"); |
250 | //RUN !!! | |
251 | if (mgr->InitAnalysis()) { | |
252 | mgr->PrintStatus(); | |
253 | mgr->StartAnalysis("local",analysisChain); | |
254 | } | |
255 | ||
256 | benchmark.Stop("AliSingleTrackTask"); | |
257 | benchmark.Show("AliSingleTrackTask"); | |
8aa19d74 | 258 | |
563113d0 | 259 | return kTRUE ; |
260 | } | |
261 | ||
262 | void Load() { | |
563113d0 | 263 | |
264 | //load the required aliroot libraries | |
265 | gSystem->Load("libANALYSIS") ; | |
8aa19d74 | 266 | gSystem->Load("libANALYSISalice") ; |
267 | gSystem->Load("libCORRFW.so") ; | |
563113d0 | 268 | |
269 | //compile online the task class | |
d62f2321 | 270 | gSystem->SetIncludePath("-I. -I$ALICE_ROOT/include -I$ALICE_ROOT/TPC -I$ROOTSYS/include"); |
563113d0 | 271 | gROOT->LoadMacro("./AliCFSingleTrackTask.cxx+"); |
272 | } |