// ESAF : Euso Simulation and Analysis Framework
// $Id: DiffusePhotonsOnPupil.cc,v 1.5 2004/09/28 12:10:31 thea Exp $
// A.Thea created Apr, 18 2004
#include "DiffusePhotonsOnPupil.hh"
#include "OpticsFactory.hh"
#include "EsafRandom.hh"
#include "EsafSpectrum.hh"
ClassImp(DiffusePhotonsOnPupil)
//______________________________________________________________________________
DiffusePhotonsOnPupil::DiffusePhotonsOnPupil() {
// ctor
fOptics = OpticsFactory::Get()->GetOpticalSystem();
fThetaFOVMax = Conf()->GetNum("DiffusePhotonsOnPupil.fThetaFOVMax")
*TMath::DegToRad();
// calculate the entrance disc size using the last element in fAngles
fEntranceDiscRadius = fOptics->Radius()+fThetaFOVMax*
(fOptics->FirstLensTop()-fOptics->FirstLensBottom());
fSpectrum = new EsafSpectrum(Conf()->GetStr("DiffusePhotonsOnPupil.fSpectrum").c_str());
string sThDist = Conf()->GetStr("DiffusePhotonsOnPupil.fThetaDistribution").c_str();
if (sThDist == "totaleff" ) {
// this fuction is the inverse of the total optics efficacy as presented by
// A.Thea at Munich EUSO General Meeting, Nov 2003
fThetaDist = new TF1("toteff","sin(x)/pol6",0,fThetaFOVMax);
fThetaDist->SetParameter(0,2.99368e+06);
fThetaDist->SetParError(0,10391.8);
fThetaDist->SetParLimits(0,0,0);
fThetaDist->SetParameter(1,532256);
fThetaDist->SetParError(1,98140.9);
fThetaDist->SetParLimits(1,0,0);
fThetaDist->SetParameter(2,-2.21992e+06);
fThetaDist->SetParError(2,333382);
fThetaDist->SetParLimits(2,0,0);
fThetaDist->SetParameter(3,-2.15698e+06);
fThetaDist->SetParError(3,778156);
fThetaDist->SetParLimits(3,0,0);
fThetaDist->SetParameter(4,-1.26283e+08);
fThetaDist->SetParError(4,1.72771e+06);
fThetaDist->SetParLimits(4,0,0);
fThetaDist->SetParameter(5,4.02746e+08);
fThetaDist->SetParError(5,3.47659e+06);
fThetaDist->SetParLimits(5,0,0);
fThetaDist->SetParameter(6,-3.87307e+08);
fThetaDist->SetParError(6,5.62178e+06);
fThetaDist->SetParLimits(6,0,0);
} else if ( sThDist == "uniform" ) {
// uniform distribution in the FOV solid angle
fThetaDist = new TF1("uniform","sin(x)",0, fThetaFOVMax);
fThetaDist->SetParameter(0,0);
fThetaDist->SetParError(0,0);
fThetaDist->SetParLimits(0,0,0);
fThetaDist->SetParameter(1,1);
fThetaDist->SetParError(1,0);
fThetaDist->SetParLimits(1,0,0);
} else if ( sThDist == "costheta" ) {
// this distribution keeps the incident flux constant
fThetaDist = new TF1("costheta","sin(x)*cos(x)",0, fThetaFOVMax);
} else
throw runtime_error("DiffusePhotonsOnPupil: " + sThDist + " unknown distribution" );
}
//______________________________________________________________________________
DiffusePhotonsOnPupil::~DiffusePhotonsOnPupil() {
// dtor
if (fSpectrum) delete fSpectrum; fSpectrum = 0;
if (fThetaDist) delete fThetaDist; fThetaDist = 0;
}
//______________________________________________________________________________
Photon* DiffusePhotonsOnPupil::Get() {
// get a new photon
TRandom *rndm = EsafRandom::Get();
Double_t th = fThetaDist->GetRandom();
Double_t ph = TMath::TwoPi()*rndm->Rndm();
Double_t rho = sqrt(rndm->Rndm())*fEntranceDiscRadius;
Double_t alpha = rndm->Rndm()*TMath::TwoPi();
Double_t s_pos[3]={0,0,0};
Double_t p_pos[3]={rho*TMath::Cos(alpha), rho*TMath::Sin(alpha),
fOptics->FirstLensBottom()};
fParent.Build(1,s_pos, p_pos, th, ph, fSpectrum->GetLambda(), 0, Fluorescence);
return &(fParent.GetPhoton());
}