| 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 | 
|---|
| 17 | This 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    117   /* floats */ | 
|---|
| 42 |  | 
|---|
| 43 | // @endcode | 
|---|
| 44 |  | 
|---|
| 45 | // @subsection Class {\em MCEventHeader}: Definition | 
|---|
| 46 |  | 
|---|
| 47 | // @code | 
|---|
| 48 | class MCEventHeader { | 
|---|
| 49 |  | 
|---|
| 50 | protected: | 
|---|
| 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 |  | 
|---|
| 91 | Float_t      CORSIKAPhs;   // Original photons written by Corsika | 
|---|
| 92 | Float_t      AtmAbsPhs;    // Photons absorved by the atmosphere | 
|---|
| 93 | Float_t      MirrAbsPhs;   // Photons absorved by the mirrors | 
|---|
| 94 | Float_t      OutOfMirrPhs; // Photons outside the mirror | 
|---|
| 95 | Float_t      BlackSpotPhs; // Photons lost in the "black spot" | 
|---|
| 96 | Float_t      OutOfChamPhs; // Photons outside the chamber | 
|---|
| 97 | Float_t      CPhotons;     // Photons reaching the chamber | 
|---|
| 98 |  | 
|---|
| 99 | public: | 
|---|
| 100 | MCEventHeader(void) {}  // default constructor | 
|---|
| 101 |  | 
|---|
| 102 | virtual ~MCEventHeader(void) {}  // default destructor | 
|---|
| 103 |  | 
|---|
| 104 | // reads EventHeader from binary input stream | 
|---|
| 105 | Int_t read ( ifstream &is ) { | 
|---|
| 106 | is.read ( (char *)this, mysize() ); | 
|---|
| 107 | return is.gcount(); | 
|---|
| 108 | } | 
|---|
| 109 |  | 
|---|
| 110 | // writes EventHeader to binary output stream | 
|---|
| 111 | Int_t write ( ofstream &os ) { | 
|---|
| 112 | os.write ( (char *)this, mysize() ); | 
|---|
| 113 | return 0; | 
|---|
| 114 | } | 
|---|
| 115 |  | 
|---|
| 116 | // get information about the EventHeader | 
|---|
| 117 |  | 
|---|
| 118 | // get the primary type (GEANT code) | 
|---|
| 119 | inline Float_t get_primary ( void ) { return ( PrimaryID ); } | 
|---|
| 120 |  | 
|---|
| 121 | // get the total primary energy | 
|---|
| 122 | inline Float_t get_energy ( void ) { return ( Etotal ); } | 
|---|
| 123 |  | 
|---|
| 124 | // get the initial zenith angle | 
|---|
| 125 | inline Float_t get_theta ( void ) { return ( Theta ); } | 
|---|
| 126 |  | 
|---|
| 127 | // get the initial phi angle | 
|---|
| 128 | inline Float_t get_phi ( void ) { return ( Phi ); } | 
|---|
| 129 |  | 
|---|
| 130 | // get the spectrum slope | 
|---|
| 131 | inline Float_t get_slope ( void ) { return ( SlopeSpec ); } | 
|---|
| 132 |  | 
|---|
| 133 | // get height of first interaction (in cm) | 
|---|
| 134 | inline Float_t get_height ( void ) { return ( zFirstInt ); } | 
|---|
| 135 |  | 
|---|
| 136 | // get the energy range of this run | 
|---|
| 137 | inline void get_energy_range ( Float_t *elow, Float_t *eup ) { | 
|---|
| 138 | *elow = ELowLim; | 
|---|
| 139 | *eup = EUppLim; | 
|---|
| 140 | } | 
|---|
| 141 |  | 
|---|
| 142 | // get the theta range of this run | 
|---|
| 143 | inline void get_theta_range ( Float_t *thlow, Float_t *thup ) { | 
|---|
| 144 | *thlow = ThetaMin; | 
|---|
| 145 | *thup = ThetaMax; | 
|---|
| 146 | } | 
|---|
| 147 |  | 
|---|
| 148 | // get the energy range of this run | 
|---|
| 149 | inline void get_phi_range ( Float_t *plow, Float_t *pup ) { | 
|---|
| 150 | *plow = PhiMin; | 
|---|
| 151 | *pup = PhiMax; | 
|---|
| 152 | } | 
|---|
| 153 |  | 
|---|
| 154 | // get the core position | 
|---|
| 155 | inline Float_t get_core ( Float_t *x, Float_t *y, Int_t ncore = 0 ) { | 
|---|
| 156 | *x = CorePos[0][ncore]; | 
|---|
| 157 | *y = CorePos[1][ncore]; | 
|---|
| 158 | return ( (Float_t) sqrt ( (*x)*(*x) + (*y)*(*y) ) ); | 
|---|
| 159 | } | 
|---|
| 160 |  | 
|---|
| 161 | // get the core position | 
|---|
| 162 | inline Float_t get_core ( Int_t ncore = 0 ) { | 
|---|
| 163 | return ( (Float_t) sqrt ( ((CorePos[0][ncore])*(CorePos[0][ncore]))+ | 
|---|
| 164 | ((CorePos[1][ncore])*(CorePos[1][ncore])) ) ); | 
|---|
| 165 | } | 
|---|
| 166 |  | 
|---|
| 167 | // get the core position in X | 
|---|
| 168 | inline Float_t get_coreX ( Int_t ncore = 0 ) { | 
|---|
| 169 | return ( (Float_t) CorePos[0][ncore] ); | 
|---|
| 170 | } | 
|---|
| 171 |  | 
|---|
| 172 | // get the core position in Y | 
|---|
| 173 | inline Float_t get_coreY ( Int_t ncore = 0 ) { | 
|---|
| 174 | return ( (Float_t) CorePos[1][ncore] ); | 
|---|
| 175 | } | 
|---|
| 176 |  | 
|---|
| 177 | //get photons at different stages | 
|---|
| 178 | inline Float_t get_CORSIKA (){ return CORSIKAPhs;} | 
|---|
| 179 |  | 
|---|
| 180 | inline Float_t get_AtmAbs (){ return AtmAbsPhs;} | 
|---|
| 181 |  | 
|---|
| 182 | inline Float_t get_MirrAbs (){ return MirrAbsPhs;} | 
|---|
| 183 |  | 
|---|
| 184 | inline Float_t get_OutOfMirr (){ return OutOfMirrPhs;} | 
|---|
| 185 |  | 
|---|
| 186 | inline Float_t get_BlackSpot (){ return BlackSpotPhs;} | 
|---|
| 187 |  | 
|---|
| 188 | inline Float_t get_OutOfCham (){ return OutOfChamPhs;} | 
|---|
| 189 |  | 
|---|
| 190 | inline Float_t get_CPhotons (){ return CPhotons;} | 
|---|
| 191 |  | 
|---|
| 192 | inline Float_t get_NumObsLev (){return NumObsLev;} | 
|---|
| 193 |  | 
|---|
| 194 | inline Float_t get_HeightLev (Int_t i) {return HeightLev[i];} | 
|---|
| 195 |  | 
|---|
| 196 | inline Float_t get_VersionPGM () {return VersionPGM;} | 
|---|
| 197 |  | 
|---|
| 198 | inline Float_t get_RunNumber () {return RunNumber;} | 
|---|
| 199 |  | 
|---|
| 200 | inline Float_t get_DateRun () {return DateRun;} | 
|---|
| 201 |  | 
|---|
| 202 | inline Float_t get_NumRndSeq () {return NumRndSeq;} | 
|---|
| 203 |  | 
|---|
| 204 | inline Float_t get_CWaveLower() {return CWaveLower;} | 
|---|
| 205 |  | 
|---|
| 206 | inline Float_t get_CWaveUpper() {return CWaveUpper;} | 
|---|
| 207 |  | 
|---|
| 208 | // transport from COREventHeader to MCEventHeader | 
|---|
| 209 | void transport ( COREventHeader *e ); | 
|---|
| 210 |  | 
|---|
| 211 | // write extreme times | 
|---|
| 212 | inline void put_times ( Float_t t1, Float_t t2 ) { | 
|---|
| 213 | TimeFirst = t1; | 
|---|
| 214 | TimeLast  = t2; | 
|---|
| 215 | } | 
|---|
| 216 |  | 
|---|
| 217 | // get extreme times | 
|---|
| 218 | inline Float_t get_times ( Float_t *t1, Float_t *t2 ) { | 
|---|
| 219 | *t1 = TimeFirst; | 
|---|
| 220 | *t2 = TimeLast; | 
|---|
| 221 | return ( TimeLast - TimeFirst ); | 
|---|
| 222 | } | 
|---|
| 223 |  | 
|---|
| 224 | // get/set trigger | 
|---|
| 225 | inline void set_trigger( Int_t flag ) { Trigger = (Float_t)flag; } | 
|---|
| 226 | inline Int_t get_trigger( void ) { return( (Int_t)Trigger ); } | 
|---|
| 227 |  | 
|---|
| 228 | inline int mysize(void) | 
|---|
| 229 | { return ( sizeof( float ) * SIZE_OF_MCEVENTHEADER ); } | 
|---|
| 230 |  | 
|---|
| 231 | // put deviations of the CT from the original shower direction | 
|---|
| 232 | inline void put_deviations ( Float_t t1, Float_t t2 ) { | 
|---|
| 233 | deviationTheta = t1; | 
|---|
| 234 | deviationPhi   = t2; | 
|---|
| 235 | //cerr << '\n' << deviationTheta << ' ' << deviationPhi << '\n'; | 
|---|
| 236 | } | 
|---|
| 237 |  | 
|---|
| 238 | // get deviations of the CT from the original shower direction | 
|---|
| 239 | inline Float_t get_deviations ( Float_t *t1, Float_t *t2 ) { | 
|---|
| 240 |  | 
|---|
| 241 | float ct1,st1,cp1,sp1; | 
|---|
| 242 | float ct2,st2,cp2,sp2; | 
|---|
| 243 | float x1,y1,z1; | 
|---|
| 244 | float x2,y2,z2; | 
|---|
| 245 |  | 
|---|
| 246 | ct1 = cos(Theta); | 
|---|
| 247 | st1 = sin(Theta); | 
|---|
| 248 | cp1 = cos(Phi); | 
|---|
| 249 | sp1 = sin(Phi); | 
|---|
| 250 |  | 
|---|
| 251 | ct2 = cos(Theta+deviationTheta); | 
|---|
| 252 | st2 = sin(Theta+deviationTheta); | 
|---|
| 253 | cp2 = cos(Phi+deviationPhi); | 
|---|
| 254 | sp2 = sin(Phi+deviationPhi); | 
|---|
| 255 |  | 
|---|
| 256 | x1 = st1*cp1; y1 = st1*sp1; z1 = ct1; | 
|---|
| 257 | x2 = st2*cp2; y2 = st2*sp2; z2 = ct2; | 
|---|
| 258 |  | 
|---|
| 259 | *t1 = deviationTheta; | 
|---|
| 260 | *t2 = deviationPhi; | 
|---|
| 261 |  | 
|---|
| 262 | return (  acos(x1*x2 + y1*y2 + z1*z2) ); | 
|---|
| 263 | } | 
|---|
| 264 |  | 
|---|
| 265 | inline void print ( void ) { | 
|---|
| 266 | float *ptr = (float *)this; | 
|---|
| 267 | for(int i=0; i<SIZE_OF_MCEVENTHEADER; ++i,++ptr) | 
|---|
| 268 | cerr << i << ':' << *ptr << '\n'; | 
|---|
| 269 | } | 
|---|
| 270 |  | 
|---|
| 271 | }; | 
|---|
| 272 | // @endcode | 
|---|
| 273 |  | 
|---|
| 274 | #endif  // not defined MCEventHeader_Class | 
|---|