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-commercial 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: AliTRDtrackerDebug.cxx 23810 2008-02-08 09:00:27Z hristov $ */
18 ///////////////////////////////////////////////////////////////////////////////
20 // Tracker debug streamer //
23 // Alex Bercuci <A.Bercuci@gsi.de> //
24 // Markus Fasel <M.Fasel@gsi.de> //
26 ///////////////////////////////////////////////////////////////////////////////
28 #include "AliTRDtrackerDebug.h"
32 #include "TTreeStream.h"
33 #include "TLinearFitter.h"
36 #include "AliTRDgeometry.h"
37 #include "AliTRDtrackV1.h"
38 #include "AliTRDseedV1.h"
39 #include "AliTRDseed.h"
40 #include "AliTRDcluster.h"
42 ClassImp(AliTRDtrackerDebug)
44 //____________________________________________________
45 AliTRDtrackerDebug::AliTRDtrackerDebug() : AliTRDtrackerV1()
54 // Default constructor
56 fOutputStreamer = new TTreeSRedirector("TRD.Debug.root");
59 //____________________________________________________
60 AliTRDtrackerDebug::~AliTRDtrackerDebug()
64 delete fOutputStreamer;
68 //____________________________________________________
69 void AliTRDtrackerDebug::Draw(const Option_t *)
71 // steer draw function
75 //____________________________________________________
76 Bool_t AliTRDtrackerDebug::Init()
78 // steer linking data for various debug streams
80 fTrack = new AliTRDtrackV1();
81 fTree->SetBranchAddress("ncl", &fNClusters);
82 fTree->SetBranchAddress("track.", &fTrack);
86 //____________________________________________________
87 Bool_t AliTRDtrackerDebug::Open(const char *method)
89 // Connect to the tracker debug file
91 TDirectory *savedir = gDirectory;
92 TFile::Open("TRD.TrackerDebugger.root");
93 fTree = (TTree*)gFile->Get(method);
95 AliInfo(Form("Can not find debug stream for the %s method.\n", method));
103 //____________________________________________________
104 Int_t AliTRDtrackerDebug::Process()
106 // steer debug process threads
108 for(int it = 0; it<fTree->GetEntries(); it++){
109 if(!fTree->GetEntry(it)) continue;
110 if(!fNClusters) continue;
111 fAlpha = fTrack->GetAlpha();
112 //printf("Processing track %d [%d] ...\n", it, fNClusters);
113 ResidualsTrackletsTrack();
115 const AliTRDseedV1 *tracklet = 0x0;
116 for(int ip = 5; ip>=0; ip--){
117 if(!(tracklet = fTrack->GetTracklet(ip))) continue;
118 if(!tracklet->GetN()) continue;
120 ResidualsClustersTrack(tracklet);
121 ResidualsClustersTracklet(tracklet);
122 ResidualsClustersParametrisation(tracklet);
129 //____________________________________________________
130 void AliTRDtrackerDebug::ResidualsClustersTrack(const AliTRDseedV1 *tracklet)
132 // Calculate averange distances from clusters to the TRD track
135 AliTRDcluster *c = 0x0;
136 for(int ic=0; ic<35/*AliTRDseed:knTimebins*/; ic++){
137 if(!(c = tracklet->GetClusters(ic))) continue;
138 Double_t xc = c->GetX(), yc = c->GetY(), zc = c->GetZ();
140 // propagate track to cluster
141 PropagateToX(*fTrack, xc, 2.);
144 // transform to local tracking coordinates
145 //Double_t xg = x[0] * TMath::Cos(fAlpha) + x[1] * TMath::Sin(fAlpha);
146 Double_t yg = -x[0] * TMath::Sin(fAlpha) + x[1] * TMath::Cos(fAlpha);
148 // apply tilt pad correction
149 yc+= (zc - x[2]) * tracklet->GetTilt();
153 TTreeSRedirector &cstreamer = *fOutputStreamer;
154 cstreamer << "ResidualsClustersTrack"
161 //____________________________________________________
162 void AliTRDtrackerDebug::ResidualsClustersTracklet(const AliTRDseedV1 *tracklet) const
164 // Calculates distances from clusters to tracklets
166 Double_t x0 = tracklet->GetX0(),
167 y0 = tracklet->GetYfit(0),
168 ys = tracklet->GetYfit(1);
169 //z0 = tracklet->GetZfit(0),
170 //zs = tracklet->GetZfit(1);
172 AliTRDcluster *c = 0x0;
173 for(int ic=0; ic<35/*AliTRDseed:knTimebins*/; ic++){
174 if(!(c = tracklet->GetClusters(ic))) continue;
175 Double_t xc = c->GetX(), yc = c->GetY()/*, zc = c->GetZ()*/;
176 Double_t dy = yc- (y0-(x0-xc)*ys);
179 //ResidualsClustersTracklet->Draw("TMath::Abs(10.*dy):TMath::ATan(ys)*TMath::RadToDeg()>>h(20, -40, 40)", "", "prof");
180 TTreeSRedirector &cstreamer = *fOutputStreamer;
181 cstreamer << "ResidualsClustersTracklet"
189 //____________________________________________________
190 void AliTRDtrackerDebug::ResidualsClustersParametrisation(const AliTRDseedV1 *tracklet) const
192 // Calculates distances from clusters to Rieman fit.
194 // store cluster positions
195 Double_t x0 = tracklet->GetX0();
196 AliTRDcluster *c = 0x0;
198 Double_t x[2]; Int_t ncl, mcl, jc;
199 TLinearFitter fitter(3, "hyp2");
200 for(int ic=0; ic<35/*AliTRDseed:knTimebins*/; ic++){
201 if(!(c = tracklet->GetClusters(ic))) continue;
202 Double_t xc = c->GetX(), yc = c->GetY()/*, zc = c->GetZ()*/;
204 jc = ic; ncl = 0; mcl=0; fitter.ClearPoints();
208 jc = ic + ((mcl&1)?-1:1)*(mcl>>1);
210 if(jc<0 || jc>=35) continue;
211 if(!(c = tracklet->GetClusters(jc))) continue;
215 fitter.AddPoint(x, c->GetY(), c->GetSigmaY2());
219 Double_t dy = yc - fitter.GetParameter(0) -fitter.GetParameter(1) * (xc-x0) - fitter.GetParameter(2)* (xc-x0)*(xc-x0);
221 TTreeSRedirector &cstreamer = *fOutputStreamer;
222 cstreamer << "ResidualsClustersParametrisation"
229 //____________________________________________________
230 void AliTRDtrackerDebug::ResidualsTrackletsTrack() const
232 // Calculates distances from tracklets to the TRD track.
234 if(fTrack->GetNumberOfTracklets() < 6) return;
236 // build a working copy of the tracklets attached to the track
237 // and initialize working variables fX, fY and fZ
238 AliTRDcluster *c = 0x0;
239 AliTRDseedV1 tracklet[6] = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0};
240 const AliTRDseedV1 *ctracklet = 0x0;
241 for(int ip = 0; ip<6; ip++){
242 if(!(ctracklet = fTrack->GetTracklet(ip))) continue;
243 tracklet[ip] = (*ctracklet);
244 Double_t x0 = tracklet[ip].GetX0();
245 for(int ic=0; ic<35/*AliTRDseed:knTimebins*/; ic++){
246 if(!(c = tracklet[ip].GetClusters(ic))) continue;
247 Double_t xc = c->GetX(), yc = c->GetY(), zc = c->GetZ();
248 tracklet[ip].SetX(ic, xc-x0);
249 tracklet[ip].SetY(ic, yc);
250 tracklet[ip].SetZ(ic, zc);
254 // Do a Rieman fit (with tilt correction) for all tracklets
255 // except the one which is tested.
256 // (Based on AliTRDseed::IsOK() return false)
257 for(int ip=0; ip<6; ip++){
258 // reset tracklet to be tested
259 Double_t x0 = tracklet[ip].GetX0();
260 new(&tracklet[ip]) AliTRDseedV1();
261 tracklet[ip].SetX0(x0);
263 // fit Rieman with tilt correction
264 AliTRDseedV1::FitRiemanTilt(&tracklet[0], kTRUE);
266 // make a copy of the fit result
268 y0 = tracklet[ip].GetYref(0),
269 dydx = tracklet[ip].GetYref(1),
270 z0 = tracklet[ip].GetZref(0),
271 dzdx = tracklet[ip].GetZref(1);
274 tracklet[ip] = (*fTrack->GetTracklet(ip));
275 for(int ic=0; ic<35/*AliTRDseed:knTimebins*/; ic++){
276 if(!(c = tracklet[ip].GetClusters(ic))) continue;
277 Double_t xc = c->GetX(), yc = c->GetY(), zc = c->GetZ();
278 tracklet[ip].SetX(ic, xc-x0);
279 tracklet[ip].SetY(ic, yc);
280 tracklet[ip].SetZ(ic, zc);
284 AliTRDseedV1 ts(tracklet[ip]);
285 ts.SetYref(0, y0); ts.SetYref(1, dydx);
286 ts.SetZref(0, z0); ts.SetZref(1, dzdx);
289 // save results for plotting
290 Int_t plane = tracklet[ip].GetPlane();
291 Double_t dy = tracklet[ip].GetYfit(0) - ts.GetYfit(0);
292 Double_t tgy = tracklet[ip].GetYfit(1);
293 Double_t dtgy = (tracklet[ip].GetYfit(1) - ts.GetYfit(1))/(1. + tracklet[ip].GetYfit(1) * ts.GetYfit(1));
294 Double_t dz = tracklet[ip].GetZfit(0) - ts.GetZfit(0);
295 Double_t tgz = tracklet[ip].GetZfit(1);
296 Double_t dtgz = (tracklet[ip].GetZfit(1) - ts.GetZfit(1))/(1. + tracklet[ip].GetZfit(1) * ts.GetZfit(1));
297 TTreeSRedirector &cstreamer = *fOutputStreamer;
298 cstreamer << "ResidualsTrackletsTrack"
299 << "ref.=" << &tracklet[ip]