]> git.uio.no Git - u/mrichter/AliRoot.git/blob - RICH/AliRICHEllipse.cxx
Cleaned up version.
[u/mrichter/AliRoot.git] / RICH / AliRICHEllipse.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 */
19
20 #include "AliRICHEllipse.h"
21 #include "AliRICH.h"
22 #include "AliRun.h"
23
24 #include <TRandom.h>
25
26 ClassImp(AliRICHEllipse)
27
28 //________________________________________________________________________________
29 AliRICHEllipse::AliRICHEllipse()
30
31
32 //  Default Constructor for a RICH ellipse
33
34     fCx = 0;
35     fCy = 0;
36     fOmega = 0;
37     fTheta = 0;
38     fPhi = 0;
39     fh= 0;
40 }
41
42 //________________________________________________________________________________
43 AliRICHEllipse::~AliRICHEllipse()
44
45
46 // Destructor
47
48     fCx = 0;
49     fCy = 0;
50     fOmega = 0;
51     fTheta = 0;
52     fPhi = 0;
53     fh= 0;
54 }
55
56
57 //________________________________________________________________________________
58 AliRICHEllipse::AliRICHEllipse(Float_t cx, Float_t cy, Float_t omega, Float_t theta, Float_t phi)
59
60
61 //  Constructor for a RICH ellipse
62
63     fCx = cx;
64     fCy = cy;
65     fOmega = omega;
66     fTheta = theta;
67     fPhi = phi;
68     fh=11.25;
69 }
70
71 //________________________________________________________________________________
72 void AliRICHEllipse::CreatePoints(Int_t chamber)
73 {
74
75 // Create points along the ellipse equation
76
77   Int_t s1,s2;
78   Float_t fiducial=fh*TMath::Tan(fOmega+fTheta), l=fh/TMath::Cos(fTheta), xtrial, y=0, c0, c1, c2;
79   //TRandom *random=new TRandom();
80
81   AliRICH *pRICH  = (AliRICH*)gAlice->GetModule("RICH");
82   AliRICHChamber*       iChamber;
83   
84   iChamber = &(pRICH->Chamber(chamber));
85   //cout<<"fiducial="<<fiducial<<endl;
86   
87   for(Float_t i=0;i<1000;i++)
88     {
89       
90       Float_t counter=0;
91       
92       c0=0;c1=0;c2=0;
93       while((c1*c1-4*c2*c0)<=0 && counter<1000)
94         {
95           //Choose which side to go...
96           if(i>250 && i<750) s1=1; 
97           //if (gRandom->Rndm(1)>.5) s1=1;
98           else s1=-1;
99           //printf("s1:%d\n",s1);
100           //Trial a y
101           y=s1*i*gRandom->Rndm(Int_t(fiducial/50));
102           //printf("Fiducial %f  for omega:%f theta:%f phi:%f\n",fiducial,fOmega,fTheta,fPhi);
103           Float_t alfa1=fTheta;
104           Float_t theta1=fPhi;
105           Float_t omega1=fOmega;
106           
107           //Solve the eq for a trial x
108           c0=-TMath::Power(y*TMath::Cos(alfa1)*TMath::Cos(theta1),2)-TMath::Power(y*TMath::Sin(alfa1),2)+TMath::Power(l*TMath::Tan(omega1),2)+2*l*y*TMath::Cos(alfa1)*TMath::Sin(theta1)*TMath::Power(TMath::Tan(omega1),2)+TMath::Power(y*TMath::Cos(alfa1)*TMath::Sin(theta1)*TMath::Tan(omega1),2);
109           c1=2*y*TMath::Cos(alfa1)*TMath::Sin(alfa1)-2*y*TMath::Cos(alfa1)*TMath::Power(TMath::Cos(theta1),2)*TMath::Sin(alfa1)+2*l*TMath::Sin(alfa1)*TMath::Sin(theta1)*TMath::Power(TMath::Tan(omega1),2)+2*y*TMath::Cos(alfa1)*TMath::Sin(alfa1)*TMath::Power(TMath::Sin(theta1),2)*TMath::Power(TMath::Tan(omega1),2);
110           c2=-TMath::Power(TMath::Cos(alfa1),2)-TMath::Power(TMath::Cos(theta1)*TMath::Sin(alfa1),2)+TMath::Power(TMath::Sin(alfa1)*TMath::Sin(theta1)*TMath::Tan(omega1),2);
111           //cout<<"Trial: y="<<y<<"c0="<<c0<<" c1="<<c1<<" c2="<<c2<<endl;
112           //printf("Result:%f\n\n",c1*c1-4*c2*c0);
113           //i+=.01;
114           counter +=1;
115         }
116       
117       if (counter>=1000)
118         y=0; 
119
120       //Choose which side to go...
121       //if(gRandom->Rndm(1)>.5) s=1; 
122       //else s=-1;
123       if(i>500) s2=1;
124       //if (gRandom->Rndm(1)>.5) s2=1;
125       else s2=-1;
126       xtrial=fCx+(-c1+s2*TMath::Sqrt(c1*c1-4*c2*c0))/(2*c2);
127       //cout<<"x="<<xtrial<<" y="<<cy+y<<endl;
128       //printf("Coordinates: %f %f\n",xtrial,fCy+y);
129
130       Float_t vectorLoc[3]={xtrial,6.276,(fCy+y)};
131       Float_t  vectorGlob[3];
132       iChamber->LocaltoGlobal(vectorLoc,vectorGlob);
133       SetPoint(i,vectorGlob[0],vectorGlob[1],vectorGlob[2]);
134       //printf("Coordinates: %f %f %f\n",vectorGlob[0],vectorGlob[1],vectorGlob[2]);
135     }
136 }
137
138
139
140
141
142
143
144
145
146
147
148
149
150