1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
16 /* $Id: AliTRDtrackingResolution.cxx 27496 2008-07-22 08:35:45Z cblume $ */
18 ////////////////////////////////////////////////////////////////////////////
20 // TRD tracking resolution //
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
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
32 // For stand alone usage please refer to the following example:
34 // gSystem->Load("libANALYSIS.so");
35 // gSystem->Load("libTRDqaRec.so");
36 // AliTRDtrackingResolution *res = new AliTRDtrackingResolution();
37 // //res->SetMCdata();
38 // //res->SetVerbose();
39 // //res->SetVisual();
40 // res->Load("TRD.TaskResolution.root");
41 // if(!res->PostProcess()) return;
42 // res->GetRefFigure(0);
46 // Alexandru Bercuci <A.Bercuci@gsi.de> //
47 // Markus Fasel <M.Fasel@gsi.de> //
49 ////////////////////////////////////////////////////////////////////////////
56 #include <TObjArray.h>
63 #include <TGraphErrors.h>
65 #include "TTreeStream.h"
66 #include "TGeoManager.h"
68 #include "AliAnalysisManager.h"
69 #include "AliTrackReference.h"
70 #include "AliTrackPointArray.h"
71 #include "AliCDBManager.h"
73 #include "AliTRDSimParam.h"
74 #include "AliTRDgeometry.h"
75 #include "AliTRDpadPlane.h"
76 #include "AliTRDcluster.h"
77 #include "AliTRDseedV1.h"
78 #include "AliTRDtrackV1.h"
79 #include "AliTRDtrackerV1.h"
80 #include "AliTRDReconstructor.h"
81 #include "AliTRDrecoParam.h"
83 #include "AliTRDtrackInfo/AliTRDclusterInfo.h"
84 #include "AliTRDtrackInfo/AliTRDtrackInfo.h"
85 #include "AliTRDtrackingResolution.h"
87 ClassImp(AliTRDtrackingResolution)
89 //________________________________________________________
90 AliTRDtrackingResolution::AliTRDtrackingResolution()
91 :AliTRDrecoTask("Resolution", "Tracking Resolution")
102 fReconstructor = new AliTRDReconstructor();
103 fReconstructor->SetRecoParam(AliTRDrecoParam::GetLowFluxParam());
104 fGeo = new AliTRDgeometry();
108 DefineOutput(1, TObjArray::Class()); // cluster2track
109 DefineOutput(2, TObjArray::Class()); // tracklet2track
110 DefineOutput(3, TObjArray::Class()); // cluster2mc
111 DefineOutput(4, TObjArray::Class()); // tracklet2mc
114 //________________________________________________________
115 AliTRDtrackingResolution::~AliTRDtrackingResolution()
117 if(fGraphS){fGraphS->Delete(); delete fGraphS;}
118 if(fGraphM){fGraphM->Delete(); delete fGraphM;}
120 delete fReconstructor;
121 if(gGeoManager) delete gGeoManager;
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;}
129 //________________________________________________________
130 void AliTRDtrackingResolution::CreateOutputObjects()
132 // spatial resolution
133 OpenFile(0, "RECREATE");
135 fContainer = Histos();
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);
147 //________________________________________________________
148 void AliTRDtrackingResolution::Exec(Option_t *opt)
155 AliTRDrecoTask::Exec(opt);
160 PostData(4, fMCtrklt);
163 //________________________________________________________
164 TH1* AliTRDtrackingResolution::PlotCluster(const AliTRDtrackV1 *track)
166 if(track) fTrack = track;
168 AliWarning("No Track defined.");
172 if(!(h = ((TH2I*)fContainer->At(kCluster)))){
173 AliWarning("No output histogram defined.");
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;
183 x0 = fTracklet->GetX0();
185 // retrive the track angle with the chamber
186 y0 = fTracklet->GetYref(0);
187 z0 = fTracklet->GetZref(0);
188 dydx = fTracklet->GetYref(1);
189 dzdx = fTracklet->GetZref(1);
190 fTracklet->GetCovRef(cov);
191 Float_t tilt = fTracklet->GetTilt();
192 AliTRDcluster *c = 0x0;
193 fTracklet->ResetClusterIter(kFALSE);
194 while((c = fTracklet->PrevCluster())){
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;
201 yc -= tilt*(zc-zt); // tilt correction
204 h->Fill(dydx, dy/TMath::Sqrt(cov[0] + c->GetSigmaY2()));
207 // Get z-position with respect to anode wire
208 AliTRDSimParam *simParam = AliTRDSimParam::Instance();
209 Int_t istk = fGeo->GetStack(c->GetDetector());
210 AliTRDpadPlane *pp = fGeo->GetPadPlane(ily, istk);
211 Float_t row0 = pp->GetRow0();
212 Float_t d = row0 - zt + pp->GetAnodeWireOffset();
213 d -= ((Int_t)(2 * d)) / 2.0;
214 if (d > 0.25) d = 0.5 - d;
216 /* AliTRDclusterInfo *clInfo = new AliTRDclusterInfo;
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
233 //________________________________________________________
234 TH1* AliTRDtrackingResolution::PlotTracklet(const AliTRDtrackV1 *track)
236 if(track) fTrack = track;
238 AliWarning("No Track defined.");
242 if(!(h = ((TH2I*)fContainer->At(kTrackletY)))){
243 AliWarning("No output histogram defined.");
247 Double_t cov[3], covR[3];
248 Float_t xref, y0, dx, dy, dydx;
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);
255 xref = fTracklet->GetXref();
256 dx = fTracklet->GetX0() - xref;
257 dy = y0-dx*dydx - fTracklet->GetYat(xref);
258 fTracklet->GetCovAt(xref, cov);
259 fTracklet->GetCovRef(covR);
260 h->Fill(dydx, dy/TMath::Sqrt(cov[0] + covR[0]));
265 //________________________________________________________
266 TH1* AliTRDtrackingResolution::PlotTrackletPhi(const AliTRDtrackV1 *track)
268 if(track) fTrack = track;
270 AliWarning("No Track defined.");
274 if(!(h = ((TH2I*)fContainer->At(kTrackletPhi)))){
275 AliWarning("No output histogram defined.");
279 AliTRDseedV1 *tracklet = 0x0;
280 for(Int_t il=0; il<AliTRDgeometry::kNlayer; il++){
281 if(!(tracklet = fTrack->GetTracklet(il))) continue;
282 if(!tracklet->IsOK()) continue;
283 h->Fill(tracklet->GetYref(1), TMath::ATan(tracklet->GetYref(1))-TMath::ATan(tracklet->GetYfit(1)));
289 //________________________________________________________
290 TH1* AliTRDtrackingResolution::PlotResolution(const AliTRDtrackV1 *track)
293 AliWarning("No MC defined. Results will not be available.");
296 if(track) fTrack = track;
298 AliWarning("No Track defined.");
303 Int_t pdg = fMC->GetPDG(), det=-1;
304 Int_t label = fMC->GetLabel();
305 Float_t p, pt, xref, x0, y0, z0, dx, dy, dz, dydx, dzdx;
308 Double_t DX[12], DY[12], DZ[12], DPt[12], COV[12][15];
309 fMC->PropagateKalman(DX, DY, DZ, DPt, COV);
310 (*fDebugStream) << "MCkalman"
327 AliTRDseedV1 *fTracklet = 0x0;
328 for(Int_t ily=0; ily<AliTRDgeometry::kNlayer; ily++){
329 if(!(fTracklet = fTrack->GetTracklet(ily)) ||
330 !fTracklet->IsOK()) continue;
332 det = fTracklet->GetDetector();
333 x0 = fTracklet->GetX0();
334 //radial shift with respect to the MC reference (radial position of the pad plane)
335 xref= fTracklet->GetXref();
337 if(!fMC->GetDirections(x0, y0, z0, dydx, dzdx, pt, s)) continue;
338 // MC track position at reference radial position
339 Float_t yt = y0 - (x0-xref)*dydx;
340 Float_t zt = z0 - (x0-xref)*dzdx;
341 p = pt*(1.+dzdx*dzdx); // pt -> p
343 // add Kalman residuals for y, z and pt
344 Float_t yr = fTracklet->GetYref(0) - dx*fTracklet->GetYref(1);
346 Float_t zr = fTracklet->GetZref(0) - dx*fTracklet->GetZref(1);
348 Float_t tgl = fTracklet->GetTgl();
349 Float_t ptr = fTracklet->GetMomentum()/(1.+tgl*tgl);
351 ((TH2I*)fContainer->At(kMCtrackY))->Fill(dydx, dy);
352 ((TH2I*)fContainer->At(kMCtrackZ))->Fill(dzdx, dz);
353 if(pdg!=kElectron && pdg!=kPositron) ((TH2I*)fContainer->At(kMCtrackPt))->Fill(1./pt, ptr-pt);
354 // Fill Debug stream for Kalman track
356 Float_t dydxr = fTracklet->GetYref(1);
357 (*fDebugStream) << "MCtrack"
373 // recalculate tracklet based on the MC info
374 AliTRDseedV1 tt(*fTracklet);
377 if(!tt.Fit(kTRUE)) continue;
378 xref= fTracklet->GetXref(); // the true one
379 yt = y0 - (x0-xref)*dydx;
381 // add tracklet residuals for y and dydx
382 Float_t yf = tt.GetYat(xref);
384 Float_t dphi = (tt.GetYfit(1) - dydx);
385 dphi /= 1.- tt.GetYfit(1)*dydx;
386 ((TH2I*)fContainer->At(kMCtrackletY))->Fill(dydx, dy);
387 ((TH2I*)fContainer->At(kMCtrackletPhi))->Fill(dydx, dphi*TMath::RadToDeg());
390 Bool_t rc = fTracklet->IsRowCross();
392 // add tracklet residuals for z
393 Double_t *xyz = tt.GetCrossXYZ();
394 dz = xyz[2] - (z0 - (x0 - xyz[0])*dzdx) ;
395 ((TH2I*)fContainer->At(kMCtrackletZ))->Fill(dzdx, dz);
398 // Fill Debug stream for tracklet
400 (*fDebugStream) << "MCtracklet"
415 Int_t istk = AliTRDgeometry::GetStack(det);
416 AliTRDpadPlane *pp = fGeo->GetPadPlane(ily, istk);
417 Float_t zr0 = pp->GetRow0() + pp->GetAnodeWireOffset();
418 Float_t tilt = fTracklet->GetTilt();
421 AliTRDcluster *c = 0x0;
422 fTracklet->ResetClusterIter(kFALSE);
423 while((c = fTracklet->PrevCluster())){
424 Float_t q = TMath::Abs(c->GetQ());
425 //AliTRDseedV1::GetClusterXY(c,x,y);
426 x = c->GetX(); y = c->GetY();
429 Float_t zc = c->GetZ();
433 dy = yt - (yc - tilt*(zc-zt));
436 if(q>20. && q<250.) ((TH2I*)fContainer->At(kMCcluster))->Fill(dydx, dy);
438 // Fill calibration container
439 Float_t d = zr0 - zt;
440 d -= ((Int_t)(2 * d)) / 2.0;
441 if (d > 0.25) d = 0.5 - d;
442 AliTRDclusterInfo *clInfo = new AliTRDclusterInfo;
444 clInfo->SetCluster(c);
445 clInfo->SetMC(pdg, label);
446 clInfo->SetGlobalPosition(yt, zt, dydx, dzdx);
447 clInfo->SetResolution(dy);
448 clInfo->SetAnisochronity(d);
449 clInfo->SetDriftLength(dx-.5*AliTRDgeometry::CamHght());
450 clInfo->SetTilt(tilt);
455 (*fDebugStream) << "MCcluster"
456 <<"clInfo.=" << clInfo
465 //________________________________________________________
466 Bool_t AliTRDtrackingResolution::GetRefFigure(Int_t ifig)
468 Float_t y[2] = {0., 0.};
471 TGraphErrors *g = 0x0;
474 if(!(g = (TGraphErrors*)fGraphS->At(ifig))) break;
476 ax = g->GetHistogram()->GetYaxis();
477 y[0] = -0.5; y[1] = 2.5;
478 ax->SetRangeUser(y[0], y[1]);
479 ax->SetTitle("Cluster-Track Pools #sigma/#mu [mm]");
480 ax = g->GetHistogram()->GetXaxis();
481 ax->SetTitle("tg(#phi)");
482 if(!(g = (TGraphErrors*)fGraphM->At(ifig))) break;
484 b = new TBox(-.15, y[0], .15, y[1]);
485 b->SetFillStyle(3002);b->SetFillColor(kGreen);
486 b->SetLineColor(0); b->Draw();
489 if(!(g = (TGraphErrors*)fGraphS->At(ifig))) break;
491 ax = g->GetHistogram()->GetYaxis();
492 ax->SetRangeUser(-.5, 3.);
493 ax->SetTitle("Tracklet-Track Y-Pools #sigma/#mu [mm]");
494 ax = g->GetHistogram()->GetXaxis();
495 ax->SetTitle("tg(#phi)");
496 if(!(g = (TGraphErrors*)fGraphM->At(ifig))) break;
498 b = new TBox(-.15, y[0], .15, y[1]);
499 b->SetFillStyle(3002);b->SetFillColor(kGreen);
500 b->SetLineColor(0); b->Draw();
503 if(!(g = (TGraphErrors*)fGraphS->At(ifig))) break;
505 ax = g->GetHistogram()->GetYaxis();
506 ax->SetRangeUser(-.5, 2.);
507 ax->SetTitle("Tracklet-Track Phi-Residuals #sigma/#mu [rad]");
508 ax = g->GetHistogram()->GetXaxis();
509 ax->SetTitle("tg(#phi)");
510 if(!(g = (TGraphErrors*)fGraphM->At(ifig))) break;
512 b = new TBox(-.15, y[0], .15, y[1]);
513 b->SetFillStyle(3002);b->SetFillColor(kGreen);
514 b->SetLineColor(0); b->Draw();
517 if(!(g = (TGraphErrors*)fGraphS->At(ifig))) break;
518 ax = g->GetHistogram()->GetYaxis();
519 y[0] = -.1; y[1] = 1.5;
520 ax->SetRangeUser(y[0], y[1]);
521 ax->SetTitle("Y_{cluster} #sigma/#mu [mm]");
522 ax = g->GetHistogram()->GetXaxis();
523 ax->SetTitle("tg(#phi)");
525 if(!(g = (TGraphErrors*)fGraphM->At(ifig))) break;
527 b = new TBox(-.15, y[0], .15, y[1]);
528 b->SetFillStyle(3002);b->SetFillColor(kBlue);
529 b->SetLineColor(0); b->Draw();
532 if(!(g = (TGraphErrors*)fGraphS->At(ifig))) break;
533 ax = g->GetHistogram()->GetYaxis();
534 y[0] = -.05; y[1] = 0.3;
535 ax->SetRangeUser(y[0], y[1]);
536 ax->SetTitle("Y_{tracklet} #sigma/#mu [mm]");
537 ax = g->GetHistogram()->GetXaxis();
538 ax->SetTitle("tg(#phi)");
540 if(!(g = (TGraphErrors*)fGraphM->At(ifig))) break;
542 b = new TBox(-.15, y[0], .15, y[1]);
543 b->SetFillStyle(3002);b->SetFillColor(kBlue);
544 b->SetLineColor(0); b->Draw();
547 if(!(g = (TGraphErrors*)fGraphS->At(ifig))) break;
548 ax = g->GetHistogram()->GetYaxis();
549 ax->SetRangeUser(-.5, 1.);
550 ax->SetTitle("Z_{tracklet} #sigma/#mu [mm]");
551 ax = g->GetHistogram()->GetXaxis();
552 ax->SetTitle("tg(#theta)");
554 if(!(g = (TGraphErrors*)fGraphM->At(ifig))) break;
558 if(!(g = (TGraphErrors*)fGraphS->At(ifig))) break;
559 ax = g->GetHistogram()->GetYaxis();
560 y[0] = -.05; y[1] = .2;
561 ax->SetRangeUser(y[0], y[1]);
562 ax->SetTitle("#Phi_{tracklet} #sigma/#mu [deg]");
563 ax = g->GetHistogram()->GetXaxis();
564 ax->SetTitle("tg(#phi)");
566 if(!(g = (TGraphErrors*)fGraphM->At(ifig))) break;
570 if(!(g = (TGraphErrors*)fGraphS->At(ifig))) break;
571 ax = g->GetHistogram()->GetYaxis();
572 y[0] = -.05; y[1] = 0.2;
573 ax->SetRangeUser(y[0], y[1]);
574 ax->SetTitle("Y_{track} #sigma/#mu [mm]");
575 ax = g->GetHistogram()->GetXaxis();
576 ax->SetTitle("tg(#phi)");
578 if(!(g = (TGraphErrors*)fGraphM->At(ifig))) break;
580 b = new TBox(-.15, y[0], .15, y[1]);
581 b->SetFillStyle(3002);b->SetFillColor(kBlue);
582 b->SetLineColor(0); b->Draw();
585 if(!(g = (TGraphErrors*)fGraphS->At(ifig))) break;
586 ax = g->GetHistogram()->GetYaxis();
587 ax->SetRangeUser(-.5, 2.);
588 ax->SetTitle("Z_{track} #sigma/#mu [mm]");
589 ax = g->GetHistogram()->GetXaxis();
590 ax->SetTitle("tg(#theta)");
592 if(!(g = (TGraphErrors*)fGraphM->At(ifig))) break;
596 if(!(g = (TGraphErrors*)fGraphS->At(ifig))) break;
597 ax = g->GetHistogram()->GetYaxis();
598 ax->SetRangeUser(-.5, 2.);
599 ax->SetTitle("#epsilon_{P_{t}}^{track} / #mu [%]");
600 ax = g->GetHistogram()->GetXaxis();
601 ax->SetTitle("1/p_{t}");
603 if(!(g = (TGraphErrors*)fGraphM->At(ifig))) break;
607 AliInfo(Form("Reference plot [%d] missing result", ifig));
612 //________________________________________________________
613 Bool_t AliTRDtrackingResolution::PostProcess()
615 //fContainer = dynamic_cast<TObjArray*>(GetOutputData(0));
617 Printf("ERROR: list not available");
620 fNRefFigures = fContainer->GetEntriesFast();
621 TGraphErrors *gm = 0x0, *gs = 0x0;
623 fGraphS = new TObjArray(fNRefFigures);
625 for(Int_t ig=0; ig<fNRefFigures; ig++){
626 gs = new TGraphErrors();
627 gs->SetLineColor(kRed);
628 gs->SetMarkerStyle(23);
629 gs->SetMarkerColor(kRed);
630 gs->SetNameTitle(Form("s_%d", ig), "");
631 fGraphS->AddAt(gs, ig);
635 fGraphM = new TObjArray(fNRefFigures);
637 for(Int_t ig=0; ig<fNRefFigures; ig++){
638 gm = new TGraphErrors();
639 gm->SetLineColor(kBlue);
640 gm->SetMarkerStyle(7);
641 gm->SetMarkerColor(kBlue);
642 gm->SetNameTitle(Form("m_%d", ig), "");
643 fGraphM->AddAt(gm, ig);
651 TF1 f("f1", "gaus", -.5, .5);
653 TF1 fb("fb", "[0]*exp(-0.5*((x-[1])/[2])**2)+[3]", -.5, .5);
655 TF1 fc("fc", "[0]*exp(-0.5*((x-[1])/[2])**2)+[3]*exp(-0.5*((x-[4])/[5])**2)", -.5, .5);
658 if(IsVisual()) c = new TCanvas("c", Form("%s Visual", GetName()), 500, 500);
660 sprintf(opt, "%c%c", IsVerbose() ? ' ' : 'Q', IsVisual() ? ' ': 'N');
663 //PROCESS RESIDUAL DISTRIBUTIONS
665 // Clusters residuals
666 h2 = (TH2I *)(fContainer->At(kCluster));
667 gm = (TGraphErrors*)fGraphM->At(kCluster);
668 gs = (TGraphErrors*)fGraphS->At(kCluster);
669 for(Int_t ibin = 1; ibin <= h2->GetNbinsX(); ibin++){
670 Double_t phi = h2->GetXaxis()->GetBinCenter(ibin);
671 h = h2->ProjectionY("py", ibin, ibin);
672 if(h->GetEntries()<100) continue;
675 if(IsVisual()){c->cd(); c->SetLogy();}
676 h->Fit(&f, opt, "", -0.5, 0.5);
677 if(IsVisual()){c->Modified(); c->Update(); gSystem->Sleep(500);}
679 Int_t ip = gm->GetN();
680 gm->SetPoint(ip, phi, 10.*f.GetParameter(1));
681 gm->SetPointError(ip, 0., 10.*f.GetParError(1));
682 gs->SetPoint(ip, phi, 10.*f.GetParameter(2));
683 gs->SetPointError(ip, 0., 10.*f.GetParError(2));
686 // Tracklet y residuals
687 h2 = (TH2I *)(fContainer->At(kTrackletY));
688 gm = (TGraphErrors*)fGraphM->At(kTrackletY);
689 gs = (TGraphErrors*)fGraphS->At(kTrackletY);
690 for(Int_t ibin = 1; ibin <= h2->GetNbinsX(); ibin++){
691 Double_t phi = h2->GetXaxis()->GetBinCenter(ibin);
692 h = h2->ProjectionY("py", ibin, ibin);
693 if(h->GetEntries()<100) continue;
696 if(IsVisual()){c->cd(); c->SetLogy();}
697 h->Fit(&f, opt, "", -0.5, 0.5);
698 if(IsVisual()){c->Modified(); c->Update(); gSystem->Sleep(500);}
700 Int_t ip = gm->GetN();
701 gm->SetPoint(ip, phi, 10.*f.GetParameter(1));
702 gm->SetPointError(ip, 0., 10.*f.GetParError(1));
703 gs->SetPoint(ip, phi, 10.*f.GetParameter(2));
704 gs->SetPointError(ip, 0., 10.*f.GetParError(2));
707 // Tracklet phi residuals
708 h2 = (TH2I *)(fContainer->At(kTrackletPhi));
709 gm = (TGraphErrors*)fGraphM->At(kTrackletPhi);
710 gs = (TGraphErrors*)fGraphS->At(kTrackletPhi);
711 for(Int_t ibin = 1; ibin <= h2->GetNbinsX(); ibin++){
712 Double_t phi = h2->GetXaxis()->GetBinCenter(ibin);
713 h = h2->ProjectionY("py", ibin, ibin);
714 if(h->GetEntries()<100) continue;
717 if(IsVisual()){c->cd(); c->SetLogy();}
718 h->Fit(&f, opt, "", -0.5, 0.5);
719 if(IsVisual()){c->Modified(); c->Update(); gSystem->Sleep(500);}
721 Int_t ip = gm->GetN();
722 gm->SetPoint(ip, phi, 10.*f.GetParameter(1));
723 gm->SetPointError(ip, 0., 10.*f.GetParError(1));
724 gs->SetPoint(ip, phi, 10.*f.GetParameter(2));
725 gs->SetPointError(ip, 0., 10.*f.GetParError(2));
733 //PROCESS MC RESIDUAL DISTRIBUTIONS
735 // cluster y resolution
736 h2 = (TH2I*)fContainer->At(kMCcluster);
737 gm = (TGraphErrors*)fGraphM->At(kMCcluster);
738 gs = (TGraphErrors*)fGraphS->At(kMCcluster);
739 for(Int_t iphi=1; iphi<=h2->GetNbinsX(); iphi++){
740 h = h2->ProjectionY("py", iphi, iphi);
741 if(h->GetEntries()<100) continue;
744 if(IsVisual()){c->cd(); c->SetLogy();}
745 h->Fit(&f, opt, "", -0.5, 0.5);
747 printf("phi[%d] mean[%e] sigma[%e]\n\n", iphi, 10.*f.GetParameter(1), 10.*f.GetParameter(2));
749 if(IsVisual()){c->Modified(); c->Update(); gSystem->Sleep(500);}
751 Double_t phi = h2->GetXaxis()->GetBinCenter(iphi);
752 Int_t ip = gm->GetN();
753 gm->SetPoint(ip, phi, 10.*f.GetParameter(1));
754 gm->SetPointError(ip, 0., 10.*f.GetParError(1));
755 gs->SetPoint(ip, phi, 10.*f.GetParameter(2));
756 gs->SetPointError(ip, 0., 10.*f.GetParError(2));
759 // tracklet y resolution
760 h2 = (TH2I*)fContainer->At(kMCtrackletY);
761 gm = (TGraphErrors*)fGraphM->At(kMCtrackletY);
762 gs = (TGraphErrors*)fGraphS->At(kMCtrackletY);
763 for(Int_t iphi=1; iphi<=h2->GetNbinsX(); iphi++){
764 h = h2->ProjectionY("py", iphi, iphi);
765 if(h->GetEntries()<100) continue;
768 if(IsVisual()){c->cd(); c->SetLogy();}
769 h->Fit(&f, opt, "", -0.5, 0.5);
770 if(IsVisual()){c->Modified(); c->Update(); gSystem->Sleep(500);}
772 Double_t phi = h2->GetXaxis()->GetBinCenter(iphi);
773 Int_t ip = gm->GetN();
774 gm->SetPoint(ip, phi, 10.*f.GetParameter(1));
775 gm->SetPointError(ip, 0., 10.*f.GetParError(1));
776 gs->SetPoint(ip, phi, 10.*f.GetParameter(2));
777 gs->SetPointError(ip, 0., 10.*f.GetParError(2));
780 // tracklet z resolution
781 h2 = (TH2I*)fContainer->At(kMCtrackletZ);
782 gm = (TGraphErrors*)fGraphM->At(kMCtrackletZ);
783 gs = (TGraphErrors*)fGraphS->At(kMCtrackletZ);
784 for(Int_t iphi=1; iphi<=h2->GetNbinsX(); iphi++){
785 h = h2->ProjectionY("py", iphi, iphi);
786 if(h->GetEntries()<100) continue;
789 if(IsVisual()){c->cd(); c->SetLogy();}
790 h->Fit(&fb, opt, "", -0.5, 0.5);
791 if(IsVisual()){c->Modified(); c->Update(); gSystem->Sleep(500);}
793 Double_t phi = h2->GetXaxis()->GetBinCenter(iphi);
794 Int_t ip = gm->GetN();
795 gm->SetPoint(ip, phi, 10.*fb.GetParameter(1));
796 gm->SetPointError(ip, 0., 10.*fb.GetParError(1));
797 gs->SetPoint(ip, phi, 10.*fb.GetParameter(2));
798 gs->SetPointError(ip, 0., 10.*fb.GetParError(2));
801 //tracklet phi resolution
802 h2 = (TH2I*)fContainer->At(kMCtrackletPhi);
803 gm = (TGraphErrors*)fGraphM->At(kMCtrackletPhi);
804 gs = (TGraphErrors*)fGraphS->At(kMCtrackletPhi);
805 for(Int_t iphi=1; iphi<=h2->GetNbinsX(); iphi++){
806 h = h2->ProjectionY("py", iphi, iphi);
807 if(h->GetEntries()<100) continue;
809 if(IsVisual()){c->cd(); c->SetLogy();}
810 h->Fit(&f, opt, "", -0.5, 0.5);
811 if(IsVisual()){c->Modified(); c->Update(); gSystem->Sleep(500);}
813 Double_t phi = h2->GetXaxis()->GetBinCenter(iphi);
814 Int_t ip = gm->GetN();
815 gm->SetPoint(ip, phi, f.GetParameter(1));
816 gm->SetPointError(ip, 0., f.GetParError(1));
817 gs->SetPoint(ip, phi, f.GetParameter(2));
818 gs->SetPointError(ip, 0., f.GetParError(2));
821 // track y resolution
822 h2 = (TH2I*)fContainer->At(kMCtrackY);
823 gm = (TGraphErrors*)fGraphM->At(kMCtrackY);
824 gs = (TGraphErrors*)fGraphS->At(kMCtrackY);
825 for(Int_t iphi=1; iphi<=h2->GetNbinsX(); iphi++){
826 h = h2->ProjectionY("py", iphi, iphi);
827 if(h->GetEntries()<100) continue;
830 if(IsVisual()){c->cd(); c->SetLogy();}
831 h->Fit(&f, opt, "", -0.5, 0.5);
832 if(IsVisual()){c->Modified(); c->Update(); gSystem->Sleep(500);}
834 Double_t phi = h2->GetXaxis()->GetBinCenter(iphi);
835 Int_t ip = gm->GetN();
836 gm->SetPoint(ip, phi, 10.*f.GetParameter(1));
837 gm->SetPointError(ip, 0., 10.*f.GetParError(1));
838 gs->SetPoint(ip, phi, 10.*f.GetParameter(2));
839 gs->SetPointError(ip, 0., 10.*f.GetParError(2));
842 // track z resolution
843 h2 = (TH2I*)fContainer->At(kMCtrackZ);
844 gm = (TGraphErrors*)fGraphM->At(kMCtrackZ);
845 gs = (TGraphErrors*)fGraphS->At(kMCtrackZ);
846 for(Int_t iphi=1; iphi<=h2->GetNbinsX(); iphi++){
847 h = h2->ProjectionY("pz", iphi, iphi);
848 if(h->GetEntries()<70) continue;
851 if(IsVisual()){c->cd(); c->SetLogy();}
852 h->Fit(&f, opt, "", -0.5, 0.5);
853 if(IsVisual()){c->Modified(); c->Update(); gSystem->Sleep(500);}
855 Double_t phi = h2->GetXaxis()->GetBinCenter(iphi);
856 Int_t ip = gm->GetN();
857 gm->SetPoint(ip, phi, 10.*f.GetParameter(1));
858 gm->SetPointError(ip, 0., 10.*f.GetParError(1));
859 gs->SetPoint(ip, phi, 10.*f.GetParameter(2));
860 gs->SetPointError(ip, 0., 10.*f.GetParError(2));
863 // track Pt resolution
864 h2 = (TH2I*)fContainer->At(kMCtrackPt);
865 TAxis *ax = h2->GetXaxis();
866 gm = (TGraphErrors*)fGraphM->At(kMCtrackPt);
867 gs = (TGraphErrors*)fGraphS->At(kMCtrackPt);
868 TF1 fg("fg", "gaus", -1.5, 1.5);
869 TF1 fl("fl", "landau", -4., 15.);
870 TF1 fgl("fgl", "gaus(0)+landau(3)", -5., 20.);
871 for(Int_t ip=1; ip<=ax->GetNbins(); ip++){
872 h = h2->ProjectionY("ppt", ip, ip);
873 if(h->GetEntries()<70) continue;
875 h->Fit(&fg, "QN", "", -1.5, 1.5);
876 fgl.SetParameter(0, fg.GetParameter(0));
877 fgl.SetParameter(1, fg.GetParameter(1));
878 fgl.SetParameter(2, fg.GetParameter(2));
879 h->Fit(&fl, "QN", "", -4., 15.);
880 fgl.SetParameter(3, fl.GetParameter(0));
881 fgl.SetParameter(4, fl.GetParameter(1));
882 fgl.SetParameter(5, fl.GetParameter(2));
884 if(IsVisual()){c->cd(); c->SetLogy();}
885 h->Fit(&fgl, opt, "", -5., 20.);
886 if(IsVisual()){c->Modified(); c->Update(); gSystem->Sleep(500);}
888 Float_t invpt = ax->GetBinCenter(ip);
889 Int_t ip = gm->GetN();
890 gm->SetPoint(ip, invpt, fgl.GetParameter(1));
891 gm->SetPointError(ip, 0., fgl.GetParError(1));
892 gs->SetPoint(ip, invpt, fgl.GetParameter(2)*invpt);
893 gs->SetPointError(ip, 0., fgl.GetParError(2));
894 // fgl.GetParameter(4) // Landau MPV
895 // fgl.GetParameter(5) // Landau Sigma
904 //________________________________________________________
905 void AliTRDtrackingResolution::Terminate(Option_t *)
912 if(HasPostProcess()) PostProcess();
915 //________________________________________________________
916 void AliTRDtrackingResolution::AdjustF1(TH1 *h, TF1 *f)
918 // Helper function to avoid duplication of code
919 // Make first guesses on the fit parameters
921 // find the intial parameters of the fit !! (thanks George)
922 Int_t nbinsy = Int_t(.5*h->GetNbinsX());
924 for(Int_t jbin=nbinsy-4; jbin<=nbinsy+4; jbin++) sum+=h->GetBinContent(jbin); sum/=9.;
925 f->SetParLimits(0, 0., 3.*sum);
926 f->SetParameter(0, .9*sum);
928 f->SetParLimits(1, -.2, .2);
929 f->SetParameter(1, -0.1);
931 f->SetParLimits(2, 0., 4.e-1);
932 f->SetParameter(2, 2.e-2);
933 if(f->GetNpar() <= 4) return;
935 f->SetParLimits(3, 0., sum);
936 f->SetParameter(3, .1*sum);
938 f->SetParLimits(4, -.3, .3);
939 f->SetParameter(4, 0.);
941 f->SetParLimits(5, 0., 1.e2);
942 f->SetParameter(5, 2.e-1);
945 //________________________________________________________
946 TObjArray* AliTRDtrackingResolution::Histos()
948 if(fContainer) return fContainer;
950 fContainer = new TObjArray(10);
951 //fContainer->SetOwner(kTRUE);
954 // cluster to tracklet residuals [2]
955 if(!(h = (TH2I*)gROOT->FindObject("hCl"))){
956 h = new TH2I("hCl", "Clusters-Track Residuals", 21, -.33, .33, 100, -.5, .5);
957 h->GetXaxis()->SetTitle("tg(#phi)");
958 h->GetYaxis()->SetTitle("#Delta y [cm]");
959 h->GetZaxis()->SetTitle("entries");
961 fContainer->AddAt(h, kCluster);
963 // tracklet to track residuals [2]
964 if(!(h = (TH2I*)gROOT->FindObject("hTrkltY"))){
965 h = new TH2I("hTrkltY", "Tracklets-Track Residuals (Y)", 21, -.33, .33, 100, -.5, .5);
966 h->GetXaxis()->SetTitle("tg(#phi)");
967 h->GetYaxis()->SetTitle("#Delta y [cm]");
968 h->GetZaxis()->SetTitle("entries");
970 fContainer->AddAt(h, kTrackletY);
972 // tracklet to track residuals angular [2]
973 if(!(h = (TH2I*)gROOT->FindObject("hTrkltPhi"))){
974 h = new TH2I("hTrkltPhi", "Tracklets-Track Residuals (#Phi)", 21, -.33, .33, 100, -.5, .5);
975 h->GetXaxis()->SetTitle("tg(#phi)");
976 h->GetYaxis()->SetTitle("#Delta phi [#circ]");
977 h->GetZaxis()->SetTitle("entries");
979 fContainer->AddAt(h, kTrackletPhi);
983 if(!HasMCdata()) return fContainer;
985 // cluster y resolution [0]
986 if(!(h = (TH2I*)gROOT->FindObject("hMCcl"))){
987 h = new TH2I("hMCcl", "Cluster Resolution", 31, -.48, .48, 100, -.5, .5);
988 h->GetXaxis()->SetTitle("tg(#phi)");
989 h->GetYaxis()->SetTitle("#Delta y [cm]");
990 h->GetZaxis()->SetTitle("entries");
992 fContainer->AddAt(h, kMCcluster);
994 // tracklet y resolution [0]
995 if(!(h = (TH2I*)gROOT->FindObject("hMCtrkltY"))){
996 h = new TH2I("hMCtrkltY", "Tracklet Resolution (Y)", 31, -.48, .48, 100, -.5, .5);
997 h->GetXaxis()->SetTitle("tg(#phi)");
998 h->GetYaxis()->SetTitle("#Delta y [cm]");
999 h->GetZaxis()->SetTitle("entries");
1001 fContainer->AddAt(h, kMCtrackletY);
1003 // tracklet y resolution [0]
1004 if(!(h = (TH2I*)gROOT->FindObject("hMCtrkltZ"))){
1005 h = new TH2I("hMCtrkltZ", "Tracklet Resolution (Z)", 31, -.48, .48, 100, -.5, .5);
1006 h->GetXaxis()->SetTitle("tg(#theta)");
1007 h->GetYaxis()->SetTitle("#Delta z [cm]");
1008 h->GetZaxis()->SetTitle("entries");
1010 fContainer->AddAt(h, kMCtrackletZ);
1012 // tracklet angular resolution [1]
1013 if(!(h = (TH2I*)gROOT->FindObject("hMCtrkltPhi"))){
1014 h = new TH2I("hMCtrkltPhi", "Tracklet Resolution (#Phi)", 31, -.48, .48, 100, -10., 10.);
1015 h->GetXaxis()->SetTitle("tg(#phi)");
1016 h->GetYaxis()->SetTitle("#Delta #phi [deg]");
1017 h->GetZaxis()->SetTitle("entries");
1019 fContainer->AddAt(h, kMCtrackletPhi);
1021 // Kalman track y resolution
1022 if(!(h = (TH2I*)gROOT->FindObject("hMCtrkY"))){
1023 h = new TH2I("hMCtrkY", "Kalman Track Resolution (Y)", 31, -.48, .48, 100, -.5, .5);
1024 h->GetXaxis()->SetTitle("tg(#phi)");
1025 h->GetYaxis()->SetTitle("#Delta y [cm]");
1026 h->GetZaxis()->SetTitle("entries");
1028 fContainer->AddAt(h, kMCtrackY);
1030 // Kalman track Z resolution
1031 if(!(h = (TH2I*)gROOT->FindObject("hMCtrkZ"))){
1032 h = new TH2I("hMCtrkZ", "Kalman Track Resolution (Z)", 20, -1., 1., 100, -1.5, 1.5);
1033 h->GetXaxis()->SetTitle("tg(#theta)");
1034 h->GetYaxis()->SetTitle("#Delta z [cm]");
1035 h->GetZaxis()->SetTitle("entries");
1037 fContainer->AddAt(h, kMCtrackZ);
1039 // Kalman track Pt resolution
1040 if(!(h = (TH2I*)gROOT->FindObject("hMCtrkPt"))){
1041 h = new TH2I("hMCtrkPt", "Kalman Track Resolution (Pt)", 100, 0., 2., 150, -5., 20.);
1042 h->GetXaxis()->SetTitle("1/p_{t}");
1043 h->GetYaxis()->SetTitle("#Delta p_{t} [GeV/c]");
1044 h->GetZaxis()->SetTitle("entries");
1046 fContainer->AddAt(h, kMCtrackPt);
1052 //________________________________________________________
1053 void AliTRDtrackingResolution::SetRecoParam(AliTRDrecoParam *r)
1056 fReconstructor->SetRecoParam(r);