Universita' di GenovaINFN Sezione di Genova  
AIRWATCH / EUSO Genova

TestDetector - source file

// $Id: Detector.cc,v 1.10 2005/11/15 11:57:48 moreggia Exp $
// Author: A.Thea   2004/12/07

/*****************************************************************************
 * ESAF: Euso Simulation and Analysis Framework                              *
 *                                                                           *
 *  Id: Detector                                                           *
 *  Package: <packagename>                                                   *
 *  Coordinator: <coordinator>                                               *
 *                                                                           *
 *****************************************************************************/

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

#include "Detector.hh"

#include "DetectorGeometry.hh"
#include "EDetectorPhotonAdder.hh"
#include "EEvent.hh"
#include "Photon.hh"
#include "PhotonsOnPupil.hh"

ClassImp(Detector)
ClassImp(TestDetector)
using namespace sou;

//_____________________________________________________________________________
Detector::Detector() : fGeometry(0) {
    //
    // Constructor
    //

}

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

//_____________________________________________________________________________
 TestDetector::TestDetector() {
    //
    // Constructor
    //

    fGeometry = new DetectorGeometry;
    fGeometry->SetRadius(Conf()->GetNum("TestDetector.fRadius")*sou::m);
    fGeometry->SetFoV(Conf()->GetNum("TestDetector.fFoV")*sou::deg);
}

//_____________________________________________________________________________
 TestDetector::~TestDetector() {
    //
    // Destructor
    //
    SafeDelete(fGeometry);
}

//______________________________________________________________________________
 Telemetry* TestDetector::Get( PhotonsOnPupil* pupil ) {
    //
    // Simulate one event and return a pointer to a Telemetry object
    //

    if ( !pupil ) { 
        MsgForm(EsafMsg::Warning,"PhotonsOnPupil is NULL. Photon tracing disabled.");
        return NULL;
    }

    Photon* p = 0;
    EEvent *ev = EEvent::GetCurrent();

    Int_t nTracked=0, nTotal(pupil->GetNphotons());
    
    Msg(EsafMsg::Info) << "Tracking Photons: " << MsgFlush;

    while( (p = pupil->GetPhoton()) ) {
    
        if (ev) {
            EDetectorPhotonAdder a(p,0,kTRUE);  
            ev->Fill(a);
        }

        // update display
        if ( nTracked*50 % nTotal == 0  || (nTracked-1)*50 % nTotal > nTracked*50 % nTotal )
            if ( nTracked*10 % nTotal == 0 || (nTracked-1)*10 % nTotal > nTracked*10 % nTotal ){
                Msg(EsafMsg::Info) << Form("%d",nTracked*100/nTotal) << '%'<< MsgFlush;
            }
            else 
                Msg(EsafMsg::Info) << "." << MsgFlush;

        nTracked++;
    }

    Msg(EsafMsg::Info) << " -done" << MsgDispatch;

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