]>
Commit | Line | Data |
---|---|---|
06d06fbb | 1 | /************************************************************************** |
2 | * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * | |
3 | * * | |
4 | * Author: The ALICE Off-line Project. * | |
5 | * Contributors are mentioned in the code where appropriate. * | |
6 | * * | |
7 | * Permission to use, copy, modify and distribute this software and its * | |
8 | * documentation strictly for non-commercial purposes is hereby granted * | |
9 | * without fee, provided that the above copyright notice appears in all * | |
10 | * copies and that both the copyright notice and this permission notice * | |
11 | * appear in the supporting documentation. The authors make no claims * | |
12 | * about the suitability of this software for any purpose. It is * | |
13 | * provided "as is" without express or implied warranty. * | |
14 | **************************************************************************/ | |
15 | ||
16 | ||
17 | /////////////////////////////////////////////////////////////////////////////// | |
18 | // // | |
19 | // Time Projection Chamber // | |
20 | // Comparison macro for ESD // | |
21 | // responsible: | |
22 | // marian.ivanov@cern.ch // | |
23 | // | |
24 | // | |
25 | ||
26 | /* | |
27 | marian.ivanov@cern.ch | |
28 | Usage: | |
29 | ||
30 | ||
31 | ||
32 | gSystem->Load("libPWG1.so"); | |
33 | // | |
1a167b98 | 34 | AliRecInfoMaker *t2 = new AliRecInfoMaker("genTracks.root","cmpESDTracks.root","galice.root",0,0); |
06d06fbb | 35 | t2->Exec(); |
36 | ||
37 | ||
38 | TFile f("cmpESDTracks.root"); | |
06d06fbb | 39 | TTree * tree = (TTree*)f.Get("ESDcmpTracks"); |
1a167b98 | 40 | |
41 | AliTreeDraw comp; | |
06d06fbb | 42 | comp.SetTree(tree) |
43 | ||
44 | ||
45 | ||
46 | // | |
47 | //some cuts definition | |
48 | TCut cprim("cprim","TMath::Sqrt(MC.fVDist[0]**2+MC.fVDist[1]**2)<0.01&&abs(MC.fVDist[2])<0.01") | |
49 | //TCut cprim("cprim","TMath::Sqrt(MC.fVDist[0]**2+MC.fVDist[1]**2)<0.5&&abs(MC.fVDist[2])<0.5") | |
50 | //TCut citsin("citsin","TMath::Sqrt(MC.fVDist[0]**2+MC.fVDist[1]**2)<3.9"); | |
51 | TCut citsin("citsin","TMath::Sqrt(MC.fVDist[0]**2+MC.fVDist[1]**2)<5"); | |
52 | TCut csec("csec","TMath::Sqrt(MC.fVDist[0]**2+MC.fVDist[1]**2)>0.5"); | |
53 | ||
54 | ||
55 | TCut crec("crec","fReconstructed==1"); | |
56 | TCut cteta1("cteta1","abs(MC.fParticle.Theta()/3.1415-0.5)<0.25"); | |
57 | TCut cteta05("cteta05","abs(MC.fParticle.Theta()/3.1415-0.5)<0.1"); | |
58 | ||
59 | TCut cpos1("cpos1","abs(MC.fParticle.fVz/sqrt(MC.fParticle.fVx*MC.fParticle.fVx+MC.fParticle.fVy*MC.fParticle.fVy))<1"); | |
60 | TCut csens("csens","abs(sqrt(fVDist[0]**2+fVDist[1]**2)-170)<50"); | |
61 | TCut cmuon("cmuon","abs(MC.fParticle.fPdgCode==-13)"); | |
62 | TCut cchi2("cchi2","fESDtrack.fITSchi2MIP[0]<7.&&fESDtrack.fITSchi2MIP[1]<5.&&fESDtrack.fITSchi2MIP[2]<7.&&fESDtrack.fITSchi2MIP[3]<7.5&&fESDtrack.fITSchi2MIP[4]<6.") | |
63 | ||
64 | ||
65 | // | |
66 | //example | |
67 | comp.fTree->SetAlias("radius","TMath::Sqrt(MC.fVDist[0]**2+MC.fVDist[1]**2)"); | |
68 | comp.fTree->SetAlias("direction","MC.fParticle.fVx*MC.fParticle.fPx+MC.fParticle.fVy*MC.fParticle.fPy"); | |
69 | comp.fTree->SetAlias("decaydir","MC.fTRdecay.fX*MC.fTRdecay.fPx+MC.fTRdecay.fY*MC.fTRdecay.fPy"); | |
70 | comp.fTree->SetAlias("theta","MC.fTrackRef.Theta()"); | |
71 | comp.fTree->SetAlias("primdca","sqrt(RC.fITStrack.fD[0]**2+RC.fITStrack.fD[1]**2)"); | |
72 | comp.fTree->SetAlias("trdchi2","fTRDtrack.fChi2/fTRDtrack.fN"); | |
73 | comp.fTree->SetAlias("trdchi2","fTRDtrack.fChi2/fTRDtrack.fN"); | |
74 | ||
75 | ||
76 | TH1F his("his","his",100,0,20); | |
77 | TH1F hpools("hpools","hpools",100,-7,7); | |
78 | TH1F hfake("hfake","hfake",1000,0,150); | |
79 | TProfile profp0("profp0","profp0",20,-0.4,0.9) | |
80 | ||
81 | comp.DrawXY("fTPCinP0[3]","fTPCDelta[4]/fTPCinP1[3]","fReconstructed==1"+cprim,"1",4,0.2,1.5,-0.06,0.06) | |
82 | comp.fRes->Draw(); | |
83 | comp.fMean->Draw(); | |
84 | ||
85 | comp.DrawXY("fITSinP0[3]","fITSDelta[4]/fITSinP1[3]","fReconstructed==1&&fITSOn"+cprim,"1",4,0.2,1.5,-0.06,0.06) | |
86 | comp.fRes->Draw(); | |
87 | ||
88 | comp.Eff("fTPCinP0[3]","fRowsWithDigits>120"+cteta1+cpos1+cprim,"fTPCOn",20,0.2,1.5) | |
89 | comp.fRes->Draw(); | |
90 | ||
91 | comp.Eff("fTPCinP0[3]","fRowsWithDigits>120"+cteta1+cpos1+cprim,"fTPCOn&&fITSOn&&fESDtrack.fITSFakeRatio<0.1",10,0.2,1.5) | |
92 | comp.fRes->Draw(); | |
93 | comp.Eff("fTPCinP0[3]","fRowsWithDigits>120"+cteta1+cpos1+cprim,"fTPCOn&&fITSOn&&fESDtrack.fITSFakeRatio>0.1",10,0.2,1.5) | |
94 | comp.fRes->Draw(); | |
95 | ||
96 | comp.fTree->Draw("fESDtrack.fITSsignal/fESDtrack.fTPCsignal","fITSOn&&fTPCOn&&fESDtrack.fITSFakeRatio==0") | |
97 | ||
98 | TH1F his("his","his",100,0,20); | |
99 | TH1F hpools("hpools","hpools",100,-7,7); | |
100 | ||
101 | TH2F * hdedx0 = new TH2F("dEdx0","dEdx0",100, 0,2,200,0,550); hdedx0->SetMarkerColor(1); | |
102 | TH2F * hdedx1 = new TH2F("dEdx1","dEdx1",100, 0,2,200,0,550); hdedx1->SetMarkerColor(4); | |
103 | TH2F * hdedx2 = new TH2F("dEdx2","dEdx2",100, 0,2,200,0,550); hdedx2->SetMarkerColor(3); | |
104 | TH2F * hdedx3 = new TH2F("dEdx3","dEdx3",100, 0,2,200,0,550); hdedx3->SetMarkerColor(2); | |
105 | ||
106 | comp.fTree->Draw("fESDtrack.fITSsignal:MC.fParticle.P()>>dEdx0","fITSOn&&abs(fPdg)==211&&fITStrack.fN==6"+cprim) | |
107 | comp.fTree->Draw("fESDtrack.fITSsignal:MC.fParticle.P()>>dEdx1","fITSOn&&abs(fPdg)==2212&&fITStrack.fN==6"+cprim) | |
108 | comp.fTree->Draw("fESDtrack.fITSsignal:MC.fParticle.P()>>dEdx2","fITSOn&&abs(fPdg)==321&&fITStrack.fN==6"+cprim) | |
109 | comp.fTree->Draw("fESDtrack.fITSsignal:MC.fParticle.P()>>dEdx3","fITSOn&&abs(fPdg)==11&&fITStrack.fN==6"+cprim) | |
110 | ||
111 | ||
112 | comp.fTree->Draw("fESDtrack.fTRDsignal:MC.fParticle.P()>>dEdx0","fTRDOn&&abs(fPdg)==211&&fTRDtrack.fN>40&&fStatus[2]>1") | |
113 | comp.fTree->Draw("fESDtrack.fTRDsignal:MC.fParticle.P()>>dEdx1","fTRDOn&&abs(fPdg)==2212&&fTRDtrack.fN>40&&fStatus[2]>1") | |
114 | comp.fTree->Draw("fESDtrack.fTRDsignal:MC.fParticle.P()>>dEdx2","fTRDOn&&abs(fPdg)==321&&fTRDtrack.fN>40&&fStatus[2]>1") | |
115 | comp.fTree->Draw("fESDtrack.fTRDsignal:MC.fParticle.P()>>dEdx3","fTRDOn&&abs(fPdg)==11&&fTRDtrack.fN>40&&fStatus[2]>1") | |
116 | ||
117 | comp.fTree->Draw("fESDtrack.fTPCsignal:fTPCinP0[4]>>dEdx0","fTPCOn&&abs(fPdg)==211&&fESDtrack.fTPCncls>180&&fESDtrack.fTPCsignal>10"+cteta1); | |
118 | comp.fTree->Draw("fESDtrack.fTPCsignal:fTPCinP0[4]>>dEdx1","fTPCOn&&abs(fPdg)==2212&&fESDtrack.fTPCncls>180&&fESDtrack.fTPCsignal>10"+cteta1); | |
119 | comp.fTree->Draw("fESDtrack.fTPCsignal:fTPCinP0[4]>>dEdx2","fTPCOn&&abs(fPdg)==321&&fESDtrack.fTPCncls>180&&fESDtrack.fTPCsignal>10"+cteta1); | |
120 | comp.fTree->Draw("fESDtrack.fTPCsignal:fTPCinP0[4]>>dEdx3","fTPCOn&&abs(fPdg)==11&&fESDtrack.fTPCncls>180&&fESDtrack.fTPCsignal>10"+cteta1); | |
121 | ||
122 | hdedx3->SetXTitle("P(GeV/c)"); | |
123 | hdedx3->SetYTitle("dEdx(unit)"); | |
124 | hdedx3->Draw(); hdedx1->Draw("same"); hdedx2->Draw("same"); hdedx0->Draw("same"); | |
125 | ||
126 | comp.DrawXY("fITSinP0[3]","fITSPools[4]","fReconstructed==1&&fPdg==-211&&fITSOn"+cprim,"1",4,0.2,1.0,-8,8) | |
127 | ||
128 | TProfile prof("prof","prof",10,0.5,5); | |
129 | ||
130 | ||
131 | ||
132 | ||
133 | */ | |
134 | ||
135 | ||
136 | #include <stdio.h> | |
137 | #include <string.h> | |
138 | //ROOT includes | |
139 | #include "Rtypes.h" | |
140 | #include "TFile.h" | |
141 | #include "TTree.h" | |
06d06fbb | 142 | #include "TStopwatch.h" |
06d06fbb | 143 | #include "TVector3.h" |
06d06fbb | 144 | #include "Getline.h" |
1a167b98 | 145 | // |
06d06fbb | 146 | //ALIROOT includes |
1a167b98 | 147 | // |
06d06fbb | 148 | #include "AliRun.h" |
06d06fbb | 149 | #include "AliESDtrack.h" |
06d06fbb | 150 | #include "AliTPCParam.h" |
151 | #include "AliTPC.h" | |
06d06fbb | 152 | #include "AliTrackReference.h" |
06d06fbb | 153 | #include "AliTPCParamSR.h" |
154 | #include "AliTracker.h" | |
1a167b98 | 155 | #include "AliESDEvent.h" |
06d06fbb | 156 | #include "AliESD.h" |
157 | #include "AliESDfriend.h" | |
158 | #include "AliESDtrack.h" | |
159 | #include "AliTPCseed.h" | |
160 | #include "AliITStrackMI.h" | |
06d06fbb | 161 | #include "AliESDVertex.h" |
162 | #include "AliExternalTrackParam.h" | |
163 | #include "AliESDkink.h" | |
164 | #include "AliESDv0.h" | |
165 | #include "AliV0.h" | |
166 | // | |
167 | #include "AliTreeDraw.h" | |
76472f75 | 168 | #include "AliMCInfo.h" |
169 | #include "AliGenKinkInfo.h" | |
170 | #include "AliGenV0Info.h" | |
171 | ||
172 | ||
999d8278 | 173 | #include "AliESDRecInfo.h" |
174 | #include "AliESDRecV0Info.h" | |
175 | #include "AliESDRecKinkInfo.h" | |
06d06fbb | 176 | #include "AliRecInfoMaker.h" |
177 | ||
178 | ||
179 | ||
180 | ClassImp(AliRecInfoMaker) | |
181 | ||
182 | ||
183 | ||
184 | ||
185 | AliTPCParam * AliRecInfoMaker::GetTPCParam(){ | |
1a167b98 | 186 | // |
187 | // create TPC param | |
188 | // | |
06d06fbb | 189 | AliTPCParamSR * par = new AliTPCParamSR; |
190 | par->Update(); | |
191 | return par; | |
192 | } | |
193 | ||
194 | ||
195 | ||
52bbef74 | 196 | void AliRecInfoMaker::MakeAliases(TTree * tree) |
06d06fbb | 197 | { |
198 | // | |
199 | // aliases definition | |
200 | // | |
52bbef74 | 201 | tree->SetAlias("radius","TMath::Sqrt(MC.fVDist[0]**2+MC.fVDist[1]**2)"); |
202 | tree->SetAlias("direction","MC.fParticle.fVx*MC.fParticle.fPx+MC.fParticle.fVy*MC.fParticle.fPy"); | |
203 | tree->SetAlias("decaydir","MC.fTRdecay.fX*MC.fTRdecay.fPx+MC.fTRdecay.fY*MC.fTRdecay.fPy"); | |
204 | tree->SetAlias("theta","MC.fTrackRef.Theta()"); | |
205 | tree->SetAlias("primdca","sqrt(RC.fITStrack.fD[0]**2+RC.fITStrack.fD[1]**2)"); | |
206 | tree->SetAlias("trdchi2","fTRDtrack.fChi2/fTRDtrack.fN"); | |
207 | tree->SetAlias("trdchi2","fTRDtrack.fChi2/fTRDtrack.fN"); | |
06d06fbb | 208 | |
52bbef74 | 209 | tree->SetAlias("trddedx","(RC.fESDtrack.fTRDsignals[0]+RC.fESDtrack.fTRDsignals[1]+RC.fESDtrack.fTRDsignals[2]+RC.fESDtrack.fTRDsignals[3]+RC.fESDtrack.fTRDsignals[4]+RC.fESDtrack.fTRDsignals[5])/6."); |
06d06fbb | 210 | |
52bbef74 | 211 | tree->SetAlias("dtofmc2","fESDtrack.fTrackTime[2]-(10^12*MC.fTOFReferences[0].fTime)"); |
212 | tree->SetAlias("dtofrc2","(fESDtrack.fTrackTime[2]-fESDtrack.fTOFsignal)"); | |
213 | ||
214 | tree->SetAlias("psum","fESDtrack.fTOFr[4]+fESDtrack.fTOFr[3]+fESDtrack.fTOFr[2]+fESDtrack.fTOFr[1]+fESDtrack.fTOFr[0]"); | |
215 | tree->SetAlias("P0","fESDtrack.fTOFr[0]/psum"); | |
216 | tree->SetAlias("P1","fESDtrack.fTOFr[1]/psum"); | |
217 | tree->SetAlias("P2","fESDtrack.fTOFr[2]/psum"); | |
218 | tree->SetAlias("P3","fESDtrack.fTOFr[3]/psum"); | |
219 | tree->SetAlias("P4","fESDtrack.fTOFr[4]/psum"); | |
220 | tree->SetAlias("MaxP","max(max(max(P0,P1),max(P2,P3)),P4)"); | |
06d06fbb | 221 | } |
222 | ||
223 | ||
06d06fbb | 224 | //////////////////////////////////////////////////////////////////////// |
225 | AliRecInfoMaker::AliRecInfoMaker(const char* fnGenTracks, | |
226 | const char* fnCmp, | |
1a167b98 | 227 | const char* fnGalice, |
06d06fbb | 228 | Int_t nEvents, Int_t firstEvent) |
229 | { | |
1a167b98 | 230 | // AliRecInfoMaker - connencts the MC information with reconstructed information |
231 | // fnGenTracks - file with MC to be created before using AliGenInfoMaker | |
232 | // fnCmp - file name to be created | |
233 | // fnGalice - file with Loaders - usualy galice.root | |
234 | // | |
235 | // nEvent - number of event s to be analyzed | |
236 | // AliRecInfoMaker *t2 = new AliRecInfoMaker("genTracks.root","cmpESDTracks.root","galice.root",0,0); | |
237 | // | |
238 | ||
239 | ||
06d06fbb | 240 | Reset(); |
241 | // fFnGenTracks = fnGenTracks; | |
242 | // fFnCmp = fnCmp; | |
243 | sprintf(fFnGenTracks,"%s",fnGenTracks); | |
244 | sprintf(fFnCmp,"%s",fnCmp); | |
245 | ||
246 | fFirstEventNr = firstEvent; | |
247 | fEventNr = firstEvent; | |
248 | fNEvents = nEvents; | |
06d06fbb | 249 | // |
250 | fLoader = AliRunLoader::Open(fnGalice); | |
251 | if (gAlice){ | |
252 | //delete gAlice->GetRunLoader(); | |
253 | delete gAlice; | |
254 | gAlice = 0x0; | |
255 | } | |
256 | if (fLoader->LoadgAlice()){ | |
257 | cerr<<"Error occured while l"<<endl; | |
258 | } | |
259 | Int_t nall = fLoader->GetNumberOfEvents(); | |
260 | if (nEvents==0) { | |
261 | nEvents =nall; | |
262 | fNEvents=nall; | |
263 | fFirstEventNr=0; | |
264 | } | |
265 | ||
266 | if (nall<=0){ | |
267 | cerr<<"no events available"<<endl; | |
268 | fEventNr = 0; | |
269 | return; | |
270 | } | |
271 | if (firstEvent+nEvents>nall) { | |
272 | fEventNr = nall-firstEvent; | |
273 | cerr<<"restricted number of events availaible"<<endl; | |
274 | } | |
275 | AliMagF * magf = gAlice->Field(); | |
276 | AliTracker::SetFieldMap(magf,0); | |
277 | ||
278 | } | |
279 | ||
280 | ||
281 | //////////////////////////////////////////////////////////////////////// | |
282 | AliRecInfoMaker::~AliRecInfoMaker() | |
283 | { | |
284 | if (fLoader) { | |
285 | delete fLoader; | |
286 | } | |
287 | } | |
288 | ||
289 | ////////////////////////////////////////////////////////////// | |
290 | Int_t AliRecInfoMaker::SetIO() | |
291 | { | |
292 | // | |
293 | // | |
294 | CreateTreeCmp(); | |
295 | if (!fTreeCmp) return 1; | |
296 | fParamTPC = GetTPCParam(); | |
297 | // | |
298 | if (!ConnectGenTree()) { | |
299 | cerr<<"Cannot connect tree with generated tracks"<<endl; | |
300 | return 1; | |
301 | } | |
302 | return 0; | |
303 | } | |
304 | ||
305 | ////////////////////////////////////////////////////////////// | |
306 | ||
307 | Int_t AliRecInfoMaker::SetIO(Int_t eventNr) | |
308 | { | |
309 | // | |
310 | // | |
311 | // SET INPUT | |
312 | // | |
313 | TFile f("AliESDs.root"); | |
314 | // | |
315 | ||
316 | TTree* tree = (TTree*) f.Get("esdTree"); | |
1a167b98 | 317 | tree->SetBranchStatus("*",1); |
318 | fEvent = new AliESDEvent; | |
319 | ||
320 | if (tree->GetBranch("ESD")){ | |
321 | // tree->SetBranchAddress("ESD", &fEvent); | |
322 | // tree->SetBranchAddress("ESDfriend.",&fESDfriend); | |
323 | // tree->GetEntry(eventNr); | |
324 | // fEvent->SetESDfriend(fESDfriend); | |
325 | }else{ | |
326 | fEvent->ReadFromTree(tree); | |
327 | fESDfriend = (AliESDfriend*)fEvent->FindListObject("AliESDfriend"); | |
06d06fbb | 328 | tree->GetEntry(eventNr); |
1a167b98 | 329 | fEvent->SetESDfriend(fESDfriend); |
330 | } | |
06d06fbb | 331 | |
1a167b98 | 332 | |
06d06fbb | 333 | |
334 | if (!fEvent) return 1; | |
335 | ||
336 | return 0; | |
337 | } | |
338 | ||
339 | ||
340 | ||
341 | //////////////////////////////////////////////////////////////////////// | |
342 | void AliRecInfoMaker::Reset() | |
343 | { | |
1a167b98 | 344 | // |
345 | // Reset the class | |
346 | // | |
06d06fbb | 347 | fEventNr = 0; |
348 | fNEvents = 0; | |
349 | fTreeCmp = 0; | |
350 | fTreeCmpKinks =0; | |
351 | fTreeCmpV0 =0; | |
352 | // fFnCmp = "cmpTracks.root"; | |
353 | fFileGenTracks = 0; | |
354 | fDebug = 0; | |
355 | // | |
356 | fParamTPC = 0; | |
357 | fEvent =0; | |
358 | } | |
359 | ||
360 | //////////////////////////////////////////////////////////////////////// | |
361 | Int_t AliRecInfoMaker::Exec(Int_t nEvents, Int_t firstEventNr) | |
362 | { | |
1a167b98 | 363 | // |
364 | // Exec comparison for subrange of events | |
365 | // | |
06d06fbb | 366 | fNEvents = nEvents; |
367 | fFirstEventNr = firstEventNr; | |
368 | return Exec(); | |
369 | } | |
370 | ||
371 | //////////////////////////////////////////////////////////////////////// | |
372 | Int_t AliRecInfoMaker::Exec() | |
373 | { | |
1a167b98 | 374 | // |
375 | // Exec comparison | |
376 | // | |
06d06fbb | 377 | TStopwatch timer; |
378 | timer.Start(); | |
379 | ||
380 | if (SetIO()==1) | |
381 | return 1; | |
382 | ||
383 | fNextTreeGenEntryToRead = 0; | |
384 | fNextKinkToRead = 0; | |
385 | fNextV0ToRead =0; | |
386 | cerr<<"fFirstEventNr, fNEvents: "<<fFirstEventNr<<" "<<fNEvents<<endl; | |
387 | for (Int_t eventNr = fFirstEventNr; eventNr < fFirstEventNr+fNEvents; | |
388 | eventNr++) { | |
389 | fEventNr = eventNr; | |
390 | SetIO(fEventNr); | |
391 | fNParticles = gAlice->GetEvent(fEventNr); | |
392 | ||
393 | fIndexRecTracks = new Short_t[fNParticles*20]; //write at maximum 4 tracks corresponding to particle | |
394 | fIndexRecKinks = new Short_t[fNParticles*20]; //write at maximum 20 tracks corresponding to particle | |
395 | fIndexRecV0 = new Short_t[fNParticles*20]; //write at maximum 20 tracks corresponding to particle | |
396 | ||
397 | fFakeRecTracks = new Short_t[fNParticles]; | |
398 | fMultiRecTracks = new Short_t[fNParticles]; | |
399 | fMultiRecKinks = new Short_t[fNParticles]; | |
400 | fMultiRecV0 = new Short_t[fNParticles]; | |
401 | ||
402 | for (Int_t i = 0; i<fNParticles; i++) { | |
403 | for (Int_t j=0;j<20;j++){ | |
404 | fIndexRecTracks[20*i+j] = -1; | |
405 | fIndexRecKinks[20*i+j] = -1; | |
406 | fIndexRecV0[20*i+j] = -1; | |
407 | } | |
408 | fFakeRecTracks[i] = 0; | |
409 | fMultiRecTracks[i] = 0; | |
410 | fMultiRecKinks[i] = 0; | |
411 | fMultiRecV0[i] = 0; | |
412 | } | |
413 | ||
414 | cout<<"Start to process event "<<fEventNr<<endl; | |
415 | cout<<"\tfNParticles = "<<fNParticles<<endl; | |
416 | if (fDebug>2) cout<<"\tStart loop over TreeT"<<endl; | |
417 | if (TreeTLoop()>0) return 1; | |
418 | ||
419 | if (fDebug>2) cout<<"\tStart loop over tree genTracks"<<endl; | |
420 | if (TreeGenLoop(eventNr)>0) return 1; | |
421 | BuildKinkInfo0(eventNr); | |
422 | //BuildV0Info(eventNr); // no V0 info for a moment | |
423 | fRecArray->Delete(); | |
424 | ||
425 | if (fDebug>2) cout<<"\tEnd loop over tree genTracks"<<endl; | |
426 | ||
427 | delete [] fIndexRecTracks; | |
428 | delete [] fIndexRecKinks; | |
429 | delete [] fIndexRecV0; | |
430 | delete [] fFakeRecTracks; | |
431 | delete [] fMultiRecTracks; | |
432 | delete [] fMultiRecKinks; | |
433 | delete [] fMultiRecV0; | |
434 | } | |
435 | ||
436 | CloseOutputFile(); | |
437 | ||
438 | cerr<<"Exec finished"<<endl; | |
439 | timer.Stop(); | |
440 | timer.Print(); | |
441 | return 0; | |
442 | ||
443 | } | |
444 | //////////////////////////////////////////////////////////////////////// | |
445 | Bool_t AliRecInfoMaker::ConnectGenTree() | |
446 | { | |
447 | // | |
448 | // connect all branches from the genTracksTree | |
449 | // use the same variables as for the new cmp tree, it may work | |
450 | // | |
451 | fFileGenTracks = TFile::Open(fFnGenTracks,"READ"); | |
452 | if (!fFileGenTracks) { | |
453 | cerr<<"Error in ConnectGenTree: cannot open file "<<fFnGenTracks<<endl; | |
454 | return kFALSE; | |
455 | } | |
456 | fTreeGenTracks = (TTree*)fFileGenTracks->Get("genTracksTree"); | |
457 | if (!fTreeGenTracks) { | |
458 | cerr<<"Error in ConnectGenTree: cannot find genTracksTree in the file " | |
459 | <<fFnGenTracks<<endl; | |
460 | return kFALSE; | |
461 | } | |
462 | // | |
463 | fMCInfo = new AliMCInfo; | |
464 | fTreeGenTracks->SetBranchAddress("MC",&fMCInfo); | |
465 | // | |
466 | // | |
467 | fTreeGenKinks = (TTree*)fFileGenTracks->Get("genKinksTree"); | |
468 | if (!fTreeGenKinks) { | |
469 | cerr<<"Error in ConnectGenTree: cannot find genTracksTree in the file " | |
470 | <<fFnGenTracks<<endl; | |
471 | //return kFALSE; | |
472 | } | |
473 | else{ | |
474 | fGenKinkInfo = new AliGenKinkInfo; | |
475 | fTreeGenKinks->SetBranchAddress("MC",&fGenKinkInfo); | |
476 | } | |
477 | ||
478 | fTreeGenV0 = (TTree*)fFileGenTracks->Get("genV0Tree"); | |
479 | if (!fTreeGenV0) { | |
480 | cerr<<"Error in ConnectGenTree: cannot find genTracksTree in the file " | |
481 | <<fFnGenTracks<<endl; | |
482 | //return kFALSE; | |
483 | } | |
484 | else{ | |
485 | fGenV0Info = new AliGenV0Info; | |
486 | fTreeGenV0->SetBranchAddress("MC",&fGenV0Info); | |
487 | } | |
488 | // | |
489 | if (fDebug > 1) { | |
490 | cout<<"Number of gen. tracks with TR: "<<fTreeGenTracks->GetEntries()<<endl; | |
491 | } | |
492 | return kTRUE; | |
493 | } | |
494 | ||
495 | ||
496 | //////////////////////////////////////////////////////////////////////// | |
497 | void AliRecInfoMaker::CreateTreeCmp() | |
498 | { | |
1a167b98 | 499 | // |
500 | // Create file and tree with comparison information | |
501 | // | |
06d06fbb | 502 | fFileCmp = TFile::Open(fFnCmp,"RECREATE"); |
503 | if (!fFileCmp) { | |
504 | cerr<<"Error in CreateTreeCmp: cannot open file "<<fFnCmp<<endl; | |
505 | return; | |
506 | } | |
507 | // | |
508 | // | |
509 | fTreeCmp = new TTree("ESDcmpTracks","ESDcmpTracks"); | |
510 | fMCInfo = new AliMCInfo; | |
511 | fRecInfo = new AliESDRecInfo; | |
512 | AliESDtrack * esdTrack = new AliESDtrack; | |
513 | // AliITStrackMI * itsTrack = new AliITStrackMI; | |
514 | fTreeCmp->Branch("MC","AliMCInfo",&fMCInfo,256000); | |
515 | fTreeCmp->Branch("RC","AliESDRecInfo",&fRecInfo,256000); | |
516 | // fTreeCmp->Branch("ITS","AliITStrackMI",&itsTrack); | |
517 | delete esdTrack; | |
518 | // | |
519 | // | |
520 | fTreeCmpKinks = new TTree("ESDcmpKinks","ESDcmpKinks"); | |
521 | fGenKinkInfo = new AliGenKinkInfo; | |
522 | fRecKinkInfo = new AliESDRecKinkInfo; | |
523 | fTreeCmpKinks->Branch("MC.","AliGenKinkInfo",&fGenKinkInfo,256000); | |
524 | fTreeCmpKinks->Branch("RC.","AliESDRecKinkInfo",&fRecKinkInfo,256000); | |
525 | // | |
526 | // | |
527 | fTreeCmpV0 = new TTree("ESDcmpV0","ESDcmpV0"); | |
528 | fGenV0Info = new AliGenV0Info; | |
529 | fRecV0Info = new AliESDRecV0Info; | |
530 | fTreeCmpV0->Branch("MC.","AliGenV0Info", &fGenV0Info,256000); | |
531 | fTreeCmpV0->Branch("RC.","AliESDRecV0Info",&fRecV0Info,256000); | |
532 | // | |
533 | fTreeCmp->AutoSave(); | |
534 | fTreeCmpKinks->AutoSave(); | |
535 | fTreeCmpV0->AutoSave(); | |
536 | } | |
1a167b98 | 537 | |
06d06fbb | 538 | //////////////////////////////////////////////////////////////////////// |
539 | void AliRecInfoMaker::CloseOutputFile() | |
540 | { | |
1a167b98 | 541 | // |
542 | // Close output file | |
543 | // | |
544 | ||
06d06fbb | 545 | if (!fFileCmp) { |
546 | cerr<<"File "<<fFnCmp<<" not found as an open file."<<endl; | |
547 | return; | |
548 | } | |
549 | fFileCmp->cd(); | |
550 | fTreeCmp->Write(); | |
551 | delete fTreeCmp; | |
552 | ||
553 | fFileCmp->Close(); | |
554 | delete fFileCmp; | |
555 | return; | |
556 | } | |
557 | //////////////////////////////////////////////////////////////////////// | |
558 | ||
559 | TVector3 AliRecInfoMaker::TR2Local(AliTrackReference *trackRef, | |
560 | AliTPCParam *paramTPC) { | |
561 | ||
1a167b98 | 562 | // |
563 | // Transform position to the local coord frame | |
564 | // | |
565 | ||
06d06fbb | 566 | Float_t x[3] = { trackRef->X(),trackRef->Y(),trackRef->Z()}; |
567 | Int_t index[4]; | |
568 | paramTPC->Transform0to1(x,index); | |
569 | paramTPC->Transform1to2Ideal(x,index); | |
570 | return TVector3(x); | |
571 | } | |
572 | //////////////////////////////////////////////////////////////////////// | |
573 | ||
574 | Int_t AliRecInfoMaker::TreeTLoop() | |
575 | { | |
576 | // | |
577 | // loop over all ESD reconstructed tracks and store info in memory | |
578 | // | |
579 | // + loop over all reconstructed kinks | |
580 | TStopwatch timer; | |
581 | timer.Start(); | |
582 | // | |
583 | Int_t nEntries = (Int_t)fEvent->GetNumberOfTracks(); | |
584 | Int_t nKinks = (Int_t) fEvent->GetNumberOfKinks(); | |
585 | Int_t nV0MIs = (Int_t) fEvent->GetNumberOfV0s(); | |
586 | fSignedKinks = new Short_t[nKinks]; | |
587 | fSignedV0 = new Short_t[nV0MIs]; | |
588 | // | |
589 | // load kinks to the memory | |
590 | for (Int_t i=0; i<nKinks;i++){ | |
591 | AliESDkink * kink =fEvent->GetKink(i); | |
592 | fSignedKinks[i]=0; | |
593 | } | |
594 | // | |
595 | for (Int_t i=0; i<nV0MIs;i++){ | |
596 | AliV0 * v0MI = (AliV0*)fEvent->GetV0(i); | |
597 | fSignedV0[i]=0; | |
598 | } | |
599 | ||
600 | // | |
601 | // | |
602 | AliESDtrack * track=0; | |
603 | for (Int_t iEntry=0; iEntry<nEntries;iEntry++){ | |
06d06fbb | 604 | track = (AliESDtrack*)fEvent->GetTrack(iEntry); |
605 | // | |
606 | Int_t label = track->GetLabel(); | |
607 | Int_t absLabel = abs(label); | |
608 | if (absLabel < fNParticles) { | |
609 | // fIndexRecTracks[absLabel] = iEntry; | |
610 | if (label < 0) fFakeRecTracks[absLabel]++; | |
611 | if (fMultiRecTracks[absLabel]>0){ | |
612 | if (fMultiRecTracks[absLabel]<20) | |
613 | fIndexRecTracks[absLabel*20+fMultiRecTracks[absLabel]] = iEntry; | |
614 | } | |
615 | else | |
616 | fIndexRecTracks[absLabel*20] = iEntry; | |
617 | fMultiRecTracks[absLabel]++; | |
618 | } | |
619 | } | |
620 | // sort reconstructed kinks | |
621 | // | |
622 | AliESDkink * kink=0; | |
623 | for (Int_t iEntry=0; iEntry<nKinks;iEntry++){ | |
624 | kink = (AliESDkink*)fEvent->GetKink(iEntry); | |
625 | if (!kink) continue; | |
626 | // | |
627 | Int_t label0 = TMath::Abs(kink->GetLabel(0)); | |
628 | Int_t label1 = TMath::Abs(kink->GetLabel(1)); | |
629 | Int_t absLabel = TMath::Min(label0,label1); | |
630 | if (absLabel < fNParticles) { | |
631 | if (fMultiRecKinks[absLabel]>0){ | |
632 | if (fMultiRecKinks[absLabel]<20) | |
633 | fIndexRecKinks[absLabel*20+fMultiRecKinks[absLabel]] = iEntry; | |
634 | } | |
635 | else | |
636 | fIndexRecKinks[absLabel*20] = iEntry; | |
637 | fMultiRecKinks[absLabel]++; | |
638 | } | |
639 | } | |
640 | // --sort reconstructed V0 | |
641 | // | |
642 | // AliV0 * v0MI=0; | |
643 | // for (Int_t iEntry=0; iEntry<nV0MIs;iEntry++){ | |
644 | // v0MI = (AliV0*)fEvent->GetV0(iEntry); | |
645 | // if (!v0MI) continue; | |
646 | // // | |
647 | // Int_t label0 = TMath::Abs(v0MI->GetLabel(0)); | |
648 | // Int_t label1 = TMath::Abs(v0MI->GetLabel(1)); | |
649 | // // | |
650 | // for (Int_t i=0;i<2;i++){ | |
651 | // Int_t absLabel = TMath::Abs(v0MI->GetLabel(i)); | |
652 | // if (absLabel < fNParticles) { | |
653 | // if (fMultiRecV0[absLabel]>0){ | |
654 | // if (fMultiRecV0[absLabel]<20) | |
655 | // fIndexRecV0[absLabel*20+fMultiRecV0[absLabel]] = iEntry; | |
656 | // } | |
657 | // else | |
658 | // fIndexRecV0[absLabel*20] = iEntry; | |
659 | // fMultiRecV0[absLabel]++; | |
660 | // } | |
661 | // } | |
662 | // } | |
663 | ||
664 | ||
665 | printf("Time spended in TreeTLoop\n"); | |
666 | timer.Print(); | |
667 | ||
668 | if (fDebug > 2) cerr<<"end of TreeTLoop"<<endl; | |
669 | return 0; | |
670 | } | |
671 | ||
672 | //////////////////////////////////////////////////////////////////////// | |
673 | Int_t AliRecInfoMaker::TreeGenLoop(Int_t eventNr) | |
674 | { | |
675 | // | |
676 | // loop over all entries for a given event, find corresponding | |
677 | // rec. track and store in the fTreeCmp | |
678 | // | |
679 | TStopwatch timer; | |
680 | timer.Start(); | |
681 | Int_t entry = fNextTreeGenEntryToRead; | |
682 | Double_t nParticlesTR = fTreeGenTracks->GetEntriesFast(); | |
683 | cerr<<"fNParticles, nParticlesTR, fNextTreeGenEntryToRead: "<<fNParticles<<" " | |
684 | <<nParticlesTR<<" "<<fNextTreeGenEntryToRead<<endl; | |
685 | TBranch * branch = fTreeCmp->GetBranch("RC"); | |
686 | TBranch * branchF = fTreeCmp->GetBranch("F"); | |
687 | ||
688 | branch->SetAddress(&fRecInfo); // set all pointers | |
689 | fRecArray = new TObjArray(fNParticles); | |
690 | AliESDtrack dummytrack; // | |
691 | AliESDfriendTrack dummytrackF; // | |
692 | ||
693 | while (entry < nParticlesTR) { | |
694 | fTreeGenTracks->GetEntry(entry); | |
695 | entry++; | |
696 | if (eventNr < fMCInfo->fEventNr) continue; | |
697 | if (eventNr > fMCInfo->fEventNr) continue;; | |
698 | // | |
699 | fNextTreeGenEntryToRead = entry-1; | |
700 | if (fDebug > 2 && fMCInfo->fLabel < 10) { | |
701 | cerr<<"Fill track with a label "<<fMCInfo->fLabel<<endl; | |
702 | } | |
703 | // if (fMCInfo->fNTPCRef<1) continue; // not TPCref | |
704 | // | |
705 | fRecInfo->Reset(); | |
706 | AliESDtrack * track=0; | |
707 | fRecInfo->fReconstructed =0; | |
708 | TVector3 local = TR2Local(&(fMCInfo->fTrackRef),fParamTPC); | |
709 | local.GetXYZ(fRecInfo->fTRLocalCoord); | |
710 | // | |
711 | if (fIndexRecTracks[fMCInfo->fLabel*20] >= 0) { | |
06d06fbb | 712 | track= (AliESDtrack*)fEvent->GetTrack(fIndexRecTracks[fMCInfo->fLabel*20]); |
713 | // | |
714 | // | |
715 | // find nearest track if multifound | |
716 | //Int_t sign = Int_t(track->GetSign()*fMCInfo->fCharge); | |
717 | // | |
718 | Int_t status = 0; | |
719 | if ((track->GetStatus()&AliESDtrack::kITSrefit)>0) status++; | |
720 | if ((track->GetStatus()&AliESDtrack::kTPCrefit)>0) status++; | |
721 | if ((track->GetStatus()&AliESDtrack::kTRDrefit)>0) status++; | |
722 | ||
723 | // | |
724 | if (fIndexRecTracks[fMCInfo->fLabel*20+1]>0){ | |
725 | // | |
726 | Double_t p[3]; | |
727 | track->GetInnerPxPyPz(p); | |
728 | Float_t maxp = p[0]*p[0]+p[1]*p[1]+p[2]*p[2]; | |
729 | // | |
730 | for (Int_t i=1;i<20;i++){ | |
731 | if (fIndexRecTracks[fMCInfo->fLabel*20+i]>=0){ | |
732 | AliESDtrack * track2 = (AliESDtrack*)fEvent->GetTrack(fIndexRecTracks[fMCInfo->fLabel*20+i]); | |
733 | if (!track2) continue; | |
734 | //Int_t sign2 = track->GetSign()*fMCInfo->fCharge; // | |
735 | //if (sign2<0) continue; | |
736 | track2->GetInnerPxPyPz(p); | |
737 | Float_t mom = p[0]*p[0]+p[1]*p[1]+p[2]*p[2]; | |
738 | /* | |
739 | if (sign<0){ | |
740 | sign = sign2; | |
741 | track = track2; | |
742 | maxp = mom; | |
743 | continue; | |
744 | } | |
745 | */ | |
746 | // | |
747 | Int_t status2 = 0; | |
748 | if ((track2->GetStatus()&AliESDtrack::kITSrefit)>0) status2++; | |
749 | if ((track2->GetStatus()&AliESDtrack::kTPCrefit)>0) status2++; | |
750 | if ((track2->GetStatus()&AliESDtrack::kTRDrefit)>0) status2++; | |
751 | if (status2<status) continue; | |
752 | // | |
753 | if (mom<maxp) continue; | |
754 | maxp = mom; | |
755 | track = track2; | |
756 | // | |
757 | } | |
758 | } | |
759 | } | |
760 | // | |
761 | if (track) { | |
762 | fRecInfo->SetESDtrack(track); | |
763 | }else{ | |
764 | fRecInfo->SetESDtrack(&dummytrack); | |
765 | } | |
766 | // | |
767 | ||
768 | fRecInfo->fReconstructed = 1; | |
769 | fRecInfo->fFake = fFakeRecTracks[fMCInfo->fLabel]; | |
770 | fRecInfo->fMultiple = fMultiRecTracks[fMCInfo->fLabel]; | |
771 | // | |
1a167b98 | 772 | fRecInfo->Update(fMCInfo,fParamTPC,kTRUE); |
06d06fbb | 773 | } |
774 | else{ | |
775 | fRecInfo->SetESDtrack(&dummytrack); | |
1a167b98 | 776 | fRecInfo->Update(fMCInfo,fParamTPC,kFALSE); |
06d06fbb | 777 | } |
778 | fRecArray->AddAt(new AliESDRecInfo(*fRecInfo),fMCInfo->fLabel); | |
779 | fTreeCmp->Fill(); | |
780 | } | |
781 | fTreeCmp->AutoSave(); | |
06d06fbb | 782 | printf("Time spended in TreeGenLoop\n"); |
783 | timer.Print(); | |
784 | if (fDebug > 2) cerr<<"end of TreeGenLoop"<<endl; | |
785 | ||
786 | return 0; | |
787 | } | |
788 | ||
789 | ||
790 | ||
791 | //////////////////////////////////////////////////////////////////////// | |
792 | //////////////////////////////////////////////////////////////////////// | |
793 | //////////////////////////////////////////////////////////////////////// | |
794 | Int_t AliRecInfoMaker::BuildKinkInfo0(Int_t eventNr) | |
795 | { | |
796 | // | |
797 | // loop over all entries for a given event, find corresponding | |
798 | // rec. track and store in the fTreeCmp | |
799 | // | |
800 | TStopwatch timer; | |
801 | timer.Start(); | |
802 | Int_t entry = fNextKinkToRead; | |
803 | Double_t nParticlesTR = fTreeGenKinks->GetEntriesFast(); | |
804 | cerr<<"fNParticles, nParticlesTR, fNextKinkToRead: "<<fNParticles<<" " | |
805 | <<nParticlesTR<<" "<<fNextKinkToRead<<endl; | |
806 | // | |
807 | TBranch * branch = fTreeCmpKinks->GetBranch("RC."); | |
808 | branch->SetAddress(&fRecKinkInfo); // set all pointers | |
809 | ||
810 | // | |
811 | while (entry < nParticlesTR) { | |
812 | fTreeGenKinks->GetEntry(entry); | |
813 | entry++; | |
814 | if (eventNr < fGenKinkInfo->GetMinus().fEventNr) continue; | |
815 | if (eventNr > fGenKinkInfo->GetMinus().fEventNr) continue;; | |
816 | // | |
817 | fNextKinkToRead = entry-1; | |
818 | // | |
819 | // | |
820 | AliESDRecInfo* fRecInfo1 = (AliESDRecInfo*)fRecArray->At(fGenKinkInfo->GetMinus().fLabel); | |
821 | AliESDRecInfo* fRecInfo2 = (AliESDRecInfo*)fRecArray->At(fGenKinkInfo->GetPlus().fLabel); | |
822 | fRecKinkInfo->fT1 = (*fRecInfo1); | |
823 | fRecKinkInfo->fT2 = (*fRecInfo2); | |
824 | fRecKinkInfo->fStatus =0; | |
825 | if (fRecInfo1 && fRecInfo1->fTPCOn) fRecKinkInfo->fStatus+=1; | |
826 | if (fRecInfo2 && fRecInfo2->fTPCOn) fRecKinkInfo->fStatus+=2; | |
827 | if (fRecKinkInfo->fStatus==3&&fRecInfo1->fSign!=fRecInfo2->fSign) fRecKinkInfo->fStatus*=-1; | |
828 | ||
829 | if (fRecKinkInfo->fStatus==3){ | |
830 | fRecKinkInfo->Update(); | |
831 | } | |
832 | Int_t label = TMath::Min(fGenKinkInfo->GetMinus().fLabel,fGenKinkInfo->GetPlus().fLabel); | |
833 | Int_t label2 = TMath::Max(fGenKinkInfo->GetMinus().fLabel,fGenKinkInfo->GetPlus().fLabel); | |
834 | ||
835 | AliESDkink *kink=0; | |
836 | fRecKinkInfo->fRecStatus =0; | |
837 | fRecKinkInfo->fMultiple = fMultiRecKinks[label]; | |
838 | fRecKinkInfo->fKinkMultiple=0; | |
839 | // | |
840 | if (fMultiRecKinks[label]>0){ | |
841 | ||
842 | // for (Int_t j=0;j<TMath::Min(fMultiRecKinks[label],100);j++){ | |
843 | for (Int_t j=TMath::Min(fMultiRecKinks[label],Short_t(20))-1;j>=0;j--){ | |
844 | Int_t index = fIndexRecKinks[label*20+j]; | |
845 | //AliESDkink *kink2 = (AliESDkink*)fKinks->At(index); | |
846 | AliESDkink *kink2 = (AliESDkink*)fEvent->GetKink(index); | |
847 | if (TMath::Abs(kink2->GetLabel(0))==label &&TMath::Abs(kink2->GetLabel(1))==label2) { | |
848 | fRecKinkInfo->fKinkMultiple++; | |
849 | fSignedKinks[index]=1; | |
850 | Int_t c0=0; | |
851 | if (kink){ | |
852 | // if (kink->fTRDOn) c0++; | |
853 | //if (kink->fITSOn) c0++; | |
854 | if (kink->GetStatus(2)>0) c0++; | |
855 | if (kink->GetStatus(0)>0) c0++; | |
856 | } | |
857 | Int_t c2=0; | |
858 | // if (kink2->fTRDOn) c2++; | |
859 | //if (kink2->fITSOn) c2++; | |
860 | if (kink2->GetStatus(2)>0) c2++; | |
861 | if (kink2->GetStatus(0)>0) c2++; | |
862 | ||
863 | if (c2<c0) continue; | |
864 | kink =kink2; | |
865 | } | |
866 | if (TMath::Abs(kink2->GetLabel(1))==label &&TMath::Abs(kink2->GetLabel(0))==label2) { | |
867 | fRecKinkInfo->fKinkMultiple++; | |
868 | fSignedKinks[index]=1; | |
869 | Int_t c0=0; | |
870 | if (kink){ | |
871 | //if (kink->fTRDOn) c0++; | |
872 | //if (kink->fITSOn) c0++; | |
873 | if (kink->GetStatus(2)>0) c0++; | |
874 | if (kink->GetStatus(0)>0) c0++; | |
875 | ||
876 | } | |
877 | Int_t c2=0; | |
878 | // if (kink2->fTRDOn) c2++; | |
879 | //if (kink2->fITSOn) c2++; | |
880 | if (kink2->GetStatus(2)>0) c2++; | |
881 | if (kink2->GetStatus(0)>0) c2++; | |
882 | ||
883 | if (c2<c0) continue; | |
884 | kink =kink2; | |
885 | } | |
886 | } | |
887 | } | |
888 | if (kink){ | |
889 | fRecKinkInfo->fKink = *kink; | |
890 | fRecKinkInfo->fRecStatus=1; | |
891 | } | |
892 | fTreeCmpKinks->Fill(); | |
893 | } | |
894 | // Int_t nkinks = fKinks->GetEntriesFast(); | |
895 | Int_t nkinks = fEvent->GetNumberOfKinks(); | |
896 | for (Int_t i=0;i<nkinks;i++){ | |
897 | if (fSignedKinks[i]==0){ | |
898 | // AliESDkink *kink = (AliESDkink*)fKinks->At(i); | |
899 | AliESDkink *kink = (AliESDkink*)fEvent->GetKink(i); | |
900 | if (!kink) continue; | |
901 | // | |
902 | fRecKinkInfo->fKink = *kink; | |
903 | fRecKinkInfo->fRecStatus =-2; | |
904 | // | |
905 | AliESDRecInfo* fRecInfo1 = (AliESDRecInfo*)fRecArray->At(TMath::Abs(kink->GetLabel(0))); | |
906 | AliESDRecInfo* fRecInfo2 = (AliESDRecInfo*)fRecArray->At(TMath::Abs(kink->GetLabel(1))); | |
907 | if (fRecInfo1 && fRecInfo2){ | |
908 | fRecKinkInfo->fT1 = (*fRecInfo1); | |
909 | fRecKinkInfo->fT2 = (*fRecInfo2); | |
910 | fRecKinkInfo->fRecStatus =-1; | |
911 | } | |
912 | fTreeCmpKinks->Fill(); | |
913 | } | |
914 | } | |
915 | ||
916 | ||
917 | fTreeCmpKinks->AutoSave(); | |
918 | printf("Time spended in BuilKinkInfo Loop\n"); | |
919 | timer.Print(); | |
920 | if (fDebug > 2) cerr<<"end of BuildKinkInfo Loop"<<endl; | |
921 | return 0; | |
922 | } | |
923 | ||
924 | ||
925 | ||
926 | //////////////////////////////////////////////////////////////////////// | |
927 | //////////////////////////////////////////////////////////////////////// | |
928 | //////////////////////////////////////////////////////////////////////// | |
929 | ||
930 | ||
931 | ||
932 | Int_t AliRecInfoMaker::BuildV0Info(Int_t eventNr) | |
933 | { | |
934 | // | |
935 | // loop over all entries for a given event, find corresponding | |
936 | // rec. track and store in the fTreeCmp | |
937 | // | |
938 | TStopwatch timer; | |
939 | timer.Start(); | |
940 | Int_t entry = fNextV0ToRead; | |
941 | Double_t nParticlesTR = fTreeGenV0->GetEntriesFast(); | |
942 | cerr<<"fNParticles, nParticlesTR, fNextV0ToRead: "<<fNParticles<<" " | |
943 | <<nParticlesTR<<" "<<fNextV0ToRead<<endl; | |
944 | // | |
945 | TBranch * branch = fTreeCmpV0->GetBranch("RC."); | |
946 | branch->SetAddress(&fRecV0Info); // set all pointers | |
947 | const AliESDVertex * esdvertex = fEvent->GetVertex(); | |
948 | Float_t vertex[3]= {esdvertex->GetXv(), esdvertex->GetYv(),esdvertex->GetZv()}; | |
949 | ||
950 | // | |
951 | while (entry < nParticlesTR) { | |
952 | fTreeGenV0->GetEntry(entry); | |
953 | entry++; | |
954 | if (eventNr < fGenV0Info->GetMinus().fEventNr) continue; | |
955 | if (eventNr > fGenV0Info->GetMinus().fEventNr) continue;; | |
956 | // | |
957 | fNextV0ToRead = entry-1; | |
958 | // | |
959 | // | |
960 | AliESDRecInfo* fRecInfo1 = (AliESDRecInfo*)fRecArray->At(fGenV0Info->GetMinus().fLabel); | |
961 | AliESDRecInfo* fRecInfo2 = (AliESDRecInfo*)fRecArray->At(fGenV0Info->GetPlus().fLabel); | |
962 | if (fGenV0Info->GetMinus().fCharge*fGenV0Info->GetPlus().fCharge>0) continue; // interactions | |
963 | if (!fRecInfo1 || !fRecInfo2) continue; | |
964 | fRecV0Info->fT1 = (*fRecInfo1); | |
965 | fRecV0Info->fT2 = (*fRecInfo2); | |
966 | fRecV0Info->fV0Status =0; | |
967 | if (fRecInfo1 && fRecInfo1->fStatus[1]>0) fRecV0Info->fV0Status+=1; | |
968 | if (fRecInfo2 && fRecInfo2->fStatus[1]>0) fRecV0Info->fV0Status+=2; | |
969 | ||
970 | if (fRecV0Info->fV0Status==3&&fRecInfo1->fSign==fRecInfo2->fSign) fRecV0Info->fV0Status*=-1; | |
971 | ||
972 | ||
973 | if (abs(fRecV0Info->fV0Status)==3){ | |
974 | fRecV0Info->Update(vertex); | |
975 | { | |
976 | // | |
977 | // TPC V0 Info | |
978 | Double_t x,alpha, param[5],cov[15]; | |
979 | if ( fRecV0Info->fT1.GetESDtrack()->GetInnerParam() && fRecV0Info->fT2.GetESDtrack()->GetInnerParam()){ | |
980 | fRecV0Info->fT1.GetESDtrack()->GetInnerExternalParameters(alpha,x,param); | |
981 | fRecV0Info->fT1.GetESDtrack()->GetInnerExternalCovariance(cov); | |
982 | AliExternalTrackParam paramP(x,alpha,param,cov); | |
983 | // | |
984 | fRecV0Info->fT2.GetESDtrack()->GetInnerExternalParameters(alpha,x,param); | |
985 | fRecV0Info->fT2.GetESDtrack()->GetInnerExternalCovariance(cov); | |
986 | AliExternalTrackParam paramM(x,alpha,param,cov); | |
987 | // | |
988 | fRecV0Info->fV0tpc->SetParamN(paramM); | |
989 | fRecV0Info->fV0tpc->SetParamP(paramP); | |
990 | Double_t pid1[5],pid2[5]; | |
991 | fRecV0Info->fT1.GetESDtrack()->GetESDpid(pid1); | |
992 | fRecV0Info->fT1.GetESDtrack()->GetESDpid(pid2); | |
993 | // | |
994 | //fRecV0Info->fV0tpc.UpdatePID(pid1,pid2); | |
995 | fRecV0Info->fV0tpc->Update(vertex); | |
996 | ||
997 | // | |
998 | // | |
999 | fRecV0Info->fT1.GetESDtrack()->GetExternalParameters(x,param); | |
1000 | fRecV0Info->fT1.GetESDtrack()->GetExternalCovariance(cov); | |
1001 | alpha = fRecV0Info->fT1.GetESDtrack()->GetAlpha(); | |
1002 | new (¶mP) AliExternalTrackParam(x,alpha,param,cov); | |
1003 | // | |
1004 | fRecV0Info->fT2.GetESDtrack()->GetExternalParameters(x,param); | |
1005 | fRecV0Info->fT2.GetESDtrack()->GetExternalCovariance(cov); | |
1006 | alpha = fRecV0Info->fT2.GetESDtrack()->GetAlpha(); | |
1007 | new (¶mM) AliExternalTrackParam(x,alpha,param,cov); | |
1008 | // | |
1009 | fRecV0Info->fV0its->SetParamN(paramM); | |
1010 | fRecV0Info->fV0its->SetParamP(paramP); | |
1011 | // fRecV0Info->fV0its.UpdatePID(pid1,pid2); | |
1012 | fRecV0Info->fV0its->Update(vertex); | |
1013 | } | |
1014 | } | |
1015 | if (TMath::Abs(fGenV0Info->GetMinus().fPdg)==11 &&TMath::Abs(fGenV0Info->GetPlus().fPdg)==11){ | |
1016 | if (fRecV0Info->fDist2>10){ | |
1017 | fRecV0Info->Update(vertex); | |
1018 | } | |
1019 | if (fRecV0Info->fDist2>10){ | |
1020 | fRecV0Info->Update(vertex); | |
1021 | } | |
1022 | } | |
1023 | } | |
1024 | // | |
1025 | // take the V0 from reconstruction | |
1026 | ||
1027 | Int_t label = TMath::Min(fGenV0Info->GetMinus().fLabel,fGenV0Info->GetPlus().fLabel); | |
1028 | Int_t label2 = TMath::Max(fGenV0Info->GetMinus().fLabel,fGenV0Info->GetPlus().fLabel); | |
1029 | AliV0 *v0MI=0; | |
1030 | fRecV0Info->fRecStatus =0; | |
1031 | fRecV0Info->fMultiple = fMultiRecV0[label]; | |
1032 | fRecV0Info->fV0Multiple=0; | |
1033 | // | |
1034 | if (fMultiRecV0[label]>0 || fMultiRecV0[label2]>0){ | |
1035 | ||
1036 | // for (Int_t j=0;j<TMath::Min(fMultiRecV0s[label],100);j++){ | |
1037 | // for (Int_t j=TMath::Min(fMultiRecV0[label],Short_t(20))-1;j>=0;j--){ | |
1038 | // Int_t index = fIndexRecV0[label*20+j]; | |
1039 | // if (index<0) continue; | |
1040 | // AliV0 *v0MI2 = (AliV0*)fEvent->GetV0(index); | |
1041 | // if (TMath::Abs(v0MI2->GetLabel(0))==label &&TMath::Abs(v0MI2->GetLabel(1))==label2) { | |
1042 | // v0MI =v0MI2; | |
1043 | // fRecV0Info->fV0Multiple++; | |
1044 | // fSignedV0[index]=1; | |
1045 | // } | |
1046 | // if (TMath::Abs(v0MI2->GetLabel(1))==label &&TMath::Abs(v0MI2->GetLabel(0))==label2) { | |
1047 | // v0MI =v0MI2; | |
1048 | // fRecV0Info->fV0Multiple++; | |
1049 | // fSignedV0[index]=1; | |
1050 | // } | |
1051 | // } | |
1052 | } | |
1053 | if (v0MI){ | |
1054 | fRecV0Info->fV0rec = v0MI; | |
1055 | fRecV0Info->fRecStatus=1; | |
1056 | } | |
1057 | ||
1058 | fTreeCmpV0->Fill(); | |
1059 | } | |
1060 | // | |
1061 | // write fake v0s | |
1062 | ||
1063 | Int_t nV0MIs = fEvent->GetNumberOfV0s(); | |
1064 | for (Int_t i=0;i<nV0MIs;i++){ | |
1065 | if (fSignedV0[i]==0){ | |
1066 | AliV0 *v0MI = (AliV0*)fEvent->GetV0(i); | |
1067 | if (!v0MI) continue; | |
1068 | // | |
1069 | fRecV0Info->fV0rec = v0MI; | |
1070 | fRecV0Info->fV0Status =-10; | |
1071 | fRecV0Info->fRecStatus =-2; | |
1072 | // | |
1073 | // AliESDRecInfo* fRecInfo1 = (AliESDRecInfo*)fRecArray->At(TMath::Abs(v0MI->GetLabel(0))); | |
1074 | // AliESDRecInfo* fRecInfo2 = (AliESDRecInfo*)fRecArray->At(TMath::Abs(v0MI->GetLabel(1))); | |
1075 | // if (fRecInfo1 && fRecInfo2){ | |
1076 | // fRecV0Info->fT1 = (*fRecInfo1); | |
1077 | // fRecV0Info->fT2 = (*fRecInfo2); | |
1078 | // fRecV0Info->fRecStatus =-1; | |
1079 | // } | |
1080 | fRecV0Info->Update(vertex); | |
1081 | fTreeCmpV0->Fill(); | |
1082 | } | |
1083 | } | |
1084 | ||
1085 | ||
1086 | ||
1087 | fTreeCmpV0->AutoSave(); | |
1088 | printf("Time spended in BuilV0Info Loop\n"); | |
1089 | timer.Print(); | |
1090 | if (fDebug > 2) cerr<<"end of BuildV0Info Loop"<<endl; | |
1091 | return 0; | |
1092 | } | |
1093 | //////////////////////////////////////////////////////////////////////// | |
1094 | //////////////////////////////////////////////////////////////////////// | |
1095 | ||
1096 |