]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TPC/template.cxx
Change of argument list of methods GetPadCxy, GetPadIxy, SetHit and FirstPad
[u/mrichter/AliRoot.git] / TPC / template.cxx
1 /**************************************************************************
2  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3  *                                                                        *
4  * Author: The ALICE Off-line Project.                                    *
5  * Contributors are mentioned in the code where appropriate.              *
6  *                                                                        *
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  **************************************************************************/
15
16 /*
17 $Log$
18 Revision 1.1.2.2  2000/04/10 11:40:46  kowal2
19
20 Needed for tracking
21
22 */
23
24 static int PropagateTo(TVector &x, Double_t fX, Double_t xk) {
25   if (TMath::Abs(x(2)*xk - x(3)) >= 0.999) {
26     cerr<<"Propagation failed !\n";
27     return 0;
28   }
29
30   Double_t x1=fX, x2=x1+(xk-x1), dx=x2-x1;//, y1=x(0), z1=x(1);
31   Double_t c1=x(2)*x1 - x(3), r1=sqrt(1.- c1*c1);
32   Double_t c2=x(2)*x2 - x(3), r2=sqrt(1.- c2*c2);
33   
34   x(0) += dx*(c1+c2)/(r1+r2);
35   x(1) += dx*(c1+c2)/(c1*r2 + c2*r1)*x(4);
36
37   return 1;
38 }
39
40 static int Rotate(TVector &x, Double_t fX, Double_t alpha) {
41   Double_t x1=fX, y1=x(0);
42   Double_t ca=cos(alpha), sa=sin(alpha);
43   Double_t r1=x(2)*fX - x(3);
44   
45   fX = x1*ca + y1*sa;
46   x(0)=-x1*sa + y1*ca;
47   x(3)=x(3)*ca + (x(2)*y1 + sqrt(1.- r1*r1))*sa;
48   
49   Double_t r2=x(2)*fX - x(3);
50   if (TMath::Abs(r2) >= 0.999) {
51     //cerr<<"Rotation failed !\n";
52     return 0;
53   }
54   
55   Double_t y0=x(0) + sqrt(1.- r2*r2)/x(2);
56   if ((x(0)-y0)*x(2) >= 0.) {
57     //cerr<<"Rotation failed !!!\n";
58     return 0;
59   }
60
61   return 1;
62
63
64 //_____________________________________________________________________________
65 static int templ(TVector par, Double_t x, Double_t dy, Double_t dz, 
66                     const AliTPCSector *sec, int s, int rf=0) 
67 {
68   //-----------------------------------------------------------------
69   // This function tries to find a track prolongation.
70   //
71   // Origin: Iouri Belikov, CERN, Jouri.Belikov@cern.ch
72   //-----------------------------------------------------------------
73   int accepted=0;
74   const int ROWS_TO_SKIP=100;
75   int try_again=ROWS_TO_SKIP;
76   Double_t alpha=sec->GetAlpha();
77   int ns=int(2*TMath::Pi()/alpha+0.5);
78
79   Double_t xold=x;
80   for (int nr=sec->GetRowNumber(x)-1; nr>=rf; nr--,xold=x) {
81     //cerr<<nr<<endl;
82     Double_t x=sec->GetX(nr), ymax=sec->GetMaxY(nr);
83     if (!PropagateTo(par,xold,x)) return 0;
84
85     AliTPCcluster *cl=0;
86     const AliTPCRow& row=sec[s][nr];
87     Double_t road=dy, y=par(0), z=par(1);
88
89     if (road>30) {
90       return 0;
91     }
92
93     if (row) {
94       for (int i=row.Find(y-road); i<row; i++) {
95         AliTPCcluster* c=(AliTPCcluster*)(row[i]);
96         if (c->fY > y+road) break;
97         if (TMath::Abs(c->fZ - z) > dz) continue;
98         cl=c;       
99       }
100     }
101     if (cl) {
102       par(0)=cl->fY; par(1)=cl->fZ;
103       //dy=TMath::Sqrt(cl->fSigmaY2); dz=TMath::Sqrt(cl->fSigmaZ2);
104       //cerr<<nr<<' '<<cl->fTracks[0]<<' '<<cl->fTracks[1]<<' '<<cl->fTracks[2]<<endl;
105       accepted++;
106       try_again=ROWS_TO_SKIP;
107     } else {
108       if (try_again==0) break;
109       if (y > ymax) {
110          s = (s+1) % ns;
111          if (!Rotate(par,x,alpha)) return 0;
112          dy*=2;
113       } else if (y <-ymax) {
114          s = (s-1+ns) % ns;
115          if (!Rotate(par,x,-alpha)) return 0;
116          dy*=2;
117       }
118       try_again--;
119     }
120   }
121
122   //cerr<<endl;
123   return accepted;
124 }
125
126