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 ///////////////////////////////////////////////////////////////////////////////
30 #include "TTreeStream.h"
31 #include "TLinearFitter.h"
37 #include "AliRieman.h"
39 #include "AliTRDgeometry.h"
40 #include "AliTRDtrackV1.h"
41 #include "AliTRDseedV1.h"
42 #include "AliTRDcluster.h"
43 #include "AliTRDgeometry.h"
45 #include "AliTRDtrackerDebug.h"
47 ClassImp(AliTRDtrackerDebug)
49 Int_t AliTRDtrackerDebug::fgEventNumber = 0;
50 Int_t AliTRDtrackerDebug::fgTrackNumber = 0;
51 Int_t AliTRDtrackerDebug::fgCandidateNumber = 0;
53 //____________________________________________________
54 AliTRDtrackerDebug::AliTRDtrackerDebug() : AliTRDtrackerV1()
55 ,fOutputStreamer(NULL)
63 // Default constructor
65 fOutputStreamer = new TTreeSRedirector("TRD.Debug.root");
68 //____________________________________________________
69 AliTRDtrackerDebug::~AliTRDtrackerDebug()
73 delete fOutputStreamer;
77 //____________________________________________________
78 void AliTRDtrackerDebug::Draw(Option_t *)
80 // steer draw function
84 //____________________________________________________
85 Bool_t AliTRDtrackerDebug::Init()
87 // steer linking data for various debug streams
88 fTrack = new AliTRDtrackV1();
89 fTree->SetBranchAddress("ncl", &fNClusters);
90 fTree->SetBranchAddress("track.", &fTrack);
94 //____________________________________________________
95 Bool_t AliTRDtrackerDebug::Open(const char *method)
97 // Connect to the tracker debug file
99 TDirectory *savedir = gDirectory;
100 TFile::Open("TRD.TrackerDebugger.root");
101 fTree = (TTree*)gFile->Get(method);
103 AliInfo(Form("Can not find debug stream for the %s method.\n", method));
111 //____________________________________________________
112 Int_t AliTRDtrackerDebug::Process()
114 // steer debug process threads
116 for(int it = 0; it<fTree->GetEntries(); it++){
117 if(!fTree->GetEntry(it)) continue;
118 if(!fNClusters) continue;
119 fAlpha = fTrack->GetAlpha();
120 //printf("Processing track %d [%d] ...\n", it, fNClusters);
121 ResidualsTrackletsTrack();
123 const AliTRDseedV1 *tracklet = NULL;
124 for(int ip = 5; ip>=0; ip--){
125 if(!(tracklet = fTrack->GetTracklet(ip))) continue;
126 if(!tracklet->GetN()) continue;
128 ResidualsClustersTrack(tracklet);
129 ResidualsClustersTracklet(tracklet);
130 ResidualsClustersParametrisation(tracklet);
137 //____________________________________________________
138 void AliTRDtrackerDebug::ResidualsClustersTrack(const AliTRDseedV1 *tracklet)
140 // Calculate averange distances from clusters to the TRD track
143 AliTRDcluster *c = NULL;
144 for(int ic=0; ic<35/*AliTRDseed:knTimebins*/; ic++){
145 if(!(c = tracklet->GetClusters(ic))) continue;
146 Double_t xc = c->GetX(), yc = c->GetY(), zc = c->GetZ();
148 // propagate track to cluster
149 PropagateToX(*fTrack, xc, 2.);
152 // transform to local tracking coordinates
153 //Double_t xg = x[0] * TMath::Cos(fAlpha) + x[1] * TMath::Sin(fAlpha);
154 Double_t yg = -x[0] * TMath::Sin(fAlpha) + x[1] * TMath::Cos(fAlpha);
156 // apply tilt pad correction
157 yc+= (zc - x[2]) * tracklet->GetTilt();
161 TTreeSRedirector &cstreamer = *fOutputStreamer;
162 cstreamer << "ResidualsClustersTrack"
169 //____________________________________________________
170 void AliTRDtrackerDebug::ResidualsClustersTracklet(const AliTRDseedV1 *tracklet) const
172 // Calculates distances from clusters to tracklets
174 Double_t x0 = tracklet->GetX0(),
175 y0 = tracklet->GetYfit(0),
176 ys = tracklet->GetYfit(1);
177 //z0 = tracklet->GetZfit(0),
178 //zs = tracklet->GetZfit(1);
180 AliTRDcluster *c = NULL;
181 for(int ic=0; ic<35/*AliTRDseed:knTimebins*/; ic++){
182 if(!(c = tracklet->GetClusters(ic))) continue;
183 Double_t xc = c->GetX(), yc = c->GetY()/*, zc = c->GetZ()*/;
184 Double_t dy = yc- (y0-(x0-xc)*ys);
187 //ResidualsClustersTracklet->Draw("TMath::Abs(10.*dy):TMath::ATan(ys)*TMath::RadToDeg()>>h(20, -40, 40)", "", "prof");
188 TTreeSRedirector &cstreamer = *fOutputStreamer;
189 cstreamer << "ResidualsClustersTracklet"
197 //____________________________________________________
198 void AliTRDtrackerDebug::ResidualsClustersParametrisation(const AliTRDseedV1 *tracklet) const
200 // Calculates distances from clusters to Rieman fit.
202 // store cluster positions
203 Double_t x0 = tracklet->GetX0();
204 AliTRDcluster *c = NULL;
206 Double_t x[2]; Int_t ncl, mcl, jc;
207 TLinearFitter fitter(3, "hyp2");
208 for(int ic=0; ic<35/*AliTRDseed:knTimebins*/; ic++){
209 if(!(c = tracklet->GetClusters(ic))) continue;
210 Double_t xc = c->GetX(), yc = c->GetY()/*, zc = c->GetZ()*/;
212 jc = ic; ncl = 0; mcl=0; fitter.ClearPoints();
216 jc = ic + ((mcl&1)?-1:1)*(mcl>>1);
218 if(jc<0 || jc>=35) continue;
219 if(!(c = tracklet->GetClusters(jc))) continue;
223 fitter.AddPoint(x, c->GetY(), c->GetSigmaY2());
227 Double_t dy = yc - fitter.GetParameter(0) -fitter.GetParameter(1) * (xc-x0) - fitter.GetParameter(2)* (xc-x0)*(xc-x0);
229 TTreeSRedirector &cstreamer = *fOutputStreamer;
230 cstreamer << "ResidualsClustersParametrisation"
237 //____________________________________________________
238 void AliTRDtrackerDebug::ResidualsTrackletsTrack() const
240 // Calculates distances from tracklets to the TRD track.
242 if(fTrack->GetNumberOfTracklets() < 6) return;
244 // build a working copy of the tracklets attached to the track
245 // and initialize working variables fX, fY and fZ
246 //AliTRDseedV1 tracklet[6] = {NULL, NULL, NULL, NULL, NULL, NULL};
247 AliTRDseedV1 tracklet[6];
248 const AliTRDseedV1 *ctracklet = NULL;
249 for(int ip = 0; ip<6; ip++){
250 if(!(ctracklet = fTrack->GetTracklet(ip))) continue;
251 tracklet[ip] = (*ctracklet);
252 // Double_t x0 = tracklet[ip].GetX0();
253 // for(int ic=0; ic<AliTRDseedV1:knTimebins; ic++){
254 // if(!(c = tracklet[ip].GetClusters(ic))) continue;
255 // Double_t xc = c->GetX(), yc = c->GetY(), zc = c->GetZ();
256 // tracklet[ip].SetX(ic, xc-x0);
257 // tracklet[ip].SetY(ic, yc);
258 // tracklet[ip].SetZ(ic, zc);
262 // Do a Rieman fit (with tilt correction) for all tracklets
263 // except the one which is tested.
264 // (Based on AliTRDseed::IsOK() return false)
265 for(int ip=0; ip<6; ip++){
266 // reset tracklet to be tested
267 Double_t x0 = tracklet[ip].GetX0();
268 new(&tracklet[ip]) AliTRDseedV1();
269 tracklet[ip].SetX0(x0);
271 // fit Rieman with tilt correction
272 AliTRDtrackerV1::FitRiemanTilt(NULL, &tracklet[0], kTRUE);
274 // make a copy of the fit result
276 y0 = tracklet[ip].GetYref(0),
277 dydx = tracklet[ip].GetYref(1),
278 z0 = tracklet[ip].GetZref(0),
279 dzdx = tracklet[ip].GetZref(1);
282 tracklet[ip] = (*fTrack->GetTracklet(ip));
283 // for(int ic=0; ic<AliTRDseedV1:knTimebins; ic++){
284 // if(!(c = tracklet[ip].GetClusters(ic))) continue;
285 // Double_t xc = c->GetX(), yc = c->GetY(), zc = c->GetZ();
286 // tracklet[ip].SetX(ic, xc-x0);
287 // tracklet[ip].SetY(ic, yc);
288 // tracklet[ip].SetZ(ic, zc);
292 AliTRDseedV1 ts(tracklet[ip]);
293 ts.SetYref(0, y0); ts.SetYref(1, dydx);
294 ts.SetZref(0, z0); ts.SetZref(1, dzdx);
297 // save results for plotting
298 Int_t plane = tracklet[ip].GetPlane();
299 Double_t dy = tracklet[ip].GetYfit(0) - ts.GetYfit(0);
300 Double_t tgy = tracklet[ip].GetYfit(1);
301 Double_t dtgy = (tracklet[ip].GetYfit(1) - ts.GetYfit(1))/(1. + tracklet[ip].GetYfit(1) * ts.GetYfit(1));
302 Double_t dz = tracklet[ip].GetZfit(0) - ts.GetZfit(0);
303 Double_t tgz = tracklet[ip].GetZfit(1);
304 Double_t dtgz = (tracklet[ip].GetZfit(1) - ts.GetZfit(1))/(1. + tracklet[ip].GetZfit(1) * ts.GetZfit(1));
305 TTreeSRedirector &cstreamer = *fOutputStreamer;
306 cstreamer << "ResidualsTrackletsTrack"
307 << "ref.=" << &tracklet[ip]
320 //____________________________________________________
321 void AliTRDtrackerDebug::AnalyseFindable(Char_t *treename){
323 // Calculates the number of findable tracklets defined as the number of tracklets
324 // per track candidate where the tan phi_tracklet is below 0.15 (maximum inclination
327 // Parameters: -the treename (this method can be used for all trees which store the
331 // A new TTree containing the number of findable tracklets and the number of clusters
332 // attached to the full track is stored to disk
335 TFile *debfile = TFile::Open("TRD.TrackerDebug.root");
336 fTree = (TTree *)(debfile->Get(treename));
338 AliError(Form("Tree %s not found in file TRDdebug.root. Abborting!", treename));
343 AliTRDseedV1 *tracklets[kNPlanes];
344 for(Int_t iPlane = 0; iPlane < AliTRDtrackerV1::kNPlanes; iPlane++)
345 tracklets[iPlane] = NULL;
346 for(Int_t iPlane = 0; iPlane < kNPlanes; iPlane++)
347 fTree->SetBranchAddress(Form("S%d.", iPlane), &tracklets[iPlane]);
348 fTree->SetBranchAddress("EventNumber", &fgEventNumber);
349 fTree->SetBranchAddress("CandidateNumber", &fgCandidateNumber);
351 Int_t findable = 0, nClusters = 0;
352 Int_t nEntries = fTree->GetEntriesFast();
353 for(Int_t iEntry = 0; iEntry < nEntries; iEntry++){
354 printf("Entry %d\n", iEntry);
355 fTree->GetEntry(iEntry);
358 // Calculate Findable
359 for(Int_t iPlane = 0; iPlane < kNPlanes; iPlane++){
360 if (TMath::Abs(tracklets[iPlane]->GetYref(0) / tracklets[iPlane]->GetX0()) < 0.15) findable++;
361 if (!tracklets[iPlane]->IsOK()) continue;
362 nClusters += tracklets[iPlane]->GetN2();
366 TTreeSRedirector &cstreamer = *fOutputStreamer;
367 cstreamer << "AnalyseFindable"
368 << "EventNumber=" << fgEventNumber
369 << "CandidateNumber=" << fgCandidateNumber
370 << "Findable=" << findable
371 << "NClusters=" << nClusters
375 //____________________________________________________
376 void AliTRDtrackerDebug::AnalyseTiltedRiemanFit(){
378 // Creating a Data Set for the method FitTiltedRieman containing usefull variables
379 // Each variable can be addressed to tracks later. Data can be processed later.
384 // TODO: Match everything with Init and Process
386 TFile *debfile = TFile::Open("TRD.TrackerDebug.root");
387 fTree = (TTree *)(debfile->Get("MakeSeeds2"));
389 Int_t nEntries = fTree->GetEntries();
390 TLinearFitter *tiltedRiemanFitter = NULL;
391 fTree->SetBranchAddress("FitterT.", &tiltedRiemanFitter);
392 fTree->SetBranchAddress("EventNumber", &fgEventNumber);
393 fTree->SetBranchAddress("CandidateNumber", &fgCandidateNumber);
394 for(Int_t entry = 0; entry < nEntries; entry++){
395 fTree->GetEntry(entry);
396 Double_t a = tiltedRiemanFitter->GetParameter(0);
397 Double_t b = tiltedRiemanFitter->GetParameter(1);
398 Double_t c = tiltedRiemanFitter->GetParameter(2);
399 Double_t offset = tiltedRiemanFitter->GetParameter(3);
400 Double_t slope = tiltedRiemanFitter->GetParameter(4);
401 Float_t radius = GetTrackRadius(a, b, c);
402 Float_t curvature = GetTrackCurvature(a, b, c);
403 Float_t dca = GetDCA(a, b, c);
404 TTreeSRedirector &cstreamer = *fOutputStreamer;
405 cstreamer << "AnalyseTiltedRiemanFit"
406 << "EventNumber=" << fgEventNumber
407 << "CandidateNumber=" << fgCandidateNumber
408 << "Radius=" << radius
409 << "Curvature=" << curvature
411 << "Offset=" << offset
417 //____________________________________________________
418 Float_t AliTRDtrackerDebug::GetTrackRadius(Float_t a, Float_t b, Float_t c) const {
420 // Calculates the track radius using the parameters given by the tilted Rieman fit
422 // Parameters: The three parameters from the Rieman fit
423 // Output: The track radius
426 if(1.0 + b*b - c*a > 0.0)
427 radius = TMath::Sqrt(1.0 + b*b - c*a )/a;
431 //____________________________________________________
432 Float_t AliTRDtrackerDebug::GetTrackCurvature(Float_t a, Float_t b, Float_t c) const {
434 // Calculates the track curvature using the parameters given by the linear fitter
436 // Parameters: the three parameters from the tilted Rieman fitter
437 // Output: the full track curvature
439 Float_t curvature = 1.0 + b*b - c*a;
441 curvature = a / TMath::Sqrt(curvature);
445 //____________________________________________________
446 Float_t AliTRDtrackerDebug::GetDCA(Float_t a, Float_t b, Float_t c) const {
448 // Calculates the Distance to Clostest Approach for the Vertex using the paramters
449 // given by the tilted Rieman fit
451 // Parameters: the three parameters from the tilted Rieman fitter
452 // Output: the Distance to Closest Approach
455 if (1.0 + b*b - c*a > 0.0) {
456 dca = -c / (TMath::Sqrt(1.0 + b*b - c*a) + TMath::Sqrt(1.0 + b*b));
461 //____________________________________________________
462 void AliTRDtrackerDebug::AnalyseMinMax()
464 // Development function related to the old tracking code
465 TFile *debfile = TFile::Open("TRD.TrackerDebug.root");
467 AliError("File TRD.TrackerDebug.root not found!");
470 fTree = (TTree *)(debfile->Get("MakeSeeds0"));
472 AliError("Tree MakeSeeds0 not found in File TRD.TrackerDebug.root.");
475 AliTRDseedV1 *cseed[4] = {NULL, NULL, NULL, NULL};
476 AliTRDcluster *c[4] = {NULL, NULL, NULL, NULL};
477 for(Int_t il = 0; il < 4; il++){
478 fTree->SetBranchAddress(Form("Seed%d.", il), &cseed[il]);
479 fTree->SetBranchAddress(Form("c%d.",il), &c[il]);
481 fTree->SetBranchAddress("CandidateNumber", &fgCandidateNumber);
482 fTree->SetBranchAddress("EventNumber", &fgEventNumber);
483 Int_t entries = fTree->GetEntries();
484 for(Int_t ientry = 0; ientry < entries; ientry++){
485 fTree->GetEntry(ientry);
486 Float_t minmax[2] = { -100.0, 100.0 };
487 for (Int_t iLayer = 0; iLayer < 4; iLayer++) {
488 Float_t max = c[iLayer]->GetZ() + cseed[iLayer]->GetPadLength() * 0.5 + 1.0 - cseed[iLayer]->GetZref(0);
489 if (max < minmax[1]) minmax[1] = max;
490 Float_t min = c[iLayer]->GetZ()-cseed[iLayer]->GetPadLength() * 0.5 - 1.0 - cseed[iLayer]->GetZref(0);
491 if (min > minmax[0]) minmax[0] = min;
493 TTreeSRedirector &cstreamer = *fOutputStreamer;
494 cstreamer << "AnalyseMinMaxLayer"
495 << "EventNumber=" << fgEventNumber
496 << "CandidateNumber=" << fgCandidateNumber
497 << "Min=" << minmax[0]
498 << "Max=" << minmax[1]
503 //____________________________________________________
504 TCanvas* AliTRDtrackerDebug::PlotSeedingConfiguration(const Char_t *direction, Int_t event, Int_t candidate){
506 // Plots the four seeding clusters, the helix fit and the reference Points for
507 // a given combination consisting of eventnr. and candidatenr.
509 // Parameters: -direction (y or z)
511 // -Candidate that has to be plotted
513 const Float_t kxmin = 280;
514 const Float_t kxmax = 380;
515 const Float_t kxdelta = (kxmax - kxmin)/1000;
517 if((strcmp(direction, "y") != 0) && (strcmp(direction, "z") != 0)){
518 AliError(Form("Direction %s does not exist. Abborting!", direction));
522 TFile *debfile = TFile::Open("TRD.TrackerDebug.root");
524 AliError("File TRD.TrackerDebug.root not found!");
527 fTree = (TTree *)(debfile->Get("MakeSeeds0"));
529 AliError("Tree MakeSeeds0 not found in File TRD.TrackerDebug.root.");
533 TGraph *seedcl = new TGraph(4);
534 TGraph *seedRef = new TGraph(4);
535 TGraph *riemanFit = new TGraph(1000);
536 seedcl->SetMarkerStyle(20);
537 seedcl->SetMarkerColor(kRed);
538 seedRef->SetMarkerStyle(2);
540 AliTRDcluster *c[4] = {NULL, NULL, NULL, NULL};
541 AliRieman *rim = NULL;
542 Bool_t found = kFALSE;
543 for(Int_t il = 0; il < 4; il++) fTree->SetBranchAddress(Form("c%d.",il), &c[il]);
544 fTree->SetBranchAddress("EventNumber", &fgEventNumber);
545 fTree->SetBranchAddress("CandidateNumber", &fgCandidateNumber);
546 fTree->SetBranchAddress("RiemanFitter.", &rim);
547 Int_t entries = fTree->GetEntries();
548 for(Int_t entry = 0; entry < entries; entry++){
549 fTree->GetEntry(entry);
550 if(fgEventNumber < event) continue;
551 if(fgEventNumber > event) break;
552 // EventNumber matching: Do the same for the candidate number
553 if(fgCandidateNumber < candidate) continue;
554 if(fgCandidateNumber > candidate) break;
557 for(Int_t il = 0; il < 4; il++){
558 Float_t cluster = 0.0, reference = 0.0;
559 if(!strcmp(direction, "y")){
560 cluster = c[il]->GetY();
561 reference = rim->GetYat(c[il]->GetX());
564 cluster = c[il]->GetZ();
565 reference = rim->GetZat(c[il]->GetX());
567 seedcl->SetPoint(nPoints, cluster, c[il]->GetX());
568 seedRef->SetPoint(nPoints, reference , c[il]->GetX());
571 // evaluate the fitter Function numerically
573 for(Int_t ipt = 0; ipt < 1000; ipt++){
574 Float_t x = kxmin + ipt * kxdelta;
576 if(!strcmp(direction, "y"))
577 point = rim->GetYat(x);
579 point = rim->GetZat(x);
580 riemanFit->SetPoint(nPoints++, point, x);
582 // We reached the End: break
586 seedcl->SetTitle(Form("Event %d, Candidate %d\n", fgEventNumber, fgCandidateNumber));
587 seedRef->SetTitle(Form("Event %d, Candidate %d\n", fgEventNumber, fgCandidateNumber));
588 riemanFit->SetTitle(Form("Event %d, Candidate %d\n", fgEventNumber, fgCandidateNumber));
589 TCanvas *c1 = new TCanvas();
591 seedRef->Draw("psame");
592 riemanFit->Draw("lpsame");
596 AliError(Form("Combination consisting of event %d and candidate %d not found", event, candidate));
604 //____________________________________________________
605 TCanvas* AliTRDtrackerDebug::PlotFullTrackFit(Int_t event, Int_t candidate, Int_t iteration, const Char_t *direction){
607 // Plots the tracklets (clusters and reference in y direction) and the fitted function for several iterations
608 // in the function ImproveSeedQuality (default is before ImproveSeedQuality)
610 // Parameters: -Event Number
612 // -Iteration Number in ImproveSeedQuality (default: -1 = before ImproveSeedQuality)
613 // -direction (default: y)
614 // Output: -TCanvas (containing the Picture);
616 const Float_t kxmin = 280;
617 const Float_t kxmax = 380;
618 const Float_t kxdelta = (kxmax - kxmin)/1000;
620 if(strcmp(direction, "y") && strcmp(direction, "z")){
621 AliError(Form("Direction %s does not exist. Abborting!", direction));
625 TFile *debfile = TFile::Open("TRD.TrackerDebug.root");
627 AliError("File TRD.TrackerDebug.root not found.");
630 TString *treename = NULL;
632 treename = new TString("ImproveSeedQuality");
634 treename = new TString("MakeSeeds1");
635 fTree = (TTree *)(debfile->Get(treename->Data()));
637 AliError(Form("Tree %s not found in File TRD.TrackerDebug.root.", treename->Data()));
643 TGraph *fitfun = new TGraph(1000);
644 // Prepare containers
645 Float_t x0[AliTRDtrackerV1::kNPlanes],
646 refP[AliTRDtrackerV1::kNPlanes],
647 clx[AliTRDtrackerV1::kNPlanes * AliTRDtrackerV1::kNTimeBins],
648 clp[AliTRDtrackerV1::kNPlanes * AliTRDtrackerV1::kNTimeBins];
649 Int_t nLayers = 0, ncls = 0;
651 TLinearFitter *fitter = NULL;
652 AliTRDseedV1 *tracklet[6] = {NULL, NULL, NULL, NULL, NULL, NULL};
653 for(Int_t iLayer = 0; iLayer < 6; iLayer++)
654 fTree->SetBranchAddress(Form("S%d.", iLayer), &tracklet[iLayer]);
655 fTree->SetBranchAddress("FitterT.", &fitter);
656 fTree->SetBranchAddress("EventNumber", &fgEventNumber);
657 fTree->SetBranchAddress("CandidateNumber", &fgCandidateNumber);
659 Int_t nEntries = fTree->GetEntriesFast();
660 Bool_t found = kFALSE;
661 for(Int_t entry = 0; entry < nEntries; entry++){
662 fTree->GetEntry(entry);
663 if(fgEventNumber < event) continue;
664 if(fgEventNumber > event) break;
665 // EventNumber matching: Do the same for the candidate number
666 if(fgCandidateNumber < candidate) continue;
667 if(fgCandidateNumber > candidate) break;
670 for(Int_t iLayer = 0; iLayer < 6; iLayer++){
671 if(!tracklet[iLayer]->IsOK()) continue;
672 x0[nLayers] = tracklet[iLayer]->GetX0();
673 if(!strcmp(direction, "y"))
674 refP[nLayers] = tracklet[iLayer]->GetYref(0);
676 refP[nLayers] = tracklet[iLayer]->GetZref(0);
678 for(Int_t itb = 0; itb < 30; itb++){
679 if(!tracklet[iLayer]->IsUsable(itb)) continue;
680 AliTRDcluster *cl = tracklet[iLayer]->GetClusters(itb);
681 if(!strcmp(direction, "y"))
682 clp[ncls] = cl->GetY();
684 clp[ncls] = cl->GetZ();
685 clx[ncls] = cl->GetX();
689 // Add function derived by the tilted Rieman fit (Defined by the curvature)
691 if(!strcmp(direction, "y")){
692 Double_t a = fitter->GetParameter(0);
693 Double_t b = fitter->GetParameter(1);
694 Double_t c = fitter->GetParameter(2);
695 Double_t curvature = 1.0 + b*b - c*a;
696 if (curvature > 0.0) {
697 curvature = a / TMath::Sqrt(curvature);
699 // Numerical evaluation of the function:
700 for(Int_t ipt = 0; ipt < 1000; ipt++){
701 Float_t x = kxmin + ipt * kxdelta;
702 Double_t res = (x * a + b); // = (x - x0)/y0
704 res = 1.0 - c * a + b * b - res; // = (R^2 - (x - x0)^2)/y0^2
707 res = TMath::Sqrt(res);
710 fitfun->SetPoint(nPoints++, y, x);
714 Double_t offset = fitter->GetParameter(3);
715 Double_t slope = fitter->GetParameter(4);
716 // calculate the reference x (defined as medium between layer 2 and layer 3)
717 // same procedure as in the tracker code
718 Float_t medx = 0, xref = 0;
719 Int_t startIndex = 5, nDistances = 0;
720 for(Int_t iLayer = 5; iLayer > 0; iLayer--){
721 if(tracklet[iLayer]->IsOK() && tracklet[iLayer - 1]->IsOK()){
722 medx += tracklet[iLayer]->GetX0() - tracklet[iLayer - 1]->GetX0();
723 startIndex = iLayer - 1;
731 Float_t xpos[2]; memset(xpos, 0, sizeof(Float_t) * 2);
732 Int_t ien = 0, idiff = 0;
733 for(Int_t iLayer = 5; iLayer > 0; iLayer--){
734 if(tracklet[iLayer]->IsOK()){
735 xpos[ien++] = tracklet[iLayer]->GetX0();
743 medx = (xpos[0] - xpos[1])/idiff;
745 xref = tracklet[startIndex]->GetX0() + medx * (2.5 - startIndex) - 0.5 * (AliTRDgeometry::AmThick() + AliTRDgeometry::DrThick());
747 for(Int_t ipt = 0; ipt < 1000; ipt++){
748 Float_t x = kxmin + ipt * kxdelta;
749 Float_t z = offset + slope * (x - xref);
750 fitfun->SetPoint(nPoints++, z, x);
756 TGraph *trGraph = new TGraph(ncls);
757 TGraph *refPoints = new TGraph(nLayers);
758 trGraph->SetMarkerStyle(20);
759 trGraph->SetMarkerColor(kRed);
760 refPoints->SetMarkerStyle(21);
761 refPoints->SetMarkerColor(kBlue);
763 for(Int_t iLayer = 0; iLayer < nLayers; iLayer++)
764 refPoints->SetPoint(iLayer, refP[iLayer], x0[iLayer]);
765 for(Int_t icls = 0; icls < ncls; icls++)
766 trGraph->SetPoint(icls, clp[icls], clx[icls]);
767 TCanvas *c1 = new TCanvas();
768 trGraph->SetTitle(Form("Event %d, Candidate %d\n", fgEventNumber, fgCandidateNumber));
769 refPoints->SetTitle(Form("Event %d, Candidate %d\n", fgEventNumber, fgCandidateNumber));
770 fitfun->SetTitle(Form("Event %d, Candidate %d\n", fgEventNumber, fgCandidateNumber));
772 refPoints->Draw("psame");
773 fitfun->Draw("lpsame");
777 AliError(Form("Combination consisting of event %d and candidate %d not found", event, candidate));