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 **************************************************************************/
20 #include "AliRICHEllipse.h"
26 ClassImp(AliRICHEllipse)
28 //________________________________________________________________________________
29 AliRICHEllipse::AliRICHEllipse()
32 // Default Constructor for a RICH ellipse
42 //________________________________________________________________________________
43 AliRICHEllipse::~AliRICHEllipse()
57 //________________________________________________________________________________
58 AliRICHEllipse::AliRICHEllipse(Float_t cx, Float_t cy, Float_t omega, Float_t theta, Float_t phi)
61 // Constructor for a RICH ellipse
71 //________________________________________________________________________________
72 void AliRICHEllipse::CreatePoints(Int_t chamber)
75 // Create points along the ellipse equation
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();
81 AliRICH *pRICH = (AliRICH*)gAlice->GetModule("RICH");
82 AliRICHChamber* iChamber;
84 iChamber = &(pRICH->Chamber(chamber));
85 //cout<<"fiducial="<<fiducial<<endl;
87 for(Float_t i=0;i<1000;i++)
93 while((c1*c1-4*c2*c0)<=0 && counter<1000)
95 //Choose which side to go...
96 if(i>250 && i<750) s1=1;
97 //if (gRandom->Rndm(1)>.5) s1=1;
99 //printf("s1:%d\n",s1);
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;
105 Float_t omega1=fOmega;
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);
120 //Choose which side to go...
121 //if(gRandom->Rndm(1)>.5) s=1;
124 //if (gRandom->Rndm(1)>.5) 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);
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]);