source: JEM-EUSO/esaf_lal/tags/v1_r0/esaf/packages/common/root/src/ETruth.cc @ 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: 8.3 KB
Line 
1// ESAF : Euso Simulation and Analysis Framework
2// $Id: ETruth.cc 2669 2006-04-12 11:43:13Z thea $
3// A.Thea created May, 23 2004
4
5
6/*****************************************************************************
7 * ESAF: Euso Simulation and Analysis Framework                              *
8 *                                                                           *
9 *  Id: ETruth                                                               *
10 *  Package: SimuEvent                                                       *
11 *  Coordinator: Alessandro.Thea                                             *
12 *                                                                           *
13 *****************************************************************************/
14
15#include "ETruth.hh"
16#include "Etypes.hh"
17
18//______________________________________________________________________________
19//
20//   ETruth
21//   ======
22//
23//   MonteCarlo Truth object. Informations about the real event
24//   In case of EECR, contains infos about the original particle,
25//   direction, energy, type
26//   In case of other backgrounds, informations about the real process
27//
28
29ClassImp(ETruth)
30
31//_____________________________________________________________________________
32ETruth::ETruth() {
33    // ctor
34    Clear();
35
36}
37
38//_____________________________________________________________________________
39ETruth::ETruth( const ETruth& other ) : TObject() {
40    // copy ctor
41
42    other.Copy( *this );
43}
44
45//_____________________________________________________________________________
46ETruth::~ETruth() {
47    // dtor
48}
49
50//______________________________________________________________________________
51void ETruth::Streamer(TBuffer &R__b)
52{
53   // Stream an object of class ETruth.
54
55   UInt_t R__s, R__c;
56   if (R__b.IsReading()) {
57      Version_t R__v = R__b.ReadVersion(&R__s, &R__c);
58      if (R__v == 1) { 
59          TObject::Streamer(R__b);
60          EFillable::Streamer(R__b);
61          R__b >> fTrueEnergy;
62          R__b >> fTrueTheta;
63          R__b >> fTruePhi;
64          fTrueParticleName.Streamer(R__b);
65          R__b >> fTrueParticleCode;
66          R__b >> fTrueInitPosX;
67          R__b >> fTrueInitPosY;
68          R__b >> fTrueInitPosZ;
69          R__b >> fTrueX1;
70          R__b >> fTrueEarthImpactX;
71          R__b >> fTrueEarthImpactY;
72          R__b >> fTrueEarthImpactZ;
73          R__b >> fTrueEarthAge;
74          R__b >> fTrueShowerMaxPosX;
75          R__b >> fTrueShowerMaxPosY;
76          R__b >> fTrueShowerMaxPosZ;
77          R__b >> fTrueShowerXMax;
78          R__b >> fTrueHclouds;
79          R__b >> fTrueCloudsthick;
80          R__b >> fTrueCloudsOD;
81          R__b >> fTrueLatitude;
82          R__b >> fTrueLongitude;
83          R__b >> fTrueDate;
84          fTrueTOAImpactX     = -kHuge;
85          fTrueTOAImpactY     = -kHuge;
86          fTrueTOAImpactZ     = -kHuge;
87          R__b.CheckByteCount(R__s, R__c, ETruth::IsA());
88      } else if  (R__v == 2) { 
89          TObject::Streamer(R__b);
90          EFillable::Streamer(R__b);
91          R__b >> fTrueEnergy;
92          R__b >> fTrueTheta;
93          R__b >> fTruePhi;
94          fTrueParticleName.Streamer(R__b);
95          R__b >> fTrueParticleCode;
96          R__b >> fTrueInitPosX;
97          R__b >> fTrueInitPosY;
98          R__b >> fTrueInitPosZ;
99          R__b >> fTrueX1;
100          R__b >> fTrueEarthImpactX;
101          R__b >> fTrueEarthImpactY;
102          R__b >> fTrueEarthImpactZ;
103          R__b >> fTrueTOAImpactX;
104          R__b >> fTrueTOAImpactY;
105          R__b >> fTrueTOAImpactZ;
106          R__b >> fTrueEarthAge;
107          R__b >> fTrueShowerMaxPosX;
108          R__b >> fTrueShowerMaxPosY;
109          R__b >> fTrueShowerMaxPosZ;
110          R__b >> fTrueShowerXMax;
111          R__b >> fTrueHclouds;
112          R__b >> fTrueCloudsthick;
113          R__b >> fTrueCloudsOD;
114          R__b >> fTrueLatitude;
115          R__b >> fTrueLongitude;
116          R__b >> fTrueDate;
117          fTrueHGround        = -kHuge;
118          fTrueGroundAlbedo   = -kHuge;
119          fTrueGroundSpecular = -kHuge;
120          R__b.CheckByteCount(R__s, R__c, ETruth::IsA());
121      } else {
122          ETruth::Class()->ReadBuffer(R__b,this, R__v, R__s, R__c);
123      }
124   } else {
125       ETruth::Class()->WriteBuffer(R__b,this);
126   }
127}
128
129//_____________________________________________________________________________
130void ETruth::Clear( Option_t* ) {
131
132    fTrueEnergy         = 0;
133    fTrueTheta          = 0;
134    fTruePhi            = 0;
135    fTrueParticleName.Resize(0);
136    fTrueParticleCode   = 0;
137    fTrueInitPosX       = -kHuge;
138    fTrueInitPosY       = -kHuge;
139    fTrueInitPosZ       = -kHuge;
140    fTrueX1             = 0;
141    fTrueEarthImpactX   = -kHuge;
142    fTrueEarthImpactY   = -kHuge;
143    fTrueEarthImpactZ   = -kHuge;
144    fTrueEarthAge       = 0;
145    fTrueShowerMaxPosX  = -kHuge;
146    fTrueShowerMaxPosY  = -kHuge;
147    fTrueShowerMaxPosZ  = -kHuge;
148    fTrueShowerXMax     = 0;
149    fTrueTOAImpactX     = -kHuge;
150    fTrueTOAImpactY     = -kHuge;
151    fTrueTOAImpactZ     = -kHuge;
152    fTrueHclouds        = -kHuge;
153
154    fTrueCloudsthick    = 0;
155    fTrueCloudsOD       = 0;
156    fTrueLatitude       = 0;
157    fTrueLongitude      = 0;
158    fTrueDate           = 0;
159    fTrueHGround        = -kHuge;
160    fTrueGroundAlbedo   = -kHuge;
161    fTrueGroundSpecular = -kHuge;
162}
163
164//_____________________________________________________________________________
165void ETruth::Copy( TObject& other) const {
166    // copy
167   
168    ETruth& truth = (ETruth&)other; 
169
170    truth.fTrueEnergy         = fTrueEnergy;
171    truth.fTrueTheta          = fTrueTheta;
172    truth.fTruePhi            = fTruePhi;
173    truth.fTrueParticleName   = fTrueParticleName;
174    truth.fTrueParticleCode   = fTrueParticleCode;
175    truth.fTrueInitPosX       = fTrueInitPosX;
176    truth.fTrueInitPosY       = fTrueInitPosY;
177    truth.fTrueInitPosZ       = fTrueInitPosZ;
178    truth.fTrueX1             = fTrueX1;
179    truth.fTrueEarthImpactX   = fTrueEarthImpactX;
180    truth.fTrueEarthImpactY   = fTrueEarthImpactY;
181    truth.fTrueEarthImpactZ   = fTrueEarthImpactZ;
182    truth.fTrueEarthAge       = fTrueEarthAge;
183    truth.fTrueShowerMaxPosX  = fTrueShowerMaxPosX;
184    truth.fTrueShowerMaxPosY  = fTrueShowerMaxPosY;
185    truth.fTrueShowerMaxPosZ  = fTrueShowerMaxPosZ;
186    truth.fTrueShowerXMax     = fTrueShowerXMax;
187    truth.fTrueTOAImpactX     = fTrueTOAImpactX;
188    truth.fTrueTOAImpactY     = fTrueTOAImpactY;
189    truth.fTrueTOAImpactZ     = fTrueTOAImpactZ;
190    truth.fTrueHclouds        = fTrueHclouds;
191
192    truth.fTrueCloudsthick    = fTrueCloudsthick;
193    truth.fTrueCloudsOD       = fTrueCloudsOD;
194    truth.fTrueLatitude       = fTrueLatitude;
195    truth.fTrueLongitude      = fTrueLongitude;
196    truth.fTrueDate           = fTrueDate;
197    truth.fTrueHGround        = fTrueHGround;
198    truth.fTrueGroundAlbedo   = fTrueGroundAlbedo;
199    truth.fTrueGroundSpecular = fTrueGroundSpecular;
200}
201
202//_____________________________________________________________________________
203Float_t ETruth::GetTrueThetaLocal() const {
204    //
205    // returns theta in frame defined at TOAimpact   
206    //
207   
208    const static Float_t EarthRadius = 6.370949e9;  // esaf unit in mm
209   
210    // init
211    TVector3 toaimpact(fTrueTOAImpactX,fTrueTOAImpactY,fTrueTOAImpactZ);
212    TVector3 omega_local(1);
213    omega_local.SetMagThetaPhi(1.,fTrueTheta,fTruePhi);
214   
215    // Change fOmega from MES frame to local frame, using TOA impact as the reference vector
216    TVector3 v1(toaimpact);
217    v1 += TVector3(0,0,EarthRadius);
218    v1 = v1.Unit();
219    TVector3 vrot;
220    TVector3 Uz(0,0,1);
221    vrot = Uz.Cross(v1);
222    if(vrot.Mag() > 1e-6) omega_local.Rotate(-v1.Theta(),vrot);
223   
224    return omega_local.Theta();
225}
226
227//_____________________________________________________________________________
228Float_t ETruth::GetTruePhiLocal() const {
229    //
230    // returns phi in frame defined at TOAimpact   
231    //
232
233    const static Float_t EarthRadius = 6.370949e9;  // esaf unit in mm
234   
235    // init
236    TVector3 toaimpact(fTrueTOAImpactX,fTrueTOAImpactY,fTrueTOAImpactZ);
237    TVector3 omega_local(1);
238    omega_local.SetMagThetaPhi(1.,fTrueTheta,fTruePhi);
239   
240    // Change fOmega from MES frame to local frame, using TOA impact as the reference vector
241    TVector3 v1(toaimpact);
242    v1 += TVector3(0,0,EarthRadius);
243    v1 = v1.Unit();
244    TVector3 vrot;
245    TVector3 Uz(0,0,1);
246    vrot = Uz.Cross(v1);
247    if(vrot.Mag() > 1e-6) omega_local.Rotate(-v1.Theta(),vrot);
248   
249    return omega_local.Phi();
250}
251
Note: See TracBrowser for help on using the repository browser.