source: branches/start/MagicSoft/Simulation/Detector/include-MC/MCEventHeader.hxx@ 18123

Last change on this file since 18123 was 295, checked in by harald, 25 years ago
In this directory you can find a implementation to write and read the output of the reflector program. This classes are needed in the reflector and the camera program. The work in the past was done by Jose Carlos Gonzales. In the future all can work on this using CVS.
File size: 4.8 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 // transport from COREventHeader to MCEventHeader
148 void transport ( COREventHeader *e );
149
150 // write extreme times
151 inline void put_times ( Float_t t1, Float_t t2 ) {
152 TimeFirst = t1;
153 TimeLast = t2;
154 }
155
156 // get extreme times
157 inline Float_t get_times ( Float_t *t1, Float_t *t2 ) {
158 *t1 = TimeFirst;
159 *t2 = TimeLast;
160 return ( TimeLast - TimeFirst );
161 }
162
163 // get/set trigger
164 inline void set_trigger( Int_t flag ) { Trigger = (Float_t)flag; }
165 inline Int_t get_trigger( void ) { return( (Int_t)Trigger ); }
166
167 inline int mysize(void)
168 { return ( sizeof( float ) * SIZE_OF_MCEVENTHEADER ); }
169
170 // put deviations of the CT from the original shower direction
171 inline void put_deviations ( Float_t t1, Float_t t2 ) {
172 deviationTheta = t1;
173 deviationPhi = t2;
174 //cerr << '\n' << deviationTheta << ' ' << deviationPhi << '\n';
175 }
176
177 // get deviations of the CT from the original shower direction
178 inline Float_t get_deviations ( Float_t *t1, Float_t *t2 ) {
179
180 float r;
181
182 r = sqrt(deviationTheta*deviationTheta + deviationPhi*deviationPhi);
183 *t1 = deviationTheta;
184 *t2 = deviationPhi;
185
186 // cerr << '\n' << deviationTheta << ' ' << deviationPhi << '\n' << flush;
187
188 return ( r );
189 }
190
191 inline void print ( void ) {
192 float *ptr = (float *)this;
193 for(int i=0; i<SIZE_OF_MCEVENTHEADER; ++i,++ptr)
194 cerr << i << ':' << *ptr << '\n';
195 }
196
197};
198// @endcode
199
200#endif // not defined MCEventHeader_Class
Note: See TracBrowser for help on using the repository browser.