Various updates
[u/mrichter/AliRoot.git] / PWGPP / TRD / AliTRDinfoGen.cxx
CommitLineData
94b94be0 1/**************************************************************************\r
2* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *\r
3* *\r
4* Author: The ALICE Off-line Project. *\r
5* Contributors are mentioned in the code where appropriate. *\r
6* *\r
7* Permission to use, copy, modify and distribute this software and its *\r
8* documentation strictly for non-commercial purposes is hereby granted *\r
9* without fee, provided that the above copyright notice appears in all *\r
10* copies and that both the copyright notice and this permission notice *\r
11* appear in the supporting documentation. The authors make no claims *\r
12* about the suitability of this software for any purpose. It is *\r
13* provided "as is" without express or implied warranty. *\r
14**************************************************************************/\r
15\r
16/* $Id: AliTRDinfoGen.cxx 27496 2008-07-22 08:35:45Z cblume $ */\r
17\r
18////////////////////////////////////////////////////////////////////////////\r
19//\r
20// Tender wagon for TRD performance/calibration train\r
21//\r
22// In this wagon the information from\r
23// - ESD\r
24// - Friends [if available]\r
25// - MC [if available]\r
26// are grouped into AliTRDtrackInfo objects and fed to worker tasks\r
27//\r
28// Authors:\r
29// Markus Fasel <M.Fasel@gsi.de>\r
30// Alexandru Bercuci <A.Bercuci@gsi.de>\r
31//\r
32////////////////////////////////////////////////////////////////////////////\r
33\r
34#include <TClonesArray.h>\r
35#include <TObjArray.h>\r
36#include <TObject.h>\r
37#include <TString.h>\r
c9b23652 38#include <TVectorT.h>\r
35983729 39#include <TH1.h>\r
40#include <TH2.h>\r
c9b23652 41#include <TCanvas.h>\r
94b94be0 42#include <TPad.h>\r
43#include <TFile.h>\r
44#include <TTree.h>\r
45#include <TROOT.h>\r
46#include <TChain.h>\r
47#include <TParticle.h>\r
48\r
49#include "AliLog.h"\r
50#include "AliAnalysisManager.h"\r
51#include "AliGeomManager.h"\r
52#include "AliCDBManager.h"\r
4e38ea4c 53#include "AliCDBStorage.h"\r
94b94be0 54#include "AliCDBEntry.h"\r
55#include "AliCDBPath.h"\r
56#include "AliESDEvent.h"\r
57#include "AliMCEvent.h"\r
58#include "AliESDInputHandler.h"\r
f073d500 59#include "AliESDInputHandlerRP.h"\r
94b94be0 60#include "AliMCEventHandler.h"\r
61\r
62#include "AliESDfriend.h"\r
63#include "AliESDfriendTrack.h"\r
64#include "AliESDHeader.h"\r
65#include "AliESDRun.h"\r
66#include "AliESDtrack.h"\r
67#include "AliESDv0.h"\r
68#include "AliESDtrackCuts.h"\r
69#include "AliMCParticle.h"\r
70#include "AliMultiplicity.h"\r
6687261d 71#include "AliCentrality.h"\r
94b94be0 72#include "AliPID.h"\r
73#include "AliStack.h"\r
74#include "AliTrackReference.h"\r
75#include "TTreeStream.h"\r
76\r
77#include <cstdio>\r
78#include <climits>\r
79#include <cstring>\r
80#include <iostream>\r
81#include <memory>\r
82\r
83#include "AliTRDReconstructor.h"\r
84#include "AliTRDrecoParam.h"\r
85#include "AliTRDcalibDB.h"\r
86#include "AliTRDtrackerV1.h"\r
c9b23652 87#include "AliTRDpadPlane.h"\r
94b94be0 88#include "AliTRDgeometry.h"\r
89#include "AliTRDtrackV1.h"\r
90#include "AliTRDseedV1.h"\r
91#include "AliTRDcluster.h"\r
92#include "AliTRDinfoGen.h"\r
2bfe5463 93#include "AliTRDpwgppHelper.h"\r
94b94be0 94#include "info/AliTRDtrackInfo.h"\r
95#include "info/AliTRDeventInfo.h"\r
96#include "info/AliTRDv0Info.h"\r
97#include "info/AliTRDeventCuts.h"\r
98\r
99ClassImp(AliTRDinfoGen)\r
100\r
101const Float_t AliTRDinfoGen::fgkITS = 100.; // to be checked\r
102const Float_t AliTRDinfoGen::fgkTPC = 290.;\r
103const Float_t AliTRDinfoGen::fgkTRD = 365.;\r
104\r
94b94be0 105const Float_t AliTRDinfoGen::fgkTrkDCAxy = 3.;\r
106const Float_t AliTRDinfoGen::fgkTrkDCAz = 10.;\r
107const Int_t AliTRDinfoGen::fgkNclTPC = 70;\r
108const Float_t AliTRDinfoGen::fgkPt = 0.2;\r
109const Float_t AliTRDinfoGen::fgkEta = 0.9;\r
110AliTRDReconstructor* AliTRDinfoGen::fgReconstructor(NULL);\r
111AliTRDgeometry* AliTRDinfoGen::fgGeo(NULL);\r
112//____________________________________________________________________\r
113AliTRDinfoGen::AliTRDinfoGen()\r
114 :AliAnalysisTaskSE()\r
94b94be0 115 ,fESDev(NULL)\r
116 ,fMCev(NULL)\r
117 ,fEventCut(NULL)\r
118 ,fTrackCut(NULL)\r
119 ,fV0Cut(NULL)\r
120 ,fOCDB("local://$ALICE_ROOT/OCDB")\r
121 ,fTrackInfo(NULL)\r
122 ,fEventInfo(NULL)\r
123 ,fV0Info(NULL)\r
124 ,fTracksBarrel(NULL)\r
125 ,fTracksSA(NULL)\r
126 ,fTracksKink(NULL)\r
127 ,fV0List(NULL)\r
f073d500 128 ,fClusters(NULL)\r
94b94be0 129 ,fContainer(NULL)\r
246fe7f7 130 ,fRecos(NULL)\r
94b94be0 131 ,fDebugStream(NULL)\r
132{\r
133 //\r
134 // Default constructor\r
135 //\r
136 SetNameTitle("TRDinfoGen", "MC-REC TRD-track list generator");\r
137}\r
138\r
139//____________________________________________________________________\r
140AliTRDinfoGen::AliTRDinfoGen(char* name)\r
141 :AliAnalysisTaskSE(name)\r
94b94be0 142 ,fESDev(NULL)\r
143 ,fMCev(NULL)\r
144 ,fEventCut(NULL)\r
145 ,fTrackCut(NULL)\r
146 ,fV0Cut(NULL)\r
147 ,fOCDB("local://$ALICE_ROOT/OCDB")\r
148 ,fTrackInfo(NULL)\r
149 ,fEventInfo(NULL)\r
150 ,fV0Info(NULL)\r
151 ,fTracksBarrel(NULL)\r
152 ,fTracksSA(NULL)\r
153 ,fTracksKink(NULL)\r
154 ,fV0List(NULL)\r
f073d500 155 ,fClusters(NULL)\r
94b94be0 156 ,fContainer(NULL)\r
246fe7f7 157 ,fRecos(NULL)\r
94b94be0 158 ,fDebugStream(NULL)\r
159{\r
160 //\r
161 // Default constructor\r
162 //\r
163 SetTitle("MC-REC TRD-track list generator");\r
2bfe5463 164 DefineOutput(AliTRDpwgppHelper::kTracksBarrel, TObjArray::Class());\r
165 DefineOutput(AliTRDpwgppHelper::kTracksSA, TObjArray::Class());\r
166 DefineOutput(AliTRDpwgppHelper::kTracksKink, TObjArray::Class());\r
167 DefineOutput(AliTRDpwgppHelper::kEventInfo, AliTRDeventInfo::Class());\r
168 DefineOutput(AliTRDpwgppHelper::kV0List, TObjArray::Class());\r
169 DefineOutput(AliTRDpwgppHelper::kClusters, TObjArray::Class());\r
170 DefineOutput(AliTRDpwgppHelper::kMonitor, TObjArray::Class()); // histogram list\r
94b94be0 171}\r
172\r
173//____________________________________________________________________\r
174AliTRDinfoGen::~AliTRDinfoGen()\r
175{\r
176// Destructor\r
177 if(fgGeo) delete fgGeo;\r
178 if(fgReconstructor) delete fgReconstructor;\r
179 if(fDebugStream) delete fDebugStream;\r
94b94be0 180 if(fV0Cut) delete fV0Cut;\r
181 if(fTrackCut) delete fTrackCut;\r
182 if(fEventCut) delete fEventCut;\r
183 if(fTrackInfo) delete fTrackInfo; fTrackInfo = NULL;\r
184 if(fEventInfo) delete fEventInfo; fEventInfo = NULL;\r
185 if(fV0Info) delete fV0Info; fV0Info = NULL;\r
f073d500 186 if(fTracksBarrel){\r
94b94be0 187 fTracksBarrel->Delete(); delete fTracksBarrel;\r
188 fTracksBarrel = NULL;\r
189 }\r
f073d500 190 if(fTracksSA){\r
94b94be0 191 fTracksSA->Delete(); delete fTracksSA;\r
192 fTracksSA = NULL;\r
193 }\r
194 if(fTracksKink){ \r
195 fTracksKink->Delete(); delete fTracksKink;\r
196 fTracksKink = NULL;\r
197 }\r
198 if(fV0List){ \r
199 fV0List->Delete(); \r
200 delete fV0List;\r
201 fV0List = NULL;\r
202 }\r
f073d500 203 if(fClusters){\r
204 fClusters->Delete(); delete fClusters;\r
205 fClusters = NULL;\r
206 }\r
c9b23652 207 if(fContainer && !(AliAnalysisManager::GetAnalysisManager() && AliAnalysisManager::GetAnalysisManager()->IsProofMode())){\r
94b94be0 208 fContainer->Delete(); \r
209 delete fContainer;\r
210 fContainer = NULL;\r
211 }\r
212}\r
213\r
214//____________________________________________________________________\r
215Bool_t AliTRDinfoGen::GetRefFigure(Int_t)\r
216{\r
2bfe5463 217// General graphs for PWGPP/TRD train\r
94b94be0 218 if(!gPad){\r
219 AliWarning("Please provide a canvas to draw results.");\r
220 return kFALSE;\r
221 }\r
3ceb45ae 222 fContainer->At(kStatTrk)->Draw("bar");\r
94b94be0 223 return kTRUE;\r
224}\r
225\r
226//____________________________________________________________________\r
227void AliTRDinfoGen::UserCreateOutputObjects()\r
228{ \r
229 //\r
230 // Create Output Containers (TObjectArray containing 1D histograms)\r
231 //\r
232 \r
233 fTrackInfo = new AliTRDtrackInfo();\r
234 fEventInfo = new AliTRDeventInfo();\r
235 fV0Info = new AliTRDv0Info();\r
236 fTracksBarrel = new TObjArray(200); fTracksBarrel->SetOwner(kTRUE);\r
237 fTracksSA = new TObjArray(20); fTracksSA->SetOwner(kTRUE);\r
238 fTracksKink = new TObjArray(20); fTracksKink->SetOwner(kTRUE);\r
239 fV0List = new TObjArray(10); fV0List->SetOwner(kTRUE);\r
f073d500 240 fClusters = new TObjArray(AliTRDgeometry::kNdet); fClusters->SetOwner(kTRUE);\r
94b94be0 241\r
242 // define general monitor\r
3ceb45ae 243 fContainer = new TObjArray(kNclasses); fContainer->SetOwner(kTRUE);\r
94b94be0 244 TH1 *h=new TH1I("hStat", "Run statistics;Observable;Entries", Int_t(kNObjects), -0.5, Float_t(kNObjects)-0.5);\r
245 TAxis *ax(h->GetXaxis());\r
246 ax->SetBinLabel(Int_t(kTracksESD) + 1, "ESD");\r
247 ax->SetBinLabel(Int_t(kTracksMC) + 1, "MC");\r
248 ax->SetBinLabel(Int_t(kV0) + 1, "V0");\r
249 ax->SetBinLabel(Int_t(kTPC) + 1, "TPC");\r
33056e04 250 ax->SetBinLabel(Int_t(kITS) + 1, "ITS");\r
94b94be0 251 ax->SetBinLabel(Int_t(kTRDin) + 1, "TRDin");\r
252 ax->SetBinLabel(Int_t(kTRDout) + 1, "TRDout");\r
253 ax->SetBinLabel(Int_t(kBarrel) + 1, "Barrel");\r
254 ax->SetBinLabel(Int_t(kBarrelMC) + 1, "BarrelMC");\r
255 ax->SetBinLabel(Int_t(kSA) + 1, "SA");\r
256 ax->SetBinLabel(Int_t(kSAMC) + 1, "SAMC");\r
257 ax->SetBinLabel(Int_t(kKink) + 1, "Kink");\r
258 ax->SetBinLabel(Int_t(kKinkMC) + 1, "KinkMC");\r
259 ax->SetBinLabel(Int_t(kBarrelFriend) + 1, "BFriend");\r
260 ax->SetBinLabel(Int_t(kSAFriend) + 1, "SFriend");\r
3ceb45ae 261 fContainer->AddAt(h, kStatTrk);\r
246fe7f7 262 h=new TH1I("hEv", "Run statistics;Event Class;Entries", 4, -0.5, 3.5);\r
263 ax = h->GetXaxis();\r
264 ax->SetBinLabel(1, "Low");\r
265 ax->SetBinLabel(2, "High");\r
266 ax->SetBinLabel(3, "Cosmic");\r
267 ax->SetBinLabel(4, "Calib");\r
3ceb45ae 268 fContainer->AddAt(h, kEvType);\r
6687261d 269 TH2I* h2=new TH2I("hBCtrack", "Track Statistics;Fill Bunch;TOF BC;Entries", 3500, -0.5, 3499.5, 31, -10.5, 20.5);\r
35983729 270 fContainer->AddAt(h2, kBC);\r
6465da91 271 h=new TH1I("hTriggers", "Triggers statistics;;Entries", 21, -0.5, 20.5);\r
272 fContainer->AddAt(h, kTrigger);\r
c9b23652 273 TObjArray *chmb = new TObjArray(AliTRDgeometry::kNdet);\r
274 chmb->SetName("Chambers"); chmb->SetOwner();\r
275 fContainer->AddAt(chmb, kChmb);\r
f073d500 276\r
2bfe5463 277 PostData(AliTRDpwgppHelper::kTracksBarrel, fTracksBarrel);\r
278 PostData(AliTRDpwgppHelper::kTracksSA, fTracksSA);\r
279 PostData(AliTRDpwgppHelper::kTracksKink, fTracksKink);\r
280 PostData(AliTRDpwgppHelper::kEventInfo, fEventInfo);\r
281 PostData(AliTRDpwgppHelper::kV0List, fV0List);\r
282 PostData(AliTRDpwgppHelper::kClusters, fClusters);\r
283 PostData(AliTRDpwgppHelper::kMonitor, fContainer);\r
94b94be0 284}\r
285\r
286//____________________________________________________________________\r
287Bool_t AliTRDinfoGen::Load(const Char_t *file, const Char_t *dir, const Char_t *name)\r
288{\r
289// Load data from performance file\r
290\r
291 if(!TFile::Open(file)){\r
292 AliWarning(Form("Couldn't open file %s.", file));\r
293 return kFALSE;\r
294 }\r
295 if(dir){\r
296 if(!gFile->cd(dir)){\r
297 AliWarning(Form("Couldn't cd to %s in %s.", dir, file));\r
298 return kFALSE;\r
299 }\r
300 }\r
301 TObjArray *o(NULL);\r
302 const Char_t *tn=(name ? name : GetName());\r
303 if(!(o = (TObjArray*)gDirectory->Get(tn))){\r
304 AliWarning(Form("Missing histogram container %s.", tn));\r
305 return kFALSE;\r
306 }\r
307 fContainer = (TObjArray*)o->Clone(GetName());\r
308 gFile->Close();\r
309 return kTRUE;\r
310}\r
311\r
312//____________________________________________________________________\r
313void AliTRDinfoGen::UserExec(Option_t *){\r
314 //\r
315 // Run the Analysis\r
316 //\r
317\r
318 fTracksBarrel->Delete();\r
319 fTracksSA->Delete();\r
320 fTracksKink->Delete();\r
321 fV0List->Delete();\r
f073d500 322 fClusters->Delete();\r
94b94be0 323 fEventInfo->Delete("");\r
324\r
325 fESDev = dynamic_cast<AliESDEvent*>(InputEvent());\r
326 if(!fESDev){\r
327 AliError("Failed retrieving ESD event");\r
328 return;\r
329 }\r
330 // WARNING\r
331 // This part may conflict with other detectors !!\r
4e38ea4c 332 if(!IsInitOCDB()){\r
94b94be0 333 AliCDBEntry* obj(NULL);\r
4e38ea4c 334 AliCDBManager* ocdb = AliCDBManager::Instance();\r
335 if(ocdb->IsDefaultStorageSet()){\r
c9b23652 336 AliInfo("OCDB :: initialized externally.");\r
94b94be0 337 } else {\r
4e38ea4c 338 AliInfo("OCDB :: initializing locally ...");\r
339 // prepare OCDB access\r
340 ocdb->SetDefaultStorage(fOCDB.Data());\r
b9058d72 341 //ocdb->SetSpecificStorage("TRD/Align/Data", "local:///home/niham/abercuci/local");\r
4e38ea4c 342 ocdb->SetRun(fESDev->GetRunNumber());\r
343 // create geo manager\r
344 if(!(obj = ocdb->Get(AliCDBPath("GRP", "Geometry", "Data")))){\r
345 AliError("GEOMETRY failed initialization.");\r
346 } else {\r
347 AliGeomManager::SetGeometry((TGeoManager*)obj->GetObject());\r
348 AliGeomManager::GetNalignable("TRD");\r
b9058d72 349 AliGeomManager::GetNalignable("TPC");\r
350 AliGeomManager::GetNalignable("ITS");\r
351 AliGeomManager::ApplyAlignObjsFromCDB("ITS TPC TRD");\r
4e38ea4c 352 }\r
353 //init magnetic field\r
354 if(!TGeoGlobalMagField::Instance()->IsLocked() &&\r
355 !fESDev->InitMagneticField()){\r
356 AliError("MAGNETIC FIELD failed initialization.");\r
357 }\r
358 // set no of time bins\r
359 AliTRDtrackerV1::SetNTimeBins(AliTRDcalibDB::Instance()->GetNumberOfTimeBinsDCS());\r
94b94be0 360 }\r
4e38ea4c 361 AliInfo(Form("OCDB : Loc[%s] Run[%d] TB[%d]", ocdb->GetDefaultStorage()->GetURI().Data(), ocdb->GetRun(), AliTRDtrackerV1::GetNTimeBins()));\r
362\r
363 // load misalignment\r
94b94be0 364 fgGeo = new AliTRDgeometry;\r
365 fgGeo->CreateClusterMatrixArray();\r
c9b23652 366 MakeChambers();\r
246fe7f7 367 // load reco param list from OCDB\r
99cd1793 368 AliInfo("Initializing TRD reco params ...");\r
94b94be0 369 fgReconstructor = new AliTRDReconstructor();\r
370 if(!(obj = ocdb->Get(AliCDBPath("TRD", "Calib", "RecoParam")))){\r
371 AliError("RECO PARAM failed initialization.");\r
94b94be0 372 } else {\r
373 obj->PrintMetaData();\r
246fe7f7 374 fRecos = (TObjArray*)obj->GetObject();\r
94b94be0 375 }\r
376 SetInitOCDB();\r
377 }\r
3ceb45ae 378\r
379 AliDebug(2, "+++++++++++++++++++++++++++++++++++++++");\r
380 AliDebug(2, Form("Analyse Ev[%d]", fESDev->GetEventNumberInFile()));\r
381\r
246fe7f7 382 // set reco param valid for this event\r
3ceb45ae 383 TH1 *h = (TH1I*)fContainer->At(kEvType);\r
246fe7f7 384 if(!fRecos){\r
385 fgReconstructor->SetRecoParam(AliTRDrecoParam::GetLowFluxParam());\r
386 h->Fill(0);\r
387 } else {\r
388 for(Int_t ireco(0); ireco<fRecos->GetEntriesFast(); ireco++){\r
389 AliTRDrecoParam *reco((AliTRDrecoParam*)fRecos->At(ireco));\r
390 Int_t es(reco->GetEventSpecie());\r
391 if(!(es&fESDev->GetEventSpecie())) continue;\r
392 fgReconstructor->SetRecoParam(reco);\r
2bfe5463 393 if(AliLog::GetDebugLevel("PWGPP/TRD", "AliTRDinfoGen")>5) reco->Dump();\r
246fe7f7 394 TString s;\r
395 if(es&AliRecoParam::kLowMult){ s="LowMult"; h->Fill(0);}\r
396 else if(es&AliRecoParam::kHighMult){ s="HighMult"; h->Fill(1);}\r
397 else if(es&AliRecoParam::kCosmic){ s="Cosmic"; h->Fill(2);}\r
398 else if(es&AliRecoParam::kCalib){ s="Calib"; h->Fill(3);}\r
399 else s="Unknown";\r
3ceb45ae 400 AliDebug(2, Form(" Using reco param \"%s\" for event %d.", s.Data(), fESDev->GetEventNumberInFile()));\r
246fe7f7 401 break;\r
402 }\r
403 }\r
94b94be0 404\r
405 // link MC if available\r
406 fMCev = MCEvent();\r
6465da91 407 \r
408 // trigger monitor\r
409 h = (TH1I*)fContainer->At(kTrigger);\r
410 TAxis *ax(h->GetXaxis());\r
411 TObjArray *evTriggers = fESDev->GetFiredTriggerClasses().Tokenize(" ");\r
412 for(Int_t iet(evTriggers->GetEntriesFast()); iet--;){\r
413 Int_t ix(1);\r
414 for(; ix<=ax->GetNbins(); ix++){\r
415 if(!Int_t(h->GetBinContent(ix))){\r
416 ax->SetBinLabel(ix, (*evTriggers)[iet]->GetName());\r
417 break;\r
418 }\r
35983729 419 if(strcmp((*evTriggers)[iet]->GetName(), ax->GetBinLabel(ix))==0) break;\r
6465da91 420 }\r
421 h->AddBinContent(ix);\r
422 }\r
94b94be0 423\r
35983729 424 // event selection based on vertex cuts and trigger\r
33056e04 425 if(UseLocalEvSelection() && !fEventCut->IsSelected(fESDev, IsCollision())){\r
426 AliDebug(2, "Event failed selection on vertex and trigger");\r
427 return;\r
428 }\r
94b94be0 429\r
430 if(!fESDfriend){\r
431 AliError("Failed retrieving ESD friend event");\r
432 return;\r
433 }\r
434 if(HasMCdata() && !fMCev){\r
435 AliError("Failed retrieving MC event");\r
436 return;\r
437 }\r
438\r
439 new(fEventInfo)AliTRDeventInfo(fESDev->GetHeader(), const_cast<AliESDRun *>(fESDev->GetESDRun()));\r
440 // Determine centrality\r
441 // Author: Ionut Arsene <I.C.Arsene@gsi.de>\r
f0857a6a 442 TString beamtype = fESDev->GetESDRun()->GetBeamType();\r
443 if(beamtype.Contains("Pb-Pb") || beamtype.Contains("A-A")){\r
94b94be0 444 const AliMultiplicity *mult = fESDev->GetMultiplicity();\r
6687261d 445 fEventInfo->SetMultiplicity(mult?mult->GetNumberOfTracklets():0);\r
446 const AliCentrality *cent = fESDev->GetCentrality();\r
447 // centrality for different options V0 = "V0M", ITS = "TKL" etc\r
448 fEventInfo->SetCentrality(cent?cent->GetCentralityPercentile("TKL"):-1.);\r
5591f3d6 449 AliDebug(2, Form(" Beam Type[%s] Mult[%d/%4d] Cent[%d/%5.2f]",\r
450 beamtype.Data(),\r
451 fEventInfo->GetMultiplicity(), mult?mult->GetNumberOfTracklets():0,\r
452 fEventInfo->GetCentrality(), cent?cent->GetCentralityPercentile("TKL"):-1.));\r
6687261d 453 } else {\r
454 fEventInfo->SetMultiplicity(0);\r
455 fEventInfo->SetCentrality(-1.);\r
5591f3d6 456 AliDebug(2, Form(" Beam Type[%s]", beamtype.Data()));\r
94b94be0 457 }\r
566c3d46 458 UShort_t evBC(fESDev->GetBunchCrossNumber());\r
94b94be0 459\r
460 Bool_t *trackMap(NULL);\r
461 AliStack * mStack(NULL);\r
462 Int_t nTracksMC = HasMCdata() ? fMCev->GetNumberOfTracks() : 0, nTracksESD = fESDev->GetNumberOfTracks();\r
463 if(HasMCdata()){\r
464 mStack = fMCev->Stack();\r
465 if(!mStack){\r
466 AliError("Failed retrieving MC Stack");\r
467 return;\r
468 }\r
469 trackMap = new Bool_t[nTracksMC];\r
470 memset(trackMap, 0, sizeof(Bool_t) * nTracksMC);\r
471 }\r
472 \r
473 Double32_t dedx[100]; Int_t nSlices(0);\r
33056e04 474 Int_t nTRDout(0), nTRDin(0), nTPC(0), nITS(0)\r
94b94be0 475 ,nclsTrklt\r
476 ,nBarrel(0), nSA(0), nKink(0)\r
477 ,nBarrelFriend(0), nSAFriend(0)\r
478 ,nBarrelMC(0), nSAMC(0), nKinkMC(0);\r
479 AliESDtrack *esdTrack = NULL;\r
480 AliESDfriendTrack *esdFriendTrack = NULL;\r
481 TObject *calObject = NULL;\r
482 AliTRDtrackV1 *track = NULL;\r
483 AliTRDseedV1 *tracklet = NULL;\r
484 AliTRDcluster *cl = NULL;\r
485\r
486\r
487 // LOOP 0 - over ESD v0s\r
488 Float_t bField(fESDev->GetMagneticField());\r
489 AliESDv0 *v0(NULL);\r
490 Int_t v0pid[AliPID::kSPECIES];\r
491 for(Int_t iv0(0); iv0<fESDev->GetNumberOfV0s(); iv0++){\r
492 if(!(v0 = fESDev->GetV0(iv0))) continue;\r
493 // register v0\r
494 if(fV0Cut) new(fV0Info) AliTRDv0Info(*fV0Cut);\r
495 else new(fV0Info) AliTRDv0Info();\r
496 fV0Info->SetMagField(bField);\r
497 fV0Info->SetV0tracks(fESDev->GetTrack(v0->GetPindex()), fESDev->GetTrack(v0->GetNindex()));\r
498 fV0Info->SetV0Info(v0);\r
499 fV0List->Add(new AliTRDv0Info(*fV0Info));// kFOUND=kFALSE;\r
500 }\r
501\r
502\r
503 // LOOP 1 - over ESD tracks\r
504 AliTRDv0Info *v0info=NULL;\r
505 for(Int_t itrk = 0; itrk < nTracksESD; itrk++){\r
506 new(fTrackInfo) AliTRDtrackInfo();\r
507 esdTrack = fESDev->GetTrack(itrk);\r
3ceb45ae 508 AliDebug(3, Form("\n%3d ITS[%d] TPC[%d] TRD[%d] TOF-BC[%d]\n", itrk, esdTrack->GetNcls(0), esdTrack->GetNcls(1), esdTrack->GetNcls(2), esdTrack->GetTOFBunchCrossing()));\r
33056e04 509 if(esdTrack->GetStatus()&AliESDtrack::kITSout) nITS++;\r
94b94be0 510 if(esdTrack->GetStatus()&AliESDtrack::kTPCout) nTPC++;\r
511 if(esdTrack->GetStatus()&AliESDtrack::kTRDout) nTRDout++;\r
512 if(esdTrack->GetStatus()&AliESDtrack::kTRDin) nTRDin++;\r
33056e04 513// printf(" %3d ITS[%c] TPC[%c] TRDin[%c] TRDout[%c] TRDStop[%c]\n", itrk,\r
514// (esdTrack->GetStatus()&AliESDtrack::kITSout)?'y':'n',\r
515// (esdTrack->GetStatus()&AliESDtrack::kTPCout)?'y':'n',\r
516// (esdTrack->GetStatus()&AliESDtrack::kTRDin)?'y':'n',\r
517// (esdTrack->GetStatus()&AliESDtrack::kTRDout)?'y':'n',\r
518// (esdTrack->GetStatus()&AliESDtrack::kTRDStop)?'y':'n');\r
94b94be0 519 // look at external track param\r
520 const AliExternalTrackParam *op = esdTrack->GetOuterParam();\r
521 Double_t xyz[3];\r
522 if(op){\r
523 op->GetXYZ(xyz);\r
524 op->Global2LocalPosition(xyz, op->GetAlpha());\r
525 AliDebug(3, Form("op @ X[%7.3f]\n", xyz[0]));\r
526 }\r
527\r
528 // read MC info\r
529 Int_t fPdg = -1;\r
530 Int_t label = -1; UInt_t alab=UINT_MAX;\r
531 if(HasMCdata()){\r
532 label = esdTrack->GetLabel(); \r
533 alab = TMath::Abs(label);\r
534 // register the track\r
535 if(alab < UInt_t(nTracksMC)){ \r
536 trackMap[alab] = kTRUE; \r
537 } else { \r
538 AliError(Form("MC label[%d] outside scope for Ev[%d] Trk[%d].", label, (Int_t)AliAnalysisManager::GetAnalysisManager()->GetCurrentEntry(), itrk));\r
539 continue; \r
540 }\r
541 AliMCParticle *mcParticle = NULL; \r
542 if(!(mcParticle = (AliMCParticle*) fMCev->GetTrack(alab))){\r
543 AliError(Form("MC particle label[%d] missing for Ev[%d] Trk[%d].", label, (Int_t)AliAnalysisManager::GetAnalysisManager()->GetCurrentEntry(), itrk));\r
544 continue;\r
545 }\r
546 fPdg = mcParticle->Particle()->GetPdgCode();\r
547 Int_t nRefs = mcParticle->GetNumberOfTrackReferences();\r
548 Int_t iref = 0; AliTrackReference *ref = NULL; \r
549 while(iref<nRefs){\r
550 ref = mcParticle->GetTrackReference(iref);\r
551 if(ref->LocalX() > fgkTPC) break;\r
552 iref++;\r
553 }\r
554\r
555 fTrackInfo->SetMC();\r
556 fTrackInfo->SetPDG(fPdg);\r
557 fTrackInfo->SetPrimary(mcParticle->Particle()->IsPrimary());\r
558 fTrackInfo->SetLabel(label);\r
eb05d549 559 fTrackInfo->SetTRDlabel(esdTrack->GetTRDLabel());\r
94b94be0 560 Int_t jref = iref;//, kref = 0;\r
561 while(jref<nRefs){\r
562 ref = mcParticle->GetTrackReference(jref);\r
563 if(ref->LocalX() > fgkTRD) break;\r
564 AliDebug(4, Form(" trackRef[%2d (%2d)] @ %7.3f OK", jref-iref, jref, ref->LocalX()));\r
565 fTrackInfo->AddTrackRef(ref);\r
566 jref++;\r
567 }\r
568 AliDebug(3, Form("NtrackRefs[%d(%d)]", fTrackInfo->GetNTrackRefs(), nRefs));\r
569 }\r
570\r
571 // copy some relevant info to TRD track info\r
572 fTrackInfo->SetStatus(esdTrack->GetStatus());\r
573 fTrackInfo->SetTrackId(esdTrack->GetID());\r
574 Double_t p[AliPID::kSPECIES]; esdTrack->GetTRDpid(p);\r
575 fTrackInfo->SetESDpid(p);\r
576 fTrackInfo->SetESDpidQuality(esdTrack->GetTRDntrackletsPID());\r
eb05d549 577 fTrackInfo->SetESDeta(esdTrack->Eta());\r
578 Double_t loc[3];\r
579 if(esdTrack->GetXYZAt(298., fESDev->GetMagneticField(), loc)) fTrackInfo->SetESDphi(TMath::ATan2(loc[1], loc[0]));\r
580 fTrackInfo->SetESDpt(esdTrack->Pt());\r
94b94be0 581 if(!nSlices) nSlices = esdTrack->GetNumberOfTRDslices();\r
582 memset(dedx, 0, 100*sizeof(Double32_t));\r
583 Int_t in(0);\r
584 for(Int_t il=0; il<AliTRDgeometry::kNlayer; il++)\r
585 for(Int_t is=0; is<nSlices; is++) \r
586 dedx[in++]=esdTrack->GetTRDslice(il, is);\r
587 for(Int_t il=0; il<AliTRDgeometry::kNlayer; il++) dedx[in++]=esdTrack->GetTRDmomentum(il);\r
588 fTrackInfo->SetSlices(in, dedx);\r
589 fTrackInfo->SetNumberOfClustersRefit(esdTrack->GetNcls(2));\r
590 // some other Informations which we may wish to store in order to find problematic cases\r
591 fTrackInfo->SetKinkIndex(esdTrack->GetKinkIndex(0));\r
592 fTrackInfo->SetTPCncls(static_cast<UShort_t>(esdTrack->GetNcls(1)));\r
566c3d46 593 fTrackInfo->SetTOFbc(esdTrack->GetTOFBunchCrossing()==AliVTrack::kTOFBCNA?0:esdTrack->GetTOFBunchCrossing());\r
94b94be0 594 nclsTrklt = 0;\r
595 \r
596 // set V0pid info\r
597 for(Int_t iv(0); iv<fV0List->GetEntriesFast(); iv++){\r
598 if(!(v0info = (AliTRDv0Info*)fV0List->At(iv))) continue;\r
599 if(!v0info->GetV0Daughter(1) && !v0info->GetV0Daughter(-1)) continue;\r
600 if(!v0info->HasTrack(fTrackInfo)) continue;\r
601 memset(v0pid, 0, AliPID::kSPECIES*sizeof(Int_t));\r
602 fTrackInfo->SetV0();\r
603 for(Int_t is=AliPID::kSPECIES; is--;){v0pid[is] = v0info->GetPID(is, fTrackInfo);}\r
604 fTrackInfo->SetV0pid(v0pid);\r
605 fTrackInfo->SetV0();\r
606 //const AliTRDtrackInfo::AliESDinfo *ei = fTrackInfo->GetESDinfo();\r
607 break;\r
608 }\r
609\r
f073d500 610 // read track REC info\r
33056e04 611 if((esdFriendTrack = (fESDfriend->GetNumberOfTracks() > itrk) ? fESDfriend->GetTrack(itrk): NULL)) {\r
35983729 612 fTrackInfo->SetTPCoutParam(esdFriendTrack->GetTPCOut());\r
b9058d72 613 fTrackInfo->SetITSoutParam(esdFriendTrack->GetITSOut());\r
eb05d549 614 const AliTrackPointArray *tps(NULL);\r
615 if((tps=esdFriendTrack->GetTrackPointArray()) && HasTrackPoints()) fTrackInfo->SetTrackPointArray(tps);\r
94b94be0 616 Int_t icalib = 0;\r
617 while((calObject = esdFriendTrack->GetCalibObject(icalib++))){\r
618 if(strcmp(calObject->IsA()->GetName(),"AliTRDtrackV1") != 0) continue; // Look for the TRDtrack\r
619 if(!(track = dynamic_cast<AliTRDtrackV1*>(calObject))) break;\r
620 AliDebug(4, Form("TRD track OK"));\r
621 // Set the clusters to unused\r
622 for(Int_t ipl = 0; ipl < AliTRDgeometry::kNlayer; ipl++){\r
623 if(!(tracklet = track->GetTracklet(ipl))) continue;\r
624 tracklet->ResetClusterIter();\r
625 while((cl = tracklet->NextCluster())) cl->Use(0);\r
626 }\r
627 fTrackInfo->SetTrack(track);\r
35983729 628 ((TH2I*)fContainer->At(kBC))->Fill(evBC, esdTrack->GetTOFBunchCrossing());\r
94b94be0 629 break;\r
630 }\r
33056e04 631 AliDebug(3, Form("Ntracklets[%d]", fTrackInfo->GetNTracklets()));\r
632 } else AliDebug(3, Form("No Friends for trk[%3d] Ntrk[%3d]", itrk, fESDfriend->GetNumberOfTracks()));\r
94b94be0 633 if(op) fTrackInfo->SetOuterParam(op);\r
634\r
635 if(DebugLevel() >= 1){\r
636 AliTRDtrackInfo info(*fTrackInfo);\r
637 (*DebugStream()) << "trackInfo"\r
638 << "TrackInfo.=" << &info\r
639 << "\n";\r
640 info.Delete("");\r
641 }\r
642\r
643 ULong_t status(esdTrack->GetStatus());\r
33056e04 644 if((status&AliESDtrack::kTPCout)){ // TPC prolongation\r
94b94be0 645 if(!esdTrack->GetKinkIndex(0)){ // Barrel Track Selection\r
646 Bool_t selected(kTRUE);\r
647 if(UseLocalTrkSelection()){\r
648 if(esdTrack->Pt() < fgkPt){ \r
3ceb45ae 649 AliDebug(3, Form("Reject Trk[%3d] Ev[%4d] Pt[%5.2f]", itrk, fESDev->GetEventNumberInFile(), esdTrack->Pt()));\r
94b94be0 650 selected = kFALSE;\r
651 }\r
652 if(selected && TMath::Abs(esdTrack->Eta()) > fgkEta){\r
3ceb45ae 653 AliDebug(3, Form("Reject Trk[%3d] Ev[%4d] Eta[%5.2f]", itrk, fESDev->GetEventNumberInFile(), TMath::Abs(esdTrack->Eta())));\r
94b94be0 654 selected = kFALSE;\r
655 }\r
656 if(selected && esdTrack->GetTPCNcls() < fgkNclTPC){ \r
3ceb45ae 657 AliDebug(3, Form("Reject Trk[%3d] Ev[%4d] NclTPC[%d]", itrk, fESDev->GetEventNumberInFile(), esdTrack->GetTPCNcls()));\r
94b94be0 658 selected = kFALSE;\r
659 }\r
660 Float_t par[2], cov[3];\r
661 esdTrack->GetImpactParameters(par, cov);\r
662 if(IsCollision()){ // cuts on DCA\r
663 if(selected && TMath::Abs(par[0]) > fgkTrkDCAxy){ \r
3ceb45ae 664 AliDebug(3, Form("Reject Trk[%3d] Ev[%4d] DCAxy[%f]", itrk, fESDev->GetEventNumberInFile(), TMath::Abs(par[0])));\r
94b94be0 665 selected = kFALSE;\r
666 }\r
667 if(selected && TMath::Abs(par[1]) > fgkTrkDCAz){ \r
3ceb45ae 668 AliDebug(3, Form("Reject Trk[%3d] Ev[%4d] DCAz[%f]", itrk, fESDev->GetEventNumberInFile(), TMath::Abs(par[1])));\r
94b94be0 669 selected = kFALSE;\r
670 }\r
671 } else if(selected && fMCev && !fMCev->IsPhysicalPrimary(alab)){;\r
3ceb45ae 672 AliDebug(3, Form("Reject Trk[%3d] Ev[%4d] Primary", itrk, fESDev->GetEventNumberInFile()));\r
94b94be0 673 selected = kFALSE;\r
674 }\r
675 }\r
676 if(fTrackCut && !fTrackCut->IsSelected(esdTrack)) selected = kFALSE;\r
677 if(selected){ \r
678 fTracksBarrel->Add(new AliTRDtrackInfo(*fTrackInfo));\r
679 nBarrel++;\r
680 if(fTrackInfo->GetTrack()) \r
681 nBarrelFriend++;\r
682 }\r
683 } else {\r
684 fTracksKink->Add(new AliTRDtrackInfo(*fTrackInfo));\r
685 nKink++;\r
686 }\r
33056e04 687 } else if((status&AliESDtrack::kITSout)) { // ITS prolongation \r
688 Bool_t selected(kTRUE);\r
689 if(UseLocalTrkSelection()){\r
690 if(esdTrack->Pt() < fgkPt){\r
691 AliDebug(3, Form("Reject Trk[%3d] Ev[%4d] Pt[%5.2f]", itrk, fESDev->GetEventNumberInFile(), esdTrack->Pt()));\r
692 selected = kFALSE;\r
693 }\r
694 if(selected && TMath::Abs(esdTrack->Eta()) > fgkEta){\r
695 AliDebug(3, Form("Reject Trk[%3d] Ev[%4d] Eta[%5.2f]", itrk, fESDev->GetEventNumberInFile(), TMath::Abs(esdTrack->Eta())));\r
696 selected = kFALSE;\r
697 }\r
698 Float_t par[2], cov[3];\r
699 esdTrack->GetImpactParameters(par, cov);\r
700 if(IsCollision()){ // cuts on DCA\r
701 if(selected && TMath::Abs(par[0]) > fgkTrkDCAxy){\r
702 AliDebug(3, Form("Reject Trk[%3d] Ev[%4d] DCAxy[%f]", itrk, fESDev->GetEventNumberInFile(), TMath::Abs(par[0])));\r
703 selected = kFALSE;\r
704 }\r
705 if(selected && TMath::Abs(par[1]) > fgkTrkDCAz){\r
706 AliDebug(3, Form("Reject Trk[%3d] Ev[%4d] DCAz[%f]", itrk, fESDev->GetEventNumberInFile(), TMath::Abs(par[1])));\r
707 selected = kFALSE;\r
708 }\r
709 } else if(selected && fMCev && !fMCev->IsPhysicalPrimary(alab)){;\r
710 AliDebug(3, Form("Reject Trk[%3d] Ev[%4d] Primary", itrk, fESDev->GetEventNumberInFile()));\r
711 selected = kFALSE;\r
712 }\r
713 }\r
714 if(fTrackCut && !fTrackCut->IsSelected(esdTrack)) selected = kFALSE;\r
715 if(selected){\r
716 fTracksBarrel->Add(new AliTRDtrackInfo(*fTrackInfo));\r
717 nBarrel++;\r
718 if(fTrackInfo->GetTrack())\r
719 nBarrelFriend++;\r
720 }\r
721 } else if((status&AliESDtrack::kTRDout) && !(status&AliESDtrack::kTRDin)){ // TRD SA tracking\r
94b94be0 722 fTracksSA->Add(new AliTRDtrackInfo(*fTrackInfo));\r
723 nSA++;\r
724 if(fTrackInfo->GetTrack()) \r
725 nSAFriend++;\r
726 }\r
727 fTrackInfo->Delete("");\r
728 }\r
f073d500 729 // read clusters REC info\r
56838f9d 730 TTree * treeR(NULL); AliESDInputHandlerRP *esdRPhandler(NULL);\r
731 if(fInputHandler) esdRPhandler = dynamic_cast<AliESDInputHandlerRP*>(fInputHandler);\r
732 if(esdRPhandler){\r
733 if((treeR = esdRPhandler->GetTreeR("TRD"))) {\r
178d284a 734 TObjArray *recPoints(NULL);\r
735 if((treeR->GetBranch("TRDcluster"))){\r
736 treeR->SetBranchAddress("TRDcluster", &recPoints);\r
737 for(Int_t idet(0); idet<treeR->GetEntries(); idet++){\r
738 treeR->GetEntry(idet);\r
739 if(!recPoints->GetEntries()){\r
740 AliDebug(1, Form("Missing entry %d from TreeR", idet));\r
741 continue;\r
742 }\r
743 AliTRDcluster *c = (AliTRDcluster*)(*recPoints)[0];\r
744 if(!c){\r
745 AliDebug(1, Form("Missing first cluster in entry %d from TreeR", idet));\r
746 continue;\r
747 }\r
748 fClusters->AddAt(recPoints->Clone(Form("%03d", c->GetDetector())), c->GetDetector());\r
f073d500 749 }\r
178d284a 750 } else AliDebug(3, "No TRDcluster branch");\r
751 } else AliDebug(3, "No RecPoints");\r
752 } else AliDebug(3, "No AliESDInputHandlerRP");\r
f073d500 753\r
94b94be0 754\r
755 // LOOP 2 - over MC tracks which are passing TRD where the track is not reconstructed\r
756 if(HasMCdata()){\r
757 AliDebug(10, "Output of the MC track map:");\r
758 for(Int_t itk = 0; itk < nTracksMC; itk++) AliDebug(10, Form("trackMap[%d] = %s", itk, trackMap[itk] == kTRUE ? "TRUE" : "kFALSE"));\r
759 \r
760 for(Int_t itk = 0; itk < nTracksMC; itk++){\r
761 if(trackMap[itk]) continue;\r
762 AliMCParticle *mcParticle = (AliMCParticle*) fMCev->GetTrack(TMath::Abs(itk));\r
763 Int_t fPdg = mcParticle->Particle()->GetPdgCode();\r
764 Int_t nRefs = mcParticle->GetNumberOfTrackReferences();\r
765 Int_t iref = 0; AliTrackReference *ref = NULL; \r
766 Int_t nRefsTRD = 0;\r
767 new(fTrackInfo) AliTRDtrackInfo();\r
768 fTrackInfo->SetMC();\r
769 fTrackInfo->SetPDG(fPdg);\r
770 while(iref<nRefs){ // count TRD TR\r
771 Bool_t kIN(kFALSE);\r
772 ref = mcParticle->GetTrackReference(iref);\r
773 if(ref->LocalX() > fgkTPC && ref->LocalX() < fgkTRD){\r
774 fTrackInfo->AddTrackRef(ref);\r
775 nRefsTRD++;kIN=kTRUE;\r
776 }\r
777 AliDebug(4, Form(" trackRef[%2d] @ x[%7.3f] %s", iref, ref->LocalX(), kIN?"IN":"OUT"));\r
778 iref++;\r
779 }\r
780 if(!nRefsTRD){\r
781 // In this stage we at least require 1 hit inside TRD. What will be done with this tracks is a task for the \r
782 // analysis job\r
783 fTrackInfo->Delete("");\r
784 continue;\r
785 }\r
786 fTrackInfo->SetPrimary(mcParticle->Particle()->IsPrimary());\r
787 fTrackInfo->SetLabel(itk);\r
788 if(DebugLevel() >= 1){\r
789 AliTRDtrackInfo info(*fTrackInfo);\r
790 (*DebugStream()) << "trackInfo"\r
791 << "TrackInfo.=" << &info\r
792 << "\n";\r
793 info.Delete("");\r
794 }\r
795 AliDebug(3, Form("Add MC track @ label[%d] nTRDrefs[%d].", itk, nRefsTRD));\r
796 // check where the track starts\r
797 ref = mcParticle->GetTrackReference(0);\r
798 if(ref->LocalX() < fgkITS){ \r
799 fTracksBarrel->Add(new AliTRDtrackInfo(*fTrackInfo));\r
800 nBarrelMC++;\r
801 } else if(ref->LocalX() < fgkTPC) {\r
802 fTracksKink->Add(new AliTRDtrackInfo(*fTrackInfo));\r
803 nKinkMC++;\r
804 } else if(nRefsTRD>6){\r
805 fTracksSA->Add(new AliTRDtrackInfo(*fTrackInfo));\r
806 nSAMC++;\r
807 }\r
808 fTrackInfo->Delete("");\r
809 }\r
810 delete[] trackMap;\r
811 }\r
812 AliDebug(1, Form(\r
813 "\nEv[%3d] Tracks: ESD[%d] MC[%d] V0[%d]\n"\r
33056e04 814 " TPCout[%d] ITSout[%d] TRDin[%d] TRDout[%d]\n"\r
94b94be0 815 " Barrel[%3d+%3d=%3d] SA[%2d+%2d=%2d] Kink[%2d+%2d=%2d]"\r
816 ,(Int_t)AliAnalysisManager::GetAnalysisManager()->GetCurrentEntry(), nTracksESD, nTracksMC, fV0List->GetEntries()\r
33056e04 817 , nTPC, nITS, nTRDin, nTRDout\r
94b94be0 818 ,nBarrel, nBarrelMC, fTracksBarrel->GetEntries()\r
819 ,nSA, nSAMC, fTracksSA->GetEntries()\r
820 ,nKink, nKinkMC, fTracksKink->GetEntries()\r
821 ));\r
822 // save track statistics\r
3ceb45ae 823 h = (TH1I*)fContainer->At(kStatTrk);\r
94b94be0 824 h->Fill(Float_t(kTracksESD), nTracksESD);\r
825 h->Fill(Float_t(kTracksMC), nTracksMC);\r
826 h->Fill(Float_t(kV0), fV0List->GetEntries());\r
827 h->Fill(Float_t(kTPC), nTPC);\r
33056e04 828 h->Fill(Float_t(kITS), nITS);\r
94b94be0 829 h->Fill(Float_t(kTRDin), nTRDin);\r
830 h->Fill(Float_t(kTRDout), nTRDout);\r
831 h->Fill(Float_t(kBarrel), nBarrel);\r
832 h->Fill(Float_t(kBarrelMC), nBarrelMC);\r
833 h->Fill(Float_t(kSA), nSA);\r
834 h->Fill(Float_t(kSAMC), nSAMC);\r
835 h->Fill(Float_t(kKink), nKink);\r
836 h->Fill(Float_t(kKinkMC), nKinkMC);\r
837 h->Fill(Float_t(kBarrelFriend), nBarrelFriend);\r
838 h->Fill(Float_t(kSAFriend), nSAFriend);\r
94b94be0 839}\r
840\r
c9b23652 841\r
842//____________________________________________________________________\r
843void AliTRDinfoGen::MakeChambers()\r
844{\r
845// Build chamber position and status\r
846 if(!fContainer){\r
847 AliError("Missing container");\r
848 return;\r
849 }\r
850 AliTRDcalibDB *calib(AliTRDcalibDB::Instance());\r
851 if(!calib){\r
852 AliError("No access to calibration data");\r
853 return;\r
854 }\r
855\r
c9b23652 856 Double_t alpha(0.), cs(-2.), sn(0.);\r
77cb6c6a 857 TVectorF pos(5*AliTRDgeometry::kNdet);\r
c9b23652 858 for(Int_t isec(0); isec<AliTRDgeometry::kNsector; isec++){\r
859 alpha = (0.5+isec)*AliTRDgeometry::GetAlpha();\r
860 cs = TMath::Cos(alpha);\r
861 sn = TMath::Sin(alpha);\r
862\r
863 for(Int_t istk(0); istk<AliTRDgeometry::kNstack; istk++){\r
864 for(Int_t ilyr(0); ilyr<AliTRDgeometry::kNlayer; ilyr++){\r
865 Int_t idet(AliTRDgeometry::GetDetector(ilyr, istk, isec));\r
77cb6c6a 866 Int_t jdet = 5*idet;\r
c9b23652 867 TGeoHMatrix *matrix(fgGeo->GetClusterMatrix(idet));\r
868 if(!matrix){\r
869 AliDebug(2, Form("Missing matrix for %03d [%02d_%d_%d]", idet, isec, istk, ilyr));\r
870 continue;\r
871 }\r
872 AliDebug(2, Form("Read info for %03d [%02d_%d_%d]", idet, isec, istk, ilyr));\r
873 AliTRDpadPlane *pp(fgGeo->GetPadPlane(ilyr, istk));\r
874 Double_t zm(0.5 * (pp->GetRow0() + pp->GetRowEnd())),\r
875 loc0[] = {AliTRDgeometry::AnodePos(), pp->GetCol0(), zm-pp->GetRow0()},\r
876 loc1[] = {AliTRDgeometry::AnodePos(), pp->GetColEnd(), zm-pp->GetRowEnd()},\r
877 glb[3];\r
878 matrix->LocalToMaster(loc0, glb);\r
879 Float_t phi = TMath::ATan2(glb[0]*sn + glb[1]*cs, glb[0]*cs - glb[1]*sn),\r
880 tgl = glb[2]/glb[0]/TMath::Sqrt(1.+glb[1]*glb[1]/glb[0]/glb[0]),\r
881 eta = -TMath::Log(TMath::Tan(0.5 * (0.5*TMath::Pi() - TMath::ATan(tgl))));\r
77cb6c6a 882 pos[jdet+0] = eta; pos[jdet+1] = phi;\r
c9b23652 883 matrix->LocalToMaster(loc1, glb);\r
884 phi = TMath::ATan2(glb[0]*sn + glb[1]*cs, glb[0]*cs - glb[1]*sn);\r
885 tgl = glb[2]/glb[0]/TMath::Sqrt(1.+glb[1]*glb[1]/glb[0]/glb[0]);\r
886 eta = -TMath::Log(TMath::Tan(0.5 * (0.5*TMath::Pi() - TMath::ATan(tgl))));\r
77cb6c6a 887 pos[jdet+2] = eta; pos[jdet+3] = phi;\r
888 pos[jdet+4] = 0.;\r
07b3a6a6 889 if(calib->IsChamberGood(idet)){\r
77cb6c6a 890 if(calib->IsHalfChamberNoData(idet, 0)) pos[jdet+4] += 2.;\r
891 if(calib->IsHalfChamberNoData(idet, 1)) pos[jdet+4] += 3.;\r
892 } else pos[jdet+4] = 1.;\r
c9b23652 893 }\r
894 }\r
895 }\r
77cb6c6a 896 fContainer->AddAt(new TVectorF(pos), kChmb);\r
c9b23652 897}\r
898\r
899//____________________________________________________________________\r
900void AliTRDinfoGen::MakeSummary()\r
901{\r
902// Build summary plots\r
903 if(!fContainer){\r
904 AliError("Missing results");\r
905 return;\r
906 }\r
907 TH1 *h1(NULL); TVirtualPad *p(NULL); TCanvas *cOut(NULL);\r
908\r
909 const Int_t nx(2048), ny(750);\r
910 cOut = new TCanvas(GetName(), "Run Statistics", nx, ny);\r
911 cOut->Divide(3,1, 1.e-5, 1.e-5);\r
912 //=========\r
913 p=cOut->cd(1);p->SetRightMargin(0.025);p->SetTopMargin(0.01);p->SetLogy();\r
914 h1 = (TH1*)fContainer->At(kStatTrk);\r
915 h1->SetBarOffset(0.06); h1->SetBarWidth(0.88); h1->SetFillColor(3);\r
916 h1->Draw("bar1");\r
917 //=========\r
918 p=cOut->cd(2);p->SetRightMargin(0.025);p->SetTopMargin(0.01);p->SetLogy();\r
919 h1 = (TH1*)fContainer->At(kEvType);\r
920 h1->SetBarOffset(0.04); h1->SetBarWidth(0.92);h1->SetFillColor(6);\r
921 h1->Draw("bar1");\r
922 //=========\r
923 p=cOut->cd(3);p->SetRightMargin(0.025);p->SetTopMargin(0.01);p->SetLogz();\r
924 TH2 *h2((TH2*)fContainer->At(kBC));\r
925 h1 = h2->ProjectionX("_px");\r
926 Int_t n(0); Int_t bins[3500];\r
927 for(Int_t ib(1); ib<=3500; ib++){\r
928 if(h1->GetBinContent(ib) < 1) continue;\r
929 bins[n++] = ib;\r
930 }\r
931 delete h1;\r
932\r
933 TAxis *ay(h2->GetYaxis());\r
934 TH2 *hs = new TH2I("hBC_Summary", Form("%s;%s;%s", h2->GetTitle(), h2->GetXaxis()->GetTitle(), h2->GetYaxis()->GetTitle()),\r
935 n, -0.5, n-0.5, ay->GetNbins(), ay->GetXmin(), ay->GetXmax());\r
936 hs->SetLineColor(kBlack);hs->SetLineWidth(1);\r
937 hs->SetMarkerColor(kRed);\r
938 TAxis *ax(hs->GetXaxis());\r
939 for(Int_t ib(0); ib<n; ib++){\r
940 ax->SetBinLabel(ib+1, Form("%d", bins[ib]));\r
941 for(Int_t iy(1); iy<=ay->GetNbins(); iy++){\r
942 hs->SetBinContent(ib+1, iy, h2->GetBinContent(bins[ib], iy));\r
943 }\r
944 }\r
945 hs->Draw("textbox");\r
946 cOut->SaveAs(Form("%s.gif", cOut->GetName()));\r
947}\r
948\r
94b94be0 949//____________________________________________________________________\r
35983729 950void AliTRDinfoGen::SetLocalEvSelection(const AliTRDeventCuts &ec)\r
94b94be0 951{\r
35983729 952// Set event cuts from outside\r
953 if(!fEventCut) fEventCut = new AliTRDeventCuts(ec);\r
954 else new(fEventCut) AliTRDeventCuts(ec);\r
955 fEventCut->Print();\r
94b94be0 956}\r
957\r
958//____________________________________________________________________\r
35983729 959void AliTRDinfoGen::SetLocalV0Selection(const AliTRDv0Info &v0)\r
94b94be0 960{\r
35983729 961// Set V0 cuts from outside\r
962\r
963 if(!fV0Cut) fV0Cut = new AliTRDv0Info(v0);\r
964 else new(fV0Cut) AliTRDv0Info(v0);\r
965 fV0Cut->Print();\r
94b94be0 966}\r
967\r
968//____________________________________________________________________\r
969TTreeSRedirector* AliTRDinfoGen::DebugStream()\r
970{\r
971// Manage debug stream for task\r
972 if(!fDebugStream){\r
973 TDirectory *savedir = gDirectory;\r
974 fDebugStream = new TTreeSRedirector("TRD.DebugInfoGen.root");\r
975 savedir->cd();\r
976 }\r
977 return fDebugStream;\r
978}\r
979\r
35983729 980//____________________________________________________________________\r
981void AliTRDinfoGen::Terminate(Option_t* /*option*/)\r
982{\r
983// Process run information\r
984 AliInfo("");\r
2bfe5463 985 if(!(fContainer = dynamic_cast<TObjArray *>(GetOutputData(AliTRDpwgppHelper::kMonitor)))) return;\r
35983729 986 AliInfo(Form("fContainer(%p)", (void*)fContainer));\r
987 if(UseLocalEvSelection()){\r
988 TH1 *h1 = (TH1*)fContainer->At(kTrigger); TAxis *ax(h1->GetXaxis());\r
989 AliInfo(Form("h1(%p)", (void*)h1));\r
990 for(Int_t ix(1); ix<=ax->GetNbins(); ix++){\r
991 if(fEventCut->CheckTrigger(ax->GetBinLabel(ix))) ax->SetBinLabel(ix, Form("#color[2]{%s}", ax->GetBinLabel(ix)));\r
992 }\r
993 }\r
994}\r
94b94be0 995\r