New drawing routine from Nico and Daniela.
[u/mrichter/AliRoot.git] / RICH / AliRICHEllipse.cxx
CommitLineData
237c933d 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$
4f17f810 18 Revision 1.1 2000/06/12 15:21:57 jbarbosa
19 Cleaned up version.
20
237c933d 21*/
22
23#include "AliRICHEllipse.h"
24#include "AliRICH.h"
25#include "AliRun.h"
4f17f810 26#include "AliRICHPatRec.h"
237c933d 27
28#include <TRandom.h>
29
30ClassImp(AliRICHEllipse)
31
32//________________________________________________________________________________
33AliRICHEllipse::AliRICHEllipse()
34{
35
36// Default Constructor for a RICH ellipse
37
38 fCx = 0;
39 fCy = 0;
40 fOmega = 0;
41 fTheta = 0;
42 fPhi = 0;
43 fh= 0;
44}
45
46//________________________________________________________________________________
47AliRICHEllipse::~AliRICHEllipse()
48{
49
50// Destructor
51
52 fCx = 0;
53 fCy = 0;
54 fOmega = 0;
55 fTheta = 0;
56 fPhi = 0;
57 fh= 0;
58}
59
60
61//________________________________________________________________________________
4f17f810 62AliRICHEllipse::AliRICHEllipse(Float_t cx, Float_t cy, Float_t omega, Float_t theta, Float_t phi, Float_t emiss)
237c933d 63{
64
65// Constructor for a RICH ellipse
66
67 fCx = cx;
68 fCy = cy;
69 fOmega = omega;
70 fTheta = theta;
71 fPhi = phi;
4f17f810 72 fEmissPoint = emiss;
237c933d 73 fh=11.25;
74}
75
76//________________________________________________________________________________
4f17f810 77/*void AliRICHEllipse::CreatePoints(Int_t chamber)
237c933d 78{
79
80// Create points along the ellipse equation
81
82 Int_t s1,s2;
83 Float_t fiducial=fh*TMath::Tan(fOmega+fTheta), l=fh/TMath::Cos(fTheta), xtrial, y=0, c0, c1, c2;
84 //TRandom *random=new TRandom();
85
86 AliRICH *pRICH = (AliRICH*)gAlice->GetModule("RICH");
87 AliRICHChamber* iChamber;
88
89 iChamber = &(pRICH->Chamber(chamber));
90 //cout<<"fiducial="<<fiducial<<endl;
91
92 for(Float_t i=0;i<1000;i++)
93 {
94
95 Float_t counter=0;
96
97 c0=0;c1=0;c2=0;
98 while((c1*c1-4*c2*c0)<=0 && counter<1000)
99 {
100 //Choose which side to go...
101 if(i>250 && i<750) s1=1;
102 //if (gRandom->Rndm(1)>.5) s1=1;
103 else s1=-1;
104 //printf("s1:%d\n",s1);
105 //Trial a y
106 y=s1*i*gRandom->Rndm(Int_t(fiducial/50));
107 //printf("Fiducial %f for omega:%f theta:%f phi:%f\n",fiducial,fOmega,fTheta,fPhi);
108 Float_t alfa1=fTheta;
109 Float_t theta1=fPhi;
110 Float_t omega1=fOmega;
111
112 //Solve the eq for a trial x
113 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);
114 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);
115 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);
116 //cout<<"Trial: y="<<y<<"c0="<<c0<<" c1="<<c1<<" c2="<<c2<<endl;
117 //printf("Result:%f\n\n",c1*c1-4*c2*c0);
118 //i+=.01;
119 counter +=1;
120 }
121
122 if (counter>=1000)
123 y=0;
124
125 //Choose which side to go...
126 //if(gRandom->Rndm(1)>.5) s=1;
127 //else s=-1;
128 if(i>500) s2=1;
129 //if (gRandom->Rndm(1)>.5) s2=1;
130 else s2=-1;
131 xtrial=fCx+(-c1+s2*TMath::Sqrt(c1*c1-4*c2*c0))/(2*c2);
132 //cout<<"x="<<xtrial<<" y="<<cy+y<<endl;
133 //printf("Coordinates: %f %f\n",xtrial,fCy+y);
134
135 Float_t vectorLoc[3]={xtrial,6.276,(fCy+y)};
136 Float_t vectorGlob[3];
137 iChamber->LocaltoGlobal(vectorLoc,vectorGlob);
138 SetPoint(i,vectorGlob[0],vectorGlob[1],vectorGlob[2]);
139 //printf("Coordinates: %f %f %f\n",vectorGlob[0],vectorGlob[1],vectorGlob[2]);
140 }
4f17f810 141 }*/
142
143
144void AliRICHEllipse::CerenkovRingDrawing(Int_t chamber,Int_t track)
145{
146
147//to draw Cherenkov ring by known Cherenkov angle
148
149 Int_t nmaxdegrees;
150 Int_t Nphpad;
151 Float_t phpad;
152 Float_t nfreonave, nquartzave;
153 Float_t aveEnerg;
154 Float_t energy[2];
155 Float_t e1, e2, f1, f2;
156 Float_t pointsOnCathode[3];
157
158 printf("Drawing ring in chamber:%d\n",chamber);
159
160
161 AliRICH *pRICH = (AliRICH*)gAlice->GetModule("RICH");
162 AliRICHChamber* iChamber;
163
164 iChamber = &(pRICH->Chamber(chamber));
165
166 AliRICHPatRec *PatRec = new AliRICHPatRec;
167 PatRec->TrackParam(track,chamber);
168
169 printf("Just created PateRec\n");
170
171//parameters to calculate freon window refractive index vs. energy
172
173 Float_t a = 1.177;
174 Float_t b = 0.0172;
175
176//parameters to calculate quartz window refractive index vs. energy
177/*
178 Energ[0] = 5.6;
179 Energ[1] = 7.7;
180*/
181 energy[0] = 5.0;
182 energy[1] = 8.0;
183 e1 = 10.666;
184 e2 = 18.125;
185 f1 = 46.411;
186 f2 = 228.71;
187
237c933d 188
4f17f810 189 /*Float_t nquartz = 1.585;
190 Float_t ngas = 1.;
191 Float_t nfreon = 1.295;
192 Float_t value;
193 */
237c933d 194
195
196
4f17f810 197 nmaxdegrees = 360;
198
199 for (Nphpad=0; Nphpad<nmaxdegrees;Nphpad++) {
200
201 phpad = (360./(Float_t)nmaxdegrees)*(Float_t)Nphpad;
202
203 aveEnerg = (energy[0]+energy[1])/2.;
204 //aveEnerg = 6.5;
205
206
207 nfreonave = a+b*aveEnerg;
208 nquartzave = sqrt(1+(f1/(TMath::Power(e1,2)-TMath::Power(aveEnerg,2)))+
209 (f2/(TMath::Power(e2,2)-TMath::Power(aveEnerg,2))));
210
211 //nfreonave = 1.295;
212 //nquartzave = 1.585;
213
214 printf("Calling DistancefromMip %f %f \n",fEmissPoint,fOmega);
215
216 //Float_t dummy =
217 PatRec->DistanceFromMip(nfreonave, nquartzave,fEmissPoint,fOmega, phpad, pointsOnCathode);
218
219 //Float_t points[3];
220
221 //points = pointsOnCathode;
222
223
224 //printf(" values %f %f %f\n",points[0],points[1],points[2]);
225
226 Float_t vectorLoc[3]={pointsOnCathode[0],pointsOnCathode[2],pointsOnCathode[1]};
227 Float_t vectorGlob[3];
228 iChamber->LocaltoGlobal(vectorLoc,vectorGlob);
229 SetPoint(Nphpad,vectorGlob[0],vectorGlob[1],vectorGlob[2]);
230 //fCoordEllipse[0][Nphpad] = pointsOnCathode[0];
231 //fCoordEllipse[1][Nphpad] = pointsOnCathode[1];
232
233 printf(" values %f %f \n",pointsOnCathode[0],pointsOnCathode[1]);
234
235 }
236
237}
238
239
237c933d 240
241
242
243
244
245
246
247
248
249