#include "CherenkovDisplay.h" #include "HKED_Util.h" #include using std::cout; using std::endl; void CherenkovDisplay::CartesianToPolar(double &mom,double &theta,double &phi,double p[3]){ mom=sqrt(p[0]*p[0]+p[1]*p[1]+p[2]*p[2]); theta=acos(p[2]/mom); phi=atan2(p[1],p[0]); } void CherenkovDisplay::polarToCartesian(double mom,double theta,double phi,double p[3]){ p[0]=mom*sin(theta)*cos(phi); p[1]=mom*sin(theta)*sin(phi); p[2]=mom*cos(theta); } double CherenkovDisplay::DotProduct(double a[],double b[],int n) { double sum=0; for (int i=0;imaxZ) { double Z=maxZ; location=0; if(intersection[2]<0) { Z=-maxZ; location=2; } t=(Z-pos[2])/line[2]; } intersection[0]=pos[0]+t*line[0]; intersection[1]=pos[1]+t*line[1]; intersection[2]=pos[2]+t*line[2]; //cout<<" return point "<1.0)return false; /* Construct a vector of points showing the cherenkov circle where it impacts with the detector. An alternative is to draw the cones themselves - great for publicity but not very practical */ cone->SetElementTitle(Name); cone->SetMainColor(colour); cone->SetLineWidth(2.0); cone->SetLineStyle(1); cone2D->SetElementTitle(Name); cone2D->SetMainColor(colour); cone2D->SetLineWidth(2.0); cone2D->SetLineStyle(1); double azim=0; int nPoints=250; double delta = 6.283/nPoints; double alpha=acos(cosAlpha); if(fabs(cosAlpha)>1.0) { //cout<<" cos Alpha is illegal "<AddLine(oldX,oldY,oldZ,endPoint[0],endPoint[1],endPoint[2]); //SetNextPoint(endPoint[0],endPoint[1],endPoint[2]); } } if(first){ copyPointsFromArray(endPoint,firstX,firstY,firstZ); } //oldX=endPoint[0]; //oldY=endPoint[1]; copyPointsFromArray(endPoint,oldX,oldY,oldZ); oldZ=endPoint[2]; UnrollView(endPoint,location); //cone2D->SetNextPoint(endPoint[0],endPoint[1],endPoint[2]); if(!first){ length=sqrt( (oldX2D-endPoint[0])*(oldX2D-endPoint[0])+ (oldY2D-endPoint[1])*(oldY2D-endPoint[1])+ (oldZ2D-endPoint[2])*(oldZ2D-endPoint[2])); if(oldlocation==location && length < 500) { if(thisOne){ cone2D->AddLine(oldX2D,oldY2D,oldZ2D,endPoint[0],endPoint[1],endPoint[2]); } if(dotted) thisOne=!thisOne; } } copyPointsFromArray(endPoint,oldX2D,oldY2D,oldZ2D); oldlocation=location; if(first==true){ first=false; copyPointsFromArray(endPoint,firstX2D,firstY2D,firstZ2D); } } float testz=endPoint[2]; if((maxZ-abs(testz)<500)&&(maxR-rTest)<500) { step=delta/10.0; } } azim+=step; } while(azim<6.283); if(!first){ //cout<<" Cone next point is "<SetNextPoint(firstX,firstY,firstZ); //cout<<"join the end to the start "<AddLine(oldX,oldY,oldZ,firstX,firstY,firstZ); cone2D->AddLine(endPoint[0],endPoint[1],endPoint[2],firstX2D,firstY2D,firstZ2D); } } return true; }