// $Id: IdealFocalSurface.cc,v 1.14 2005/04/15 18:54:41 thea Exp $
// A.Thea created Apr, 1 2003
//______________________________________________________________________________
//
// IdealFocalSurface
// =================
#include "IdealFocalSurface.hh"
#include "Etypes.hh"
ClassImp(IdealFocalSurface)
ClassImp(TestIdealFocalSurface)
using namespace TMath;
//______________________________________________________________________________
IdealFocalSurface::IdealFocalSurface() :
fPos(0,0,0), fDZup(0), fDZdown(0) {
//
// Constructor
//
}
//______________________________________________________________________________
IdealFocalSurface::~IdealFocalSurface() {
//
// Destructor
//
}
//______________________________________________________________________________
Double_t IdealFocalSurface::NextInt( const TVector3 &pos, const TVector3 &dir ) {
//
// finds the next interaction of the photon inside the cylinder
//
Double_t dist[4] = {-kHuge,-kHuge,-kHuge,-kHuge};
// array of intersections, 0, 1 basis, 3, 4 lateral surface
// int with the basis
if ( Abs(dir[Z]) > kTolerance ) {
dist[0] = (fDZup-pos[Z])/dir[Z];
dist[1] = (-fDZdown-pos[Z])/dir[Z];
}
Double_t a, b, c;
a = dir[X]*dir[X]+dir[Y]*dir[Y];
b = 2*(dir[X]*pos[X]+dir[Y]*pos[Y]);
c = pos[X]*pos[X]+pos[Y]*pos[Y]-fR*fR;
Double_t delta = (b*b)-4*a*c;
if ( a > 0 )
if ( Abs(delta) < kTolerance ) {
dist[2] = -b/(2*a);
} else if ( delta >= kTolerance ) {
dist[2] = (-b-Sqrt(delta))/(2*a);
dist[3] = (-b+Sqrt(delta))/(2*a);
}
Double_t dt = MaxElement(4,dist);
for(Int_t i(0); i<4; i++)
if ( dist[i] > kTolerance && dist[i] < dt ) dt = dist[i];
// Printf("d(%.3f,%.3f,%.3f,%.3f)",dist[0],dist[1],dist[2],dist[3]);
return dt;
}
//______________________________________________________________________________
TestIdealFocalSurface::TestIdealFocalSurface() {
//
// Constructor
//
}
//______________________________________________________________________________
Bool_t TestIdealFocalSurface::HitPosition(Photon *p)
{
p->posOnIfs=p->pos;
p->hitIfs=kTRUE;
return kTRUE;
}
//______________________________________________________________________________
TestIdealFocalSurface::~TestIdealFocalSurface() {
//
// Destructor
//
}