]>
Commit | Line | Data |
---|---|---|
1ee39b3a | 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 | /* $Id: AliTRDinfoGen.cxx 27496 2008-07-22 08:35:45Z cblume $ */ | |
17 | ||
18 | //////////////////////////////////////////////////////////////////////////// | |
19 | // | |
20 | // Tender wagon for TRD performance/calibration train | |
21 | // | |
22 | // In this wagon the information from | |
23 | // - ESD | |
24 | // - Friends [if available] | |
25 | // - MC [if available] | |
26 | // are grouped into AliTRDtrackInfo objects and fed to worker tasks | |
27 | // | |
28 | // Authors: | |
29 | // Markus Fasel <M.Fasel@gsi.de> | |
30 | // Alexandru Bercuci <A.Bercuci@gsi.de> | |
31 | // | |
32 | //////////////////////////////////////////////////////////////////////////// | |
33 | ||
34 | #include <TClonesArray.h> | |
35 | #include <TObjArray.h> | |
36 | #include <TObject.h> | |
705f8b0a | 37 | #include <TString.h> |
1ee39b3a | 38 | #include <TH1F.h> |
39 | #include <TFile.h> | |
40 | #include <TTree.h> | |
41 | #include <TROOT.h> | |
42 | #include <TChain.h> | |
43 | #include <TParticle.h> | |
44 | ||
45 | #include "AliLog.h" | |
46 | #include "AliAnalysisManager.h" | |
47 | #include "AliESDEvent.h" | |
48 | #include "AliMCEvent.h" | |
49 | #include "AliESDInputHandler.h" | |
50 | #include "AliMCEventHandler.h" | |
51 | ||
52 | #include "AliESDfriend.h" | |
53 | #include "AliESDfriendTrack.h" | |
54 | #include "AliESDHeader.h" | |
55 | #include "AliESDtrack.h" | |
07ece31c | 56 | #include "AliESDtrackCuts.h" |
1ee39b3a | 57 | #include "AliMCParticle.h" |
58 | #include "AliPID.h" | |
59 | #include "AliStack.h" | |
60 | #include "AliTRDtrackV1.h" | |
61 | #include "AliTrackReference.h" | |
62 | #include "AliTRDgeometry.h" | |
63 | #include "AliTRDcluster.h" | |
64 | #include "AliTRDseedV1.h" | |
65 | #include "TTreeStream.h" | |
66 | ||
67 | #include <cstdio> | |
68 | #include <climits> | |
69 | #include <cstring> | |
70 | #include <iostream> | |
71 | ||
72 | #include "AliTRDinfoGen.h" | |
73 | #include "info/AliTRDtrackInfo.h" | |
74 | #include "info/AliTRDeventInfo.h" | |
75 | #include "info/AliTRDv0Info.h" | |
07ece31c | 76 | #include "info/AliTRDeventCuts.h" |
705f8b0a | 77 | #include "macros/AliTRDperformanceTrain.h" |
1ee39b3a | 78 | |
79 | ClassImp(AliTRDinfoGen) | |
80 | ||
3d2a3dff | 81 | const Float_t AliTRDinfoGen::fgkITS = 100.; // to be checked |
1ee39b3a | 82 | const Float_t AliTRDinfoGen::fgkTPC = 290.; |
3d2a3dff | 83 | const Float_t AliTRDinfoGen::fgkTRD = 365.; |
1ee39b3a | 84 | |
3f19c2cd | 85 | const Float_t AliTRDinfoGen::fgkEvVertexZ = 15.; |
86 | const Int_t AliTRDinfoGen::fgkEvVertexN = 1; | |
87 | ||
88 | const Float_t AliTRDinfoGen::fgkTrkDCAxy = 40.; | |
89 | const Float_t AliTRDinfoGen::fgkTrkDCAz = 15.; | |
81979445 | 90 | const Int_t AliTRDinfoGen::fgkNclTPC = 100; |
3f19c2cd | 91 | const Float_t AliTRDinfoGen::fgkPt = 0.2; |
92 | const Float_t AliTRDinfoGen::fgkEta = 0.9; | |
93 | ||
1ee39b3a | 94 | //____________________________________________________________________ |
db99a57a | 95 | AliTRDinfoGen::AliTRDinfoGen() |
705f8b0a | 96 | :AliAnalysisTaskSE() |
97 | ,fEvTrigger(NULL) | |
770382d9 | 98 | ,fESDev(NULL) |
99 | ,fMCev(NULL) | |
705f8b0a | 100 | ,fEventCut(NULL) |
101 | ,fTrackCut(NULL) | |
770382d9 | 102 | ,fTrackInfo(NULL) |
103 | ,fEventInfo(NULL) | |
770382d9 | 104 | ,fV0Info(NULL) |
705f8b0a | 105 | ,fTracksBarrel(NULL) |
106 | ,fTracksSA(NULL) | |
107 | ,fTracksKink(NULL) | |
108 | ,fV0List(NULL) | |
109 | ,fDebugStream(NULL) | |
1ee39b3a | 110 | { |
111 | // | |
112 | // Default constructor | |
113 | // | |
f2e89a4c | 114 | SetNameTitle("infoGen", "MC-REC TRD-track list generator"); |
f8f46e4d | 115 | } |
1ee39b3a | 116 | |
07ece31c | 117 | //____________________________________________________________________ |
db99a57a | 118 | AliTRDinfoGen::AliTRDinfoGen(char* name) |
705f8b0a | 119 | :AliAnalysisTaskSE(name) |
120 | ,fEvTrigger(NULL) | |
f8f46e4d | 121 | ,fESDev(NULL) |
122 | ,fMCev(NULL) | |
705f8b0a | 123 | ,fEventCut(NULL) |
124 | ,fTrackCut(NULL) | |
f8f46e4d | 125 | ,fTrackInfo(NULL) |
126 | ,fEventInfo(NULL) | |
f8f46e4d | 127 | ,fV0Info(NULL) |
705f8b0a | 128 | ,fTracksBarrel(NULL) |
129 | ,fTracksSA(NULL) | |
130 | ,fTracksKink(NULL) | |
131 | ,fV0List(NULL) | |
132 | ,fDebugStream(NULL) | |
f8f46e4d | 133 | { |
134 | // | |
135 | // Default constructor | |
136 | // | |
705f8b0a | 137 | SetTitle("MC-REC TRD-track list generator"); |
138 | DefineOutput(kTracksBarrel, TObjArray::Class()); | |
139 | DefineOutput(kTracksSA, TObjArray::Class()); | |
140 | DefineOutput(kTracksKink, TObjArray::Class()); | |
141 | DefineOutput(kEventInfo, AliTRDeventInfo::Class()); | |
142 | DefineOutput(kV0List, TObjArray::Class()); | |
1ee39b3a | 143 | } |
144 | ||
145 | //____________________________________________________________________ | |
146 | AliTRDinfoGen::~AliTRDinfoGen() | |
147 | { | |
148 | // Destructor | |
705f8b0a | 149 | |
0205fb04 | 150 | if(fDebugStream) delete fDebugStream; |
705f8b0a | 151 | if(fEvTrigger) delete fEvTrigger; |
07ece31c | 152 | if(fTrackCut) delete fTrackCut; |
153 | if(fEventCut) delete fEventCut; | |
770382d9 | 154 | if(fTrackInfo) delete fTrackInfo; fTrackInfo = NULL; |
770382d9 | 155 | if(fEventInfo) delete fEventInfo; fEventInfo = NULL; |
770382d9 | 156 | if(fV0Info) delete fV0Info; fV0Info = NULL; |
705f8b0a | 157 | if(fTracksBarrel){ |
158 | fTracksBarrel->Delete(); delete fTracksBarrel; | |
159 | fTracksBarrel = NULL; | |
160 | } | |
161 | if(fTracksSA){ | |
162 | fTracksSA->Delete(); delete fTracksSA; | |
163 | fTracksSA = NULL; | |
1ee39b3a | 164 | } |
705f8b0a | 165 | if(fTracksKink){ |
166 | fTracksKink->Delete(); delete fTracksKink; | |
167 | fTracksKink = NULL; | |
168 | } | |
169 | if(fV0List){ | |
170 | fV0List->Delete(); delete fV0List; | |
171 | fV0List = NULL; | |
1ee39b3a | 172 | } |
173 | } | |
174 | ||
175 | //____________________________________________________________________ | |
f8f46e4d | 176 | void AliTRDinfoGen::UserCreateOutputObjects() |
1ee39b3a | 177 | { |
178 | // | |
179 | // Create Output Containers (TObjectArray containing 1D histograms) | |
180 | // | |
b4414720 | 181 | |
1ee39b3a | 182 | fTrackInfo = new AliTRDtrackInfo(); |
183 | fEventInfo = new AliTRDeventInfo(); | |
184 | fV0Info = new AliTRDv0Info(); | |
705f8b0a | 185 | fTracksBarrel = new TObjArray(200); fTracksBarrel->SetOwner(kTRUE); |
186 | fTracksSA = new TObjArray(20); fTracksSA->SetOwner(kTRUE); | |
187 | fTracksKink = new TObjArray(20); fTracksKink->SetOwner(kTRUE); | |
188 | fV0List = new TObjArray(10); fV0List->SetOwner(kTRUE); | |
1ee39b3a | 189 | } |
190 | ||
191 | //____________________________________________________________________ | |
f8f46e4d | 192 | void AliTRDinfoGen::UserExec(Option_t *){ |
1ee39b3a | 193 | // |
194 | // Run the Analysis | |
195 | // | |
f2e89a4c | 196 | |
f8f46e4d | 197 | fESDev = dynamic_cast<AliESDEvent*>(InputEvent()); |
198 | fMCev = MCEvent(); | |
199 | ||
1ee39b3a | 200 | if(!fESDev){ |
201 | AliError("Failed retrieving ESD event"); | |
202 | return; | |
203 | } | |
3f19c2cd | 204 | |
205 | // event selection : trigger cut | |
705f8b0a | 206 | if(UseLocalEvSelection() && fEvTrigger){ |
3f19c2cd | 207 | Bool_t kTRIGGERED(kFALSE); |
705f8b0a | 208 | const TObjArray *trig = fEvTrigger->Tokenize(" "); |
3f19c2cd | 209 | for(Int_t itrig=trig->GetEntriesFast(); itrig--;){ |
210 | const Char_t *trigClass(((TObjString*)(*trig)[itrig])->GetName()); | |
211 | if(fESDev->IsTriggerClassFired(trigClass)) { | |
212 | AliDebug(2, Form("Ev[%4d] Trigger[%s]", fESDev->GetEventNumberInFile(), trigClass)); | |
213 | kTRIGGERED = kTRUE; | |
214 | break; | |
215 | } | |
216 | } | |
55d5090e | 217 | if(!kTRIGGERED){ |
218 | AliDebug(2, Form("Reject Ev[%4d] Trigger", fESDev->GetEventNumberInFile())); | |
219 | return; | |
220 | } | |
3f19c2cd | 221 | // select only physical events |
55d5090e | 222 | if(fESDev->GetEventType() != 7){ |
223 | AliDebug(2, Form("Reject Ev[%4d] EvType[%d]", fESDev->GetEventNumberInFile(), fESDev->GetEventType())); | |
224 | return; | |
225 | } | |
3f19c2cd | 226 | } |
227 | ||
228 | // if the required trigger is a collision trigger then apply event vertex cut | |
229 | if(UseLocalEvSelection() && IsCollision()){ | |
230 | const AliESDVertex *vertex = fESDev->GetPrimaryVertex(); | |
231 | if(TMath::Abs(vertex->GetZv())<1.e-10 || | |
232 | TMath::Abs(vertex->GetZv())>fgkEvVertexZ || | |
233 | vertex->GetNContributors()<fgkEvVertexN) { | |
55d5090e | 234 | AliDebug(2, Form("Reject Ev[%4d] Vertex Zv[%f] Nv[%d]", fESDev->GetEventNumberInFile(), TMath::Abs(vertex->GetZv()), vertex->GetNContributors())); |
3f19c2cd | 235 | return; |
236 | } | |
237 | } | |
238 | ||
07ece31c | 239 | if(fEventCut && !fEventCut->IsSelected(fESDev, IsCollision())) return; |
240 | ||
1ee39b3a | 241 | if(!fESDfriend){ |
242 | AliError("Failed retrieving ESD friend event"); | |
243 | return; | |
244 | } | |
245 | if(HasMCdata() && !fMCev){ | |
246 | AliError("Failed retrieving MC event"); | |
247 | return; | |
248 | } | |
f8f46e4d | 249 | |
705f8b0a | 250 | fTracksBarrel->Delete(); |
251 | fTracksSA->Delete(); | |
252 | fTracksKink->Delete(); | |
253 | fV0List->Delete(); | |
1ee39b3a | 254 | fEventInfo->Delete(""); |
1ee39b3a | 255 | new(fEventInfo)AliTRDeventInfo(fESDev->GetHeader(), const_cast<AliESDRun *>(fESDev->GetESDRun())); |
256 | ||
770382d9 | 257 | Bool_t *trackMap(NULL); |
258 | AliStack * mStack(NULL); | |
1ee39b3a | 259 | Int_t nTracksMC = HasMCdata() ? fMCev->GetNumberOfTracks() : 0, nTracksESD = fESDev->GetNumberOfTracks(); |
260 | if(HasMCdata()){ | |
261 | mStack = fMCev->Stack(); | |
262 | if(!mStack){ | |
263 | AliError("Failed retrieving MC Stack"); | |
264 | return; | |
265 | } | |
266 | trackMap = new Bool_t[nTracksMC]; | |
267 | memset(trackMap, 0, sizeof(Bool_t) * nTracksMC); | |
268 | } | |
269 | ||
f232df0d | 270 | Double32_t dedx[100]; Int_t nSlices(0); |
3d2a3dff | 271 | Int_t nTRDout(0), nTRDin(0), nTPC(0) |
272 | ,nclsTrklt | |
273 | ,nBarrel(0), nSA(0), nKink(0) | |
274 | ,nBarrelMC(0), nSAMC(0), nKinkMC(0); | |
770382d9 | 275 | AliESDtrack *esdTrack = NULL; |
276 | AliESDfriendTrack *esdFriendTrack = NULL; | |
277 | TObject *calObject = NULL; | |
278 | AliTRDtrackV1 *track = NULL; | |
279 | AliTRDseedV1 *tracklet = NULL; | |
280 | AliTRDcluster *cl = NULL; | |
1ee39b3a | 281 | for(Int_t itrk = 0; itrk < nTracksESD; itrk++){ |
282 | esdTrack = fESDev->GetTrack(itrk); | |
283 | AliDebug(3, Form("\n%3d ITS[%d] TPC[%d] TRD[%d]\n", itrk, esdTrack->GetNcls(0), esdTrack->GetNcls(1), esdTrack->GetNcls(2))); | |
3f19c2cd | 284 | |
770382d9 | 285 | if(esdTrack->GetStatus()&AliESDtrack::kTPCout) nTPC++; |
286 | if(esdTrack->GetStatus()&AliESDtrack::kTRDout) nTRDout++; | |
287 | if(esdTrack->GetStatus()&AliESDtrack::kTRDin) nTRDin++; | |
1ee39b3a | 288 | |
289 | // look at external track param | |
290 | const AliExternalTrackParam *op = esdTrack->GetOuterParam(); | |
291 | Double_t xyz[3]; | |
292 | if(op){ | |
293 | op->GetXYZ(xyz); | |
294 | op->Global2LocalPosition(xyz, op->GetAlpha()); | |
295 | AliDebug(3, Form("op @ X[%7.3f]\n", xyz[0])); | |
296 | } | |
297 | ||
298 | // read MC info | |
299 | Int_t fPdg = -1; | |
300 | Int_t label = -1; UInt_t alab=UINT_MAX; | |
301 | if(HasMCdata()){ | |
302 | label = esdTrack->GetLabel(); | |
303 | alab = TMath::Abs(label); | |
304 | // register the track | |
305 | if(alab < UInt_t(nTracksMC)){ | |
306 | trackMap[alab] = kTRUE; | |
307 | } else { | |
308 | AliError(Form("MC label[%d] outside scope for Ev[%d] Trk[%d].", label, (Int_t)AliAnalysisManager::GetAnalysisManager()->GetCurrentEntry(), itrk)); | |
309 | continue; | |
310 | } | |
770382d9 | 311 | AliMCParticle *mcParticle = NULL; |
1ee39b3a | 312 | if(!(mcParticle = (AliMCParticle*) fMCev->GetTrack(alab))){ |
313 | AliError(Form("MC particle label[%d] missing for Ev[%d] Trk[%d].", label, (Int_t)AliAnalysisManager::GetAnalysisManager()->GetCurrentEntry(), itrk)); | |
314 | continue; | |
315 | } | |
316 | fPdg = mcParticle->Particle()->GetPdgCode(); | |
317 | Int_t nRefs = mcParticle->GetNumberOfTrackReferences(); | |
770382d9 | 318 | Int_t iref = 0; AliTrackReference *ref = NULL; |
1ee39b3a | 319 | while(iref<nRefs){ |
320 | ref = mcParticle->GetTrackReference(iref); | |
321 | if(ref->LocalX() > fgkTPC) break; | |
322 | iref++; | |
323 | } | |
324 | ||
325 | new(fTrackInfo) AliTRDtrackInfo(); | |
326 | fTrackInfo->SetPDG(fPdg); | |
327 | fTrackInfo->SetPrimary(mcParticle->Particle()->IsPrimary()); | |
328 | Int_t jref = iref;//, kref = 0; | |
329 | while(jref<nRefs){ | |
330 | ref = mcParticle->GetTrackReference(jref); | |
3d2a3dff | 331 | if(ref->LocalX() > fgkTRD) break; |
1ee39b3a | 332 | AliDebug(4, Form(" trackRef[%2d (%2d)] @ %7.3f OK", jref-iref, jref, ref->LocalX())); |
333 | fTrackInfo->AddTrackRef(ref); | |
334 | jref++; | |
335 | } | |
336 | AliDebug(3, Form("NtrackRefs[%d(%d)]", fTrackInfo->GetNTrackRefs(), nRefs)); | |
337 | } else { | |
338 | new (fTrackInfo) AliTRDtrackInfo(); | |
339 | fTrackInfo->SetPDG(fPdg); | |
340 | } | |
341 | ||
342 | // copy some relevant info to TRD track info | |
343 | fTrackInfo->SetStatus(esdTrack->GetStatus()); | |
344 | fTrackInfo->SetTrackId(esdTrack->GetID()); | |
345 | Double_t p[AliPID::kSPECIES]; esdTrack->GetTRDpid(p); | |
346 | fTrackInfo->SetESDpid(p); | |
347 | fTrackInfo->SetESDpidQuality(esdTrack->GetTRDntrackletsPID()); | |
f232df0d | 348 | if(!nSlices) nSlices = esdTrack->GetNumberOfTRDslices(); |
349 | memset(dedx, 0, 100*sizeof(Double32_t)); | |
92c40e64 | 350 | Int_t in(0); |
351 | for(Int_t il=0; il<AliTRDgeometry::kNlayer; il++) | |
352 | for(Int_t is=0; is<nSlices; is++) | |
353 | dedx[in++]=esdTrack->GetTRDslice(il, is); | |
354 | for(Int_t il=0; il<AliTRDgeometry::kNlayer; il++) dedx[in++]=esdTrack->GetTRDmomentum(il); | |
355 | fTrackInfo->SetSlices(in, dedx); | |
1ee39b3a | 356 | fTrackInfo->SetLabel(label); |
357 | fTrackInfo->SetNumberOfClustersRefit(esdTrack->GetNcls(2)); | |
358 | // some other Informations which we may wish to store in order to find problematic cases | |
359 | fTrackInfo->SetKinkIndex(esdTrack->GetKinkIndex(0)); | |
360 | fTrackInfo->SetTPCncls(static_cast<UShort_t>(esdTrack->GetNcls(1))); | |
361 | nclsTrklt = 0; | |
362 | ||
363 | ||
364 | // read REC info | |
365 | esdFriendTrack = fESDfriend->GetTrack(itrk); | |
366 | if(esdFriendTrack){ | |
367 | Int_t icalib = 0; | |
368 | while((calObject = esdFriendTrack->GetCalibObject(icalib++))){ | |
369 | if(strcmp(calObject->IsA()->GetName(),"AliTRDtrackV1") != 0) continue; // Look for the TRDtrack | |
370 | if(!(track = dynamic_cast<AliTRDtrackV1*>(calObject))) break; | |
1ee39b3a | 371 | AliDebug(4, Form("TRD track OK")); |
372 | // Set the clusters to unused | |
373 | for(Int_t ipl = 0; ipl < AliTRDgeometry::kNlayer; ipl++){ | |
374 | if(!(tracklet = track->GetTracklet(ipl))) continue; | |
375 | tracklet->ResetClusterIter(); | |
376 | while((cl = tracklet->NextCluster())) cl->Use(0); | |
377 | } | |
378 | fTrackInfo->SetTrack(track); | |
379 | break; | |
380 | } | |
381 | AliDebug(3, Form("Ntracklets[%d]\n", fTrackInfo->GetNTracklets())); | |
382 | } else AliDebug(3, "No ESD friends"); | |
383 | if(op) fTrackInfo->SetOuterParam(op); | |
384 | ||
385 | if(DebugLevel() >= 1){ | |
386 | AliTRDtrackInfo info(*fTrackInfo); | |
387 | (*DebugStream()) << "trackInfo" | |
388 | << "TrackInfo.=" << &info | |
389 | << "\n"; | |
390 | info.Delete(""); | |
391 | } | |
705f8b0a | 392 | |
393 | ULong_t status(esdTrack->GetStatus()); | |
394 | if((status&AliESDtrack::kTPCout)){ | |
395 | if(!esdTrack->GetKinkIndex(0)){ // Barrel Track Selection | |
396 | Bool_t selected(kTRUE); | |
397 | if(UseLocalTrkSelection()){ | |
55d5090e | 398 | if(esdTrack->Pt() < fgkPt){ |
399 | AliDebug(2, Form("Reject Ev[%4d] Trk[%3d] Pt[%5.2f]", fESDev->GetEventNumberInFile(), itrk, esdTrack->Pt())); | |
400 | selected = kFALSE; | |
401 | } | |
402 | if(TMath::Abs(esdTrack->Eta()) > fgkEta){ | |
403 | AliDebug(2, Form("Reject Ev[%4d] Trk[%3d] Eta[%5.2f]", fESDev->GetEventNumberInFile(), itrk, TMath::Abs(esdTrack->Eta()))); | |
404 | selected = kFALSE; | |
405 | } | |
406 | if(esdTrack->GetTPCNcls() < fgkNclTPC){ | |
407 | AliDebug(2, Form("Reject Ev[%4d] Trk[%3d] NclTPC[%d]", fESDev->GetEventNumberInFile(), itrk, esdTrack->GetTPCNcls())); | |
408 | selected = kFALSE; | |
409 | } | |
705f8b0a | 410 | Float_t par[2], cov[3]; |
411 | esdTrack->GetImpactParameters(par, cov); | |
412 | if(IsCollision()){ // cuts on DCA | |
55d5090e | 413 | if(TMath::Abs(par[0]) > fgkTrkDCAxy){ |
414 | AliDebug(2, Form("Reject Ev[%4d] Trk[%3d] DCAxy[%f]", fESDev->GetEventNumberInFile(), itrk, TMath::Abs(par[0]))); | |
415 | selected = kFALSE; | |
416 | } | |
417 | if(TMath::Abs(par[1]) > fgkTrkDCAz){ | |
418 | AliDebug(2, Form("Reject Ev[%4d] Trk[%3d] DCAz[%f]", fESDev->GetEventNumberInFile(), itrk, TMath::Abs(par[1]))); | |
419 | selected = kFALSE; | |
420 | } | |
705f8b0a | 421 | } |
422 | } | |
423 | if(fTrackCut && !fTrackCut->IsSelected(esdTrack)) selected = kFALSE; | |
3d2a3dff | 424 | if(selected){ |
425 | fTracksBarrel->Add(new AliTRDtrackInfo(*fTrackInfo)); | |
426 | nBarrel++; | |
427 | } | |
428 | } else { | |
429 | fTracksKink->Add(new AliTRDtrackInfo(*fTrackInfo)); | |
430 | nKink++; | |
431 | } | |
432 | } else if((status&AliESDtrack::kTRDout) && !(status&AliESDtrack::kTRDin)){ | |
433 | fTracksSA->Add(new AliTRDtrackInfo(*fTrackInfo)); | |
434 | nSA++; | |
435 | } | |
1ee39b3a | 436 | fTrackInfo->Delete(""); |
437 | } | |
1ee39b3a | 438 | |
770382d9 | 439 | // AliESDv0 *v0 = NULL; |
1ee39b3a | 440 | // for(Int_t iv0=0; iv0<fESD->GetNumberOfV0s(); iv0++){ |
441 | // if(!(v0 = fESD->GetV0(iv0))) continue; | |
705f8b0a | 442 | // fV0List->Add(new AliTRDv0Info(v0)); |
1ee39b3a | 443 | // } |
444 | ||
445 | // Insert also MC tracks which are passing TRD where the track is not reconstructed | |
446 | if(HasMCdata()){ | |
447 | AliDebug(10, "Output of the MC track map:"); | |
448 | for(Int_t itk = 0; itk < nTracksMC; itk++) AliDebug(10, Form("trackMap[%d] = %s", itk, trackMap[itk] == kTRUE ? "TRUE" : "kFALSE")); | |
449 | ||
450 | for(Int_t itk = 0; itk < nTracksMC; itk++){ | |
451 | if(trackMap[itk]) continue; | |
452 | AliMCParticle *mcParticle = (AliMCParticle*) fMCev->GetTrack(TMath::Abs(itk)); | |
453 | Int_t fPdg = mcParticle->Particle()->GetPdgCode(); | |
454 | Int_t nRefs = mcParticle->GetNumberOfTrackReferences(); | |
770382d9 | 455 | Int_t iref = 0; AliTrackReference *ref = NULL; |
1ee39b3a | 456 | Int_t nRefsTRD = 0; |
457 | new(fTrackInfo) AliTRDtrackInfo(); | |
458 | fTrackInfo->SetPDG(fPdg); | |
3d2a3dff | 459 | while(iref<nRefs){ // count TRD TR |
770382d9 | 460 | Bool_t kIN(kFALSE); |
1ee39b3a | 461 | ref = mcParticle->GetTrackReference(iref); |
3d2a3dff | 462 | if(ref->LocalX() > fgkTPC && ref->LocalX() < fgkTRD){ |
1ee39b3a | 463 | fTrackInfo->AddTrackRef(ref); |
770382d9 | 464 | nRefsTRD++;kIN=kTRUE; |
1ee39b3a | 465 | } |
770382d9 | 466 | AliDebug(4, Form(" trackRef[%2d] @ x[%7.3f] %s", iref, ref->LocalX(), kIN?"IN":"OUT")); |
1ee39b3a | 467 | iref++; |
468 | } | |
469 | if(!nRefsTRD){ | |
470 | // In this stage we at least require 1 hit inside TRD. What will be done with this tracks is a task for the | |
471 | // analysis job | |
472 | fTrackInfo->Delete(""); | |
473 | continue; | |
474 | } | |
475 | fTrackInfo->SetPrimary(mcParticle->Particle()->IsPrimary()); | |
476 | fTrackInfo->SetLabel(itk); | |
477 | if(DebugLevel() >= 1){ | |
478 | AliTRDtrackInfo info(*fTrackInfo); | |
479 | (*DebugStream()) << "trackInfo" | |
480 | << "TrackInfo.=" << &info | |
481 | << "\n"; | |
482 | info.Delete(""); | |
483 | } | |
770382d9 | 484 | AliDebug(3, Form("Add MC track @ label[%d] nTRDrefs[%d].", itk, nRefsTRD)); |
3d2a3dff | 485 | // check where the track starts |
486 | ref = mcParticle->GetTrackReference(0); | |
487 | if(ref->LocalX() < fgkITS){ | |
488 | fTracksBarrel->Add(new AliTRDtrackInfo(*fTrackInfo)); | |
489 | nBarrelMC++; | |
490 | } else if(ref->LocalX() < fgkTPC) { | |
491 | fTracksKink->Add(new AliTRDtrackInfo(*fTrackInfo)); | |
492 | nKinkMC++; | |
493 | } else if(nRefsTRD>6){ | |
494 | fTracksSA->Add(new AliTRDtrackInfo(*fTrackInfo)); | |
495 | nSAMC++; | |
496 | } | |
1ee39b3a | 497 | fTrackInfo->Delete(""); |
498 | } | |
499 | delete[] trackMap; | |
500 | } | |
3d2a3dff | 501 | AliDebug(2, Form( |
502 | "\nEv[%3d] Tracks: ESD[%d] MC[%d]\n" | |
503 | " TPCout[%d] TRDin[%d] TRDout[%d]\n" | |
504 | " Barrel[%3d+%3d=%3d] SA[%2d+%2d=%2d] Kink[%2d+%2d=%2d]" | |
505 | ,(Int_t)AliAnalysisManager::GetAnalysisManager()->GetCurrentEntry(), nTracksESD, nTracksMC | |
506 | , nTPC, nTRDin, nTRDout | |
507 | ,nBarrel, nBarrelMC, fTracksBarrel->GetEntries() | |
508 | ,nSA, nSAMC, fTracksSA->GetEntries() | |
509 | ,nKink, nKinkMC, fTracksKink->GetEntries() | |
510 | )); | |
511 | ||
705f8b0a | 512 | PostData(kTracksBarrel, fTracksBarrel); |
513 | PostData(kTracksSA, fTracksSA); | |
514 | PostData(kTracksKink, fTracksKink); | |
515 | PostData(kEventInfo, fEventInfo); | |
516 | PostData(kV0List, fV0List); | |
517 | } | |
518 | ||
519 | //____________________________________________________________________ | |
520 | void AliTRDinfoGen::SetTrigger(const Char_t *trigger) | |
521 | { | |
522 | if(!fEvTrigger) fEvTrigger = new TString(trigger); | |
523 | else (*fEvTrigger) = trigger; | |
524 | } | |
525 | ||
526 | //____________________________________________________________________ | |
527 | TTreeSRedirector* AliTRDinfoGen::DebugStream() | |
528 | { | |
529 | if(!fDebugStream){ | |
530 | TDirectory *savedir = gDirectory; | |
531 | fDebugStream = new TTreeSRedirector("TRD.DebugInfoGen.root"); | |
532 | savedir->cd(); | |
533 | } | |
534 | return fDebugStream; | |
1ee39b3a | 535 | } |
536 | ||
705f8b0a | 537 |