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 **************************************************************************/
17 ////////////////////////////////////////////////////////////////////////////
19 // TRD tracker systematic //
23 // Alexandru Bercuci <A.Bercuci@gsi.de> //
25 ////////////////////////////////////////////////////////////////////////////
32 #include "TObjArray.h"
33 #include "THnSparse.h"
37 #include "AliTRDcluster.h"
38 #include "AliTRDseedV1.h"
39 #include "AliTRDtrackletOflHelper.h"
40 #include "AliTRDtrackV1.h"
41 #include "AliTRDtrackerV1.h"
42 #include "AliTRDtransform.h"
44 #include "AliTRDcheckTRK.h"
46 ClassImp(AliTRDcheckTRK)
48 UChar_t AliTRDcheckTRK::fgSteer= 0;
49 Float_t AliTRDcheckTRK::fgKalmanStep = 2.;
50 //__________________________________________________________________________
51 AliTRDcheckTRK::AliTRDcheckTRK()
54 // Default constructor
55 SetNameTitle("TRDtrackerSys", "TRD Tracker Systematic");
58 //__________________________________________________________________________
59 AliTRDcheckTRK::AliTRDcheckTRK(char* name)
60 : AliTRDresolution(name, kFALSE)
63 SetTitle("TRD Tracker Systematic");
68 //__________________________________________________________________________
69 AliTRDcheckTRK::~AliTRDcheckTRK()
75 //__________________________________________________________________________
76 TObjArray* AliTRDcheckTRK::Histos()
78 // Build extra calibration plots
79 if(!(fContainer = AliTRDresolution::Histos())) return NULL;
80 //fContainer->Expand(AliTRDresolution::kNclasses+1);
83 if(!(H = (THnSparseI*)gROOT->FindObject("hRoads"))){
84 const Char_t *title[kNdim] = {"layer", "charge", fgkTitle[kPt], fgkTitle[kYrez], fgkTitle[kPrez], "#sigma^{*}/<#sigma_{y}> [a.u.]", "n_{cl}"};
85 const Int_t nbins[kNdim] = {AliTRDgeometry::kNlayer, 2, kNptBins, fgkNbins[kYrez], fgkNbins[kPrez], kNSigmaBins, kNclusters};
86 const Double_t min[kNdim] = {-0.5, -0.5, -0.5, -1., -5., 0., 8.5},
87 max[kNdim] = {AliTRDgeometry::kNlayer-0.5, 1.5, kNptBins-0.5, 1., 5., 5., min[6]+kNclusters};
88 TString st("Tracking Roads Calib;");
89 // define minimum info to be saved in non debug mode
90 for(Int_t idim(0); idim<kNdim; idim++){ st += title[idim]; st+=";";}
91 H = new THnSparseI("hRoads", st.Data(), kNdim, nbins, min, max);
93 fContainer->AddAt(H, fContainer->GetEntries()/*AliTRDresolution::kNclasses*/);
97 //__________________________________________________________________________
98 TH1* AliTRDcheckTRK::PlotTrack(const AliTRDtrackV1 *track)
102 if(track) fkTrack = track;
104 AliDebug(4, "No Track defined.");
107 // make a local copy of current track
108 AliTRDtrackV1 lt(*fkTrack);
109 if(!PropagateKalman(lt, UseITS()?fkESD->GetITSoutParam():fkESD->GetTPCoutParam())) return NULL;
117 //________________________________________________________
118 void AliTRDcheckTRK::MakePtCalib(Float_t pt0, Float_t dpt)
121 for(Int_t j(0); j<=kNptBins; j++){
122 pt0+=(TMath::Exp(j*j*dpt)-1.);
127 //__________________________________________________________________________
128 Int_t AliTRDcheckTRK::GetPtBinCalib(Float_t pt)
130 // Find pt bin according to local pt segmentation
133 if(pt<fPtBinCalib[ipt+1]) break;
140 //__________________________________________________________________________
141 TH1* AliTRDcheckTRK::DoRoads(const AliTRDtrackV1 *track)
144 if(track) fkTrack = track;
146 AliDebug(4, "No Track defined.");
149 if(TMath::Abs(fkESD->GetTOFbc())>1){
150 AliDebug(4, Form("Track with BC_index[%d] not used.", fkESD->GetTOFbc()));
154 if(!fContainer || !(H = (THnSparse*)fContainer->At(3))){
155 AliWarning("No output container defined.");
160 AliTRDseedV1 *fTracklet(NULL);
161 AliTRDtrackletOflHelper helper; TObjArray cl(AliTRDseedV1::kNclusters); cl.SetOwner(kFALSE);
162 for(Int_t il(0); il<AliTRDgeometry::kNlayer; il++){
163 if(!(fTracklet = fkTrack->GetTracklet(il))) continue;
164 if(!fTracklet->IsOK() || !fTracklet->IsChmbGood()) continue;
165 Int_t ipt(GetPtBinCalib(fTracklet->GetPt()));
168 val[1] = fkTrack->Charge()<0?0:1;
170 Double_t dyt(fTracklet->GetYfit(0) - fTracklet->GetYref(0)),
171 dzt(fTracklet->GetZfit(0) - fTracklet->GetZref(0)),
172 dydx(fTracklet->GetYfit(1)),
173 tilt(fTracklet->GetTilt());
174 // correct for tilt rotation
175 val[3] = dyt - dzt*tilt;
176 dydx+= tilt*fTracklet->GetZref(1);
177 val[4] = TMath::ATan((dydx - fTracklet->GetYref(1))/(1.+ fTracklet->GetYref(1)*dydx)) * TMath::RadToDeg();
178 fTracklet->ResetClusterIter(kTRUE); AliTRDcluster *c(NULL);
179 while((c = fTracklet->NextCluster())) cl.AddLast(c);
180 helper.Init(AliTRDtransform::Geometry().GetPadPlane(fTracklet->GetDetector()), &cl);
181 Double_t r, y, s; helper.GetRMS(r, y, s, fTracklet->GetX0());
182 val[5] = s/helper.GetSyMean();
183 val[6] = fTracklet->GetN();
189 //___________________________________________________
190 Bool_t AliTRDcheckTRK::PropagateKalman(AliTRDtrackV1 &t, AliExternalTrackParam *ref)
192 // Propagate Back Kalman from the TPC input parameter to the last tracklet attached to track.
193 // On the propagation recalibration of clusters, tracklet refit and material budget are recalculated (on demand)
194 // On output the track is updated with the new info
198 // printf("PropagateKalman()\n");
199 Int_t ntracklets(t.GetNumberOfTracklets());
201 printf("E - AliTRDcheckTRK::PropagateKalman :: No tracklets attached to track.\n");
205 AliTRDseedV1 *tr(NULL);
207 printf("E - AliTRDcheckTRK::PropagateKalman :: Track did not entered TRD fiducial volume.\n");
211 //printf("W - AliTRDcheckTRK::PropagateKalman :: Missing starting param.\n");
214 if(ref->Pt()<1.e-3) return kFALSE;
217 // Initialize TRD track to the reference
219 tt.Set(ref->GetX(), ref->GetAlpha(), ref->GetParameter(), ref->GetCovariance());
220 tt.SetMass(t.GetMass());
221 tt.SetTrackOut(t.GetTrackOut());
223 if(!tt.Rotate((Int_t(ref->GetAlpha()/AliTRDgeometry::GetAlpha()) +(ref->GetAlpha()>0.?1:-1)* 0.5)*AliTRDgeometry::GetAlpha()-ref->GetAlpha())) return kFALSE;
225 for(Int_t ily(0); ily<AliTRDgeometry::kNlayer; ily++){
226 if(!(tr = t.GetTracklet(ily))) continue;
227 Int_t det(tr->GetDetector());
228 if(HasClRecalibrate()){
229 AliTRDtransform trans(det);
230 AliTRDcluster *c(NULL);
231 Float_t exb, vd, t0, s2, dl, dt; tr->GetCalibParam(exb, vd, t0, s2, dl, dt);
232 tr->ResetClusterIter(kFALSE);
233 while((c = tr->PrevCluster())){
234 if(!trans.Transform(c/*, GetCalib(det)*/)){
235 printf("W - AliTRDcheckTRK::PropagateKalman :: Transform() failed for Det[%03d %02d_%d_%d]\n", det,
236 AliTRDgeometry::GetSector(det), AliTRDgeometry::GetStack(det), AliTRDgeometry::GetLayer(det));
242 if(!tr->FitRobust(tt.Charge()>0.)) printf("W - AliTRDcheckTRK::PropagateKalman :: FitRobust() failed for Det[%03d]\n", det);
244 if(!AliTRDtrackerV1::PropagateToX(tt, tr->GetX0(), fgKalmanStep)) continue;
245 if(!tt.GetTrackIn()) tt.SetTrackIn();
247 if(HasKalmanUpdate()){
248 Double_t x(tr->GetX0()),
249 p[2] = { tr->GetYfit(0), tr->GetZfit(0)},
251 tr->GetCovAt(x, covTrklt);
252 if(!((AliExternalTrackParam&)tt).Update(p, covTrklt)) continue;
253 tt.SetTracklet(tr, 0);
254 tt.SetNumberOfClusters();
255 tt.UpdateChi2(((AliExternalTrackParam)tt).GetPredictedChi2(p, covTrklt));
260 new(&t) AliTRDtrackV1(tt);