// $Id: Pupil.cc,v 1.2 2005/10/31 14:45:43 thea Exp $
// Author: Alessandro Thea 2005/10/28
/*****************************************************************************
* ESAF: Euso Simulation and Analysis Framework *
* *
* Id: Pupil *
* Package: RadiativeTransfe *
* Coordinator: Sylvain.Moreggia *
* *
*****************************************************************************/
//_____________________________________________________________________________
//
// Pupil
//
// <extensive class description>
//
// Config file parameters
// ======================
//
// <parameter name>: <parameter description>
// -Valid options: <available options>
//
#include "Pupil.hh"
#include "DetectorGeometry.hh"
#include "Etypes.hh"
#include "Photon.hh"
ClassImp(Pupil)
//______________________________________________________________________________
Pupil::Pupil( PhotonsOnPupil* photons, DetectorGeometry* geo) : fPhotons(photons),
fGeometry(geo) {
//
// Constructor
//
if (!fPhotons) return;
if ( !fPhotons->GetFrame() ) {
return;
}
EsafRefFrame* frame = fPhotons->GetFrame();
fTrasl = fGeometry->GetPos()-frame->GetPos();
if ( (fTrasl).Mag() > 1*sou::m)
Msg(EsafMsg::Warning) << "PhotonsOnPupil and Detector are not in the same place." << MsgDispatch;
fRotDet2PoP = (*(frame->GetToLocal()))*(*(geo->GetToGlobal()));
fRotPoP2Det = fRotDet2PoP.Inverse();
}
//______________________________________________________________________________
Pupil::~Pupil() {
//
// Destructor
//
ClearFrame();
}
//______________________________________________________________________________
Photon* Pupil::GetPhoton() {
//
// Perform pre tracking of the photons using the DetectorGeometry
// informations
//
if (!fPhotons) return 0;
if ( !fPhotons->GetFrame() )
// nothing to do, return a plain photon
return fPhotons->GetPhoton();
Photon* p = fPhotons->GetPhoton();
if (!p) return 0;
p->pos -= fTrasl;
p->pos.Transform(fRotPoP2Det);
p->dir.Transform(fRotPoP2Det);
// pretracking to Z=0 in detector's ref frame
p->pos -= p->dir*((p->pos.Z()-fGeometry->GetTargetZ())/p->dir.Z());
// tah the photons which are outside the detector
if ( p->pos.Perp() > fGeometry->GetRadius() )
p->history = kNotInside;
return p;
}