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

Last change on this file since 664 was 350, checked in by harald, 25 years ago
The member function get_deviations has changed!!! That is all at the moment!
File size: 5.3 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#ifdef __ROOT__
27#include "TROOT.h"
28#include "TObject.h"
29#else // not __ROOT__
30#include "Rtypes.h"
31#endif
32
33#include <iostream.h>
34#include <iomanip.h>
35#include <fstream.h>
36#include <stdlib.h>
37#include <math.h>
38
39#include "COREventHeader.hxx"
40
41#define SIZE_OF_MCEVENTHEADER 110 /* floats */
42
43// @endcode
44
45// @subsection Class {\em MCEventHeader}: Definition
46
47// @code
48class MCEventHeader {
49
50protected:
51 Float_t EvtNumber;
52 Float_t PrimaryID;
53 Float_t Etotal;
54 Float_t Thick0;
55 Float_t FirstTarget;
56 Float_t zFirstInt;
57 Float_t p[3];
58 Float_t Theta;
59 Float_t Phi;
60
61 Float_t NumRndSeq;
62 Float_t RndData[10][3];
63
64 Float_t RunNumber;
65 Float_t DateRun;
66 Float_t VersionPGM;
67
68 Float_t NumObsLev;
69 Float_t HeightLev[10];
70
71 Float_t SlopeSpec;
72 Float_t ELowLim;
73 Float_t EUppLim;
74
75 Float_t ThetaMin;
76 Float_t ThetaMax;
77 Float_t PhiMin;
78 Float_t PhiMax;
79
80 Float_t CWaveLower;
81 Float_t CWaveUpper;
82 Float_t CorePos[2][20];
83 Float_t TimeFirst;
84 Float_t TimeLast;
85
86 Float_t deviationPhi;
87 Float_t deviationTheta;
88
89 Float_t Trigger; // 110 floats
90
91public:
92 MCEventHeader(void) {} // default constructor
93
94 virtual ~MCEventHeader(void) {} // default destructor
95
96 // reads EventHeader from binary input stream
97 Int_t read ( ifstream &is ) {
98 is.read ( (char *)this, mysize() );
99 return is.gcount();
100 }
101
102 // writes EventHeader to binary output stream
103 Int_t write ( ofstream &os ) {
104 os.write ( (char *)this, mysize() );
105 return 0;
106 }
107
108 // get information about the EventHeader
109
110 // get the primary type (GEANT code)
111 inline Float_t get_primary ( void ) { return ( PrimaryID ); }
112
113 // get the total primary energy
114 inline Float_t get_energy ( void ) { return ( Etotal ); }
115
116 // get the initial zenith angle
117 inline Float_t get_theta ( void ) { return ( Theta ); }
118
119 // get the initial phi angle
120 inline Float_t get_phi ( void ) { return ( Phi ); }
121
122 // get the spectrum slope
123 inline Float_t get_slope ( void ) { return ( SlopeSpec ); }
124
125 // get height of first interaction (in cm)
126 inline Float_t get_height ( void ) { return ( zFirstInt ); }
127
128 // get the energy range of this run
129 inline void get_energy_range ( Float_t *elow, Float_t *eup ) {
130 *elow = ELowLim;
131 *eup = EUppLim;
132 }
133
134 // get the core position
135 inline Float_t get_core ( Float_t *x, Float_t *y, Int_t ncore = 0 ) {
136 *x = CorePos[0][ncore];
137 *y = CorePos[1][ncore];
138 return ( (Float_t) sqrt ( (*x)*(*x) + (*y)*(*y) ) );
139 }
140
141 // get the core position
142 inline Float_t get_core ( Int_t ncore = 0 ) {
143 return ( (Float_t) sqrt ( ((CorePos[0][ncore])*(CorePos[0][ncore]))+
144 ((CorePos[1][ncore])*(CorePos[1][ncore])) ) );
145 }
146
147 // get the core position in X
148 inline Float_t get_coreX ( Int_t ncore = 0 ) {
149 return ( (Float_t) CorePos[0][ncore] );
150 }
151
152 // get the core position in Y
153 inline Float_t get_coreY ( Int_t ncore = 0 ) {
154 return ( (Float_t) CorePos[1][ncore] );
155 }
156
157 // transport from COREventHeader to MCEventHeader
158 void transport ( COREventHeader *e );
159
160 // write extreme times
161 inline void put_times ( Float_t t1, Float_t t2 ) {
162 TimeFirst = t1;
163 TimeLast = t2;
164 }
165
166 // get extreme times
167 inline Float_t get_times ( Float_t *t1, Float_t *t2 ) {
168 *t1 = TimeFirst;
169 *t2 = TimeLast;
170 return ( TimeLast - TimeFirst );
171 }
172
173 // get/set trigger
174 inline void set_trigger( Int_t flag ) { Trigger = (Float_t)flag; }
175 inline Int_t get_trigger( void ) { return( (Int_t)Trigger ); }
176
177 inline int mysize(void)
178 { return ( sizeof( float ) * SIZE_OF_MCEVENTHEADER ); }
179
180 // put deviations of the CT from the original shower direction
181 inline void put_deviations ( Float_t t1, Float_t t2 ) {
182 deviationTheta = t1;
183 deviationPhi = t2;
184 //cerr << '\n' << deviationTheta << ' ' << deviationPhi << '\n';
185 }
186
187 // get deviations of the CT from the original shower direction
188 inline Float_t get_deviations ( Float_t *t1, Float_t *t2 ) {
189
190 float ct1,st1,cp1,sp1;
191 float ct2,st2,cp2,sp2;
192 float x1,y1,z1;
193 float x2,y2,z2;
194
195 ct1 = cos(Theta);
196 st1 = sin(Theta);
197 cp1 = cos(Phi);
198 sp1 = sin(Phi);
199
200 ct2 = cos(Theta+deviationTheta);
201 st2 = sin(Theta+deviationTheta);
202 cp2 = cos(Phi+deviationPhi);
203 sp2 = sin(Phi+deviationPhi);
204
205 x1 = st1*cp1; y1 = st1*sp1; z1 = ct1;
206 x2 = st2*cp2; y2 = st2*sp2; z2 = ct2;
207
208 *t1 = deviationTheta;
209 *t2 = deviationPhi;
210
211 return ( acos(x1*x2 + y1*y2 + z1*z2) );
212 }
213
214 inline void print ( void ) {
215 float *ptr = (float *)this;
216 for(int i=0; i<SIZE_OF_MCEVENTHEADER; ++i,++ptr)
217 cerr << i << ':' << *ptr << '\n';
218 }
219
220};
221// @endcode
222
223#endif // not defined MCEventHeader_Class
Note: See TracBrowser for help on using the repository browser.