]>
Commit | Line | Data |
---|---|---|
461292d6 | 1 | // DEFINITION OF A FEW CONSTANTS |
2 | ||
3 | // File scan | |
4 | ||
5 | const Int_t nsub = 800; | |
6 | ||
7 | // Event var | |
8 | ||
9 | const Double_t nevtmin= 1; | |
10 | const Double_t nevtmax = 500000; | |
11 | ||
12 | const Double_t trgmin=0; | |
13 | const Double_t trgmax=10; | |
14 | ||
15 | const Double_t vmin=-100; | |
16 | const Double_t vmax=100; | |
17 | ||
18 | const Double_t vzmin=-3000; | |
19 | const Double_t vzmax=1000; | |
20 | ||
21 | // Muons | |
22 | ||
23 | const Int_t PDG = 13; | |
24 | ||
25 | const Double_t ymin = -4; | |
26 | const Double_t ymax = -2.5; | |
27 | ||
28 | const Double_t phimin = -180; | |
29 | const Double_t phimax = 180; | |
30 | ||
31 | const Double_t ptmin = 0; | |
32 | const Double_t ptmax = 20; | |
33 | ||
34 | const Double_t pmin = 0; | |
35 | const Double_t pmax = 800; | |
36 | ||
37 | const Double_t hitmin=0; | |
38 | const Double_t hitmax=20; | |
39 | ||
40 | const Double_t chi2min=0; | |
41 | const Double_t chi2max=20; | |
42 | ||
43 | const Double_t dcamin=0; | |
44 | const Double_t dcamax=50; | |
45 | ||
46 | //---------------------------------------------------- | |
47 | ||
48 | Bool_t AliCFMuonSingleTask1( Int_t runmin = 170119, Int_t runmax = 170119, | |
49 | const Bool_t useGrid = 0, | |
50 | const Bool_t readAOD = 0, | |
51 | const char * kTagXMLFile="wn.xml" // XML file containing tags | |
52 | ) | |
53 | { | |
54 | ||
55 | TBenchmark benchmark; | |
56 | benchmark.Start("AliMuonSingleTask1"); | |
57 | AliLog::SetGlobalDebugLevel(0); | |
58 | Load() ; // load the required libraries | |
59 | TChain * analysisChain ; | |
60 | ||
61 | ///// INPUT | |
62 | ||
63 | if (useGrid) { // data located on AliEn | |
64 | TGrid::Connect("alien://") ; // Create an AliRunTagCuts and an AliEventTagCuts Object | |
65 | // and impose some selection criteria | |
66 | AliRunTagCuts *runCuts = new AliRunTagCuts(); | |
67 | AliEventTagCuts *eventCuts = new AliEventTagCuts(); | |
68 | AliLHCTagCuts *lhcCuts = new AliLHCTagCuts(); | |
69 | AliDetectorTagCuts *detCuts = new AliDetectorTagCuts(); | |
70 | eventCuts->SetMultiplicityRange(0,2000); | |
71 | ||
72 | // Create an AliTagAnalysis Object and chain the tags | |
73 | AliTagAnalysis *tagAna = new AliTagAnalysis(); | |
74 | if (readAOD) tagAna->SetType("AOD"); // for aliroot > v4-05 | |
75 | else tagAna->SetType("ESD"); // for aliroot > v4-05 | |
76 | TAlienCollection *coll = TAlienCollection::Open(kTagXMLFile); | |
77 | TGridResult *tagResult = coll->GetGridResult("",0,0); | |
78 | tagResult->Print(); | |
79 | tagAna->ChainGridTags(tagResult); | |
80 | ||
81 | // Create a new esd chain and assign the chain that is returned by querying the tags | |
82 | analysisChain = tagAna->QueryTags(runCuts,lhcCuts,detCuts,eventCuts); | |
83 | } | |
84 | ||
85 | else {// local data | |
86 | // here put your input data path | |
87 | printf("\n\nRunning on local file, please check the path\n\n"); | |
88 | ||
89 | if (readAOD) { | |
90 | analysisChain = new TChain("aodTree"); | |
91 | analysisChain->Add("AliAOD.root"); | |
92 | } | |
93 | else { | |
94 | analysisChain = new TChain("esdTree"); | |
95 | ||
96 | // my flat single | |
97 | Char_t RunFile[256]; | |
98 | for(Int_t i=1; i<=160; i++){ | |
99 | sprintf(RunFile,"/dalice02/lopez/single/myprod/4D_YCUT/run%d-500/AliESDs.root",i); | |
100 | analysisChain->Add(RunFile); | |
101 | } | |
102 | ||
103 | /* | |
104 | // input ascii list | |
105 | Char_t asciFile[256]; | |
106 | for(Int_t i=runmin; i<=runmax; i++){ | |
107 | sprintf(asciFile,"/dalice05/vulpescu/scratch/PDC08/LHC08t/LIST/ESDlist%d.txt",i); | |
108 | Char_t esdFileName[256]; | |
109 | ifstream inf(asciFile, ios::in); | |
110 | Int_t nFile = 0; | |
111 | while (!inf.eof()) { | |
112 | inf >> esdFileName; | |
113 | nFile++; | |
114 | if (nFile > nsub) break; | |
115 | analysisChain->Add(esdFileName); | |
116 | } | |
117 | } | |
118 | */ | |
119 | } | |
120 | } | |
121 | ||
122 | ///// END INPUT | |
123 | ||
124 | Info("AliCFMuonSingleTask1",Form("CHAIN HAS %d ENTRIES",(Int_t)analysisChain->GetEntries())); | |
125 | ||
126 | // CONTAINER DEFINITION | |
127 | Info("AliCFMuonSingleTask1","SETUP CONTAINER"); | |
128 | ||
129 | // The sensitive variables (15 in this example), their indices | |
130 | UInt_t nevt = 0; | |
131 | UInt_t y = 1; | |
132 | UInt_t phi = 2; | |
133 | UInt_t pt = 3; | |
134 | UInt_t p = 4; | |
135 | UInt_t hit = 5; | |
136 | UInt_t chi2 = 6; | |
137 | UInt_t matchtrig = 7; | |
138 | UInt_t chi2match = 8; | |
139 | UInt_t vx = 9; | |
140 | UInt_t vy = 10; | |
141 | UInt_t vz = 11; | |
142 | UInt_t trg = 12; | |
143 | UInt_t dca = 13; | |
144 | UInt_t zcoor = 14; | |
145 | ||
146 | ||
147 | // Setting up the container grid | |
148 | UInt_t nstep = 2 ; //number of selection steps : MC and ESD | |
149 | const Int_t nvar = 15 ; //number of variables on the grid | |
150 | const Int_t nbin1 = nevtmax ; | |
151 | const Int_t nbin2 = 6 ; // y | |
152 | const Int_t nbin3 = 45 ; // phi | |
153 | const Int_t nbin4 = 50 ; // pt | |
154 | const Int_t nbin5 = 800 ; // p | |
155 | const Int_t nbin6 = 20 ; // hit | |
156 | const Int_t nbin7 = 20 ; // chi2 | |
157 | const Int_t nbin8 = 10 ; // match trigger | |
158 | const Int_t nbin9 = 20 ; // chi2 match | |
159 | const Int_t nbin10 = 100 ; // vx | |
160 | const Int_t nbin11 = 100 ; // vy | |
161 | const Int_t nbin12 = 100 ; // vz | |
162 | const Int_t nbin13 = 10 ; // trg | |
163 | const Int_t nbin14 = 100 ; // dca | |
164 | const Int_t nbin15 = 1000 ; // zcoor | |
165 | ||
166 | // arrays for the number of bins in each dimension | |
167 | Int_t iBin[nvar]; | |
168 | iBin[0]=nbin1; | |
169 | iBin[1]=nbin2; | |
170 | iBin[2]=nbin3; | |
171 | iBin[3]=nbin4; | |
172 | iBin[4]=nbin5; | |
173 | iBin[5]=nbin6; | |
174 | iBin[6]=nbin7; | |
175 | iBin[7]=nbin8; | |
176 | iBin[8]=nbin9; | |
177 | iBin[9]=nbin10; | |
178 | iBin[10]=nbin11; | |
179 | iBin[11]=nbin12; | |
180 | iBin[12]=nbin13; | |
181 | iBin[13]=nbin14; | |
182 | iBin[14]=nbin15; | |
183 | ||
184 | // arrays for lower bounds : | |
185 | Double_t *binLim1=new Double_t[nbin1+1]; | |
186 | Double_t *binLim2=new Double_t[nbin2+1]; | |
187 | Double_t *binLim3=new Double_t[nbin3+1]; | |
188 | Double_t *binLim4=new Double_t[nbin4+1]; | |
189 | Double_t *binLim5=new Double_t[nbin5+1]; | |
190 | Double_t *binLim6=new Double_t[nbin6+1]; | |
191 | Double_t *binLim7=new Double_t[nbin7+1]; | |
192 | Double_t *binLim8=new Double_t[nbin8+1]; | |
193 | Double_t *binLim9=new Double_t[nbin9+1]; | |
194 | Double_t *binLim10=new Double_t[nbin10+1]; | |
195 | Double_t *binLim11=new Double_t[nbin11+1]; | |
196 | Double_t *binLim12=new Double_t[nbin12+1]; | |
197 | Double_t *binLim13=new Double_t[nbin13+1]; | |
198 | Double_t *binLim14=new Double_t[nbin14+1]; | |
199 | Double_t *binLim15=new Double_t[nbin15+1]; | |
200 | ||
201 | // values for bin lower bounds | |
202 | for(Int_t i=0; i<=nbin1; i++) binLim1[i]=(Double_t)nevtmin + (nevtmax-nevtmin) /nbin1*(Double_t)i ; | |
203 | for(Int_t i=0; i<=nbin2; i++) binLim2[i]=(Double_t)ymin + (ymax-ymin) /nbin2*(Double_t)i ; | |
204 | for(Int_t i=0; i<=nbin3; i++) binLim3[i]=(Double_t)phimin + (phimax-phimin) /nbin3*(Double_t)i ; | |
205 | for(Int_t i=0; i<=nbin4; i++) binLim4[i]=(Double_t)ptmin + (ptmax-ptmin) /nbin4*(Double_t)i ; | |
206 | for(Int_t i=0; i<=nbin5; i++) binLim5[i]=(Double_t)pmin + (pmax-pmin) /nbin5*(Double_t)i ; | |
207 | for(Int_t i=0; i<=nbin6; i++) binLim6[i]=(Double_t)hitmin + (hitmax-hitmin) /nbin6*(Double_t)i ; | |
208 | for(Int_t i=0; i<=nbin7; i++) binLim7[i]=(Double_t)chi2min + (chi2max-chi2min) /nbin7*(Double_t)i ; | |
209 | for(Int_t i=0; i<=nbin8; i++) binLim8[i]=(Double_t)trgmin + (trgmax-trgmin) /nbin8*(Double_t)i ; | |
210 | for(Int_t i=0; i<=nbin9; i++) binLim9[i]=(Double_t)chi2min + (chi2max-chi2min) /nbin9*(Double_t)i ; | |
211 | for(Int_t i=0; i<=nbin10; i++) binLim10[i]=(Double_t)vmin + (vmax-vmin) /nbin10*(Double_t)i ; | |
212 | for(Int_t i=0; i<=nbin11; i++) binLim11[i]=(Double_t)vmin + (vmax-vmin) /nbin11*(Double_t)i ; | |
213 | for(Int_t i=0; i<=nbin12; i++) binLim12[i]=(Double_t)vmin + (vmax-vmin) /nbin12*(Double_t)i ; | |
214 | for(Int_t i=0; i<=nbin13; i++) binLim13[i]=(Double_t)trgmin + (trgmax-trgmin) /nbin13*(Double_t)i ; | |
215 | for(Int_t i=0; i<=nbin14; i++) binLim14[i]=(Double_t)dcamin + (dcamax-dcamin) /nbin14*(Double_t)i ; | |
216 | for(Int_t i=0; i<=nbin15; i++) binLim15[i]=(Double_t)vzmin + (vzmax-vzmin) /nbin15*(Double_t)i ; | |
217 | ||
218 | // one container of 2 steps (MC and ESD) with 15 variables | |
219 | AliCFContainer* container = new AliCFContainer("container","container for tracks",nstep,nvar,iBin); | |
220 | // setting the bin limits | |
221 | container -> SetBinLimits(nevt,binLim1); | |
222 | container -> SetBinLimits(y,binLim2); | |
223 | container -> SetBinLimits(phi,binLim3); | |
224 | container -> SetBinLimits(pt,binLim4); | |
225 | container -> SetBinLimits(p,binLim5); | |
226 | container -> SetBinLimits(hit,binLim6); | |
227 | container -> SetBinLimits(chi2,binLim7); | |
228 | container -> SetBinLimits(matchtrig,binLim8); | |
229 | container -> SetBinLimits(chi2match,binLim9); | |
230 | container -> SetBinLimits(vx,binLim10); | |
231 | container -> SetBinLimits(vy,binLim11); | |
232 | container -> SetBinLimits(vz,binLim12); | |
233 | container -> SetBinLimits(trg,binLim13); | |
234 | container -> SetBinLimits(dca,binLim14); | |
235 | container -> SetBinLimits(zcoor,binLim15); | |
236 | ||
237 | // Set list | |
238 | TList* qaList = new TList(); | |
239 | ||
240 | //CREATE THE CUTS | |
241 | // Choice of the particle: here mu- | |
242 | AliCFParticleGenCuts* mcGenCuts = new AliCFParticleGenCuts("mcGenCuts","MC particle generation cuts"); | |
243 | mcGenCuts->SetRequirePdgCode(PDG); | |
244 | mcGenCuts->SetQAOn(qaList); | |
245 | ||
246 | TObjArray* mcList = new TObjArray(0) ; | |
247 | mcList->AddLast(mcGenCuts); | |
248 | ||
249 | // Set a pt cut of the particle | |
250 | AliCFTrackKineCuts *mcKineCuts = new AliCFTrackKineCuts("mcKineCuts","MC-level kinematic cuts"); | |
251 | mcKineCuts->SetPtRange(ptmin,ptmax); | |
252 | mcKineCuts->SetQAOn(qaList); | |
253 | // Set a rapidity cut | |
254 | AliCFTrackKineCuts *recKineCuts = new AliCFTrackKineCuts("recKineCuts","rec-level kine cuts"); | |
255 | recKineCuts->SetRapidityRange(ymin,ymax); | |
256 | recKineCuts->SetQAOn(qaList); | |
257 | ||
258 | TObjArray* recList = new TObjArray(0) ; | |
259 | recList->AddLast(recKineCuts); | |
260 | recList->AddLast(mcKineCuts); | |
261 | ||
262 | // CREATE THE INTERFACE TO CORRECTION FRAMEWORK USED IN THE TASK | |
263 | printf("CREATE INTERFACE AND CUTS\n"); | |
264 | AliCFManager* man = new AliCFManager() ; | |
265 | man->SetParticleContainer (container); | |
266 | man->SetParticleCutsList(AliCFManager::kPartGenCuts,mcList); | |
267 | man->SetParticleCutsList(AliCFManager::kPartAccCuts,recList); | |
268 | ||
269 | //CREATE THE TASK | |
270 | printf("CREATE TASK\n"); | |
271 | // create the task | |
272 | AliCFMuonSingleTask1 *task = new AliCFMuonSingleTask1("AliMuonSingleTask1"); | |
273 | task->SetCFManager(man); //here is set the CF manager | |
274 | task->SetQAList(qaList); | |
275 | if (readAOD) task->SetReadAODData() ; | |
276 | ||
277 | //SETUP THE ANALYSIS MANAGER TO READ INPUT CHAIN AND WRITE DESIRED OUTPUTS | |
278 | printf("CREATE ANALYSIS MANAGER\n"); | |
279 | // Make the analysis manager | |
280 | AliAnalysisManager *mgr = new AliAnalysisManager("TestManager"); | |
281 | ||
282 | if (useGrid) mgr->SetAnalysisType(AliAnalysisManager::kGridAnalysis); | |
283 | else mgr->SetAnalysisType(AliAnalysisManager::kLocalAnalysis); | |
284 | ||
285 | AliMCEventHandler* mcHandler = new AliMCEventHandler(); | |
286 | mgr->SetMCtruthEventHandler(mcHandler); | |
287 | ||
288 | AliInputEventHandler* dataHandler ; | |
289 | ||
290 | if (readAOD) dataHandler = new AliAODInputHandler(); | |
291 | else dataHandler = new AliESDInputHandler(); | |
292 | mgr->SetInputEventHandler(dataHandler); | |
293 | ||
294 | // Create and connect containers for input/output | |
295 | ||
296 | // input data | |
297 | AliAnalysisDataContainer *cinput0 = mgr->CreateContainer("cchain0",TChain::Class(),AliAnalysisManager::kInputContainer); | |
298 | ||
299 | // output data | |
300 | Char_t file[256]; | |
301 | ||
302 | sprintf(file,"/dalice02/lopez/single/myprod/4D_YCUT/CFMuonSingleTask1.root"); | |
303 | printf("Analysis output in %s \n",file); | |
304 | ||
305 | // output TH1I for event counting | |
306 | AliAnalysisDataContainer *coutput1 = mgr->CreateContainer("chist0", TH1I::Class(),AliAnalysisManager::kOutputContainer,file); | |
307 | // output Correction Framework Container (for acceptance & efficiency calculations) | |
308 | AliAnalysisDataContainer *coutput2 = mgr->CreateContainer("ccontainer0", AliCFContainer::Class(),AliAnalysisManager::kOutputContainer,file); | |
309 | ||
310 | ||
311 | cinput0->SetData(analysisChain); | |
312 | mgr->AddTask(task); | |
313 | mgr->ConnectInput(task,0,mgr->GetCommonInputContainer()); | |
314 | mgr->ConnectOutput(task,1,coutput1); | |
315 | mgr->ConnectOutput(task,2,coutput2); | |
316 | ||
317 | printf("READY TO RUN\n"); | |
318 | //RUN !!! | |
319 | if (mgr->InitAnalysis()) { | |
320 | mgr->PrintStatus(); | |
321 | mgr->StartAnalysis("local",analysisChain); | |
322 | } | |
323 | benchmark.Stop("AliMuonSingleTask1"); | |
324 | benchmark.Show("AliMuonSingleTask1"); | |
325 | ||
326 | return kTRUE ; | |
327 | } | |
328 | ||
329 | void Load() { | |
330 | ||
331 | //load the required aliroot libraries | |
332 | gSystem->Load("libANALYSIS") ; | |
333 | gSystem->Load("libANALYSISalice") ; | |
334 | gSystem->Load("$ALICE_ROOT/lib/tgt_linux/libCORRFW.so") ; | |
335 | ||
336 | //compile online the task class | |
337 | gSystem->SetIncludePath("-I. -I$ALICE_ROOT/include -I$ALICE_ROOT/MUON -I$ALICE_ROOT/STEER -I$ROOTSYS/include"); | |
338 | gROOT->LoadMacro("./AliCFMuonSingleTask1.cxx+"); | |
339 | } |