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"
39 #include "AliTRDgeometry.h"
40 #include "AliTRDtrackV1.h"
41 #include "AliTRDseedV1.h"
42 #include "AliTRDseed.h"
43 #include "AliTRDcluster.h"
44 #include "AliTRDgeometry.h"
46 ClassImp(AliTRDtrackerDebug)
48 Int_t AliTRDtrackerDebug::fgEventNumber = 0;
49 Int_t AliTRDtrackerDebug::fgTrackNumber = 0;
50 Int_t AliTRDtrackerDebug::fgCandidateNumber = 0;
52 //____________________________________________________
53 AliTRDtrackerDebug::AliTRDtrackerDebug() : AliTRDtrackerV1()
62 // Default constructor
64 fOutputStreamer = new TTreeSRedirector("TRD.Debug.root");
67 //____________________________________________________
68 AliTRDtrackerDebug::~AliTRDtrackerDebug()
72 delete fOutputStreamer;
76 //____________________________________________________
77 void AliTRDtrackerDebug::Draw(const Option_t *)
79 // steer draw function
83 //____________________________________________________
84 Bool_t AliTRDtrackerDebug::Init()
86 // steer linking data for various debug streams
87 fTrack = new AliTRDtrackV1();
88 fTree->SetBranchAddress("ncl", &fNClusters);
89 fTree->SetBranchAddress("track.", &fTrack);
93 //____________________________________________________
94 Bool_t AliTRDtrackerDebug::Open(const char *method)
96 // Connect to the tracker debug file
98 TDirectory *savedir = gDirectory;
99 TFile::Open("TRD.TrackerDebugger.root");
100 fTree = (TTree*)gFile->Get(method);
102 AliInfo(Form("Can not find debug stream for the %s method.\n", method));
110 //____________________________________________________
111 Int_t AliTRDtrackerDebug::Process()
113 // steer debug process threads
115 for(int it = 0; it<fTree->GetEntries(); it++){
116 if(!fTree->GetEntry(it)) continue;
117 if(!fNClusters) continue;
118 fAlpha = fTrack->GetAlpha();
119 //printf("Processing track %d [%d] ...\n", it, fNClusters);
120 ResidualsTrackletsTrack();
122 const AliTRDseedV1 *tracklet = 0x0;
123 for(int ip = 5; ip>=0; ip--){
124 if(!(tracklet = fTrack->GetTracklet(ip))) continue;
125 if(!tracklet->GetN()) continue;
127 ResidualsClustersTrack(tracklet);
128 ResidualsClustersTracklet(tracklet);
129 ResidualsClustersParametrisation(tracklet);
136 //____________________________________________________
137 void AliTRDtrackerDebug::ResidualsClustersTrack(const AliTRDseedV1 *tracklet)
139 // Calculate averange distances from clusters to the TRD track
142 AliTRDcluster *c = 0x0;
143 for(int ic=0; ic<35/*AliTRDseed:knTimebins*/; ic++){
144 if(!(c = tracklet->GetClusters(ic))) continue;
145 Double_t xc = c->GetX(), yc = c->GetY(), zc = c->GetZ();
147 // propagate track to cluster
148 PropagateToX(*fTrack, xc, 2.);
151 // transform to local tracking coordinates
152 //Double_t xg = x[0] * TMath::Cos(fAlpha) + x[1] * TMath::Sin(fAlpha);
153 Double_t yg = -x[0] * TMath::Sin(fAlpha) + x[1] * TMath::Cos(fAlpha);
155 // apply tilt pad correction
156 yc+= (zc - x[2]) * tracklet->GetTilt();
160 TTreeSRedirector &cstreamer = *fOutputStreamer;
161 cstreamer << "ResidualsClustersTrack"
168 //____________________________________________________
169 void AliTRDtrackerDebug::ResidualsClustersTracklet(const AliTRDseedV1 *tracklet) const
171 // Calculates distances from clusters to tracklets
173 Double_t x0 = tracklet->GetX0(),
174 y0 = tracklet->GetYfit(0),
175 ys = tracklet->GetYfit(1);
176 //z0 = tracklet->GetZfit(0),
177 //zs = tracklet->GetZfit(1);
179 AliTRDcluster *c = 0x0;
180 for(int ic=0; ic<35/*AliTRDseed:knTimebins*/; ic++){
181 if(!(c = tracklet->GetClusters(ic))) continue;
182 Double_t xc = c->GetX(), yc = c->GetY()/*, zc = c->GetZ()*/;
183 Double_t dy = yc- (y0-(x0-xc)*ys);
186 //ResidualsClustersTracklet->Draw("TMath::Abs(10.*dy):TMath::ATan(ys)*TMath::RadToDeg()>>h(20, -40, 40)", "", "prof");
187 TTreeSRedirector &cstreamer = *fOutputStreamer;
188 cstreamer << "ResidualsClustersTracklet"
196 //____________________________________________________
197 void AliTRDtrackerDebug::ResidualsClustersParametrisation(const AliTRDseedV1 *tracklet) const
199 // Calculates distances from clusters to Rieman fit.
201 // store cluster positions
202 Double_t x0 = tracklet->GetX0();
203 AliTRDcluster *c = 0x0;
205 Double_t x[2]; Int_t ncl, mcl, jc;
206 TLinearFitter fitter(3, "hyp2");
207 for(int ic=0; ic<35/*AliTRDseed:knTimebins*/; ic++){
208 if(!(c = tracklet->GetClusters(ic))) continue;
209 Double_t xc = c->GetX(), yc = c->GetY()/*, zc = c->GetZ()*/;
211 jc = ic; ncl = 0; mcl=0; fitter.ClearPoints();
215 jc = ic + ((mcl&1)?-1:1)*(mcl>>1);
217 if(jc<0 || jc>=35) continue;
218 if(!(c = tracklet->GetClusters(jc))) continue;
222 fitter.AddPoint(x, c->GetY(), c->GetSigmaY2());
226 Double_t dy = yc - fitter.GetParameter(0) -fitter.GetParameter(1) * (xc-x0) - fitter.GetParameter(2)* (xc-x0)*(xc-x0);
228 TTreeSRedirector &cstreamer = *fOutputStreamer;
229 cstreamer << "ResidualsClustersParametrisation"
236 //____________________________________________________
237 void AliTRDtrackerDebug::ResidualsTrackletsTrack() const
239 // Calculates distances from tracklets to the TRD track.
241 if(fTrack->GetNumberOfTracklets() < 6) return;
243 // build a working copy of the tracklets attached to the track
244 // and initialize working variables fX, fY and fZ
245 AliTRDcluster *c = 0x0;
246 AliTRDseedV1 tracklet[6] = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0};
247 const AliTRDseedV1 *ctracklet = 0x0;
248 for(int ip = 0; ip<6; ip++){
249 if(!(ctracklet = fTrack->GetTracklet(ip))) continue;
250 tracklet[ip] = (*ctracklet);
251 Double_t x0 = tracklet[ip].GetX0();
252 for(int ic=0; ic<35/*AliTRDseed:knTimebins*/; ic++){
253 if(!(c = tracklet[ip].GetClusters(ic))) continue;
254 Double_t xc = c->GetX(), yc = c->GetY(), zc = c->GetZ();
255 tracklet[ip].SetX(ic, xc-x0);
256 tracklet[ip].SetY(ic, yc);
257 tracklet[ip].SetZ(ic, zc);
261 // Do a Rieman fit (with tilt correction) for all tracklets
262 // except the one which is tested.
263 // (Based on AliTRDseed::IsOK() return false)
264 for(int ip=0; ip<6; ip++){
265 // reset tracklet to be tested
266 Double_t x0 = tracklet[ip].GetX0();
267 new(&tracklet[ip]) AliTRDseedV1();
268 tracklet[ip].SetX0(x0);
270 // fit Rieman with tilt correction
271 AliTRDseedV1::FitRiemanTilt(&tracklet[0], kTRUE);
273 // make a copy of the fit result
275 y0 = tracklet[ip].GetYref(0),
276 dydx = tracklet[ip].GetYref(1),
277 z0 = tracklet[ip].GetZref(0),
278 dzdx = tracklet[ip].GetZref(1);
281 tracklet[ip] = (*fTrack->GetTracklet(ip));
282 for(int ic=0; ic<35/*AliTRDseed:knTimebins*/; ic++){
283 if(!(c = tracklet[ip].GetClusters(ic))) continue;
284 Double_t xc = c->GetX(), yc = c->GetY(), zc = c->GetZ();
285 tracklet[ip].SetX(ic, xc-x0);
286 tracklet[ip].SetY(ic, yc);
287 tracklet[ip].SetZ(ic, zc);
291 AliTRDseedV1 ts(tracklet[ip]);
292 ts.SetYref(0, y0); ts.SetYref(1, dydx);
293 ts.SetZref(0, z0); ts.SetZref(1, dzdx);
296 // save results for plotting
297 Int_t plane = tracklet[ip].GetPlane();
298 Double_t dy = tracklet[ip].GetYfit(0) - ts.GetYfit(0);
299 Double_t tgy = tracklet[ip].GetYfit(1);
300 Double_t dtgy = (tracklet[ip].GetYfit(1) - ts.GetYfit(1))/(1. + tracklet[ip].GetYfit(1) * ts.GetYfit(1));
301 Double_t dz = tracklet[ip].GetZfit(0) - ts.GetZfit(0);
302 Double_t tgz = tracklet[ip].GetZfit(1);
303 Double_t dtgz = (tracklet[ip].GetZfit(1) - ts.GetZfit(1))/(1. + tracklet[ip].GetZfit(1) * ts.GetZfit(1));
304 TTreeSRedirector &cstreamer = *fOutputStreamer;
305 cstreamer << "ResidualsTrackletsTrack"
306 << "ref.=" << &tracklet[ip]
319 //____________________________________________________
320 void AliTRDtrackerDebug::AnalyseFindable(Char_t *treename){
322 // Calculates the number of findable tracklets defined as the number of tracklets
323 // per track candidate where the tan phi_tracklet is below 0.15 (maximum inclination
326 // Parameters: -the treename (this method can be used for all trees which store the
330 // A new TTree containing the number of findable tracklets and the number of clusters
331 // attached to the full track is stored to disk
334 TFile *debfile = TFile::Open("TRD.TrackerDebug.root");
335 fTree = (TTree *)(debfile->Get(treename));
337 AliError(Form("Tree %s not found in file TRDdebug.root. Abborting!", treename));
342 AliTRDseedV1 *tracklets[kNPlanes];
343 for(Int_t iPlane = 0; iPlane < AliTRDtrackerV1::kNPlanes; iPlane++)
344 tracklets[iPlane] = 0x0;
345 for(Int_t iPlane = 0; iPlane < kNPlanes; iPlane++)
346 fTree->SetBranchAddress(Form("S%d.", iPlane), &tracklets[iPlane]);
347 fTree->SetBranchAddress("EventNumber", &fgEventNumber);
348 fTree->SetBranchAddress("CandidateNumber", &fgCandidateNumber);
350 Int_t findable = 0, nClusters = 0;
351 Int_t nEntries = fTree->GetEntriesFast();
352 for(Int_t iEntry = 0; iEntry < nEntries; iEntry++){
353 printf("Entry %d\n", iEntry);
354 fTree->GetEntry(iEntry);
357 // Calculate Findable
358 for(Int_t iPlane = 0; iPlane < kNPlanes; iPlane++){
359 if (TMath::Abs(tracklets[iPlane]->GetYref(0) / tracklets[iPlane]->GetX0()) < 0.15) findable++;
360 if (!tracklets[iPlane]->IsOK()) continue;
361 nClusters += tracklets[iPlane]->GetN2();
365 TTreeSRedirector &cstreamer = *fOutputStreamer;
366 cstreamer << "AnalyseFindable"
367 << "EventNumber=" << fgEventNumber
368 << "CandidateNumber=" << fgCandidateNumber
369 << "Findable=" << findable
370 << "NClusters=" << nClusters
374 //____________________________________________________
375 void AliTRDtrackerDebug::AnalyseTiltedRiemanFit(){
377 // Creating a Data Set for the method FitTiltedRieman containing usefull variables
378 // Each variable can be addressed to tracks later. Data can be processed later.
383 // TODO: Match everything with Init and Process
385 TFile *debfile = TFile::Open("TRD.TrackerDebug.root");
386 fTree = (TTree *)(debfile->Get("MakeSeeds2"));
388 Int_t nEntries = fTree->GetEntries();
389 TLinearFitter *tiltedRiemanFitter = 0x0;
390 fTree->SetBranchAddress("FitterT.", &tiltedRiemanFitter);
391 fTree->SetBranchAddress("EventNumber", &fgEventNumber);
392 fTree->SetBranchAddress("CandidateNumber", &fgCandidateNumber);
393 for(Int_t entry = 0; entry < nEntries; entry++){
394 fTree->GetEntry(entry);
395 Double_t a = tiltedRiemanFitter->GetParameter(0);
396 Double_t b = tiltedRiemanFitter->GetParameter(1);
397 Double_t c = tiltedRiemanFitter->GetParameter(2);
398 Double_t offset = tiltedRiemanFitter->GetParameter(3);
399 Double_t slope = tiltedRiemanFitter->GetParameter(4);
400 Float_t radius = GetTrackRadius(a, b, c);
401 Float_t curvature = GetTrackCurvature(a, b, c);
402 Float_t dca = GetDCA(a, b, c);
403 TTreeSRedirector &cstreamer = *fOutputStreamer;
404 cstreamer << "AnalyseTiltedRiemanFit"
405 << "EventNumber=" << fgEventNumber
406 << "CandidateNumber=" << fgCandidateNumber
407 << "Radius=" << radius
408 << "Curvature=" << curvature
410 << "Offset=" << offset
416 //____________________________________________________
417 Float_t AliTRDtrackerDebug::GetTrackRadius(Float_t a, Float_t b, Float_t c) const {
419 // Calculates the track radius using the parameters given by the tilted Rieman fit
421 // Parameters: The three parameters from the Rieman fit
422 // Output: The track radius
425 if(1.0 + b*b - c*a > 0.0)
426 radius = TMath::Sqrt(1.0 + b*b - c*a )/a;
430 //____________________________________________________
431 Float_t AliTRDtrackerDebug::GetTrackCurvature(Float_t a, Float_t b, Float_t c) const {
433 // Calculates the track curvature using the parameters given by the linear fitter
435 // Parameters: the three parameters from the tilted Rieman fitter
436 // Output: the full track curvature
438 Float_t curvature = 1.0 + b*b - c*a;
440 curvature = a / TMath::Sqrt(curvature);
444 //____________________________________________________
445 Float_t AliTRDtrackerDebug::GetDCA(Float_t a, Float_t b, Float_t c) const {
447 // Calculates the Distance to Clostest Approach for the Vertex using the paramters
448 // given by the tilted Rieman fit
450 // Parameters: the three parameters from the tilted Rieman fitter
451 // Output: the Distance to Closest Approach
454 if (1.0 + b*b - c*a > 0.0) {
455 dca = -c / (TMath::Sqrt(1.0 + b*b - c*a) + TMath::Sqrt(1.0 + b*b));
460 //____________________________________________________
461 void AliTRDtrackerDebug::AnalyseMinMax()
464 TFile *debfile = TFile::Open("TRD.TrackerDebug.root");
466 AliError("File TRD.TrackerDebug.root not found!");
469 fTree = (TTree *)(debfile->Get("MakeSeeds0"));
471 AliError("Tree MakeSeeds0 not found in File TRD.TrackerDebug.root.");
474 AliTRDseedV1 *cseed[4] = {0x0, 0x0, 0x0, 0x0};
475 AliTRDcluster *c[4] = {0x0, 0x0, 0x0, 0x0};
476 for(Int_t il = 0; il < 4; il++){
477 fTree->SetBranchAddress(Form("Seed%d.", il), &cseed[il]);
478 fTree->SetBranchAddress(Form("c%d.",il), &c[il]);
480 fTree->SetBranchAddress("CandidateNumber", &fgCandidateNumber);
481 fTree->SetBranchAddress("EventNumber", &fgEventNumber);
482 Int_t entries = fTree->GetEntries();
483 for(Int_t ientry = 0; ientry < entries; ientry++){
484 fTree->GetEntry(ientry);
485 Float_t minmax[2] = { -100.0, 100.0 };
486 for (Int_t iLayer = 0; iLayer < 4; iLayer++) {
487 Float_t max = c[iLayer]->GetZ() + cseed[iLayer]->GetPadLength() * 0.5 + 1.0 - cseed[iLayer]->GetZref(0);
488 if (max < minmax[1]) minmax[1] = max;
489 Float_t min = c[iLayer]->GetZ()-cseed[iLayer]->GetPadLength() * 0.5 - 1.0 - cseed[iLayer]->GetZref(0);
490 if (min > minmax[0]) minmax[0] = min;
492 TTreeSRedirector &cstreamer = *fOutputStreamer;
493 cstreamer << "AnalyseMinMaxLayer"
494 << "EventNumber=" << fgEventNumber
495 << "CandidateNumber=" << fgCandidateNumber
496 << "Min=" << minmax[0]
497 << "Max=" << minmax[1]
502 //____________________________________________________
503 TCanvas* AliTRDtrackerDebug::PlotSeedingConfiguration(Char_t *direction, Int_t event, Int_t candidate){
505 // Plots the four seeding clusters, the helix fit and the reference Points for
506 // a given combination consisting of eventnr. and candidatenr.
508 // Parameters: -direction (y or z)
510 // -Candidate that has to be plotted
512 const Float_t kxmin = 280;
513 const Float_t kxmax = 380;
514 const Float_t kxdelta = (kxmax - kxmin)/1000;
516 if((strcmp(direction, "y") != 0) && (strcmp(direction, "z") != 0)){
517 AliError(Form("Direction %s does not exist. Abborting!", direction));
521 TFile *debfile = TFile::Open("TRD.TrackerDebug.root");
523 AliError("File TRD.TrackerDebug.root not found!");
526 fTree = (TTree *)(debfile->Get("MakeSeeds0"));
528 AliError("Tree MakeSeeds0 not found in File TRD.TrackerDebug.root.");
532 TGraph *seedcl = new TGraph(4);
533 TGraph *seedRef = new TGraph(4);
534 TGraph *riemanFit = new TGraph(1000);
535 seedcl->SetMarkerStyle(20);
536 seedcl->SetMarkerColor(kRed);
537 seedRef->SetMarkerStyle(2);
539 AliTRDcluster *c[4] = {0x0, 0x0, 0x0, 0x0};
540 AliRieman *rim = 0x0;
541 Bool_t found = kFALSE;
542 for(Int_t il = 0; il < 4; il++) fTree->SetBranchAddress(Form("c%d.",il), &c[il]);
543 fTree->SetBranchAddress("EventNumber", &fgEventNumber);
544 fTree->SetBranchAddress("CandidateNumber", &fgCandidateNumber);
545 fTree->SetBranchAddress("RiemanFitter.", &rim);
546 Int_t entries = fTree->GetEntries();
547 for(Int_t entry = 0; entry < entries; entry++){
548 fTree->GetEntry(entry);
549 if(fgEventNumber < event) continue;
550 if(fgEventNumber > event) break;
551 // EventNumber matching: Do the same for the candidate number
552 if(fgCandidateNumber < candidate) continue;
553 if(fgCandidateNumber > candidate) break;
556 for(Int_t il = 0; il < 4; il++){
557 Float_t cluster = 0.0, reference = 0.0;
558 if(!strcmp(direction, "y")){
559 cluster = c[il]->GetY();
560 reference = rim->GetYat(c[il]->GetX());
563 cluster = c[il]->GetZ();
564 reference = rim->GetZat(c[il]->GetX());
566 seedcl->SetPoint(nPoints, cluster, c[il]->GetX());
567 seedRef->SetPoint(nPoints, reference , c[il]->GetX());
570 // evaluate the fitter Function numerically
572 for(Int_t ipt = 0; ipt < 1000; ipt++){
573 Float_t x = kxmin + ipt * kxdelta;
575 if(!strcmp(direction, "y"))
576 point = rim->GetYat(x);
578 point = rim->GetZat(x);
579 riemanFit->SetPoint(nPoints++, point, x);
581 // We reached the End: break
585 seedcl->SetTitle(Form("Event %d, Candidate %d\n", fgEventNumber, fgCandidateNumber));
586 seedRef->SetTitle(Form("Event %d, Candidate %d\n", fgEventNumber, fgCandidateNumber));
587 riemanFit->SetTitle(Form("Event %d, Candidate %d\n", fgEventNumber, fgCandidateNumber));
588 TCanvas *c1 = new TCanvas();
590 seedRef->Draw("psame");
591 riemanFit->Draw("lpsame");
595 AliError(Form("Combination consisting of event %d and candidate %d not found", event, candidate));
603 //____________________________________________________
604 TCanvas* AliTRDtrackerDebug::PlotFullTrackFit(Int_t event, Int_t candidate, Int_t iteration, Char_t *direction){
606 // Plots the tracklets (clusters and reference in y direction) and the fitted function for several iterations
607 // in the function ImproveSeedQuality (default is before ImproveSeedQuality)
609 // Parameters: -Event Number
611 // -Iteration Number in ImproveSeedQuality (default: -1 = before ImproveSeedQuality)
612 // -direction (default: y)
613 // Output: -TCanvas (containing the Picture);
615 const Float_t kxmin = 280;
616 const Float_t kxmax = 380;
617 const Float_t kxdelta = (kxmax - kxmin)/1000;
619 if(strcmp(direction, "y") && strcmp(direction, "z")){
620 AliError(Form("Direction %s does not exist. Abborting!", direction));
624 TFile *debfile = TFile::Open("TRD.TrackerDebug.root");
626 AliError("File TRD.TrackerDebug.root not found.");
629 TString *treename = 0x0;
631 treename = new TString("ImproveSeedQuality");
633 treename = new TString("MakeSeeds1");
634 fTree = (TTree *)(debfile->Get(treename->Data()));
636 AliError(Form("Tree %s not found in File TRD.TrackerDebug.root.", treename->Data()));
642 TGraph *fitfun = new TGraph(1000);
643 // Prepare containers
644 Float_t x0[AliTRDtrackerV1::kNPlanes],
645 refP[AliTRDtrackerV1::kNPlanes],
646 clx[AliTRDtrackerV1::kNPlanes * AliTRDtrackerV1::kNTimeBins],
647 clp[AliTRDtrackerV1::kNPlanes * AliTRDtrackerV1::kNTimeBins];
648 Int_t nLayers = 0, ncls = 0;
650 TLinearFitter *fitter = 0x0;
651 AliTRDseedV1 *tracklet[6] = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0};
652 for(Int_t iLayer = 0; iLayer < 6; iLayer++)
653 fTree->SetBranchAddress(Form("S%d.", iLayer), &tracklet[iLayer]);
654 fTree->SetBranchAddress("FitterT.", &fitter);
655 fTree->SetBranchAddress("EventNumber", &fgEventNumber);
656 fTree->SetBranchAddress("CandidateNumber", &fgCandidateNumber);
658 Int_t nEntries = fTree->GetEntriesFast();
659 Bool_t found = kFALSE;
660 for(Int_t entry = 0; entry < nEntries; entry++){
661 fTree->GetEntry(entry);
662 if(fgEventNumber < event) continue;
663 if(fgEventNumber > event) break;
664 // EventNumber matching: Do the same for the candidate number
665 if(fgCandidateNumber < candidate) continue;
666 if(fgCandidateNumber > candidate) break;
669 for(Int_t iLayer = 0; iLayer < 6; iLayer++){
670 if(!tracklet[iLayer]->IsOK()) continue;
671 x0[nLayers] = tracklet[iLayer]->GetX0();
672 if(!strcmp(direction, "y"))
673 refP[nLayers] = tracklet[iLayer]->GetYref(0);
675 refP[nLayers] = tracklet[iLayer]->GetZref(0);
677 for(Int_t itb = 0; itb < 30; itb++){
678 if(!tracklet[iLayer]->IsUsable(itb)) continue;
679 AliTRDcluster *cl = tracklet[iLayer]->GetClusters(itb);
680 if(!strcmp(direction, "y"))
681 clp[ncls] = cl->GetY();
683 clp[ncls] = cl->GetZ();
684 clx[ncls] = cl->GetX();
688 // Add function derived by the tilted Rieman fit (Defined by the curvature)
690 if(!strcmp(direction, "y")){
691 Double_t a = fitter->GetParameter(0);
692 Double_t b = fitter->GetParameter(1);
693 Double_t c = fitter->GetParameter(2);
694 Double_t curvature = 1.0 + b*b - c*a;
695 if (curvature > 0.0) {
696 curvature = a / TMath::Sqrt(curvature);
698 // Numerical evaluation of the function:
699 for(Int_t ipt = 0; ipt < 1000; ipt++){
700 Float_t x = kxmin + ipt * kxdelta;
701 Double_t res = (x * a + b); // = (x - x0)/y0
703 res = 1.0 - c * a + b * b - res; // = (R^2 - (x - x0)^2)/y0^2
706 res = TMath::Sqrt(res);
709 fitfun->SetPoint(nPoints++, y, x);
713 Double_t offset = fitter->GetParameter(3);
714 Double_t slope = fitter->GetParameter(4);
715 // calculate the reference x (defined as medium between layer 2 and layer 3)
716 // same procedure as in the tracker code
717 Float_t medx = 0, xref = 0;
718 Int_t startIndex = 5, nDistances = 0;
719 for(Int_t iLayer = 5; iLayer > 0; iLayer--){
720 if(tracklet[iLayer]->IsOK() && tracklet[iLayer - 1]->IsOK()){
721 medx += tracklet[iLayer]->GetX0() - tracklet[iLayer - 1]->GetX0();
722 startIndex = iLayer - 1;
730 Float_t xpos[2]; memset(xpos, 0, sizeof(Float_t) * 2);
731 Int_t ien = 0, idiff = 0;
732 for(Int_t iLayer = 5; iLayer > 0; iLayer--){
733 if(tracklet[iLayer]->IsOK()){
734 xpos[ien++] = tracklet[iLayer]->GetX0();
742 medx = (xpos[0] - xpos[1])/idiff;
744 xref = tracklet[startIndex]->GetX0() + medx * (2.5 - startIndex) - 0.5 * (AliTRDgeometry::AmThick() + AliTRDgeometry::DrThick());
746 for(Int_t ipt = 0; ipt < 1000; ipt++){
747 Float_t x = kxmin + ipt * kxdelta;
748 Float_t z = offset + slope * (x - xref);
749 fitfun->SetPoint(nPoints++, z, x);
755 TGraph *trGraph = new TGraph(ncls);
756 TGraph *refPoints = new TGraph(nLayers);
757 trGraph->SetMarkerStyle(20);
758 trGraph->SetMarkerColor(kRed);
759 refPoints->SetMarkerStyle(21);
760 refPoints->SetMarkerColor(kBlue);
762 for(Int_t iLayer = 0; iLayer < nLayers; iLayer++)
763 refPoints->SetPoint(iLayer, refP[iLayer], x0[iLayer]);
764 for(Int_t icls = 0; icls < ncls; icls++)
765 trGraph->SetPoint(icls, clp[icls], clx[icls]);
766 TCanvas *c1 = new TCanvas();
767 trGraph->SetTitle(Form("Event %d, Candidate %d\n", fgEventNumber, fgCandidateNumber));
768 refPoints->SetTitle(Form("Event %d, Candidate %d\n", fgEventNumber, fgCandidateNumber));
769 fitfun->SetTitle(Form("Event %d, Candidate %d\n", fgEventNumber, fgCandidateNumber));
771 refPoints->Draw("psame");
772 fitfun->Draw("lpsame");
776 AliError(Form("Combination consisting of event %d and candidate %d not found", event, candidate));