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: AliTRDclusterResolution.cxx */
18 ///////////////////////////////////////////////////////////////////////////////
20 // TRD cluster error parameterization //
22 // This class is designed to produce the reference plots for a detailed study//
23 // and parameterization of TRD cluster errors. The following effects are taken//
25 // - dependence with the total charge of the cluster //
26 // - dependence with the distance from the center pad. This is monitored
27 // for each layer individually since the pad size varies with layer
28 // - dependence with the drift length - here the influence of anisochronity
29 // and diffusion are searched
30 // - dependence with the distance to the anode wire - anisochronity effects
31 // - dependence with track angle (for y resolution)
32 // The correlation between effects is taken into account.
34 // Since magnetic field plays a very important role in the TRD measurement
35 // the ExB correction is forced by the setter function SetExB(Int_t). The
36 // argument is the detector index, if none is specified all will be
39 // Two cases are of big importance.
40 // - comparison with MC
41 // - comparison with Kalman fit. In this case the covariance matrix of the
42 // Kalman fit are needed.
44 // The functionalities implemented in this class are based on the storage
45 // class AliTRDclusterInfo.
50 // The method to disentangle s_y and s_x is based on the relation (see also fig.)
52 // #sigma^{2} = #sigma^{2}_{y} + tg^{2}(#alpha_{L})*#sigma^{2}_{x_{d}} + tg^{2}(#phi-#alpha_{L})*(#sigma^{2}_{x_{d}}+#sigma^{2}_{x_{c}})
56 // #sigma^{2}_{x_{c}} #approx 0
58 // we suppose the chamber is well calibrated for t_{0} and aligned in
61 // Clusters can be radially shifted due to three causes:
62 // - globally shifted - due to residual misalignment/miscalibration(t0)
63 // - locally shifted - due to different local drift velocity from the mean
64 // - randomly shifted - due to neighboring (radial direction) clusters
65 // charge induced by asymmetry of the TRF.
67 // We estimate this effects by the relations:
69 // #mu_{y} = tg(#alpha_{L})*#Delta x_{d}(...) + tg(#phi-#alpha_{L})*(#Delta x_{c}(...) + #Delta x_{d}(...))
73 // #Delta x_{d}(...) = (<v_{d}> + #delta v_{d}(x_{d}, d)) * (t + t^{*}(Q))
75 // and we specified explicitely the variation of drift velocity parallel
76 // with the track (x_{d}) and perpendicular to it due to anisochronity (d).
78 // For estimating the contribution from asymmetry of TRF the following
79 // parameterization is being used
81 // t^{*}(Q) = #delta_{0} * #frac{Q_{t+1} - Q_{t-1}}{Q_{t-1} + Q_{t} + Q_{t+1}}
85 // Clusters can also be r-phi shifted due to:
86 // - wrong PRF or wrong cuts at digits level
87 //The following correction is applied :
89 // <#Delta y> = a + b * sin(c*y_{pw})
94 // Parameterization against total charge
96 // Obtained for B=0T at phi=0. All other effects integrated out.
98 // #sigma^{2}_{y}(Q) = #sigma^{2}_{y}(...) + b(#frac{1}{Q} - #frac{1}{Q_{0}})
100 // For B diff 0T the error of the average ExB correction error has to be subtracted !!
102 // Parameterization Sx
104 // The parameterization of the error in the x direction can be written as
106 // #sigma_{x} = #sigma_{x}^{||} + #sigma_{x}^{#perp}
109 // where the parallel component is given mainly by the TRF width while
110 // the perpendicular component by the anisochronity. The model employed for
111 // the parallel is gaus(0)+expo(3) with the following parameters
112 // 1 C 5.49018e-01 1.23854e+00 3.84540e-04 -8.21084e-06
113 // 2 M 7.82999e-01 6.22531e-01 2.71272e-04 -6.88485e-05
114 // 3 S 2.74451e-01 1.13815e+00 2.90667e-04 1.13493e-05
115 // 4 E1 2.53596e-01 1.08646e+00 9.95591e-05 -2.11625e-05
116 // 5 E2 -2.40078e-02 4.26520e-01 4.67153e-05 -2.35392e-04
118 // and perpendicular to the track is pol2 with the parameters
120 // Par_0 = 0.190676 +/- 0.41785
121 // Par_1 = -3.9269 +/- 7.49862
122 // Par_2 = 14.7851 +/- 27.8012
124 // Parameterization Sy
126 // The parameterization of the error in the y direction along track uses
128 // #sigma_{y}^{||} = #sigma_{y}^{0} -a*exp(1/(x-b))
131 // with following values for the parameters:
132 // 1 sy0 2.60967e-01 2.99652e-03 7.82902e-06 -1.89636e-04
133 // 2 a -7.68941e+00 1.87883e+00 3.84539e-04 9.38268e-07
134 // 3 b -3.41160e-01 7.72850e-02 1.63231e-05 2.51602e-05
136 //==========================================================================
137 // Example how to retrive reference plots from the task
138 // void steerClErrParam(Int_t fig=0)
140 // gSystem->Load("libANALYSIS.so");
141 // gSystem->Load("libTRDqaRec.so");
143 // // initialize DB manager
144 // AliCDBManager *cdb = AliCDBManager::Instance();
145 // cdb->SetDefaultStorage("local://$ALICE_ROOT/OCDB");
147 // // initialize magnetic field.
148 // AliMagFCheb *field=new AliMagFCheb("Maps","Maps", 2, 1., 10., AliMagFCheb::k5kG);
149 // AliTracker::SetFieldMap(field, kTRUE);
151 // AliTRDclusterResolution *res = new AliTRDclusterResolution();
153 // res->Load("TRD.TaskClErrParam.root");
156 // //res->SetSaveAs();
157 // res->SetProcessCharge(kFALSE);
158 // res->SetProcessCenterPad(kFALSE);
159 // //res->SetProcessMean(kFALSE);
160 // res->SetProcessSigma(kFALSE);
161 // if(!res->PostProcess()) return;
163 // res->GetRefFigure(fig);
167 // Alexandru Bercuci <A.Bercuci@gsi.de> //
168 ////////////////////////////////////////////////////////////////////////////
170 #include "AliTRDclusterResolution.h"
171 #include "info/AliTRDclusterInfo.h"
172 #include "AliTRDgeometry.h"
173 #include "AliTRDpadPlane.h"
174 #include "AliTRDcluster.h"
175 #include "AliTRDseedV1.h"
176 #include "AliTRDcalibDB.h"
177 #include "AliTRDCommonParam.h"
178 #include "Cal/AliTRDCalROC.h"
179 #include "Cal/AliTRDCalDet.h"
181 #include "AliESDEvent.h"
182 #include "AliCDBManager.h"
185 #include "TObjArray.h"
189 #include "TGraphErrors.h"
195 #include "TLinearFitter.h"
196 #include "TGeoGlobalMagField.h"
201 ClassImp(AliTRDclusterResolution)
203 const Float_t AliTRDclusterResolution::fgkTimeBinLength = 1./ AliTRDCommonParam::Instance()->GetSamplingFrequency();
204 //_______________________________________________________
205 AliTRDclusterResolution::AliTRDclusterResolution()
227 SetNameTitle("ClErrCalib", "Cluster Error Parameterization");
228 memset(fR, 0, 4*sizeof(Float_t));
229 memset(fP, 0, 4*sizeof(Float_t));
232 //_______________________________________________________
233 AliTRDclusterResolution::AliTRDclusterResolution(const char *name)
234 : AliTRDrecoTask(name, "Cluster Error Parameterization")
256 memset(fR, 0, 4*sizeof(Float_t));
257 memset(fP, 0, 4*sizeof(Float_t));
259 // By default register all analysis
260 // The user can switch them off in his steering macro
267 //_______________________________________________________
268 AliTRDclusterResolution::~AliTRDclusterResolution()
272 if(fCanvas) delete fCanvas;
279 //_______________________________________________________
280 void AliTRDclusterResolution::UserCreateOutputObjects()
282 fContainer = Histos();
283 PostData(1, fContainer);
286 //_______________________________________________________
287 Bool_t AliTRDclusterResolution::GetRefFigure(Int_t ifig)
289 // Steering function to retrieve performance plots
291 if(!fResults) return kFALSE;
294 TObjArray *arr = NULL;
296 TH2 *h2 = NULL;TH1 *h1 = NULL;
297 TGraphErrors *gm(NULL), *gs(NULL), *gp(NULL);
300 if(!(arr = (TObjArray*)fResults->At(kQRes))) break;
301 if(!(gm = (TGraphErrors*)arr->At(0))) break;
302 if(!(gs = (TGraphErrors*)arr->At(1))) break;
303 if(!(gp = (TGraphErrors*)arr->At(2))) break;
304 leg= new TLegend(.7, .7, .9, .95);
305 leg->SetBorderSize(0); leg->SetFillColor(0); leg->SetFillStyle(0);
306 gs->Draw("apl"); leg->AddEntry(gs, "Sigma / Resolution", "pl");
307 gs->GetHistogram()->GetYaxis()->SetRangeUser(-50., 700.);
308 gs->GetHistogram()->SetXTitle("Q [a.u.]");
309 gs->GetHistogram()->SetYTitle("y - x tg(#alpha_{L}) [#mum]");
310 gm->Draw("pl");leg->AddEntry(gm, "Mean / Systematics", "pl");
311 gp->Draw("pl");leg->AddEntry(gp, "Abundance / Probability", "pl");
315 if(!(arr = (TObjArray*)fResults->At(kCenter))) break;
316 gPad->Divide(2, 1); l = gPad->GetListOfPrimitives();
317 ((TVirtualPad*)l->At(0))->cd();
318 ((TTree*)arr->At(0))->Draw(Form("y:t>>h(%d, -0.5, %f, 51, -.51, .51)",AliTRDseedV1::kNtb, AliTRDseedV1::kNtb-0.5),
319 "m[0]*(ly==0&&abs(m[0])<1.e-1)", "colz");
320 ((TVirtualPad*)l->At(1))->cd();
321 leg= new TLegend(.7, .7, .9, .95);
322 leg->SetBorderSize(0); leg->SetFillColor(0); leg->SetFillStyle(0);
323 leg->SetHeader("TRD Plane");
324 for(Int_t il = 1; il<=AliTRDgeometry::kNlayer; il++){
325 if(!(gm = (TGraphErrors*)arr->At(il))) return kFALSE;
326 gm->Draw(il>1?"pc":"apc"); leg->AddEntry(gm, Form("%d", il-1), "pl");
328 gm->GetHistogram()->SetXTitle("t_{drift} [tb]");
329 gm->GetHistogram()->SetYTitle("#sigma_{y}(x|cen=0) [#mum]");
330 gm->GetHistogram()->GetYaxis()->SetRangeUser(150., 500.);
335 if(!(t = (TTree*)fResults->At(kSigm))) break;
336 t->Draw("z:t>>h2x(23, 0.1, 2.4, 25, 0., 2.5)","sx*(1)", "lego2fb");
337 h2 = (TH2F*)gROOT->FindObject("h2x");
338 printf(" const Double_t sx[24][25]={\n");
339 for(Int_t ix=1; ix<=h2->GetNbinsX(); ix++){
341 for(Int_t iy=1; iy<h2->GetNbinsY(); iy++){
342 printf("%6.4f ", h2->GetBinContent(ix, iy));
344 printf("%6.4f},\n", h2->GetBinContent(ix, h2->GetNbinsY()));
347 gPad->Divide(2, 1, 1.e-5, 1.e-5); l = gPad->GetListOfPrimitives();
348 ((TVirtualPad*)l->At(0))->cd();
349 h1 = h2->ProjectionX("hsx_pxx"); h1->Scale(1.e4/kND); h1->SetMarkerStyle(24);
350 h1->SetYTitle("<#sigma_{x}> [#mum]");
351 h1->SetXTitle("t_{drift} [#mus]");
352 h1->GetXaxis()->SetRange(2, AliTRDseedV1::kNtb-1); h1->Draw("pc");
354 t->Draw("z:t>>h2y(23, 0.1, 2.4, 25, 0., 2.5)","sy*(1)", "lego2fb");
355 h2 = (TH2F*)gROOT->FindObject("h2y");
356 printf(" const Double_t sy[24][25]={\n");
357 for(Int_t ix=1; ix<=h2->GetNbinsX(); ix++){
359 for(Int_t iy=1; iy<h2->GetNbinsY(); iy++){
360 printf("%6.4f ", h2->GetBinContent(ix, iy));
362 printf("%6.4f},\n", h2->GetBinContent(ix, h2->GetNbinsY()));
365 ((TVirtualPad*)l->At(1))->cd();
366 h1 = h2->ProjectionX("hsy_pxx"); h1->Scale(1.e4/kND); h1->SetMarkerStyle(24);
367 h1->SetYTitle("<#sigma_{y}> [#mum]");
368 h1->SetXTitle("t_{drift} [#mus]");
369 h1->GetXaxis()->SetRange(2, AliTRDseedV1::kNtb-1); h1->Draw("pc");
372 if(!(t = (TTree*)fResults->At(kMean))) break;
373 if(!t->Draw(Form("z:t>>h2x(%d, -0.5, %3.1f, %d, 0., 2.5)",
374 AliTRDseedV1::kNtb, AliTRDseedV1::kNtb-0.5, kND),
375 "dx*(1)", "goff")) break;
376 h2 = (TH2F*)gROOT->FindObject("h2x");
377 printf(" const Double_t dx[%d][%d]={\n", AliTRDseedV1::kNtb, kND);
378 for(Int_t ix=1; ix<=h2->GetNbinsX(); ix++){
380 for(Int_t iy=1; iy<h2->GetNbinsY(); iy++){
381 printf("%+6.4e, ", h2->GetBinContent(ix, iy));
383 printf("%+6.4e},\n", h2->GetBinContent(ix, h2->GetNbinsY()));
386 gPad->Divide(2, 2, 1.e-5, 1.e-5); l = gPad->GetListOfPrimitives();
387 ((TVirtualPad*)l->At(0))->cd();
389 ((TVirtualPad*)l->At(2))->cd();
390 h1 = h2->ProjectionX("hdx_pxx"); h1->Scale(1.e4/kND); h1->SetMarkerStyle(24);
391 h1->SetYTitle("<#deltax> [#mum]");
392 h1->SetXTitle("t_{drift} [tb]");
393 //h1->GetXaxis()->SetRange(2, AliTRDseedV1::kNtb-1);
396 if(!t->Draw(Form("z:t>>h2y(%d, -0.5, %3.1f, %d, 0., 2.5)",
397 AliTRDseedV1::kNtb, AliTRDseedV1::kNtb-0.5, kND),
398 "dy*(1)", "goff")) break;
399 h2 = (TH2F*)gROOT->FindObject("h2y");
400 printf(" const Double_t dy[%d][%d]={\n", AliTRDseedV1::kNtb, kND);
401 for(Int_t ix=1; ix<=h2->GetNbinsX(); ix++){
403 for(Int_t iy=1; iy<h2->GetNbinsY(); iy++){
404 printf("%+6.4e ", h2->GetBinContent(ix, iy));
406 printf("%+6.4e},\n", h2->GetBinContent(ix, h2->GetNbinsY()));
409 ((TVirtualPad*)l->At(1))->cd();
411 ((TVirtualPad*)l->At(3))->cd();
412 h1 = h2->ProjectionX("hdy_pxx"); h1->Scale(1.e4/kND); h1->SetMarkerStyle(24);
413 h1->SetYTitle("<#deltay> [#mum]");
414 h1->SetXTitle("t_{drift} [tb]");
415 //h1->GetXaxis()->SetRange(2, AliTRDseedV1::kNtb-1);
422 AliWarning("No container/data found.");
426 //_______________________________________________________
427 TObjArray* AliTRDclusterResolution::Histos()
429 // Retrieve histograms array if already build or build it
431 if(fContainer) return fContainer;
432 fContainer = new TObjArray(kNtasks);
433 //fContainer->SetOwner(kTRUE);
436 TObjArray *arr = NULL;
438 // add resolution/pulls plots for dydx=ExB
439 fContainer->AddAt(arr = new TObjArray(2), kCenter);
440 arr->SetName("Center");
441 if(!(h3=(TH3S*)gROOT->FindObject(Form("hRes%s%03d", (HasMCdata()?"MC":"") ,fDet)))) {
443 Form("hRes%s%03d", (HasMCdata()?"MC":""),fDet),
444 Form(" Det[%d] Col[%d] Row[%d];t [bin];y [pw];#Delta y[cm]", fDet, fCol, fRow),
445 AliTRDseedV1::kNtb, -.5, AliTRDseedV1::kNtb-0.5, // x
447 60, -fDyRange, fDyRange); // dy
450 // add Pull plot for each layer
451 if(!(h3=(TH3S*)gROOT->FindObject(Form("hPull%s%03d", (HasMCdata()?"MC":""), fDet)))){
453 Form("hPull%s%03d", (HasMCdata()?"MC":""), fDet),
454 Form(" Det[%d] Col[%d] Row[%d];t [bin];y [pw];#Delta y[cm]/#sigma_{y}", fDet, fCol, fRow),
455 AliTRDseedV1::kNtb, -0.5, AliTRDseedV1::kNtb-0.5, // x
457 60, -4., 4.); // dy/sy
461 if(!(h3 = (TH3S*)gROOT->FindObject(Form("Charge%s%03d", (HasMCdata()?"MC":""), fDet)))){
462 h3 = new TH3S(Form("Charge%s%03d", (HasMCdata()?"MC":""), fDet),
463 "dy=f(q);log(q) [a.u.];#Delta y[cm];#Delta y/#sigma_{y}",
464 50, 2.2, 7.5, 60, -fDyRange, fDyRange, 60, -4., 4.);
466 fContainer->AddAt(h3, kQRes);
468 fContainer->AddAt(arr = new TObjArray(AliTRDseedV1::kNtb), kSigm);
469 arr->SetName("Resolution");
470 for(Int_t it=0; it<AliTRDseedV1::kNtb; it++){
471 if(!(h3=(TH3S*)gROOT->FindObject(Form("hr%s%03d_t%02d", (HasMCdata()?"MC":""), fDet, it)))){
473 Form("hr%s%03d_t%02d", (HasMCdata()?"MC":""), fDet, it),
474 Form(" Det[%d] t_{drift}(%2d)[bin];h*tg(#theta);tg(#phi);#Delta y[cm]", fDet, it),
475 35, -0.035, 0.035, // tgt
476 35, -.35, .35, // tgp
477 60, -fDyRange, fDyRange); // dy
482 fContainer->AddAt(arr = new TObjArray(AliTRDseedV1::kNtb), kMean);
483 arr->SetName("Systematics");
484 for(Int_t it=0; it<AliTRDseedV1::kNtb; it++){
485 if(!(h3=(TH3S*)gROOT->FindObject(Form("hs%s%03d_t%02d", (HasMCdata()?"MC":""), fDet, it)))){
487 Form("hs%s%03d_t%02d", (HasMCdata()?"MC":""), fDet, it),
488 Form(" Det[%d] t_{drift}(%2d)[bin];z [mm];tg(#phi) - h*tg(#theta) %s;#Delta y[cm]", fDet, it, fExB>1.e-5?"- tg(#alpha_{L})":""),
490 35, -.35, .35, // tgp-h tgt-tg(aL)
491 60, -fDyRange, fDyRange); // dy
499 //_______________________________________________________
500 void AliTRDclusterResolution::UserExec(Option_t *)
502 // Fill container histograms
505 fInfo = dynamic_cast<TObjArray *>(GetInputData(1));
506 AliDebug(2, Form("Clusters[%d]", fInfo->GetEntriesFast()));
510 AliWarning("Loading the calibration settings failed. Check OCDB access.");
516 Float_t x, y, z, q, dy, dydx, dzdx, cov[3], covcl[3];
519 // define limits around ExB for which x contribution is negligible
520 const Float_t kAroundZero = 3.5e-2; //(+- 2 deg)
522 TObjArray *arr0 = (TObjArray*)fContainer->At(kCenter);
523 TObjArray *arr1 = (TObjArray*)fContainer->At(kSigm);
524 TObjArray *arr2 = (TObjArray*)fContainer->At(kMean);
526 const AliTRDclusterInfo *cli = NULL;
527 TIterator *iter=fInfo->MakeIterator();
528 while((cli=dynamic_cast<AliTRDclusterInfo*>((*iter)()))){
529 cli->GetCluster(det, x, y, z, q, t, covcl);
531 // select cluster according to detector region if specified
532 if(fDet>=0 && fDet!=det) continue;
533 if(fCol>=0 && fRow>=0){
535 cli->GetCenterPad(c, r);
536 if(TMath::Abs(fCol-c) > 5) continue;
537 if(TMath::Abs(fRow-r) > 2) continue;
539 dy = cli->GetResolution();
540 AliDebug(4, Form("det[%d] tb[%2d] q[%4.0f Log[%6.4f]] dy[%7.2f][um] ypull[%5.2f]", det, t, q, TMath::Log(q), 1.e4*dy, dy/TMath::Sqrt(covcl[0])));
542 cli->GetGlobalPosition(y, z, dydx, dzdx, &cov[0]);
543 Float_t tilt(cli->GetTilt());
545 // resolution as a function of cluster charge
546 // only for phi equal exB
547 if(TMath::Abs(dydx-fExB-tilt*dzdx) < kAroundZero){
548 h3 = (TH3S*)fContainer->At(kQRes);
549 h3->Fill(TMath::Log(q), dy, dy/TMath::Sqrt(covcl[0]));
552 // do not use problematic clusters in resolution analysis
553 // TODO define limits as calibration aware (gain) !!
554 if(q<20.*fGain || q>250.*fGain) continue;
556 //x = (t+.5)*fgkTimeBinLength; // conservative approach !!
558 // resolution as a function of y displacement from pad center
559 // only for phi equal exB
560 if(TMath::Abs(dydx-fExB-tilt*dzdx) < kAroundZero){
561 h3 = (TH3S*)arr0->At(0);
562 h3->Fill(t, cli->GetYDisplacement(), dy);
563 h3 = (TH3S*)arr0->At(1);
564 h3->Fill(t, cli->GetYDisplacement(), dy/TMath::Sqrt(covcl[0]));
567 Int_t it(((TH3S*)arr0->At(0))->GetXaxis()->FindBin(t));
569 // fill histo for resolution (sigma)
570 ((TH3S*)arr1->At(it-1))->Fill(tilt*dzdx, dydx, dy);
572 // fill histo for systematic (mean)
573 ((TH3S*)arr2->At(it-1))->Fill(10.*cli->GetAnisochronity(), tilt*dzdx-fExB, dy);
578 //_______________________________________________________
579 Bool_t AliTRDclusterResolution::PostProcess()
581 // Steer processing of various cluster resolution dependences :
583 // - process resolution dependency cluster charge
584 // if(HasProcess(kQRes)) ProcessCharge();
585 // - process resolution dependency on y displacement
586 // if(HasProcess(kCenter)) ProcessCenterPad();
587 // - process resolution dependency on drift legth and drift cell width
588 // if(HasProcess(kSigm)) ProcessSigma();
589 // - process systematic shift on drift legth and drift cell width
590 // if(HasProcess(kMean)) ProcessMean();
592 if(!fContainer) return kFALSE;
594 AliWarning("Not calibrated.");
597 TObjArray *arr = NULL;
600 TGraphErrors *g = NULL;
601 fResults = new TObjArray(kNtasks);
602 fResults->SetOwner();
603 fResults->AddAt(arr = new TObjArray(3), kQRes);
605 arr->AddAt(g = new TGraphErrors(), 0);
606 g->SetLineColor(kBlue); g->SetMarkerColor(kBlue);
607 g->SetMarkerStyle(7);
608 arr->AddAt(g = new TGraphErrors(), 1);
609 g->SetLineColor(kRed); g->SetMarkerColor(kRed);
610 g->SetMarkerStyle(23);
611 arr->AddAt(g = new TGraphErrors(), 2);
612 g->SetLineColor(kGreen); g->SetMarkerColor(kGreen);
613 g->SetMarkerStyle(7);
615 // pad center dependence
616 fResults->AddAt(arr = new TObjArray(AliTRDgeometry::kNlayer+1), kCenter);
619 t = new TTree("cent", "dy=f(y,x,ly)"), 0);
620 t->Branch("ly", &fLy, "ly/B");
621 t->Branch("t", &fT, "t/F");
622 t->Branch("y", &fY, "y/F");
623 t->Branch("m", &fR[0], "m[2]/F");
624 t->Branch("s", &fR[2], "s[2]/F");
625 t->Branch("pm", &fP[0], "pm[2]/F");
626 t->Branch("ps", &fP[2], "ps[2]/F");
627 for(Int_t il=1; il<=AliTRDgeometry::kNlayer; il++){
628 arr->AddAt(g = new TGraphErrors(), il);
629 g->SetLineColor(il); g->SetLineStyle(il);
630 g->SetMarkerColor(il);g->SetMarkerStyle(4);
634 fResults->AddAt(t = new TTree("sigm", "dy=f(dw,x,dydx)"), kSigm);
635 t->Branch("t", &fT, "t/F");
636 t->Branch("x", &fX, "x/F");
637 t->Branch("z", &fZ, "z/F");
638 t->Branch("sx", &fR[0], "sx[2]/F");
639 t->Branch("sy", &fR[2], "sy[2]/F");
642 fResults->AddAt(t = new TTree("mean", "dy=f(dw,x,dydx - h dzdx)"), kMean);
643 t->Branch("t", &fT, "t/F");
644 t->Branch("x", &fX, "x/F");
645 t->Branch("z", &fZ, "z/F");
646 t->Branch("dx", &fR[0], "dx[2]/F");
647 t->Branch("dy", &fR[2], "dy[2]/F");
650 TIterator *iter=fResults->MakeIterator();
651 while((o=((*iter)()))) o->Clear(); // maybe it is wrong but we should never reach this point
654 // process resolution dependency on charge
655 if(HasProcess(kQRes)) ProcessCharge();
657 // process resolution dependency on y displacement
658 if(HasProcess(kCenter)) ProcessCenterPad();
660 // process resolution dependency on drift legth and drift cell width
661 if(HasProcess(kSigm)) ProcessSigma();
663 // process systematic shift on drift legth and drift cell width
664 if(HasProcess(kMean)) ProcessMean();
669 //_______________________________________________________
670 Bool_t AliTRDclusterResolution::LoadCalibration()
672 // Retrieve calibration parameters from OCDB, drift velocity and t0 for the detector region specified by
673 // a previous call to AliTRDclusterResolution::SetCalibrationRegion().
675 AliCDBManager *cdb = AliCDBManager::Instance(); // check access OCDB
676 if(cdb->GetRun() < 0){
677 AliError("OCDB manager not properly initialized");
680 // check magnetic field
681 if(!TGeoGlobalMagField::Instance() || !TGeoGlobalMagField::Instance()->IsLocked()){
682 AliError("Magnetic field not available.");
686 // check pad for detector
687 if(fCol>=0 && fRow>=0){
689 AliTRDpadPlane *pp(geo.GetPadPlane(fDet));
690 if(fCol>=pp->GetNcols() ||
691 fRow>=pp->GetNrows()){
692 AliWarning(Form("Pad coordinates col[%d] or row[%d] incorrect for det[%d].\nLimits are max col[%d] max row[%d]. Reset to default", fCol, fRow, fDet, pp->GetNcols(), pp->GetNrows()));
697 AliTRDcalibDB *fCalibration = AliTRDcalibDB::Instance();
698 AliTRDCalROC *fCalVdriftROC(fCalibration->GetVdriftROC(fDet>=0?fDet:0))
699 ,*fCalT0ROC(fCalibration->GetT0ROC(fDet>=0?fDet:0));
700 const AliTRDCalDet *fCalVdriftDet = fCalibration->GetVdriftDet();
701 const AliTRDCalDet *fCalT0Det = fCalibration->GetT0Det();
703 if(IsUsingCalibParam(kVdrift)){
704 fVdrift = fCalVdriftDet->GetValue(fDet>=0?fDet:0);
705 if(fCol>=0 && fRow>=0) fVdrift*= fCalVdriftROC->GetValue(fCol, fRow);
707 fExB = AliTRDCommonParam::Instance()->GetOmegaTau(fVdrift);
708 if(IsUsingCalibParam(kT0)){
709 fT0 = fCalT0Det->GetValue(fDet>=0?fDet:0);
710 if(fCol>=0 && fRow>=0) fT0 *= fCalT0ROC->GetValue(fCol, fRow);
712 if(IsUsingCalibParam(kGain)) fGain = (fCol>=0 && fRow>=0)?fCalibration-> GetGainFactor(fDet, fCol, fRow):fCalibration-> GetGainFactorAverage(fDet);
716 AliInfo(Form("Calibrate for Det[%3d] Col[%3d] Row[%2d] : \n t0[%5.3f] vd[%5.3f] gain[%5.3f] ExB[%f]", fDet, fCol, fRow, fT0, fVdrift, fGain, fExB));
721 //_______________________________________________________
722 void AliTRDclusterResolution::SetCalibrationRegion(Int_t det, Int_t col, Int_t row)
724 // Set calibration region in terms of detector and pad.
725 // By default detector 0 mean values are considered.
727 if(det>=0 && det<AliTRDgeometry::kNdet){
729 if(col>=0 && row>=0){
735 AliError(Form("Detector index outside range [0 %d].", AliTRDgeometry::kNdet));
738 //_______________________________________________________
739 void AliTRDclusterResolution::SetVisual()
742 fCanvas = new TCanvas("clResCanvas", "Cluster Resolution Visualization", 10, 10, 600, 600);
745 //_______________________________________________________
746 void AliTRDclusterResolution::ProcessCharge()
748 // Resolution as a function of cluster charge.
750 // As described in the function ProcessCenterPad() the error parameterization for clusters for phi = a_L can be
753 // #sigma_{y}^{2} = #sigma_{y}^{2}|_{B=0} + tg^{2}(#alpha_{L})*#sigma_{x}^{2}
755 // with the contribution in case of B=0 given by:
757 // #sigma_{y}|_{B=0} = #sigma_{diff}*Gauss(0, s_{ly}) + #delta_{#sigma}(q)
759 // which further can be simplified to:
761 // <#sigma_{y}|_{B=0}>(q) = <#sigma_{y}> + #delta_{#sigma}(q)
762 // <#sigma_{y}> = #int{f(q)#sigma_{y}dq}
764 // The results for s_y and f(q) are displayed below:
766 //<img src="TRD/clusterQerror.gif">
768 // The function has to extended to accomodate gain calibration scalling and errors.
771 // Alexandru Bercuci <A.Bercuci@gsi.de>
774 if(!(h3 = (TH3S*)fContainer->At(kQRes))) {
775 AliWarning("Missing dy=f(Q) histo");
778 TF1 f("f", "gaus", -.5, .5);
782 // compute mean error on x
784 for(Int_t ix=5; ix<AliTRDseedV1::kNtb; ix++){
785 // retrieve error on the drift length
786 s2x += AliTRDcluster::GetSX(ix);
788 s2x /= (AliTRDseedV1::kNtb-5); s2x *= s2x;
789 //Double_t exb2 = fExB*fExB;
791 TObjArray *arr = (TObjArray*)fResults->At(kQRes);
792 TGraphErrors *gqm = (TGraphErrors*)arr->At(0);
793 TGraphErrors *gqs = (TGraphErrors*)arr->At(1);
794 TGraphErrors *gqp = (TGraphErrors*)arr->At(2);
795 Double_t q, n = 0., entries;
797 for(Int_t ix=1; ix<=ax->GetNbins(); ix++){
798 q = TMath::Exp(ax->GetBinCenter(ix));
799 ax->SetRange(ix, ix);
800 h1 = h3->Project3D("y");
801 entries = h1->GetEntries();
802 if(entries < 150) continue;
806 Int_t ip = gqm->GetN();
807 gqm->SetPoint(ip, q, 1.e4*f.GetParameter(1));
808 gqm->SetPointError(ip, 0., 1.e4*f.GetParError(1));
810 // correct sigma for ExB effect
811 gqs->SetPoint(ip, q, 1.e4*f.GetParameter(2)/**f.GetParameter(2)-exb2*s2x)*/);
812 gqs->SetPointError(ip, 0., 1.e4*f.GetParError(2)/**f.GetParameter(2)*/);
816 gqp->SetPoint(ip, q, entries);
817 gqp->SetPointError(ip, 0., 0./*TMath::Sqrt(entries)*/);
820 // normalize probability and get mean sy
821 Double_t sm = 0., sy;
822 for(Int_t ip=gqp->GetN(); ip--;){
823 gqp->GetPoint(ip, q, entries);
825 gqp->SetPoint(ip, q, 1.e4*entries);
826 gqs->GetPoint(ip, q, sy);
830 // error parametrization s(q) = <sy> + b(1/q-1/q0)
831 TF1 fq("fq", "[0] + [1]/x", 20., 250.);
832 gqs->Fit(&fq/*, "W"*/);
833 printf("sm=%f [0]=%f [1]=%f\n", 1.e-4*sm, fq.GetParameter(0), fq.GetParameter(1));
834 printf(" const Float_t sq0inv = %f; // [1/q0]\n", (sm-fq.GetParameter(0))/fq.GetParameter(1));
835 printf(" const Float_t sqb = %f; // [cm]\n", 1.e-4*fq.GetParameter(1));
838 //_______________________________________________________
839 void AliTRDclusterResolution::ProcessCenterPad()
841 // Resolution as a function of y displacement from pad center and drift length.
843 // Since the error parameterization of cluster r-phi position can be written as (see AliTRDcluster::SetSigmaY2()):
845 // #sigma_{y}^{2} = (#sigma_{diff}*Gauss(0, s_{ly}) + #delta_{#sigma}(q))^{2} + tg^{2}(#alpha_{L})*#sigma_{x}^{2} + tg^{2}(#phi-#alpha_{L})*#sigma_{x}^{2}+[tg(#phi-#alpha_{L})*tg(#alpha_{L})*x]^{2}/12
847 // one can see that for phi = a_L one gets the following expression:
849 // #sigma_{y}^{2} = #sigma_{y}^{2}|_{B=0} + tg^{2}(#alpha_{L})*#sigma_{x}^{2}
851 // where we have explicitely marked the remaining term in case of absence of magnetic field. Thus one can use the
852 // previous equation to estimate s_y for B=0 and than by comparing in magnetic field conditions one can get the s_x.
853 // This is a simplified method to determine the error parameterization for s_x and s_y as compared to the one
854 // implemented in ProcessSigma(). For more details on cluster error parameterization please see also
855 // AliTRDcluster::SetSigmaY2()
857 // The representation of dy=f(y_cen, x_drift| layer) can be also used to estimate the systematic shift in the r-phi
858 // coordinate resulting from imperfection in the cluster shape parameterization. From the expresion of the shift derived
859 // in ProcessMean() with phi=exb one gets:
861 // <#Delta y>= <#delta x> * (tg(#alpha_{L})-h*dz/dx) + <#delta y - #delta x * tg(#alpha_{L})>
862 // <#Delta y>(y_{cen})= -h*<#delta x>(x_{drift}, q_{cl}) * dz/dx + #delta y(y_{cen}, ...)
864 // where all dependences are made explicit. This last expression can be used in two ways:
865 // - by average on the dz/dx we can determine directly dy (the method implemented here)
866 // - by plotting as a function of dzdx one can determine both dx and dy components in an independent method.
868 //<img src="TRD/clusterYcorr.gif">
871 // Alexandru Bercuci <A.Bercuci@gsi.de>
873 TObjArray *arr = (TObjArray*)fContainer->At(kCenter);
875 AliWarning("Missing dy=f(y | x, ly) container");
878 Double_t exb2 = fExB*fExB;
879 Float_t s[AliTRDgeometry::kNlayer];
880 TF1 f("f", "gaus", -.5, .5);
881 TF1 fp("fp", "gaus", -3.5, 3.5);
883 TH1D *h1 = NULL; TH2F *h2 = NULL; TH3S *h3r=NULL, *h3p=NULL;
884 TObjArray *arrRes = (TObjArray*)fResults->At(kCenter);
885 TTree *t = (TTree*)arrRes->At(0);
886 TGraphErrors *gs = NULL;
889 AliDebug(1, Form("Calibrate for Det[%3d] t0[%5.3f] vd[%5.3f]", fDet, fT0, fVdrift));
891 const Int_t nl = AliTRDgeometry::kNlayer;
892 printf(" const Float_t lSy[%d][%d] = {\n {", nl, AliTRDseedV1::kNtb);
893 for(Int_t il=0; il<nl; il++){
894 if(!(h3r = (TH3S*)arr->At(il))) continue;
895 if(!(h3p = (TH3S*)arr->At(nl+il))) continue;
896 gs = (TGraphErrors*)arrRes->At(il+1);
898 for(Int_t ix=1; ix<=h3r->GetXaxis()->GetNbins(); ix++){
899 ax = h3r->GetXaxis(); ax->SetRange(ix, ix);
900 ax = h3p->GetXaxis(); ax->SetRange(ix, ix);
901 fT = ax->GetBinCenter(ix);
902 for(Int_t iy=1; iy<=h3r->GetYaxis()->GetNbins(); iy++){
903 ax = h3r->GetYaxis(); ax->SetRange(iy, iy);
904 ax = h3p->GetYaxis(); ax->SetRange(iy, iy);
905 fY = ax->GetBinCenter(iy);
906 // finish navigation in the HnSparse
908 h1 = (TH1D*)h3r->Project3D("z");
909 Int_t entries = (Int_t)h1->Integral();
910 if(entries < 50) continue;
914 // Fill sy,my=f(y_w,x,ly)
915 fR[0] = f.GetParameter(1); fR[1] = f.GetParError(1);
916 fR[2] = f.GetParameter(2); fR[3] = f.GetParError(2);
918 h1 = (TH1D*)h3p->Project3D("z");
920 fP[0] = fp.GetParameter(1); fP[1] = fp.GetParError(1);
921 fP[2] = fp.GetParameter(2); fP[3] = fp.GetParError(2);
923 AliDebug(4, Form("ly[%d] tb[%2d] y[%+5.2f] m[%5.3f] s[%5.3f] pm[%5.3f] ps[%5.3f]", fLy, (Int_t)fT, fY, fR[0], fR[2], fP[0], fP[2]));
927 t->Draw(Form("y:t>>h(%d, -0.5, %f, 51, -.51, .51)", AliTRDseedV1::kNtb, AliTRDseedV1::kNtb-0.5),
928 Form("s[0]*(ly==%d&&abs(m[0])<1.e-1)", fLy),
930 h2=(TH2F*)gROOT->FindObject("h");
931 f.FixParameter(1, 0.);
932 Int_t n = h2->GetXaxis()->GetNbins(), nn(0); s[il]=0.;
934 for(Int_t ix=1; ix<=n; ix++){
936 fT = ax->GetBinCenter(ix);
937 h1 = h2->ProjectionY("hCenPy", ix, ix);
938 //if((Int_t)h1->Integral() < 1.e-10) continue;
940 // Apply lorentz angle correction
941 // retrieve error on the drift length
942 Double_t s2x = AliTRDcluster::GetSX(ix-1); s2x *= s2x;
944 for(Int_t iy=1; iy<=h1->GetNbinsX(); iy++){
945 Double_t s2 = h1->GetBinContent(iy); s2*= s2;
946 // sigma square corrected for Lorentz angle
947 // s2 = s2_y(y_w,x)+exb2*s2_x
948 Double_t sy = TMath::Sqrt(TMath::Max(s2 - exb2*s2x, Double_t(0.)));
949 if(sy<1.e-20) continue;
950 h1->SetBinContent(iy, sy); nnn++;
951 AliDebug(4, Form("s[%6.2f] sx[%6.2f] sy[%6.2f]\n",
952 1.e4*TMath::Sqrt(s2), 1.e4*TMath::Abs(fExB*AliTRDcluster::GetSX(ix-1)),
953 1.e4*h1->GetBinContent(iy)));
955 // do fit only if enough data
959 sPRF = f.GetParameter(2); nn++;
962 printf("%6.4f,%s", sPRF, ix%6?" ":"\n ");
963 Int_t jx = gs->GetN();
964 gs->SetPoint(jx, fT, 1.e4*sPRF);
965 gs->SetPointError(jx, 0., 0./*f.GetParError(0)*/);
970 f.ReleaseParameter(1);
973 if(!fCanvas) continue;
975 fCanvas->Modified(); fCanvas->Update();
976 if(IsSaveAs()) fCanvas->SaveAs(Form("Figures/ProcessCenter_ly[%d].gif", fLy));
977 else gSystem->Sleep(100);
980 printf(" const Float_t lPRF[] = {"
981 "%5.3f, %5.3f, %5.3f, %5.3f, %5.3f, %5.3f};\n",
982 s[0], s[1], s[2], s[3], s[4], s[5]);
985 //_______________________________________________________
986 void AliTRDclusterResolution::ProcessSigma()
988 // As the r-phi coordinate is the only one which is measured by the TRD detector we have to rely on it to
989 // estimate both the radial (x) and r-phi (y) errors. This method is based on the following assumptions.
990 // The measured error in the y direction is the sum of the intrinsic contribution of the r-phi measurement
991 // with the contribution of the radial measurement - because x is not a parameter of Alice track model (Kalman).
993 // #sigma^{2}|_{y} = #sigma^{2}_{y*} + #sigma^{2}_{x*}
995 // In the general case
997 // #sigma^{2}_{y*} = #sigma^{2}_{y} + tg^{2}(#alpha_{L})#sigma^{2}_{x_{drift}}
998 // #sigma^{2}_{x*} = tg^{2}(#phi - #alpha_{L})*(#sigma^{2}_{x_{drift}} + #sigma^{2}_{x_{0}} + tg^{2}(#alpha_{L})*x^{2}/12)
1000 // where we have explicitely show the lorentz angle correction on y and the projection of radial component on the y
1001 // direction through the track angle in the bending plane (phi). Also we have shown that the radial component in the
1002 // last equation has twp terms, the drift and the misalignment (x_0). For ideal geometry or known misalignment one
1003 // can solve the equation
1005 // #sigma^{2}|_{y} = tg^{2}(#phi - #alpha_{L})*(#sigma^{2}_{x} + tg^{2}(#alpha_{L})*x^{2}/12)+ [#sigma^{2}_{y} + tg^{2}(#alpha_{L})#sigma^{2}_{x}]
1007 // by fitting a straight line:
1009 // #sigma^{2}|_{y} = a(x_{cl}, z_{cl}) * tg^{2}(#phi - #alpha_{L}) + b(x_{cl}, z_{cl})
1011 // the error parameterization will be given by:
1013 // #sigma_{x} (x_{cl}, z_{cl}) = #sqrt{a(x_{cl}, z_{cl}) - tg^{2}(#alpha_{L})*x^{2}/12}
1014 // #sigma_{y} (x_{cl}, z_{cl}) = #sqrt{b(x_{cl}, z_{cl}) - #sigma^{2}_{x} (x_{cl}, z_{cl}) * tg^{2}(#alpha_{L})}
1016 // Below there is an example of such dependency.
1018 //<img src="TRD/clusterSigmaMethod.gif">
1021 // The error parameterization obtained by this method are implemented in the functions AliTRDcluster::GetSX() and
1022 // AliTRDcluster::GetSYdrift(). For an independent method to determine s_y as a function of drift length check the
1023 // function ProcessCenterPad(). One has to keep in mind that while this method return the mean s_y over the distance
1024 // to pad center distribution the other method returns the *STANDARD* value at center=0 (maximum). To recover the
1025 // standard value one has to solve the obvious equation:
1027 // #sigma_{y}^{STANDARD} = #frac{<#sigma_{y}>}{#int{s exp(s^{2}/#sigma) ds}}
1029 // with "<s_y>" being the value calculated here and "sigma" the width of the s_y distribution calculated in
1030 // ProcessCenterPad().
1033 // Alexandru Bercuci <A.Bercuci@gsi.de>
1035 TObjArray *arr = (TObjArray*)fContainer->At(kSigm);
1037 AliWarning("Missing dy=f(x_d, d_w) container");
1041 // init visualization
1042 TGraphErrors *ggs = NULL;
1043 TGraph *line = NULL;
1045 ggs = new TGraphErrors();
1046 line = new TGraph();
1047 line->SetLineColor(kRed);line->SetLineWidth(2);
1050 // init logistic support
1051 TF1 f("f", "gaus", -.5, .5);
1052 TLinearFitter gs(1,"pol1");
1054 TH1D *h1 = NULL; TH3S *h3=NULL;
1056 Double_t exb2 = fExB*fExB;
1058 TTree *t = (TTree*)fResults->At(kSigm);
1059 for(Int_t ix=0; ix<AliTRDseedV1::kNtb; ix++){
1060 if(!(h3=(TH3S*)arr->At(ix))) continue;
1062 fX = c.GetXloc(fT0, fVdrift);
1063 fT = c.GetLocalTimeBin(); // ideal
1064 printf(" pad time[%d] local[%f]\n", ix, fT);
1065 for(Int_t iz=1; iz<=h3->GetXaxis()->GetNbins(); iz++){
1066 ax = h3->GetXaxis();
1067 ax->SetRange(iz, iz);
1068 fZ = ax->GetBinCenter(iz);
1070 // reset visualization
1072 new(ggs) TGraphErrors();
1073 ggs->SetMarkerStyle(7);
1077 for(Int_t ip=1; ip<=h3->GetYaxis()->GetNbins(); ip++){
1078 ax = h3->GetYaxis();
1079 ax->SetRange(ip, ip);
1080 Double_t tgl = ax->GetBinCenter(ip);
1081 // finish navigation in the HnSparse
1083 //if(TMath::Abs(dydx)>0.18) continue;
1084 Double_t tgg = (tgl-fExB)/(1.+tgl*fExB);
1085 Double_t tgg2 = tgg*tgg;
1087 h1 = (TH1D*)h3->Project3D("z");
1088 Int_t entries = (Int_t)h1->Integral();
1089 if(entries < 50) continue;
1093 Double_t s2 = f.GetParameter(2)*f.GetParameter(2);
1094 Double_t s2e = 2.*f.GetParameter(2)*f.GetParError(2);
1095 // Fill sy^2 = f(tg^2(phi-a_L))
1096 gs.AddPoint(&tgg2, s2, s2e);
1099 Int_t jp = ggs->GetN();
1100 ggs->SetPoint(jp, tgg2, s2);
1101 ggs->SetPointError(jp, 0., s2e);
1103 // TODO here a more robust fit method has to be provided
1104 // for which lower boundaries on the parameters have to
1105 // be imposed. Unfortunately the Minuit fit does not work
1106 // for the TGraph in the case of B not 0.
1107 if(gs.Eval()) continue;
1109 fR[0] = gs.GetParameter(1) - fX*fX*exb2/12.;
1110 AliDebug(3, Form(" s2x+x2=%f ang=%f s2x=%f", gs.GetParameter(1), fX*fX*exb2/12., fR[0]));
1111 fR[0] = TMath::Max(fR[0], Float_t(4.e-4));
1113 // s^2_y = s0^2_y + tg^2(a_L) * s^2_x
1114 // s0^2_y = f(D_L)*x + s_PRF^2
1115 fR[2]= gs.GetParameter(0)-exb2*fR[0];
1116 AliDebug(3, Form(" s2y+s2x=%f s2y=%f", fR[0], fR[2]));
1117 fR[2] = TMath::Max(fR[2], Float_t(2.5e-5));
1118 fR[0] = TMath::Sqrt(fR[0]);
1119 fR[1] = .5*gs.GetParError(1)/fR[0];
1120 fR[2] = TMath::Sqrt(fR[2]);
1121 fR[3] = gs.GetParError(0)+exb2*exb2*gs.GetParError(1);
1123 AliDebug(2, Form("xd=%4.2f[cm] sx=%6.1f[um] sy=%5.1f[um]", fX, 1.e4*fR[0], 1.e4*fR[2]));
1125 if(!fCanvas) continue;
1126 fCanvas->cd(); fCanvas->SetLogx(); //fCanvas->SetLogy();
1128 fCanvas->SetMargin(0.15, 0.01, 0.1, 0.01);
1129 hFrame=new TH1I("hFrame", "", 100, 0., .3);
1130 hFrame->SetMinimum(0.);hFrame->SetMaximum(.005);
1131 hFrame->SetXTitle("tg^{2}(#phi-#alpha_{L})");
1132 hFrame->SetYTitle("#sigma^{2}y[cm^{2}]");
1133 hFrame->GetYaxis()->SetTitleOffset(2.);
1134 hFrame->SetLineColor(1);hFrame->SetLineWidth(1);
1136 } else hFrame->Reset();
1137 Double_t xx = 0., dxx=.2/50;
1138 for(Int_t ip=0;ip<50;ip++){
1139 line->SetPoint(ip, xx, gs.GetParameter(0)+xx*gs.GetParameter(1));
1142 ggs->Draw("pl"); line->Draw("l");
1143 fCanvas->Modified(); fCanvas->Update();
1144 if(IsSaveAs()) fCanvas->SaveAs(Form("Figures/ProcessSigma_z[%5.3f]_x[%5.3f].gif", fZ, fX));
1145 else gSystem->Sleep(100);
1151 //_______________________________________________________
1152 void AliTRDclusterResolution::ProcessMean()
1154 // By this method the cluster shift in r-phi and radial directions can be estimated by comparing with the MC.
1155 // The resolution of the cluster corrected for pad tilt with respect to MC in the r-phi (measuring) plane can be
1158 // #Delta y=w - y_{MC}(x_{cl})
1159 // w = y_{cl}^{'} + h*(z_{MC}(x_{cl})-z_{cl})
1160 // y_{MC}(x_{cl}) = y_{0} - dy/dx*x_{cl}
1161 // z_{MC}(x_{cl}) = z_{0} - dz/dx*x_{cl}
1162 // y_{cl}^{'} = y_{cl}-x_{cl}*tg(#alpha_{L})
1164 // where x_cl is the drift length attached to a cluster, y_cl is the r-phi coordinate of the cluster measured by
1165 // charge sharing on adjacent pads and y_0 and z_0 are MC reference points (as example the track references at
1166 // entrance/exit of a chamber). If we suppose that both r-phi (y) and radial (x) coordinate of the clusters are
1167 // affected by errors we can write
1169 // x_{cl} = x_{cl}^{*} + #delta x
1170 // y_{cl} = y_{cl}^{*} + #delta y
1172 // where the starred components are the corrected values. Thus by definition the following quantity
1174 // #Delta y^{*}= w^{*} - y_{MC}(x_{cl}^{*})
1176 // has 0 average over all dependency. Using this decomposition we can write:
1178 // <#Delta y>=<#Delta y^{*}> + <#delta x * (dy/dx-h*dz/dx) + #delta y - #delta x * tg(#alpha_{L})>
1180 // which can be transformed to the following linear dependence:
1182 // <#Delta y>= <#delta x> * (dy/dx-h*dz/dx) + <#delta y - #delta x * tg(#alpha_{L})>
1184 // if expressed as function of dy/dx-h*dz/dx. Furtheremore this expression can be plotted for various clusters
1185 // i.e. we can explicitely introduce the diffusion (x_cl) and drift cell - anisochronity (z_cl) dependences. From
1186 // plotting this dependence and linear fitting it with:
1188 // <#Delta y>= a(x_{cl}, z_{cl}) * (dy/dx-h*dz/dx) + b(x_{cl}, z_{cl})
1190 // the systematic shifts will be given by:
1192 // #delta x (x_{cl}, z_{cl}) = a(x_{cl}, z_{cl})
1193 // #delta y (x_{cl}, z_{cl}) = b(x_{cl}, z_{cl}) + a(x_{cl}, z_{cl}) * tg(#alpha_{L})
1195 // Below there is an example of such dependency.
1197 //<img src="TRD/clusterShiftMethod.gif">
1200 // The occurance of the radial shift is due to the following conditions
1201 // - the approximation of a constant drift velocity over the drift length (larger drift velocities close to
1202 // cathode wire plane)
1203 // - the superposition of charge tails in the amplification region (first clusters appear to be located at the
1205 // - the superposition of charge tails in the drift region (shift towards anode wire)
1206 // - diffusion effects which convolute with the TRF thus enlarging it
1207 // - approximate knowledge of the TRF (approximate measuring in test beam conditions)
1209 // The occurance of the r-phi shift is due to the following conditions
1210 // - approximate model for cluster shape (LUT)
1211 // - rounding-up problems
1213 // The numerical results for ideal simulations for the radial and r-phi shifts are displayed below and used
1214 // for the cluster reconstruction (see the functions AliTRDcluster::GetXcorr() and AliTRDcluster::GetYcorr()).
1216 //<img src="TRD/clusterShiftX.gif">
1217 //<img src="TRD/clusterShiftY.gif">
1219 // More details can be found in the presentation given during the TRD
1220 // software meeting at the end of 2008 and beginning of year 2009, published on indico.cern.ch.
1223 // Alexandru Bercuci <A.Bercuci@gsi.de>
1227 TObjArray *arr = (TObjArray*)fContainer->At(kMean);
1229 AliWarning("Missing dy=f(x_d, d_w) container");
1233 // init logistic support
1234 TF1 f("f", "gaus", -.5, .5);
1235 TF1 line("l", "[0]+[1]*x", -.15, .15);
1236 TGraphErrors *gm = new TGraphErrors();
1238 TH1D *h1 = NULL; TH3S *h3 =NULL;
1241 AliDebug(1, Form("Calibrate for Det[%3d] t0[%5.3f] vd[%5.3f]", fDet, fT0, fVdrift));
1244 TTree *t = (TTree*)fResults->At(kMean);
1245 for(Int_t ix=0; ix<AliTRDseedV1::kNtb; ix++){
1246 if(!(h3=(TH3S*)arr->At(ix))) continue;
1248 fX = c.GetXloc(fT0, fVdrift);
1249 fT = c.GetLocalTimeBin();
1250 for(Int_t iz=1; iz<=h3->GetXaxis()->GetNbins(); iz++){
1251 ax = h3->GetXaxis();
1252 ax->SetRange(iz, iz);
1253 fZ = ax->GetBinCenter(iz);
1256 new(gm) TGraphErrors();
1257 gm->SetMarkerStyle(7);
1259 for(Int_t ip=1; ip<=h3->GetYaxis()->GetNbins(); ip++){
1260 ax = h3->GetYaxis();
1261 ax->SetRange(ip, ip);
1262 Double_t tgl = ax->GetBinCenter(ip);
1263 // finish navigation in the HnSparse
1265 h1 = (TH1D*)h3->Project3D("z");
1266 Int_t entries = (Int_t)h1->Integral();
1267 if(entries < 50) continue;
1271 // Fill <Dy> = f(dydx - h*dzdx)
1272 Int_t jp = gm->GetN();
1273 gm->SetPoint(jp, tgl, f.GetParameter(1));
1274 gm->SetPointError(jp, 0., f.GetParError(1));
1276 if(gm->GetN()<10) continue;
1278 gm->Fit(&line, "QN");
1279 fR[0] = line.GetParameter(1); // dx
1280 fR[1] = line.GetParError(1);
1281 fR[2] = line.GetParameter(0) + fExB*fR[0]; // xs = dy - tg(a_L)*dx
1283 AliDebug(2, Form("tb[%02d] xd=%4.2f[cm] dx=%6.2f[um] dy=%6.2f[um]", ix, fX, 1.e4*fR[0], 1.e4*fR[2]));
1284 if(!fCanvas) continue;
1288 fCanvas->SetMargin(0.1, 0.02, 0.1, 0.01);
1289 hFrame=new TH1I("hFrame", "", 100, -.3, .3);
1290 hFrame->SetMinimum(-.1);hFrame->SetMaximum(.1);
1291 hFrame->SetXTitle("tg#phi-htg#theta");
1292 hFrame->SetYTitle("#Delta y[cm]");
1293 hFrame->GetYaxis()->SetTitleOffset(1.5);
1294 hFrame->SetLineColor(1);hFrame->SetLineWidth(1);
1296 } else hFrame->Reset();
1297 gm->Draw("pl"); line.Draw("same");
1298 fCanvas->Modified(); fCanvas->Update();
1299 if(IsSaveAs()) fCanvas->SaveAs(Form("Figures/ProcessMean_Z[%5.3f]_TB[%02d].gif", fZ, ix));
1300 else gSystem->Sleep(100);