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 ////////////////////////////////////////////////////////////////////////////
55 #include <TObjArray.h>
62 #include <TGraphErrors.h>
64 #include "TTreeStream.h"
65 #include "TGeoManager.h"
67 #include "AliAnalysisManager.h"
68 #include "AliTrackReference.h"
69 #include "AliTrackPointArray.h"
70 #include "AliCDBManager.h"
72 #include "AliTRDSimParam.h"
73 #include "AliTRDgeometry.h"
74 #include "AliTRDpadPlane.h"
75 #include "AliTRDcluster.h"
76 #include "AliTRDseedV1.h"
77 #include "AliTRDtrackV1.h"
78 #include "AliTRDtrackerV1.h"
79 #include "AliTRDReconstructor.h"
80 #include "AliTRDrecoParam.h"
82 #include "AliTRDtrackInfo/AliTRDclusterInfo.h"
83 #include "AliTRDtrackInfo/AliTRDtrackInfo.h"
84 #include "AliTRDtrackingResolution.h"
86 ClassImp(AliTRDtrackingResolution)
88 //________________________________________________________
89 AliTRDtrackingResolution::AliTRDtrackingResolution()
90 :AliTRDrecoTask("Resolution", "Tracking Resolution")
98 ,fTrkltPhiResiduals(0x0)
100 ,fTrkltResolution(0x0)
102 fReconstructor = new AliTRDReconstructor();
103 fReconstructor->SetRecoParam(AliTRDrecoParam::GetLowFluxParam());
104 fGeo = new AliTRDgeometry();
108 DefineOutput(1+kClusterResidual, TObjArray::Class());
109 DefineOutput(1+kTrackletYResidual, TObjArray::Class());
110 DefineOutput(1+kTrackletPhiResidual, TObjArray::Class());
111 DefineOutput(1+kClusterResolution, TObjArray::Class());
112 DefineOutput(1+kTrackletYResolution, TObjArray::Class());
115 //________________________________________________________
116 AliTRDtrackingResolution::~AliTRDtrackingResolution()
118 if(fGraphS){fGraphS->Delete(); delete fGraphS;}
119 if(fGraphM){fGraphM->Delete(); delete fGraphM;}
121 delete fReconstructor;
122 if(gGeoManager) delete gGeoManager;
123 if(fClResiduals){fClResiduals->Delete(); delete fClResiduals;}
124 if(fTrkltResiduals){fTrkltResiduals->Delete(); delete fTrkltResiduals;}
125 if(fTrkltPhiResiduals){fTrkltPhiResiduals->Delete(); delete fTrkltPhiResiduals;}
126 if(fClResolution){fClResolution->Delete(); delete fClResolution;}
127 if(fTrkltResolution){fTrkltResolution->Delete(); delete fTrkltResolution;}
131 //________________________________________________________
132 void AliTRDtrackingResolution::CreateOutputObjects()
134 // spatial resolution
135 OpenFile(0, "RECREATE");
137 fContainer = Histos();
139 fClResiduals = new TObjArray();
140 fClResiduals->SetOwner(kTRUE);
141 fTrkltResiduals = new TObjArray();
142 fTrkltResiduals->SetOwner(kTRUE);
143 fTrkltPhiResiduals = new TObjArray();
144 fTrkltPhiResiduals->SetOwner(kTRUE);
145 fClResolution = new TObjArray();
146 fClResolution->SetOwner(kTRUE);
147 fTrkltResolution = new TObjArray();
148 fTrkltResolution->SetOwner(kTRUE);
151 //________________________________________________________
152 void AliTRDtrackingResolution::Exec(Option_t *opt)
154 fClResiduals->Delete();
155 fTrkltResiduals->Delete();
156 fTrkltPhiResiduals->Delete();
157 fClResolution->Delete();
158 fTrkltResolution->Delete();
160 AliTRDrecoTask::Exec(opt);
162 PostData(1+kClusterResidual, fClResiduals);
163 PostData(1+kTrackletYResidual, fTrkltResiduals);
164 PostData(1+kTrackletPhiResidual, fTrkltPhiResiduals);
165 PostData(1+kClusterResolution, fClResolution);
166 PostData(1+kTrackletYResolution, fTrkltResolution);
169 //________________________________________________________
170 TH1* AliTRDtrackingResolution::PlotClusterResiduals(const AliTRDtrackV1 *track)
172 if(track) fTrack = track;
174 AliWarning("No Track defined.");
178 if(!(h = ((TH2I*)fContainer->At(kClusterResidual)))){
179 AliWarning("No output histogram defined.");
183 Float_t x0, y0, z0, dy, dydx, dzdx;
184 AliTRDseedV1 *fTracklet = 0x0;
185 for(Int_t ily=0; ily<AliTRDgeometry::kNlayer; ily++){
186 if(!(fTracklet = fTrack->GetTracklet(ily))) continue;
187 if(!fTracklet->IsOK()) continue;
188 x0 = fTracklet->GetX0();
190 // retrive the track angle with the chamber
191 y0 = fTracklet->GetYref(0);
192 z0 = fTracklet->GetZref(0);
193 dydx = fTracklet->GetYref(1);
194 dzdx = fTracklet->GetZref(1);
195 Float_t tilt = fTracklet->GetTilt();
196 AliTRDcluster *c = 0x0;
197 fTracklet->ResetClusterIter(kFALSE);
198 while((c = fTracklet->PrevCluster())){
199 Float_t xc = c->GetX();
200 Float_t yc = c->GetY();
201 Float_t zc = c->GetZ();
202 Float_t dx = x0 - xc;
203 Float_t yt = y0 - dx*dydx;
204 Float_t zt = z0 - dx*dzdx;
205 dy = yt - (yc - tilt*(zc-zt));
207 //dy = trklt.GetYat(c->GetX()) - c->GetY();
211 // Get z-position with respect to anode wire
212 AliTRDSimParam *simParam = AliTRDSimParam::Instance();
213 Int_t istk = fGeo->GetStack(c->GetDetector());
214 AliTRDpadPlane *pp = fGeo->GetPadPlane(ily, istk);
215 Float_t row0 = pp->GetRow0();
216 Float_t d = row0 - zt + simParam->GetAnodeWireOffset();
217 d -= ((Int_t)(2 * d)) / 2.0;
218 if (d > 0.25) d = 0.5 - d;
220 AliTRDclusterInfo *clInfo = new AliTRDclusterInfo;
221 fClResiduals->Add(clInfo);
222 clInfo->SetCluster(c);
223 clInfo->SetGlobalPosition(yt, zt, dydx, dzdx);
224 clInfo->SetResolution(dy);
225 clInfo->SetAnisochronity(d);
226 clInfo->SetDriftLength(dx);
227 (*fDebugStream) << "ClusterResiduals"
228 <<"clInfo.=" << clInfo
237 //________________________________________________________
238 TH1* AliTRDtrackingResolution::PlotTrackletResiduals(const AliTRDtrackV1 *track)
240 if(track) fTrack = track;
242 AliWarning("No Track defined.");
246 if(!(h = ((TH2I*)fContainer->At(kTrackletYResidual)))){
247 AliWarning("No output histogram defined.");
252 AliTRDtrackerV1::FitRiemanTilt(fTrack, 0x0, kTRUE);
253 //AliTRDtrackerV1::FitLine(fTrack);
255 Float_t dydx, dzdx, yref, zref, yfit, zfit, x0, xmean;
256 AliTRDseedV1 *fTracklet = 0x0;
257 for(Int_t ily=0; ily<AliTRDgeometry::kNlayer; ily++){
258 if(!(fTracklet = fTrack->GetTracklet(ily))) continue;
259 if(!fTracklet->IsOK()) continue;
261 AliTRDseedV1 tt(*fTracklet);
262 // tt.SetX0(fTracklet->GetX0()+2.4);
263 if(!tt.Fit(kTRUE)) continue;
266 xmean = x0;//tt.GetXref();
267 // printf("xmean[%f]\n", xmean);
269 dydx = tt.GetYref(1);
270 yfit = tt.GetYfit(0)/*-tt.GetYfit(1)*xmean*/;
271 yref = tt.GetYref(0)/*-tt.GetYref(1)*xmean*/;
273 dzdx = tt.GetZref(1);
274 zfit = -tt.GetZfit(1)*xmean+tt.GetZfit(0);
275 zref = -tt.GetZref(1)*xmean+tt.GetZref(0);
277 h->Fill(dydx, yref-yfit);
280 /* AliTRDclusterInfo *clInfo = new AliTRDclusterInfo;
281 fClResiduals->Add(clInfo);
282 clInfo->SetGlobalPosition(yref, zref, phiref, thetaref);
283 clInfo->SetResolution(yref-yfit);
285 (*fDebugStream) << "TrackletResiduals"
286 <<"clInfo.=" << clInfo
289 (*fDebugStream) << "TrkltResiduals"
304 //________________________________________________________
305 TH1* AliTRDtrackingResolution::PlotTrackletPhiResiduals(const AliTRDtrackV1 *track)
307 if(track) fTrack = track;
309 AliWarning("No Track defined.");
313 if(!(h = ((TH2I*)fContainer->At(kTrackletPhiResidual)))){
314 AliWarning("No output histogram defined.");
319 AliTRDtrackerV1::FitRiemanTilt(fTrack, 0x0, kTRUE);
320 //AliTRDtrackerV1::FitLine(fTrack);
322 Float_t dydx_ref, dydx_fit;
323 AliTRDseedV1 *fTracklet = 0x0;
324 for(Int_t ily=0; ily<AliTRDgeometry::kNlayer; ily++){
325 if(!(fTracklet = fTrack->GetTracklet(ily))) continue;
326 if(!fTracklet->IsOK()) continue;
328 dydx_ref = fTracklet->GetYref(1);
329 dydx_fit = fTracklet->GetYfit(1);
331 h->Fill(dydx_ref, dydx_ref-dydx_fit);
334 (*fDebugStream) << "TrkltPhiResiduals"
335 << "dydx_ref=" << dydx_ref
336 << "dydx_fit=" << dydx_fit
344 //________________________________________________________
345 TH1* AliTRDtrackingResolution::PlotResolution(const AliTRDtrackV1 *track)
348 AliWarning("No MC defined. Results will not be available.");
351 if(track) fTrack = track;
353 AliWarning("No Track defined.");
357 if(!(h = ((TH2I*)fContainer->At(kClusterResolution)))){
358 AliWarning("No output histogram defined.");
361 if(!(h = ((TH2I*)fContainer->At(kTrackletYResolution)))){
362 AliWarning("No output histogram defined.");
365 if(!(h = ((TH2I*)fContainer->At(kTrackletZResolution)))){
366 AliWarning("No output histogram defined.");
369 if(!(h = ((TH2I*)fContainer->At(kTrackletAngleResolution)))){
370 AliWarning("No output histogram defined.");
373 //printf("called for %d tracklets ... \n", fTrack->GetNumberOfTracklets());
375 Int_t pdg = fMC->GetPDG(), det=-1;
376 Int_t label = fMC->GetLabel();
377 Float_t x0, y0, z0, dy, dydx, dzdx;
378 AliTRDseedV1 *fTracklet = 0x0;
379 for(Int_t ily=0; ily<AliTRDgeometry::kNlayer; ily++){
380 if(!(fTracklet = fTrack->GetTracklet(ily))) continue;
381 if(!fTracklet->IsOK()) continue;
382 //printf("process layer[%d]\n", ily);
383 // retrive the track position and direction within the chamber
384 det = fTracklet->GetDetector();
385 x0 = fTracklet->GetX0();
386 if(!fMC->GetDirections(x0, y0, z0, dydx, dzdx, s)) continue;
388 // recalculate tracklet based on the MC info
389 AliTRDseedV1 tt(*fTracklet);
392 if(!tt.Fit(kFALSE)) continue;
394 dy = tt.GetYfit(0) - y0;
395 Float_t dphi = TMath::ATan(tt.GetYfit(1)) - TMath::ATan(dydx);
397 Bool_t cross = fTracklet->GetNChange();
399 Double_t *xyz = tt.GetCrossXYZ();
400 dz = xyz[2] - (z0 - (x0 - xyz[0])*dzdx) ;
401 ((TH2I*)fContainer->At(kTrackletZResolution))->Fill(dzdx, dz);
405 ((TH2I*)fContainer->At(kTrackletYResolution))->Fill(dydx, dy);
406 ((TH2I*)fContainer->At(kTrackletAngleResolution))->Fill(dydx, dphi*TMath::RadToDeg());
410 Float_t p = fMC->GetTrackRef() ? fMC->GetTrackRef()->P() : -1.;
411 (*fDebugStream) << "TrkltResolution"
426 Int_t istk = AliTRDgeometry::GetStack(det);
427 AliTRDpadPlane *pp = fGeo->GetPadPlane(ily, istk);
428 Float_t zr0 = pp->GetRow0() + AliTRDSimParam::Instance()->GetAnodeWireOffset();
429 Float_t tilt = fTracklet->GetTilt();
431 AliTRDcluster *c = 0x0;
432 fTracklet->ResetClusterIter(kFALSE);
433 while((c = fTracklet->PrevCluster())){
434 Float_t q = TMath::Abs(c->GetQ());
435 Float_t xc = c->GetX();
436 Float_t yc = c->GetY();
437 Float_t zc = c->GetZ();
438 Float_t dx = x0 - xc;
439 Float_t yt = y0 - dx*dydx;
440 Float_t zt = z0 - dx*dzdx;
441 dy = yt - (yc - tilt*(zc-zt));
444 if(q>100.) ((TH2I*)fContainer->At(kClusterResolution))->Fill(dydx, dy);
448 Float_t d = zr0 - zt;
449 d -= ((Int_t)(2 * d)) / 2.0;
450 if (d > 0.25) d = 0.5 - d;
452 AliTRDclusterInfo *clInfo = new AliTRDclusterInfo;
453 fClResolution->Add(clInfo);
454 clInfo->SetCluster(c);
455 clInfo->SetMC(pdg, label);
456 clInfo->SetGlobalPosition(yt, zt, dydx, dzdx);
457 clInfo->SetResolution(dy);
458 clInfo->SetAnisochronity(d);
459 clInfo->SetDriftLength(x0-xc);
461 (*fDebugStream) << "ClusterResolution"
462 <<"clInfo.=" << clInfo
471 //________________________________________________________
472 void AliTRDtrackingResolution::GetRefFigure(Int_t ifig)
476 TGraphErrors *g = 0x0;
478 case kClusterResidual:
479 if(!(g = (TGraphErrors*)fGraphS->At(ifig))) break;
481 ax = g->GetHistogram()->GetYaxis();
482 ax->SetRangeUser(-.5, 1.);
483 ax->SetTitle("Clusters Y Residuals #sigma/#mu [mm]");
484 ax = g->GetHistogram()->GetXaxis();
485 ax->SetTitle("tg(#phi)");
486 if(!(g = (TGraphErrors*)fGraphM->At(ifig))) break;
488 b = new TBox(-.15, -.5, .15, 1.);
489 b->SetFillStyle(3002);b->SetFillColor(kGreen);
490 b->SetLineColor(0); b->Draw();
492 case kTrackletYResidual:
493 if(!(g = (TGraphErrors*)fGraphS->At(ifig))) break;
495 ax = g->GetHistogram()->GetYaxis();
496 ax->SetRangeUser(-.5, 1.);
497 ax->SetTitle("Tracklet Y Residuals #sigma/#mu [mm]");
498 ax = g->GetHistogram()->GetXaxis();
499 ax->SetTitle("tg(#phi)");
500 if(!(g = (TGraphErrors*)fGraphM->At(ifig))) break;
502 b = new TBox(-.15, -.5, .15, 1.);
503 b->SetFillStyle(3002);b->SetFillColor(kGreen);
504 b->SetLineColor(0); b->Draw();
506 case kTrackletPhiResidual:
507 if(!(g = (TGraphErrors*)fGraphS->At(ifig))) break;
509 ax = g->GetHistogram()->GetYaxis();
510 ax->SetRangeUser(-.5, 1.);
511 ax->SetTitle("Tracklet Phi Residuals #sigma/#mu [mm]");
512 ax = g->GetHistogram()->GetXaxis();
513 ax->SetTitle("tg(#phi)");
514 if(!(g = (TGraphErrors*)fGraphM->At(ifig))) break;
516 b = new TBox(-.15, -.5, .15, 1.);
517 b->SetFillStyle(3002);b->SetFillColor(kGreen);
518 b->SetLineColor(0); b->Draw();
520 case kClusterResolution:
521 if(!(g = (TGraphErrors*)fGraphS->At(ifig))) break;
522 ax = g->GetHistogram()->GetYaxis();
523 ax->SetRangeUser(-.5, 1.);
524 ax->SetTitle("Cluster Y Resolution #sigma/#mu [mm]");
525 ax = g->GetHistogram()->GetXaxis();
526 ax->SetTitle("tg(#phi)");
528 if(!(g = (TGraphErrors*)fGraphM->At(ifig))) break;
530 b = new TBox(-.15, -.5, .15, 1.);
531 b->SetFillStyle(3002);b->SetFillColor(kGreen);
532 b->SetLineColor(0); b->Draw();
534 case kTrackletYResolution:
535 if(!(g = (TGraphErrors*)fGraphS->At(ifig))) break;
536 ax = g->GetHistogram()->GetYaxis();
537 ax->SetRangeUser(-.5, 1.);
538 ax->SetTitle("Tracklet Y Resolution #sigma/#mu [mm]");
539 ax = g->GetHistogram()->GetXaxis();
540 ax->SetTitle("tg(#phi)");
542 if(!(g = (TGraphErrors*)fGraphM->At(ifig))) break;
545 case kTrackletZResolution:
546 if(!(g = (TGraphErrors*)fGraphS->At(ifig))) break;
547 ax = g->GetHistogram()->GetYaxis();
548 ax->SetRangeUser(-.5, 1.);
549 ax->SetTitle("Tracklet Z Resolution #sigma/#mu [mm]");
550 ax = g->GetHistogram()->GetXaxis();
551 ax->SetTitle("tg(#theta)");
553 if(!(g = (TGraphErrors*)fGraphM->At(ifig))) break;
556 case kTrackletAngleResolution:
557 if(!(g = (TGraphErrors*)fGraphS->At(ifig))) break;
558 ax = g->GetHistogram()->GetYaxis();
559 ax->SetRangeUser(-.05, .2);
560 ax->SetTitle("Tracklet Angular Resolution #sigma/#mu [deg]");
561 ax = g->GetHistogram()->GetXaxis();
562 ax->SetTitle("tg(#phi)");
564 if(!(g = (TGraphErrors*)fGraphM->At(ifig))) break;
568 AliInfo(Form("Reference plot [%d] not implemented yet", ifig));
571 AliInfo(Form("Reference plot [%d] missing result", ifig));
575 //________________________________________________________
576 Bool_t AliTRDtrackingResolution::PostProcess()
578 //fContainer = dynamic_cast<TObjArray*>(GetOutputData(0));
580 Printf("ERROR: list not available");
583 fNRefFigures = fContainer->GetEntriesFast();
585 fGraphS = new TObjArray(fNRefFigures);
589 fGraphM = new TObjArray(fNRefFigures);
595 TGraphErrors *gm = 0x0, *gs = 0x0;
598 TF1 f("f1", "gaus", -.5, .5);
600 TF1 fb("fb", "[0]*exp(-0.5*((x-[1])/[2])**2)+[3]", -.5, .5);
602 TF1 fc("fc", "[0]*exp(-0.5*((x-[1])/[2])**2)+[3]*exp(-0.5*((x-[4])/[5])**2)", -.5, .5);
605 if(IsVisual()) c = new TCanvas("c", Form("%s Visual", GetName()), 500, 500);
607 sprintf(opt, "%c%c", IsVerbose() ? ' ' : 'Q', IsVisual() ? ' ': 'N');
610 //PROCESS RESIDUAL DISTRIBUTIONS
612 // Clusters residuals
613 h2 = (TH2I *)(fContainer->At(kClusterResidual));
614 gm = new TGraphErrors();
615 gm->SetLineColor(kBlue);
616 gm->SetMarkerStyle(7);
617 gm->SetMarkerColor(kBlue);
618 gm->SetNameTitle("clm", "");
619 fGraphM->AddAt(gm, kClusterResidual);
620 gs = new TGraphErrors();
621 gs->SetLineColor(kRed);
622 gs->SetMarkerStyle(23);
623 gs->SetMarkerColor(kRed);
624 gs->SetNameTitle("cls", "");
625 fGraphS->AddAt(gs, kClusterResidual);
626 for(Int_t ibin = 1; ibin <= h2->GetNbinsX(); ibin++){
627 Double_t phi = h2->GetXaxis()->GetBinCenter(ibin);
628 h = h2->ProjectionY("py", ibin, ibin);
629 if(h->GetEntries()<100) continue;
632 if(IsVisual()){c->cd(); c->SetLogy();}
633 h->Fit(&f, opt, "", -0.5, 0.5);
634 if(IsVisual()){c->Modified(); c->Update(); gSystem->Sleep(500);}
636 Int_t ip = gm->GetN();
637 gm->SetPoint(ip, phi, 10.*f.GetParameter(1));
638 gm->SetPointError(ip, 0., 10.*f.GetParError(1));
639 gs->SetPoint(ip, phi, 10.*f.GetParameter(2));
640 gs->SetPointError(ip, 0., 10.*f.GetParError(2));
643 // Tracklet y residuals
644 h2 = (TH2I *)(fContainer->At(kTrackletYResidual));
645 gm = new TGraphErrors();
646 gm->SetLineColor(kBlue);
647 gm->SetMarkerStyle(7);
648 gm->SetMarkerColor(kBlue);
649 gm->SetNameTitle("tktm", "");
650 fGraphM->AddAt(gm, kTrackletYResidual);
651 gs = new TGraphErrors();
652 gs->SetLineColor(kRed);
653 gs->SetMarkerStyle(23);
654 gs->SetMarkerColor(kRed);
655 gs->SetNameTitle("tkts", "");
656 fGraphS->AddAt(gs, kTrackletYResidual);
657 for(Int_t ibin = 1; ibin <= h2->GetNbinsX(); ibin++){
658 Double_t phi = h2->GetXaxis()->GetBinCenter(ibin);
659 h = h2->ProjectionY("py", ibin, ibin);
660 if(h->GetEntries()<100) continue;
663 if(IsVisual()){c->cd(); c->SetLogy();}
664 h->Fit(&f, opt, "", -0.5, 0.5);
665 if(IsVisual()){c->Modified(); c->Update(); gSystem->Sleep(500);}
667 Int_t ip = gm->GetN();
668 gm->SetPoint(ip, phi, 10.*f.GetParameter(1));
669 gm->SetPointError(ip, 0., 10.*f.GetParError(1));
670 gs->SetPoint(ip, phi, 10.*f.GetParameter(2));
671 gs->SetPointError(ip, 0., 10.*f.GetParError(2));
674 // Tracklet phi residuals
675 h2 = (TH2I *)(fContainer->At(kTrackletPhiResidual));
676 gm = new TGraphErrors();
677 gm->SetLineColor(kBlue);
678 gm->SetMarkerStyle(7);
679 gm->SetMarkerColor(kBlue);
680 gm->SetNameTitle("tktphim", "");
681 fGraphM->AddAt(gm, kTrackletPhiResidual);
682 gs = new TGraphErrors();
683 gs->SetLineColor(kRed);
684 gs->SetMarkerStyle(23);
685 gs->SetMarkerColor(kRed);
686 gs->SetNameTitle("tktphis", "");
687 fGraphS->AddAt(gs, kTrackletPhiResidual);
688 for(Int_t ibin = 1; ibin <= h2->GetNbinsX(); ibin++){
689 Double_t phi = h2->GetXaxis()->GetBinCenter(ibin);
690 h = h2->ProjectionY("py", ibin, ibin);
691 if(h->GetEntries()<100) continue;
694 if(IsVisual()){c->cd(); c->SetLogy();}
695 h->Fit(&f, opt, "", -0.5, 0.5);
696 if(IsVisual()){c->Modified(); c->Update(); gSystem->Sleep(500);}
698 Int_t ip = gm->GetN();
699 gm->SetPoint(ip, phi, 10.*f.GetParameter(1));
700 gm->SetPointError(ip, 0., 10.*f.GetParError(1));
701 gs->SetPoint(ip, phi, 10.*f.GetParameter(2));
702 gs->SetPointError(ip, 0., 10.*f.GetParError(2));
706 //PROCESS RESOLUTION DISTRIBUTIONS
709 // cluster y resolution
710 h2 = (TH2I*)fContainer->At(kClusterResolution);
711 gm = new TGraphErrors();
712 gm->SetLineColor(kBlue);
713 gm->SetMarkerStyle(7);
714 gm->SetMarkerColor(kBlue);
715 gm->SetNameTitle("clym", "");
716 fGraphM->AddAt(gm, kClusterResolution);
717 gs = new TGraphErrors();
718 gs->SetLineColor(kRed);
719 gs->SetMarkerStyle(23);
720 gs->SetMarkerColor(kRed);
721 gs->SetNameTitle("clys", "");
722 fGraphS->AddAt(gs, kClusterResolution);
723 for(Int_t iphi=1; iphi<=h2->GetNbinsX(); iphi++){
724 h = h2->ProjectionY("py", iphi, iphi);
725 if(h->GetEntries()<100) continue;
728 if(IsVisual()){c->cd(); c->SetLogy();}
729 h->Fit(&f, opt, "", -0.5, 0.5);
731 printf("phi[%d] mean[%e] sigma[%e]\n\n", iphi, 10.*f.GetParameter(1), 10.*f.GetParameter(2));
733 if(IsVisual()){c->Modified(); c->Update(); gSystem->Sleep(500);}
735 Double_t phi = h2->GetXaxis()->GetBinCenter(iphi);
736 Int_t ip = gm->GetN();
737 gm->SetPoint(ip, phi, 10.*f.GetParameter(1));
738 gm->SetPointError(ip, 0., 10.*f.GetParError(1));
739 gs->SetPoint(ip, phi, 10.*f.GetParameter(2));
740 gs->SetPointError(ip, 0., 10.*f.GetParError(2));
743 // tracklet y resolution
744 h2 = (TH2I*)fContainer->At(kTrackletYResolution);
745 gm = new TGraphErrors();
746 gm->SetLineColor(kBlue);
747 gm->SetMarkerStyle(7);
748 gm->SetMarkerColor(kBlue);
749 gm->SetNameTitle("trkltym", "");
750 fGraphM->AddAt(gm, kTrackletYResolution);
751 gs = new TGraphErrors();
752 gs->SetLineColor(kRed);
753 gs->SetMarkerStyle(23);
754 gs->SetMarkerColor(kRed);
755 gs->SetNameTitle("trkltys", "");
756 fGraphS->AddAt(gs, kTrackletYResolution);
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(&fb, opt, "", -0.5, 0.5);
764 if(IsVisual()){c->Modified(); c->Update(); gSystem->Sleep(500);}
766 Double_t phi = h2->GetXaxis()->GetBinCenter(iphi);
767 Int_t ip = gm->GetN();
768 gm->SetPoint(ip, phi, 10.*fb.GetParameter(1));
769 gm->SetPointError(ip, 0., 10.*fb.GetParError(1));
770 gs->SetPoint(ip, phi, 10.*fb.GetParameter(2));
771 gs->SetPointError(ip, 0., 10.*fb.GetParError(2));
774 // tracklet z resolution
775 h2 = (TH2I*)fContainer->At(kTrackletZResolution);
776 gm = new TGraphErrors();
777 gm->SetLineColor(kBlue);
778 gm->SetMarkerStyle(7);
779 gm->SetMarkerColor(kBlue);
780 gm->SetNameTitle("trkltzm", "");
781 fGraphM->AddAt(gm, kTrackletZResolution);
782 gs = new TGraphErrors();
783 gs->SetLineColor(kRed);
784 gs->SetMarkerStyle(23);
785 gs->SetMarkerColor(kRed);
786 gs->SetNameTitle("trkltzs", "");
787 fGraphS->AddAt(gs, kTrackletZResolution);
788 for(Int_t iphi=1; iphi<=h2->GetNbinsX(); iphi++){
789 h = h2->ProjectionY("py", iphi, iphi);
790 if(h->GetEntries()<100) continue;
793 if(IsVisual()){c->cd(); c->SetLogy();}
794 h->Fit(&fb, opt, "", -0.5, 0.5);
795 if(IsVisual()){c->Modified(); c->Update(); gSystem->Sleep(500);}
797 Double_t phi = h2->GetXaxis()->GetBinCenter(iphi);
798 Int_t ip = gm->GetN();
799 gm->SetPoint(ip, phi, 10.*fb.GetParameter(1));
800 gm->SetPointError(ip, 0., 10.*fb.GetParError(1));
801 gs->SetPoint(ip, phi, 10.*fb.GetParameter(2));
802 gs->SetPointError(ip, 0., 10.*fb.GetParError(2));
805 // tracklet phi resolution
806 h2 = (TH2I*)fContainer->At(kTrackletAngleResolution);
807 gm = new TGraphErrors();
808 gm->SetLineColor(kBlue);
809 gm->SetMarkerStyle(7);
810 gm->SetMarkerColor(kBlue);
811 gm->SetNameTitle("trkltym", "");
812 fGraphM->AddAt(gm, kTrackletAngleResolution);
813 gs = new TGraphErrors();
814 gs->SetLineColor(kRed);
815 gs->SetMarkerStyle(23);
816 gs->SetMarkerColor(kRed);
817 gs->SetNameTitle("trkltys", "");
818 fGraphS->AddAt(gs, kTrackletAngleResolution);
819 for(Int_t iphi=1; iphi<=h2->GetNbinsX(); iphi++){
820 h = h2->ProjectionY("py", iphi, iphi);
821 if(h->GetEntries()<100) continue;
823 if(IsVisual()){c->cd(); c->SetLogy();}
824 h->Fit(&f, opt, "", -0.5, 0.5);
825 if(IsVisual()){c->Modified(); c->Update(); gSystem->Sleep(500);}
827 Double_t phi = h2->GetXaxis()->GetBinCenter(iphi);
828 Int_t ip = gm->GetN();
829 gm->SetPoint(ip, phi, f.GetParameter(1));
830 gm->SetPointError(ip, 0., f.GetParError(1));
831 gs->SetPoint(ip, phi, f.GetParameter(2));
832 gs->SetPointError(ip, 0., f.GetParError(2));
841 //________________________________________________________
842 void AliTRDtrackingResolution::Terminate(Option_t *)
849 if(HasPostProcess()) PostProcess();
852 //________________________________________________________
853 void AliTRDtrackingResolution::AdjustF1(TH1 *h, TF1 *f)
855 // Helper function to avoid duplication of code
856 // Make first guesses on the fit parameters
858 // find the intial parameters of the fit !! (thanks George)
859 Int_t nbinsy = Int_t(.5*h->GetNbinsX());
861 for(Int_t jbin=nbinsy-4; jbin<=nbinsy+4; jbin++) sum+=h->GetBinContent(jbin); sum/=9.;
862 f->SetParLimits(0, 0., 3.*sum);
863 f->SetParameter(0, .9*sum);
865 f->SetParLimits(1, -.2, .2);
866 f->SetParameter(1, -0.1);
868 f->SetParLimits(2, 0., 4.e-1);
869 f->SetParameter(2, 2.e-2);
870 if(f->GetNpar() <= 4) return;
872 f->SetParLimits(3, 0., sum);
873 f->SetParameter(3, .1*sum);
875 f->SetParLimits(4, -.3, .3);
876 f->SetParameter(4, 0.);
878 f->SetParLimits(5, 0., 1.e2);
879 f->SetParameter(5, 2.e-1);
882 //________________________________________________________
883 TObjArray* AliTRDtrackingResolution::Histos()
885 if(fContainer) return fContainer;
887 fContainer = new TObjArray(7);
890 // cluster to tracklet residuals [2]
891 if(!(h = (TH2I*)gROOT->FindObject("fYCl"))){
892 h = new TH2I("fYCl", "Clusters Residuals", 21, -.33, .33, 100, -.5, .5);
893 h->GetXaxis()->SetTitle("tg(#phi)");
894 h->GetYaxis()->SetTitle("#Delta y [cm]");
895 h->GetZaxis()->SetTitle("entries");
897 fContainer->AddAt(h, kClusterResidual);
899 // tracklet to track residuals [2]
900 if(!(h = (TH2I*)gROOT->FindObject("hTrkltYRez"))){
901 h = new TH2I("hTrkltYRez", "Tracklets", 21, -.33, .33, 100, -.5, .5);
902 h->GetXaxis()->SetTitle("tg(#phi)");
903 h->GetYaxis()->SetTitle("#Delta y [cm]");
904 h->GetZaxis()->SetTitle("entries");
906 fContainer->AddAt(h, kTrackletYResidual);
908 // tracklet to track residuals angular [2]
909 if(!(h = (TH2I*)gROOT->FindObject("hTrkltPhiRez"))){
910 h = new TH2I("hTrkltPhiRez", "Tracklets", 21, -.33, .33, 100, -.5, .5);
911 h->GetXaxis()->SetTitle("tg(#phi)");
912 h->GetYaxis()->SetTitle("#Delta phi [#circ]");
913 h->GetZaxis()->SetTitle("entries");
915 fContainer->AddAt(h, kTrackletPhiResidual);
920 // cluster y resolution [0]
921 if(!(h = (TH2I*)gROOT->FindObject("fYClMC"))){
922 h = new TH2I("fYClMC", "Cluster Resolution", 31, -.48, .48, 100, -.5, .5);
923 h->GetXaxis()->SetTitle("tg(#phi)");
924 h->GetYaxis()->SetTitle("#Delta y [cm]");
925 h->GetZaxis()->SetTitle("entries");
927 fContainer->AddAt(h, kClusterResolution);
929 // tracklet y resolution [0]
930 if(!(h = (TH2I*)gROOT->FindObject("fYTrkltMC"))){
931 h = new TH2I("fYTrkltMC", "Tracklet Resolution (Y)", 31, -.48, .48, 100, -.5, .5);
932 h->GetXaxis()->SetTitle("tg(#phi)");
933 h->GetYaxis()->SetTitle("#Delta y [cm]");
934 h->GetZaxis()->SetTitle("entries");
936 fContainer->AddAt(h, kTrackletYResolution);
938 // tracklet y resolution [0]
939 if(!(h = (TH2I*)gROOT->FindObject("fZTrkltMC"))){
940 h = new TH2I("fZTrkltMC", "Tracklet Resolution (Z)", 31, -.48, .48, 100, -.5, .5);
941 h->GetXaxis()->SetTitle("tg(#theta)");
942 h->GetYaxis()->SetTitle("#Delta z [cm]");
943 h->GetZaxis()->SetTitle("entries");
945 fContainer->AddAt(h, kTrackletZResolution);
947 // tracklet angular resolution [1]
948 if(!(h = (TH2I*)gROOT->FindObject("fPhiTrkltMC"))){
949 h = new TH2I("fPhiTrkltMC", "Tracklet Resolution (Angular)", 31, -.48, .48, 100, -10., 10.);
950 h->GetXaxis()->SetTitle("tg(#phi)");
951 h->GetYaxis()->SetTitle("#Delta #phi [deg]");
952 h->GetZaxis()->SetTitle("entries");
954 fContainer->AddAt(h, kTrackletAngleResolution);
960 //________________________________________________________
961 void AliTRDtrackingResolution::SetRecoParam(AliTRDrecoParam *r)
964 fReconstructor->SetRecoParam(r);