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 "AliTRDtrackInfo/AliTRDclusterInfo.h"
172 #include "AliTRDgeometry.h"
173 #include "AliTRDcalibDB.h"
174 #include "AliTRDCommonParam.h"
175 #include "Cal/AliTRDCalROC.h"
176 #include "Cal/AliTRDCalDet.h"
179 #include "AliTracker.h"
180 #include "AliCDBManager.h"
183 #include "TObjArray.h"
186 #include "TGraphErrors.h"
190 #include "TLinearFitter.h"
196 ClassImp(AliTRDclusterResolution)
198 const Float_t AliTRDclusterResolution::fgkTimeBinLength = 1./ AliTRDCommonParam::Instance()->GetSamplingFrequency();
199 //_______________________________________________________
200 AliTRDclusterResolution::AliTRDclusterResolution(const char *name)
201 : AliTRDrecoTask(name, "Cluster Error Parametrization")
213 fAt = new TAxis(kNTB, 0., kNTB*fgkTimeBinLength);
214 // z axis spans the drift cell 2.5 mm
215 fAd = new TAxis(kND, 0., .25);
217 // By default register all analysis
218 // The user can switch them off in his steering macro
225 //_______________________________________________________
226 AliTRDclusterResolution::~AliTRDclusterResolution()
228 if(fCanvas) delete fCanvas;
237 //_______________________________________________________
238 void AliTRDclusterResolution::ConnectInputData(Option_t *)
240 fInfo = dynamic_cast<TObjArray *>(GetInputData(0));
243 //_______________________________________________________
244 void AliTRDclusterResolution::CreateOutputObjects()
246 OpenFile(0, "RECREATE");
247 fContainer = Histos();
250 //_______________________________________________________
251 Bool_t AliTRDclusterResolution::GetRefFigure(Int_t ifig)
253 if(!fResults) return kFALSE;
256 TObjArray *arr = 0x0;
258 TGraphErrors *gm(0x0), *gs(0x0), *gp(0x0);
261 if(!(arr = (TObjArray*)fResults->At(kQRes))) break;
262 if(!(gm = (TGraphErrors*)arr->At(0))) break;
263 if(!(gs = (TGraphErrors*)arr->At(1))) break;
264 if(!(gp = (TGraphErrors*)arr->At(2))) break;
266 gs->GetHistogram()->GetYaxis()->SetRangeUser(-.01, .6);
267 gs->GetHistogram()->SetXTitle("Q [a.u.]");
268 gs->GetHistogram()->SetYTitle("#sigma_{y} / #mu_{y} [mm] / freq");
273 if(!(arr = (TObjArray*)fResults->At(kCenter))) break;
274 gPad->Divide(3, 1); l = gPad->GetListOfPrimitives();
275 for(Int_t ipad = 3; ipad--;){
276 if(!(h2 = (TH2F*)arr->At(ipad))) return kFALSE;
277 ((TVirtualPad*)l->At(ipad))->cd();
282 if(!(arr = (TObjArray*)fResults->At(kSigm))) break;
283 gPad->Divide(2, 1); l = gPad->GetListOfPrimitives();
284 for(Int_t ipad = 2; ipad--;){
285 if(!(h2 = (TH2F*)arr->At(ipad))) return kFALSE;
286 ((TVirtualPad*)l->At(ipad))->cd();
291 if(!(arr = (TObjArray*)fResults->At(kMean))) break;
292 gPad->Divide(2, 1); l = gPad->GetListOfPrimitives();
293 for(Int_t ipad = 2; ipad--;){
294 if(!(h2 = (TH2F*)arr->At(ipad))) return kFALSE;
295 ((TVirtualPad*)l->At(ipad))->cd();
302 AliWarning("No container/data found.");
306 //_______________________________________________________
307 TObjArray* AliTRDclusterResolution::Histos()
309 if(fContainer) return fContainer;
310 fContainer = new TObjArray(sizeof(AliTRDclusterResolution::EResultContainer));
311 //fContainer->SetOwner(kTRUE);
314 TObjArray *arr = 0x0;
316 fContainer->AddAt(h2 = new TH2I("h_q", "", 50, 2.2, 7.5, 100, -.5, .5), kQRes);
317 h2->SetXTitle("log(q) [a.u.]");
318 h2->SetYTitle("#Delta y[cm]");
319 h2->SetZTitle("entries");
321 fContainer->AddAt(arr = new TObjArray(AliTRDgeometry::kNlayer), kCenter);
322 arr->SetName("y(PadWidth)");
323 for(Int_t ily=0; ily<AliTRDgeometry::kNlayer; ily++){
324 arr->AddAt(h2 = new TH2I(Form("h_y%d", ily), Form("Ly[%d]", ily), 51, -.51, .51, 100, -.5, .5), ily);
325 h2->SetXTitle("y_{w} [w]");
326 h2->SetYTitle("#Delta y[cm]");
327 h2->SetZTitle("entries");
330 fContainer->AddAt(arr = new TObjArray(kN), kSigm);
331 arr->SetName("Resolution");
333 for(Int_t id=1; id<=fAd->GetNbins(); id++){
334 for(Int_t it=1; it<=fAt->GetNbins(); it++){
335 arr->AddAt(h2 = new TH2I(Form("hr_d%02dt%02d", id, it), Form("d_{wire}(%3.1f-%3.1f)[mm] t_{drift}(%3.1f-%3.1f)[#mus]", 10.*fAd->GetBinLowEdge(id), 10.*fAd->GetBinUpEdge(id), fAt->GetBinLowEdge(it), fAt->GetBinUpEdge(it)), 35, -.35, .35, 100, -.5, .5), ih++);
336 h2->SetXTitle("tg#phi");
337 h2->SetYTitle("#Delta y[cm]");
338 h2->SetZTitle("entries");
342 fContainer->AddAt(arr = new TObjArray(kN), kMean);
343 arr->SetName("Systematics");
345 for(Int_t id=1; id<=fAd->GetNbins(); id++){
346 for(Int_t it=1; it<=fAt->GetNbins(); it++){
347 arr->AddAt(h2 = new TH2I(Form("hs_d%02dt%02d", id, it), Form("d_{wire}(%3.1f-%3.1f)[mm] t_{drift}(%3.1f-%3.1f)[#mus]", 10.*fAd->GetBinLowEdge(id), 10.*fAd->GetBinUpEdge(id), fAt->GetBinLowEdge(it), fAt->GetBinUpEdge(it)), 35, -.35, .35, 100, -.5, .5), ih++);
348 h2->SetXTitle("tg#phi-h*tg(#theta)");
349 h2->SetYTitle("#Delta y[cm]");
350 h2->SetZTitle("entries");
357 //_______________________________________________________
358 void AliTRDclusterResolution::Exec(Option_t *)
360 if(!HasExB()) AliWarning("ExB was not set. Call SetExB() before running the task.");
363 Float_t x, y, z, q, dy, dydx, dzdx, cov[3], covcl[3];
366 // define limits around ExB for which x contribution is negligible
367 const Float_t kDtgPhi = 3.5e-2; //(+- 2 deg)
369 TObjArray *arr0 = (TObjArray*)fContainer->At(kCenter);
370 TObjArray *arr1 = (TObjArray*)fContainer->At(kSigm);
371 TObjArray *arr2 = (TObjArray*)fContainer->At(kMean);
373 const AliTRDclusterInfo *cli = 0x0;
374 TIterator *iter=fInfo->MakeIterator();
375 while((cli=dynamic_cast<AliTRDclusterInfo*>((*iter)()))){
376 cli->GetCluster(det, x, y, z, q, t, covcl);
377 if(fDet>=0 && fDet!=det) continue;
379 dy = cli->GetResolution();
380 cli->GetGlobalPosition(y, z, dydx, dzdx, &cov[0]);
382 // resolution as a function of cluster charge
383 // only for phi equal exB
384 if(TMath::Abs(dydx-fExB) < kDtgPhi){
385 h2 = (TH2I*)fContainer->At(kQRes);
386 h2->Fill(TMath::Log(q), dy);
389 // do not use problematic clusters in resolution analysis
390 // TODO define limits as calibration aware (gain) !!
391 if(q<20. || q>250.) continue;
393 // resolution as a function of y displacement from pad center
394 // only for phi equal exB
395 if(TMath::Abs(dydx-fExB) < kDtgPhi){
396 h2 = (TH2I*)arr0->At(AliTRDgeometry::GetLayer(det));
397 h2->Fill(cli->GetYDisplacement(), dy);
400 Int_t it = fAt->FindBin((t+.5)*fgkTimeBinLength);
401 if(it==0 || it == fAt->GetNbins()+1){
402 AliWarning(Form("Drift time %f outside allowed range", t));
405 Int_t id = fAd->FindBin(cli->GetAnisochronity());
406 if(id==0 || id == fAd->GetNbins()+1){
407 AliWarning(Form("Distance to anode %f outside allowed range", cli->GetAnisochronity()));
410 // calculate index of cluster position in array
411 Int_t hid = (id-1)*kNTB+it-1;
413 // fill histo for resolution (sigma)
414 h2 = (TH2I*)arr1->At(hid);
417 // fill histo for systematic (mean)
418 h2 = (TH2I*)arr2->At(hid);
419 h2->Fill(dydx-cli->GetTilt()*dzdx, dy);
421 PostData(0, fContainer);
425 //_______________________________________________________
426 Bool_t AliTRDclusterResolution::PostProcess()
428 if(!fContainer) return kFALSE;
429 if(!HasExB()) AliWarning("ExB was not set. Call SetExB() before running the post processing.");
431 TObjArray *arr = 0x0;
434 TGraphErrors *g = 0x0;
435 fResults = new TObjArray(sizeof(AliTRDclusterResolution::EResultContainer));
436 fResults->SetOwner();
437 fResults->AddAt(arr = new TObjArray(3), kQRes);
439 arr->AddAt(g = new TGraphErrors(), 0);
440 g->SetLineColor(kBlue); g->SetMarkerColor(kBlue);
441 g->SetMarkerStyle(7);
442 arr->AddAt(g = new TGraphErrors(), 1);
443 g->SetLineColor(kRed); g->SetMarkerColor(kRed);
444 g->SetMarkerStyle(23);
445 arr->AddAt(g = new TGraphErrors(), 2);
446 g->SetLineColor(kGreen); g->SetMarkerColor(kGreen);
447 g->SetMarkerStyle(7);
449 fResults->AddAt(arr = new TObjArray(3), kCenter);
452 if(!(h2 = (TH2F*)gROOT->FindObject("hYM"))){
453 h2 = new TH2F("hYM", "",
454 AliTRDgeometry::kNlayer, -.5, AliTRDgeometry::kNlayer-.5, 51, -.51, .51);
458 h2->SetYTitle("y [w]");
459 h2->SetZTitle("#mu_{x} [cm]");
460 arr->AddAt(h2 = (TH2F*)h2->Clone("hYS"), 1);
461 h2->SetZTitle("#sigma_{x} [cm]");
462 arr->AddAt(h2 = (TH2F*)h2->Clone("hYP"), 2);
463 h2->SetZTitle("entries");
465 fResults->AddAt(arr = new TObjArray(2), kSigm);
467 if(!(h2 = (TH2F*)gROOT->FindObject("hSX"))){
468 h2 = new TH2F("hSX", "",
469 fAd->GetNbins(), fAd->GetXmin(), fAd->GetXmax(),
470 fAt->GetNbins(), fAt->GetXmin(), fAt->GetXmax());
473 h2->SetXTitle("d [mm]");
474 h2->SetYTitle("t_{drift} [#mus]");
475 h2->SetZTitle("#sigma_{x} [cm]");
476 arr->AddAt(h2 = (TH2F*)h2->Clone("hSY"), 1);
477 h2->SetZTitle("#sigma_{y} [cm]");
479 fResults->AddAt(arr = new TObjArray(2), kMean);
481 arr->AddAt(h2 = (TH2F*)h2->Clone("hDX"), 0);
482 h2->SetZTitle("dx [cm]");
483 arr->AddAt(h2 = (TH2F*)h2->Clone("hX0"), 1);
484 h2->SetZTitle("x0 [cm]");
487 TIterator *iter=fResults->MakeIterator();
488 while((o=((*iter)()))) o->Clear(); // maybe it is wrong but we should never reach this point
491 // precalculated value of tg^2(alpha_L)
492 Double_t exb2 = fExB*fExB;
493 // square of the mean value of sigma drift length.
494 // has to come from previous calibration
495 //Double_t sxd2 = 1.;// [mm^2]
497 printf("ExB[%e] ExB2[%e]\n", fExB, exb2);
499 // process resolution dependency on charge
500 if(HasProcess(kQRes)) ProcessCharge();
502 // process resolution dependency on y displacement
503 if(HasProcess(kCenter)) ProcessCenterPad();
505 // process resolution dependency on drift legth and drift cell width
506 if(HasProcess(kSigm)) ProcessSigma();
508 // process systematic shift on drift legth and drift cell width
509 if(HasProcess(kMean)) ProcessMean();
514 //_______________________________________________________
515 Bool_t AliTRDclusterResolution::SetExB(Int_t det, Int_t col, Int_t row)
518 AliCDBManager *cdb = AliCDBManager::Instance();
519 if(cdb->GetRun() < 0){
520 AliError("OCDB manager not properly initialized");
524 // check magnetic field
525 if(TMath::Abs(AliTracker::GetBz()) < 1.e-10){
526 AliWarning("B=0. Magnetic field may not be initialized. Continue if you know what you are doing !");
529 // set reference detector if any
530 if(det>=0 && det<AliTRDgeometry::kNdet) fDet = det;
533 AliTRDcalibDB *fCalibration = AliTRDcalibDB::Instance();
534 AliTRDCalROC *fCalVdriftROC = fCalibration->GetVdriftROC(det);
535 const AliTRDCalDet *fCalVdriftDet = fCalibration->GetVdriftDet();
537 fVdrift = fCalVdriftDet->GetValue(det) * fCalVdriftROC->GetValue(col, row);
538 fExB = AliTRDCommonParam::Instance()->GetOmegaTau(fVdrift);
543 //_______________________________________________________
544 void AliTRDclusterResolution::SetVisual()
547 fCanvas = new TCanvas("clResCanvas", "Cluster Resolution Visualization", 10, 10, 600, 600);
550 //_______________________________________________________
551 void AliTRDclusterResolution::ProcessCharge()
554 if((h2 = (TH2I*)fContainer->At(kQRes))) {
555 AliWarning("Missing dy=f(Q) histo");
558 TF1 f("f", "gaus", -.5, .5);
562 TObjArray *arr = (TObjArray*)fResults->At(kQRes);
563 TGraphErrors *gqm = (TGraphErrors*)arr->At(0);
564 TGraphErrors *gqs = (TGraphErrors*)arr->At(1);
565 TGraphErrors *gqp = (TGraphErrors*)arr->At(2);
566 Double_t q, n = 0., entries;
568 for(Int_t ix=1; ix<=ax->GetNbins(); ix++){
569 q = TMath::Exp(ax->GetBinCenter(ix));
570 if(q<20. || q>250.) continue; // ?!
572 h1 = h2->ProjectionY("py", ix, ix);
573 entries = h1->GetEntries();
574 if(entries < 50) continue;
579 Int_t ip = gqm->GetN();
580 gqm->SetPoint(ip, q, 10.*f.GetParameter(1));
581 gqm->SetPointError(ip, 0., 10.*f.GetParError(1));
583 // correct sigma for ExB effect
584 gqs->SetPoint(ip, q, 1.e1*f.GetParameter(2)/**f.GetParameter(2)-exb2*sxd2*/);
585 gqs->SetPointError(ip, 0., 1.e1*f.GetParError(2)/**f.GetParameter(2)*/);
589 gqp->SetPoint(ip, q, entries);
590 gqp->SetPointError(ip, 0., 0./*TMath::Sqrt(entries)*/);
593 // normalize probability and get mean sy
594 Double_t sm = 0., sy;
595 for(Int_t ip=gqp->GetN(); ip--;){
596 gqp->GetPoint(ip, q, entries);
598 gqp->SetPoint(ip, q, entries);
599 gqs->GetPoint(ip, q, sy);
603 // error parametrization s(q) = <sy> + b(1/q-1/q0)
604 TF1 fq("fq", "[0] + [1]/x", 20., 250.);
606 printf("sy(Q) :: sm[%f] b[%f] 1/q0[%f]\n", sm, fq.GetParameter(1), (sm-fq.GetParameter(0))/fq.GetParameter(1));
609 //_______________________________________________________
610 void AliTRDclusterResolution::ProcessCenterPad()
612 TObjArray *arr = (TObjArray*)fContainer->At(kCenter);
614 AliWarning("Missing dy=f(y_d) container");
617 TF1 f("f", "gaus", -.5, .5);
619 TH1D *h1 = 0x0, *h11 = 0x0;
622 TObjArray *arrg = (TObjArray*)fResults->At(kCenter);
623 TH2F *hym = (TH2F*)arrg->At(0);
624 TH2F *hys = (TH2F*)arrg->At(1);
625 TH2F *hyp = (TH2F*)arrg->At(2);
626 for(Int_t ily=0; ily<AliTRDgeometry::kNlayer; ily++){
627 if(!(h2 = (TH2I*)arr->At(ily))) continue;
629 for(Int_t ix=1; ix<=ax->GetNbins(); ix++){
630 Float_t yd = ax->GetBinCenter(ix);
631 h1 = h2->ProjectionY("py", ix, ix);
632 Int_t entries = (Int_t)h1->GetEntries();
633 if(entries < 50) continue;
638 hyp->Fill(ily, yd, entries);
639 hym->Fill(ily, yd, f.GetParameter(1));
640 //hym->SetPointError(ip, 0., f.GetParError(1));
641 hys->Fill(ily, yd, f.GetParameter(2));
642 //hys->SetPointError(ip, 0., f.GetParError(2));
646 // POSTPROCESS SPECTRA
647 // Found correction for systematic deviation
648 TF1 fprf("fprf", "[0]+[1]*sin([2]*x)", -.5, .5);
649 fprf.SetParameter(0, 0.);
650 fprf.SetParameter(1, 1.1E-2);
651 fprf.SetParameter(2, -TMath::PiOver2()/0.25);
652 printf(" const Float_t cy[AliTRDgeometry::kNlayer][3] = {\n");
653 for(Int_t ily=0; ily<AliTRDgeometry::kNlayer; ily++){
654 h1 = hym->ProjectionY("hym_pyy", ily+1, ily+1);
656 for(Int_t ib=h1->GetNbinsX(); ib--;) h1->SetBinError(ib, 0.002);
658 printf(" {%5.3e, %5.3e, %5.3e},\n", fprf.GetParameter(0), fprf.GetParameter(1), fprf.GetParameter(2));
660 if(!fCanvas) continue;
662 h1->SetMinimum(-0.02);h1->SetMaximum(0.02);h1->Draw("e1");
663 h11 = hyp->ProjectionY("hyp_pyy", ily+1, ily+1);
664 h11->Scale(.8/h11->Integral());
665 h11->SetLineColor(kBlue); h11->Draw("csame");
666 fCanvas->Modified(); fCanvas->Update();
668 fCanvas->SaveAs(Form("Figures/ProcessCenterPad_M_Ly%d.gif", ily));
669 else gSystem->Sleep(500);
673 // Parameterization for sigma PRF
674 TF1 fgaus("fgaus", "gaus", -.5, .5);
675 printf(" const Float_t scy[AliTRDgeometry::kNlayer][4] = {\n");
676 for(Int_t ily=0; ily<AliTRDgeometry::kNlayer; ily++){
677 h1 = hys->ProjectionY("hys_pyy", ily+1, ily+1);
679 for(Int_t ib=h1->GetNbinsX(); ib--;) h1->SetBinError(ib, 0.002);
681 h1->Fit(&fgaus, "Q");
682 printf(" {%5.3e, %5.3e, %5.3e, ", fgaus.GetParameter(0), fgaus.GetParameter(1), fgaus.GetParameter(2));
684 // calculate mean sigma on the pad center distribution
686 h1 = hyp->ProjectionY("hyp_pyy", ily+1, ily+1);
687 for(Int_t ix=1; ix<=h1->GetNbinsX(); ix++){
688 sy += fgaus.Eval(h1->GetBinCenter(ix))*h1->GetBinContent(ix);
690 sy /= h1->GetEntries();
691 printf("%5.3e},\n", sy);
693 if(!fCanvas) continue;
695 h1->SetMinimum(0.01);h1->SetMaximum(0.04);h1->Draw("e1");
696 h11 = hyp->ProjectionY("hyp_pyy", ily+1, ily+1);
697 h11->Scale(1./h11->Integral());
698 h11->SetLineColor(kBlue); h11->Draw("csame");
699 fCanvas->Modified(); fCanvas->Update();
701 fCanvas->SaveAs(Form("Figures/ProcessCenterPad_S_Ly%d.gif", ily));
702 else gSystem->Sleep(500);
707 //_______________________________________________________
708 void AliTRDclusterResolution::ProcessSigma()
710 TObjArray *arr = (TObjArray*)fContainer->At(kSigm);
712 AliWarning("Missing dy=f(x_d, d_wire) container");
715 TLinearFitter gs(1,"pol1");
716 TF1 f("f", "gaus", -.5, .5);
720 // init visualization
721 TGraphErrors *ggs = 0x0;
724 ggs = new TGraphErrors();
728 Double_t d(0.), x(0.), sx, sy;
729 TObjArray *arrr = (TObjArray*)fResults->At(kSigm);
730 TH2F *hsx = (TH2F*)arrr->At(0);
731 TH2F *hsy = (TH2F*)arrr->At(1);
732 for(Int_t id=1; id<=fAd->GetNbins(); id++){
733 d = fAd->GetBinCenter(id); //[mm]
734 printf(" Doing d = %5.3f [mm]\n", d);
735 for(Int_t it=1; it<=fAt->GetNbins(); it++){
736 x = fAt->GetBinCenter(it); //[mm]
737 Int_t idx = (id-1)*kNTB+it-1;
739 // retrieve data histogram
740 if(!(h2 = (TH2I*)arr->At(idx))) {
741 AliWarning(Form("Missing histo at index idx[%3d] [id[%2d] it[%2d]] xd[%f] d[%f]\n", idx, id, it, x, d));
746 new(ggs) TGraphErrors();
747 ggs->SetMarkerStyle(7);
751 for(Int_t ix=1; ix<=ax->GetNbins(); ix++){
752 Float_t dydx = ax->GetBinCenter(ix);
753 Double_t tgg = (dydx-fExB)/(1.+dydx*fExB);
754 Double_t tgg2 = tgg*tgg;
755 h1 = h2->ProjectionY("py", ix, ix);
756 if(h1->GetEntries() < 100) continue;
758 //printf("\tFit ix[%d] on %s entries [%d]\n", ix, h2->GetName(), (Int_t)h1->GetEntries());
760 Double_t s2 = f.GetParameter(2)*f.GetParameter(2);
761 Double_t s2e = 2.*f.GetParameter(2)*f.GetParError(2);
762 // Fill sy^2 = f(tg^2(phi-a_L))
763 gs.AddPoint(&tgg2, s2, s2e);
766 Int_t ip = ggs->GetN();
767 ggs->SetPoint(ip, tgg2, s2);
768 ggs->SetPointError(ip, 0., s2e);
769 //printf("%f, %f, %f, \n", tgg2, s2, s2e);
771 if(gs.Eval()) continue;
772 sx = gs.GetParameter(1);
773 sy = gs.GetParameter(0);
774 hsx->SetBinContent(id, it, TMath::Sqrt(sx));
775 //hsx->SetBinError(id, it, sig.GetParError(1));
777 // s^2_y = s0^2_y + tg^2(a_L) * s^2_x
778 hsy->SetBinContent(id, it, TMath::Sqrt(sy)/* - exb2*sig.GetParameter(1)*/);
779 //hsy->SetBinError(id, it, sig.GetParError(0)+exb2*exb2*sig.GetParError(1));
781 /*if(!fCanvas) */continue;
783 new(line) TLine(0, sy, .025, sy+.025*sx);
784 line->SetLineColor(kRed);line->SetLineWidth(2);
785 ggs->Draw("apl"); line->Draw("");
786 fCanvas->Modified(); fCanvas->Update();
787 if(IsSaveAs()) fCanvas->SaveAs(Form("Figures/ProcessSigma_D%d_T%02d.gif", id, it));
788 else gSystem->Sleep(100);
790 printf(" xd=%4.1f[cm] sx=%5.3e[cm] sy=%5.3e[cm]\n", x, sx, sy);
793 // if(ggs) delete ggs; // TODO fix this memory leak !
794 // if(line) delete line;
796 // fit sy parallel to the drift
797 TF1 fsyD("fsy", "[0]+[1]*exp(1./(x+[2]))", 0.5, 3.5);
798 fsyD.SetParameter(0, .025);
799 fsyD.SetParameter(1, -8.e-4);
800 fsyD.SetParameter(2, -.25);
801 h1 = hsy->ProjectionY("hsy_pyy"); h1->Scale(1./hsy->GetNbinsX());
802 for(Int_t ib=1; ib<=h1->GetNbinsX(); ib++) h1->SetBinError(ib, 0.002);
803 h1->Fit(&fsyD, "Q", "", .5, 3.5);
804 printf(" const Float_t sy0 = %5.3e;\n", fsyD.GetParameter(0));
805 printf(" const Float_t sya = %5.3e;\n", fsyD.GetParameter(1));
806 printf(" const Float_t syb = %5.3e;\n", fsyD.GetParameter(2));
809 h1->Draw("e1"); fsyD.Draw("same");
810 fCanvas->Modified(); fCanvas->Update();
811 if(IsSaveAs()) fCanvas->SaveAs("Figures/ProcessSigma_SY||.gif");
812 else gSystem->Sleep(1000);
816 // fit sx parallel to the drift
817 TF1 fsxD("fsx", "gaus(0)+expo(3)", 0., 3.5);
818 h1 = hsx->ProjectionY("hsx_pyy");
819 h1->Scale(1./hsx->GetNbinsX());
820 for(Int_t ib=1; ib<=h1->GetNbinsX(); ib++) if(h1->GetBinContent(ib)>0.) h1->SetBinError(ib, 0.02);
821 h1->Fit(&f, "QN", "", 0., 1.3);
822 fsxD.SetParameter(0, 0.);
823 fsxD.SetParameter(1, f.GetParameter(1));
824 fsxD.SetParameter(2, f.GetParameter(2));
825 TF1 expo("fexpo", "expo", 0., 3.5);
826 h1->Fit(&expo, "QN");
827 fsxD.SetParameter(3, expo.GetParameter(0));
828 fsxD.SetParameter(4, expo.GetParameter(1));
830 printf(" const Float_t sxgc = %5.3e;\n", fsxD.GetParameter(0));
831 printf(" const Float_t sxgm = %5.3e;\n", fsxD.GetParameter(1));
832 printf(" const Float_t sxgs = %5.3e;\n", fsxD.GetParameter(2));
833 printf(" const Float_t sxe0 = %5.3e;\n", fsxD.GetParameter(3));
834 printf(" const Float_t sxe1 = %5.3e;\n", fsxD.GetParameter(4));
837 h1->Draw("e1"); fsxD.Draw("same");
838 fCanvas->Modified(); fCanvas->Update();
839 if(IsSaveAs()) fCanvas->SaveAs("Figures/ProcessSigma_SX||.gif");
840 else gSystem->Sleep(1000);
843 // fit sx perpendicular to the drift
845 TAxis *ay = hsx->GetYaxis();
846 TH1D *hx = hsx->ProjectionX("hsx_px", 1,1);
847 TH1D *hAn = (TH1D*)hx->Clone("hAn"); hAn->Reset();
848 for(Int_t ib = 11; ib<24; ib++, nb++){
849 hx = hsx->ProjectionX("hsx_px", ib, ib);
850 for(Int_t id=1; id<=hx->GetNbinsX(); id++)
851 hx->SetBinContent(id, hx->GetBinContent(id)-fsxD.Eval(ay->GetBinCenter(ib)));
854 TF1 fsxA("fsxA", "pol2", 0., 0.25);
856 for(Int_t ib=1; ib<=hAn->GetNbinsX(); ib++) hAn->SetBinError(ib, 0.002);
857 hAn->Fit(&fsxA, "Q");
858 printf(" const Float_t sxd0 = %5.3e;\n", fsxA.GetParameter(0));
859 printf(" const Float_t sxd1 = %5.3e;\n", fsxA.GetParameter(1));
860 printf(" const Float_t sxd2 = %5.3e;\n", fsxA.GetParameter(2));
863 hAn->Draw("e1"); fsxA.Draw("same");
864 fCanvas->Modified(); fCanvas->Update();
865 if(IsSaveAs()) fCanvas->SaveAs("Figures/ProcessSigma_SXL.gif");
866 else gSystem->Sleep(100);
870 //_______________________________________________________
871 void AliTRDclusterResolution::ProcessMean()
873 TObjArray *arr = (TObjArray*)fContainer->At(kMean);
875 AliWarning("Missing dy=f(x_d, d_wire) container");
878 TGraphErrors *gm = new TGraphErrors();
879 TF1 f("f", "gaus", -.5, .5);
880 TF1 line("l", Form("%6.4f*[0]+[1]*x", fExB), -.15, .15);
881 Double_t d(0.), x(0.), dx, x0;
886 TObjArray *arrr = (TObjArray*)fResults->At(kMean);
887 TH2F *hdx = (TH2F*)arrr->At(0);
888 TH2F *hx0 = (TH2F*)arrr->At(1);
889 for(Int_t id=1; id<=fAd->GetNbins(); id++){
890 d = fAd->GetBinCenter(id); //[mm]
891 printf(" Doing d = %5.3f [mm]\n", d);
892 for(Int_t it=1; it<=fAt->GetNbins(); it++){
893 x = fAt->GetBinCenter(it); //[mm]
894 Int_t idx = (id-1)*kNTB+it-1;
895 if(!(h2 = (TH2I*)arr->At(idx))) {
896 AliWarning(Form("Missing histo at index idx[%3d] [id[%2d] it[%2d]] xd[%f] d[%f]\n", idx, id, it, x, d));
900 new(gm) TGraphErrors();
901 gm->SetMarkerStyle(7);
903 for(Int_t ix=1; ix<=ax->GetNbins(); ix++){
904 Double_t dydx = ax->GetBinCenter(ix);
905 h1 = h2->ProjectionY("py", ix, ix);
906 if(h1->GetEntries() < 50) continue;
910 // Fill <Dy> = f(dydx - h*dzdx)
911 Int_t ip = gm->GetN();
912 gm->SetPoint(ip, dydx, f.GetParameter(1));
913 gm->SetPointError(ip, 0., f.GetParError(1));
916 if(gm->GetN()<4) continue;
918 gm->Fit(&line, "QN");
919 dx = line.GetParameter(1); // = (fVdrift + dVd)*(fT + tCorr);
920 x0 = line.GetParameter(0); // = tg(a_L)*dx
921 hdx->SetBinContent(id, it, dx);
922 hx0->SetBinContent(id, it, x0);
924 if(!fCanvas) continue;
926 gm->Draw("apl"); line.Draw("same");
927 fCanvas->Modified(); fCanvas->Update();
928 if(IsSaveAs()) fCanvas->SaveAs(Form("Figures/ProcessMean_D%d_T%02d.gif", id, it));
929 else gSystem->Sleep(100);
930 printf(" xd=%4.1f[cm] dx=%5.3e[cm] x0=%5.3e[cm]\n", x, dx, x0);
934 TH1D *h=hdx->ProjectionY("hdx_py"); h->Scale(1./hdx->GetNbinsX());
935 printf(" const Float_t cx[] = {\n ");
936 for(Int_t ib=1; ib<=h->GetNbinsX(); ib++){
937 printf("%6.4e, ", h->GetBinContent(ib));
938 if(ib%6==0) printf("\n ");
942 // delete gm; TODO memory leak ?