]>
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> |
058c3053 | 38 | #include <TH1S.h> |
39 | #include <TPad.h> | |
1ee39b3a | 40 | #include <TFile.h> |
41 | #include <TTree.h> | |
42 | #include <TROOT.h> | |
43 | #include <TChain.h> | |
44 | #include <TParticle.h> | |
45 | ||
46 | #include "AliLog.h" | |
47 | #include "AliAnalysisManager.h" | |
fd7ffd88 | 48 | #include "AliGeomManager.h" |
801d4d50 | 49 | #include "AliCDBManager.h" |
fd7ffd88 | 50 | #include "AliCDBEntry.h" |
51 | #include "AliCDBPath.h" | |
1ee39b3a | 52 | #include "AliESDEvent.h" |
53 | #include "AliMCEvent.h" | |
54 | #include "AliESDInputHandler.h" | |
55 | #include "AliMCEventHandler.h" | |
56 | ||
57 | #include "AliESDfriend.h" | |
58 | #include "AliESDfriendTrack.h" | |
59 | #include "AliESDHeader.h" | |
60 | #include "AliESDtrack.h" | |
3d19c1b0 | 61 | #include "AliESDv0.h" |
07ece31c | 62 | #include "AliESDtrackCuts.h" |
1ee39b3a | 63 | #include "AliMCParticle.h" |
64 | #include "AliPID.h" | |
65 | #include "AliStack.h" | |
1ee39b3a | 66 | #include "AliTrackReference.h" |
1ee39b3a | 67 | #include "TTreeStream.h" |
68 | ||
69 | #include <cstdio> | |
70 | #include <climits> | |
71 | #include <cstring> | |
72 | #include <iostream> | |
eba58f30 | 73 | #include <memory> |
1ee39b3a | 74 | |
fd7ffd88 | 75 | #include "AliTRDReconstructor.h" |
76 | #include "AliTRDrecoParam.h" | |
801d4d50 | 77 | #include "AliTRDcalibDB.h" |
78 | #include "AliTRDtrackerV1.h" | |
79 | #include "AliTRDgeometry.h" | |
80 | #include "AliTRDtrackV1.h" | |
81 | #include "AliTRDseedV1.h" | |
82 | #include "AliTRDcluster.h" | |
1ee39b3a | 83 | #include "AliTRDinfoGen.h" |
99535225 | 84 | #include "AliTRDpwg1Helper.h" |
1ee39b3a | 85 | #include "info/AliTRDtrackInfo.h" |
86 | #include "info/AliTRDeventInfo.h" | |
87 | #include "info/AliTRDv0Info.h" | |
07ece31c | 88 | #include "info/AliTRDeventCuts.h" |
1ee39b3a | 89 | |
90 | ClassImp(AliTRDinfoGen) | |
91 | ||
3d2a3dff | 92 | const Float_t AliTRDinfoGen::fgkITS = 100.; // to be checked |
1ee39b3a | 93 | const Float_t AliTRDinfoGen::fgkTPC = 290.; |
3d2a3dff | 94 | const Float_t AliTRDinfoGen::fgkTRD = 365.; |
1ee39b3a | 95 | |
3f19c2cd | 96 | const Float_t AliTRDinfoGen::fgkEvVertexZ = 15.; |
97 | const Int_t AliTRDinfoGen::fgkEvVertexN = 1; | |
98 | ||
bd05b0f1 | 99 | const Float_t AliTRDinfoGen::fgkTrkDCAxy = 3.; |
100 | const Float_t AliTRDinfoGen::fgkTrkDCAz = 10.; | |
101 | const Int_t AliTRDinfoGen::fgkNclTPC = 70; | |
3f19c2cd | 102 | const Float_t AliTRDinfoGen::fgkPt = 0.2; |
103 | const Float_t AliTRDinfoGen::fgkEta = 0.9; | |
fd7ffd88 | 104 | AliTRDReconstructor* AliTRDinfoGen::fgReconstructor(NULL); |
105 | AliTRDgeometry* AliTRDinfoGen::fgGeo(NULL); | |
1ee39b3a | 106 | //____________________________________________________________________ |
db99a57a | 107 | AliTRDinfoGen::AliTRDinfoGen() |
705f8b0a | 108 | :AliAnalysisTaskSE() |
109 | ,fEvTrigger(NULL) | |
770382d9 | 110 | ,fESDev(NULL) |
111 | ,fMCev(NULL) | |
705f8b0a | 112 | ,fEventCut(NULL) |
113 | ,fTrackCut(NULL) | |
3d19c1b0 | 114 | ,fV0Cut(NULL) |
801d4d50 | 115 | ,fOCDB("local://$ALICE_ROOT/OCDB") |
770382d9 | 116 | ,fTrackInfo(NULL) |
117 | ,fEventInfo(NULL) | |
770382d9 | 118 | ,fV0Info(NULL) |
705f8b0a | 119 | ,fTracksBarrel(NULL) |
120 | ,fTracksSA(NULL) | |
121 | ,fTracksKink(NULL) | |
122 | ,fV0List(NULL) | |
058c3053 | 123 | ,fContainer(NULL) |
705f8b0a | 124 | ,fDebugStream(NULL) |
1ee39b3a | 125 | { |
126 | // | |
127 | // Default constructor | |
128 | // | |
76106bcc | 129 | SetNameTitle("TRDinfoGen", "MC-REC TRD-track list generator"); |
f8f46e4d | 130 | } |
1ee39b3a | 131 | |
07ece31c | 132 | //____________________________________________________________________ |
db99a57a | 133 | AliTRDinfoGen::AliTRDinfoGen(char* name) |
705f8b0a | 134 | :AliAnalysisTaskSE(name) |
135 | ,fEvTrigger(NULL) | |
f8f46e4d | 136 | ,fESDev(NULL) |
137 | ,fMCev(NULL) | |
705f8b0a | 138 | ,fEventCut(NULL) |
139 | ,fTrackCut(NULL) | |
3d19c1b0 | 140 | ,fV0Cut(NULL) |
801d4d50 | 141 | ,fOCDB("local://$ALICE_ROOT/OCDB") |
f8f46e4d | 142 | ,fTrackInfo(NULL) |
143 | ,fEventInfo(NULL) | |
f8f46e4d | 144 | ,fV0Info(NULL) |
705f8b0a | 145 | ,fTracksBarrel(NULL) |
146 | ,fTracksSA(NULL) | |
147 | ,fTracksKink(NULL) | |
148 | ,fV0List(NULL) | |
058c3053 | 149 | ,fContainer(NULL) |
705f8b0a | 150 | ,fDebugStream(NULL) |
f8f46e4d | 151 | { |
152 | // | |
153 | // Default constructor | |
154 | // | |
705f8b0a | 155 | SetTitle("MC-REC TRD-track list generator"); |
99535225 | 156 | DefineOutput(AliTRDpwg1Helper::kTracksBarrel, TObjArray::Class()); |
157 | DefineOutput(AliTRDpwg1Helper::kTracksSA, TObjArray::Class()); | |
158 | DefineOutput(AliTRDpwg1Helper::kTracksKink, TObjArray::Class()); | |
159 | DefineOutput(AliTRDpwg1Helper::kEventInfo, AliTRDeventInfo::Class()); | |
160 | DefineOutput(AliTRDpwg1Helper::kV0List, TObjArray::Class()); | |
161 | DefineOutput(AliTRDpwg1Helper::kMonitor, TObjArray::Class()); // histogram list | |
1ee39b3a | 162 | } |
163 | ||
164 | //____________________________________________________________________ | |
165 | AliTRDinfoGen::~AliTRDinfoGen() | |
166 | { | |
167 | // Destructor | |
fd7ffd88 | 168 | if(fgGeo) delete fgGeo; |
169 | if(fgReconstructor) delete fgReconstructor; | |
0205fb04 | 170 | if(fDebugStream) delete fDebugStream; |
705f8b0a | 171 | if(fEvTrigger) delete fEvTrigger; |
3d19c1b0 | 172 | if(fV0Cut) delete fV0Cut; |
07ece31c | 173 | if(fTrackCut) delete fTrackCut; |
174 | if(fEventCut) delete fEventCut; | |
770382d9 | 175 | if(fTrackInfo) delete fTrackInfo; fTrackInfo = NULL; |
770382d9 | 176 | if(fEventInfo) delete fEventInfo; fEventInfo = NULL; |
770382d9 | 177 | if(fV0Info) delete fV0Info; fV0Info = NULL; |
705f8b0a | 178 | if(fTracksBarrel){ |
179 | fTracksBarrel->Delete(); delete fTracksBarrel; | |
180 | fTracksBarrel = NULL; | |
181 | } | |
182 | if(fTracksSA){ | |
183 | fTracksSA->Delete(); delete fTracksSA; | |
184 | fTracksSA = NULL; | |
1ee39b3a | 185 | } |
705f8b0a | 186 | if(fTracksKink){ |
187 | fTracksKink->Delete(); delete fTracksKink; | |
188 | fTracksKink = NULL; | |
189 | } | |
190 | if(fV0List){ | |
3d19c1b0 | 191 | fV0List->Delete(); |
192 | delete fV0List; | |
705f8b0a | 193 | fV0List = NULL; |
1ee39b3a | 194 | } |
058c3053 | 195 | if(fContainer){ |
196 | fContainer->Delete(); | |
197 | delete fContainer; | |
198 | fContainer = NULL; | |
199 | } | |
200 | } | |
201 | ||
202 | //____________________________________________________________________ | |
203 | Bool_t AliTRDinfoGen::GetRefFigure(Int_t) | |
204 | { | |
61f6b45e | 205 | // General graphs for PWG1/TRD train |
058c3053 | 206 | if(!gPad){ |
207 | AliWarning("Please provide a canvas to draw results."); | |
208 | return kFALSE; | |
209 | } | |
210 | fContainer->At(0)->Draw("bar"); | |
211 | return kTRUE; | |
1ee39b3a | 212 | } |
213 | ||
214 | //____________________________________________________________________ | |
f8f46e4d | 215 | void AliTRDinfoGen::UserCreateOutputObjects() |
1ee39b3a | 216 | { |
217 | // | |
218 | // Create Output Containers (TObjectArray containing 1D histograms) | |
219 | // | |
b4414720 | 220 | |
1ee39b3a | 221 | fTrackInfo = new AliTRDtrackInfo(); |
222 | fEventInfo = new AliTRDeventInfo(); | |
223 | fV0Info = new AliTRDv0Info(); | |
705f8b0a | 224 | fTracksBarrel = new TObjArray(200); fTracksBarrel->SetOwner(kTRUE); |
225 | fTracksSA = new TObjArray(20); fTracksSA->SetOwner(kTRUE); | |
226 | fTracksKink = new TObjArray(20); fTracksKink->SetOwner(kTRUE); | |
227 | fV0List = new TObjArray(10); fV0List->SetOwner(kTRUE); | |
058c3053 | 228 | |
229 | // define general monitor | |
230 | fContainer = new TObjArray(1); fContainer->SetOwner(kTRUE); | |
08d1f138 | 231 | TH1 *h=new TH1I("hStat", "Run statistics;Observable;Entries", 14, -0.5, 11.5); |
058c3053 | 232 | TAxis *ax(h->GetXaxis()); |
233 | ax->SetBinLabel( 1, "ESD"); | |
234 | ax->SetBinLabel( 2, "MC"); | |
235 | ax->SetBinLabel( 3, "V0"); | |
236 | ax->SetBinLabel( 4, "TPC"); | |
237 | ax->SetBinLabel( 5, "TRDin"); | |
238 | ax->SetBinLabel( 6, "TRDout"); | |
239 | ax->SetBinLabel( 7, "Barrel"); | |
240 | ax->SetBinLabel( 8, "BarrelMC"); | |
241 | ax->SetBinLabel( 9, "SA"); | |
242 | ax->SetBinLabel(10, "SAMC"); | |
243 | ax->SetBinLabel(11, "Kink"); | |
244 | ax->SetBinLabel(12, "KinkMC"); | |
08d1f138 | 245 | ax->SetBinLabel(13, "BFriend"); |
246 | ax->SetBinLabel(14, "SFriend"); | |
058c3053 | 247 | fContainer->AddAt(h, 0); |
99535225 | 248 | PostData(AliTRDpwg1Helper::kMonitor, fContainer); |
058c3053 | 249 | } |
250 | ||
251 | //____________________________________________________________________ | |
252 | Bool_t AliTRDinfoGen::Load(const Char_t *file, const Char_t *dir, const Char_t *name) | |
253 | { | |
254 | // Load data from performance file | |
255 | ||
256 | if(!TFile::Open(file)){ | |
257 | AliWarning(Form("Couldn't open file %s.", file)); | |
258 | return kFALSE; | |
259 | } | |
260 | if(dir){ | |
261 | if(!gFile->cd(dir)){ | |
262 | AliWarning(Form("Couldn't cd to %s in %s.", dir, file)); | |
263 | return kFALSE; | |
264 | } | |
265 | } | |
266 | TObjArray *o(NULL); | |
267 | const Char_t *tn=(name ? name : GetName()); | |
268 | if(!(o = (TObjArray*)gDirectory->Get(tn))){ | |
269 | AliWarning(Form("Missing histogram container %s.", tn)); | |
270 | return kFALSE; | |
271 | } | |
272 | fContainer = (TObjArray*)o->Clone(GetName()); | |
273 | gFile->Close(); | |
274 | return kTRUE; | |
1ee39b3a | 275 | } |
276 | ||
277 | //____________________________________________________________________ | |
f8f46e4d | 278 | void AliTRDinfoGen::UserExec(Option_t *){ |
1ee39b3a | 279 | // |
280 | // Run the Analysis | |
281 | // | |
f2e89a4c | 282 | |
d80a6a00 | 283 | fTracksBarrel->Delete(); |
284 | fTracksSA->Delete(); | |
285 | fTracksKink->Delete(); | |
286 | fV0List->Delete(); | |
287 | fEventInfo->Delete(""); | |
288 | ||
f8f46e4d | 289 | fESDev = dynamic_cast<AliESDEvent*>(InputEvent()); |
1ee39b3a | 290 | if(!fESDev){ |
291 | AliError("Failed retrieving ESD event"); | |
292 | return; | |
293 | } | |
fd7ffd88 | 294 | // WARNING |
295 | // This part may conflict with other detectors !! | |
296 | if(!IsInitOCDB()){ | |
45e058a2 | 297 | AliInfo("Initializing OCDB ..."); |
801d4d50 | 298 | // prepare OCDB access |
299 | AliCDBManager* ocdb = AliCDBManager::Instance(); | |
300 | ocdb->SetDefaultStorage(fOCDB.Data()); | |
301 | ocdb->SetRun(fESDev->GetRunNumber()); | |
fd7ffd88 | 302 | // create geo manager |
7fe4e88b | 303 | AliCDBEntry* obj(NULL); |
304 | if(!(obj = ocdb->Get(AliCDBPath("GRP", "Geometry", "Data")))){ | |
305 | AliError("GEOMETRY failed initialization."); | |
306 | } else { | |
307 | AliGeomManager::SetGeometry((TGeoManager*)obj->GetObject()); | |
308 | AliGeomManager::GetNalignable("TRD"); | |
309 | AliGeomManager::ApplyAlignObjsFromCDB("TRD"); | |
310 | } | |
fd7ffd88 | 311 | fgGeo = new AliTRDgeometry; |
56f313bd | 312 | //init magnetic field |
313 | if(!TGeoGlobalMagField::Instance()->IsLocked() && | |
314 | !fESDev->InitMagneticField()){ | |
7fe4e88b | 315 | AliError("MAGNETIC FIELD failed initialization."); |
56f313bd | 316 | } |
fd7ffd88 | 317 | |
318 | // set no of time bins | |
801d4d50 | 319 | AliTRDtrackerV1::SetNTimeBins(AliTRDcalibDB::Instance()->GetNumberOfTimeBinsDCS()); |
320 | AliInfo(Form("OCDB : Loc[%s] Run[%d] TB[%d]", fOCDB.Data(), ocdb->GetRun(), AliTRDtrackerV1::GetNTimeBins())); | |
fd7ffd88 | 321 | |
56f313bd | 322 | // set reco param valid for this run/event |
fd7ffd88 | 323 | AliInfo(Form("Initializing TRD reco params for EventSpecie[%d]...", |
324 | fESDev->GetEventSpecie())); | |
325 | fgReconstructor = new AliTRDReconstructor(); | |
7fe4e88b | 326 | if(!(obj = ocdb->Get(AliCDBPath("TRD", "Calib", "RecoParam")))){ |
327 | AliError("RECO PARAM failed initialization."); | |
328 | fgReconstructor->SetRecoParam(AliTRDrecoParam::GetLowFluxParam()); | |
329 | } else { | |
330 | obj->PrintMetaData(); | |
331 | TObjArray *recos((TObjArray*)obj->GetObject()); | |
332 | for(Int_t ireco(0); ireco<recos->GetEntriesFast(); ireco++){ | |
333 | AliTRDrecoParam *reco((AliTRDrecoParam*)recos->At(ireco)); | |
334 | Int_t es(reco->GetEventSpecie()); | |
335 | if(!(es&fESDev->GetEventSpecie())) continue; | |
336 | fgReconstructor->SetRecoParam(reco); | |
337 | TString s; | |
338 | if(es&AliRecoParam::kLowMult) s="LowMult"; | |
339 | else if(es&AliRecoParam::kHighMult) s="HighMult"; | |
340 | else if(es&AliRecoParam::kCosmic) s="Cosmic"; | |
341 | else if(es&AliRecoParam::kCalib) s="Calib"; | |
342 | else s="Unknown"; | |
343 | AliInfo(Form("Using reco params for %s", s.Data())); | |
344 | break; | |
345 | } | |
fd7ffd88 | 346 | } |
801d4d50 | 347 | SetInitOCDB(); |
348 | } | |
349 | ||
350 | // link MC if available | |
351 | fMCev = MCEvent(); | |
3f19c2cd | 352 | |
353 | // event selection : trigger cut | |
705f8b0a | 354 | if(UseLocalEvSelection() && fEvTrigger){ |
3f19c2cd | 355 | Bool_t kTRIGGERED(kFALSE); |
eba58f30 | 356 | std::auto_ptr<TObjArray> trig(fEvTrigger->Tokenize(" ")); |
3f19c2cd | 357 | for(Int_t itrig=trig->GetEntriesFast(); itrig--;){ |
358 | const Char_t *trigClass(((TObjString*)(*trig)[itrig])->GetName()); | |
359 | if(fESDev->IsTriggerClassFired(trigClass)) { | |
360 | AliDebug(2, Form("Ev[%4d] Trigger[%s]", fESDev->GetEventNumberInFile(), trigClass)); | |
361 | kTRIGGERED = kTRUE; | |
362 | break; | |
363 | } | |
364 | } | |
55d5090e | 365 | if(!kTRIGGERED){ |
366 | AliDebug(2, Form("Reject Ev[%4d] Trigger", fESDev->GetEventNumberInFile())); | |
367 | return; | |
368 | } | |
3f19c2cd | 369 | // select only physical events |
55d5090e | 370 | if(fESDev->GetEventType() != 7){ |
371 | AliDebug(2, Form("Reject Ev[%4d] EvType[%d]", fESDev->GetEventNumberInFile(), fESDev->GetEventType())); | |
372 | return; | |
373 | } | |
3f19c2cd | 374 | } |
375 | ||
376 | // if the required trigger is a collision trigger then apply event vertex cut | |
377 | if(UseLocalEvSelection() && IsCollision()){ | |
378 | const AliESDVertex *vertex = fESDev->GetPrimaryVertex(); | |
379 | if(TMath::Abs(vertex->GetZv())<1.e-10 || | |
380 | TMath::Abs(vertex->GetZv())>fgkEvVertexZ || | |
381 | vertex->GetNContributors()<fgkEvVertexN) { | |
55d5090e | 382 | AliDebug(2, Form("Reject Ev[%4d] Vertex Zv[%f] Nv[%d]", fESDev->GetEventNumberInFile(), TMath::Abs(vertex->GetZv()), vertex->GetNContributors())); |
3f19c2cd | 383 | return; |
384 | } | |
385 | } | |
386 | ||
07ece31c | 387 | if(fEventCut && !fEventCut->IsSelected(fESDev, IsCollision())) return; |
388 | ||
1ee39b3a | 389 | if(!fESDfriend){ |
390 | AliError("Failed retrieving ESD friend event"); | |
391 | return; | |
392 | } | |
393 | if(HasMCdata() && !fMCev){ | |
394 | AliError("Failed retrieving MC event"); | |
395 | return; | |
396 | } | |
f8f46e4d | 397 | |
1ee39b3a | 398 | new(fEventInfo)AliTRDeventInfo(fESDev->GetHeader(), const_cast<AliESDRun *>(fESDev->GetESDRun())); |
399 | ||
770382d9 | 400 | Bool_t *trackMap(NULL); |
401 | AliStack * mStack(NULL); | |
1ee39b3a | 402 | Int_t nTracksMC = HasMCdata() ? fMCev->GetNumberOfTracks() : 0, nTracksESD = fESDev->GetNumberOfTracks(); |
403 | if(HasMCdata()){ | |
404 | mStack = fMCev->Stack(); | |
405 | if(!mStack){ | |
406 | AliError("Failed retrieving MC Stack"); | |
407 | return; | |
408 | } | |
409 | trackMap = new Bool_t[nTracksMC]; | |
410 | memset(trackMap, 0, sizeof(Bool_t) * nTracksMC); | |
411 | } | |
412 | ||
f232df0d | 413 | Double32_t dedx[100]; Int_t nSlices(0); |
3d2a3dff | 414 | Int_t nTRDout(0), nTRDin(0), nTPC(0) |
415 | ,nclsTrklt | |
416 | ,nBarrel(0), nSA(0), nKink(0) | |
08d1f138 | 417 | ,nBarrelFriend(0), nSAFriend(0) |
3d2a3dff | 418 | ,nBarrelMC(0), nSAMC(0), nKinkMC(0); |
770382d9 | 419 | AliESDtrack *esdTrack = NULL; |
420 | AliESDfriendTrack *esdFriendTrack = NULL; | |
421 | TObject *calObject = NULL; | |
422 | AliTRDtrackV1 *track = NULL; | |
423 | AliTRDseedV1 *tracklet = NULL; | |
424 | AliTRDcluster *cl = NULL; | |
d80a6a00 | 425 | |
426 | ||
427 | // LOOP 0 - over ESD v0s | |
428 | Float_t bField(fESDev->GetMagneticField()); | |
429 | AliESDv0 *v0(NULL); | |
430 | Int_t v0pid[AliPID::kSPECIES]; | |
431 | for(Int_t iv0(0); iv0<fESDev->GetNumberOfV0s(); iv0++){ | |
432 | if(!(v0 = fESDev->GetV0(iv0))) continue; | |
433 | // register v0 | |
434 | if(fV0Cut) new(fV0Info) AliTRDv0Info(*fV0Cut); | |
435 | else new(fV0Info) AliTRDv0Info(); | |
436 | fV0Info->SetMagField(bField); | |
437 | fV0Info->SetV0tracks(fESDev->GetTrack(v0->GetPindex()), fESDev->GetTrack(v0->GetNindex())); | |
438 | fV0Info->SetV0Info(v0); | |
439 | fV0List->Add(new AliTRDv0Info(*fV0Info));// kFOUND=kFALSE; | |
440 | } | |
441 | ||
442 | ||
443 | // LOOP 1 - over ESD tracks | |
45e058a2 | 444 | AliTRDv0Info *v0info=NULL; |
1ee39b3a | 445 | for(Int_t itrk = 0; itrk < nTracksESD; itrk++){ |
267f8668 | 446 | new(fTrackInfo) AliTRDtrackInfo(); |
1ee39b3a | 447 | esdTrack = fESDev->GetTrack(itrk); |
448 | AliDebug(3, Form("\n%3d ITS[%d] TPC[%d] TRD[%d]\n", itrk, esdTrack->GetNcls(0), esdTrack->GetNcls(1), esdTrack->GetNcls(2))); | |
3f19c2cd | 449 | |
770382d9 | 450 | if(esdTrack->GetStatus()&AliESDtrack::kTPCout) nTPC++; |
451 | if(esdTrack->GetStatus()&AliESDtrack::kTRDout) nTRDout++; | |
452 | if(esdTrack->GetStatus()&AliESDtrack::kTRDin) nTRDin++; | |
1ee39b3a | 453 | |
454 | // look at external track param | |
455 | const AliExternalTrackParam *op = esdTrack->GetOuterParam(); | |
456 | Double_t xyz[3]; | |
457 | if(op){ | |
458 | op->GetXYZ(xyz); | |
459 | op->Global2LocalPosition(xyz, op->GetAlpha()); | |
460 | AliDebug(3, Form("op @ X[%7.3f]\n", xyz[0])); | |
461 | } | |
462 | ||
463 | // read MC info | |
464 | Int_t fPdg = -1; | |
465 | Int_t label = -1; UInt_t alab=UINT_MAX; | |
466 | if(HasMCdata()){ | |
467 | label = esdTrack->GetLabel(); | |
468 | alab = TMath::Abs(label); | |
469 | // register the track | |
470 | if(alab < UInt_t(nTracksMC)){ | |
471 | trackMap[alab] = kTRUE; | |
472 | } else { | |
473 | AliError(Form("MC label[%d] outside scope for Ev[%d] Trk[%d].", label, (Int_t)AliAnalysisManager::GetAnalysisManager()->GetCurrentEntry(), itrk)); | |
474 | continue; | |
475 | } | |
770382d9 | 476 | AliMCParticle *mcParticle = NULL; |
1ee39b3a | 477 | if(!(mcParticle = (AliMCParticle*) fMCev->GetTrack(alab))){ |
478 | AliError(Form("MC particle label[%d] missing for Ev[%d] Trk[%d].", label, (Int_t)AliAnalysisManager::GetAnalysisManager()->GetCurrentEntry(), itrk)); | |
479 | continue; | |
480 | } | |
481 | fPdg = mcParticle->Particle()->GetPdgCode(); | |
482 | Int_t nRefs = mcParticle->GetNumberOfTrackReferences(); | |
770382d9 | 483 | Int_t iref = 0; AliTrackReference *ref = NULL; |
1ee39b3a | 484 | while(iref<nRefs){ |
485 | ref = mcParticle->GetTrackReference(iref); | |
486 | if(ref->LocalX() > fgkTPC) break; | |
487 | iref++; | |
488 | } | |
489 | ||
267f8668 | 490 | fTrackInfo->SetMC(); |
1ee39b3a | 491 | fTrackInfo->SetPDG(fPdg); |
492 | fTrackInfo->SetPrimary(mcParticle->Particle()->IsPrimary()); | |
b09af9ec | 493 | fTrackInfo->SetLabel(label); |
1ee39b3a | 494 | Int_t jref = iref;//, kref = 0; |
495 | while(jref<nRefs){ | |
496 | ref = mcParticle->GetTrackReference(jref); | |
3d2a3dff | 497 | if(ref->LocalX() > fgkTRD) break; |
1ee39b3a | 498 | AliDebug(4, Form(" trackRef[%2d (%2d)] @ %7.3f OK", jref-iref, jref, ref->LocalX())); |
499 | fTrackInfo->AddTrackRef(ref); | |
500 | jref++; | |
501 | } | |
502 | AliDebug(3, Form("NtrackRefs[%d(%d)]", fTrackInfo->GetNTrackRefs(), nRefs)); | |
1ee39b3a | 503 | } |
504 | ||
505 | // copy some relevant info to TRD track info | |
506 | fTrackInfo->SetStatus(esdTrack->GetStatus()); | |
507 | fTrackInfo->SetTrackId(esdTrack->GetID()); | |
508 | Double_t p[AliPID::kSPECIES]; esdTrack->GetTRDpid(p); | |
509 | fTrackInfo->SetESDpid(p); | |
510 | fTrackInfo->SetESDpidQuality(esdTrack->GetTRDntrackletsPID()); | |
f232df0d | 511 | if(!nSlices) nSlices = esdTrack->GetNumberOfTRDslices(); |
512 | memset(dedx, 0, 100*sizeof(Double32_t)); | |
92c40e64 | 513 | Int_t in(0); |
514 | for(Int_t il=0; il<AliTRDgeometry::kNlayer; il++) | |
515 | for(Int_t is=0; is<nSlices; is++) | |
516 | dedx[in++]=esdTrack->GetTRDslice(il, is); | |
517 | for(Int_t il=0; il<AliTRDgeometry::kNlayer; il++) dedx[in++]=esdTrack->GetTRDmomentum(il); | |
518 | fTrackInfo->SetSlices(in, dedx); | |
1ee39b3a | 519 | fTrackInfo->SetNumberOfClustersRefit(esdTrack->GetNcls(2)); |
520 | // some other Informations which we may wish to store in order to find problematic cases | |
521 | fTrackInfo->SetKinkIndex(esdTrack->GetKinkIndex(0)); | |
522 | fTrackInfo->SetTPCncls(static_cast<UShort_t>(esdTrack->GetNcls(1))); | |
523 | nclsTrklt = 0; | |
524 | ||
d80a6a00 | 525 | // set V0pid info |
d80a6a00 | 526 | for(Int_t iv(0); iv<fV0List->GetEntriesFast(); iv++){ |
527 | if(!(v0info = (AliTRDv0Info*)fV0List->At(iv))) continue; | |
64d57299 | 528 | if(!v0info->GetV0Daughter(1) && !v0info->GetV0Daughter(-1)) continue; |
d80a6a00 | 529 | if(!v0info->HasTrack(fTrackInfo)) continue; |
530 | memset(v0pid, 0, AliPID::kSPECIES*sizeof(Int_t)); | |
531 | fTrackInfo->SetV0(); | |
532 | for(Int_t is=AliPID::kSPECIES; is--;){v0pid[is] = v0info->GetPID(is, fTrackInfo);} | |
533 | fTrackInfo->SetV0pid(v0pid); | |
534 | fTrackInfo->SetV0(); | |
535 | //const AliTRDtrackInfo::AliESDinfo *ei = fTrackInfo->GetESDinfo(); | |
536 | break; | |
537 | } | |
1ee39b3a | 538 | |
539 | // read REC info | |
540 | esdFriendTrack = fESDfriend->GetTrack(itrk); | |
541 | if(esdFriendTrack){ | |
542 | Int_t icalib = 0; | |
543 | while((calObject = esdFriendTrack->GetCalibObject(icalib++))){ | |
544 | if(strcmp(calObject->IsA()->GetName(),"AliTRDtrackV1") != 0) continue; // Look for the TRDtrack | |
545 | if(!(track = dynamic_cast<AliTRDtrackV1*>(calObject))) break; | |
1ee39b3a | 546 | AliDebug(4, Form("TRD track OK")); |
547 | // Set the clusters to unused | |
548 | for(Int_t ipl = 0; ipl < AliTRDgeometry::kNlayer; ipl++){ | |
549 | if(!(tracklet = track->GetTracklet(ipl))) continue; | |
550 | tracklet->ResetClusterIter(); | |
551 | while((cl = tracklet->NextCluster())) cl->Use(0); | |
552 | } | |
553 | fTrackInfo->SetTrack(track); | |
554 | break; | |
555 | } | |
556 | AliDebug(3, Form("Ntracklets[%d]\n", fTrackInfo->GetNTracklets())); | |
557 | } else AliDebug(3, "No ESD friends"); | |
558 | if(op) fTrackInfo->SetOuterParam(op); | |
559 | ||
560 | if(DebugLevel() >= 1){ | |
561 | AliTRDtrackInfo info(*fTrackInfo); | |
562 | (*DebugStream()) << "trackInfo" | |
563 | << "TrackInfo.=" << &info | |
564 | << "\n"; | |
565 | info.Delete(""); | |
566 | } | |
705f8b0a | 567 | |
568 | ULong_t status(esdTrack->GetStatus()); | |
569 | if((status&AliESDtrack::kTPCout)){ | |
570 | if(!esdTrack->GetKinkIndex(0)){ // Barrel Track Selection | |
571 | Bool_t selected(kTRUE); | |
572 | if(UseLocalTrkSelection()){ | |
55d5090e | 573 | if(esdTrack->Pt() < fgkPt){ |
574 | AliDebug(2, Form("Reject Ev[%4d] Trk[%3d] Pt[%5.2f]", fESDev->GetEventNumberInFile(), itrk, esdTrack->Pt())); | |
575 | selected = kFALSE; | |
576 | } | |
dfd7d48b | 577 | if(selected && TMath::Abs(esdTrack->Eta()) > fgkEta){ |
55d5090e | 578 | AliDebug(2, Form("Reject Ev[%4d] Trk[%3d] Eta[%5.2f]", fESDev->GetEventNumberInFile(), itrk, TMath::Abs(esdTrack->Eta()))); |
579 | selected = kFALSE; | |
580 | } | |
dfd7d48b | 581 | if(selected && esdTrack->GetTPCNcls() < fgkNclTPC){ |
55d5090e | 582 | AliDebug(2, Form("Reject Ev[%4d] Trk[%3d] NclTPC[%d]", fESDev->GetEventNumberInFile(), itrk, esdTrack->GetTPCNcls())); |
583 | selected = kFALSE; | |
584 | } | |
705f8b0a | 585 | Float_t par[2], cov[3]; |
586 | esdTrack->GetImpactParameters(par, cov); | |
587 | if(IsCollision()){ // cuts on DCA | |
dfd7d48b | 588 | if(selected && TMath::Abs(par[0]) > fgkTrkDCAxy){ |
55d5090e | 589 | AliDebug(2, Form("Reject Ev[%4d] Trk[%3d] DCAxy[%f]", fESDev->GetEventNumberInFile(), itrk, TMath::Abs(par[0]))); |
590 | selected = kFALSE; | |
591 | } | |
dfd7d48b | 592 | if(selected && TMath::Abs(par[1]) > fgkTrkDCAz){ |
55d5090e | 593 | AliDebug(2, Form("Reject Ev[%4d] Trk[%3d] DCAz[%f]", fESDev->GetEventNumberInFile(), itrk, TMath::Abs(par[1]))); |
594 | selected = kFALSE; | |
595 | } | |
dfd7d48b | 596 | } else if(selected && fMCev && !fMCev->IsPhysicalPrimary(alab)){; |
597 | AliDebug(2, Form("Reject Ev[%4d] Trk[%3d] Primary", fESDev->GetEventNumberInFile(), itrk)); | |
598 | selected = kFALSE; | |
705f8b0a | 599 | } |
600 | } | |
601 | if(fTrackCut && !fTrackCut->IsSelected(esdTrack)) selected = kFALSE; | |
3d2a3dff | 602 | if(selected){ |
603 | fTracksBarrel->Add(new AliTRDtrackInfo(*fTrackInfo)); | |
604 | nBarrel++; | |
08d1f138 | 605 | if(fTrackInfo->GetTrack()) |
606 | nBarrelFriend++; | |
3d2a3dff | 607 | } |
608 | } else { | |
609 | fTracksKink->Add(new AliTRDtrackInfo(*fTrackInfo)); | |
610 | nKink++; | |
611 | } | |
612 | } else if((status&AliESDtrack::kTRDout) && !(status&AliESDtrack::kTRDin)){ | |
613 | fTracksSA->Add(new AliTRDtrackInfo(*fTrackInfo)); | |
614 | nSA++; | |
08d1f138 | 615 | if(fTrackInfo->GetTrack()) |
616 | nSAFriend++; | |
3d2a3dff | 617 | } |
1ee39b3a | 618 | fTrackInfo->Delete(""); |
619 | } | |
1ee39b3a | 620 | |
3d19c1b0 | 621 | // LOOP 2 - over MC tracks which are passing TRD where the track is not reconstructed |
1ee39b3a | 622 | if(HasMCdata()){ |
623 | AliDebug(10, "Output of the MC track map:"); | |
624 | for(Int_t itk = 0; itk < nTracksMC; itk++) AliDebug(10, Form("trackMap[%d] = %s", itk, trackMap[itk] == kTRUE ? "TRUE" : "kFALSE")); | |
625 | ||
626 | for(Int_t itk = 0; itk < nTracksMC; itk++){ | |
627 | if(trackMap[itk]) continue; | |
628 | AliMCParticle *mcParticle = (AliMCParticle*) fMCev->GetTrack(TMath::Abs(itk)); | |
629 | Int_t fPdg = mcParticle->Particle()->GetPdgCode(); | |
630 | Int_t nRefs = mcParticle->GetNumberOfTrackReferences(); | |
770382d9 | 631 | Int_t iref = 0; AliTrackReference *ref = NULL; |
1ee39b3a | 632 | Int_t nRefsTRD = 0; |
633 | new(fTrackInfo) AliTRDtrackInfo(); | |
4c860218 | 634 | fTrackInfo->SetMC(); |
1ee39b3a | 635 | fTrackInfo->SetPDG(fPdg); |
3d2a3dff | 636 | while(iref<nRefs){ // count TRD TR |
770382d9 | 637 | Bool_t kIN(kFALSE); |
1ee39b3a | 638 | ref = mcParticle->GetTrackReference(iref); |
3d2a3dff | 639 | if(ref->LocalX() > fgkTPC && ref->LocalX() < fgkTRD){ |
1ee39b3a | 640 | fTrackInfo->AddTrackRef(ref); |
770382d9 | 641 | nRefsTRD++;kIN=kTRUE; |
1ee39b3a | 642 | } |
770382d9 | 643 | AliDebug(4, Form(" trackRef[%2d] @ x[%7.3f] %s", iref, ref->LocalX(), kIN?"IN":"OUT")); |
1ee39b3a | 644 | iref++; |
645 | } | |
646 | if(!nRefsTRD){ | |
647 | // In this stage we at least require 1 hit inside TRD. What will be done with this tracks is a task for the | |
648 | // analysis job | |
649 | fTrackInfo->Delete(""); | |
650 | continue; | |
651 | } | |
652 | fTrackInfo->SetPrimary(mcParticle->Particle()->IsPrimary()); | |
653 | fTrackInfo->SetLabel(itk); | |
654 | if(DebugLevel() >= 1){ | |
655 | AliTRDtrackInfo info(*fTrackInfo); | |
656 | (*DebugStream()) << "trackInfo" | |
657 | << "TrackInfo.=" << &info | |
658 | << "\n"; | |
659 | info.Delete(""); | |
660 | } | |
770382d9 | 661 | AliDebug(3, Form("Add MC track @ label[%d] nTRDrefs[%d].", itk, nRefsTRD)); |
3d2a3dff | 662 | // check where the track starts |
663 | ref = mcParticle->GetTrackReference(0); | |
664 | if(ref->LocalX() < fgkITS){ | |
665 | fTracksBarrel->Add(new AliTRDtrackInfo(*fTrackInfo)); | |
666 | nBarrelMC++; | |
667 | } else if(ref->LocalX() < fgkTPC) { | |
668 | fTracksKink->Add(new AliTRDtrackInfo(*fTrackInfo)); | |
669 | nKinkMC++; | |
670 | } else if(nRefsTRD>6){ | |
671 | fTracksSA->Add(new AliTRDtrackInfo(*fTrackInfo)); | |
672 | nSAMC++; | |
673 | } | |
1ee39b3a | 674 | fTrackInfo->Delete(""); |
675 | } | |
676 | delete[] trackMap; | |
677 | } | |
b9ddd472 | 678 | AliDebug(1, Form( |
3d19c1b0 | 679 | "\nEv[%3d] Tracks: ESD[%d] MC[%d] V0[%d]\n" |
3d2a3dff | 680 | " TPCout[%d] TRDin[%d] TRDout[%d]\n" |
681 | " Barrel[%3d+%3d=%3d] SA[%2d+%2d=%2d] Kink[%2d+%2d=%2d]" | |
3d19c1b0 | 682 | ,(Int_t)AliAnalysisManager::GetAnalysisManager()->GetCurrentEntry(), nTracksESD, nTracksMC, fV0List->GetEntries() |
3d2a3dff | 683 | , nTPC, nTRDin, nTRDout |
684 | ,nBarrel, nBarrelMC, fTracksBarrel->GetEntries() | |
685 | ,nSA, nSAMC, fTracksSA->GetEntries() | |
686 | ,nKink, nKinkMC, fTracksKink->GetEntries() | |
687 | )); | |
058c3053 | 688 | // save track statistics |
689 | TH1 *h((TH1S*)fContainer->At(0)); | |
690 | h->Fill( 0., nTracksESD); | |
691 | h->Fill( 1., nTracksMC); | |
692 | h->Fill( 2., fV0List->GetEntries()); | |
693 | h->Fill( 3., nTPC); | |
694 | h->Fill( 4., nTRDin); | |
695 | h->Fill( 5., nTRDout); | |
696 | h->Fill( 6., nBarrel); | |
697 | h->Fill( 7., nBarrelMC); | |
698 | h->Fill( 8., nSA); | |
699 | h->Fill( 9., nSAMC); | |
700 | h->Fill(10., nKink); | |
701 | h->Fill(11., nKinkMC); | |
08d1f138 | 702 | h->Fill(12., nBarrelFriend); |
703 | h->Fill(13., nSAFriend); | |
3d2a3dff | 704 | |
99535225 | 705 | PostData(AliTRDpwg1Helper::kTracksBarrel, fTracksBarrel); |
706 | PostData(AliTRDpwg1Helper::kTracksSA, fTracksSA); | |
707 | PostData(AliTRDpwg1Helper::kTracksKink, fTracksKink); | |
708 | PostData(AliTRDpwg1Helper::kEventInfo, fEventInfo); | |
709 | PostData(AliTRDpwg1Helper::kV0List, fV0List); | |
705f8b0a | 710 | } |
711 | ||
3d19c1b0 | 712 | //____________________________________________________________________ |
61f6b45e | 713 | void AliTRDinfoGen::SetLocalV0Selection(const AliTRDv0Info *v0) |
3d19c1b0 | 714 | { |
715 | // Set V0 cuts from outside | |
716 | ||
717 | if(!fV0Cut) fV0Cut = new AliTRDv0Info(*v0); | |
718 | else new(fV0Cut) AliTRDv0Info(*v0); | |
719 | } | |
720 | ||
705f8b0a | 721 | //____________________________________________________________________ |
722 | void AliTRDinfoGen::SetTrigger(const Char_t *trigger) | |
723 | { | |
724 | if(!fEvTrigger) fEvTrigger = new TString(trigger); | |
725 | else (*fEvTrigger) = trigger; | |
726 | } | |
727 | ||
728 | //____________________________________________________________________ | |
729 | TTreeSRedirector* AliTRDinfoGen::DebugStream() | |
730 | { | |
61f6b45e | 731 | // Manage debug stream for task |
705f8b0a | 732 | if(!fDebugStream){ |
733 | TDirectory *savedir = gDirectory; | |
734 | fDebugStream = new TTreeSRedirector("TRD.DebugInfoGen.root"); | |
735 | savedir->cd(); | |
736 | } | |
737 | return fDebugStream; | |
1ee39b3a | 738 | } |
739 | ||
705f8b0a | 740 | |
058c3053 | 741 |