1 | // ESAF : Euso Simulation and Analysis Framework |
---|
2 | // $Id: EAtmosphere.cc 2877 2011-04-25 14:15:15Z biktem $ |
---|
3 | // Alessandro Thea created May, 28 2004 |
---|
4 | |
---|
5 | #include "EAtmosphere.hh" |
---|
6 | #include "ESinglePhoton.hh" |
---|
7 | #include "EBunchPhotons.hh" |
---|
8 | |
---|
9 | ClassImp(EAtmosphere) |
---|
10 | |
---|
11 | //TClonesArray* EAtmosphere::fgBunches = NULL; |
---|
12 | //TClonesArray* EAtmosphere::fgSingles = NULL; |
---|
13 | EAtmosphere* EAtmosphere::fgCurrent = NULL; |
---|
14 | |
---|
15 | const Int_t fgDefClonesSize=10000; |
---|
16 | |
---|
17 | //_____________________________________________________________________________ |
---|
18 | EAtmosphere::EAtmosphere() : TObject() { |
---|
19 | // ctor |
---|
20 | |
---|
21 | // if ( fgBunches == 0 ) |
---|
22 | // fgBunches = new TClonesArray("EBunchPhotons",20000); |
---|
23 | // |
---|
24 | // if ( fgSingles == 0 ) |
---|
25 | // fgSingles = new TClonesArray("ESinglePhoton",20000); |
---|
26 | |
---|
27 | if (TClass::IsCallingNew()) { |
---|
28 | fBunches = 0; |
---|
29 | fSingles = 0; |
---|
30 | } else { |
---|
31 | fBunches = new TClonesArray("EBunchPhotons",fgDefClonesSize); |
---|
32 | fSingles = new TClonesArray("ESinglePhoton",fgDefClonesSize); |
---|
33 | } |
---|
34 | |
---|
35 | |
---|
36 | fCopy = kFALSE; |
---|
37 | fNumBunches = 0; |
---|
38 | fNumSingles = 0; |
---|
39 | fMaxScatOrder =1; |
---|
40 | } |
---|
41 | |
---|
42 | //_____________________________________________________________________________ |
---|
43 | EAtmosphere::EAtmosphere(const EAtmosphere& other) : fBunches(0), fSingles(0) { |
---|
44 | // copy ctor |
---|
45 | other.Copy( *this ); |
---|
46 | } |
---|
47 | |
---|
48 | //_____________________________________________________________________________ |
---|
49 | EAtmosphere::~EAtmosphere() { |
---|
50 | // |
---|
51 | // dtor |
---|
52 | // |
---|
53 | |
---|
54 | Clear(); |
---|
55 | |
---|
56 | SafeDelete(fBunches); |
---|
57 | SafeDelete(fSingles); |
---|
58 | |
---|
59 | if ( GetCurrent() == this ) SetCurrent( 0 ); |
---|
60 | } |
---|
61 | |
---|
62 | //_____________________________________________________________________________ |
---|
63 | void EAtmosphere::Copy( TObject& other) const { |
---|
64 | // copy |
---|
65 | |
---|
66 | EAtmosphere& atm = ( EAtmosphere&) other; |
---|
67 | |
---|
68 | // copy atmosphere variables |
---|
69 | atm.fNumBunches = fNumBunches; |
---|
70 | atm.fNumSingles = fNumSingles; |
---|
71 | atm.fMaxScatOrder = fMaxScatOrder; |
---|
72 | |
---|
73 | SafeDelete(atm.fBunches); |
---|
74 | SafeDelete(atm.fSingles); |
---|
75 | // create TClonesArray |
---|
76 | atm.fBunches = (TClonesArray*)fBunches->Clone(); |
---|
77 | atm.fSingles = (TClonesArray*)fSingles->Clone(); |
---|
78 | } |
---|
79 | |
---|
80 | //_____________________________________________________________________________ |
---|
81 | void EAtmosphere::Clear( Option_t* opt ) { |
---|
82 | // clear this obj |
---|
83 | if ( fBunches ) fBunches->Clear( opt ); |
---|
84 | if ( fSingles ) fSingles->Clear( opt ); |
---|
85 | |
---|
86 | fNumBunches = 0; |
---|
87 | fNumSingles = 0; |
---|
88 | } |
---|
89 | |
---|
90 | //______________________________________________________________________________ |
---|
91 | void EAtmosphere::ClearAndShrink( Option_t* opt) { |
---|
92 | // |
---|
93 | // |
---|
94 | // |
---|
95 | |
---|
96 | Clear( opt ); |
---|
97 | if ( fBunches ) fBunches->Expand( fgDefClonesSize ); |
---|
98 | if ( fSingles ) fSingles->Expand( fgDefClonesSize ); |
---|
99 | } |
---|
100 | |
---|
101 | //______________________________________________________________________________ |
---|
102 | void EAtmosphere::AddTestPhoton() { |
---|
103 | |
---|
104 | ESinglePhoton* ph = new ((*fSingles)[fNumSingles++]) ESinglePhoton; |
---|
105 | if ( fBunches->At(fNumBunches-1) ) { |
---|
106 | EBunchPhotons* bunch = (EBunchPhotons*)fBunches->At(fNumBunches-1); |
---|
107 | bunch->AddSingleRef(ph); |
---|
108 | } |
---|
109 | |
---|
110 | } |
---|
111 | |
---|
112 | //______________________________________________________________________________ |
---|
113 | void EAtmosphere::AddTestBunch( Int_t nph) { |
---|
114 | |
---|
115 | new ((*fBunches)[fNumBunches++]) EBunchPhotons; |
---|
116 | for(Int_t i(0); i<nph; i++){ |
---|
117 | AddTestPhoton(); |
---|
118 | } |
---|
119 | |
---|
120 | } |
---|