source: trunk/MagicSoft/Simulation/Detector/include-MC/MCEventHeader.hxx@ 17874

Last change on this file since 17874 was 5103, checked in by moralejo, 20 years ago
Changes to adapt headers to c++ style.
File size: 6.9 KB
Line 
1/////////////////////////////////////////////////////////////////
2//
3// MCEventHeader
4//
5// Created: Tue Apr 28 16:27:14 1998
6// Author: Jose Carlos Gonzales
7// Purpose: Base class for EventHeader-classes
8// Notes:
9//
10/////////////////////////////////////////////////////////////////
11
12// @T \newpage
13
14// @section Source code of {\tt MCEventHeader.hxx}
15
16/* @text
17This section shows the include file {\tt MCEventHeader.hxx}
18@endtext */
19
20#ifndef MCEventHeader_Class
21#define MCEventHeader_Class
22
23// @subsection Include files
24
25// @code
26#include <MAGIC.h>
27#include <TObject.h>
28
29#include <iostream>
30#include <iomanip>
31#include <fstream>
32#include <stdlib.h>
33#include <math.h>
34
35#include "COREventHeader.hxx"
36
37#define SIZE_OF_MCEVENTHEADER 117 /* floats */
38
39// @endcode
40
41// @subsection Class {\em MCEventHeader}: Definition
42
43// @code
44class MCEventHeader {
45
46protected:
47 Float_t EvtNumber;
48 Float_t PrimaryID;
49 Float_t Etotal;
50 Float_t Thick0;
51 Float_t FirstTarget;
52 Float_t zFirstInt;
53 Float_t p[3];
54 Float_t Theta;
55 Float_t Phi;
56
57 Float_t NumRndSeq;
58 Float_t RndData[10][3];
59
60 Float_t RunNumber;
61 Float_t DateRun;
62 Float_t VersionPGM;
63
64 Float_t NumObsLev;
65 Float_t HeightLev[10];
66
67 Float_t SlopeSpec;
68 Float_t ELowLim;
69 Float_t EUppLim;
70
71 Float_t ThetaMin;
72 Float_t ThetaMax;
73 Float_t PhiMin;
74 Float_t PhiMax;
75
76 Float_t CWaveLower;
77 Float_t CWaveUpper;
78 Float_t CorePos[2][20];
79 Float_t TimeFirst;
80 Float_t TimeLast;
81
82 Float_t deviationPhi;
83 Float_t deviationTheta;
84
85 Float_t Trigger; // 110 floats
86
87 Float_t CORSIKAPhs; // Original photons written by Corsika
88 Float_t AtmAbsPhs; // Photons absorved by the atmosphere
89 Float_t MirrAbsPhs; // Photons absorved by the mirrors
90 Float_t OutOfMirrPhs; // Photons outside the mirror
91 Float_t BlackSpotPhs; // Photons lost in the "black spot"
92 Float_t OutOfChamPhs; // Photons outside the chamber
93 Float_t CPhotons; // Photons reaching the chamber
94
95public:
96 MCEventHeader(void) {} // default constructor
97
98 virtual ~MCEventHeader(void) {} // default destructor
99
100 // reads EventHeader from binary input stream
101 Int_t read ( ifstream &is ) {
102 is.read ( (char *)this, mysize() );
103 return is.gcount();
104 }
105
106 Int_t read (FILE* f) {
107 return fread((char*)&EvtNumber, (SIZE_OF_MCEVENTHEADER)*sizeof(Float_t), 1, f );
108 }
109
110
111 // writes EventHeader to binary output stream
112 Int_t write ( ofstream &os ) {
113 os.write ( (char *)this, mysize() );
114 return 0;
115 }
116
117 // get information about the EventHeader
118
119 // get the primary type (GEANT code)
120 inline Float_t get_primary ( void ) { return ( PrimaryID ); }
121
122 // get the total primary energy
123 inline Float_t get_energy ( void ) { return ( Etotal ); }
124
125 // get the initial zenith angle
126 inline Float_t get_theta ( void ) { return ( Theta ); }
127
128 // get the initial phi angle
129 inline Float_t get_phi ( void ) { return ( Phi ); }
130
131 // get the spectrum slope
132 inline Float_t get_slope ( void ) { return ( SlopeSpec ); }
133
134 // get height of first interaction (in cm)
135 inline Float_t get_height ( void ) { return ( zFirstInt ); }
136
137 // get the energy range of this run
138 inline void get_energy_range ( Float_t *elow, Float_t *eup ) {
139 *elow = ELowLim;
140 *eup = EUppLim;
141 }
142
143 // get the theta range of this run
144 inline void get_theta_range ( Float_t *thlow, Float_t *thup ) {
145 *thlow = ThetaMin;
146 *thup = ThetaMax;
147 }
148
149 // get the energy range of this run
150 inline void get_phi_range ( Float_t *plow, Float_t *pup ) {
151 *plow = PhiMin;
152 *pup = PhiMax;
153 }
154
155 // get the core position
156 inline Float_t get_core ( Float_t *x, Float_t *y, Int_t ncore = 0 ) {
157 *x = CorePos[0][ncore];
158 *y = CorePos[1][ncore];
159 return ( (Float_t) sqrt ( (*x)*(*x) + (*y)*(*y) ) );
160 }
161
162 // get the core position
163 inline Float_t get_core ( Int_t ncore = 0 ) {
164 return ( (Float_t) sqrt ( ((CorePos[0][ncore])*(CorePos[0][ncore]))+
165 ((CorePos[1][ncore])*(CorePos[1][ncore])) ) );
166 }
167
168 // get the core position in X
169 inline Float_t get_coreX ( Int_t ncore = 0 ) {
170 return ( (Float_t) CorePos[0][ncore] );
171 }
172
173 // get the core position in Y
174 inline Float_t get_coreY ( Int_t ncore = 0 ) {
175 return ( (Float_t) CorePos[1][ncore] );
176 }
177
178 //get photons at different stages
179 inline Float_t get_CORSIKA (){ return CORSIKAPhs;}
180
181 inline Float_t get_AtmAbs (){ return AtmAbsPhs;}
182
183 inline Float_t get_MirrAbs (){ return MirrAbsPhs;}
184
185 inline Float_t get_OutOfMirr (){ return OutOfMirrPhs;}
186
187 inline Float_t get_BlackSpot (){ return BlackSpotPhs;}
188
189 inline Float_t get_OutOfCham (){ return OutOfChamPhs;}
190
191 inline Float_t get_CPhotons (){ return CPhotons;}
192
193 inline Float_t get_NumObsLev (){return NumObsLev;}
194
195 inline Float_t get_HeightLev (Int_t i) {return HeightLev[i];}
196
197 inline Float_t get_VersionPGM () {return VersionPGM;}
198
199 inline Float_t get_RunNumber () {return RunNumber;}
200
201 inline Float_t get_DateRun () {return DateRun;}
202
203 inline Float_t get_NumRndSeq () {return NumRndSeq;}
204
205 inline Float_t get_CWaveLower() {return CWaveLower;}
206
207 inline Float_t get_CWaveUpper() {return CWaveUpper;}
208
209 // transport from COREventHeader to MCEventHeader
210 void transport ( COREventHeader *e );
211
212 // write extreme times
213 inline void put_times ( Float_t t1, Float_t t2 ) {
214 TimeFirst = t1;
215 TimeLast = t2;
216 }
217
218 // get extreme times
219 inline Float_t get_times ( Float_t *t1, Float_t *t2 ) {
220 *t1 = TimeFirst;
221 *t2 = TimeLast;
222 return ( TimeLast - TimeFirst );
223 }
224
225 // get/set trigger
226 inline void set_trigger( Int_t flag ) { Trigger = (Float_t)flag; }
227 inline Int_t get_trigger( void ) { return( (Int_t)Trigger ); }
228
229 inline int mysize(void)
230 { return ( sizeof( float ) * SIZE_OF_MCEVENTHEADER ); }
231
232 // put deviations of the CT from the original shower direction
233 inline void put_deviations ( Float_t t1, Float_t t2 ) {
234 deviationTheta = t1;
235 deviationPhi = t2;
236 //cerr << '\n' << deviationTheta << ' ' << deviationPhi << '\n';
237 }
238
239 // get deviations of the CT from the original shower direction
240 inline Float_t get_deviations ( Float_t *t1, Float_t *t2 ) {
241
242 float ct1,st1,cp1,sp1;
243 float ct2,st2,cp2,sp2;
244 float x1,y1,z1;
245 float x2,y2,z2;
246
247 ct1 = cos(Theta);
248 st1 = sin(Theta);
249 cp1 = cos(Phi);
250 sp1 = sin(Phi);
251
252 ct2 = cos(Theta+deviationTheta);
253 st2 = sin(Theta+deviationTheta);
254 cp2 = cos(Phi+deviationPhi);
255 sp2 = sin(Phi+deviationPhi);
256
257 x1 = st1*cp1; y1 = st1*sp1; z1 = ct1;
258 x2 = st2*cp2; y2 = st2*sp2; z2 = ct2;
259
260 *t1 = deviationTheta;
261 *t2 = deviationPhi;
262
263 return ( acos(x1*x2 + y1*y2 + z1*z2) );
264 }
265
266 inline void print ( void ) {
267 float *ptr = (float *)this;
268 for(int i=0; i<SIZE_OF_MCEVENTHEADER; ++i,++ptr)
269 cerr << i << ':' << *ptr << '\n';
270 }
271
272};
273// @endcode
274
275#endif // not defined MCEventHeader_Class
Note: See TracBrowser for help on using the repository browser.