source: JEM-EUSO/esaf_lal/tags/v1_r0/esaf/packages/simulation/lightsources/include/ListPhotonsInAtmosphere.hh @ 117

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

ESAF version compilable on mac OS

File size: 4.5 KB
Line 
1// ESAF : Euso Simulation and Analysis Framework
2// $Id: ListPhotonsInAtmosphere.hh 2681 2006-05-03 10:58:33Z moreggia $
3// Anne Stutz created Dec,  1 2003
4//
5// NB: list of bunches need to ordered correctly : first created <-> first in the list
6//
7
8#ifndef __LISTPHOTONSINATMOSPHERE_HH_
9#define __LISTPHOTONSINATMOSPHERE_HH_
10
11#include <vector>
12
13#include "euso.hh"
14#include "PhotonsInAtmosphere.hh"
15#include "EarthVector.hh"
16
17class SinglePhoton;
18class BunchOfPhotons;
19
20class ListPhotonsInAtmosphere : public PhotonsInAtmosphere {
21public:
22    // ctors
23    ListPhotonsInAtmosphere();
24    ListPhotonsInAtmosphere(const ListPhotonsInAtmosphere&);
25
26    // dtor
27    virtual ~ListPhotonsInAtmosphere();
28
29    // Get photons following the two different "formats"
30    inline const vector<SinglePhoton*>& GetListOfSingle() const {return fListSingle;}
31    inline const vector<BunchOfPhotons*>& GetListOfBunch() const {return fListBunch;}
32    inline size_t GetBunchEntries() const {return fListBunch.size();}
33    inline size_t GetSingleEntries() const {return fListSingle.size();}
34   
35    // Extract one photon from the list
36    SinglePhoton* GetSingle() const;
37   
38    // Extract one Bunch of photons from the list
39    BunchOfPhotons* GetBunch() const;
40    BunchOfPhotons* GetBunch(size_t i) const;
41    inline void ResetBunchCounter() const {fCountB = 0;}
42    inline void ResetSingleCounter() const {fCountS = 0;}
43
44    // Add new elements to the lists
45    void Add(SinglePhoton*,Bool_t saved = false);
46    void Add(BunchOfPhotons*);
47    void Add(vector<SinglePhoton*>&,Bool_t saved = false);
48    void Add(ListPhotonsInAtmosphere&,Bool_t saved = false);
49   
50    // Same as the matching Add() methods, BUT copies of SinglePhoton and BunchOfPhotons
51    // are created, instead of storing the pointers (in)directly given in argument,
52    // so that the lists passed in argument are not destroyed
53    void Copy(const vector<SinglePhoton*>&,Bool_t saved = false);
54    void Copy(const ListPhotonsInAtmosphere&,Bool_t saved = false);
55       
56    // Clear lists without deleting pointers they hold
57    // Int_t argument allows to clear only one list
58    void Clear(Int_t t = 0);
59   
60    // Several options to empty the lists
61    void Reset(Int_t t = 0);
62   
63    // handle the fNbNotSaved counter
64    inline void OneSingleSaved() const {fNbNotSaved--;}
65    inline UInt_t GetNbNotSaved() const {return fNbNotSaved;}
66   
67   
68    // set fTrack steps nb and reserve corresponding memory for fTrack
69    void SetNbTrackSteps(UInt_t);
70   
71    // return fTrack nb ofsteps
72    UInt_t GetNbTrackSteps() const;
73   
74    // add a step
75    void FillTrack(const EarthVector& v,Bool_t quiet = false);
76   
77    // get a step
78    inline const EarthVector& GetTrackStep(UInt_t i) const {return fTrack[i];}
79   
80    // clear track
81    inline void ClearTrack() {fTrack.clear(); fTrackNbSteps = 0;}
82   
83    // project the given vector on the track
84    // then return the index of the fTrack matching step
85    UInt_t TrackStepIndex(const EarthVector&) const;
86    UInt_t TrackStepIndex(const EarthVector&,EarthVector& rtn) const;
87
88    // release all the mem hold in the buffers
89    virtual Bool_t ClearMemory();
90
91private:
92    vector<SinglePhoton*> fListSingle;
93    vector<BunchOfPhotons*> fListBunch;
94    vector<EarthVector> fTrack;         // set of steps adapted from shower simulation, used in propagation
95                                        // elements = step entry, excepted for last = track end, and last = impact on ground
96   
97    UInt_t fTrackNbSteps;               // nb of fTrack elements
98    mutable Int_t fBeforeTrackstart;    // check photons not correctly on the track
99   
100    mutable UInt_t fNbNotSaved;         // nb of *last added* SinglePhotons which still need to be saved into root
101    mutable UInt_t fCountS;             // for extraction of SinglePhoton   
102    mutable UInt_t fCountB;             // for extraction of BunchOfPhotons   
103
104    ClassDef(ListPhotonsInAtmosphere,0)
105};
106
107
108
109inline void ListPhotonsInAtmosphere::SetNbTrackSteps(UInt_t nb) {
110    fTrackNbSteps = nb;
111    fTrack.reserve(nb); 
112}
113
114inline void ListPhotonsInAtmosphere::FillTrack(const EarthVector& v,Bool_t quiet) {
115    if(fTrack.size() == fTrackNbSteps) {
116        if(!quiet) Msg(EsafMsg::Warning) << "<Fill()> MORE STEPS THAN FORESEEN" << MsgDispatch;
117        fTrackNbSteps++;
118    }
119    fTrack.push_back(v);
120}
121
122inline UInt_t ListPhotonsInAtmosphere::GetNbTrackSteps() const {
123    if(fTrack.size() < fTrackNbSteps) Msg(EsafMsg::Warning) << "<GetNbTrackSteps()> fTrack is NOT WHOLLY FILLED YET" << MsgDispatch;
124    return fTrack.size();
125}
126
127#endif  /* __LISTPHOTONSINATMOSPHERE_HH_ */
128
Note: See TracBrowser for help on using the repository browser.