Universita' di GenovaINFN Sezione di Genova  
AIRWATCH / EUSO Genova

TestOpticalAdaptor - source file

//
// $Id: TestOpticalAdaptor.cc,v 1.18 2005/10/21 13:33:39 moreggia Exp $
//
#include "TRotation.h"
#include "TestOpticalAdaptor.hh"
#include "OpticsFactory.hh"
#include "Photomultiplier.hh"
#include "EEvent.hh"
#include "EConst.hh"

using namespace sou;
using namespace TMath;
using namespace EConst;

ClassImp(TestOpticalAdaptor)

//______________________________________________________________________________
 TestOpticalAdaptor::TestOpticalAdaptor() {
    //
    // Contructor
    //

    fReflectivity = Conf()->GetNum("TestOpticalAdaptor.fCathode.reflectivity");
    
    fSide=Conf()->GetNum("TestOpticalAdaptor.fSide")*mm;
    fHeight=Conf()->GetNum("TestOpticalAdaptor.fHeight")*mm;

}

//______________________________________________________________________________
 Photon *TestOpticalAdaptor::Transport(Photon *p) const {
    vector<EVector> ips=intPoints(p);

    // find the hit position
    int hitFace;
    for(hitFace=0; hitFace<6; hitFace++) 
        if(isInside(ips[hitFace], hitFace)) break;
    if(hitFace==6) {//throw runtime_error("TestOpticalAdaptor: shouldn't happen. no face hit");
        cerr<<"warning: photon on OpticalAdaptor edge. Killed"<<endl;
        return 0;  
    }

#ifdef DEBUG
    cout<<"hit face: "<<hitFace<<endl;
    cout<<"hit position (local): "<<ips[hitFace]<<endl;
#endif /* DEBUG */

    EVector dummy=p->pos;        // previous photon position
    p->pos=goGlobal(ips[hitFace]);
    p->pos+=fPos;                    // new photon position
    p->time+=(p->pos-dummy).Mag()/Clight();

#ifdef DEBUG
    cout<<"hit position (global): "<<p->pos<<endl;
#endif /* DEBUG */

    if(hitFace==BOTTOM) {
        // Cathode reflectivity
        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)) {
#ifdef DEBUG
            cout<<"photon rejected by PMT"<<endl;
#endif /* DEBUG */
        } else {
#ifdef DEBUG
            cout<<"photon accepted by PMT"<<endl;
#endif /* DEBUG */
        }

        return 0;
    } 

    if(hitFace==TOP) return p;
#ifdef DEBUG
    cout<<"photon hit on OA side"<<endl;
#endif /* DEBUG */

    const PmtGeometry *nearest=pmt->Nearest((OAFace)hitFace);
    if(!nearest) {
        // photon hit on PMT wall
#ifdef DEBUG
        cout<<"photon destroyed, no nearest"<<endl;
#endif /* DEBUG */
        // photon absorbed
        return 0;
    }
#ifdef DEBUG
    cout<<"cur_PMT_Id: "<<pmt->Pmt()->Id()<<endl;
    cout<<"near_PMT_Id: "<<nearest->Pmt()->Id()<<endl;
#endif
    OpticalAdaptor *oa=nearest->GetOA();
    // photon doesn't need to be propagated from one OA side to the
    // other one because unlike PMTs they are stuck together
    p=oa->Transport(p);
    delete oa;

        return p;
}

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