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