CorsikaShowerFile.h
Go to the documentation of this file.
1 #ifndef _io_CorsikaShowerFile_h_
2 #define _io_CorsikaShowerFile_h_
3 
4 #include <io/RawCorsikaFile.h>
5 #include <io/CorsikaShowerFileParticleIterator.h>
6 #include <io/CorsikaIOException.h>
7 #include <io/VEventFile.h>
8 
9 #include <utl/CoordinateSystemPtr.h>
10 #include <utl/Branch.h>
11 
12 #include <string>
13 #include <fstream>
14 #include <map>
15 #include <vector>
16 
17 
18 namespace evt {
19  class Event;
20  class ShowerSimData;
21  class GaisserHillas6Parameter;
22 }
23 
24 
25 namespace io {
26 
37  class CorsikaShowerFile : public VEventFile {
38 
39  public:
41  CorsikaShowerFile(const std::string& fileName, const Mode mode = eRead, utl::Branch* const b = nullptr);
42  virtual ~CorsikaShowerFile();
43 
44  void Open(const std::string& fileName, const Mode mode = eRead, utl::Branch* const b = nullptr) override;
45  void Close() override;
46  Status Read(evt::Event& event) override;
47  void Write(const evt::Event& event) override;
48  Status FindEvent(const unsigned int eventId) override;
49  Status GotoPosition(const unsigned int position) override;
50  int GetNEvents() override;
51 
52  void SetMagneticFieldDeclination(const double d) { fMagneticDeclination = d; }
54  void SetReadLongFile(const bool f) { fReadLongFile = f; }
55 
58 
59  private:
60  typedef std::vector<Corsika::RawFile::PositionType> PositionVector;
61  typedef std::map<unsigned int, unsigned int> IdToPositionMap;
62 
63  void SetRunHeader(const bool first, const Corsika::RunHeader& header);
64  void SetEventHeader(const bool first, const unsigned int eventsSoFar, const Corsika::EventHeader& eh);
65  void SetHeaderTrailer(evt::Event& event, double& timeShift,
66  evt::GaisserHillas6Parameter& gh, bool& haveGH, double& zenith,
67  const Corsika::EventHeader& header, const Corsika::EventTrailer& trailer);
68 
70  Status ScanGroundFile(const std::string& name, Corsika::RawFile& raw, PositionVector& posEVTH, PositionVector& posEVTE,
71  const bool first, const bool noException = false);
72 
74  Status ScanLongFile(const std::string& name);
75  Status ReadProfile(evt::ShowerSimData& shower, const double zenith);
76 
77  Status ScanSteerFile(const std::string& name);
78 
81 
83  double GetDensityVsHeight(const double height) const;
85  double GetDepthVsHeight(const double h) const;
87  double GetSlantDepthCurved(const double hObs, const double theta, const double h) const;
88 
89  // data members
90  bool fOpenedAnything = false;
91  unsigned int fNumberOfEvents = 0;
93  std::map<utl::AttributeMap, io::Corsika::RawFile> fCherenkovFile;
94 
95  std::string fRefCoordinateSystemName = "PampaAmarilla";
96  //utl::CoordinateSystemPtr fRefCoordinateSystem;
97  std::vector<int> fMultiCoreSelection;
98 
99  std::string fLongFile;
100  bool fReadLongFile = false;
101 
102  std::string fSteerFile;
103  bool fReadSteerFile = false;
104 
105  std::string fListFile;
106  bool fReadListFile = false;
107 
110  std::map<utl::AttributeMap, PositionVector> fPositionToCherenkovRaw;
111  std::map<utl::AttributeMap, PositionVector> fPositionOfCherenkovEventTrailer;
113  unsigned int fCurrentPosition = 0;
114  int fRunNumber = 0;
116  unsigned int fObservationLevel = 1;
117  bool fIsThinned = true;
118  bool fIsSlant = true;
119 
120  bool fHasCherenkov = false;
123 
124  double fMagneticDeclination = -4.233*utl::degree; // some history halve-wrong value [WEST=-EAST]
126 
128 
130  std::map<utl::AttributeMap, CorsikaShowerFileParticleIterator*> fCherenkovIterator;
131 
132  std::vector<double> fShowerEnergy;
133  std::vector<double> fShowerTheta;
134  std::vector<double> fShowerPhi;
135 
136  friend class REASFile; // necessary so that REASFile can call ReadProfile()
137  friend class REASH5File; // necessary so that REASFile can call ReadProfile()
138 
139  };
140 
141 }
142 
143 
144 #endif
void SetHeaderTrailer(evt::Event &event, double &timeShift, evt::GaisserHillas6Parameter &gh, bool &haveGH, double &zenith, const Corsika::EventHeader &header, const Corsika::EventTrailer &trailer)
Status Read(evt::Event &event) override
read current event advance cursor by 1
Status ReadProfile(evt::ShowerSimData &shower, const double zenith)
int raw
Definition: dump1090.h:270
Status ScanGroundFile(const std::string &name, Corsika::RawFile &raw, PositionVector &posEVTH, PositionVector &posEVTE, const bool first, const bool noException=false)
Collect information about ground file.
double GetDepthVsHeight(const double h) const
Return vertical atmospheric depth as a function of height, according to the parameters stored in the ...
void Write(const evt::Event &event) override
event header struct for Corsika files
Definition: CorsikaBlock.h:182
Status ScanSteerFile(const std::string &name)
Mode
Available open modes.
Definition: IoCodes.h:16
CorsikaShowerFileParticleIterator * fParticleIterator
Raw disk file.
unsigned int fObservationLevel
std::vector< double > fShowerTheta
Status GotoPosition(const unsigned int position) override
goto by position in the file
std::map< unsigned int, unsigned int > IdToPositionMap
Interface class to access Shower Simulated parameters.
Definition: ShowerSimData.h:49
Status ScanLongFile(const std::string &name)
Read longitudinal profile.
Class representing a document branch.
Definition: Branch.h:107
Status
Return code for seek operation.
Definition: IoCodes.h:24
void SetRunHeader(const bool first, const Corsika::RunHeader &header)
void SetMagneticFieldDeclination(const double d)
run header struct for Corsika files
Definition: CorsikaBlock.h:136
std::string fRefCoordinateSystemName
void UseRealisticMagneticDeclination(const bool v)
std::vector< double > fShowerEnergy
std::vector< double > fShowerPhi
CorsikaShowerFileParticleIterator * GetCorsikaShowerFileParticleIterator() const
Get CorsikaShowerFileParticleIterator for testing.
constexpr double degree
Read data from the output of CORSIKA.
Corsika::AtmosphereParameters fAtmPars
Implementation of the VShowerFileParticleIterator for an Corsika generated shower file...
void SetReadLongFile(const bool f)
PositionVector fPositionOfEventTrailer
void Open(const std::string &fileName, const Mode mode=eRead, utl::Branch *const b=nullptr) override
std::map< utl::AttributeMap, io::Corsika::RawFile > fCherenkovFile
Status ReadSteerFile(evt::Event &event)
Read steering file.
std::map< utl::AttributeMap, CorsikaShowerFileParticleIterator * > fCherenkovIterator
std::map< utl::AttributeMap, PositionVector > fPositionOfCherenkovEventTrailer
PositionVector fPositionToRaw
Read REAS simulation output.
Definition: REASFile.h:34
IdToPositionMap fIdToPosition
Read REASH5 simulation output.
Definition: REASH5File.h:40
Status FindEvent(const unsigned int eventId) override
seek Event id set cursor there
std::vector< int > fMultiCoreSelection
unsigned int fNumberOfEvents
void SetEventHeader(const bool first, const unsigned int eventsSoFar, const Corsika::EventHeader &eh)
std::vector< Corsika::RawFile::PositionType > PositionVector
double GetDensityVsHeight(const double height) const
Return the air density as a function of height, according to the parameters stored in the file...
io::Corsika::RawFile fRawFile
Gaisser-Hillas with 6 parameters (CORSIKA)
std::map< utl::AttributeMap, PositionVector > fPositionToCherenkovRaw
double GetSlantDepthCurved(const double hObs, const double theta, const double h) const
Return slant atmospheric depth as a function of height, according to the parameters stored in the fil...
event trailer struct for Corsika files
Definition: CorsikaBlock.h:300

, generated on Tue Sep 26 2023.