Universita' di GenovaINFN Sezione di Genova  
AIRWATCH / EUSO Genova

ListPhotonsOnPupil - source file

// ESAF : Euso Simulation and Analysis Framework
// $Id: ListPhotonsOnPupil.cc,v 1.8 2005/02/21 10:16:35 moreggia Exp $
// M. Pallavicini created Jul,  2 2002

#include "ListPhotonsOnPupil.hh"
#include <stdexcept>

ClassImp(ListPhotonsOnPupil)

//______________________________________________________________________________
ListPhotonsOnPupil::ListPhotonsOnPupil( vector<ParentPhoton*>* list ) : 
                                        PhotonsOnPupil(), fPhotons( list ) {
    //
    // constructor
    //
    fCurrent = 0;
    if (!list) fPhotons = new vector<ParentPhoton*>;
}

//______________________________________________________________________________
ListPhotonsOnPupil::~ListPhotonsOnPupil() {
    //
    // destructor
    //
    if (fPhotons) {
        Clear();
        SafeDelete(fPhotons);
    }
}

//______________________________________________________________________________
 Photon* ListPhotonsOnPupil::Get() {
    //
    // returns a Photon object
    //
    if ( fCurrent == fPhotons->size() )
        return (Photon*)0;
    return &( (*fPhotons)[fCurrent++]->GetPhoton() );
}

//______________________________________________________________________________
 void ListPhotonsOnPupil::Clear() {
    //
    // reset the list
    //
    fCurrent=0;
    for(size_t i=0; i < fPhotons->size();i++) {
       ParentPhoton *p=(*fPhotons)[i];
       SafeDelete(p);
    }
    fPhotons->clear();
}

//______________________________________________________________________________
 void ListPhotonsOnPupil::Add( const SinglePhoton& sp, const TVector3& pos) {
    //
    // Convert SinglePhoton into ParentPhoton, then add the latter
    //
    ParentPhoton* pp = new ParentPhoton(sp,pos);
    Add(pp);
}
About Us | EUSO Official Website | Web pages created by Roberto Pesce and Alessandro Thea - Last Update 14-May-2005 21:31