]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TPC/template.cxx
doxy: TPC/macros/scripts converted
[u/mrichter/AliRoot.git] / TPC / template.cxx
CommitLineData
3a4edebe 1/// \class template
2
cc80f89e 3/**************************************************************************
4 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
5 * *
6 * Author: The ALICE Off-line Project. *
7 * Contributors are mentioned in the code where appropriate. *
8 * *
9 * Permission to use, copy, modify and distribute this software and its *
10 * documentation strictly for non-commercial purposes is hereby granted *
11 * without fee, provided that the above copyright notice appears in all *
12 * copies and that both the copyright notice and this permission notice *
13 * appear in the supporting documentation. The authors make no claims *
14 * about the suitability of this software for any purpose. It is *
15 * provided "as is" without express or implied warranty. *
16 **************************************************************************/
17
88cb7938 18/* $Id$ */
cc80f89e 19
20static int PropagateTo(TVector &x, Double_t fX, Double_t xk) {
21 if (TMath::Abs(x(2)*xk - x(3)) >= 0.999) {
22 cerr<<"Propagation failed !\n";
23 return 0;
24 }
25
26 Double_t x1=fX, x2=x1+(xk-x1), dx=x2-x1;//, y1=x(0), z1=x(1);
60e55aee 27 Double_t c1=x(2)*x1 - x(3), r1=sqrt((1.-c1)*(1.+c1));
28 Double_t c2=x(2)*x2 - x(3), r2=sqrt((1.-c2)*(1.+c2));
cc80f89e 29
30 x(0) += dx*(c1+c2)/(r1+r2);
31 x(1) += dx*(c1+c2)/(c1*r2 + c2*r1)*x(4);
32
33 return 1;
34}
35
36static int Rotate(TVector &x, Double_t fX, Double_t alpha) {
37 Double_t x1=fX, y1=x(0);
38 Double_t ca=cos(alpha), sa=sin(alpha);
39 Double_t r1=x(2)*fX - x(3);
40
41 fX = x1*ca + y1*sa;
42 x(0)=-x1*sa + y1*ca;
60e55aee 43 x(3)=x(3)*ca + (x(2)*y1 + sqrt((1.-r1)*(1.+r1)))*sa;
cc80f89e 44
45 Double_t r2=x(2)*fX - x(3);
46 if (TMath::Abs(r2) >= 0.999) {
47 //cerr<<"Rotation failed !\n";
48 return 0;
49 }
50
60e55aee 51 Double_t y0=x(0) + sqrt((1.-r2)*(1.+r2))/x(2);
cc80f89e 52 if ((x(0)-y0)*x(2) >= 0.) {
53 //cerr<<"Rotation failed !!!\n";
54 return 0;
55 }
56
57 return 1;
58}
59
60//_____________________________________________________________________________
61static int templ(TVector par, Double_t x, Double_t dy, Double_t dz,
62 const AliTPCSector *sec, int s, int rf=0)
63{
3a4edebe 64 /// This function tries to find a track prolongation.
65 ///
66 /// Origin: Iouri Belikov, CERN, Jouri.Belikov@cern.ch
67
cc80f89e 68 int accepted=0;
69 const int ROWS_TO_SKIP=100;
70 int try_again=ROWS_TO_SKIP;
71 Double_t alpha=sec->GetAlpha();
72 int ns=int(2*TMath::Pi()/alpha+0.5);
73
74 Double_t xold=x;
75 for (int nr=sec->GetRowNumber(x)-1; nr>=rf; nr--,xold=x) {
76 //cerr<<nr<<endl;
77 Double_t x=sec->GetX(nr), ymax=sec->GetMaxY(nr);
78 if (!PropagateTo(par,xold,x)) return 0;
79
80 AliTPCcluster *cl=0;
81 const AliTPCRow& row=sec[s][nr];
82 Double_t road=dy, y=par(0), z=par(1);
83
84 if (road>30) {
85 return 0;
86 }
87
88 if (row) {
89 for (int i=row.Find(y-road); i<row; i++) {
90 AliTPCcluster* c=(AliTPCcluster*)(row[i]);
91 if (c->fY > y+road) break;
92 if (TMath::Abs(c->fZ - z) > dz) continue;
93 cl=c;
94 }
95 }
96 if (cl) {
97 par(0)=cl->fY; par(1)=cl->fZ;
98 //dy=TMath::Sqrt(cl->fSigmaY2); dz=TMath::Sqrt(cl->fSigmaZ2);
99 //cerr<<nr<<' '<<cl->fTracks[0]<<' '<<cl->fTracks[1]<<' '<<cl->fTracks[2]<<endl;
100 accepted++;
101 try_again=ROWS_TO_SKIP;
102 } else {
103 if (try_again==0) break;
104 if (y > ymax) {
105 s = (s+1) % ns;
106 if (!Rotate(par,x,alpha)) return 0;
107 dy*=2;
108 } else if (y <-ymax) {
109 s = (s-1+ns) % ns;
110 if (!Rotate(par,x,-alpha)) return 0;
111 dy*=2;
112 }
113 try_again--;
114 }
115 }
116
117 //cerr<<endl;
118 return accepted;
119}
120
121