]>
Commit | Line | Data |
---|---|---|
814ecea4 | 1 | /************************************************************************** |
d2381af5 | 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 | **************************************************************************/ | |
814ecea4 | 15 | |
873458ab | 16 | /* $Id: AliTRDinfoGen.cxx 27496 2008-07-22 08:35:45Z cblume $ */ |
814ecea4 | 17 | |
18 | //////////////////////////////////////////////////////////////////////////// | |
dad3aa6b | 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 | // | |
814ecea4 | 32 | //////////////////////////////////////////////////////////////////////////// |
33 | ||
34 | #include <TClonesArray.h> | |
35 | #include <TObjArray.h> | |
36 | #include <TObject.h> | |
37 | #include <TH1F.h> | |
38 | #include <TFile.h> | |
39 | #include <TTree.h> | |
40 | #include <TROOT.h> | |
41 | #include <TChain.h> | |
42 | #include <TParticle.h> | |
43 | ||
44 | #include "AliLog.h" | |
45 | #include "AliAnalysisManager.h" | |
46 | #include "AliESDEvent.h" | |
47 | #include "AliMCEvent.h" | |
48 | #include "AliESDInputHandler.h" | |
49 | #include "AliMCEventHandler.h" | |
50 | ||
51 | #include "AliESDfriend.h" | |
52 | #include "AliESDfriendTrack.h" | |
a24151d1 | 53 | #include "AliESDHeader.h" |
814ecea4 | 54 | #include "AliESDtrack.h" |
55 | #include "AliMCParticle.h" | |
c46a7947 | 56 | #include "AliPID.h" |
814ecea4 | 57 | #include "AliStack.h" |
58 | #include "AliTRDtrackV1.h" | |
59 | #include "AliTrackReference.h" | |
60 | #include "AliTRDgeometry.h" | |
5c6b33ff | 61 | #include "AliTRDcluster.h" |
62 | #include "AliTRDseedV1.h" | |
814ecea4 | 63 | #include "TTreeStream.h" |
64 | ||
65 | #include <cstdio> | |
d068cde5 | 66 | #include <climits> |
814ecea4 | 67 | #include <cstring> |
afefec95 | 68 | #include <iostream> |
814ecea4 | 69 | |
873458ab | 70 | #include "AliTRDinfoGen.h" |
71 | #include "info/AliTRDtrackInfo.h" | |
72 | #include "info/AliTRDeventInfo.h" | |
98233fc0 | 73 | #include "info/AliTRDv0Info.h" |
814ecea4 | 74 | |
873458ab | 75 | ClassImp(AliTRDinfoGen) |
814ecea4 | 76 | |
3a43767e | 77 | const Float_t AliTRDinfoGen::fgkTPC = 290.; |
78 | const Float_t AliTRDinfoGen::fgkTOF = 365.; | |
814ecea4 | 79 | |
80 | //____________________________________________________________________ | |
873458ab | 81 | AliTRDinfoGen::AliTRDinfoGen(): |
6da3eee3 | 82 | AliTRDrecoTask("infoGen", "MC-REC TRD-track list generator") |
3a43767e | 83 | ,fESDev(0x0) |
84 | ,fMCev(0x0) | |
814ecea4 | 85 | ,fESDfriend(0x0) |
86 | ,fTrackInfo(0x0) | |
a24151d1 | 87 | ,fEventInfo(0x0) |
98233fc0 | 88 | ,fV0container(0x0) |
89 | ,fV0Info(0x0) | |
814ecea4 | 90 | { |
91 | // | |
92 | // Default constructor | |
93 | // | |
94 | ||
95 | DefineInput(0, TChain::Class()); | |
96 | DefineOutput(0, TObjArray::Class()); | |
a24151d1 | 97 | DefineOutput(1, AliTRDeventInfo::Class()); |
98233fc0 | 98 | DefineOutput(2, TObjArray::Class()); |
814ecea4 | 99 | } |
100 | ||
101 | //____________________________________________________________________ | |
873458ab | 102 | AliTRDinfoGen::~AliTRDinfoGen() |
ed383798 | 103 | { |
3a43767e | 104 | // Destructor |
94f34623 | 105 | if(fTrackInfo) delete fTrackInfo; fTrackInfo = 0x0; |
106 | if(fEventInfo) delete fEventInfo; fEventInfo = 0x0; | |
98233fc0 | 107 | if(fV0Info) delete fV0Info; fV0Info = 0x0; |
94f34623 | 108 | if(fContainer){ |
109 | fContainer->Delete(); delete fContainer; | |
110 | fContainer = 0x0; | |
111 | } | |
98233fc0 | 112 | if(fV0container){ |
113 | fV0container->Delete(); delete fV0container; | |
114 | fV0container = 0x0; | |
115 | } | |
ed383798 | 116 | } |
117 | ||
118 | //____________________________________________________________________ | |
873458ab | 119 | void AliTRDinfoGen::ConnectInputData(Option_t *) |
814ecea4 | 120 | { |
121 | // | |
122 | // Link the Input Data | |
123 | // | |
d2381af5 | 124 | TTree *tree = dynamic_cast<TChain*>(GetInputData(0)); |
125 | if(!tree){ | |
814ecea4 | 126 | printf("ERROR - ESD event not found"); |
d2381af5 | 127 | } else { |
128 | tree->SetBranchStatus("Tracks", 1); | |
129 | tree->SetBranchStatus("ESDfriend*",1); | |
814ecea4 | 130 | } |
131 | ||
132 | AliESDInputHandler *esdH = dynamic_cast<AliESDInputHandler*>(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()); | |
133 | if(!esdH){ | |
d2381af5 | 134 | printf("ERROR - ESD input handler not found"); |
814ecea4 | 135 | } else { |
3a43767e | 136 | fESDev = esdH->GetEvent(); |
137 | if(!fESDev){ | |
d2381af5 | 138 | printf("ERROR - ESD event not found"); |
814ecea4 | 139 | } else { |
140 | esdH->SetActiveBranches("ESDfriend*"); | |
3a43767e | 141 | fESDfriend = (AliESDfriend *)fESDev->FindListObject("AliESDfriend"); |
814ecea4 | 142 | } |
143 | } | |
4b8f8a35 | 144 | if(HasMCdata()){ |
d2381af5 | 145 | AliMCEventHandler *mcH = dynamic_cast<AliMCEventHandler*>(AliAnalysisManager::GetAnalysisManager()->GetMCtruthEventHandler()); |
146 | if(!mcH){ | |
147 | AliError("MC input handler not found"); | |
148 | } else { | |
3a43767e | 149 | fMCev = mcH->MCEvent(); |
d2381af5 | 150 | } |
814ecea4 | 151 | } |
152 | } | |
153 | ||
154 | //____________________________________________________________________ | |
873458ab | 155 | void AliTRDinfoGen::CreateOutputObjects() |
814ecea4 | 156 | { |
157 | // | |
158 | // Create Output Containers (TObjectArray containing 1D histograms) | |
159 | // | |
160 | fTrackInfo = new AliTRDtrackInfo(); | |
a24151d1 | 161 | fEventInfo = new AliTRDeventInfo(); |
98233fc0 | 162 | fV0Info = new AliTRDv0Info(); |
3d86166d | 163 | fContainer = new TObjArray(1000); |
94f34623 | 164 | fContainer->SetOwner(kTRUE); |
98233fc0 | 165 | fV0container = new TObjArray(50); |
166 | fV0container->SetOwner(kTRUE); | |
814ecea4 | 167 | |
814ecea4 | 168 | } |
169 | ||
170 | //____________________________________________________________________ | |
873458ab | 171 | void AliTRDinfoGen::Exec(Option_t *){ |
d2381af5 | 172 | // |
173 | // Run the Analysis | |
174 | // | |
3a43767e | 175 | if(!fESDev){ |
b94feda9 | 176 | AliError("Failed retrieving ESD event"); |
d2381af5 | 177 | return; |
178 | } | |
179 | if(!fESDfriend){ | |
b94feda9 | 180 | AliError("Failed retrieving ESD friend event"); |
d2381af5 | 181 | return; |
182 | } | |
3a43767e | 183 | if(HasMCdata() && !fMCev){ |
b94feda9 | 184 | AliError("Failed retrieving MC event"); |
d2381af5 | 185 | return; |
186 | } | |
3d86166d | 187 | fContainer->Delete(); |
98233fc0 | 188 | fV0container->Delete(); |
afefec95 | 189 | fEventInfo->Delete(""); |
3a43767e | 190 | fESDev->SetESDfriend(fESDfriend); |
191 | new(fEventInfo)AliTRDeventInfo(fESDev->GetHeader(), const_cast<AliESDRun *>(fESDev->GetESDRun())); | |
d2381af5 | 192 | |
193 | Bool_t *trackMap = 0x0; | |
194 | AliStack * mStack = 0x0; | |
3a43767e | 195 | Int_t nTracksMC = HasMCdata() ? fMCev->GetNumberOfTracks() : 0, nTracksESD = fESDev->GetNumberOfTracks(); |
d2381af5 | 196 | if(HasMCdata()){ |
3a43767e | 197 | mStack = fMCev->Stack(); |
d2381af5 | 198 | if(!mStack){ |
b94feda9 | 199 | AliError("Failed retrieving MC Stack"); |
d2381af5 | 200 | return; |
201 | } | |
2d65e748 | 202 | trackMap = new Bool_t[nTracksMC]; |
203 | memset(trackMap, 0, sizeof(Bool_t) * nTracksMC); | |
d2381af5 | 204 | } |
205 | ||
206 | Int_t nTRD = 0, nTPC = 0, nclsTrklt; | |
dad3aa6b | 207 | AliDebug(2, Form("Entry[%3d] Tracks: ESD[%d] MC[%d]\n", (Int_t)AliAnalysisManager::GetAnalysisManager()->GetCurrentEntry(), nTracksESD, nTracksMC)); |
d2381af5 | 208 | AliESDtrack *esdTrack = 0x0; |
209 | AliESDfriendTrack *esdFriendTrack = 0x0; | |
210 | TObject *calObject = 0x0; | |
211 | AliTRDtrackV1 *track = 0x0; | |
5c6b33ff | 212 | AliTRDseedV1 *tracklet = 0x0; |
213 | AliTRDcluster *cl = 0x0; | |
2d65e748 | 214 | for(Int_t itrk = 0; itrk < nTracksESD; itrk++){ |
3a43767e | 215 | esdTrack = fESDev->GetTrack(itrk); |
dad3aa6b | 216 | AliDebug(3, Form("\n%3d ITS[%d] TPC[%d] TRD[%d]\n", itrk, esdTrack->GetNcls(0), esdTrack->GetNcls(1), esdTrack->GetNcls(2))); |
d2381af5 | 217 | if(esdTrack->GetNcls(1)) nTPC++; |
218 | if(esdTrack->GetNcls(2)) nTRD++; | |
814ecea4 | 219 | |
303f052c | 220 | // look at external track param |
d2381af5 | 221 | const AliExternalTrackParam *op = esdTrack->GetOuterParam(); |
222 | Double_t xyz[3]; | |
223 | if(op){ | |
dad3aa6b | 224 | op->GetXYZ(xyz); |
225 | op->Global2LocalPosition(xyz, op->GetAlpha()); | |
226 | AliDebug(3, Form("op @ X[%7.3f]\n", xyz[0])); | |
d2381af5 | 227 | } |
814ecea4 | 228 | |
d2381af5 | 229 | // read MC info |
230 | Int_t fPdg = -1; | |
d068cde5 | 231 | Int_t label = -1; UInt_t alab=UINT_MAX; |
d2381af5 | 232 | if(HasMCdata()){ |
b94feda9 | 233 | label = esdTrack->GetLabel(); |
234 | alab = TMath::Abs(label); | |
235 | // register the track | |
236 | if(alab < UInt_t(nTracksMC)){ | |
237 | trackMap[alab] = kTRUE; | |
238 | } else { | |
82b33eb2 | 239 | AliError(Form("MC label[%d] outside scope for Ev[%d] Trk[%d].", label, (Int_t)AliAnalysisManager::GetAnalysisManager()->GetCurrentEntry(), itrk)); |
b94feda9 | 240 | continue; |
241 | } | |
5d6dc395 | 242 | AliMCParticle *mcParticle = 0x0; |
3a43767e | 243 | if(!(mcParticle = (AliMCParticle*) fMCev->GetTrack(alab))){ |
82b33eb2 | 244 | AliError(Form("MC particle label[%d] missing for Ev[%d] Trk[%d].", label, (Int_t)AliAnalysisManager::GetAnalysisManager()->GetCurrentEntry(), itrk)); |
5d6dc395 | 245 | continue; |
246 | } | |
d2381af5 | 247 | fPdg = mcParticle->Particle()->GetPdgCode(); |
248 | Int_t nRefs = mcParticle->GetNumberOfTrackReferences(); | |
249 | Int_t iref = 0; AliTrackReference *ref = 0x0; | |
250 | while(iref<nRefs){ | |
251 | ref = mcParticle->GetTrackReference(iref); | |
3a43767e | 252 | if(ref->LocalX() > fgkTPC) break; |
d2381af5 | 253 | iref++; |
254 | } | |
814ecea4 | 255 | |
93e41bce | 256 | new(fTrackInfo) AliTRDtrackInfo(); |
257 | fTrackInfo->SetPDG(fPdg); | |
d2381af5 | 258 | fTrackInfo->SetPrimary(mcParticle->Particle()->IsPrimary()); |
259 | Int_t jref = iref;//, kref = 0; | |
260 | while(jref<nRefs){ | |
261 | ref = mcParticle->GetTrackReference(jref); | |
3a43767e | 262 | if(ref->LocalX() > fgkTOF) break; |
dad3aa6b | 263 | AliDebug(4, Form(" trackRef[%2d (%2d)] @ %7.3f OK", jref-iref, jref, ref->LocalX())); |
d2381af5 | 264 | fTrackInfo->AddTrackRef(ref); |
265 | jref++; | |
266 | } | |
dad3aa6b | 267 | AliDebug(3, Form("NtrackRefs[%d(%d)]", fTrackInfo->GetNTrackRefs(), nRefs)); |
d2381af5 | 268 | } else { |
93e41bce | 269 | new (fTrackInfo) AliTRDtrackInfo(); |
270 | fTrackInfo->SetPDG(fPdg); | |
d2381af5 | 271 | } |
814ecea4 | 272 | |
d2381af5 | 273 | // copy some relevant info to TRD track info |
274 | fTrackInfo->SetStatus(esdTrack->GetStatus()); | |
275 | fTrackInfo->SetTrackId(esdTrack->GetID()); | |
c46a7947 | 276 | Double_t p[AliPID::kSPECIES]; esdTrack->GetTRDpid(p); |
277 | fTrackInfo->SetESDpid(p); | |
ed15ef4f | 278 | fTrackInfo->SetESDpidQuality(esdTrack->GetTRDntrackletsPID()); |
d2381af5 | 279 | fTrackInfo->SetLabel(label); |
280 | fTrackInfo->SetNumberOfClustersRefit(esdTrack->GetNcls(2)); | |
52a79f8d | 281 | // some other Informations which we may wish to store in order to find problematic cases |
282 | fTrackInfo->SetKinkIndex(esdTrack->GetKinkIndex(0)); | |
283 | fTrackInfo->SetTPCncls(static_cast<UShort_t>(esdTrack->GetNcls(1))); | |
d2381af5 | 284 | nclsTrklt = 0; |
285 | ||
814ecea4 | 286 | |
d2381af5 | 287 | // read REC info |
288 | esdFriendTrack = fESDfriend->GetTrack(itrk); | |
289 | if(esdFriendTrack){ | |
290 | Int_t icalib = 0; | |
291 | while((calObject = esdFriendTrack->GetCalibObject(icalib++))){ | |
292 | if(strcmp(calObject->IsA()->GetName(),"AliTRDtrackV1") != 0) continue; // Look for the TRDtrack | |
b718144c | 293 | if(!(track = dynamic_cast<AliTRDtrackV1*>(calObject))) break; |
294 | nTRD++; | |
dad3aa6b | 295 | AliDebug(4, Form("TRD track OK")); |
5c6b33ff | 296 | // Set the clusters to unused |
297 | for(Int_t ipl = 0; ipl < AliTRDgeometry::kNlayer; ipl++){ | |
298 | if(!(tracklet = track->GetTracklet(ipl))) continue; | |
299 | tracklet->ResetClusterIter(); | |
300 | while((cl = tracklet->NextCluster())) cl->Use(0); | |
301 | } | |
c46a7947 | 302 | fTrackInfo->SetTrack(track); |
d2381af5 | 303 | break; |
304 | } | |
dad3aa6b | 305 | AliDebug(3, Form("Ntracklets[%d]\n", fTrackInfo->GetNTracklets())); |
306 | } else AliDebug(3, "No ESD friends"); | |
d2381af5 | 307 | if(op) fTrackInfo->SetOuterParam(op); |
814ecea4 | 308 | |
dad3aa6b | 309 | if(DebugLevel() >= 1){ |
b718144c | 310 | AliTRDtrackInfo info(*fTrackInfo); |
dad3aa6b | 311 | (*DebugStream()) << "trackInfo" |
b718144c | 312 | << "TrackInfo.=" << &info |
d2381af5 | 313 | << "\n"; |
b718144c | 314 | info.Delete(""); |
d2381af5 | 315 | } |
316 | ||
3d86166d | 317 | fContainer->Add(new AliTRDtrackInfo(*fTrackInfo)); |
d2381af5 | 318 | fTrackInfo->Delete(""); |
319 | } | |
dad3aa6b | 320 | AliDebug(3, Form("%3d Tracks: TPC[%d] TRD[%d]\n", (Int_t)AliAnalysisManager::GetAnalysisManager()->GetCurrentEntry(), nTPC, nTRD)); |
4b8f8a35 | 321 | |
ea4502f6 | 322 | // AliESDv0 *v0 = 0x0; |
323 | // for(Int_t iv0=0; iv0<fESD->GetNumberOfV0s(); iv0++){ | |
324 | // if(!(v0 = fESD->GetV0(iv0))) continue; | |
325 | // fV0container->Add(new AliTRDv0Info(v0)); | |
326 | // } | |
98233fc0 | 327 | |
d2381af5 | 328 | // Insert also MC tracks which are passing TRD where the track is not reconstructed |
329 | if(HasMCdata()){ | |
dad3aa6b | 330 | AliDebug(10, "Output of the MC track map:"); |
331 | for(Int_t itk = 0; itk < nTracksMC; itk++) AliDebug(10, Form("trackMap[%d] = %s", itk, trackMap[itk] == kTRUE ? "TRUE" : "kFALSE")); | |
d2381af5 | 332 | |
2d65e748 | 333 | for(Int_t itk = 0; itk < nTracksMC; itk++){ |
d2381af5 | 334 | if(trackMap[itk]) continue; |
3a43767e | 335 | AliMCParticle *mcParticle = (AliMCParticle*) fMCev->GetTrack(TMath::Abs(itk)); |
d2381af5 | 336 | Int_t fPdg = mcParticle->Particle()->GetPdgCode(); |
337 | Int_t nRefs = mcParticle->GetNumberOfTrackReferences(); | |
338 | Int_t iref = 0; AliTrackReference *ref = 0x0; | |
339 | Int_t nRefsTRD = 0; | |
93e41bce | 340 | new(fTrackInfo) AliTRDtrackInfo(); |
341 | fTrackInfo->SetPDG(fPdg); | |
d2381af5 | 342 | while(iref<nRefs){ |
343 | ref = mcParticle->GetTrackReference(iref); | |
d2381af5 | 344 | if(ref->LocalX() > 250. && ref->LocalX() < 370.){ |
dad3aa6b | 345 | AliDebug(4, Form(" trackRef[%2d] @ %7.3f IN", iref, ref->LocalX())); |
d2381af5 | 346 | fTrackInfo->AddTrackRef(ref); |
347 | nRefsTRD++; | |
348 | } | |
dad3aa6b | 349 | else AliDebug(4, Form(" trackRef[%2d] @ %7.3f OUT", iref, ref->LocalX())); |
d2381af5 | 350 | iref++; |
351 | } | |
352 | if(!nRefsTRD){ | |
353 | // In this stage we at least require 1 hit inside TRD. What will be done with this tracks is a task for the | |
354 | // analysis job | |
355 | fTrackInfo->Delete(""); | |
356 | continue; | |
357 | } | |
358 | fTrackInfo->SetPrimary(mcParticle->Particle()->IsPrimary()); | |
359 | fTrackInfo->SetLabel(itk); | |
dad3aa6b | 360 | if(DebugLevel() >= 1){ |
b718144c | 361 | AliTRDtrackInfo info(*fTrackInfo); |
dad3aa6b | 362 | (*DebugStream()) << "trackInfo" |
b718144c | 363 | << "TrackInfo.=" << &info |
d2381af5 | 364 | << "\n"; |
b718144c | 365 | info.Delete(""); |
d2381af5 | 366 | } |
dad3aa6b | 367 | AliDebug(3, Form("Registering rejected MC track with label %d", itk)); |
3d86166d | 368 | fContainer->Add(new AliTRDtrackInfo(*fTrackInfo)); |
d2381af5 | 369 | fTrackInfo->Delete(""); |
370 | } | |
371 | delete[] trackMap; | |
372 | } | |
3d86166d | 373 | PostData(0, fContainer); |
a24151d1 | 374 | PostData(1, fEventInfo); |
98233fc0 | 375 | PostData(2, fV0container); |
814ecea4 | 376 | } |
377 |