1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercialf purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
16 /* $Id: AliTRDresolution.cxx 27496 2008-07-22 08:35:45Z cblume $ */
18 ////////////////////////////////////////////////////////////////////////////
20 // TRD tracking resolution //
22 // The class performs resolution and residual studies
23 // of the TRD tracks for the following quantities :
24 // - spatial position (y, [z])
25 // - angular (phi) tracklet
26 // - momentum at the track level
28 // The class has to be used for regular detector performance checks using the official macros:
29 // - $ALICE_ROOT/TRD/qaRec/run.C
30 // - $ALICE_ROOT/TRD/qaRec/makeResults.C
32 // For stand alone usage please refer to the following example:
34 // gSystem->Load("libANALYSIS.so");
35 // gSystem->Load("libTRDqaRec.so");
36 // AliTRDresolution *res = new AliTRDresolution();
37 // //res->SetMCdata();
38 // //res->SetVerbose();
39 // //res->SetVisual();
41 // if(!res->PostProcess()) return;
42 // res->GetRefFigure(0);
46 // Alexandru Bercuci <A.Bercuci@gsi.de> //
47 // Markus Fasel <M.Fasel@gsi.de> //
49 ////////////////////////////////////////////////////////////////////////////
54 #include <TObjArray.h>
58 #include <THnSparse.h>
64 #include <TGraphErrors.h>
65 #include <TGraphAsymmErrors.h>
66 #include <TLinearFitter.h>
70 #include <TTreeStream.h>
71 #include <TGeoManager.h>
72 #include <TDatabasePDG.h>
76 #include "AliESDtrack.h"
77 #include "AliMathBase.h"
78 #include "AliTrackPointArray.h"
80 #include "AliTRDresolution.h"
81 #include "AliTRDgeometry.h"
82 #include "AliTRDtransform.h"
83 #include "AliTRDpadPlane.h"
84 #include "AliTRDcluster.h"
85 #include "AliTRDseedV1.h"
86 #include "AliTRDtrackV1.h"
87 #include "AliTRDReconstructor.h"
88 #include "AliTRDrecoParam.h"
89 #include "AliTRDpidUtil.h"
90 #include "AliTRDinfoGen.h"
92 #include "info/AliTRDclusterInfo.h"
94 ClassImp(AliTRDresolution)
96 Int_t const AliTRDresolution::fgkNbins[kNdim] = {
97 Int_t(kNbunchCross)/*bc*/,
100 Int_t(kNcharge)*AliPID::kSPECIES+1/*chg*species*/,
105 }; //! no of bins/projection
106 Double_t const AliTRDresolution::fgkMin[kNdim] = {
110 -AliPID::kSPECIES-0.5,
115 }; //! low limits for projections
116 Double_t const AliTRDresolution::fgkMax[kNdim] = {
117 Int_t(kNbunchCross)-0.5,
120 AliPID::kSPECIES+0.5,
125 }; //! high limits for projections
126 Char_t const *AliTRDresolution::fgkTitle[kNdim] = {
135 }; //! title of projection
137 UChar_t const AliTRDresolution::fgNproj[kNclasses] = {
141 Char_t const * AliTRDresolution::fgPerformanceName[kNclasses] = {
152 Float_t AliTRDresolution::fgPtBin[kNpt+1] = {0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.};
154 //________________________________________________________
155 AliTRDresolution::AliTRDresolution()
167 // Default constructor
169 SetNameTitle("TRDresolution", "TRD spatial and momentum resolution");
170 MakePtSegmentation();
173 //________________________________________________________
174 AliTRDresolution::AliTRDresolution(char* name)
175 :AliTRDrecoTask(name, "TRD spatial and momentum resolution")
186 // Default constructor
190 MakePtSegmentation();
192 DefineOutput(kClToTrk, TObjArray::Class()); // cluster2track
193 DefineOutput(kClToMC, TObjArray::Class()); // cluster2mc
196 //________________________________________________________
197 AliTRDresolution::~AliTRDresolution()
203 if(fProj){fProj->Delete(); delete fProj;}
204 if(fCl){fCl->Delete(); delete fCl;}
205 if(fMCcl){fMCcl->Delete(); delete fMCcl;}
209 //________________________________________________________
210 void AliTRDresolution::UserCreateOutputObjects()
212 // spatial resolution
214 AliTRDrecoTask::UserCreateOutputObjects();
215 InitExchangeContainers();
218 //________________________________________________________
219 void AliTRDresolution::InitExchangeContainers()
221 // Init containers for subsequent tasks (AliTRDclusterResolution)
223 fCl = new TObjArray(200); fCl->SetOwner(kTRUE);
224 fMCcl = new TObjArray(); fMCcl->SetOwner(kTRUE);
225 PostData(kClToTrk, fCl);
226 PostData(kClToMC, fMCcl);
229 //________________________________________________________
230 void AliTRDresolution::UserExec(Option_t *opt)
238 AliTRDrecoTask::UserExec(opt);
241 //________________________________________________________
242 Bool_t AliTRDresolution::Pulls(Double_t* /*dyz[2]*/, Double_t* /*cov[3]*/, Double_t /*tilt*/) const
244 // Helper function to calculate pulls in the yz plane
245 // using proper tilt rotation
246 // Uses functionality defined by AliTRDseedV1.
250 Double_t t2(tilt*tilt);
251 // exit door until a bug fix is found for AliTRDseedV1::GetCovSqrt
255 cc[0] = cov[0] - 2.*tilt*cov[1] + t2*cov[2];
256 cc[1] = cov[1]*(1.-t2) + tilt*(cov[0] - cov[2]);
257 cc[2] = t2*cov[0] + 2.*tilt*cov[1] + cov[2];
259 Double_t sqr[3]={0., 0., 0.};
260 if(AliTRDseedV1::GetCovSqrt(cc, sqr)) return kFALSE;
261 Double_t invsqr[3]={0., 0., 0.};
262 if(AliTRDseedV1::GetCovInv(sqr, invsqr)<1.e-40) return kFALSE;
263 Double_t tmp(dyz[0]);
264 dyz[0] = invsqr[0]*tmp + invsqr[1]*dyz[1];
265 dyz[1] = invsqr[1]*tmp + invsqr[2]*dyz[1];
270 //________________________________________________________
271 TH1* AliTRDresolution::PlotCluster(const AliTRDtrackV1 *track)
274 // Plot the cluster distributions
277 if(track) fkTrack = track;
279 AliDebug(4, "No Track defined.");
282 if(fkESD->GetTOFbc() > 1){
283 AliDebug(4, Form("Track with BC_index[%d] not used.", fkESD->GetTOFbc()));
286 if(fPt<fPtThreshold){
287 AliDebug(4, Form("Track with pt[%6.4f] under threshold.", fPt));
291 if(!fContainer || !(H = ((THnSparse*)fContainer->At(kCluster)))){
292 AliWarning("No output container defined.");
296 AliTRDgeometry *geo(AliTRDinfoGen::Geometry());
297 Double_t val[kNdim]; Float_t exb, vd, t0, s2, dl, dt, corr;
298 TObjArray *clInfoArr(NULL);
299 AliTRDseedV1 *fTracklet(NULL);
300 AliTRDcluster *c(NULL)/*, *cc(NULL)*/;
301 for(Int_t ily=0; ily<AliTRDgeometry::kNlayer; ily++){
302 if(!(fTracklet = fkTrack->GetTracklet(ily))) continue;
303 if(!fTracklet->IsOK()) continue;
304 fTracklet->GetCalibParam(exb, vd, t0, s2, dl, dt);
308 //val[kPt] = TMath::ATan((fTracklet->GetYref(1) - exb)/(1+fTracklet->GetYref(1)*exb))*TMath::RadToDeg();
309 corr = fkTrack->Charge()/TMath::Sqrt(1.+fTracklet->GetYref(1)*fTracklet->GetYref(1)+fTracklet->GetZref(1)*fTracklet->GetZref(1))/vd;
310 fTracklet->ResetClusterIter(kTRUE);
311 while((c = fTracklet->NextCluster())){
312 Float_t xc(c->GetX()); //Int_t tb(c->GetLocalTimeBin());
314 val[kYrez] = c->GetY()-fTracklet->GetYat(xc);
315 //val[kZrez] = fTracklet->GetX0()-xc;
316 //val[kPrez] = 0.; Int_t ic(0);
317 //if((cc = fTracklet->GetClusters(tb-1))) {val[kPrez] += cc->GetQ(); ic++;}
318 //if((cc = fTracklet->GetClusters(tb-2))) {val[kPrez] += cc->GetQ(); ic++;}
319 //if(ic) val[kPrez] /= (ic*c->GetQ());
320 val[kSpeciesChgRC]= fTracklet->IsRowCross()?0:(c->GetQ()*corr);
322 /* // tilt rotation of covariance for clusters
323 Double_t sy2(c->GetSigmaY2()), sz2(c->GetSigmaZ2());
324 cov[0] = (sy2+t2*sz2)*corr;
325 cov[1] = tilt*(sz2 - sy2)*corr;
326 cov[2] = (t2*sy2+sz2)*corr;
327 // sum with track covariance
328 cov[0]+=covR[0]; cov[1]+=covR[1]; cov[2]+=covR[2];
329 Double_t dyz[2]= {dy[1], dz[1]};
330 Pulls(dyz, cov, tilt);*/
332 // Get z-position with respect to anode wire
333 Float_t yt(fTracklet->GetYref(0)-val[kZrez]*fTracklet->GetYref(1)),
334 zt(fTracklet->GetZref(0)-val[kZrez]*fTracklet->GetZref(1));
335 Int_t istk = geo->GetStack(c->GetDetector());
336 AliTRDpadPlane *pp = geo->GetPadPlane(ily, istk);
337 Float_t row0 = pp->GetRow0();
338 Float_t d = row0 - zt + pp->GetAnodeWireOffset();
339 d -= ((Int_t)(2 * d)) / 2.0;
340 if (d > 0.25) d = 0.5 - d;
342 AliTRDclusterInfo *clInfo(NULL);
343 clInfo = new AliTRDclusterInfo;
344 clInfo->SetCluster(c);
345 //Float_t covF[] = {cov[0], cov[1], cov[2]};
346 clInfo->SetGlobalPosition(yt, zt, fTracklet->GetYref(1), fTracklet->GetZref(1)/*, covF*/);
347 clInfo->SetResolution(val[kYrez]);
348 clInfo->SetAnisochronity(d);
349 clInfo->SetDriftLength(val[kZrez]);
350 clInfo->SetTilt(fTracklet->GetTilt());
351 if(fCl) fCl->Add(clInfo);
352 else AliDebug(1, "Cl exchange container missing. Activate by calling \"InitExchangeContainers()\"");
356 clInfoArr=new TObjArray(AliTRDseedV1::kNclusters);
357 clInfoArr->SetOwner(kFALSE);
359 clInfoArr->Add(clInfo);
362 if(DebugLevel()>=1 && clInfoArr){
363 ULong_t status = fkESD->GetStatus();
364 (*DebugStream()) << "cluster"
365 <<"status=" << status
366 <<"clInfo.=" << clInfoArr
371 if(clInfoArr) delete clInfoArr;
373 return NULL;//H->Projection(kEta, kPhi);
377 //________________________________________________________
378 TH1* AliTRDresolution::PlotTracklet(const AliTRDtrackV1 *track)
380 // Plot normalized residuals for tracklets to track.
382 // We start from the result that if X=N(|m|, |Cov|)
384 // (Cov^{-1})^{1/2}X = N((Cov^{-1})^{1/2}*|m|, |1|)
386 // in our case X=(y_trklt - y_trk z_trklt - z_trk) and |Cov| = |Cov_trklt| + |Cov_trk| at the radial
387 // reference position.
388 if(track) fkTrack = track;
390 AliDebug(4, "No Track defined.");
393 if(fkESD->GetTOFbc()>1){
394 AliDebug(4, Form("Track with BC_index[%d] not used.", fkESD->GetTOFbc()));
398 if(!fContainer || !(H = (THnSparse*)fContainer->At(kTracklet))){
399 AliWarning("No output container defined.");
403 Double_t val[kNdim+1];
404 AliTRDseedV1 *fTracklet(NULL);
405 for(Int_t il(0); il<AliTRDgeometry::kNlayer; il++){
406 if(!(fTracklet = fkTrack->GetTracklet(il))) continue;
407 if(!fTracklet->IsOK()) continue;
411 val[kSpeciesChgRC]= fSpecies;
412 //val[kPt] = GetPtBin(fTracklet->GetPt());
413 Double_t dyt(fTracklet->GetYref(0) - fTracklet->GetYfit(0)),
414 dzt(fTracklet->GetZref(0) - fTracklet->GetZfit(0)),
415 dydx(fTracklet->GetYfit(1)),
416 tilt(fTracklet->GetTilt());
417 // correct for tilt rotation
418 val[kYrez] = dyt - dzt*tilt;
419 val[kZrez] = dzt + dyt*tilt;
420 dydx+= tilt*fTracklet->GetZref(1);
421 val[kPrez] = TMath::ATan((fTracklet->GetYref(1) - dydx)/(1.+ fTracklet->GetYref(1)*dydx)) * TMath::RadToDeg();
422 if(fTracklet->IsRowCross()){
423 val[kSpeciesChgRC]= 0.;
424 val[kPrez] = fkTrack->Charge(); // may be better defined
426 Float_t exb, vd, t0, s2, dl, dt;
427 fTracklet->GetCalibParam(exb, vd, t0, s2, dl, dt);
428 val[kZrez] = TMath::ATan((fTracklet->GetYref(1) - exb)/(1+fTracklet->GetYref(1)*exb));
430 val[kNdim] = fTracklet->GetdQdl();
431 if(DebugLevel()>=1) H->Fill(val);
433 // // compute covariance matrix
434 // fTracklet->GetCovAt(x, cov);
435 // fTracklet->GetCovRef(covR);
436 // cov[0] += covR[0]; cov[1] += covR[1]; cov[2] += covR[2];
437 // Double_t dyz[2]= {dy[1], dz[1]};
438 // Pulls(dyz, cov, tilt);
439 // ((TH3S*)arr->At(1))->Fill(sgm[fSegmentLevel], dyz[0], dyz[1]);
440 // ((TH3S*)arr->At(3))->Fill(tht, dyz[1], rc);
443 Bool_t rc(fTracklet->IsRowCross());
444 UChar_t err(fTracklet->GetErrorMsg());
445 Double_t x(fTracklet->GetX()),
446 pt(fTracklet->GetPt()),
447 yt(fTracklet->GetYref(0)),
448 zt(fTracklet->GetZref(0)),
449 phi(fTracklet->GetYref(1)),
450 tht(fTracklet->GetZref(1));
451 Int_t ncl(fTracklet->GetN()),
452 det(fTracklet->GetDetector());
453 (*DebugStream()) << "tracklet"
464 <<"dy=" << val[kYrez]
465 <<"dz=" << val[kZrez]
466 <<"dphi="<< val[kPrez]
467 <<"dQ ="<< val[kNdim]
473 return NULL;//H->Projection(kEta, kPhi);
477 //________________________________________________________
478 TH1* AliTRDresolution::PlotTrackIn(const AliTRDtrackV1 *track)
480 // Store resolution/pulls of Kalman before updating with the TRD information
481 // at the radial position of the first tracklet. The following points are used
483 // - the (y,z,snp) of the first TRD tracklet
484 // - the (y, z, snp, tgl, pt) of the MC track reference
486 // Additionally the momentum resolution/pulls are calculated for usage in the
489 if(track) fkTrack = track;
491 AliDebug(4, "No Track defined.");
495 THnSparseI *H=(THnSparseI*)fContainer->At(kTrackIn);
497 AliError(Form("Missing container @ %d", Int_t(kTrackIn)));
500 // check input track status
501 AliExternalTrackParam *tin(NULL);
502 if(!(tin = fkTrack->GetTrackIn())){
503 AliError("Track did not entered TRD fiducial volume.");
506 // check first tracklet
507 AliTRDseedV1 *fTracklet(fkTrack->GetTracklet(0));
509 AliDebug(3, "No Tracklet in ly[0]. Skip track.");
512 // check radial position
513 Double_t x = tin->GetX();
514 if(TMath::Abs(x-fTracklet->GetX())>1.e-3){
515 AliDebug(1, Form("Tracklet did not match Track. dx[cm]=%+4.1f", x-fTracklet->GetX()));
519 Int_t bc(fkESD->GetTOFbc()%2);
520 const Double_t *parR(tin->GetParameter());
521 Double_t dyt(parR[0] - fTracklet->GetYfit(0)), dzt(parR[1] - fTracklet->GetZfit(0)),
522 phit(fTracklet->GetYfit(1)),
523 tilt(fTracklet->GetTilt());
525 // correct for tilt rotation
526 Double_t dy = dyt - dzt*tilt,
528 phit += tilt*parR[3];
529 Double_t dphi = TMath::ASin(parR[2])-TMath::ATan(phit);
535 val[kSpeciesChgRC]= fTracklet->IsRowCross()?0:fSpecies;
536 // val[kPt] = GetPtBin(fPt);
539 val[kPrez] = dphi*TMath::RadToDeg();
542 if(!HasMCdata()) return NULL; // H->Projection(kEta, kPhi);
543 if(!(H = (THnSparseI*)fContainer->At(kMCtrackIn))) {
544 AliError(Form("Missing container @ %d", Int_t(kMCtrackIn)));
550 Float_t pt0, eta, x0=fTracklet->GetX0(), y0, z0, dydx0, dzdx0;
551 if(!fkMC->GetDirections(x0, y0, z0, dydx0, dzdx0, pt0, eta, s)) return NULL;
552 dyt = y0 - fTracklet->GetYfit(0);
553 dzt = z0 - fTracklet->GetZfit(0);
554 phit= fTracklet->GetYfit(1) + tilt*dzdx0;
555 Float_t phi = TMath::ATan2(y0, x0);
558 dphi= TMath::ASin(dydx0)-TMath::ATan(phit);
560 Int_t pdg = fkMC->GetPDG(),
561 sIdx(AliTRDpidUtil::Pdg2Pid(TMath::Abs(pdg))+1), // species index
563 if(!fDBPDG) fDBPDG=TDatabasePDG::Instance();
564 TParticlePDG *ppdg(fDBPDG->GetParticle(pdg));
565 if(ppdg) sign = ppdg->Charge() > 0. ? 1 : -1;
568 val[kBC] = (bc>=kNbunchCross)?(kNbunchCross-1):bc;
571 val[kSpeciesChgRC]= fTracklet->IsRowCross()?0:sign*(sIdx+1);
572 // val[kPt] = GetPtBin(pt0);
575 val[kPrez] = dphi*TMath::RadToDeg();
578 return NULL; //H->Projection(kEta, kPhi);
581 //________________________________________________________
582 TH1* AliTRDresolution::PlotTrackOut(const AliTRDtrackV1 *track)
584 // Store resolution/pulls of Kalman after last update with the TRD information
585 // at the radial position of the first tracklet. The following points are used
587 // - the (y,z,snp) of the first TRD tracklet
588 // - the (y, z, snp, tgl, pt) of the MC track reference
590 // Additionally the momentum resolution/pulls are calculated for usage in the
593 if(track) fkTrack = track;
597 //________________________________________________________
598 TH1* AliTRDresolution::PlotMC(const AliTRDtrackV1 *track)
601 // Plot MC distributions
605 AliDebug(2, "No MC defined. Results will not be available.");
608 if(track) fkTrack = track;
610 AliDebug(4, "No Track defined.");
614 AliWarning("No output container defined.");
617 // retriev track characteristics
618 Int_t pdg = fkMC->GetPDG(),
619 sIdx(AliTRDpidUtil::Pdg2Pid(TMath::Abs(pdg))+1), // species index
622 label(fkMC->GetLabel()),
624 if(!fDBPDG) fDBPDG=TDatabasePDG::Instance();
625 TParticlePDG *ppdg(fDBPDG->GetParticle(pdg));
626 if(ppdg) sign = ppdg->Charge() > 0. ? 1 : -1;
628 TObjArray *arr(NULL);TH1 *h(NULL);
629 AliTRDgeometry *geo(AliTRDinfoGen::Geometry());
630 AliTRDseedV1 *fTracklet(NULL); TObjArray *clInfoArr(NULL);
632 Double_t xAnode, x, y, z, pt, dydx, dzdx, dzdl;
633 Float_t pt0, x0, y0, z0, dx, dy, dz, dydx0, dzdx0;
634 Double_t covR[7]/*, cov[3]*/;
637 // get first detector
639 for(Int_t ily=0; ily<AliTRDgeometry::kNlayer; ily++){
640 if(!(fTracklet = fkTrack->GetTracklet(ily))) continue;
641 det = fTracklet->GetDetector();
645 TVectorD X(12), Y(12), Z(12), dX(12), dY(12), dZ(12), vPt(12), dPt(12), budget(12), cCOV(12*15);
647 m = fkTrack->GetMass();
648 if(fkMC->PropagateKalman(&X, &Y, &Z, &dX, &dY, &dZ, &vPt, &dPt, &budget, &cCOV, m)){
649 (*DebugStream()) << "MCkalman"
666 for(Int_t ily=0; ily<AliTRDgeometry::kNlayer; ily++){
667 if(!(fTracklet = fkTrack->GetTracklet(ily)))/* ||
668 !fTracklet->IsOK())*/ continue;
670 sgm[2] = fTracklet->GetDetector();
671 sgm[0] = AliTRDgeometry::GetSector(sgm[2]);
672 sgm[1] = sgm[0] * AliTRDgeometry::kNstack + AliTRDgeometry::GetStack(sgm[2]);
673 Double_t tilt(fTracklet->GetTilt())
676 ,cost(TMath::Sqrt(corr));
677 x0 = fTracklet->GetX0();
678 //radial shift with respect to the MC reference (radial position of the pad plane)
679 x= fTracklet->GetX();
680 Bool_t rc(fTracklet->IsRowCross()); Float_t eta;
681 if(!fkMC->GetDirections(x0, y0, z0, dydx0, dzdx0, pt0, eta, s)) continue;
682 xAnode = fTracklet->GetX0();
684 // MC track position at reference radial position
687 (*DebugStream()) << "MC"
699 Float_t ymc = y0 - dx*dydx0;
700 Float_t zmc = z0 - dx*dzdx0;
701 //p = pt0*TMath::Sqrt(1.+dzdx0*dzdx0); // pt -> p
703 // Kalman position at reference radial position
705 dydx = fTracklet->GetYref(1);
706 dzdx = fTracklet->GetZref(1);
707 dzdl = fTracklet->GetTgl();
708 y = fTracklet->GetYref(0) - dx*dydx;
710 z = fTracklet->GetZref(0) - dx*dzdx;
712 pt = TMath::Abs(fTracklet->GetPt());
713 fTracklet->GetCovRef(covR);
715 arr = (TObjArray*)((TObjArray*)fContainer->At(kMCtrack))->At(ily);
716 // y resolution/pulls
717 if(pt0>fPtThreshold) ((TH3S*)arr->At(0))->Fill(dydx0, dy, sgm[fSegmentLevel]);
718 ((TH3S*)arr->At(1))->Fill(sgm[fSegmentLevel], dy/TMath::Sqrt(covR[0]), dz/TMath::Sqrt(covR[2]));
719 // z resolution/pulls
720 ((TH2S*)arr->At(2))->Fill(dzdx0, dz);
721 ((TH3S*)arr->At(3))->Fill(dzdx0, dz/TMath::Sqrt(covR[2]), 0);
722 // phi resolution/ snp pulls
723 Double_t dtgp = (dydx - dydx0)/(1.- dydx*dydx0);
724 ((TH2I*)arr->At(4))->Fill(dydx0, TMath::ATan(dtgp));
725 Double_t dsnp = dydx/TMath::Sqrt(1.+dydx*dydx) - dydx0/TMath::Sqrt(1.+dydx0*dydx0);
726 ((TH2I*)arr->At(5))->Fill(dydx0, dsnp/TMath::Sqrt(covR[3]));
727 // theta resolution/ tgl pulls
728 Double_t dzdl0 = dzdx0/TMath::Sqrt(1.+dydx0*dydx0),
729 dtgl = (dzdl - dzdl0)/(1.- dzdl*dzdl0);
730 ((TH2I*)arr->At(6))->Fill(dzdl0,
732 ((TH2I*)arr->At(7))->Fill(dzdl0, (dzdl - dzdl0)/TMath::Sqrt(covR[4]));
733 // pt resolution \\ 1/pt pulls \\ p resolution for PID
734 Double_t p0 = TMath::Sqrt(1.+ dzdl0*dzdl0)*pt0,
735 p = TMath::Sqrt(1.+ dzdl*dzdl)*pt;
736 ((TH3S*)((TObjArray*)arr->At(8)))->Fill(pt0, pt/pt0-1., sign*sIdx);
737 ((TH3S*)((TObjArray*)arr->At(9)))->Fill(1./pt0, (1./pt-1./pt0)/TMath::Sqrt(covR[6]), sign*sIdx);
738 ((TH3S*)((TObjArray*)arr->At(10)))->Fill(p0, p/p0-1., sign*sIdx);
740 // Fill Debug stream for Kalman track
742 (*DebugStream()) << "MCtrack"
754 // recalculate tracklet based on the MC info
755 AliTRDseedV1 tt(*fTracklet);
756 tt.SetZref(0, z0 - (x0-xAnode)*dzdx0);
757 tt.SetZref(1, dzdx0);
758 tt.SetReconstructor(AliTRDinfoGen::Reconstructor());
760 x= tt.GetX();y= tt.GetY();z= tt.GetZ();
761 dydx = tt.GetYfit(1);
767 Float_t dphi = (dydx - dydx0);
768 dphi /= (1.- dydx*dydx0);
770 // add tracklet residuals for y and dydx
771 arr = (TObjArray*)fContainer->At(kMCtracklet);
773 if(pt0>fPtThreshold) ((TH3S*)arr->At(0))->Fill(dydx0, dy, sgm[fSegmentLevel]);
774 if(tt.GetS2Y()>0. && tt.GetS2Z()>0.) ((TH3S*)arr->At(1))->Fill(sgm[fSegmentLevel], dy/TMath::Sqrt(tt.GetS2Y()), dz/TMath::Sqrt(tt.GetS2Z()));
775 ((TH3S*)arr->At(2))->Fill(dzdl0, dz, rc);
776 if(tt.GetS2Z()>0.) ((TH3S*)arr->At(3))->Fill(dzdl0, dz/TMath::Sqrt(tt.GetS2Z()), rc);
777 ((TH2I*)arr->At(4))->Fill(dydx0, TMath::ATan(dphi));
779 // Fill Debug stream for tracklet
781 Float_t s2y = tt.GetS2Y();
782 Float_t s2z = tt.GetS2Z();
783 (*DebugStream()) << "MCtracklet"
794 AliTRDpadPlane *pp = geo->GetPadPlane(ily, AliTRDgeometry::GetStack(sgm[2]));
795 Float_t zr0 = pp->GetRow0() + pp->GetAnodeWireOffset();
796 //Double_t exb = AliTRDCommonParam::Instance()->GetOmegaTau(1.5);
798 arr = (TObjArray*)fContainer->At(kMCcluster);
799 AliTRDcluster *c = NULL;
800 tt.ResetClusterIter(kFALSE);
801 while((c = tt.PrevCluster())){
802 Float_t q = TMath::Abs(c->GetQ());
803 x = c->GetX();//+fXcorr[c->GetDetector()][c->GetLocalTimeBin()]; y = c->GetY();z = c->GetZ();
807 dy = cost*(y - ymc - tilt*(z-zmc));
808 dz = cost*(z - zmc + tilt*(y-ymc));
811 if(q>20. && q<250. && pt0>fPtThreshold && c->IsInChamber()){
812 ((TH3S*)arr->At(0))->Fill(dydx0, dy, sgm[fSegmentLevel]);
813 ((TH3S*)arr->At(1))->Fill(sgm[fSegmentLevel], dy/TMath::Sqrt(c->GetSigmaY2()), dz/TMath::Sqrt(c->GetSigmaZ2()));
816 // Fill calibration container
817 Float_t d = zr0 - zmc;
818 d -= ((Int_t)(2 * d)) / 2.0;
819 if (d > 0.25) d = 0.5 - d;
820 AliTRDclusterInfo *clInfo = new AliTRDclusterInfo;
821 clInfo->SetCluster(c);
822 clInfo->SetMC(pdg, label);
823 clInfo->SetGlobalPosition(ymc, zmc, dydx0, dzdx0);
824 clInfo->SetResolution(dy);
825 clInfo->SetAnisochronity(d);
826 clInfo->SetDriftLength(dx);
827 clInfo->SetTilt(tilt);
828 if(fMCcl) fMCcl->Add(clInfo);
829 else AliDebug(1, "MCcl exchange container missing. Activate by calling \"InitExchangeContainers()\"");
832 clInfoArr=new TObjArray(AliTRDseedV1::kNclusters);
833 clInfoArr->SetOwner(kFALSE);
835 clInfoArr->Add(clInfo);
839 if(DebugLevel()>=5 && clInfoArr){
840 (*DebugStream()) << "MCcluster"
841 <<"clInfo.=" << clInfoArr
846 if(clInfoArr) delete clInfoArr;
851 //__________________________________________________________________________
852 Int_t AliTRDresolution::GetPtBin(Float_t pt)
854 // Find pt bin according to local pt segmentation
856 while(ipt<AliTRDresolution::kNpt){
857 if(pt<fgPtBin[ipt]) break;
860 return TMath::Max(0,ipt);
863 //________________________________________________________
864 Float_t AliTRDresolution::GetMeanWithBoundary(TH1 *h, Float_t zm, Float_t zM, Float_t dz) const
866 // return mean of histogram "h"
867 // if histo is empty returns -infinity
868 // if few entries returns zM+epsilon
869 // if mean less than zm returns zm-epsilon
871 Int_t ne(Int_t(h->GetEntries()));
872 if(ne==0) return -1.e+5;
873 else if(ne<20) return zM+0.5*dz;
875 Float_t val(h->GetMean());
876 if(val<zm) return zm-0.5*dz;
877 else if(val>zM) return zM-0.5*dz;
882 //________________________________________________________
883 Bool_t AliTRDresolution::GetRefFigure(Int_t ifig)
886 // Get the reference figures
890 AliWarning("Please provide a canvas to draw results.");
893 /* Int_t selection[100], n(0), selStart(0); //
894 Int_t ly0(0), dly(5);
895 TList *l(NULL); TVirtualPad *pad(NULL); */
900 AliWarning(Form("Reference plot [%d] missing result", ifig));
905 //________________________________________________________
906 void AliTRDresolution::MakePtSegmentation(Float_t pt0, Float_t dpt)
909 for(Int_t j(0); j<=kNpt; j++){
910 pt0+=(TMath::Exp(j*j*dpt)-1.);
915 //________________________________________________________
916 void AliTRDresolution::MakeSummary()
918 // Build summary plots
921 AliError("Missing results");
925 TVirtualPad *p(NULL); TCanvas *cOut(NULL);
926 TObjArray *arr(NULL);
928 // cluster resolution
930 gStyle->SetPalette(1);
931 cOut = new TCanvas(Form("TRDsummary%s_%d", GetName(), iSumPlot++), "Cluster Resolution", 1024, 768);
932 cOut->Divide(3,2, 2.e-3, 2.e-3);
933 arr = (TObjArray*)fProj->At(kCluster);
934 for(Int_t iplot(0); iplot<fgNproj[kCluster]; iplot++){
935 p=cOut->cd(iplot+1); p->SetRightMargin(0.1572581);p->SetTopMargin(0.08262712);
936 ((TH2*)arr->At(iplot))->Draw("colz");
938 cOut->SaveAs(Form("%s.gif", cOut->GetName()));
941 // trackIn systematic
944 for (int i=1;i<49;i++) palette[i] = 50+i; palette[0]=kMagenta; palette[49]=kBlack;
945 gStyle->SetPalette(50, palette);
946 cOut = new TCanvas(Form("TRDsummary%s_%d", GetName(), iSumPlot++), "Track IN Resolution", 1024, 768);
947 cOut->Divide(3,2, 2.e-3, 2.e-3);
948 arr = (TObjArray*)fProj->At(kTrackIn);
949 for(Int_t iplot(0); iplot<fgNproj[kTrackIn]; iplot++){
950 p=cOut->cd(iplot+1); p->SetRightMargin(0.1572581);p->SetTopMargin(0.08262712);
951 ((TH2*)arr->At(iplot))->Draw("colz");
953 cOut->SaveAs(Form("%s.gif", cOut->GetName()));
956 gStyle->SetPalette(1);
959 //________________________________________________________
960 void AliTRDresolution::GetRange(TH2 *h2, Char_t mod, Float_t *range)
962 // Returns the range of the bulk of data in histogram h2. Removes outliers.
963 // The "range" vector should be initialized with 2 elements
964 // Option "mod" can be any of
965 // - 0 : gaussian like distribution
966 // - 1 : tailed distribution
968 Int_t nx(h2->GetNbinsX())
969 , ny(h2->GetNbinsY())
971 Double_t *data=new Double_t[n];
972 for(Int_t ix(1), in(0); ix<=nx; ix++){
973 for(Int_t iy(1); iy<=ny; iy++)
974 data[in++] = h2->GetBinContent(ix, iy);
977 AliMathBase::EvaluateUni(n, data, mean, sigm, Int_t(n*.8));
979 range[0]=mean-3.*sigm; range[1]=mean+3.*sigm;
980 if(mod==1) range[0]=TMath::Max(Float_t(1.e-3), range[0]);
981 AliDebug(2, Form("h[%s] range0[%f %f]", h2->GetName(), range[0], range[1]));
982 TH1S h1("h1SF0", "", 100, range[0], range[1]);
987 case 0:// gaussian distribution
989 TF1 fg("fg", "gaus", mean-3.*sigm, mean+3.*sigm);
991 mean=fg.GetParameter(1); sigm=fg.GetParameter(2);
992 range[0] = mean-2.5*sigm;range[1] = mean+2.5*sigm;
993 AliDebug(2, Form(" rangeG[%f %f]", range[0], range[1]));
996 case 1:// tailed distribution
998 Int_t bmax(h1.GetMaximumBin());
999 Int_t jBinMin(1), jBinMax(100);
1000 for(Int_t ibin(bmax); ibin--;){
1001 if(h1.GetBinContent(ibin)<1.){
1002 jBinMin=ibin; break;
1005 for(Int_t ibin(bmax); ibin++;){
1006 if(h1.GetBinContent(ibin)<1.){
1007 jBinMax=ibin; break;
1010 range[0]=h1.GetBinCenter(jBinMin); range[1]=h1.GetBinCenter(jBinMax);
1011 AliDebug(2, Form(" rangeT[%f %f]", range[0], range[1]));
1020 //________________________________________________________
1021 Bool_t AliTRDresolution::MakeProjectionCluster()
1024 Int_t cidx = kCluster;
1025 if(fProj && fProj->At(cidx)) return kTRUE;
1027 AliError("Missing data container.");
1031 if(!(H = (THnSparse*)fContainer->At(cidx))){
1032 AliError(Form("Missing/Wrong data @ %d.", cidx));
1036 TAxis *aphi(H->GetAxis(kPhi)),
1037 *aeta(H->GetAxis(kEta)),
1038 *as(H->GetAxis(kSpeciesChgRC)),
1039 //*apt(H->GetAxis(kPt)),
1040 *ay(H->GetAxis(kYrez));
1041 //*az(H->GetAxis(kZrez)),
1042 //*ap(H->GetAxis(kPrez));
1043 Int_t neta(aeta->GetNbins()), nphi(aphi->GetNbins()), rcBin(as->GetNbins()/2 + 1);
1044 TH3I *h3[fgNproj[cidx]];
1045 for(Int_t ily(0); ily<AliTRDgeometry::kNlayer; ily++){
1046 h3[ily] = new TH3I(Form("h3CL%d", ily), Form("r-#phi residuals @ ly[%d];%s;%s;%s", ily, aeta->GetTitle(), aphi->GetTitle(), ay->GetTitle()),
1047 neta, aeta->GetXmin(), aeta->GetXmax(),
1048 nphi, aphi->GetXmin(), aphi->GetXmax(),
1049 ay->GetNbins(), ay->GetXmin(), ay->GetXmax());
1051 Int_t coord[AliTRDresolution::kNdim]; memset(coord, 0, sizeof(Int_t) * AliTRDresolution::kNdim); Double_t v = 0.;
1052 for (Long64_t ib(0); ib < H->GetNbins(); ib++) {
1053 v = H->GetBinContent(ib, coord);
1055 if(coord[kSpeciesChgRC]==rcBin) continue; // row cross
1056 Int_t ily(coord[kBC]-1);
1057 h3[ily]->AddBinContent(h3[ily]->GetBin(coord[kEta], coord[kPhi], coord[kYrez]), v);
1060 TF1 fg("fg", "gaus", ay->GetXmin(), ay->GetXmax());
1062 AliInfo("Building array of projections ...");
1063 fProj = new TObjArray(kNclasses); fProj->SetOwner(kTRUE);
1065 TObjArray *arr(NULL);
1066 fProj->AddAt(arr = new TObjArray(fgNproj[cidx]), cidx);
1069 for(Int_t ily(0); ily<AliTRDgeometry::kNlayer; ily++){
1070 arr->AddAt(h2 = new TH2F(Form("h2CLs%d", ily),
1071 Form("Cl Resolution Ly[%d];%s;%s;#sigmay [#mum]", ily, aeta->GetTitle(), aphi->GetTitle()),
1072 neta, aeta->GetXmin(), aeta->GetXmax(),
1073 nphi, aphi->GetXmin(), aphi->GetXmax()), ily);
1074 TAxis *ax = h2->GetZaxis();
1075 ax->CenterTitle(); ax->SetTitleOffset(1.3);
1076 ax->SetRangeUser(250, 500);
1077 for(Int_t iphi(1); iphi<=nphi; iphi++){
1078 for(Int_t ieta(1); ieta<=neta; ieta++){
1079 TH1 *h = h3[ily]->ProjectionZ(Form("h1CLs%d", ily), ieta, ieta, iphi, iphi);
1080 Int_t ne(Int_t(h->GetEntries()));
1081 if(ne<100.) h2->SetBinContent(ieta, iphi, -999);
1083 fg.SetParameter(0, ne);fg.SetParameter(1, 0.);fg.SetParameter(2, 0.05);
1085 Float_t val=TMath::Max(250., 1.e4*fg.GetParameter(2));
1086 h2->SetBinContent(ieta, iphi, val);
1091 for(Int_t iproj(0); iproj<fgNproj[cidx]; iproj++) delete h3[iproj];
1095 //________________________________________________________
1096 Bool_t AliTRDresolution::MakeProjectionTracklet()
1099 Int_t cidx = kTracklet;
1100 if(fProj && fProj->At(cidx)) return kTRUE;
1102 AliError("Missing data container.");
1106 if(!(H = (THnSparse*)fContainer->At(cidx))){
1107 // AliError(Form("Missing/Wrong data @ %d.", cidx));
1110 AliDebug(2, Form("%s[%d]", H->GetName(), H->GetNdimensions()));
1114 //________________________________________________________
1115 Bool_t AliTRDresolution::MakeProjectionTrackIn()
1119 Int_t cidx = kTrackIn;
1120 if(fProj && fProj->At(cidx)) return kTRUE;
1122 AliError("Missing data container.");
1126 if(!(H = (THnSparse*)fContainer->At(cidx))){
1127 AliError(Form("Missing/Wrong data @ %d.", Int_t(cidx)));
1131 Int_t coord[kNdim]; memset(coord, 0, sizeof(Int_t) * kNdim); Double_t v = 0.;
1132 TAxis //*abc(H->GetAxis(kBC)),
1133 *aphi(H->GetAxis(kPhi)),
1134 *aeta(H->GetAxis(kEta)),
1135 //*as(H->GetAxis(kSpeciesChgRC)),
1136 //*apt(H->GetAxis(kPt)),
1137 *ay(H->GetAxis(kYrez)),
1138 *az(H->GetAxis(kZrez)),
1139 *ap(H->GetAxis(kPrez));
1140 Int_t neta(aeta->GetNbins()), nphi(aphi->GetNbins());
1141 TH3I *h3[fgNproj[cidx]];
1142 h3[0] = new TH3I("h3TI0", Form("r-#phi residuals for neg tracks;%s;%s;%s", aeta->GetTitle(), aphi->GetTitle(), ay->GetTitle()),
1143 neta, aeta->GetXmin(), aeta->GetXmax(),
1144 nphi, aphi->GetXmin(), aphi->GetXmax(),
1145 ay->GetNbins(), ay->GetXmin(), ay->GetXmax());
1146 h3[1] = (TH3I*)h3[0]->Clone("h3TI1"); h3[1]->SetTitle("r-#phi residuals for pos tracks");
1147 h3[2] = new TH3I("h3TI2", Form("z residuals for row cross;%s;%s;%s", aeta->GetTitle(), aphi->GetTitle(), az->GetTitle()),
1148 neta, aeta->GetXmin(), aeta->GetXmax(),
1149 nphi, aphi->GetXmin(), aphi->GetXmax(),
1150 az->GetNbins(), az->GetXmin(), az->GetXmax());
1151 h3[3] = new TH3I("h3TI3", Form("angular residuals for neg tracks;%s;%s;%s", aeta->GetTitle(), aphi->GetTitle(), ap->GetTitle()),
1152 neta, aeta->GetXmin(), aeta->GetXmax(),
1153 nphi, aphi->GetXmin(), aphi->GetXmax(),
1154 ap->GetNbins(), ap->GetXmin(), ap->GetXmax());
1155 h3[4] = (TH3I*)h3[3]->Clone("h3TI4"); h3[4]->SetTitle("angular residuals for pos tracks");
1156 for (Long64_t ib(0); ib < H->GetNbins(); ib++) {
1157 v = H->GetBinContent(ib, coord);
1159 if(coord[kBC]>1) continue; // bunch cross cut
1160 // species selection
1161 if(coord[kSpeciesChgRC]<6){
1162 h3[0]->AddBinContent(
1163 h3[0]->GetBin(coord[kEta], coord[kPhi], coord[kYrez]), v);
1164 h3[3]->AddBinContent(
1165 h3[3]->GetBin(coord[kEta], coord[kPhi], coord[kPrez]), v);
1166 } else if(coord[kSpeciesChgRC]==6) {
1167 h3[2]->AddBinContent(
1168 h3[2]->GetBin(coord[kEta], coord[kPhi], coord[kYrez]), v);
1169 } else if(coord[kSpeciesChgRC]>6) {
1170 h3[1]->AddBinContent(
1171 h3[1]->GetBin(coord[kEta], coord[kPhi], coord[kYrez]), v);
1172 h3[4]->AddBinContent(
1173 h3[4]->GetBin(coord[kEta], coord[kPhi], coord[kPrez]), v);
1177 AliInfo("Building array of projections ...");
1178 fProj = new TObjArray(kNclasses); fProj->SetOwner(kTRUE);
1180 TObjArray *arr(NULL);
1181 fProj->AddAt(arr = new TObjArray(fgNproj[cidx]), cidx);
1184 for(Int_t iproj(0); iproj<fgNproj[cidx]; iproj++){
1185 TAxis *ax(h3[iproj]->GetZaxis());
1186 Float_t zm(ax->GetXmin()/3.), zM(ax->GetXmax()/3.), dz=(zM-zm)/50;
1187 arr->AddAt(h2 = new TH2F(Form("h2TI%d", iproj),
1188 Form("%s;%s;%s;%s", h3[iproj]->GetTitle(), aeta->GetTitle(), aphi->GetTitle(), ax->GetTitle()),
1189 neta, aeta->GetXmin(), aeta->GetXmax(),
1190 nphi, aphi->GetXmin(), aphi->GetXmax()), iproj);
1192 h2->GetZaxis()->CenterTitle();
1193 h2->GetZaxis()->SetRangeUser(zm, zM);
1195 for(Int_t iphi(1); iphi<=nphi; iphi++){
1196 for(Int_t ieta(1); ieta<=neta; ieta++){
1197 TH1 *h = h3[iproj]->ProjectionZ(Form("hy%d", iproj), ieta, ieta, iphi, iphi);
1198 h2->SetBinContent(ieta, iphi, GetMeanWithBoundary(h, zm, zM, dz));
1202 // h2[5] = (TH2F*)h2[0]->Clone("h25");
1203 // h2[5]->SetTitle("Systematic shift between neg/pos tracks");
1204 // h2[5]->SetZTitle("#Delta(#Delta^{-}y - #Delta^{+}y) [cm]"); h2[5]->Reset();
1205 // h2[6] = (TH2F*)h2[1]->Clone("h26");
1206 // h2[6]->SetTitle("Average shift of pos&neg tracks");
1207 // h2[6]->SetZTitle("<#Delta^{-}y, #Delta^{+}y> [cm]"); h2[6]->Reset();
1208 // for(Int_t iphi(1); iphi<=nphi; iphi++){
1209 // for(Int_t ieta(1); ieta<=neta; ieta++){
1210 // Float_t neg = h2[0]->GetBinContent(ieta, iphi),
1211 // pos = h2[1]->GetBinContent(ieta, iphi);
1212 // if(neg<-100 || pos<-100){
1213 // h2[5]->SetBinContent(ieta, iphi, -999.);
1214 // h2[6]->SetBinContent(ieta, iphi, -999.);
1216 // h2[5]->SetBinContent(ieta, iphi, neg-pos);
1217 // h2[6]->SetBinContent(ieta, iphi, 0.5*(neg+pos));
1222 for(Int_t iproj(0); iproj<fgNproj[cidx]; iproj++) delete h3[iproj];
1228 //________________________________________________________
1229 Bool_t AliTRDresolution::PostProcess()
1231 // Fit, Project, Combine, Extract values from the containers filled during execution
1234 AliError("ERROR: list not available");
1240 TF1 fg("fGauss", "gaus", -.5, .5);
1241 // Landau for charge resolution
1242 TF1 fch("fClCh", "landau", 0., 1000.);
1243 // Landau for e+- pt resolution
1244 TF1 fpt("fPt", "landau", -0.1, 0.2);
1246 //PROCESS EXPERIMENTAL DISTRIBUTIONS
1247 // Clusters residuals
1248 if(!MakeProjectionCluster()) return kFALSE;
1250 // Tracklet residual/pulls
1251 if(!MakeProjectionTracklet()) return kFALSE;
1253 // TRDin residual/pulls
1254 if(!MakeProjectionTrackIn()) return kFALSE;
1256 // TRDout residual/pulls
1257 // if(!MakeProjectionTrackOut()) return kFALSE;
1260 if(!HasMCdata()) return kTRUE;
1263 //PROCESS MC RESIDUAL DISTRIBUTIONS
1265 // CLUSTER Y RESOLUTION/PULLS
1266 // if(!MakeProjectionClusterMC()) return kFALSE;
1269 // TRACKLET RESOLUTION/PULLS
1270 // if(!MakeProjectionTrackletMC()) return kFALSE;
1273 // TRACK RESOLUTION/PULLS
1274 /* Process3Darray(kMCtrack, 0, &fg, 1.e4); // y
1275 Process3DlinkedArray(kMCtrack, 1, &fg); // y PULL
1276 Process3Darray(kMCtrack, 2, &fg, 1.e4); // z
1277 Process3Darray(kMCtrack, 3, &fg); // z PULL
1278 Process2Darray(kMCtrack, 4, &fg, 1.e3); // phi
1279 Process2Darray(kMCtrack, 5, &fg); // snp PULL
1280 Process2Darray(kMCtrack, 6, &fg, 1.e3); // theta
1281 Process2Darray(kMCtrack, 7, &fg); // tgl PULL
1282 Process3Darray(kMCtrack, 8, &fg, 1.e2); // pt resolution
1283 Process3Darray(kMCtrack, 9, &fg); // 1/pt pulls
1284 Process3Darray(kMCtrack, 10, &fg, 1.e2); // p resolution*/
1285 // if(!MakeProjectionTrackMC(kMCtrack)) return kFALSE;
1288 // TRACK TRDin RESOLUTION/PULLS
1289 // if(!MakeProjectionTrackMC(kMCtrackIn)) return kFALSE;
1292 // TRACK TRDout RESOLUTION/PULLS
1293 // if(!MakeProjectionTrackMC(kMCtrackOut)) return kFALSE;
1300 //________________________________________________________
1301 void AliTRDresolution::Terminate(Option_t *opt)
1303 AliTRDrecoTask::Terminate(opt);
1304 if(HasPostProcess()) PostProcess();
1307 //________________________________________________________
1308 void AliTRDresolution::AdjustF1(TH1 *h, TF1 *f)
1310 // Helper function to avoid duplication of code
1311 // Make first guesses on the fit parameters
1313 // find the intial parameters of the fit !! (thanks George)
1314 Int_t nbinsy = Int_t(.5*h->GetNbinsX());
1316 for(Int_t jbin=nbinsy-4; jbin<=nbinsy+4; jbin++) sum+=h->GetBinContent(jbin); sum/=9.;
1317 f->SetParLimits(0, 0., 3.*sum);
1318 f->SetParameter(0, .9*sum);
1319 Double_t rms = h->GetRMS();
1320 f->SetParLimits(1, -rms, rms);
1321 f->SetParameter(1, h->GetMean());
1323 f->SetParLimits(2, 0., 2.*rms);
1324 f->SetParameter(2, rms);
1325 if(f->GetNpar() <= 4) return;
1327 f->SetParLimits(3, 0., sum);
1328 f->SetParameter(3, .1*sum);
1330 f->SetParLimits(4, -.3, .3);
1331 f->SetParameter(4, 0.);
1333 f->SetParLimits(5, 0., 1.e2);
1334 f->SetParameter(5, 2.e-1);
1337 //________________________________________________________
1338 TObjArray* AliTRDresolution::BuildMonitorContainerCluster(const char* name, Bool_t expand, Float_t range)
1340 // Build performance histograms for AliTRDcluster.vs TRD track or MC
1341 // - y reziduals/pulls
1343 TObjArray *arr = new TObjArray(2);
1344 arr->SetName(name); arr->SetOwner();
1345 TH1 *h(NULL); char hname[100], htitle[300];
1347 // tracklet resolution/pull in y direction
1348 snprintf(hname, 100, "%s_%s_Y", GetNameId(), name);
1349 snprintf(htitle, 300, "Y res for \"%s\" @ %s;tg(#phi);#Delta y [cm];%s", GetNameId(), name, "Detector");
1350 Float_t rr = range<0.?fDyRange:range;
1351 if(!(h = (TH3S*)gROOT->FindObject(hname))){
1353 if(expand) nybins*=2;
1354 h = new TH3S(hname, htitle,
1355 48, -.48, .48, // phi
1357 nybins, -0.5, nybins-0.5);// segment
1360 snprintf(hname, 100, "%s_%s_YZpull", GetNameId(), name);
1361 snprintf(htitle, 300, "YZ pull for \"%s\" @ %s;%s;#Delta y / #sigma_{y};#Delta z / #sigma_{z}", GetNameId(), name, "Detector");
1362 if(!(h = (TH3S*)gROOT->FindObject(hname))){
1363 h = new TH3S(hname, htitle, 540, -0.5, 540-0.5, 100, -4.5, 4.5, 100, -4.5, 4.5);
1370 //________________________________________________________
1371 TObjArray* AliTRDresolution::BuildMonitorContainerTracklet(const char* name, Bool_t expand)
1373 // Build performance histograms for AliExternalTrackParam.vs TRD tracklet
1374 // - y reziduals/pulls
1375 // - z reziduals/pulls
1377 TObjArray *arr = BuildMonitorContainerCluster(name, expand, 0.05);
1379 TH1 *h(NULL); char hname[100], htitle[300];
1381 // tracklet resolution/pull in z direction
1382 snprintf(hname, 100, "%s_%s_Z", GetNameId(), name);
1383 snprintf(htitle, 300, "Z res for \"%s\" @ %s;tg(#theta);#Delta z [cm]", GetNameId(), name);
1384 if(!(h = (TH2S*)gROOT->FindObject(hname))){
1385 h = new TH2S(hname, htitle, 50, -1., 1., 100, -.05, .05);
1388 snprintf(hname, 100, "%s_%s_Zpull", GetNameId(), name);
1389 snprintf(htitle, 300, "Z pull for \"%s\" @ %s;tg(#theta);#Delta z / #sigma_{z};row cross", GetNameId(), name);
1390 if(!(h = (TH3S*)gROOT->FindObject(hname))){
1391 h = new TH3S(hname, htitle, 50, -1., 1., 100, -5.5, 5.5, 2, -0.5, 1.5);
1392 h->GetZaxis()->SetBinLabel(1, "no RC");
1393 h->GetZaxis()->SetBinLabel(2, "RC");
1397 // tracklet to track phi resolution
1398 snprintf(hname, 100, "%s_%s_PHI", GetNameId(), name);
1399 snprintf(htitle, 300, "#Phi res for \"%s\" @ %s;tg(#phi);#Delta #phi [rad];%s", GetNameId(), name, "Detector");
1401 if(!(h = (TH3S*)gROOT->FindObject(hname))){
1402 h = new TH3S(hname, htitle, 48, -.48, .48, 100, -.5, .5, nsgms, -0.5, nsgms-0.5);
1409 //________________________________________________________
1410 TObjArray* AliTRDresolution::BuildMonitorContainerTrack(const char* name)
1412 // Build performance histograms for AliExternalTrackParam.vs MC
1413 // - y resolution/pulls
1414 // - z resolution/pulls
1415 // - phi resolution, snp pulls
1416 // - theta resolution, tgl pulls
1417 // - pt resolution, 1/pt pulls, p resolution
1419 TObjArray *arr = BuildMonitorContainerTracklet(name);
1421 TH1 *h(NULL); char hname[100], htitle[300];
1425 snprintf(hname, 100, "%s_%s_SNPpull", GetNameId(), name);
1426 snprintf(htitle, 300, "SNP pull for \"%s\" @ %s;tg(#phi);#Delta snp / #sigma_{snp};entries", GetNameId(), name);
1427 if(!(h = (TH2I*)gROOT->FindObject(hname))){
1428 h = new TH2I(hname, htitle, 60, -.3, .3, 100, -4.5, 4.5);
1433 snprintf(hname, 100, "%s_%s_THT", GetNameId(), name);
1434 snprintf(htitle, 300, "#Theta res for \"%s\" @ %s;tg(#theta);#Delta #theta [rad];entries", GetNameId(), name);
1435 if(!(h = (TH2I*)gROOT->FindObject(hname))){
1436 h = new TH2I(hname, htitle, 100, -1., 1., 100, -5e-3, 5e-3);
1440 snprintf(hname, 100, "%s_%s_TGLpull", GetNameId(), name);
1441 snprintf(htitle, 300, "TGL pull for \"%s\" @ %s;tg(#theta);#Delta tgl / #sigma_{tgl};entries", GetNameId(), name);
1442 if(!(h = (TH2I*)gROOT->FindObject(hname))){
1443 h = new TH2I(hname, htitle, 100, -1., 1., 100, -4.5, 4.5);
1447 const Int_t kNdpt(150);
1448 const Int_t kNspc = 2*AliPID::kSPECIES+1;
1449 Float_t lPt=0.1, lDPt=-.1, lSpc=-5.5;
1450 Float_t binsPt[kNpt+1], binsSpc[kNspc+1], binsDPt[kNdpt+1];
1451 for(Int_t i=0;i<kNpt+1; i++,lPt=TMath::Exp(i*.15)-1.) binsPt[i]=lPt;
1452 for(Int_t i=0; i<kNspc+1; i++,lSpc+=1.) binsSpc[i]=lSpc;
1453 for(Int_t i=0; i<kNdpt+1; i++,lDPt+=2.e-3) binsDPt[i]=lDPt;
1456 snprintf(hname, 100, "%s_%s_Pt", GetNameId(), name);
1457 snprintf(htitle, 300, "#splitline{P_{t} res for}{\"%s\" @ %s};p_{t} [GeV/c];#Delta p_{t}/p_{t}^{MC};SPECIES", GetNameId(), name);
1458 if(!(h = (TH3S*)gROOT->FindObject(hname))){
1459 h = new TH3S(hname, htitle,
1460 kNpt, binsPt, kNdpt, binsDPt, kNspc, binsSpc);
1461 //ax = h->GetZaxis();
1462 //for(Int_t ib(1); ib<=ax->GetNbins(); ib++) ax->SetBinLabel(ib, fgParticle[ib-1]);
1466 snprintf(hname, 100, "%s_%s_1Pt", GetNameId(), name);
1467 snprintf(htitle, 300, "#splitline{1/P_{t} pull for}{\"%s\" @ %s};1/p_{t}^{MC} [c/GeV];#Delta(1/p_{t})/#sigma(1/p_{t});SPECIES", GetNameId(), name);
1468 if(!(h = (TH3S*)gROOT->FindObject(hname))){
1469 h = new TH3S(hname, htitle,
1470 kNpt, 0., 2., 100, -4., 4., kNspc, -5.5, 5.5);
1471 //ax = h->GetZaxis();
1472 //for(Int_t ib(1); ib<=ax->GetNbins(); ib++) ax->SetBinLabel(ib, fgParticle[ib-1]);
1476 snprintf(hname, 100, "%s_%s_P", GetNameId(), name);
1477 snprintf(htitle, 300, "P res for \"%s\" @ %s;p [GeV/c];#Delta p/p^{MC};SPECIES", GetNameId(), name);
1478 if(!(h = (TH3S*)gROOT->FindObject(hname))){
1479 h = new TH3S(hname, htitle,
1480 kNpt, binsPt, kNdpt, binsDPt, kNspc, binsSpc);
1481 //ax = h->GetZaxis();
1482 //for(Int_t ib(1); ib<=ax->GetNbins(); ib++) ax->SetBinLabel(ib, fgParticle[ib-1]);
1490 //________________________________________________________
1491 TObjArray* AliTRDresolution::Histos()
1494 // Define histograms
1497 if(fContainer) return fContainer;
1499 fContainer = new TObjArray(kNclasses); fContainer->SetOwner(kTRUE);
1501 const Int_t nhn(100); Char_t hn[nhn]; TString st;
1503 //++++++++++++++++++++++
1504 // cluster to track residuals/pulls
1505 snprintf(hn, nhn, "h%s", fgPerformanceName[kCluster]);
1506 if(!(H = (THnSparseI*)gROOT->FindObject(hn))){
1507 const Char_t *clTitle[5/*kNdim*/] = {"layer", fgkTitle[kPhi], fgkTitle[kEta], "chg*Q/vd/angle", fgkTitle[kYrez]/*, "#Deltax [cm]", "Q</Q", "#Phi^{*} - ExB [deg]"*/};
1508 const Int_t clNbins[5/*kNdim*/] = {AliTRDgeometry::kNlayer, fgkNbins[kPhi], fgkNbins[kEta], 51, fgkNbins[kYrez]/*, 33, 10, 30*/};
1509 const Double_t clMin[5/*kNdim*/] = {-0.5, fgkMin[kPhi], fgkMin[kEta], -102., fgkMin[kYrez]/3./*, 0., 0.1, -30*/},
1510 clMax[5/*kNdim*/] = {AliTRDgeometry::kNlayer-0.5, fgkMax[kPhi], fgkMax[kEta], 102., fgkMax[kYrez]/3./*, 3.3, 2.1, 30*/};
1511 st = "cluster spatial&charge resolution;";
1512 for(Int_t idim(0); idim<5/*kNdim*/; idim++){ st += clTitle[idim]; st+=";";}
1513 H = new THnSparseI(hn, st.Data(), kNdim, clNbins, clMin, clMax);
1515 fContainer->AddAt(H, kCluster);
1516 //++++++++++++++++++++++
1517 // tracklet to TRD track
1518 snprintf(hn, nhn, "h%s", fgPerformanceName[kTracklet]);
1519 if(!(H = (THnSparseI*)gROOT->FindObject(hn))){
1520 const Char_t *trTitle[kNdim+1] = {"layer", fgkTitle[kPhi], fgkTitle[kEta], fgkTitle[kSpeciesChgRC], fgkTitle[kYrez], "#Deltaz [cm]/#Phi^{*} - ExB [rad]", fgkTitle[kPrez], "dq/dl [a.u.]"/*, fgkTitle[kPt]*/};
1521 const Int_t trNbins[kNdim+1] = {AliTRDgeometry::kNlayer, fgkNbins[kPhi], fgkNbins[kEta], fgkNbins[kSpeciesChgRC], fgkNbins[kYrez], fgkNbins[kZrez], fgkNbins[kPrez], 30/*, fgkNbins[kPt]*/};
1522 const Double_t trMin[kNdim+1] = {-0.5, fgkMin[kPhi], fgkMin[kEta], fgkMin[kSpeciesChgRC], fgkMin[kYrez], fgkMin[kZrez], fgkMin[kPrez], 0./*, fgkMin[kPt]*/},
1523 trMax[kNdim+1] = {AliTRDgeometry::kNlayer-0.5, fgkMax[kPhi], fgkMax[kEta], fgkMax[kSpeciesChgRC], fgkMax[kYrez], fgkMax[kZrez], fgkMax[kPrez], 3000./*, fgkMax[kPt]*/};
1524 st = "tracklet spatial&charge resolution;";
1525 for(Int_t idim(0); idim<kNdim+1; idim++){ st += trTitle[idim]; st+=";";}
1526 H = new THnSparseI(hn, st.Data(), kNdim+1, trNbins, trMin, trMax);
1528 fContainer->AddAt(H, kTracklet);
1529 //++++++++++++++++++++++
1530 // tracklet to TRDin
1531 snprintf(hn, nhn, "h%s", fgPerformanceName[kTrackIn]);
1532 if(!(H = (THnSparseI*)gROOT->FindObject(hn))){
1533 st = "r-#phi/z/angular residuals @ TRD entry;";
1534 for(Int_t idim(0); idim<kNdim; idim++){ st += fgkTitle[idim]; st+=";";}
1535 H = new THnSparseI(hn, st.Data(), kNdim, fgkNbins, fgkMin, fgkMax);
1537 fContainer->AddAt(H, kTrackIn);
1538 // tracklet to TRDout
1539 fContainer->AddAt(BuildMonitorContainerTracklet("TrkOUT"), kTrackOut);
1542 // Resolution histos
1543 if(!HasMCdata()) return fContainer;
1545 // cluster resolution
1546 fContainer->AddAt(BuildMonitorContainerCluster("MCcl"), kMCcluster);
1548 // tracklet resolution
1549 fContainer->AddAt(BuildMonitorContainerTracklet("MCtracklet"), kMCtracklet);
1552 TObjArray *arr(NULL);
1553 fContainer->AddAt(arr = new TObjArray(AliTRDgeometry::kNlayer), kMCtrack);
1554 arr->SetName("MCtrk");
1555 for(Int_t il(0); il<AliTRDgeometry::kNlayer; il++) arr->AddAt(BuildMonitorContainerTrack(Form("MCtrk_Ly%d", il)), il);
1557 // TRDin TRACK RESOLUTION
1558 fContainer->AddAt(H, kMCtrackIn);
1560 // TRDout TRACK RESOLUTION
1561 fContainer->AddAt(BuildMonitorContainerTrack("MCtrkOUT"), kMCtrackOut);
1566 //________________________________________________________
1567 Bool_t AliTRDresolution::Process(TH2* const h2, TGraphErrors **g, Int_t stat)
1569 // Robust function to process sigma/mean for 2D plot dy(x)
1570 // For each x bin a gauss fit is performed on the y projection and the range
1571 // with the minimum chi2/ndf is choosen
1574 if(AliLog::GetDebugLevel("PWG1", "AliTRDresolution")>0) printf("D-AliTRDresolution::Process() : NULL pointer input container.\n");
1577 if(!Int_t(h2->GetEntries())){
1578 if(AliLog::GetDebugLevel("PWG1", "AliTRDresolution")>0) printf("D-AliTRDresolution::Process() : Empty h[%s - %s].\n", h2->GetName(), h2->GetTitle());
1581 if(!g || !g[0]|| !g[1]) {
1582 if(AliLog::GetDebugLevel("PWG1", "AliTRDresolution")>0) printf("D-AliTRDresolution::Process() : NULL pointer output container.\n");
1586 TAxis *ax(h2->GetXaxis()), *ay(h2->GetYaxis());
1587 Float_t ymin(ay->GetXmin()), ymax(ay->GetXmax()), dy(ay->GetBinWidth(1)), y0(0.), y1(0.);
1588 TF1 f("f", "gaus", ymin, ymax);
1590 if((n=g[0]->GetN())) for(;n--;) g[0]->RemovePoint(n);
1591 if((n=g[1]->GetN())) for(;n--;) g[1]->RemovePoint(n);
1593 if((h=(TH1D*)gROOT->FindObject("py"))) delete h;
1594 Double_t x(0.), y(0.), ex(0.), ey(0.), sy(0.), esy(0.);
1598 Float_t chi2OverNdf(0.);
1599 for(Int_t ix = 1, np=0; ix<=ax->GetNbins(); ix++){
1600 x = ax->GetBinCenter(ix); ex= ax->GetBinWidth(ix)*0.288; // w/sqrt(12)
1601 ymin = ay->GetXmin(); ymax = ay->GetXmax();
1603 h = h2->ProjectionY("py", ix, ix);
1604 if((n=(Int_t)h->GetEntries())<stat){
1605 if(AliLog::GetDebugLevel("PWG1", "AliTRDresolution")>1) printf("I-AliTRDresolution::Process() : Low statistics @ x[%f] stat[%d]=%d [%d].\n", x, ix, n, stat);
1608 // looking for a first order mean value
1609 f.SetParameter(1, 0.); f.SetParameter(2, 3.e-2);
1611 chi2OverNdf = f.GetChisquare()/f.GetNDF();
1612 printf("x[%f] range[%f %f] chi2[%f] ndf[%d] chi2/ndf[%f]\n", x, ymin, ymax, f.GetChisquare(),f.GetNDF(),chi2OverNdf);
1613 y = f.GetParameter(1); y0 = y-4*dy; y1 = y+4*dy;
1614 ey = f.GetParError(1);
1615 sy = f.GetParameter(2); esy = f.GetParError(2);
1616 // // looking for the best chi2/ndf value
1617 // while(ymin<y0 && ymax>y1){
1618 // f.SetParameter(1, y);
1619 // f.SetParameter(2, sy);
1620 // h->Fit(&f, "QNW", "", y0, y1);
1621 // printf(" range[%f %f] chi2[%f] ndf[%d] chi2/ndf[%f]\n", y0, y1, f.GetChisquare(),f.GetNDF(),f.GetChisquare()/f.GetNDF());
1622 // if(f.GetChisquare()/f.GetNDF() < Chi2OverNdf){
1623 // chi2OverNdf = f.GetChisquare()/f.GetNDF();
1624 // y = f.GetParameter(1); ey = f.GetParError(1);
1625 // sy = f.GetParameter(2); esy = f.GetParError(2);
1626 // printf(" set y[%f] sy[%f] chi2/ndf[%f]\n", y, sy, chi2OverNdf);
1630 g[0]->SetPoint(np, x, y);
1631 g[0]->SetPointError(np, ex, ey);
1632 g[1]->SetPoint(np, x, sy);
1633 g[1]->SetPointError(np, ex, esy);
1640 //________________________________________________________
1641 Bool_t AliTRDresolution::Process(TH2 * const h2, TF1 *f, Float_t k, TGraphErrors **g)
1644 // Do the processing
1647 Char_t pn[10]; snprintf(pn, 10, "p%03d", fIdxPlot);
1649 if((n=g[0]->GetN())) for(;n--;) g[0]->RemovePoint(n);
1650 if((n=g[1]->GetN())) for(;n--;) g[1]->RemovePoint(n);
1651 if(Int_t(h2->GetEntries())){
1652 AliDebug(4, Form("%s: g[%s %s]", pn, g[0]->GetName(), g[0]->GetTitle()));
1654 AliDebug(2, Form("%s: g[%s %s]: Missing entries.", pn, g[0]->GetName(), g[0]->GetTitle()));
1659 const Int_t kINTEGRAL=1;
1660 for(Int_t ibin = 0; ibin < Int_t(h2->GetNbinsX()/kINTEGRAL); ibin++){
1661 Int_t abin(ibin*kINTEGRAL+1),bbin(abin+kINTEGRAL-1),mbin(abin+Int_t(kINTEGRAL/2));
1662 Double_t x = h2->GetXaxis()->GetBinCenter(mbin);
1663 TH1D *h = h2->ProjectionY(pn, abin, bbin);
1664 if((n=(Int_t)h->GetEntries())<150){
1665 AliDebug(4, Form(" x[%f] range[%d %d] stat[%d] low statistics !", x, abin, bbin, n));
1669 Int_t ip = g[0]->GetN();
1670 AliDebug(4, Form(" x_%d[%f] range[%d %d] stat[%d] M[%f] Sgm[%f]", ip, x, abin, bbin, n, f->GetParameter(1), f->GetParameter(2)));
1671 g[0]->SetPoint(ip, x, k*f->GetParameter(1));
1672 g[0]->SetPointError(ip, 0., k*f->GetParError(1));
1673 g[1]->SetPoint(ip, x, k*f->GetParameter(2));
1674 g[1]->SetPointError(ip, 0., k*f->GetParError(2));
1676 g[0]->SetPoint(ip, x, k*h->GetMean());
1677 g[0]->SetPointError(ip, 0., k*h->GetMeanError());
1678 g[1]->SetPoint(ip, x, k*h->GetRMS());
1679 g[1]->SetPointError(ip, 0., k*h->GetRMSError());*/
1686 //____________________________________________________________________
1687 Bool_t AliTRDresolution::FitTrack(const Int_t np, AliTrackPoint *points, Float_t param[10])
1690 // Fit track with a staight line using the "np" clusters stored in the array "points".
1691 // The following particularities are stored in the clusters from points:
1692 // 1. pad tilt as cluster charge
1693 // 2. pad row cross or vertex constrain as fake cluster with cluster type 1
1694 // The parameters of the straight line fit are stored in the array "param" in the following order :
1695 // param[0] - x0 reference radial position
1696 // param[1] - y0 reference r-phi position @ x0
1697 // param[2] - z0 reference z position @ x0
1698 // param[3] - slope dy/dx
1699 // param[4] - slope dz/dx
1702 // Function should be used to refit tracks for B=0T
1706 if(AliLog::GetDebugLevel("PWG1", "AliTRDresolution")>1) printf("D-AliTRDresolution::FitTrack: Not enough clusters to fit a track [%d].\n", np);
1709 TLinearFitter yfitter(2, "pol1"), zfitter(2, "pol1");
1712 for(Int_t ip(0); ip<np; ip++) x0+=points[ip].GetX();
1715 Double_t x, y, z, dx, tilt(0.);
1716 for(Int_t ip(0); ip<np; ip++){
1717 x = points[ip].GetX(); z = points[ip].GetZ();
1719 zfitter.AddPoint(&dx, z, points[ip].GetClusterType()?1.e-3:1.);
1721 if(zfitter.Eval() != 0) return kFALSE;
1723 Double_t z0 = zfitter.GetParameter(0);
1724 Double_t dzdx = zfitter.GetParameter(1);
1725 for(Int_t ip(0); ip<np; ip++){
1726 if(points[ip].GetClusterType()) continue;
1727 x = points[ip].GetX();
1729 y = points[ip].GetY();
1730 z = points[ip].GetZ();
1731 tilt = points[ip].GetCharge();
1732 y -= tilt*(-dzdx*dx + z - z0);
1733 Float_t xyz[3] = {x, y, z}; points[ip].SetXYZ(xyz);
1734 yfitter.AddPoint(&dx, y, 1.);
1736 if(yfitter.Eval() != 0) return kFALSE;
1737 Double_t y0 = yfitter.GetParameter(0);
1738 Double_t dydx = yfitter.GetParameter(1);
1740 param[0] = x0; param[1] = y0; param[2] = z0; param[3] = dydx; param[4] = dzdx;
1741 if(AliLog::GetDebugLevel("PWG1", "AliTRDresolution")>3) printf("D-AliTRDresolution::FitTrack: x0[%f] y0[%f] z0[%f] dydx[%f] dzdx[%f].\n", x0, y0, z0, dydx, dzdx);
1745 //____________________________________________________________________
1746 Bool_t AliTRDresolution::FitTracklet(const Int_t ly, const Int_t np, const AliTrackPoint *points, const Float_t param[10], Float_t par[3])
1749 // Fit tracklet with a staight line using the coresponding subset of clusters out of the total "np" clusters stored in the array "points".
1750 // See function FitTrack for the data stored in the "clusters" array
1752 // The parameters of the straight line fit are stored in the array "param" in the following order :
1753 // par[0] - x0 reference radial position
1754 // par[1] - y0 reference r-phi position @ x0
1755 // par[2] - slope dy/dx
1758 // Function should be used to refit tracks for B=0T
1761 TLinearFitter yfitter(2, "pol1");
1763 // grep data for tracklet
1764 Double_t x0(0.), x[60], y[60], dy[60];
1766 for(Int_t ip(0); ip<np; ip++){
1767 if(points[ip].GetClusterType()) continue;
1768 if(points[ip].GetVolumeID() != ly) continue;
1769 Float_t xt(points[ip].GetX())
1770 ,yt(param[1] + param[3] * (xt - param[0]));
1772 y[nly] = points[ip].GetY();
1778 if(AliLog::GetDebugLevel("PWG1", "AliTRDresolution")>1) printf("D-AliTRDresolution::FitTracklet: Not enough clusters to fit a tracklet [%d].\n", nly);
1781 // set radial reference for fit
1784 // find tracklet core
1785 Double_t mean(0.), sig(1.e3);
1786 AliMathBase::EvaluateUni(nly, dy, mean, sig, 0);
1788 // simple cluster error parameterization
1789 Float_t kSigCut = TMath::Sqrt(5.e-4 + param[3]*param[3]*0.018);
1791 // fit tracklet core
1792 for(Int_t jly(0); jly<nly; jly++){
1793 if(TMath::Abs(dy[jly]-mean)>kSigCut) continue;
1794 Double_t dx(x[jly]-x0);
1795 yfitter.AddPoint(&dx, y[jly], 1.);
1797 if(yfitter.Eval() != 0) return kFALSE;
1799 par[1] = yfitter.GetParameter(0);
1800 par[2] = yfitter.GetParameter(1);
1804 //____________________________________________________________________
1805 Bool_t AliTRDresolution::UseTrack(const Int_t np, const AliTrackPoint *points, Float_t param[10])
1808 // Global selection mechanism of tracksbased on cluster to fit residuals
1809 // The parameters are the same as used ni function FitTrack().
1811 const Float_t kS(0.6), kM(0.2);
1812 TH1S h("h1", "", 100, -5.*kS, 5.*kS);
1813 Float_t dy, dz, s, m;
1814 for(Int_t ip(0); ip<np; ip++){
1815 if(points[ip].GetClusterType()) continue;
1816 Float_t x0(points[ip].GetX())
1817 ,y0(param[1] + param[3] * (x0 - param[0]))
1818 ,z0(param[2] + param[4] * (x0 - param[0]));
1819 dy=points[ip].GetY() - y0; h.Fill(dy);
1820 dz=points[ip].GetZ() - z0;
1822 TF1 fg("fg", "gaus", -5.*kS, 5.*kS);
1823 fg.SetParameter(1, 0.);
1824 fg.SetParameter(2, 2.e-2);
1826 m=fg.GetParameter(1); s=fg.GetParameter(2);
1827 if(s>kS || TMath::Abs(m)>kM) return kFALSE;
1831 //________________________________________________________
1832 void AliTRDresolution::GetLandauMpvFwhm(TF1 * const f, Float_t &mpv, Float_t &xm, Float_t &xM)
1835 // Get the most probable value and the full width half mean
1836 // of a Landau distribution
1839 const Float_t dx = 1.;
1840 mpv = f->GetParameter(1);
1841 Float_t fx, max = f->Eval(mpv);
1844 while((fx = f->Eval(xm))>.5*max){
1853 while((fx = f->Eval(xM))>.5*max) xM += dx;
1857 // #include "TFile.h"
1858 // //________________________________________________________
1859 // Bool_t AliTRDresolution::LoadCorrection(const Char_t *file)
1862 // AliWarning("Use cluster position as in reconstruction.");
1863 // SetLoadCorrection();
1866 // TDirectory *cwd(gDirectory);
1867 // TString fileList;
1868 // FILE *filePtr = fopen(file, "rt");
1870 // AliWarning(Form("Couldn't open correction list \"%s\". Use cluster position as in reconstruction.", file));
1871 // SetLoadCorrection();
1874 // TH2 *h2 = new TH2F("h2", ";time [time bins];detector;dx [#mum]", 30, -0.5, 29.5, AliTRDgeometry::kNdet, -0.5, AliTRDgeometry::kNdet-0.5);
1875 // while(fileList.Gets(filePtr)){
1876 // if(!TFile::Open(fileList.Data())) {
1877 // AliWarning(Form("Couldn't open \"%s\"", fileList.Data()));
1879 // } else AliInfo(Form("\"%s\"", fileList.Data()));
1881 // TTree *tSys = (TTree*)gFile->Get("tSys");
1882 // h2->SetDirectory(gDirectory); h2->Reset("ICE");
1883 // tSys->Draw("det:t>>h2", "dx", "goff");
1884 // for(Int_t idet(0); idet<AliTRDgeometry::kNdet; idet++){
1885 // for(Int_t it(0); it<30; it++) fXcorr[idet][it]+=(1.e-4*h2->GetBinContent(it+1, idet+1));
1887 // h2->SetDirectory(cwd);
1892 // if(AliLog::GetDebugLevel("PWG1", "AliTRDresolution")>=2){
1893 // for(Int_t il(0); il<184; il++) printf("-"); printf("\n");
1894 // printf("DET|");for(Int_t it(0); it<30; it++) printf(" tb%02d|", it); printf("\n");
1895 // for(Int_t il(0); il<184; il++) printf("-"); printf("\n");
1896 // FILE *fout = fopen("TRD.ClusterCorrection.txt", "at");
1897 // fprintf(fout, " static const Double_t dx[AliTRDgeometry::kNdet][30]={\n");
1898 // for(Int_t idet(0); idet<AliTRDgeometry::kNdet; idet++){
1899 // printf("%03d|", idet);
1900 // fprintf(fout, " {");
1901 // for(Int_t it(0); it<30; it++){
1902 // printf("%+5.0f|", 1.e4*fXcorr[idet][it]);
1903 // fprintf(fout, "%+6.4f%c", fXcorr[idet][it], it==29?' ':',');
1906 // fprintf(fout, "}%c\n", idet==AliTRDgeometry::kNdet-1?' ':',');
1908 // fprintf(fout, " };\n");
1910 // SetLoadCorrection();