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: AliTRDresolution.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 // AliTRDresolution *res = new AliTRDresolution();
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 "AliTRDresolution.h"
87 ClassImp(AliTRDresolution)
89 //________________________________________________________
90 AliTRDresolution::AliTRDresolution()
91 :AliTRDrecoTask("Resolution", "Spatial and Momentum 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 AliTRDresolution::~AliTRDresolution()
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 AliTRDresolution::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 AliTRDresolution::Exec(Option_t *opt)
155 AliTRDrecoTask::Exec(opt);
160 PostData(4, fMCtrklt);
163 //________________________________________________________
164 TH1* AliTRDresolution::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* AliTRDresolution::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 x, 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 x = fTracklet->GetX();
256 dx = fTracklet->GetX0() - x;
257 dy = y0-dx*dydx - fTracklet->GetY();
258 fTracklet->GetCovAt(x, cov);
259 fTracklet->GetCovRef(covR);
260 h->Fill(dydx, dy/TMath::Sqrt(cov[0] + covR[0]));
265 //________________________________________________________
266 TH1* AliTRDresolution::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* AliTRDresolution::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();
306 Float_t p, pt, x0, y0, z0, dx, dy, dz, dydx, dzdx;
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"
329 AliTRDseedV1 *fTracklet = 0x0;
330 for(Int_t ily=0; ily<AliTRDgeometry::kNlayer; ily++){
331 if(!(fTracklet = fTrack->GetTracklet(ily)) ||
332 !fTracklet->IsOK()) continue;
334 det = fTracklet->GetDetector();
335 x0 = fTracklet->GetX0();
336 //radial shift with respect to the MC reference (radial position of the pad plane)
337 x= fTracklet->GetX();
339 if(!fMC->GetDirections(x0, y0, z0, dydx, dzdx, pt, s)) continue;
341 (*fDebugStream) << "MC"
352 // MC track position at reference radial position
353 Float_t yt = y0 - dx*dydx;
354 Float_t zt = z0 - dx*dzdx;
355 p = pt*(1.+dzdx*dzdx); // pt -> p
357 // add Kalman residuals for y, z and pt
358 Float_t yr = fTracklet->GetYref(0) - dx*fTracklet->GetYref(1);
360 Float_t zr = fTracklet->GetZref(0) - dx*fTracklet->GetZref(1);
362 Float_t tgl = fTracklet->GetTgl();
363 Float_t dpt = pt - fTracklet->GetMomentum()/(1.+tgl*tgl);
364 fTracklet->GetCovRef(covR);
366 ((TH2I*)fContainer->At(kMCtrackY))->Fill(dydx, dy);
367 ((TH2I*)fContainer->At(kMCtrackYPull))->Fill(dydx, dy/TMath::Sqrt(covR[0]));
369 ((TH2I*)fContainer->At(kMCtrackZIn))->Fill(dzdx, dz);
370 ((TH2I*)fContainer->At(kMCtrackZInPull))->Fill(dzdx, dz/TMath::Sqrt(covR[2]));
371 } else if(ily==AliTRDgeometry::kNlayer-1) {
372 ((TH2I*)fContainer->At(kMCtrackZOut))->Fill(dzdx, dz);
373 ((TH2I*)fContainer->At(kMCtrackZOutPull))->Fill(dzdx, dz/TMath::Sqrt(covR[2]));
375 if(pdg!=kElectron && pdg!=kPositron) ((TH2I*)fContainer->At(kMCtrackPt))->Fill(1./pt, dpt);
376 // Fill Debug stream for Kalman track
378 Float_t dydxr = fTracklet->GetYref(1);
379 (*fDebugStream) << "MCtrack"
391 // recalculate tracklet based on the MC info
392 AliTRDseedV1 tt(*fTracklet);
396 x= tt.GetX(); // the true one
399 Bool_t rc = tt.IsRowCross();
401 // add tracklet residuals for y and dydx
402 Float_t yf = tt.GetY();
403 dy = yt - yf; dz = 100.;
404 Float_t dphi = (tt.GetYfit(1) - dydx);
405 dphi /= 1.- tt.GetYfit(1)*dydx;
406 Double_t s2y = tt.GetS2Y(), s2z = tt.GetS2Z();
408 ((TH2I*)fContainer->At(kMCtrackletY))->Fill(dydx, dy);
409 ((TH2I*)fContainer->At(kMCtrackletYPull))->Fill(dydx, dy/TMath::Sqrt(s2y));
410 ((TH2I*)fContainer->At(kMCtrackletPhi))->Fill(dydx, dphi*TMath::RadToDeg());
412 // add tracklet residuals for z
413 dz = tt.GetZ() - (z0 - dx*dzdx) ;
414 ((TH2I*)fContainer->At(kMCtrackletZ))->Fill(dzdx, dz);
415 ((TH2I*)fContainer->At(kMCtrackletZPull))->Fill(dzdx, dz/TMath::Sqrt(s2z));
418 // Fill Debug stream for tracklet
420 (*fDebugStream) << "MCtracklet"
431 Int_t istk = AliTRDgeometry::GetStack(det);
432 AliTRDpadPlane *pp = fGeo->GetPadPlane(ily, istk);
433 Float_t zr0 = pp->GetRow0() + pp->GetAnodeWireOffset();
434 Float_t tilt = fTracklet->GetTilt();
436 AliTRDcluster *c = 0x0;
437 fTracklet->ResetClusterIter(kFALSE);
438 while((c = fTracklet->PrevCluster())){
439 Float_t q = TMath::Abs(c->GetQ());
440 //AliTRDseedV1::GetClusterXY(c,x,y);
441 x = c->GetX(); y = c->GetY(); z = c->GetZ();
448 dy = yt - (yc - tilt*(zc-zt));
451 if(q>20. && q<250.) ((TH2I*)fContainer->At(kMCcluster))->Fill(dydx, dy);
453 // Fill calibration container
454 Float_t d = zr0 - zt;
455 d -= ((Int_t)(2 * d)) / 2.0;
456 if (d > 0.25) d = 0.5 - d;
457 AliTRDclusterInfo *clInfo = new AliTRDclusterInfo;
459 clInfo->SetCluster(c);
460 clInfo->SetMC(pdg, label);
461 clInfo->SetGlobalPosition(yt, zt, dydx, dzdx);
462 clInfo->SetResolution(dy);
463 clInfo->SetAnisochronity(d);
464 clInfo->SetDriftLength(dx-.5*AliTRDgeometry::CamHght());
465 clInfo->SetTilt(tilt);
470 (*fDebugStream) << "MCcluster"
471 <<"clInfo.=" << clInfo
480 //________________________________________________________
481 Bool_t AliTRDresolution::GetRefFigure(Int_t ifig)
483 Float_t y[2] = {0., 0.};
486 TGraphErrors *g = 0x0;
489 if(!(g = (TGraphErrors*)fGraphS->At(ifig))) break;
491 ax = g->GetHistogram()->GetYaxis();
492 y[0] = -0.5; y[1] = 2.5;
493 ax->SetRangeUser(y[0], y[1]);
494 ax->SetTitle("Cluster-Track Pools #sigma/#mu [mm]");
495 ax = g->GetHistogram()->GetXaxis();
496 ax->SetTitle("tg(#phi)");
497 if(!(g = (TGraphErrors*)fGraphM->At(ifig))) break;
499 b = new TBox(-.15, y[0], .15, y[1]);
500 b->SetFillStyle(3002);b->SetFillColor(kGreen);
501 b->SetLineColor(0); b->Draw();
504 if(!(g = (TGraphErrors*)fGraphS->At(ifig))) break;
506 ax = g->GetHistogram()->GetYaxis();
507 ax->SetRangeUser(-.5, 3.);
508 ax->SetTitle("Tracklet-Track Y-Pools #sigma/#mu [mm]");
509 ax = g->GetHistogram()->GetXaxis();
510 ax->SetTitle("tg(#phi)");
511 if(!(g = (TGraphErrors*)fGraphM->At(ifig))) break;
513 b = new TBox(-.15, y[0], .15, y[1]);
514 b->SetFillStyle(3002);b->SetFillColor(kGreen);
515 b->SetLineColor(0); b->Draw();
518 if(!(g = (TGraphErrors*)fGraphS->At(ifig))) break;
520 ax = g->GetHistogram()->GetYaxis();
521 ax->SetRangeUser(-.5, 2.);
522 ax->SetTitle("Tracklet-Track Phi-Residuals #sigma/#mu [rad]");
523 ax = g->GetHistogram()->GetXaxis();
524 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(kGreen);
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.6;
535 ax->SetRangeUser(y[0], y[1]);
536 ax->SetTitle("Y_{cluster} #sigma/#mu [mm]");
537 ax = g->GetHistogram()->GetXaxis();
538 ax->SetRangeUser(-.3, .3);
539 ax->SetTitle("tg(#phi)");
541 if(!(g = (TGraphErrors*)fGraphM->At(ifig))) break;
543 b = new TBox(-.15, y[0], .15, y[1]);
544 b->SetFillStyle(3002);b->SetFillColor(kBlue);
545 b->SetLineColor(0); b->Draw();
548 if(!(g = (TGraphErrors*)fGraphS->At(ifig))) break;
549 ax = g->GetHistogram()->GetYaxis();
550 y[0] = -.05; y[1] = 0.25;
551 ax->SetRangeUser(y[0], y[1]);
552 ax->SetTitle("Y_{tracklet} #sigma/#mu [mm]");
553 ax = g->GetHistogram()->GetXaxis();
554 ax->SetRangeUser(-.2, .2);
555 ax->SetTitle("tg(#phi)");
557 if(!(g = (TGraphErrors*)fGraphM->At(ifig))) break;
559 b = new TBox(-.15, y[0], .15, y[1]);
560 b->SetFillStyle(3002);b->SetFillColor(kBlue);
561 b->SetLineColor(0); b->Draw();
564 if(!(g = (TGraphErrors*)fGraphS->At(ifig))) break;
565 ax = g->GetHistogram()->GetYaxis();
566 ax->SetRangeUser(-.5, 1.);
567 ax->SetTitle("Z_{tracklet} #sigma/#mu [mm]");
568 ax = g->GetHistogram()->GetXaxis();
569 ax->SetTitle("tg(#theta)");
571 if(!(g = (TGraphErrors*)fGraphM->At(ifig))) break;
575 if(!(g = (TGraphErrors*)fGraphS->At(ifig))) break;
576 ax = g->GetHistogram()->GetYaxis();
577 y[0] = -.05; y[1] = .2;
578 ax->SetRangeUser(y[0], y[1]);
579 ax->SetTitle("#Phi_{tracklet} #sigma/#mu [deg]");
580 ax = g->GetHistogram()->GetXaxis();
581 ax->SetTitle("tg(#phi)");
583 if(!(g = (TGraphErrors*)fGraphM->At(ifig))) break;
587 if(!(g = (TGraphErrors*)fGraphS->At(ifig))) break;
588 ax = g->GetHistogram()->GetYaxis();
589 y[0] = -.05; y[1] = 0.25;
590 ax->SetRangeUser(y[0], y[1]);
591 ax->SetTitle("Y_{track} #sigma/#mu [mm]");
592 ax = g->GetHistogram()->GetXaxis();
593 ax->SetRangeUser(-.2, .2);
594 ax->SetTitle("tg(#phi)");
596 if(!(g = (TGraphErrors*)fGraphM->At(ifig))) break;
598 b = new TBox(-.15, y[0], .15, y[1]);
599 b->SetFillStyle(3002);b->SetFillColor(kBlue);
600 b->SetLineColor(0); b->Draw();
603 if(!(g = (TGraphErrors*)fGraphS->At(ifig))) break;
604 ax = g->GetHistogram()->GetYaxis();
605 ax->SetRangeUser(-.5, 2.);
606 ax->SetTitle("Z_{track} #sigma/#mu [mm]");
607 ax = g->GetHistogram()->GetXaxis();
608 ax->SetTitle("tg(#theta)");
610 if(!(g = (TGraphErrors*)fGraphM->At(ifig))) break;
614 if(!(g = (TGraphErrors*)fGraphS->At(ifig))) break;
615 ax = g->GetHistogram()->GetYaxis();
616 ax->SetRangeUser(-.5, 2.);
617 ax->SetTitle("#epsilon_{P_{t}}^{track} / #mu [%]");
618 ax = g->GetHistogram()->GetXaxis();
619 ax->SetTitle("1/p_{t}");
621 if(!(g = (TGraphErrors*)fGraphM->At(ifig))) break;
625 AliInfo(Form("Reference plot [%d] missing result", ifig));
630 //________________________________________________________
631 Bool_t AliTRDresolution::PostProcess()
633 //fContainer = dynamic_cast<TObjArray*>(GetOutputData(0));
635 Printf("ERROR: list not available");
638 fNRefFigures = fContainer->GetEntriesFast();
639 TGraphErrors *gm = 0x0, *gs = 0x0;
641 fGraphS = new TObjArray(fNRefFigures);
643 for(Int_t ig=0; ig<fNRefFigures; ig++){
644 gs = new TGraphErrors();
645 gs->SetLineColor(kRed);
646 gs->SetMarkerStyle(23);
647 gs->SetMarkerColor(kRed);
648 gs->SetNameTitle(Form("s_%d", ig), "");
649 fGraphS->AddAt(gs, ig);
653 fGraphM = new TObjArray(fNRefFigures);
655 for(Int_t ig=0; ig<fNRefFigures; ig++){
656 gm = new TGraphErrors();
657 gm->SetLineColor(kBlue);
658 gm->SetMarkerStyle(7);
659 gm->SetMarkerColor(kBlue);
660 gm->SetNameTitle(Form("m_%d", ig), "");
661 fGraphM->AddAt(gm, ig);
669 TF1 f("f1", "gaus", -.5, .5);
671 TF1 fb("fb", "[0]*exp(-0.5*((x-[1])/[2])**2)+[3]", -.5, .5);
673 TF1 fc("fc", "[0]*exp(-0.5*((x-[1])/[2])**2)+[3]*exp(-0.5*((x-[4])/[5])**2)", -.5, .5);
676 if(IsVisual()) c = new TCanvas("c", Form("%s Visual", GetName()), 500, 500);
678 sprintf(opt, "%c%c", IsVerbose() ? ' ' : 'Q', IsVisual() ? ' ': 'N');
681 //PROCESS RESIDUAL DISTRIBUTIONS
683 // Clusters residuals
684 h2 = (TH2I *)(fContainer->At(kCluster));
685 gm = (TGraphErrors*)fGraphM->At(kCluster);
686 gs = (TGraphErrors*)fGraphS->At(kCluster);
687 for(Int_t ibin = 1; ibin <= h2->GetNbinsX(); ibin++){
688 Double_t phi = h2->GetXaxis()->GetBinCenter(ibin);
689 h = h2->ProjectionY("py", ibin, ibin);
690 if(h->GetEntries()<100) continue;
693 if(IsVisual()){c->cd(); c->SetLogy();}
694 h->Fit(&f, opt, "", -0.5, 0.5);
695 if(IsVisual()){c->Modified(); c->Update(); gSystem->Sleep(500);}
697 Int_t ip = gm->GetN();
698 gm->SetPoint(ip, phi, 10.*f.GetParameter(1));
699 gm->SetPointError(ip, 0., 10.*f.GetParError(1));
700 gs->SetPoint(ip, phi, 10.*f.GetParameter(2));
701 gs->SetPointError(ip, 0., 10.*f.GetParError(2));
704 // Tracklet y residuals
705 h2 = (TH2I *)(fContainer->At(kTrackletY));
706 gm = (TGraphErrors*)fGraphM->At(kTrackletY);
707 gs = (TGraphErrors*)fGraphS->At(kTrackletY);
708 for(Int_t ibin = 1; ibin <= h2->GetNbinsX(); ibin++){
709 Double_t phi = h2->GetXaxis()->GetBinCenter(ibin);
710 h = h2->ProjectionY("py", ibin, ibin);
711 if(h->GetEntries()<100) continue;
714 if(IsVisual()){c->cd(); c->SetLogy();}
715 h->Fit(&f, opt, "", -0.5, 0.5);
716 if(IsVisual()){c->Modified(); c->Update(); gSystem->Sleep(500);}
718 Int_t ip = gm->GetN();
719 gm->SetPoint(ip, phi, 10.*f.GetParameter(1));
720 gm->SetPointError(ip, 0., 10.*f.GetParError(1));
721 gs->SetPoint(ip, phi, 10.*f.GetParameter(2));
722 gs->SetPointError(ip, 0., 10.*f.GetParError(2));
725 // Tracklet phi residuals
726 h2 = (TH2I *)(fContainer->At(kTrackletPhi));
727 gm = (TGraphErrors*)fGraphM->At(kTrackletPhi);
728 gs = (TGraphErrors*)fGraphS->At(kTrackletPhi);
729 for(Int_t ibin = 1; ibin <= h2->GetNbinsX(); ibin++){
730 Double_t phi = h2->GetXaxis()->GetBinCenter(ibin);
731 h = h2->ProjectionY("py", ibin, ibin);
732 if(h->GetEntries()<100) continue;
735 if(IsVisual()){c->cd(); c->SetLogy();}
736 h->Fit(&f, opt, "", -0.5, 0.5);
737 if(IsVisual()){c->Modified(); c->Update(); gSystem->Sleep(500);}
739 Int_t ip = gm->GetN();
740 gm->SetPoint(ip, phi, 10.*f.GetParameter(1));
741 gm->SetPointError(ip, 0., 10.*f.GetParError(1));
742 gs->SetPoint(ip, phi, 10.*f.GetParameter(2));
743 gs->SetPointError(ip, 0., 10.*f.GetParError(2));
751 //PROCESS MC RESIDUAL DISTRIBUTIONS
753 // cluster y resolution
754 h2 = (TH2I*)fContainer->At(kMCcluster);
755 gm = (TGraphErrors*)fGraphM->At(kMCcluster);
756 gs = (TGraphErrors*)fGraphS->At(kMCcluster);
757 for(Int_t iphi=1; iphi<=h2->GetNbinsX(); iphi++){
758 h = h2->ProjectionY("py", iphi, iphi);
759 if(h->GetEntries()<100) continue;
762 if(IsVisual()){c->cd(); c->SetLogy();}
763 h->Fit(&f, opt, "", -0.5, 0.5);
765 printf("phi[%d] mean[%e] sigma[%e]\n\n", iphi, 10.*f.GetParameter(1), 10.*f.GetParameter(2));
767 if(IsVisual()){c->Modified(); c->Update(); gSystem->Sleep(500);}
769 Double_t phi = h2->GetXaxis()->GetBinCenter(iphi);
770 Int_t ip = gm->GetN();
771 gm->SetPoint(ip, phi, 10.*f.GetParameter(1));
772 gm->SetPointError(ip, 0., 10.*f.GetParError(1));
773 gs->SetPoint(ip, phi, 10.*f.GetParameter(2));
774 gs->SetPointError(ip, 0., 10.*f.GetParError(2));
777 // tracklet y resolution
778 h2 = (TH2I*)fContainer->At(kMCtrackletY);
779 gm = (TGraphErrors*)fGraphM->At(kMCtrackletY);
780 gs = (TGraphErrors*)fGraphS->At(kMCtrackletY);
781 for(Int_t iphi=1; iphi<=h2->GetNbinsX(); iphi++){
782 h = h2->ProjectionY("py", iphi, iphi);
783 if(h->GetEntries()<100) continue;
786 if(IsVisual()){c->cd(); c->SetLogy();}
787 h->Fit(&f, opt, "", -0.5, 0.5);
788 if(IsVisual()){c->Modified(); c->Update(); gSystem->Sleep(500);}
790 Double_t phi = h2->GetXaxis()->GetBinCenter(iphi);
791 Int_t ip = gm->GetN();
792 gm->SetPoint(ip, phi, 10.*f.GetParameter(1));
793 gm->SetPointError(ip, 0., 10.*f.GetParError(1));
794 gs->SetPoint(ip, phi, 10.*f.GetParameter(2));
795 gs->SetPointError(ip, 0., 10.*f.GetParError(2));
798 // tracklet z resolution
799 h2 = (TH2I*)fContainer->At(kMCtrackletZ);
800 gm = (TGraphErrors*)fGraphM->At(kMCtrackletZ);
801 gs = (TGraphErrors*)fGraphS->At(kMCtrackletZ);
802 for(Int_t iphi=1; iphi<=h2->GetNbinsX(); iphi++){
803 h = h2->ProjectionY("py", iphi, iphi);
804 if(h->GetEntries()<100) continue;
807 if(IsVisual()){c->cd(); c->SetLogy();}
808 h->Fit(&fb, opt, "", -0.5, 0.5);
809 if(IsVisual()){c->Modified(); c->Update(); gSystem->Sleep(500);}
811 Double_t phi = h2->GetXaxis()->GetBinCenter(iphi);
812 Int_t ip = gm->GetN();
813 gm->SetPoint(ip, phi, 10.*fb.GetParameter(1));
814 gm->SetPointError(ip, 0., 10.*fb.GetParError(1));
815 gs->SetPoint(ip, phi, 10.*fb.GetParameter(2));
816 gs->SetPointError(ip, 0., 10.*fb.GetParError(2));
819 //tracklet phi resolution
820 h2 = (TH2I*)fContainer->At(kMCtrackletPhi);
821 gm = (TGraphErrors*)fGraphM->At(kMCtrackletPhi);
822 gs = (TGraphErrors*)fGraphS->At(kMCtrackletPhi);
823 for(Int_t iphi=1; iphi<=h2->GetNbinsX(); iphi++){
824 h = h2->ProjectionY("py", iphi, iphi);
825 if(h->GetEntries()<100) continue;
827 if(IsVisual()){c->cd(); c->SetLogy();}
828 h->Fit(&f, opt, "", -0.5, 0.5);
829 if(IsVisual()){c->Modified(); c->Update(); gSystem->Sleep(500);}
831 Double_t phi = h2->GetXaxis()->GetBinCenter(iphi);
832 Int_t ip = gm->GetN();
833 gm->SetPoint(ip, phi, f.GetParameter(1));
834 gm->SetPointError(ip, 0., f.GetParError(1));
835 gs->SetPoint(ip, phi, f.GetParameter(2));
836 gs->SetPointError(ip, 0., f.GetParError(2));
839 // track y resolution
840 h2 = (TH2I*)fContainer->At(kMCtrackY);
841 gm = (TGraphErrors*)fGraphM->At(kMCtrackY);
842 gs = (TGraphErrors*)fGraphS->At(kMCtrackY);
843 for(Int_t iphi=1; iphi<=h2->GetNbinsX(); iphi++){
844 h = h2->ProjectionY("py", iphi, iphi);
845 if(h->GetEntries()<100) continue;
848 if(IsVisual()){c->cd(); c->SetLogy();}
849 h->Fit(&f, opt, "", -0.5, 0.5);
850 if(IsVisual()){c->Modified(); c->Update(); gSystem->Sleep(500);}
852 Double_t phi = h2->GetXaxis()->GetBinCenter(iphi);
853 Int_t ip = gm->GetN();
854 gm->SetPoint(ip, phi, 10.*f.GetParameter(1));
855 gm->SetPointError(ip, 0., 10.*f.GetParError(1));
856 gs->SetPoint(ip, phi, 10.*f.GetParameter(2));
857 gs->SetPointError(ip, 0., 10.*f.GetParError(2));
860 // track z resolution
861 h2 = (TH2I*)fContainer->At(kMCtrackZIn);
862 gm = (TGraphErrors*)fGraphM->At(kMCtrackZIn);
863 gs = (TGraphErrors*)fGraphS->At(kMCtrackZIn);
864 for(Int_t iphi=1; iphi<=h2->GetNbinsX(); iphi++){
865 h = h2->ProjectionY("pz", iphi, iphi);
866 if(h->GetEntries()<70) continue;
869 if(IsVisual()){c->cd(); c->SetLogy();}
870 h->Fit(&f, opt, "", -0.5, 0.5);
871 if(IsVisual()){c->Modified(); c->Update(); gSystem->Sleep(500);}
873 Double_t phi = h2->GetXaxis()->GetBinCenter(iphi);
874 Int_t ip = gm->GetN();
875 gm->SetPoint(ip, phi, 10.*f.GetParameter(1));
876 gm->SetPointError(ip, 0., 10.*f.GetParError(1));
877 gs->SetPoint(ip, phi, 10.*f.GetParameter(2));
878 gs->SetPointError(ip, 0., 10.*f.GetParError(2));
881 // track Pt resolution
882 h2 = (TH2I*)fContainer->At(kMCtrackPt);
883 TAxis *ax = h2->GetXaxis();
884 gm = (TGraphErrors*)fGraphM->At(kMCtrackPt);
885 gs = (TGraphErrors*)fGraphS->At(kMCtrackPt);
886 TF1 fg("fg", "gaus", -1.5, 1.5);
887 TF1 fl("fl", "landau", -4., 15.);
888 TF1 fgl("fgl", "gaus(0)+landau(3)", -5., 20.);
889 for(Int_t ip=1; ip<=ax->GetNbins(); ip++){
890 h = h2->ProjectionY("ppt", ip, ip);
891 if(h->GetEntries()<70) continue;
893 h->Fit(&fg, "QN", "", -1.5, 1.5);
894 fgl.SetParameter(0, fg.GetParameter(0));
895 fgl.SetParameter(1, fg.GetParameter(1));
896 fgl.SetParameter(2, fg.GetParameter(2));
897 h->Fit(&fl, "QN", "", -4., 15.);
898 fgl.SetParameter(3, fl.GetParameter(0));
899 fgl.SetParameter(4, fl.GetParameter(1));
900 fgl.SetParameter(5, fl.GetParameter(2));
902 if(IsVisual()){c->cd(); c->SetLogy();}
903 h->Fit(&fgl, opt, "", -5., 20.);
904 if(IsVisual()){c->Modified(); c->Update(); gSystem->Sleep(500);}
906 Float_t invpt = ax->GetBinCenter(ip);
907 Int_t ip = gm->GetN();
908 gm->SetPoint(ip, invpt, fgl.GetParameter(1));
909 gm->SetPointError(ip, 0., fgl.GetParError(1));
910 gs->SetPoint(ip, invpt, fgl.GetParameter(2)*invpt);
911 gs->SetPointError(ip, 0., fgl.GetParError(2));
912 // fgl.GetParameter(4) // Landau MPV
913 // fgl.GetParameter(5) // Landau Sigma
922 //________________________________________________________
923 void AliTRDresolution::Terminate(Option_t *)
930 if(HasPostProcess()) PostProcess();
933 //________________________________________________________
934 void AliTRDresolution::AdjustF1(TH1 *h, TF1 *f)
936 // Helper function to avoid duplication of code
937 // Make first guesses on the fit parameters
939 // find the intial parameters of the fit !! (thanks George)
940 Int_t nbinsy = Int_t(.5*h->GetNbinsX());
942 for(Int_t jbin=nbinsy-4; jbin<=nbinsy+4; jbin++) sum+=h->GetBinContent(jbin); sum/=9.;
943 f->SetParLimits(0, 0., 3.*sum);
944 f->SetParameter(0, .9*sum);
946 f->SetParLimits(1, -.2, .2);
947 f->SetParameter(1, -0.1);
949 f->SetParLimits(2, 0., 4.e-1);
950 f->SetParameter(2, 2.e-2);
951 if(f->GetNpar() <= 4) return;
953 f->SetParLimits(3, 0., sum);
954 f->SetParameter(3, .1*sum);
956 f->SetParLimits(4, -.3, .3);
957 f->SetParameter(4, 0.);
959 f->SetParLimits(5, 0., 1.e2);
960 f->SetParameter(5, 2.e-1);
963 //________________________________________________________
964 TObjArray* AliTRDresolution::Histos()
966 if(fContainer) return fContainer;
968 fContainer = new TObjArray(kNhistos);
969 //fContainer->SetOwner(kTRUE);
972 // cluster to tracklet residuals [2]
973 if(!(h = (TH2I*)gROOT->FindObject("hCl"))){
974 h = new TH2I("hCl", "Clusters-Track Residuals", 21, -.33, .33, 100, -.5, .5);
975 h->GetXaxis()->SetTitle("tg(#phi)");
976 h->GetYaxis()->SetTitle("#Delta y [cm]");
977 h->GetZaxis()->SetTitle("entries");
979 fContainer->AddAt(h, kCluster);
981 // tracklet to track residuals [2]
982 if(!(h = (TH2I*)gROOT->FindObject("hTrkltY"))){
983 h = new TH2I("hTrkltY", "Tracklets-Track Residuals (Y)", 21, -.33, .33, 100, -.5, .5);
984 h->GetXaxis()->SetTitle("tg(#phi)");
985 h->GetYaxis()->SetTitle("#Delta y [cm]");
986 h->GetZaxis()->SetTitle("entries");
988 fContainer->AddAt(h, kTrackletY);
990 // tracklet to track residuals angular [2]
991 if(!(h = (TH2I*)gROOT->FindObject("hTrkltPhi"))){
992 h = new TH2I("hTrkltPhi", "Tracklets-Track Residuals (#Phi)", 21, -.33, .33, 100, -.5, .5);
993 h->GetXaxis()->SetTitle("tg(#phi)");
994 h->GetYaxis()->SetTitle("#Delta phi [#circ]");
995 h->GetZaxis()->SetTitle("entries");
997 fContainer->AddAt(h, kTrackletPhi);
1000 // Resolution histos
1001 if(!HasMCdata()) return fContainer;
1003 // cluster y resolution [0]
1004 if(!(h = (TH2I*)gROOT->FindObject("hMCcl"))){
1005 h = new TH2I("hMCcl", "Cluster Resolution", 31, -.48, .48, 100, -.5, .5);
1006 h->GetXaxis()->SetTitle("tg(#phi)");
1007 h->GetYaxis()->SetTitle("#Delta y [cm]");
1008 h->GetZaxis()->SetTitle("entries");
1010 fContainer->AddAt(h, kMCcluster);
1012 // tracklet y resolution [0]
1013 if(!(h = (TH2I*)gROOT->FindObject("hMCtrkltY"))){
1014 h = new TH2I("hMCtrkltY", "Tracklet Resolution (Y)", 31, -.48, .48, 100, -.5, .5);
1015 h->GetXaxis()->SetTitle("tg(#phi)");
1016 h->GetYaxis()->SetTitle("#Delta y [cm]");
1017 h->GetZaxis()->SetTitle("entries");
1019 fContainer->AddAt(h, kMCtrackletY);
1021 // tracklet y resolution [0]
1022 if(!(h = (TH2I*)gROOT->FindObject("hMCtrkltYPull"))){
1023 h = new TH2I("hMCtrkltYPull", "Tracklet Pulls (Y)", 31, -.48, .48, 100, -3.5, 3.5);
1024 h->GetXaxis()->SetTitle("tg(#phi)");
1025 h->GetYaxis()->SetTitle("#Delta y / #sigma_{y}");
1026 h->GetZaxis()->SetTitle("entries");
1028 fContainer->AddAt(h, kMCtrackletYPull);
1030 // tracklet y resolution [0]
1031 if(!(h = (TH2I*)gROOT->FindObject("hMCtrkltZ"))){
1032 h = new TH2I("hMCtrkltZ", "Tracklet Resolution (Z)", 31, -.48, .48, 100, -.5, .5);
1033 h->GetXaxis()->SetTitle("tg(#theta)");
1034 h->GetYaxis()->SetTitle("#Delta z [cm]");
1035 h->GetZaxis()->SetTitle("entries");
1037 fContainer->AddAt(h, kMCtrackletZ);
1039 // tracklet y resolution [0]
1040 if(!(h = (TH2I*)gROOT->FindObject("hMCtrkltZPull"))){
1041 h = new TH2I("hMCtrkltZ", "Tracklet Pulls (Z)", 31, -.48, .48, 100, -3.5, 3.5);
1042 h->GetXaxis()->SetTitle("tg(#theta)");
1043 h->GetYaxis()->SetTitle("#Delta z / #sigma_{z}");
1044 h->GetZaxis()->SetTitle("entries");
1046 fContainer->AddAt(h, kMCtrackletZPull);
1048 // tracklet angular resolution [1]
1049 if(!(h = (TH2I*)gROOT->FindObject("hMCtrkltPhi"))){
1050 h = new TH2I("hMCtrkltPhi", "Tracklet Resolution (#Phi)", 31, -.48, .48, 100, -10., 10.);
1051 h->GetXaxis()->SetTitle("tg(#phi)");
1052 h->GetYaxis()->SetTitle("#Delta #phi [deg]");
1053 h->GetZaxis()->SetTitle("entries");
1055 fContainer->AddAt(h, kMCtrackletPhi);
1057 // Kalman track y resolution
1058 if(!(h = (TH2I*)gROOT->FindObject("hMCtrkY"))){
1059 h = new TH2I("hMCtrkY", "Kalman Track Resolution (Y)", 31, -.48, .48, 100, -.5, .5);
1060 h->GetXaxis()->SetTitle("tg(#phi)");
1061 h->GetYaxis()->SetTitle("#Delta y [cm]");
1062 h->GetZaxis()->SetTitle("entries");
1064 fContainer->AddAt(h, kMCtrackY);
1066 // Kalman track y resolution
1067 if(!(h = (TH2I*)gROOT->FindObject("hMCtrkYPull"))){
1068 h = new TH2I("hMCtrkYPull", "Kalman Track Pulls (Y)", 31, -.48, .48, 100, -3.5, 3.5);
1069 h->GetXaxis()->SetTitle("tg(#phi)");
1070 h->GetYaxis()->SetTitle("#Delta y / #sigma_{y}");
1071 h->GetZaxis()->SetTitle("entries");
1073 fContainer->AddAt(h, kMCtrackYPull);
1075 // Kalman track Z resolution
1076 if(!(h = (TH2I*)gROOT->FindObject("hMCtrkZIn"))){
1077 h = new TH2I("hMCtrkZIn", "Kalman Track Resolution (Zin)", 20, -1., 1., 100, -1.5, 1.5);
1078 h->GetXaxis()->SetTitle("tg(#theta)");
1079 h->GetYaxis()->SetTitle("#Delta z [cm]");
1080 h->GetZaxis()->SetTitle("entries");
1082 fContainer->AddAt(h, kMCtrackZIn);
1084 // Kalman track Z resolution
1085 if(!(h = (TH2I*)gROOT->FindObject("hMCtrkZOut"))){
1086 h = new TH2I("hMCtrkZOut", "Kalman Track Resolution (Zout)", 20, -1., 1., 100, -1.5, 1.5);
1087 h->GetXaxis()->SetTitle("tg(#theta)");
1088 h->GetYaxis()->SetTitle("#Delta z [cm]");
1089 h->GetZaxis()->SetTitle("entries");
1091 fContainer->AddAt(h, kMCtrackZOut);
1093 // Kalman track Z resolution
1094 if(!(h = (TH2I*)gROOT->FindObject("hMCtrkZInPull"))){
1095 h = new TH2I("hMCtrkZInPull", "Kalman Track Pulls (Zin)", 20, -1., 1., 100, -4.5, 4.5);
1096 h->GetXaxis()->SetTitle("tg(#theta)");
1097 h->GetYaxis()->SetTitle("#Delta z / #sigma_{z}");
1098 h->GetZaxis()->SetTitle("entries");
1100 fContainer->AddAt(h, kMCtrackZInPull);
1102 // Kalman track Z resolution
1103 if(!(h = (TH2I*)gROOT->FindObject("hMCtrkZOutPull"))){
1104 h = new TH2I("hMCtrkZOutPull", "Kalman Track Pulls (Zout)", 20, -1., 1., 100, -4.5, 4.5);
1105 h->GetXaxis()->SetTitle("tg(#theta)");
1106 h->GetYaxis()->SetTitle("#Delta z / #sigma_{z}");
1107 h->GetZaxis()->SetTitle("entries");
1109 fContainer->AddAt(h, kMCtrackZOutPull);
1111 // Kalman track Pt resolution
1112 if(!(h = (TH2I*)gROOT->FindObject("hMCtrkPt"))){
1113 h = new TH2I("hMCtrkPt", "Kalman Track Resolution (Pt)", 100, 0., 2., 150, -5., 20.);
1114 h->GetXaxis()->SetTitle("1/p_{t}");
1115 h->GetYaxis()->SetTitle("#Delta p_{t} [GeV/c]");
1116 h->GetZaxis()->SetTitle("entries");
1118 fContainer->AddAt(h, kMCtrackPt);
1124 //________________________________________________________
1125 void AliTRDresolution::SetRecoParam(AliTRDrecoParam *r)
1128 fReconstructor->SetRecoParam(r);