Universita' di GenovaINFN Sezione di Genova  
AIRWATCH / EUSO Genova

BunchPropagator - source file

// $Id: BunchPropagator.cc,v 1.19 2005/05/02 17:21:50 moreggia Exp $
// Author: Sylvain Moreggia   2004/09/29

/*****************************************************************************
 * ESAF: Euso Simulation and Analysis Framework                              *
 *                                                                           *
 *  Id: BunchPropagator                                                      *
 *  Package: RadiativeTransfer                                               *
 *  Coordinator: Sylvain Moreggia                                            *
 *                                                                           *
 *****************************************************************************/

//_____________________________________________________________________________
//
// BunchPropagator
//
// <extensive class description>
//
//   Config file parameters
//   ======================
//
//   <parameter name>: <parameter description>
//   -Valid options: <available options>
//

#include "BunchPropagator.hh"
#include "Ground.hh"
#include "EarthVector.hh"
#include "Atmosphere.hh"

ClassImp(BunchPropagator)

//_____________________________________________________________________________
BunchPropagator::BunchPropagator() : EsafConfigurable(), EsafMsgSource(), fGround(0), fDetGeom(0) {
    //
    // Constructor
    //
    Msg(EsafMsg::Warning) << "Default ctor used -> OK if no clouds" << MsgDispatch;
}

//_____________________________________________________________________________
BunchPropagator::BunchPropagator(const Ground* g) : EsafConfigurable(), EsafMsgSource() {
    //
    // Constructor, copy the RadiativeTransfer ground description
    //
    CopyGround(g);
    fDetGeom = 0;
}

//_____________________________________________________________________________
 BunchPropagator::~BunchPropagator() {
    //
    // Destructor
    //
}

//_____________________________________________________________________________
 Medium BunchPropagator::GetNextImpact(const EarthVector& pos,const EarthVector& dir,EarthVector& res) const {
    //
    // Calculate the impact upon the next medium according to the given track
    // Return type of the next encountered medium
    //
    // - Cases with no impact are handled -> set impact to a boundary position, returning CLEARSKY as next medium
    // - If pos is underground, NONE medium is returned and impact set to (0,0,-HUGE)
    //
    // //TOFIX : impact on Aerosols should be done here when necessary 
    //
    
    Medium rtn = GROUND;
    EarthVector gd_imp, cloud_imp;
    
    // get impact on ground
    gd_imp = fGround->GetImpact(pos,dir);
    res = gd_imp;
    // if pos is underground
    if(gd_imp.Z() == -HUGE) return NONE;
  
    // get impact on clouds, then make appropriate changes
    cloud_imp = Atmosphere::Get()->GetClouds()->GetCloudImpact(pos,dir);
    if((cloud_imp - pos).Mag() < (gd_imp - pos).Mag()) {
	res = cloud_imp;
	rtn = CLOUDY;
    }
    
    // if no impact, means clear sky conditions remain
    if(res.Z() == HUGE) {
        rtn = CLEARSKY;
	res = fEndFoV;  //TOFIX : out of Fov must be more general
    }
      
    return rtn;
}
//_____________________________________________________________________________
 Medium BunchPropagator::GetNextImpact(const BunchOfPhotons& b,EarthVector& res) const {
    return GetNextImpact(b.GetPos(),b.GetDir(),res);
}

//_____________________________________________________________________________
 Medium  BunchPropagator::GetFinalImpact(const EarthVector& pos,const EarthVector& dir,EarthVector& res) const {
    //
    // Calculate the final impact (i.e. ground or clear sky)
    // Return medium where this impact occurs
    //
    // - Cases with no impact are handled -> set impact to a boundary position, returning CLEARSKY as next medium
    // - If pos is underground, NONE medium is returned and impact set to (0,0,-HUGE)
    //
    
    Medium rtn = GROUND;
    res = fGround->GetImpact(pos,dir);
    
    // if pos is underground
    if(res.Z() == -HUGE) return NONE;
    
    // if no impact
    if(res.Z() == HUGE) {
        res = fEndFoV;  //TOFIX : out of Fov must be more general
	rtn = CLEARSKY;
    }

    return rtn;
}

//_____________________________________________________________________________
 Medium BunchPropagator::GetFinalImpact(const BunchOfPhotons& b,EarthVector& res) const {
    return GetFinalImpact(b.GetPos(),b.GetDir(),res);
}

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