// ESAF : Euso Simulation and Analysis Framework
// $Id: ListPhotonsOnPupil.cc,v 1.10 2005/10/13 13:27:31 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::GetPhoton() {
//
// 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, const TVector3& local_dir) {
//
// Convert SinglePhoton into ParentPhoton, then add the latter
//
ParentPhoton* pp = new ParentPhoton(sp,pos,local_dir);
Add(pp);
}