// ESAF : Euso Simulation and Analysis Framework
// class JOpticalSystem
// $Id: JOpticalSystem.cc,v 1.15 2004/10/08 16:56:11 thea Exp $
//
#include <TTUBE.h>
#include <TSPHE.h>
#include <TNode.h>
#include <TRotation.h>
#include "SystemOfUnits.hh"
#include "PhysicalConstants.hh"
#include "JOpticalSystem.hh"
#include "Config.hh"
#include "EsafRandom.hh"
#include "EEvent.hh"
ClassImp(JOpticalSystem)
void read_para(void);
int trace(double*, double*);
JOpticalSystem::JOpticalSystem(): OpticalSystem() {
fDZdown=20*mm;
fDZup=900*mm; // FIXME
fR=1250*mm;
fPos=EVector(0,0,100*mm);
read_para();
}
Photon *JOpticalSystem::Transport(Photon *p) const {
double ph_in[8];
double ph_out[8];
ph_in[0]=p->pos[X]/mm;
ph_in[1]=p->pos[Y]/mm;
ph_in[2]=p->pos[Z]/mm;
ph_in[3]=p->dir[X];
ph_in[4]=p->dir[Y];
ph_in[5]=p->dir[Z];
ph_in[6]=p->wl/nm;
ph_in[7]=p->time/ns;
#ifdef DEBUG
cout<<"JOpticalSystem"<<endl;
cout<<"position = "<<p->pos<<endl;
cout<<"direction = "<<p->dir<<endl;
double theta=p->dir.Angle(EVector(0.,0.,1.));
cout<<"theta = "<<theta/deg<<endl;
cout<<"wl = "<<p->wl/nm<<endl;
cout<<"time = "<<p->time/ns<<endl;
#endif /* DEBUG */
int flag=trace(ph_in, ph_out);
#ifdef DEBUG
cout << flag << endl;
#endif /* DEBUG */
if(flag!=0) {
return 0;
}
p->pos[X]=ph_out[0]*mm;
p->pos[Y]=ph_out[1]*mm;
p->pos[Z]=ph_out[2]*mm;
p->dir[X]=ph_out[3];
p->dir[Y]=ph_out[4];
p->dir[Z]=ph_out[5];
p->wl = ph_out[6]*nm;
p->time = ph_out[7]*ns;
#ifdef DEBUG
cout<<"new position = "<<p->pos<<endl;
cout<<"new direction = "<<p->dir<<endl;
#endif /* DEBUG */
return p;
}