Universita' di GenovaINFN Sezione di Genova  
AIRWATCH / EUSO Genova

IdealOpticalAdaptor - source file

// $Id: IdealOpticalAdaptor.cc,v 1.25 2005/10/21 13:33:39 moreggia Exp $
// Author: A.Thea    22/10/2002

//______________________________________________________________________________
//  
//  IdealOpticalAdaptor
//  ===================
//
//  Simple implementation of an ideal optical adaptor:
//  Compresses the image it gets on its top surface in order to fit the
//  sensitive area of the pmt (i.e. without external dead borders).
// 
//  Config file parameters
//  ======================
//
//  fSmallSide [mm]: Side of the exit face.
//
//  fRadiomEff : Radiometric efficiency of the adapter.
//
//  fFilter : Filter to apply to the incident radiation
//  - options
//      BG3: Plain BG3 filter. [EUSO-FS-REP-012-1.pdf]
//      multilayer: MgF2/HfO2 + AR coating applied to a BG3Filter 
//                  [EUSO-FS-REP-012-1.pdf]
//
//  fFilterThikness [mm] : effective thikness of the filter
//

#include "IdealOpticalAdaptor.hh"
#include "OpticsFactory.hh"
#include "Photomultiplier.hh"
#include "Etypes.hh"
#include "EConst.hh"

#include <TRotMatrix.h>
#include <TFile.h>

using namespace sou;
using namespace EConst;

ClassImp(IdealOpticalAdaptor)

//______________________________________________________________________________
 IdealOpticalAdaptor::IdealOpticalAdaptor() {
    //
    // Constructor
    //

    fReflectivity = Conf()->GetNum("IdealOpticalAdaptor.fCathode.reflectivity");
    
    fSide=Conf()->GetNum("IdealOpticalAdaptor.fSide")*mm;
    fHeight=Conf()->GetNum("IdealOpticalAdaptor.fHeight")*mm;
    fSmallSide = Conf()->GetNum("IdealOpticalAdaptor.fSmallSide")*mm;
    fScale = fSmallSide/fSide;
    fRadiomEff = Conf()->GetNum("IdealOpticalAdaptor.fRadiomEff")*mm;

    string filter = Conf()->GetStr("IdealOpticalAdaptor.fFilter");

    if ( filter=="square" ) {
        fFilterThickness = 0;
        fFilterType = kSquare;
    } else if ( filter=="BG3" ) {
        fFilterType = kBG3;
        fFilterThickness = Conf()->GetNum("IdealOpticalAdaptor.fFilterThickness")*mm;
    } else if ( filter=="multilayer" ) {
        fFilterType = kMultilayer;
        fFilterThickness = Conf()->GetNum("IdealOpticalAdaptor.fFilterThickness")*mm;
    } else {
        Msg(EsafMsg::Panic) << "Unknown filter in OpticalAdaptor.cfg" << MsgDispatch;
    }
}

//______________________________________________________________________________
 Photon *IdealOpticalAdaptor::Transport(Photon *p) const {

    // check if the photon gets through the adapter
    if ( IsAbsorbed( p ) ) {
        p->fate = kOpticalAdapter;
        return 0;
    }
    
    EVector dummy=p->pos;
    EVector lpos=p->pos;
    lpos-=fPos;
    lpos=goLocal(lpos);

    // check hitface, 
    int face=whichFace(p);

    if (face!=TOP && face!=BOTTOM) {
        //FIXME waiting MsgForm to become const
        // MsgForm(EsafMsg::Warning,"IdealOpticalAdaptor error: hit face neither TOP nor BOTTOM");
        return 0;
    }

    if (face==TOP) {

        // bottom face border length
        double deltaside=(fSide-fSmallSide)/2;

        // new photon position on the bottom side. 
        lpos[X]=lpos[X]*fScale+deltaside;
        lpos[Y]=lpos[Y]*fScale-deltaside;  // y axis is negative
        lpos[Z]=lpos[Z]-fHeight;
        p->pos=goGlobal(lpos);
        p->pos+=fPos;                // new photon position


        p->time+=(p->pos-dummy).Mag()/Clight();

        if (isReflectedByCathode()) {
            EVector ldir=goLocal(p->dir);
            ldir[Z]*=-1;
            p->dir=goGlobal(ldir);
            p->MChit=false;
            p->hit=false;
            return Transport(p);        
        }

        // Add photon to PMT
        if(!pmt->Pmt()->Add(*p)) {
            return 0;
        }

    }

    if (face==BOTTOM)  {
        // bottom face border length
        double deltaside=(fSide-fSmallSide)/2;

        // new photon position on the bottom side. 
        lpos[X]=(lpos[X]-deltaside)/fScale;
        lpos[Y]=(lpos[Y]+deltaside)/fScale;  // y axis is negative
        lpos[Z]=lpos[Z]+fHeight;
        p->pos=goGlobal(lpos);
        p->pos+=fPos;                // new photon position


        p->time+=(p->pos-dummy).Mag()/Clight();

        return p;

    }
    return 0;
}
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