CorsikaBlock.h
Go to the documentation of this file.
1 
12 #ifndef _io_Corsika_Block_h_
13 #define _io_Corsika_Block_h_
14 
15 #include <cstddef>
16 
17 
18 namespace io {
19 
20  namespace Corsika {
21 
47  typedef float RWORD; // 4 byte real
48 
49 
51 
52  /* C ---------------------------------------------------------
53  C ELEMENT 77 OF EVENT HEADER HAS THE FOLLOWING CONTENTS IF
54  C CONVERTED TO AN INTEGER WITH SUITABLE ROUNDING APPLIED:
55  C BIT 1: CERENKOV OPTION COMPILED IN
56  C 2: IACT OPTION COMPILED IN
57  C 3: CEFFIC OPTION COMPILED IN
58  C 4: ATMEXT OPTION COMPILED IN
59  C 5: ATMEXT OPTION USED WITH REFRACTION ENABLED
60  C 6: VOLUMEDET OPTION COMPILED IN
61  C 7: CURVED OPTION COMPILED IN (SEE ALSO EVTH(79))
62  C 8: USED BY THE IACT INTERFACE
63  C 9: SLANT OPTION
64  C 10: UNUSED
65  C 11-21: TABLE NUMBER FOR EXTERNAL ATMOSPHERE TABLE
66  C (BUT LIMITED TO 1023 IF THE NUMBER IS LARGER)
67  C -------------------------------------------------------- */
68 
69  enum Flags {
70  eCHERENKOV = 0x00001,
71  eIACT = 0x00002,
72  eCEFFIC = 0x00004,
73  eATMEXT = 0x00008,
74  eREFRACT = 0x00010,
75  eVOLUMEDET = 0x00020,
76  eCURVED = 0x00040,
77  // 0x00080 used by IACT interface
78  eSLANT = 0x00100,
79  // unused 0x00200
80  eATMO_ID = 0xffc00,
82  };
83 
84  public:
85  CherenkovFlags(const unsigned int d) : fData(d) { }
86 
87  bool IsCHERENKOV() const { return fData & eCHERENKOV; }
88  bool IsIACT() const { return fData & eIACT; }
89  bool IsCEFFIC() const { return fData & eCEFFIC; }
90  bool IsATMEXT() const { return fData & eATMEXT; }
91  bool IsREFRACT() const { return fData & eREFRACT; }
92  bool IsVOLUMEDET() const { return fData & eVOLUMEDET; }
93  bool IsCURVED() const { return fData & eCURVED; }
94  bool IsSLANT() const { return fData & eSLANT; }
95 
96  int GetATMO_ID() const { return (fData & eATMO_ID) >> eATMO_IDShift; }
97 
98  private:
99  unsigned int fData = 0;
100  };
101 
102 
103  static const unsigned int kMaxObservationLevels = 10;
104  static const unsigned int kParticlesInBlock = 39;
105 
106 
112  class BlockID {
113  public:
115  static const size_t kLength = 4;
116 
118  void SetID(const char* const theID);
119 
121  const char* GetID() const { return fID; }
122 
124  bool Is(const char* const theID) const;
125 
126  private:
127  char fID[kLength]; // hold strings like RUNH etc to
128  // identify the block type
129  };
130 
131 
136  struct RunHeader {
141 
144 
146  RWORD fEMin, fEMax; // in GeV
147 
150 
152  RWORD fCutoffMuons; // in GeV
155 
157  RWORD fConstUNUSED1a[5]; // inclined observation level parameters. Check Guide.
158  RWORD fCoordinateRotation; // c.f. ARRANG option of CORSIKA
174  };
175 
176 
182  struct EventHeader {
189  RWORD fZFirst; // cm
190  RWORD fPx, fPy, fPz; // GeV
191  RWORD fTheta; // zenith in radians
192  RWORD fPhi; // azimuth in radians
193 
194  struct Seed {
198  };
201 
205 
208 
210  RWORD fEMin, fEMax; // in GeV
211 
213  RWORD fCutoffMuons; // in GeV
216 
223 
224  RWORD fBx, fBz; // magnetic field in mu T
227 
233  RWORD fFlagComputer; // 1: IBM, 2: Transputer, 3: DEC/UNIX, 4: Mac,
234  // 5: VAX/VMS, 6: GNU/Linux
235 
236  RWORD fThetaMin, fThetaMax; // degrees
237  RWORD fPhiMin, fPhiMax; // degrees
238 
244 
247 
251  RWORD fCoreX[20], fCoreY[20]; // cm
252 
257  RWORD fFlagMuonMultiple; // 0: Gauss, 1: Moilere
259  RWORD fEFractionThinningH; // Energy fraction of thinning
260  // level
261  // These are in the CORSIKA manual but not in Lukas's original code
262  RWORD fEFractionThinningEM; // Energy fraction of thinning level EM
266 
275 
276  // Padding adjusted according to additions described above
277  RWORD fPad[105];
278  };
279 
280 
286  struct RunTrailer {
290 
291  RWORD fPad[270];
292  };
293 
294 
300  struct EventTrailer {
303 
309 
310  // NKG output
311  RWORD fLateral1X[21], fLateral1Y[21]; // cm^-2
312  RWORD fLateral1XY[21], fLateral1YX[21]; // cm^-2
313 
314  RWORD fLateral2X[21], fLateral2Y[21]; // cm^-2
315  RWORD fLateral2XY[21], fLateral2YX[21]; // cm^-2
316 
317  RWORD fElectronNumber[10]; // in steps of 100 g cm^-2
318  RWORD fAge[10]; // in steps of 100 g cm^-2
319  RWORD fDistances[10]; // cm
321 
322  RWORD fLevelHeightMass[10]; // g cm^-2
326 
327  // Longitudinal distribution
330  // Added according to the CORSIKA manual
336 
338  };
339 
340 
341  //
342 
343 
344  template<class T, unsigned int n>
345  class Padded : public T {
347  };
348 
349 
355  bool IsParticle() const
356  { return 0 < fDescription && fDescription < 100000; }
357  bool IsNucleus() const
358  { return 100000 <= fDescription && fDescription < 9900000; }
359  bool IsCherenkov() const
360  { return 9900000 <= fDescription; }
361 
362  RWORD fDescription; // Particle ID
363  RWORD fPx, fPy, fPz; // GeV
364  RWORD fX, fY; // cm
365  RWORD fTorZ; // ns or cm
366  };
367 
368 
370  RWORD fWeight; // absent if CORSIKA compiled w/o thinning
371  };
372 
373 
379  RWORD fPhotonsInBunch; // includes weight
380  RWORD fX, fY; // cm
381  RWORD fU, fV; // cos to X and Y axis
382  RWORD fT; // ns
383  //RWORD fProductionHeight; // cm
385  };
386 
387 
389  RWORD fWavelength; // absent if CORSIKA compiled w/o thinning
390  };
391 
392 
393  template<class ParticleType, class CherenkovType,
394  unsigned int nParticles, unsigned int padding>
395  class BasicBlock {
396  public:
397  static const unsigned int kPadding = padding;
398 
399  struct ParticleBlock {
400  ParticleType fParticle[nParticles];
401  };
402 
403  struct CherenkovBlock {
404  CherenkovType fParticle[nParticles];
405  };
406 
411 
412  union SubBlock {
419  };
420 
421  bool IsRunHeader() const { return fSubBlock.fRunHeader.fID.Is("RUNH"); }
422  bool IsRunTrailer() const { return fSubBlock.fRunTrailer.fID.Is("RUNE"); }
423  bool IsEventHeader() const { return fSubBlock.fEventHeader.fID.Is("EVTH"); }
424  bool IsEventTrailer() const { return fSubBlock.fEventTrailer.fID.Is("EVTE"); }
425  bool IsControl() const
426  { return IsRunHeader() || IsRunTrailer() || IsEventHeader() || IsEventTrailer(); }
427 
428  const RunHeader& AsRunHeader() const { return fSubBlock.fRunHeader; }
429  const RunTrailer& AsRunTrailer() const { return fSubBlock.fRunTrailer; }
430  const EventHeader& AsEventHeader() const { return fSubBlock.fEventHeader; }
432  const ParticleBlock& AsParticleBlock() const { return fSubBlock.fParticleBlock; }
433  const CherenkovBlock& AsCherenkovBlock() const { return fSubBlock.fCherenkovBlock; }
434 
435  private:
436  SubBlock fSubBlock;
437 
438  };
439 
440 
441  // Padding for thinning (in RWORDS): 39 (thinning) or 0 (no thinning)
442 
444 
446 
447  }
448 
449 }
450 
451 
452 #endif
static const unsigned int kParticlesInBlock
Definition: CorsikaBlock.h:104
Padded< EventTrailer, padding > EventTrailerPadded
Definition: CorsikaBlock.h:410
const RunTrailer & AsRunTrailer() const
Definition: CorsikaBlock.h:429
ParticleType fParticle[nParticles]
Definition: CorsikaBlock.h:400
Padded< EventHeader, padding > EventHeaderPadded
Definition: CorsikaBlock.h:409
bool IsRunHeader() const
Definition: CorsikaBlock.h:421
struct with particle data
Definition: CorsikaBlock.h:369
RWORD fObservationHeight[kMaxObservationLevels]
Definition: CorsikaBlock.h:207
event header struct for Corsika files
Definition: CorsikaBlock.h:182
const RunHeader & AsRunHeader() const
Definition: CorsikaBlock.h:428
EventTrailerPadded fEventTrailer
Definition: CorsikaBlock.h:416
const EventTrailer & AsEventTrailer() const
Definition: CorsikaBlock.h:431
Padded< RunTrailer, padding > RunTrailerPadded
Definition: CorsikaBlock.h:408
bool IsEventHeader() const
Definition: CorsikaBlock.h:423
const CherenkovBlock & AsCherenkovBlock() const
Definition: CorsikaBlock.h:433
struct with Cherenkov data
Definition: CorsikaBlock.h:388
run header struct for Corsika files
Definition: CorsikaBlock.h:136
bool IsEventTrailer() const
Definition: CorsikaBlock.h:424
static const unsigned int kPadding
Definition: CorsikaBlock.h:397
run trailer struct for Corsika files
Definition: CorsikaBlock.h:286
BasicBlock< ParticleData, CherenkovData, kParticlesInBlock, 39 > Block
Definition: CorsikaBlock.h:443
CherenkovFlags(const unsigned int d)
Definition: CorsikaBlock.h:85
bool IsControl() const
Definition: CorsikaBlock.h:425
Padded< RunHeader, padding > RunHeaderPadded
Definition: CorsikaBlock.h:407
BasicBlock< ParticleDataUnthinned, CherenkovDataUnthinned, kParticlesInBlock, 0 > BlockUnthinned
Definition: CorsikaBlock.h:445
const EventHeader & AsEventHeader() const
Definition: CorsikaBlock.h:430
const ParticleBlock & AsParticleBlock() const
Definition: CorsikaBlock.h:432
bool IsRunTrailer() const
Definition: CorsikaBlock.h:422
const char * GetID() const
set from c-string (for testing)
Definition: CorsikaBlock.h:121
static const size_t kLength
Length of sub-block identifier.
Definition: CorsikaBlock.h:115
static const unsigned int kMaxObservationLevels
Definition: CorsikaBlock.h:103
CherenkovType fParticle[nParticles]
Definition: CorsikaBlock.h:404
char fID[kLength]
Definition: CorsikaBlock.h:127
void SetID(const char *const theID)
set from c-string (for testing)
Definition: CorsikaBlock.cc:18
RWORD fObservationHeight[kMaxObservationLevels]
Definition: CorsikaBlock.h:143
bool Is(const char *const theID) const
Compare ID&#39;s.
Definition: CorsikaBlock.cc:33
Sub-block used in CORSIKA files.
Definition: CorsikaBlock.h:112
event trailer struct for Corsika files
Definition: CorsikaBlock.h:300

, generated on Tue Sep 26 2023.