]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TRD/qaRec/AliTRDresolution.cxx
- fix in AliTRDcheckDetector in the PHs plotter that uses the cluster
[u/mrichter/AliRoot.git] / TRD / qaRec / AliTRDresolution.cxx
CommitLineData
77203477 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-commercialf 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**************************************************************************/
77203477 15
e3cf3d02 16/* $Id: AliTRDresolution.cxx 27496 2008-07-22 08:35:45Z cblume $ */
77203477 17
18////////////////////////////////////////////////////////////////////////////
19// //
017bd6af 20// TRD tracking resolution //
21//
22// The class performs resolution and residual studies
23// of the TRD tracks for the following quantities :
24// - spatial position (y, [z])
25// - angular (phi) tracklet
26// - momentum at the track level
27//
28// The class has to be used for regular detector performance checks using the official macros:
29// - $ALICE_ROOT/TRD/qaRec/run.C
30// - $ALICE_ROOT/TRD/qaRec/makeResults.C
31//
32// For stand alone usage please refer to the following example:
33// {
34// gSystem->Load("libANALYSIS.so");
35// gSystem->Load("libTRDqaRec.so");
e3cf3d02 36// AliTRDresolution *res = new AliTRDresolution();
017bd6af 37// //res->SetMCdata();
38// //res->SetVerbose();
39// //res->SetVisual();
40// res->Load("TRD.TaskResolution.root");
41// if(!res->PostProcess()) return;
42// res->GetRefFigure(0);
43// }
44//
77203477 45// Authors: //
017bd6af 46// Alexandru Bercuci <A.Bercuci@gsi.de> //
77203477 47// Markus Fasel <M.Fasel@gsi.de> //
48// //
49////////////////////////////////////////////////////////////////////////////
50
aaf47b30 51#include <cstring>
52
124d488a 53#include <TROOT.h>
017bd6af 54#include <TSystem.h>
a6264da2 55#include <TPDGCode.h>
77203477 56#include <TObjArray.h>
7102d1b1 57#include <TH2.h>
58#include <TH1.h>
59#include <TF1.h>
017bd6af 60#include <TCanvas.h>
b2dc316d 61#include <TBox.h>
77203477 62#include <TProfile.h>
7102d1b1 63#include <TGraphErrors.h>
77203477 64#include <TMath.h>
aaf47b30 65#include "TTreeStream.h"
66#include "TGeoManager.h"
77203477 67
68#include "AliAnalysisManager.h"
77203477 69#include "AliTrackReference.h"
aaf47b30 70#include "AliTrackPointArray.h"
71#include "AliCDBManager.h"
72
9605ce80 73#include "AliTRDSimParam.h"
74#include "AliTRDgeometry.h"
75#include "AliTRDpadPlane.h"
aaf47b30 76#include "AliTRDcluster.h"
77#include "AliTRDseedV1.h"
78#include "AliTRDtrackV1.h"
79#include "AliTRDtrackerV1.h"
80#include "AliTRDReconstructor.h"
81#include "AliTRDrecoParam.h"
77203477 82
b2dc316d 83#include "AliTRDtrackInfo/AliTRDclusterInfo.h"
77203477 84#include "AliTRDtrackInfo/AliTRDtrackInfo.h"
e3cf3d02 85#include "AliTRDresolution.h"
77203477 86
e3cf3d02 87ClassImp(AliTRDresolution)
77203477 88
89//________________________________________________________
e3cf3d02 90AliTRDresolution::AliTRDresolution()
91 :AliTRDrecoTask("Resolution", "Spatial and Momentum Resolution")
017bd6af 92 ,fStatus(0)
aaf47b30 93 ,fReconstructor(0x0)
9605ce80 94 ,fGeo(0x0)
b718144c 95 ,fGraphS(0x0)
96 ,fGraphM(0x0)
6fc46cba 97 ,fCl(0x0)
98 ,fTrklt(0x0)
99 ,fMCcl(0x0)
100 ,fMCtrklt(0x0)
77203477 101{
aaf47b30 102 fReconstructor = new AliTRDReconstructor();
103 fReconstructor->SetRecoParam(AliTRDrecoParam::GetLowFluxParam());
9605ce80 104 fGeo = new AliTRDgeometry();
b2dc316d 105
de520d8f 106 InitFunctorList();
b2dc316d 107
6fc46cba 108 DefineOutput(1, TObjArray::Class()); // cluster2track
109 DefineOutput(2, TObjArray::Class()); // tracklet2track
110 DefineOutput(3, TObjArray::Class()); // cluster2mc
111 DefineOutput(4, TObjArray::Class()); // tracklet2mc
77203477 112}
113
ed383798 114//________________________________________________________
e3cf3d02 115AliTRDresolution::~AliTRDresolution()
ed383798 116{
b718144c 117 if(fGraphS){fGraphS->Delete(); delete fGraphS;}
118 if(fGraphM){fGraphM->Delete(); delete fGraphM;}
9605ce80 119 delete fGeo;
ed383798 120 delete fReconstructor;
2c0cf367 121 if(gGeoManager) delete gGeoManager;
6fc46cba 122 if(fCl){fCl->Delete(); delete fCl;}
123 if(fTrklt){fTrklt->Delete(); delete fTrklt;}
124 if(fMCcl){fMCcl->Delete(); delete fMCcl;}
125 if(fMCtrklt){fMCtrklt->Delete(); delete fMCtrklt;}
ed383798 126}
127
77203477 128
129//________________________________________________________
e3cf3d02 130void AliTRDresolution::CreateOutputObjects()
77203477 131{
132 // spatial resolution
77203477 133 OpenFile(0, "RECREATE");
39779ce6 134
3d86166d 135 fContainer = Histos();
b2dc316d 136
6fc46cba 137 fCl = new TObjArray();
138 fCl->SetOwner(kTRUE);
139 fTrklt = new TObjArray();
140 fTrklt->SetOwner(kTRUE);
141 fMCcl = new TObjArray();
142 fMCcl->SetOwner(kTRUE);
143 fMCtrklt = new TObjArray();
144 fMCtrklt->SetOwner(kTRUE);
77203477 145}
146
b2dc316d 147//________________________________________________________
e3cf3d02 148void AliTRDresolution::Exec(Option_t *opt)
b2dc316d 149{
6fc46cba 150 fCl->Delete();
151 fTrklt->Delete();
152 fMCcl->Delete();
153 fMCtrklt->Delete();
b2dc316d 154
155 AliTRDrecoTask::Exec(opt);
156
6fc46cba 157 PostData(1, fCl);
158 PostData(2, fTrklt);
159 PostData(3, fMCcl);
160 PostData(4, fMCtrklt);
b2dc316d 161}
aaf47b30 162
de520d8f 163//________________________________________________________
e3cf3d02 164TH1* AliTRDresolution::PlotCluster(const AliTRDtrackV1 *track)
de520d8f 165{
74b2e03d 166 if(track) fTrack = track;
167 if(!fTrack){
168 AliWarning("No Track defined.");
169 return 0x0;
de520d8f 170 }
171 TH1 *h = 0x0;
b1957d3c 172 if(!(h = ((TH2I*)fContainer->At(kCluster)))){
de520d8f 173 AliWarning("No output histogram defined.");
174 return 0x0;
175 }
176
b1957d3c 177 Double_t cov[3];
de520d8f 178 Float_t x0, y0, z0, dy, dydx, dzdx;
179 AliTRDseedV1 *fTracklet = 0x0;
180 for(Int_t ily=0; ily<AliTRDgeometry::kNlayer; ily++){
181 if(!(fTracklet = fTrack->GetTracklet(ily))) continue;
182 if(!fTracklet->IsOK()) continue;
de520d8f 183 x0 = fTracklet->GetX0();
184
185 // retrive the track angle with the chamber
0b8bcca4 186 y0 = fTracklet->GetYref(0);
187 z0 = fTracklet->GetZref(0);
188 dydx = fTracklet->GetYref(1);
189 dzdx = fTracklet->GetZref(1);
b1957d3c 190 fTracklet->GetCovRef(cov);
251a1ae6 191 Float_t tilt = fTracklet->GetTilt();
de520d8f 192 AliTRDcluster *c = 0x0;
193 fTracklet->ResetClusterIter(kFALSE);
194 while((c = fTracklet->PrevCluster())){
0b8bcca4 195 Float_t xc = c->GetX();
196 Float_t yc = c->GetY();
197 Float_t zc = c->GetZ();
198 Float_t dx = x0 - xc;
199 Float_t yt = y0 - dx*dydx;
200 Float_t zt = z0 - dx*dzdx;
b1957d3c 201 yc -= tilt*(zc-zt); // tilt correction
202 dy = yt - yc;
0b8bcca4 203
b1957d3c 204 h->Fill(dydx, dy/TMath::Sqrt(cov[0] + c->GetSigmaY2()));
de520d8f 205
206 if(fDebugLevel>=1){
de520d8f 207 // Get z-position with respect to anode wire
834ac2c9 208 //AliTRDSimParam *simParam = AliTRDSimParam::Instance();
0b8bcca4 209 Int_t istk = fGeo->GetStack(c->GetDetector());
de520d8f 210 AliTRDpadPlane *pp = fGeo->GetPadPlane(ily, istk);
211 Float_t row0 = pp->GetRow0();
58897a75 212 Float_t d = row0 - zt + pp->GetAnodeWireOffset();
de520d8f 213 d -= ((Int_t)(2 * d)) / 2.0;
214 if (d > 0.25) d = 0.5 - d;
b2dc316d 215
94f34623 216/* AliTRDclusterInfo *clInfo = new AliTRDclusterInfo;
6fc46cba 217 fCl->Add(clInfo);
0b8bcca4 218 clInfo->SetCluster(c);
219 clInfo->SetGlobalPosition(yt, zt, dydx, dzdx);
220 clInfo->SetResolution(dy);
221 clInfo->SetAnisochronity(d);
222 clInfo->SetDriftLength(dx);
223 (*fDebugStream) << "ClusterResiduals"
224 <<"clInfo.=" << clInfo
94f34623 225 << "\n";*/
de520d8f 226 }
227 }
228 }
229 return h;
230}
231
251a1ae6 232
233//________________________________________________________
e3cf3d02 234TH1* AliTRDresolution::PlotTracklet(const AliTRDtrackV1 *track)
251a1ae6 235{
236 if(track) fTrack = track;
237 if(!fTrack){
238 AliWarning("No Track defined.");
239 return 0x0;
240 }
241 TH1 *h = 0x0;
b1957d3c 242 if(!(h = ((TH2I*)fContainer->At(kTrackletY)))){
251a1ae6 243 AliWarning("No output histogram defined.");
244 return 0x0;
245 }
246
b1957d3c 247 Double_t cov[3], covR[3];
e3cf3d02 248 Float_t x, y0, dx, dy, dydx;
b1957d3c 249 AliTRDseedV1 *fTracklet = 0x0;
250 for(Int_t il=AliTRDgeometry::kNlayer; il--;){
251 if(!(fTracklet = fTrack->GetTracklet(il))) continue;
252 if(!fTracklet->IsOK()) continue;
253 y0 = fTracklet->GetYref(0);
254 dydx = fTracklet->GetYref(1);
e3cf3d02 255 x = fTracklet->GetX();
256 dx = fTracklet->GetX0() - x;
257 dy = y0-dx*dydx - fTracklet->GetY();
258 fTracklet->GetCovAt(x, cov);
b1957d3c 259 fTracklet->GetCovRef(covR);
e9ecf70f 260 h->Fill(dydx, dy/*/TMath::Sqrt(cov[0] + covR[0])*/);
251a1ae6 261 }
262 return h;
263}
264
265//________________________________________________________
e3cf3d02 266TH1* AliTRDresolution::PlotTrackletPhi(const AliTRDtrackV1 *track)
251a1ae6 267{
268 if(track) fTrack = track;
269 if(!fTrack){
270 AliWarning("No Track defined.");
271 return 0x0;
272 }
273 TH1 *h = 0x0;
b1957d3c 274 if(!(h = ((TH2I*)fContainer->At(kTrackletPhi)))){
251a1ae6 275 AliWarning("No output histogram defined.");
276 return 0x0;
277 }
a37c3c70 278
bcdbe5e5 279 AliTRDseedV1 *tracklet = 0x0;
a37c3c70 280 for(Int_t il=0; il<AliTRDgeometry::kNlayer; il++){
a37c3c70 281 if(!(tracklet = fTrack->GetTracklet(il))) continue;
282 if(!tracklet->IsOK()) continue;
bcdbe5e5 283 h->Fill(tracklet->GetYref(1), TMath::ATan(tracklet->GetYref(1))-TMath::ATan(tracklet->GetYfit(1)));
251a1ae6 284 }
285 return h;
286}
287
288
de520d8f 289//________________________________________________________
e9ecf70f 290TH1* AliTRDresolution::PlotMC(const AliTRDtrackV1 *track)
de520d8f 291{
c0811145 292 if(!HasMCdata()){
74b2e03d 293 AliWarning("No MC defined. Results will not be available.");
de520d8f 294 return 0x0;
295 }
74b2e03d 296 if(track) fTrack = track;
297 if(!fTrack){
298 AliWarning("No Track defined.");
299 return 0x0;
de520d8f 300 }
301 TH1 *h = 0x0;
612ae7ed 302 UChar_t s;
de520d8f 303 Int_t pdg = fMC->GetPDG(), det=-1;
0b8bcca4 304 Int_t label = fMC->GetLabel();
3e778975 305 Double_t x, y, z, pt, dydx, dzdx;
306 Float_t p, pt0, x0, y0, z0, dx, dy, dz, dydx0, dzdx0;
018f98ca 307 Double_t covR[3], cov[3];
b1957d3c 308
0e08101e 309 if(fDebugLevel>=1){
310 Double_t DX[12], DY[12], DZ[12], DPt[12], COV[12][15];
311 fMC->PropagateKalman(DX, DY, DZ, DPt, COV);
312 (*fDebugStream) << "MCkalman"
313 << "pdg=" << pdg
314 << "dx0=" << DX[0]
315 << "dx1=" << DX[1]
316 << "dx2=" << DX[2]
317 << "dy0=" << DY[0]
318 << "dy1=" << DY[1]
319 << "dy2=" << DY[2]
320 << "dz0=" << DZ[0]
321 << "dz1=" << DZ[1]
322 << "dz2=" << DZ[2]
323 << "dpt0=" << DPt[0]
324 << "dpt1=" << DPt[1]
325 << "dpt2=" << DPt[2]
326 << "\n";
327 }
328
de520d8f 329 AliTRDseedV1 *fTracklet = 0x0;
330 for(Int_t ily=0; ily<AliTRDgeometry::kNlayer; ily++){
018f98ca 331 if(!(fTracklet = fTrack->GetTracklet(ily)))/* ||
332 !fTracklet->IsOK())*/ continue;
b1957d3c 333
de520d8f 334 det = fTracklet->GetDetector();
335 x0 = fTracklet->GetX0();
b1957d3c 336 //radial shift with respect to the MC reference (radial position of the pad plane)
e3cf3d02 337 x= fTracklet->GetX();
3e778975 338 if(!fMC->GetDirections(x0, y0, z0, dydx0, dzdx0, pt0, s)) continue;
018f98ca 339 // MC track position at reference radial position
340 dx = x0 - x;
e3cf3d02 341 if(fDebugLevel>=1){
342 (*fDebugStream) << "MC"
343 << "det=" << det
344 << "pdg=" << pdg
3e778975 345 << "pt=" << pt0
346 << "x=" << x0
347 << "y=" << y0
348 << "z=" << z0
349 << "dydx=" << dydx0
350 << "dzdx=" << dzdx0
e3cf3d02 351 << "\n";
352 }
3e778975 353 Float_t yt = y0 - dx*dydx0;
354 Float_t zt = z0 - dx*dzdx0;
355 p = pt0*(1.+dzdx0*dzdx0); // pt -> p
b1957d3c 356
6090b78a 357 // add Kalman residuals for y, z and pt
018f98ca 358 dx = fTracklet->GetX0() - x;
3e778975 359 y = fTracklet->GetYref(0) - dx*fTracklet->GetYref(1);
360 dy = yt - y;
361 z = fTracklet->GetZref(0) - dx*fTracklet->GetZref(1);
362 dz = zt - z;
363 dzdx = fTracklet->GetTgl();
364 pt = fTracklet->GetMomentum()/(1.+dzdx*dzdx);
e3cf3d02 365 fTracklet->GetCovRef(covR);
6090b78a 366
3e778975 367 ((TH2I*)fContainer->At(kMCtrackY))->Fill(dydx0, dy);
368 ((TH2I*)fContainer->At(kMCtrackYPull))->Fill(dydx0, dy/TMath::Sqrt(covR[0]));
e3cf3d02 369 if(ily==0){
3e778975 370 ((TH2I*)fContainer->At(kMCtrackZIn))->Fill(dzdx0, dz);
371 ((TH2I*)fContainer->At(kMCtrackZInPull))->Fill(dzdx0, dz/TMath::Sqrt(covR[2]));
e3cf3d02 372 } else if(ily==AliTRDgeometry::kNlayer-1) {
3e778975 373 ((TH2I*)fContainer->At(kMCtrackZOut))->Fill(dzdx0, dz);
374 ((TH2I*)fContainer->At(kMCtrackZOutPull))->Fill(dzdx0, dz/TMath::Sqrt(covR[2]));
e3cf3d02 375 }
3e778975 376 if(pdg!=kElectron && pdg!=kPositron) ((TH2I*)fContainer->At(kMCtrackPt))->Fill(1./pt0, pt-pt0);
b1957d3c 377 // Fill Debug stream for Kalman track
378 if(fDebugLevel>=1){
3e778975 379 dydx = fTracklet->GetYref(1);
b1957d3c 380 (*fDebugStream) << "MCtrack"
3e778975 381 << "pt=" << pt
e3cf3d02 382 << "x=" << x
3e778975 383 << "y=" << y
384 << "z=" << z
385 << "dydx=" << dydx
386 << "dzdx=" << dzdx
e3cf3d02 387 << "s2y=" << covR[0]
388 << "s2z=" << covR[2]
b1957d3c 389 << "\n";
390 }
de520d8f 391
392 // recalculate tracklet based on the MC info
393 AliTRDseedV1 tt(*fTracklet);
8d2bec9e 394 tt.SetZref(0, z0 - (x0-tt.GetX0())*dzdx0);
3e778975 395 tt.SetZref(1, dzdx0);
e3cf3d02 396 tt.Fit(kTRUE);
3e778975 397 x= tt.GetX();y= tt.GetY();z= tt.GetZ();
398 dydx = tt.GetYfit(1);
e3cf3d02 399 dx = x0 - x;
3e778975 400 yt = y0 - dx*dydx0;
401 zt = z0 - dx*dzdx0;
e3cf3d02 402 Bool_t rc = tt.IsRowCross();
403
b1957d3c 404 // add tracklet residuals for y and dydx
e3cf3d02 405 if(!rc){
3e778975 406 dy = yt-y;
4fba4b4e 407
3e778975 408 Float_t dphi = (dydx - dydx0);
409 dphi /= 1.- dydx*dydx0;
410
411 ((TH2I*)fContainer->At(kMCtrackletY))->Fill(dydx0, dy);
8d2bec9e 412 if(tt.GetS2Y()>0.) ((TH2I*)fContainer->At(kMCtrackletYPull))->Fill(dydx0, dy/TMath::Sqrt(tt.GetS2Y()));
3e778975 413 ((TH2I*)fContainer->At(kMCtrackletPhi))->Fill(dydx0, dphi*TMath::RadToDeg());
e3cf3d02 414 } else {
b1957d3c 415 // add tracklet residuals for z
3e778975 416 dz = zt-z;
417 ((TH2I*)fContainer->At(kMCtrackletZ))->Fill(dzdx0, dz);
8d2bec9e 418 if(tt.GetS2Z()>0.) ((TH2I*)fContainer->At(kMCtrackletZPull))->Fill(dzdx0, dz/TMath::Sqrt(tt.GetS2Z()));
de520d8f 419 }
420
b1957d3c 421 // Fill Debug stream for tracklet
de520d8f 422 if(fDebugLevel>=1){
0758dd40 423 Float_t s2y = tt.GetS2Y();
424 Float_t s2z = tt.GetS2Z();
b1957d3c 425 (*fDebugStream) << "MCtracklet"
e3cf3d02 426 << "rc=" << rc
427 << "x=" << x
3e778975 428 << "y=" << y
429 << "z=" << z
430 << "dydx=" << dydx
0758dd40 431 << "s2y=" << s2y
432 << "s2z=" << s2z
de520d8f 433 << "\n";
434 }
39779ce6 435
de520d8f 436 Int_t istk = AliTRDgeometry::GetStack(det);
437 AliTRDpadPlane *pp = fGeo->GetPadPlane(ily, istk);
58897a75 438 Float_t zr0 = pp->GetRow0() + pp->GetAnodeWireOffset();
de520d8f 439 Float_t tilt = fTracklet->GetTilt();
440
441 AliTRDcluster *c = 0x0;
442 fTracklet->ResetClusterIter(kFALSE);
443 while((c = fTracklet->PrevCluster())){
444 Float_t q = TMath::Abs(c->GetQ());
e9ecf70f 445 AliTRDseedV1::GetClusterXY(c,x,y);
446 //x = c->GetX(); y = c->GetY();
3e778975 447 z = c->GetZ();
448 dx = x0 - x;
449 yt = y0 - dx*dydx0;
450 zt = z0 - dx*dzdx0;
451 dy = yt - (y - tilt*(z-zt));
de520d8f 452
453 // Fill Histograms
3e778975 454 if(q>20. && q<250.) ((TH2I*)fContainer->At(kMCcluster))->Fill(dydx0, dy);
b1957d3c 455
456 // Fill calibration container
457 Float_t d = zr0 - zt;
458 d -= ((Int_t)(2 * d)) / 2.0;
459 if (d > 0.25) d = 0.5 - d;
460 AliTRDclusterInfo *clInfo = new AliTRDclusterInfo;
6fc46cba 461 fMCcl->Add(clInfo);
b1957d3c 462 clInfo->SetCluster(c);
463 clInfo->SetMC(pdg, label);
3e778975 464 clInfo->SetGlobalPosition(yt, zt, dydx0, dzdx0);
b1957d3c 465 clInfo->SetResolution(dy);
466 clInfo->SetAnisochronity(d);
fd40f855 467 clInfo->SetDriftLength(dx-.5*AliTRDgeometry::CamHght());
b1957d3c 468 clInfo->SetTilt(tilt);
b2dc316d 469
b1957d3c 470 // Fill Debug Tree
471 if(fDebugLevel>=2){
b2dc316d 472 //clInfo->Print();
b1957d3c 473 (*fDebugStream) << "MCcluster"
b2dc316d 474 <<"clInfo.=" << clInfo
de520d8f 475 << "\n";
476 }
477 }
77203477 478 }
de520d8f 479 return h;
77203477 480}
481
de520d8f 482
d85cd79c 483//________________________________________________________
e3cf3d02 484Bool_t AliTRDresolution::GetRefFigure(Int_t ifig)
d85cd79c 485{
b1957d3c 486 Float_t y[2] = {0., 0.};
b2dc316d 487 TBox *b = 0x0;
a391a274 488 TAxis *ax = 0x0;
489 TGraphErrors *g = 0x0;
d85cd79c 490 switch(ifig){
b1957d3c 491 case kCluster:
de520d8f 492 if(!(g = (TGraphErrors*)fGraphS->At(ifig))) break;
a391a274 493 g->Draw("apl");
494 ax = g->GetHistogram()->GetYaxis();
b1957d3c 495 y[0] = -0.5; y[1] = 2.5;
496 ax->SetRangeUser(y[0], y[1]);
e9ecf70f 497 ax->SetTitle("Cluster-Track Pulls #sigma/#mu [mm]");
a391a274 498 ax = g->GetHistogram()->GetXaxis();
017bd6af 499 ax->SetTitle("tg(#phi)");
de520d8f 500 if(!(g = (TGraphErrors*)fGraphM->At(ifig))) break;
017bd6af 501 g->Draw("pl");
b1957d3c 502 b = new TBox(-.15, y[0], .15, y[1]);
b2dc316d 503 b->SetFillStyle(3002);b->SetFillColor(kGreen);
504 b->SetLineColor(0); b->Draw();
e15179be 505 return kTRUE;
b1957d3c 506 case kTrackletY:
251a1ae6 507 if(!(g = (TGraphErrors*)fGraphS->At(ifig))) break;
508 g->Draw("apl");
509 ax = g->GetHistogram()->GetYaxis();
a37c3c70 510 ax->SetRangeUser(-.5, 3.);
e9ecf70f 511 ax->SetTitle("Tracklet-Track Y-Pulls #sigma/#mu [mm]");
251a1ae6 512 ax = g->GetHistogram()->GetXaxis();
513 ax->SetTitle("tg(#phi)");
514 if(!(g = (TGraphErrors*)fGraphM->At(ifig))) break;
515 g->Draw("pl");
b1957d3c 516 b = new TBox(-.15, y[0], .15, y[1]);
251a1ae6 517 b->SetFillStyle(3002);b->SetFillColor(kGreen);
518 b->SetLineColor(0); b->Draw();
e15179be 519 return kTRUE;
b1957d3c 520 case kTrackletPhi:
251a1ae6 521 if(!(g = (TGraphErrors*)fGraphS->At(ifig))) break;
522 g->Draw("apl");
523 ax = g->GetHistogram()->GetYaxis();
a37c3c70 524 ax->SetRangeUser(-.5, 2.);
b1957d3c 525 ax->SetTitle("Tracklet-Track Phi-Residuals #sigma/#mu [rad]");
251a1ae6 526 ax = g->GetHistogram()->GetXaxis();
527 ax->SetTitle("tg(#phi)");
528 if(!(g = (TGraphErrors*)fGraphM->At(ifig))) break;
529 g->Draw("pl");
b1957d3c 530 b = new TBox(-.15, y[0], .15, y[1]);
251a1ae6 531 b->SetFillStyle(3002);b->SetFillColor(kGreen);
532 b->SetLineColor(0); b->Draw();
e15179be 533 return kTRUE;
b1957d3c 534 case kMCcluster:
de520d8f 535 if(!(g = (TGraphErrors*)fGraphS->At(ifig))) break;
a391a274 536 ax = g->GetHistogram()->GetYaxis();
4fba4b4e 537 y[0] = -50.; y[1] = 600.;
b1957d3c 538 ax->SetRangeUser(y[0], y[1]);
4fba4b4e 539 ax->SetTitle("Y_{cluster} #sigma/#mu [#mum]");
b718144c 540 ax = g->GetHistogram()->GetXaxis();
834ac2c9 541 ax->SetRangeUser(-.3, .3);
017bd6af 542 ax->SetTitle("tg(#phi)");
b718144c 543 g->Draw("apl");
de520d8f 544 if(!(g = (TGraphErrors*)fGraphM->At(ifig))) break;
017bd6af 545 g->Draw("pl");
b1957d3c 546 b = new TBox(-.15, y[0], .15, y[1]);
547 b->SetFillStyle(3002);b->SetFillColor(kBlue);
b2dc316d 548 b->SetLineColor(0); b->Draw();
e15179be 549 return kTRUE;
b1957d3c 550 case kMCtrackletY:
de520d8f 551 if(!(g = (TGraphErrors*)fGraphS->At(ifig))) break;
b718144c 552 ax = g->GetHistogram()->GetYaxis();
4fba4b4e 553 y[0] = -50.; y[1] = 250.;
b1957d3c 554 ax->SetRangeUser(y[0], y[1]);
4fba4b4e 555 ax->SetTitle("Y_{tracklet} #sigma/#mu [#mum]");
a391a274 556 ax = g->GetHistogram()->GetXaxis();
834ac2c9 557 ax->SetRangeUser(-.2, .2);
612ae7ed 558 ax->SetTitle("tg(#phi)");
de520d8f 559 g->Draw("apl");
560 if(!(g = (TGraphErrors*)fGraphM->At(ifig))) break;
561 g->Draw("pl");
b1957d3c 562 b = new TBox(-.15, y[0], .15, y[1]);
563 b->SetFillStyle(3002);b->SetFillColor(kBlue);
564 b->SetLineColor(0); b->Draw();
e15179be 565 return kTRUE;
b1957d3c 566 case kMCtrackletZ:
de520d8f 567 if(!(g = (TGraphErrors*)fGraphS->At(ifig))) break;
568 ax = g->GetHistogram()->GetYaxis();
4fba4b4e 569 ax->SetRangeUser(-50., 700.);
570 ax->SetTitle("Z_{tracklet} #sigma/#mu [#mum]");
de520d8f 571 ax = g->GetHistogram()->GetXaxis();
612ae7ed 572 ax->SetTitle("tg(#theta)");
a391a274 573 g->Draw("apl");
de520d8f 574 if(!(g = (TGraphErrors*)fGraphM->At(ifig))) break;
017bd6af 575 g->Draw("pl");
e15179be 576 return kTRUE;
b1957d3c 577 case kMCtrackletPhi:
de520d8f 578 if(!(g = (TGraphErrors*)fGraphS->At(ifig))) break;
a391a274 579 ax = g->GetHistogram()->GetYaxis();
b1957d3c 580 y[0] = -.05; y[1] = .2;
581 ax->SetRangeUser(y[0], y[1]);
582 ax->SetTitle("#Phi_{tracklet} #sigma/#mu [deg]");
a391a274 583 ax = g->GetHistogram()->GetXaxis();
de520d8f 584 ax->SetTitle("tg(#phi)");
a391a274 585 g->Draw("apl");
de520d8f 586 if(!(g = (TGraphErrors*)fGraphM->At(ifig))) break;
017bd6af 587 g->Draw("pl");
e15179be 588 return kTRUE;
b1957d3c 589 case kMCtrackY:
590 if(!(g = (TGraphErrors*)fGraphS->At(ifig))) break;
591 ax = g->GetHistogram()->GetYaxis();
4fba4b4e 592 y[0] = -50.; y[1] = 200.;
b1957d3c 593 ax->SetRangeUser(y[0], y[1]);
4fba4b4e 594 ax->SetTitle("Y_{track} #sigma/#mu [#mum]");
b1957d3c 595 ax = g->GetHistogram()->GetXaxis();
834ac2c9 596 ax->SetRangeUser(-.2, .2);
b1957d3c 597 ax->SetTitle("tg(#phi)");
598 g->Draw("apl");
599 if(!(g = (TGraphErrors*)fGraphM->At(ifig))) break;
600 g->Draw("pl");
601 b = new TBox(-.15, y[0], .15, y[1]);
602 b->SetFillStyle(3002);b->SetFillColor(kBlue);
603 b->SetLineColor(0); b->Draw();
d937ad7a 604 return kTRUE;
e3cf3d02 605 case kMCtrackZIn:
e9ecf70f 606 case kMCtrackZOut:
b1957d3c 607 if(!(g = (TGraphErrors*)fGraphS->At(ifig))) break;
608 ax = g->GetHistogram()->GetYaxis();
4fba4b4e 609 ax->SetRangeUser(-500., 2000.);
610 ax->SetTitle(Form("Z_{track}^{%s} #sigma/#mu [#mum]", ifig==kMCtrackZIn ? "in" : "out"));
b1957d3c 611 ax = g->GetHistogram()->GetXaxis();
612 ax->SetTitle("tg(#theta)");
613 g->Draw("apl");
614 if(!(g = (TGraphErrors*)fGraphM->At(ifig))) break;
615 g->Draw("pl");
d937ad7a 616 return kTRUE;
6090b78a 617 case kMCtrackPt:
618 if(!(g = (TGraphErrors*)fGraphS->At(ifig))) break;
619 ax = g->GetHistogram()->GetYaxis();
620 ax->SetRangeUser(-.5, 2.);
621 ax->SetTitle("#epsilon_{P_{t}}^{track} / #mu [%]");
622 ax = g->GetHistogram()->GetXaxis();
623 ax->SetTitle("1/p_{t}");
624 g->Draw("apl");
625 if(!(g = (TGraphErrors*)fGraphM->At(ifig))) break;
626 g->Draw("pl");
627 return kTRUE;
e9ecf70f 628 case kMCtrackletYPull:
629 case kMCtrackletZPull:
630 case kMCtrackYPull:
631 case kMCtrackZInPull:
632 case kMCtrackZOutPull:
633 if(!(g = (TGraphErrors*)fGraphS->At(ifig))) break;
634 ax = g->GetHistogram()->GetYaxis();
635 ax->SetRangeUser(-.5, 2.);
636 ax->SetTitle("MC Pulls");
637 g->Draw("apl");
638 if(!(g = (TGraphErrors*)fGraphM->At(ifig))) break;
639 g->Draw("pl");
640 return kTRUE;
d85cd79c 641 }
017bd6af 642 AliInfo(Form("Reference plot [%d] missing result", ifig));
e15179be 643 return kFALSE;
d85cd79c 644}
645
39779ce6 646
77203477 647//________________________________________________________
e3cf3d02 648Bool_t AliTRDresolution::PostProcess()
7102d1b1 649{
d85cd79c 650 //fContainer = dynamic_cast<TObjArray*>(GetOutputData(0));
651 if (!fContainer) {
652 Printf("ERROR: list not available");
653 return kFALSE;
3d86166d 654 }
b718144c 655 fNRefFigures = fContainer->GetEntriesFast();
e9ecf70f 656 TGraphErrors *gm= 0x0, *gs= 0x0;
b718144c 657 if(!fGraphS){
658 fGraphS = new TObjArray(fNRefFigures);
659 fGraphS->SetOwner();
b1957d3c 660 for(Int_t ig=0; ig<fNRefFigures; ig++){
661 gs = new TGraphErrors();
662 gs->SetLineColor(kRed);
663 gs->SetMarkerStyle(23);
664 gs->SetMarkerColor(kRed);
665 gs->SetNameTitle(Form("s_%d", ig), "");
666 fGraphS->AddAt(gs, ig);
667 }
b718144c 668 }
669 if(!fGraphM){
670 fGraphM = new TObjArray(fNRefFigures);
671 fGraphM->SetOwner();
b1957d3c 672 for(Int_t ig=0; ig<fNRefFigures; ig++){
673 gm = new TGraphErrors();
674 gm->SetLineColor(kBlue);
675 gm->SetMarkerStyle(7);
676 gm->SetMarkerColor(kBlue);
677 gm->SetNameTitle(Form("m_%d", ig), "");
678 fGraphM->AddAt(gm, ig);
679 }
b718144c 680 }
7102d1b1 681
e9ecf70f 682 // DEFINE MODELS
683 // simple gauss
d2381af5 684 TF1 f("f1", "gaus", -.5, .5);
e9ecf70f 685 // gauss on a constant background
017bd6af 686 TF1 fb("fb", "[0]*exp(-0.5*((x-[1])/[2])**2)+[3]", -.5, .5);
e9ecf70f 687 // gauss on a gauss background
b718144c 688 TF1 fc("fc", "[0]*exp(-0.5*((x-[1])/[2])**2)+[3]*exp(-0.5*((x-[4])/[5])**2)", -.5, .5);
874acced 689
017bd6af 690
e9ecf70f 691 //PROCESS EXPERIMENTAL DISTRIBUTIONS
874acced 692
693 // Clusters residuals
e9ecf70f 694 Process(kCluster, &f);
d2381af5 695
251a1ae6 696 // Tracklet y residuals
e9ecf70f 697 Process(kTrackletY, &f);
251a1ae6 698
699 // Tracklet phi residuals
e9ecf70f 700 Process(kTrackletPhi, &f);
251a1ae6 701
e9ecf70f 702 if(!HasMCdata()) return kTRUE;
251a1ae6 703
874acced 704
b1957d3c 705 //PROCESS MC RESIDUAL DISTRIBUTIONS
706
707 // cluster y resolution
4fba4b4e 708 Process(kMCcluster, &f, 1.e4);
b1957d3c 709
e9ecf70f 710 // tracklet resolution
4fba4b4e 711 Process(kMCtrackletY, &f, 1.e4); // y
712 Process(kMCtrackletZ, &f, 1.e4); // z
e9ecf70f 713 Process(kMCtrackletPhi, &f); // phi
b1957d3c 714
e9ecf70f 715 // tracklet pulls
716 Process(kMCtrackletYPull, &f); // y
717 Process(kMCtrackletZPull, &f); // z
b1957d3c 718
e9ecf70f 719 // track resolution
4fba4b4e 720 Process(kMCtrackY, &f, 1.e4); // y
721 Process(kMCtrackZIn, &f, 1.e4); // z towards TPC
722 Process(kMCtrackZOut, &f, 1.e4); // z towards TOF
b1957d3c 723
e9ecf70f 724 // track pulls
725 Process(kMCtrackYPull, &f); // y
726 Process(kMCtrackZInPull, &f); // z towards TPC
727 Process(kMCtrackZOutPull, &f); // z towards TOF
b1957d3c 728
6090b78a 729 // track Pt resolution
e9ecf70f 730 TH2I *h2 = (TH2I*)fContainer->At(kMCtrackPt);
6090b78a 731 TAxis *ax = h2->GetXaxis();
732 gm = (TGraphErrors*)fGraphM->At(kMCtrackPt);
733 gs = (TGraphErrors*)fGraphS->At(kMCtrackPt);
734 TF1 fg("fg", "gaus", -1.5, 1.5);
735 TF1 fl("fl", "landau", -4., 15.);
736 TF1 fgl("fgl", "gaus(0)+landau(3)", -5., 20.);
737 for(Int_t ip=1; ip<=ax->GetNbins(); ip++){
e9ecf70f 738 TH1D *h = h2->ProjectionY("ppt", ip, ip);
6090b78a 739 if(h->GetEntries()<70) continue;
740
741 h->Fit(&fg, "QN", "", -1.5, 1.5);
742 fgl.SetParameter(0, fg.GetParameter(0));
743 fgl.SetParameter(1, fg.GetParameter(1));
744 fgl.SetParameter(2, fg.GetParameter(2));
745 h->Fit(&fl, "QN", "", -4., 15.);
746 fgl.SetParameter(3, fl.GetParameter(0));
747 fgl.SetParameter(4, fl.GetParameter(1));
748 fgl.SetParameter(5, fl.GetParameter(2));
749
e9ecf70f 750 h->Fit(&fgl, "NQ", "", -5., 20.);
6090b78a 751
752 Float_t invpt = ax->GetBinCenter(ip);
753 Int_t ip = gm->GetN();
754 gm->SetPoint(ip, invpt, fgl.GetParameter(1));
755 gm->SetPointError(ip, 0., fgl.GetParError(1));
756 gs->SetPoint(ip, invpt, fgl.GetParameter(2)*invpt);
757 gs->SetPointError(ip, 0., fgl.GetParError(2));
758 // fgl.GetParameter(4) // Landau MPV
759 // fgl.GetParameter(5) // Landau Sigma
760 }
761
b1957d3c 762
d85cd79c 763 return kTRUE;
764}
765
766
767//________________________________________________________
e3cf3d02 768void AliTRDresolution::Terminate(Option_t *)
d85cd79c 769{
770 if(fDebugStream){
771 delete fDebugStream;
772 fDebugStream = 0x0;
773 fDebugLevel = 0;
774 }
775 if(HasPostProcess()) PostProcess();
874acced 776}
d2381af5 777
3c3d9ff1 778//________________________________________________________
e3cf3d02 779void AliTRDresolution::AdjustF1(TH1 *h, TF1 *f)
3c3d9ff1 780{
781// Helper function to avoid duplication of code
782// Make first guesses on the fit parameters
783
784 // find the intial parameters of the fit !! (thanks George)
785 Int_t nbinsy = Int_t(.5*h->GetNbinsX());
786 Double_t sum = 0.;
787 for(Int_t jbin=nbinsy-4; jbin<=nbinsy+4; jbin++) sum+=h->GetBinContent(jbin); sum/=9.;
788 f->SetParLimits(0, 0., 3.*sum);
789 f->SetParameter(0, .9*sum);
790
017bd6af 791 f->SetParLimits(1, -.2, .2);
612ae7ed 792 f->SetParameter(1, -0.1);
3c3d9ff1 793
017bd6af 794 f->SetParLimits(2, 0., 4.e-1);
3c3d9ff1 795 f->SetParameter(2, 2.e-2);
017bd6af 796 if(f->GetNpar() <= 4) return;
3c3d9ff1 797
798 f->SetParLimits(3, 0., sum);
799 f->SetParameter(3, .1*sum);
800
801 f->SetParLimits(4, -.3, .3);
802 f->SetParameter(4, 0.);
803
804 f->SetParLimits(5, 0., 1.e2);
805 f->SetParameter(5, 2.e-1);
3c3d9ff1 806}
807
874acced 808//________________________________________________________
e3cf3d02 809TObjArray* AliTRDresolution::Histos()
874acced 810{
cf194b94 811 if(fContainer) return fContainer;
812
e3cf3d02 813 fContainer = new TObjArray(kNhistos);
94f34623 814 //fContainer->SetOwner(kTRUE);
cf194b94 815
b11eae29 816 TH1 *h = 0x0;
cf194b94 817 // cluster to tracklet residuals [2]
b1957d3c 818 if(!(h = (TH2I*)gROOT->FindObject("hCl"))){
819 h = new TH2I("hCl", "Clusters-Track Residuals", 21, -.33, .33, 100, -.5, .5);
124d488a 820 h->GetXaxis()->SetTitle("tg(#phi)");
821 h->GetYaxis()->SetTitle("#Delta y [cm]");
822 h->GetZaxis()->SetTitle("entries");
823 } else h->Reset();
b1957d3c 824 fContainer->AddAt(h, kCluster);
124d488a 825
251a1ae6 826 // tracklet to track residuals [2]
b1957d3c 827 if(!(h = (TH2I*)gROOT->FindObject("hTrkltY"))){
828 h = new TH2I("hTrkltY", "Tracklets-Track Residuals (Y)", 21, -.33, .33, 100, -.5, .5);
124d488a 829 h->GetXaxis()->SetTitle("tg(#phi)");
830 h->GetYaxis()->SetTitle("#Delta y [cm]");
831 h->GetZaxis()->SetTitle("entries");
832 } else h->Reset();
b1957d3c 833 fContainer->AddAt(h, kTrackletY);
124d488a 834
251a1ae6 835 // tracklet to track residuals angular [2]
b1957d3c 836 if(!(h = (TH2I*)gROOT->FindObject("hTrkltPhi"))){
837 h = new TH2I("hTrkltPhi", "Tracklets-Track Residuals (#Phi)", 21, -.33, .33, 100, -.5, .5);
124d488a 838 h->GetXaxis()->SetTitle("tg(#phi)");
839 h->GetYaxis()->SetTitle("#Delta phi [#circ]");
840 h->GetZaxis()->SetTitle("entries");
841 } else h->Reset();
b1957d3c 842 fContainer->AddAt(h, kTrackletPhi);
251a1ae6 843
cf194b94 844
845 // Resolution histos
d937ad7a 846 if(!HasMCdata()) return fContainer;
847
848 // cluster y resolution [0]
b1957d3c 849 if(!(h = (TH2I*)gROOT->FindObject("hMCcl"))){
850 h = new TH2I("hMCcl", "Cluster Resolution", 31, -.48, .48, 100, -.5, .5);
d937ad7a 851 h->GetXaxis()->SetTitle("tg(#phi)");
852 h->GetYaxis()->SetTitle("#Delta y [cm]");
853 h->GetZaxis()->SetTitle("entries");
854 } else h->Reset();
b1957d3c 855 fContainer->AddAt(h, kMCcluster);
d937ad7a 856
857 // tracklet y resolution [0]
b1957d3c 858 if(!(h = (TH2I*)gROOT->FindObject("hMCtrkltY"))){
e9ecf70f 859 h = new TH2I("hMCtrkltY", "Tracklet Resolution (Y)", 31, -.48, .48, 100, -.2, .2);
d937ad7a 860 h->GetXaxis()->SetTitle("tg(#phi)");
861 h->GetYaxis()->SetTitle("#Delta y [cm]");
862 h->GetZaxis()->SetTitle("entries");
863 } else h->Reset();
b1957d3c 864 fContainer->AddAt(h, kMCtrackletY);
d937ad7a 865
e3cf3d02 866 // tracklet y resolution [0]
867 if(!(h = (TH2I*)gROOT->FindObject("hMCtrkltYPull"))){
868 h = new TH2I("hMCtrkltYPull", "Tracklet Pulls (Y)", 31, -.48, .48, 100, -3.5, 3.5);
869 h->GetXaxis()->SetTitle("tg(#phi)");
870 h->GetYaxis()->SetTitle("#Delta y / #sigma_{y}");
871 h->GetZaxis()->SetTitle("entries");
872 } else h->Reset();
873 fContainer->AddAt(h, kMCtrackletYPull);
874
d937ad7a 875 // tracklet y resolution [0]
b1957d3c 876 if(!(h = (TH2I*)gROOT->FindObject("hMCtrkltZ"))){
877 h = new TH2I("hMCtrkltZ", "Tracklet Resolution (Z)", 31, -.48, .48, 100, -.5, .5);
d937ad7a 878 h->GetXaxis()->SetTitle("tg(#theta)");
879 h->GetYaxis()->SetTitle("#Delta z [cm]");
880 h->GetZaxis()->SetTitle("entries");
881 } else h->Reset();
b1957d3c 882 fContainer->AddAt(h, kMCtrackletZ);
d937ad7a 883
e3cf3d02 884 // tracklet y resolution [0]
885 if(!(h = (TH2I*)gROOT->FindObject("hMCtrkltZPull"))){
e9ecf70f 886 h = new TH2I("hMCtrkltZPull", "Tracklet Pulls (Z)", 31, -.48, .48, 100, -3.5, 3.5);
e3cf3d02 887 h->GetXaxis()->SetTitle("tg(#theta)");
888 h->GetYaxis()->SetTitle("#Delta z / #sigma_{z}");
889 h->GetZaxis()->SetTitle("entries");
890 } else h->Reset();
891 fContainer->AddAt(h, kMCtrackletZPull);
892
d937ad7a 893 // tracklet angular resolution [1]
b1957d3c 894 if(!(h = (TH2I*)gROOT->FindObject("hMCtrkltPhi"))){
895 h = new TH2I("hMCtrkltPhi", "Tracklet Resolution (#Phi)", 31, -.48, .48, 100, -10., 10.);
d937ad7a 896 h->GetXaxis()->SetTitle("tg(#phi)");
897 h->GetYaxis()->SetTitle("#Delta #phi [deg]");
898 h->GetZaxis()->SetTitle("entries");
899 } else h->Reset();
b1957d3c 900 fContainer->AddAt(h, kMCtrackletPhi);
d937ad7a 901
902 // Kalman track y resolution
b1957d3c 903 if(!(h = (TH2I*)gROOT->FindObject("hMCtrkY"))){
e9ecf70f 904 h = new TH2I("hMCtrkY", "Kalman Track Resolution (Y)", 31, -.48, .48, 100, -.2, .2);
d937ad7a 905 h->GetXaxis()->SetTitle("tg(#phi)");
906 h->GetYaxis()->SetTitle("#Delta y [cm]");
907 h->GetZaxis()->SetTitle("entries");
908 } else h->Reset();
b1957d3c 909 fContainer->AddAt(h, kMCtrackY);
d937ad7a 910
e3cf3d02 911 // Kalman track y resolution
912 if(!(h = (TH2I*)gROOT->FindObject("hMCtrkYPull"))){
913 h = new TH2I("hMCtrkYPull", "Kalman Track Pulls (Y)", 31, -.48, .48, 100, -3.5, 3.5);
914 h->GetXaxis()->SetTitle("tg(#phi)");
915 h->GetYaxis()->SetTitle("#Delta y / #sigma_{y}");
916 h->GetZaxis()->SetTitle("entries");
917 } else h->Reset();
918 fContainer->AddAt(h, kMCtrackYPull);
919
920 // Kalman track Z resolution
921 if(!(h = (TH2I*)gROOT->FindObject("hMCtrkZIn"))){
e9ecf70f 922 h = new TH2I("hMCtrkZIn", "Kalman Track Resolution (Zin)", 20, -1., 1., 100, -1., 1.);
e3cf3d02 923 h->GetXaxis()->SetTitle("tg(#theta)");
924 h->GetYaxis()->SetTitle("#Delta z [cm]");
925 h->GetZaxis()->SetTitle("entries");
926 } else h->Reset();
927 fContainer->AddAt(h, kMCtrackZIn);
928
d937ad7a 929 // Kalman track Z resolution
e3cf3d02 930 if(!(h = (TH2I*)gROOT->FindObject("hMCtrkZOut"))){
e9ecf70f 931 h = new TH2I("hMCtrkZOut", "Kalman Track Resolution (Zout)", 20, -1., 1., 100, -1., 1.);
d937ad7a 932 h->GetXaxis()->SetTitle("tg(#theta)");
933 h->GetYaxis()->SetTitle("#Delta z [cm]");
934 h->GetZaxis()->SetTitle("entries");
935 } else h->Reset();
e3cf3d02 936 fContainer->AddAt(h, kMCtrackZOut);
937
938 // Kalman track Z resolution
939 if(!(h = (TH2I*)gROOT->FindObject("hMCtrkZInPull"))){
940 h = new TH2I("hMCtrkZInPull", "Kalman Track Pulls (Zin)", 20, -1., 1., 100, -4.5, 4.5);
941 h->GetXaxis()->SetTitle("tg(#theta)");
942 h->GetYaxis()->SetTitle("#Delta z / #sigma_{z}");
943 h->GetZaxis()->SetTitle("entries");
944 } else h->Reset();
945 fContainer->AddAt(h, kMCtrackZInPull);
946
947 // Kalman track Z resolution
948 if(!(h = (TH2I*)gROOT->FindObject("hMCtrkZOutPull"))){
949 h = new TH2I("hMCtrkZOutPull", "Kalman Track Pulls (Zout)", 20, -1., 1., 100, -4.5, 4.5);
950 h->GetXaxis()->SetTitle("tg(#theta)");
951 h->GetYaxis()->SetTitle("#Delta z / #sigma_{z}");
952 h->GetZaxis()->SetTitle("entries");
953 } else h->Reset();
954 fContainer->AddAt(h, kMCtrackZOutPull);
d937ad7a 955
6090b78a 956 // Kalman track Pt resolution
957 if(!(h = (TH2I*)gROOT->FindObject("hMCtrkPt"))){
958 h = new TH2I("hMCtrkPt", "Kalman Track Resolution (Pt)", 100, 0., 2., 150, -5., 20.);
959 h->GetXaxis()->SetTitle("1/p_{t}");
960 h->GetYaxis()->SetTitle("#Delta p_{t} [GeV/c]");
961 h->GetZaxis()->SetTitle("entries");
962 } else h->Reset();
963 fContainer->AddAt(h, kMCtrackPt);
964
3d86166d 965 return fContainer;
77203477 966}
967
aaf47b30 968
e9ecf70f 969//________________________________________________________
4fba4b4e 970Bool_t AliTRDresolution::Process(ETRDresolutionPlot ip, TF1 *f, Float_t k)
e9ecf70f 971{
972 if(!fContainer || !fGraphS || !fGraphM) return kFALSE;
973 Bool_t kBUILD = kFALSE;
974 if(!f){
975 f = new TF1("f1", "gaus", -.5, .5);
976 kBUILD = kTRUE;
977 }
978
979 TH2I *h2 = 0x0;
980 if(!(h2 = (TH2I *)(fContainer->At(ip)))) return kFALSE;
981 TGraphErrors *gm = 0x0, *gs = 0x0;
982 if(!(gm=(TGraphErrors*)fGraphM->At(ip))) return kFALSE;
983 if(gm->GetN()) for(Int_t ip=gm->GetN(); ip--;) gm->RemovePoint(ip);
984 if(!(gs=(TGraphErrors*)fGraphS->At(ip))) return kFALSE;
985 if(gs->GetN()) for(Int_t ip=gs->GetN(); ip--;) gs->RemovePoint(ip);
4fba4b4e 986 Char_t pn[10]; sprintf(pn, "p%02d", ip);
e9ecf70f 987 for(Int_t ibin = 1; ibin <= h2->GetNbinsX(); ibin++){
988 Double_t x = h2->GetXaxis()->GetBinCenter(ibin);
4fba4b4e 989 TH1D *h = h2->ProjectionY(pn, ibin, ibin);
e9ecf70f 990 if(h->GetEntries()<100) continue;
991 AdjustF1(h, f);
992
4fba4b4e 993 h->Fit(f, "QN");
e9ecf70f 994
995 Int_t ip = gm->GetN();
4fba4b4e 996 gm->SetPoint(ip, x, k*f->GetParameter(1));
997 gm->SetPointError(ip, 0., k*f->GetParError(1));
998 gs->SetPoint(ip, x, k*f->GetParameter(2));
999 gs->SetPointError(ip, 0., k*f->GetParError(2));
e9ecf70f 1000 }
1001
1002 if(kBUILD) delete f;
1003 return kTRUE;
1004}
1005
aaf47b30 1006//________________________________________________________
e3cf3d02 1007void AliTRDresolution::SetRecoParam(AliTRDrecoParam *r)
aaf47b30 1008{
3d86166d 1009
aaf47b30 1010 fReconstructor->SetRecoParam(r);
1011}