source: JEM-EUSO/esaf_cc_at_lal/packages/simulation/radiativetransfer/src/ListPhotonsOnPupil.cc @ 114

Last change on this file since 114 was 114, checked in by moretto, 11 years ago

actual version of ESAF at CCin2p3

File size: 2.0 KB
Line 
1// ESAF : Euso Simulation and Analysis Framework
2// $Id: ListPhotonsOnPupil.cc 2604 2006-03-20 21:51:35Z thea $
3// M. Pallavicini created Jul,  2 2002
4
5#include "ListPhotonsOnPupil.hh"
6#include <stdexcept>
7
8ClassImp(ListPhotonsOnPupil)
9
10//______________________________________________________________________________
11ListPhotonsOnPupil::ListPhotonsOnPupil( vector<ParentPhoton*>* list ) : 
12                                        PhotonsOnPupil(), fPhotons( list ) {
13    //
14    // constructor
15    //
16    fCurrent = 0;
17    if (!list) fPhotons = new vector<ParentPhoton*>;
18}
19
20//______________________________________________________________________________
21ListPhotonsOnPupil::~ListPhotonsOnPupil() {
22    //
23    // destructor
24    //
25    if (fPhotons) {
26        Clear();
27        SafeDelete(fPhotons);
28    }
29}
30
31//______________________________________________________________________________
32Bool_t ListPhotonsOnPupil::ClearMemory() {
33    //
34    // Release all the memory hold by the buffers
35    //
36
37    Clear();
38    vector<ParentPhoton*> empty;
39    empty.swap( *fPhotons );
40    return kTRUE;
41
42}
43
44//______________________________________________________________________________
45Photon* ListPhotonsOnPupil::GetPhoton() {
46    //
47    // returns a Photon object
48    //
49    if ( fCurrent == fPhotons->size() )
50        return (Photon*)0;
51    return &( (*fPhotons)[fCurrent++]->GetPhoton() );
52}
53
54//______________________________________________________________________________
55void ListPhotonsOnPupil::Clear() {
56    //
57    // reset the list
58    //
59    fCurrent=0;
60    for(size_t i=0; i < fPhotons->size();i++) {
61       ParentPhoton *p=(*fPhotons)[i];
62       SafeDelete(p);
63    }
64    fPhotons->clear();
65}
66
67//______________________________________________________________________________
68void ListPhotonsOnPupil::Add( const SinglePhoton& sp, const TVector3& pos, const TVector3& local_dir) {
69    //
70    // Convert SinglePhoton into ParentPhoton, then add the latter
71    //
72    ParentPhoton* pp = new ParentPhoton(sp,pos,local_dir);
73    Add(pp);
74}
Note: See TracBrowser for help on using the repository browser.