]>
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" |
9f3282ed | 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 | { | |
9f3282ed | 284 | // |
285 | // Destructor | |
286 | // | |
06d06fbb | 287 | if (fLoader) { |
288 | delete fLoader; | |
289 | } | |
290 | } | |
291 | ||
292 | ////////////////////////////////////////////////////////////// | |
293 | Int_t AliRecInfoMaker::SetIO() | |
294 | { | |
295 | // | |
9f3282ed | 296 | // SetIO - Create the input trees |
297 | // | |
06d06fbb | 298 | CreateTreeCmp(); |
299 | if (!fTreeCmp) return 1; | |
300 | fParamTPC = GetTPCParam(); | |
301 | // | |
302 | if (!ConnectGenTree()) { | |
303 | cerr<<"Cannot connect tree with generated tracks"<<endl; | |
304 | return 1; | |
305 | } | |
306 | return 0; | |
307 | } | |
308 | ||
309 | ////////////////////////////////////////////////////////////// | |
310 | ||
311 | Int_t AliRecInfoMaker::SetIO(Int_t eventNr) | |
312 | { | |
313 | // | |
314 | // | |
315 | // SET INPUT | |
316 | // | |
317 | TFile f("AliESDs.root"); | |
318 | // | |
319 | ||
320 | TTree* tree = (TTree*) f.Get("esdTree"); | |
1a167b98 | 321 | tree->SetBranchStatus("*",1); |
322 | fEvent = new AliESDEvent; | |
323 | ||
324 | if (tree->GetBranch("ESD")){ | |
325 | // tree->SetBranchAddress("ESD", &fEvent); | |
326 | // tree->SetBranchAddress("ESDfriend.",&fESDfriend); | |
327 | // tree->GetEntry(eventNr); | |
328 | // fEvent->SetESDfriend(fESDfriend); | |
329 | }else{ | |
330 | fEvent->ReadFromTree(tree); | |
331 | fESDfriend = (AliESDfriend*)fEvent->FindListObject("AliESDfriend"); | |
06d06fbb | 332 | tree->GetEntry(eventNr); |
1a167b98 | 333 | fEvent->SetESDfriend(fESDfriend); |
334 | } | |
06d06fbb | 335 | |
1a167b98 | 336 | |
06d06fbb | 337 | |
338 | if (!fEvent) return 1; | |
339 | ||
340 | return 0; | |
341 | } | |
342 | ||
343 | ||
344 | ||
345 | //////////////////////////////////////////////////////////////////////// | |
346 | void AliRecInfoMaker::Reset() | |
347 | { | |
1a167b98 | 348 | // |
349 | // Reset the class | |
350 | // | |
06d06fbb | 351 | fEventNr = 0; |
352 | fNEvents = 0; | |
353 | fTreeCmp = 0; | |
354 | fTreeCmpKinks =0; | |
355 | fTreeCmpV0 =0; | |
356 | // fFnCmp = "cmpTracks.root"; | |
357 | fFileGenTracks = 0; | |
358 | fDebug = 0; | |
359 | // | |
360 | fParamTPC = 0; | |
361 | fEvent =0; | |
362 | } | |
363 | ||
364 | //////////////////////////////////////////////////////////////////////// | |
365 | Int_t AliRecInfoMaker::Exec(Int_t nEvents, Int_t firstEventNr) | |
366 | { | |
1a167b98 | 367 | // |
368 | // Exec comparison for subrange of events | |
369 | // | |
06d06fbb | 370 | fNEvents = nEvents; |
371 | fFirstEventNr = firstEventNr; | |
372 | return Exec(); | |
373 | } | |
374 | ||
375 | //////////////////////////////////////////////////////////////////////// | |
376 | Int_t AliRecInfoMaker::Exec() | |
377 | { | |
1a167b98 | 378 | // |
379 | // Exec comparison | |
380 | // | |
06d06fbb | 381 | TStopwatch timer; |
382 | timer.Start(); | |
383 | ||
384 | if (SetIO()==1) | |
385 | return 1; | |
386 | ||
387 | fNextTreeGenEntryToRead = 0; | |
388 | fNextKinkToRead = 0; | |
389 | fNextV0ToRead =0; | |
390 | cerr<<"fFirstEventNr, fNEvents: "<<fFirstEventNr<<" "<<fNEvents<<endl; | |
391 | for (Int_t eventNr = fFirstEventNr; eventNr < fFirstEventNr+fNEvents; | |
392 | eventNr++) { | |
393 | fEventNr = eventNr; | |
394 | SetIO(fEventNr); | |
395 | fNParticles = gAlice->GetEvent(fEventNr); | |
396 | ||
397 | fIndexRecTracks = new Short_t[fNParticles*20]; //write at maximum 4 tracks corresponding to particle | |
398 | fIndexRecKinks = new Short_t[fNParticles*20]; //write at maximum 20 tracks corresponding to particle | |
399 | fIndexRecV0 = new Short_t[fNParticles*20]; //write at maximum 20 tracks corresponding to particle | |
400 | ||
401 | fFakeRecTracks = new Short_t[fNParticles]; | |
402 | fMultiRecTracks = new Short_t[fNParticles]; | |
403 | fMultiRecKinks = new Short_t[fNParticles]; | |
404 | fMultiRecV0 = new Short_t[fNParticles]; | |
405 | ||
406 | for (Int_t i = 0; i<fNParticles; i++) { | |
407 | for (Int_t j=0;j<20;j++){ | |
408 | fIndexRecTracks[20*i+j] = -1; | |
409 | fIndexRecKinks[20*i+j] = -1; | |
410 | fIndexRecV0[20*i+j] = -1; | |
411 | } | |
412 | fFakeRecTracks[i] = 0; | |
413 | fMultiRecTracks[i] = 0; | |
414 | fMultiRecKinks[i] = 0; | |
415 | fMultiRecV0[i] = 0; | |
416 | } | |
417 | ||
418 | cout<<"Start to process event "<<fEventNr<<endl; | |
419 | cout<<"\tfNParticles = "<<fNParticles<<endl; | |
420 | if (fDebug>2) cout<<"\tStart loop over TreeT"<<endl; | |
421 | if (TreeTLoop()>0) return 1; | |
422 | ||
423 | if (fDebug>2) cout<<"\tStart loop over tree genTracks"<<endl; | |
424 | if (TreeGenLoop(eventNr)>0) return 1; | |
425 | BuildKinkInfo0(eventNr); | |
426 | //BuildV0Info(eventNr); // no V0 info for a moment | |
427 | fRecArray->Delete(); | |
428 | ||
429 | if (fDebug>2) cout<<"\tEnd loop over tree genTracks"<<endl; | |
430 | ||
431 | delete [] fIndexRecTracks; | |
432 | delete [] fIndexRecKinks; | |
433 | delete [] fIndexRecV0; | |
434 | delete [] fFakeRecTracks; | |
435 | delete [] fMultiRecTracks; | |
436 | delete [] fMultiRecKinks; | |
437 | delete [] fMultiRecV0; | |
438 | } | |
439 | ||
440 | CloseOutputFile(); | |
441 | ||
442 | cerr<<"Exec finished"<<endl; | |
443 | timer.Stop(); | |
444 | timer.Print(); | |
445 | return 0; | |
446 | ||
447 | } | |
448 | //////////////////////////////////////////////////////////////////////// | |
449 | Bool_t AliRecInfoMaker::ConnectGenTree() | |
450 | { | |
451 | // | |
452 | // connect all branches from the genTracksTree | |
453 | // use the same variables as for the new cmp tree, it may work | |
454 | // | |
455 | fFileGenTracks = TFile::Open(fFnGenTracks,"READ"); | |
456 | if (!fFileGenTracks) { | |
457 | cerr<<"Error in ConnectGenTree: cannot open file "<<fFnGenTracks<<endl; | |
458 | return kFALSE; | |
459 | } | |
460 | fTreeGenTracks = (TTree*)fFileGenTracks->Get("genTracksTree"); | |
461 | if (!fTreeGenTracks) { | |
462 | cerr<<"Error in ConnectGenTree: cannot find genTracksTree in the file " | |
463 | <<fFnGenTracks<<endl; | |
464 | return kFALSE; | |
465 | } | |
466 | // | |
467 | fMCInfo = new AliMCInfo; | |
468 | fTreeGenTracks->SetBranchAddress("MC",&fMCInfo); | |
469 | // | |
470 | // | |
471 | fTreeGenKinks = (TTree*)fFileGenTracks->Get("genKinksTree"); | |
472 | if (!fTreeGenKinks) { | |
473 | cerr<<"Error in ConnectGenTree: cannot find genTracksTree in the file " | |
474 | <<fFnGenTracks<<endl; | |
475 | //return kFALSE; | |
476 | } | |
477 | else{ | |
478 | fGenKinkInfo = new AliGenKinkInfo; | |
479 | fTreeGenKinks->SetBranchAddress("MC",&fGenKinkInfo); | |
480 | } | |
481 | ||
482 | fTreeGenV0 = (TTree*)fFileGenTracks->Get("genV0Tree"); | |
483 | if (!fTreeGenV0) { | |
484 | cerr<<"Error in ConnectGenTree: cannot find genTracksTree in the file " | |
485 | <<fFnGenTracks<<endl; | |
486 | //return kFALSE; | |
487 | } | |
488 | else{ | |
489 | fGenV0Info = new AliGenV0Info; | |
490 | fTreeGenV0->SetBranchAddress("MC",&fGenV0Info); | |
491 | } | |
492 | // | |
493 | if (fDebug > 1) { | |
494 | cout<<"Number of gen. tracks with TR: "<<fTreeGenTracks->GetEntries()<<endl; | |
495 | } | |
496 | return kTRUE; | |
497 | } | |
498 | ||
499 | ||
500 | //////////////////////////////////////////////////////////////////////// | |
501 | void AliRecInfoMaker::CreateTreeCmp() | |
502 | { | |
1a167b98 | 503 | // |
504 | // Create file and tree with comparison information | |
505 | // | |
06d06fbb | 506 | fFileCmp = TFile::Open(fFnCmp,"RECREATE"); |
507 | if (!fFileCmp) { | |
508 | cerr<<"Error in CreateTreeCmp: cannot open file "<<fFnCmp<<endl; | |
509 | return; | |
510 | } | |
511 | // | |
512 | // | |
513 | fTreeCmp = new TTree("ESDcmpTracks","ESDcmpTracks"); | |
514 | fMCInfo = new AliMCInfo; | |
515 | fRecInfo = new AliESDRecInfo; | |
516 | AliESDtrack * esdTrack = new AliESDtrack; | |
517 | // AliITStrackMI * itsTrack = new AliITStrackMI; | |
518 | fTreeCmp->Branch("MC","AliMCInfo",&fMCInfo,256000); | |
519 | fTreeCmp->Branch("RC","AliESDRecInfo",&fRecInfo,256000); | |
520 | // fTreeCmp->Branch("ITS","AliITStrackMI",&itsTrack); | |
521 | delete esdTrack; | |
522 | // | |
523 | // | |
524 | fTreeCmpKinks = new TTree("ESDcmpKinks","ESDcmpKinks"); | |
525 | fGenKinkInfo = new AliGenKinkInfo; | |
526 | fRecKinkInfo = new AliESDRecKinkInfo; | |
527 | fTreeCmpKinks->Branch("MC.","AliGenKinkInfo",&fGenKinkInfo,256000); | |
528 | fTreeCmpKinks->Branch("RC.","AliESDRecKinkInfo",&fRecKinkInfo,256000); | |
529 | // | |
530 | // | |
531 | fTreeCmpV0 = new TTree("ESDcmpV0","ESDcmpV0"); | |
532 | fGenV0Info = new AliGenV0Info; | |
533 | fRecV0Info = new AliESDRecV0Info; | |
534 | fTreeCmpV0->Branch("MC.","AliGenV0Info", &fGenV0Info,256000); | |
535 | fTreeCmpV0->Branch("RC.","AliESDRecV0Info",&fRecV0Info,256000); | |
536 | // | |
537 | fTreeCmp->AutoSave(); | |
538 | fTreeCmpKinks->AutoSave(); | |
539 | fTreeCmpV0->AutoSave(); | |
540 | } | |
1a167b98 | 541 | |
06d06fbb | 542 | //////////////////////////////////////////////////////////////////////// |
543 | void AliRecInfoMaker::CloseOutputFile() | |
544 | { | |
1a167b98 | 545 | // |
546 | // Close output file | |
547 | // | |
548 | ||
06d06fbb | 549 | if (!fFileCmp) { |
550 | cerr<<"File "<<fFnCmp<<" not found as an open file."<<endl; | |
551 | return; | |
552 | } | |
553 | fFileCmp->cd(); | |
554 | fTreeCmp->Write(); | |
555 | delete fTreeCmp; | |
556 | ||
557 | fFileCmp->Close(); | |
558 | delete fFileCmp; | |
559 | return; | |
560 | } | |
561 | //////////////////////////////////////////////////////////////////////// | |
562 | ||
563 | TVector3 AliRecInfoMaker::TR2Local(AliTrackReference *trackRef, | |
564 | AliTPCParam *paramTPC) { | |
565 | ||
1a167b98 | 566 | // |
567 | // Transform position to the local coord frame | |
568 | // | |
569 | ||
06d06fbb | 570 | Float_t x[3] = { trackRef->X(),trackRef->Y(),trackRef->Z()}; |
571 | Int_t index[4]; | |
572 | paramTPC->Transform0to1(x,index); | |
573 | paramTPC->Transform1to2Ideal(x,index); | |
574 | return TVector3(x); | |
575 | } | |
576 | //////////////////////////////////////////////////////////////////////// | |
577 | ||
578 | Int_t AliRecInfoMaker::TreeTLoop() | |
579 | { | |
580 | // | |
581 | // loop over all ESD reconstructed tracks and store info in memory | |
582 | // | |
583 | // + loop over all reconstructed kinks | |
584 | TStopwatch timer; | |
585 | timer.Start(); | |
586 | // | |
587 | Int_t nEntries = (Int_t)fEvent->GetNumberOfTracks(); | |
588 | Int_t nKinks = (Int_t) fEvent->GetNumberOfKinks(); | |
589 | Int_t nV0MIs = (Int_t) fEvent->GetNumberOfV0s(); | |
590 | fSignedKinks = new Short_t[nKinks]; | |
591 | fSignedV0 = new Short_t[nV0MIs]; | |
592 | // | |
593 | // load kinks to the memory | |
594 | for (Int_t i=0; i<nKinks;i++){ | |
9f3282ed | 595 | // AliESDkink * kink = |
596 | fEvent->GetKink(i); | |
06d06fbb | 597 | fSignedKinks[i]=0; |
598 | } | |
599 | // | |
600 | for (Int_t i=0; i<nV0MIs;i++){ | |
9f3282ed | 601 | //AliV0 * v0MI = |
602 | (AliV0*)fEvent->GetV0(i); | |
06d06fbb | 603 | fSignedV0[i]=0; |
604 | } | |
605 | ||
606 | // | |
607 | // | |
608 | AliESDtrack * track=0; | |
609 | for (Int_t iEntry=0; iEntry<nEntries;iEntry++){ | |
06d06fbb | 610 | track = (AliESDtrack*)fEvent->GetTrack(iEntry); |
611 | // | |
612 | Int_t label = track->GetLabel(); | |
613 | Int_t absLabel = abs(label); | |
614 | if (absLabel < fNParticles) { | |
615 | // fIndexRecTracks[absLabel] = iEntry; | |
616 | if (label < 0) fFakeRecTracks[absLabel]++; | |
617 | if (fMultiRecTracks[absLabel]>0){ | |
618 | if (fMultiRecTracks[absLabel]<20) | |
619 | fIndexRecTracks[absLabel*20+fMultiRecTracks[absLabel]] = iEntry; | |
620 | } | |
621 | else | |
622 | fIndexRecTracks[absLabel*20] = iEntry; | |
623 | fMultiRecTracks[absLabel]++; | |
624 | } | |
625 | } | |
626 | // sort reconstructed kinks | |
627 | // | |
628 | AliESDkink * kink=0; | |
629 | for (Int_t iEntry=0; iEntry<nKinks;iEntry++){ | |
630 | kink = (AliESDkink*)fEvent->GetKink(iEntry); | |
631 | if (!kink) continue; | |
632 | // | |
633 | Int_t label0 = TMath::Abs(kink->GetLabel(0)); | |
634 | Int_t label1 = TMath::Abs(kink->GetLabel(1)); | |
635 | Int_t absLabel = TMath::Min(label0,label1); | |
636 | if (absLabel < fNParticles) { | |
637 | if (fMultiRecKinks[absLabel]>0){ | |
638 | if (fMultiRecKinks[absLabel]<20) | |
639 | fIndexRecKinks[absLabel*20+fMultiRecKinks[absLabel]] = iEntry; | |
640 | } | |
641 | else | |
642 | fIndexRecKinks[absLabel*20] = iEntry; | |
643 | fMultiRecKinks[absLabel]++; | |
644 | } | |
645 | } | |
646 | // --sort reconstructed V0 | |
647 | // | |
648 | // AliV0 * v0MI=0; | |
649 | // for (Int_t iEntry=0; iEntry<nV0MIs;iEntry++){ | |
650 | // v0MI = (AliV0*)fEvent->GetV0(iEntry); | |
651 | // if (!v0MI) continue; | |
652 | // // | |
653 | // Int_t label0 = TMath::Abs(v0MI->GetLabel(0)); | |
654 | // Int_t label1 = TMath::Abs(v0MI->GetLabel(1)); | |
655 | // // | |
656 | // for (Int_t i=0;i<2;i++){ | |
657 | // Int_t absLabel = TMath::Abs(v0MI->GetLabel(i)); | |
658 | // if (absLabel < fNParticles) { | |
659 | // if (fMultiRecV0[absLabel]>0){ | |
660 | // if (fMultiRecV0[absLabel]<20) | |
661 | // fIndexRecV0[absLabel*20+fMultiRecV0[absLabel]] = iEntry; | |
662 | // } | |
663 | // else | |
664 | // fIndexRecV0[absLabel*20] = iEntry; | |
665 | // fMultiRecV0[absLabel]++; | |
666 | // } | |
667 | // } | |
668 | // } | |
669 | ||
670 | ||
671 | printf("Time spended in TreeTLoop\n"); | |
672 | timer.Print(); | |
673 | ||
674 | if (fDebug > 2) cerr<<"end of TreeTLoop"<<endl; | |
675 | return 0; | |
676 | } | |
677 | ||
678 | //////////////////////////////////////////////////////////////////////// | |
679 | Int_t AliRecInfoMaker::TreeGenLoop(Int_t eventNr) | |
680 | { | |
681 | // | |
682 | // loop over all entries for a given event, find corresponding | |
683 | // rec. track and store in the fTreeCmp | |
684 | // | |
685 | TStopwatch timer; | |
686 | timer.Start(); | |
687 | Int_t entry = fNextTreeGenEntryToRead; | |
688 | Double_t nParticlesTR = fTreeGenTracks->GetEntriesFast(); | |
689 | cerr<<"fNParticles, nParticlesTR, fNextTreeGenEntryToRead: "<<fNParticles<<" " | |
690 | <<nParticlesTR<<" "<<fNextTreeGenEntryToRead<<endl; | |
691 | TBranch * branch = fTreeCmp->GetBranch("RC"); | |
692 | TBranch * branchF = fTreeCmp->GetBranch("F"); | |
693 | ||
694 | branch->SetAddress(&fRecInfo); // set all pointers | |
695 | fRecArray = new TObjArray(fNParticles); | |
696 | AliESDtrack dummytrack; // | |
697 | AliESDfriendTrack dummytrackF; // | |
698 | ||
699 | while (entry < nParticlesTR) { | |
700 | fTreeGenTracks->GetEntry(entry); | |
701 | entry++; | |
702 | if (eventNr < fMCInfo->fEventNr) continue; | |
703 | if (eventNr > fMCInfo->fEventNr) continue;; | |
704 | // | |
705 | fNextTreeGenEntryToRead = entry-1; | |
706 | if (fDebug > 2 && fMCInfo->fLabel < 10) { | |
707 | cerr<<"Fill track with a label "<<fMCInfo->fLabel<<endl; | |
708 | } | |
709 | // if (fMCInfo->fNTPCRef<1) continue; // not TPCref | |
710 | // | |
711 | fRecInfo->Reset(); | |
712 | AliESDtrack * track=0; | |
713 | fRecInfo->fReconstructed =0; | |
714 | TVector3 local = TR2Local(&(fMCInfo->fTrackRef),fParamTPC); | |
715 | local.GetXYZ(fRecInfo->fTRLocalCoord); | |
716 | // | |
717 | if (fIndexRecTracks[fMCInfo->fLabel*20] >= 0) { | |
06d06fbb | 718 | track= (AliESDtrack*)fEvent->GetTrack(fIndexRecTracks[fMCInfo->fLabel*20]); |
719 | // | |
720 | // | |
721 | // find nearest track if multifound | |
722 | //Int_t sign = Int_t(track->GetSign()*fMCInfo->fCharge); | |
723 | // | |
724 | Int_t status = 0; | |
725 | if ((track->GetStatus()&AliESDtrack::kITSrefit)>0) status++; | |
726 | if ((track->GetStatus()&AliESDtrack::kTPCrefit)>0) status++; | |
727 | if ((track->GetStatus()&AliESDtrack::kTRDrefit)>0) status++; | |
728 | ||
729 | // | |
730 | if (fIndexRecTracks[fMCInfo->fLabel*20+1]>0){ | |
731 | // | |
732 | Double_t p[3]; | |
733 | track->GetInnerPxPyPz(p); | |
734 | Float_t maxp = p[0]*p[0]+p[1]*p[1]+p[2]*p[2]; | |
735 | // | |
736 | for (Int_t i=1;i<20;i++){ | |
737 | if (fIndexRecTracks[fMCInfo->fLabel*20+i]>=0){ | |
738 | AliESDtrack * track2 = (AliESDtrack*)fEvent->GetTrack(fIndexRecTracks[fMCInfo->fLabel*20+i]); | |
739 | if (!track2) continue; | |
740 | //Int_t sign2 = track->GetSign()*fMCInfo->fCharge; // | |
741 | //if (sign2<0) continue; | |
742 | track2->GetInnerPxPyPz(p); | |
743 | Float_t mom = p[0]*p[0]+p[1]*p[1]+p[2]*p[2]; | |
744 | /* | |
745 | if (sign<0){ | |
746 | sign = sign2; | |
747 | track = track2; | |
748 | maxp = mom; | |
749 | continue; | |
750 | } | |
751 | */ | |
752 | // | |
753 | Int_t status2 = 0; | |
754 | if ((track2->GetStatus()&AliESDtrack::kITSrefit)>0) status2++; | |
755 | if ((track2->GetStatus()&AliESDtrack::kTPCrefit)>0) status2++; | |
756 | if ((track2->GetStatus()&AliESDtrack::kTRDrefit)>0) status2++; | |
757 | if (status2<status) continue; | |
758 | // | |
759 | if (mom<maxp) continue; | |
760 | maxp = mom; | |
761 | track = track2; | |
762 | // | |
763 | } | |
764 | } | |
765 | } | |
766 | // | |
767 | if (track) { | |
768 | fRecInfo->SetESDtrack(track); | |
769 | }else{ | |
770 | fRecInfo->SetESDtrack(&dummytrack); | |
771 | } | |
772 | // | |
773 | ||
774 | fRecInfo->fReconstructed = 1; | |
775 | fRecInfo->fFake = fFakeRecTracks[fMCInfo->fLabel]; | |
776 | fRecInfo->fMultiple = fMultiRecTracks[fMCInfo->fLabel]; | |
777 | // | |
1a167b98 | 778 | fRecInfo->Update(fMCInfo,fParamTPC,kTRUE); |
06d06fbb | 779 | } |
780 | else{ | |
781 | fRecInfo->SetESDtrack(&dummytrack); | |
1a167b98 | 782 | fRecInfo->Update(fMCInfo,fParamTPC,kFALSE); |
06d06fbb | 783 | } |
784 | fRecArray->AddAt(new AliESDRecInfo(*fRecInfo),fMCInfo->fLabel); | |
785 | fTreeCmp->Fill(); | |
786 | } | |
787 | fTreeCmp->AutoSave(); | |
06d06fbb | 788 | printf("Time spended in TreeGenLoop\n"); |
789 | timer.Print(); | |
790 | if (fDebug > 2) cerr<<"end of TreeGenLoop"<<endl; | |
791 | ||
792 | return 0; | |
793 | } | |
794 | ||
795 | ||
796 | ||
797 | //////////////////////////////////////////////////////////////////////// | |
798 | //////////////////////////////////////////////////////////////////////// | |
799 | //////////////////////////////////////////////////////////////////////// | |
800 | Int_t AliRecInfoMaker::BuildKinkInfo0(Int_t eventNr) | |
801 | { | |
802 | // | |
803 | // loop over all entries for a given event, find corresponding | |
804 | // rec. track and store in the fTreeCmp | |
805 | // | |
806 | TStopwatch timer; | |
807 | timer.Start(); | |
808 | Int_t entry = fNextKinkToRead; | |
809 | Double_t nParticlesTR = fTreeGenKinks->GetEntriesFast(); | |
810 | cerr<<"fNParticles, nParticlesTR, fNextKinkToRead: "<<fNParticles<<" " | |
811 | <<nParticlesTR<<" "<<fNextKinkToRead<<endl; | |
812 | // | |
813 | TBranch * branch = fTreeCmpKinks->GetBranch("RC."); | |
814 | branch->SetAddress(&fRecKinkInfo); // set all pointers | |
815 | ||
816 | // | |
817 | while (entry < nParticlesTR) { | |
818 | fTreeGenKinks->GetEntry(entry); | |
819 | entry++; | |
820 | if (eventNr < fGenKinkInfo->GetMinus().fEventNr) continue; | |
821 | if (eventNr > fGenKinkInfo->GetMinus().fEventNr) continue;; | |
822 | // | |
823 | fNextKinkToRead = entry-1; | |
824 | // | |
825 | // | |
826 | AliESDRecInfo* fRecInfo1 = (AliESDRecInfo*)fRecArray->At(fGenKinkInfo->GetMinus().fLabel); | |
827 | AliESDRecInfo* fRecInfo2 = (AliESDRecInfo*)fRecArray->At(fGenKinkInfo->GetPlus().fLabel); | |
828 | fRecKinkInfo->fT1 = (*fRecInfo1); | |
829 | fRecKinkInfo->fT2 = (*fRecInfo2); | |
830 | fRecKinkInfo->fStatus =0; | |
831 | if (fRecInfo1 && fRecInfo1->fTPCOn) fRecKinkInfo->fStatus+=1; | |
832 | if (fRecInfo2 && fRecInfo2->fTPCOn) fRecKinkInfo->fStatus+=2; | |
833 | if (fRecKinkInfo->fStatus==3&&fRecInfo1->fSign!=fRecInfo2->fSign) fRecKinkInfo->fStatus*=-1; | |
834 | ||
835 | if (fRecKinkInfo->fStatus==3){ | |
836 | fRecKinkInfo->Update(); | |
837 | } | |
838 | Int_t label = TMath::Min(fGenKinkInfo->GetMinus().fLabel,fGenKinkInfo->GetPlus().fLabel); | |
839 | Int_t label2 = TMath::Max(fGenKinkInfo->GetMinus().fLabel,fGenKinkInfo->GetPlus().fLabel); | |
840 | ||
841 | AliESDkink *kink=0; | |
842 | fRecKinkInfo->fRecStatus =0; | |
843 | fRecKinkInfo->fMultiple = fMultiRecKinks[label]; | |
844 | fRecKinkInfo->fKinkMultiple=0; | |
845 | // | |
846 | if (fMultiRecKinks[label]>0){ | |
847 | ||
848 | // for (Int_t j=0;j<TMath::Min(fMultiRecKinks[label],100);j++){ | |
849 | for (Int_t j=TMath::Min(fMultiRecKinks[label],Short_t(20))-1;j>=0;j--){ | |
850 | Int_t index = fIndexRecKinks[label*20+j]; | |
851 | //AliESDkink *kink2 = (AliESDkink*)fKinks->At(index); | |
852 | AliESDkink *kink2 = (AliESDkink*)fEvent->GetKink(index); | |
853 | if (TMath::Abs(kink2->GetLabel(0))==label &&TMath::Abs(kink2->GetLabel(1))==label2) { | |
854 | fRecKinkInfo->fKinkMultiple++; | |
855 | fSignedKinks[index]=1; | |
856 | Int_t c0=0; | |
857 | if (kink){ | |
858 | // if (kink->fTRDOn) c0++; | |
859 | //if (kink->fITSOn) c0++; | |
860 | if (kink->GetStatus(2)>0) c0++; | |
861 | if (kink->GetStatus(0)>0) c0++; | |
862 | } | |
863 | Int_t c2=0; | |
864 | // if (kink2->fTRDOn) c2++; | |
865 | //if (kink2->fITSOn) c2++; | |
866 | if (kink2->GetStatus(2)>0) c2++; | |
867 | if (kink2->GetStatus(0)>0) c2++; | |
868 | ||
869 | if (c2<c0) continue; | |
870 | kink =kink2; | |
871 | } | |
872 | if (TMath::Abs(kink2->GetLabel(1))==label &&TMath::Abs(kink2->GetLabel(0))==label2) { | |
873 | fRecKinkInfo->fKinkMultiple++; | |
874 | fSignedKinks[index]=1; | |
875 | Int_t c0=0; | |
876 | if (kink){ | |
877 | //if (kink->fTRDOn) c0++; | |
878 | //if (kink->fITSOn) c0++; | |
879 | if (kink->GetStatus(2)>0) c0++; | |
880 | if (kink->GetStatus(0)>0) c0++; | |
881 | ||
882 | } | |
883 | Int_t c2=0; | |
884 | // if (kink2->fTRDOn) c2++; | |
885 | //if (kink2->fITSOn) c2++; | |
886 | if (kink2->GetStatus(2)>0) c2++; | |
887 | if (kink2->GetStatus(0)>0) c2++; | |
888 | ||
889 | if (c2<c0) continue; | |
890 | kink =kink2; | |
891 | } | |
892 | } | |
893 | } | |
894 | if (kink){ | |
895 | fRecKinkInfo->fKink = *kink; | |
896 | fRecKinkInfo->fRecStatus=1; | |
897 | } | |
898 | fTreeCmpKinks->Fill(); | |
899 | } | |
900 | // Int_t nkinks = fKinks->GetEntriesFast(); | |
901 | Int_t nkinks = fEvent->GetNumberOfKinks(); | |
902 | for (Int_t i=0;i<nkinks;i++){ | |
903 | if (fSignedKinks[i]==0){ | |
904 | // AliESDkink *kink = (AliESDkink*)fKinks->At(i); | |
905 | AliESDkink *kink = (AliESDkink*)fEvent->GetKink(i); | |
906 | if (!kink) continue; | |
907 | // | |
908 | fRecKinkInfo->fKink = *kink; | |
909 | fRecKinkInfo->fRecStatus =-2; | |
910 | // | |
911 | AliESDRecInfo* fRecInfo1 = (AliESDRecInfo*)fRecArray->At(TMath::Abs(kink->GetLabel(0))); | |
912 | AliESDRecInfo* fRecInfo2 = (AliESDRecInfo*)fRecArray->At(TMath::Abs(kink->GetLabel(1))); | |
913 | if (fRecInfo1 && fRecInfo2){ | |
914 | fRecKinkInfo->fT1 = (*fRecInfo1); | |
915 | fRecKinkInfo->fT2 = (*fRecInfo2); | |
916 | fRecKinkInfo->fRecStatus =-1; | |
917 | } | |
918 | fTreeCmpKinks->Fill(); | |
919 | } | |
920 | } | |
921 | ||
922 | ||
923 | fTreeCmpKinks->AutoSave(); | |
924 | printf("Time spended in BuilKinkInfo Loop\n"); | |
925 | timer.Print(); | |
926 | if (fDebug > 2) cerr<<"end of BuildKinkInfo Loop"<<endl; | |
927 | return 0; | |
928 | } | |
929 | ||
930 | ||
931 | ||
932 | //////////////////////////////////////////////////////////////////////// | |
933 | //////////////////////////////////////////////////////////////////////// | |
934 | //////////////////////////////////////////////////////////////////////// | |
935 | ||
936 | ||
937 | ||
938 | Int_t AliRecInfoMaker::BuildV0Info(Int_t eventNr) | |
939 | { | |
940 | // | |
941 | // loop over all entries for a given event, find corresponding | |
942 | // rec. track and store in the fTreeCmp | |
943 | // | |
944 | TStopwatch timer; | |
945 | timer.Start(); | |
946 | Int_t entry = fNextV0ToRead; | |
947 | Double_t nParticlesTR = fTreeGenV0->GetEntriesFast(); | |
948 | cerr<<"fNParticles, nParticlesTR, fNextV0ToRead: "<<fNParticles<<" " | |
949 | <<nParticlesTR<<" "<<fNextV0ToRead<<endl; | |
950 | // | |
951 | TBranch * branch = fTreeCmpV0->GetBranch("RC."); | |
952 | branch->SetAddress(&fRecV0Info); // set all pointers | |
953 | const AliESDVertex * esdvertex = fEvent->GetVertex(); | |
954 | Float_t vertex[3]= {esdvertex->GetXv(), esdvertex->GetYv(),esdvertex->GetZv()}; | |
955 | ||
956 | // | |
957 | while (entry < nParticlesTR) { | |
958 | fTreeGenV0->GetEntry(entry); | |
959 | entry++; | |
960 | if (eventNr < fGenV0Info->GetMinus().fEventNr) continue; | |
961 | if (eventNr > fGenV0Info->GetMinus().fEventNr) continue;; | |
962 | // | |
963 | fNextV0ToRead = entry-1; | |
964 | // | |
965 | // | |
966 | AliESDRecInfo* fRecInfo1 = (AliESDRecInfo*)fRecArray->At(fGenV0Info->GetMinus().fLabel); | |
967 | AliESDRecInfo* fRecInfo2 = (AliESDRecInfo*)fRecArray->At(fGenV0Info->GetPlus().fLabel); | |
968 | if (fGenV0Info->GetMinus().fCharge*fGenV0Info->GetPlus().fCharge>0) continue; // interactions | |
969 | if (!fRecInfo1 || !fRecInfo2) continue; | |
970 | fRecV0Info->fT1 = (*fRecInfo1); | |
971 | fRecV0Info->fT2 = (*fRecInfo2); | |
972 | fRecV0Info->fV0Status =0; | |
973 | if (fRecInfo1 && fRecInfo1->fStatus[1]>0) fRecV0Info->fV0Status+=1; | |
974 | if (fRecInfo2 && fRecInfo2->fStatus[1]>0) fRecV0Info->fV0Status+=2; | |
975 | ||
976 | if (fRecV0Info->fV0Status==3&&fRecInfo1->fSign==fRecInfo2->fSign) fRecV0Info->fV0Status*=-1; | |
977 | ||
978 | ||
979 | if (abs(fRecV0Info->fV0Status)==3){ | |
980 | fRecV0Info->Update(vertex); | |
981 | { | |
982 | // | |
983 | // TPC V0 Info | |
984 | Double_t x,alpha, param[5],cov[15]; | |
985 | if ( fRecV0Info->fT1.GetESDtrack()->GetInnerParam() && fRecV0Info->fT2.GetESDtrack()->GetInnerParam()){ | |
986 | fRecV0Info->fT1.GetESDtrack()->GetInnerExternalParameters(alpha,x,param); | |
987 | fRecV0Info->fT1.GetESDtrack()->GetInnerExternalCovariance(cov); | |
988 | AliExternalTrackParam paramP(x,alpha,param,cov); | |
989 | // | |
990 | fRecV0Info->fT2.GetESDtrack()->GetInnerExternalParameters(alpha,x,param); | |
991 | fRecV0Info->fT2.GetESDtrack()->GetInnerExternalCovariance(cov); | |
992 | AliExternalTrackParam paramM(x,alpha,param,cov); | |
993 | // | |
994 | fRecV0Info->fV0tpc->SetParamN(paramM); | |
995 | fRecV0Info->fV0tpc->SetParamP(paramP); | |
996 | Double_t pid1[5],pid2[5]; | |
997 | fRecV0Info->fT1.GetESDtrack()->GetESDpid(pid1); | |
998 | fRecV0Info->fT1.GetESDtrack()->GetESDpid(pid2); | |
999 | // | |
1000 | //fRecV0Info->fV0tpc.UpdatePID(pid1,pid2); | |
1001 | fRecV0Info->fV0tpc->Update(vertex); | |
1002 | ||
1003 | // | |
1004 | // | |
1005 | fRecV0Info->fT1.GetESDtrack()->GetExternalParameters(x,param); | |
1006 | fRecV0Info->fT1.GetESDtrack()->GetExternalCovariance(cov); | |
1007 | alpha = fRecV0Info->fT1.GetESDtrack()->GetAlpha(); | |
1008 | new (¶mP) AliExternalTrackParam(x,alpha,param,cov); | |
1009 | // | |
1010 | fRecV0Info->fT2.GetESDtrack()->GetExternalParameters(x,param); | |
1011 | fRecV0Info->fT2.GetESDtrack()->GetExternalCovariance(cov); | |
1012 | alpha = fRecV0Info->fT2.GetESDtrack()->GetAlpha(); | |
1013 | new (¶mM) AliExternalTrackParam(x,alpha,param,cov); | |
1014 | // | |
1015 | fRecV0Info->fV0its->SetParamN(paramM); | |
1016 | fRecV0Info->fV0its->SetParamP(paramP); | |
1017 | // fRecV0Info->fV0its.UpdatePID(pid1,pid2); | |
1018 | fRecV0Info->fV0its->Update(vertex); | |
1019 | } | |
1020 | } | |
1021 | if (TMath::Abs(fGenV0Info->GetMinus().fPdg)==11 &&TMath::Abs(fGenV0Info->GetPlus().fPdg)==11){ | |
1022 | if (fRecV0Info->fDist2>10){ | |
1023 | fRecV0Info->Update(vertex); | |
1024 | } | |
1025 | if (fRecV0Info->fDist2>10){ | |
1026 | fRecV0Info->Update(vertex); | |
1027 | } | |
1028 | } | |
1029 | } | |
1030 | // | |
1031 | // take the V0 from reconstruction | |
1032 | ||
1033 | Int_t label = TMath::Min(fGenV0Info->GetMinus().fLabel,fGenV0Info->GetPlus().fLabel); | |
1034 | Int_t label2 = TMath::Max(fGenV0Info->GetMinus().fLabel,fGenV0Info->GetPlus().fLabel); | |
1035 | AliV0 *v0MI=0; | |
1036 | fRecV0Info->fRecStatus =0; | |
1037 | fRecV0Info->fMultiple = fMultiRecV0[label]; | |
1038 | fRecV0Info->fV0Multiple=0; | |
1039 | // | |
1040 | if (fMultiRecV0[label]>0 || fMultiRecV0[label2]>0){ | |
1041 | ||
1042 | // for (Int_t j=0;j<TMath::Min(fMultiRecV0s[label],100);j++){ | |
1043 | // for (Int_t j=TMath::Min(fMultiRecV0[label],Short_t(20))-1;j>=0;j--){ | |
1044 | // Int_t index = fIndexRecV0[label*20+j]; | |
1045 | // if (index<0) continue; | |
1046 | // AliV0 *v0MI2 = (AliV0*)fEvent->GetV0(index); | |
1047 | // if (TMath::Abs(v0MI2->GetLabel(0))==label &&TMath::Abs(v0MI2->GetLabel(1))==label2) { | |
1048 | // v0MI =v0MI2; | |
1049 | // fRecV0Info->fV0Multiple++; | |
1050 | // fSignedV0[index]=1; | |
1051 | // } | |
1052 | // if (TMath::Abs(v0MI2->GetLabel(1))==label &&TMath::Abs(v0MI2->GetLabel(0))==label2) { | |
1053 | // v0MI =v0MI2; | |
1054 | // fRecV0Info->fV0Multiple++; | |
1055 | // fSignedV0[index]=1; | |
1056 | // } | |
1057 | // } | |
1058 | } | |
1059 | if (v0MI){ | |
1060 | fRecV0Info->fV0rec = v0MI; | |
1061 | fRecV0Info->fRecStatus=1; | |
1062 | } | |
1063 | ||
1064 | fTreeCmpV0->Fill(); | |
1065 | } | |
1066 | // | |
1067 | // write fake v0s | |
1068 | ||
1069 | Int_t nV0MIs = fEvent->GetNumberOfV0s(); | |
1070 | for (Int_t i=0;i<nV0MIs;i++){ | |
1071 | if (fSignedV0[i]==0){ | |
1072 | AliV0 *v0MI = (AliV0*)fEvent->GetV0(i); | |
1073 | if (!v0MI) continue; | |
1074 | // | |
1075 | fRecV0Info->fV0rec = v0MI; | |
1076 | fRecV0Info->fV0Status =-10; | |
1077 | fRecV0Info->fRecStatus =-2; | |
1078 | // | |
1079 | // AliESDRecInfo* fRecInfo1 = (AliESDRecInfo*)fRecArray->At(TMath::Abs(v0MI->GetLabel(0))); | |
1080 | // AliESDRecInfo* fRecInfo2 = (AliESDRecInfo*)fRecArray->At(TMath::Abs(v0MI->GetLabel(1))); | |
1081 | // if (fRecInfo1 && fRecInfo2){ | |
1082 | // fRecV0Info->fT1 = (*fRecInfo1); | |
1083 | // fRecV0Info->fT2 = (*fRecInfo2); | |
1084 | // fRecV0Info->fRecStatus =-1; | |
1085 | // } | |
1086 | fRecV0Info->Update(vertex); | |
1087 | fTreeCmpV0->Fill(); | |
1088 | } | |
1089 | } | |
1090 | ||
1091 | ||
1092 | ||
1093 | fTreeCmpV0->AutoSave(); | |
1094 | printf("Time spended in BuilV0Info Loop\n"); | |
1095 | timer.Print(); | |
1096 | if (fDebug > 2) cerr<<"end of BuildV0Info Loop"<<endl; | |
1097 | return 0; | |
1098 | } | |
1099 | //////////////////////////////////////////////////////////////////////// | |
1100 | //////////////////////////////////////////////////////////////////////// | |
1101 | ||
1102 |