Universita' di GenovaINFN Sezione di Genova  
AIRWATCH / EUSO Genova

RadiativeTransfer - source file

// ESAF : Euso Simulation and Analysis Framework
// $Id: RadiativeTransfer.cc,v 1.16 2005/10/31 10:56:12 moreggia Exp $
// D. De Marco - M. Pallavicini created Jan, 20 2002

#include "RadiativeTransfer.hh"
#include "Ground.hh"
#include "EsafRandom.hh"
#include "PhotonsOnPupil.hh"

ClassImp(RadiativeTransfer)

//______________________________________________________________________________
RadiativeTransfer::RadiativeTransfer(): EsafConfigurable(), EsafMsgSource(), fGround(0), fDetAtGrnd(false)  {
    //
    // ctor
    //
}

//______________________________________________________________________________
 RadiativeTransfer::~RadiativeTransfer() {
    //
    // dtor
    //
    SafeDelete(fGround);
}



//_______________________________________________________________________________________________________________________
 void RadiativeTransfer::RamdomPosOnPupil(const PhotonsOnPupil* photons, TVector3& pos, TVector3& local_dir) const {
    //
    // Sample a random photon position on pupil
    //
    Double_t x, y, r, phi;
    TRandom* rndm = EsafRandom::Get();
    if(fDecoupled) {
        TVector3 origin(pos);
	TVector3 dir = (EUSO() - origin).Unit();

	r = 1;
	while ( r > 0.25 ) {
            x = rndm->Rndm()-0.5;
            y = rndm->Rndm()-0.5;
            r = x*x+y*y;
	}
	x *= EusoRadius()/0.5;
	y *= EusoRadius()/0.5;
	TVector3 xAxis = dir.Orthogonal();
	TVector3 yAxis = dir.Cross(xAxis);

	pos = x*xAxis+y*yAxis;
	// other possible method. Which is the swiftest?
        //    TRotation rot;
        //    rot.SetZAxis(dir);
        //    pos *= rot;
    }
    else {
        r = EusoRadius() * sqrt(rndm->Rndm());
        phi = TMath::TwoPi() * rndm->Rndm();
        pos.SetXYZ(r*cos(phi),r*sin(phi),0);
        local_dir *= *(GetDetGeometry()->GetToLocal());
    }
}

//_______________________________________________________________________________________________________________________
 void RadiativeTransfer::BuildPupilFrame(PhotonsOnPupil* photons) const {
    //
    // definition of frame contained by PhotonOnPupil object
    //
    EsafRefFrame *frame = new EsafRefFrame;
    // if radiative transfer is decoupled from the detector
    // then assume the std set of axis (1,0,0),(0,1,0),(0,0,1) and set only the position
    if (fDecoupled) frame->SetPos(GetDetGeometry()->GetPos());
    else GetDetGeometry()->EsafRefFrame::Copy(*frame);
    
    photons->AddFrame(frame);
}
About Us | EUSO Official Website | Web pages created by Roberto Pesce and Alessandro Thea - Last Update Wed Nov 16 16:57:39 2005 Wed Nov 16 16:29:22 2005