8 #include <io/SELFASFile.h>
9 #include <io/SELFASIOException.h>
11 #include <evt/Event.h>
12 #include <evt/ShowerSimData.h>
13 #include <evt/SimRadioPulse.h>
14 #include <evt/RadioSimulation.h>
15 #include <evt/DefaultShowerGeometryProducer.h>
17 #include <utl/VParticleProperties.h>
18 #include <utl/ErrorLogger.h>
19 #include <utl/AugerUnits.h>
20 #include <utl/PhysicalConstants.h>
21 #include <utl/Vector.h>
22 #include <utl/UTMPoint.h>
23 #include <utl/TimeStamp.h>
24 #include <utl/Particle.h>
25 #include <det/Detector.h>
33 #include <boost/tokenizer.hpp>
39 using std::ostringstream;
46 SELFASFile::SELFASFile(
const string& fileName,
const Mode mode,
utl::Branch*
const ) :
59 msg <<
"Cannot open file " <<
FileName <<
" - ERROR";
65 msg <<
"Cannot open file " << fileName <<
" - SELFAS files are read-only";
76 typedef boost::tokenizer<boost::char_separator<char>> my_tok;
77 boost::char_separator<char> separ(sep.c_str());
78 my_tok tok(line, separ);
79 vector<string> zetokens;
80 for (boost::tokenizer<boost::char_separator<char> >::const_iterator titer = tok.begin(); titer != tok.end(); ++titer)
81 zetokens.push_back(*titer);
91 std::istringstream iss(s);
92 return !(iss >> f >> t).
fail();
99 INFO(
"READ SELFASFile");
105 const string msg =
"Cannot read from a closed file.";
112 vector<double> xinflexion;
119 string LineSep =
" ";
120 vector<string> SplitedLine =
StringSplitter(theLine, LineSep.c_str());
122 if (SplitedLine[1] ==
"shower") {
124 }
else if (SplitedLine[1] ==
"shower_id") {
126 }
else if (SplitedLine[1] ==
"B0") {
127 from_string<double>(
fB0, SplitedLine[2], std::dec);
128 }
else if(SplitedLine[1] ==
"Bfield") {
129 int strsize = SplitedLine[3].size();
130 std::string SplitedLine2 = SplitedLine[3].substr(1,strsize-2);
131 string LineSep =
",";
132 vector<string> SplitedLine3 =
StringSplitter(SplitedLine2, LineSep.c_str());
133 from_string<double>(
fBx, SplitedLine3[0], std::dec);
134 from_string<double>(
fBy, SplitedLine3[1], std::dec);
135 from_string<double>(
fBz, SplitedLine3[2], std::dec);
136 }
else if (SplitedLine[1] ==
"Bfield_Vec::") {
137 int strsize = SplitedLine[2].size();
138 std::string SplitedLine2 = SplitedLine[2].substr(1,strsize-2);
139 string LineSep =
",";
140 vector<string> SplitedLine3 =
StringSplitter(SplitedLine2, LineSep.c_str());
141 from_string<double>(
fBx, SplitedLine3[0], std::dec);
142 from_string<double>(
fBy, SplitedLine3[1], std::dec);
143 from_string<double>(
fBz, SplitedLine3[2], std::dec);
144 }
else if (SplitedLine[1] ==
"site" && SplitedLine[3] ==
"(m)") {
145 from_string<double>(
fSiteGround_m, SplitedLine[4], std::dec);
146 fSiteGround_m = fSiteGround_m *
meter;
147 }
else if (SplitedLine[1] ==
"site_ground_(m)") {
148 from_string<double>(
fSiteGround_m, SplitedLine[2], std::dec);
149 fSiteGround_m = fSiteGround_m *
meter;
150 }
else if(SplitedLine[1] ==
"site" && SplitedLine[3] ==
"(gcm2)") {
153 }
else if (SplitedLine[1] ==
"site_ground_(gcm2)") {
156 }
else if (SplitedLine[1] ==
"theta") {
157 from_string<double>(
fzenith_angle, SplitedLine[2], std::dec);
158 fzenith_angle = fzenith_angle *
deg;
159 }
else if (SplitedLine[1] ==
"phi") {
161 fazimuth_angle = fazimuth_angle *
deg;
162 }
else if (SplitedLine[1] ==
"xc") {
164 fx_core_position = fx_core_position *
meter;
165 }
else if (SplitedLine[1] ==
"yc") {
167 fy_core_position = fy_core_position *
meter;
168 }
else if (SplitedLine[1] ==
"zc") {
170 fz_core_position = fz_core_position *
meter;
171 }
else if (SplitedLine[1] ==
"primary") {
172 if (SplitedLine[2] ==
"1")
174 }
else if (SplitedLine[1] ==
"Ep") {
177 }
else if (SplitedLine[1] ==
"Ep_(EeV)") {
180 cout <<
"primary_energy " << fprimary_energy << endl;
181 }
else if (SplitedLine[1] ==
"x1") {
183 ffirst_interaction_lenght = ffirst_interaction_lenght *
meter;
184 }
else if (SplitedLine[1] ==
"xmax") {
185 from_string<double>(
fxmax, SplitedLine[2], std::dec);
186 }
else if (SplitedLine[1] ==
"xinflexion") {
187 from_string<double>(
fxinflexion, SplitedLine[2], std::dec);
188 xinflexion.push_back(fxinflexion);
189 }
else if (SplitedLine[1] ==
"timestep") {
190 from_string<double>(
ftime_step,SplitedLine[2],std::dec);
191 ftime_step = ftime_step *
ns;
192 }
else if (SplitedLine[1] ==
"npart") {
194 }
else if (SplitedLine[1] ==
"has_charge_excess") {
196 if (charge_excess == 1) {
198 cout <<
"charge excess on" << endl;
200 cout <<
"charge excess off " << endl ;
201 }
else if (SplitedLine[1] ==
"has_multiple_scattering") {
203 if (multiple_scattering == 1) {
205 cout <<
"multiple scattering on" << endl;
207 cout <<
"multiple scattering off " << endl ;
208 }
else if (SplitedLine[1] ==
"has_dE_dx") {
209 from_string<double>(
de_dx, SplitedLine[2], std::dec);
212 cout <<
"de_dx on" << endl;
214 cout <<
"de_dx off " << endl ;
215 }
else if (SplitedLine[1] ==
"has_Cerenkov") {
216 from_string<double>(
Cerenkov, SplitedLine[2], std::dec);
219 cout <<
"Cerenkov on" << endl;
221 cout <<
"Cerenkov off" << endl ;
222 }
else if (SplitedLine[1] ==
"Nantennas") {
224 cout <<
"number of antennas = " << fantennas_number << endl;
226 cout<<
"unknown parameter" <<endl;
232 unsigned int gpssecs = 1010534400;
233 unsigned int gpsnanosecs = 200;
239 ERROR(
"Event not cleared - has SimShower. Cannot read SELFASFile.");
244 #warning RU: check geometry
258 UTMPoint utmpampaOrig(pampaOrig, ReferenceEllipsoid::GetWGS84());
259 float pampaheight = utmpampaOrig.
GetHeight();
263 cout <<
"warning - it may be necessary to increase the </MaximumAllowedDistance>\n"
264 "---------------------------------------------------------------------" << endl;
271 event.GetHeader().SetId(fparticle_id);
278 string LineSep =
" ";
281 vector<string> SplitedLine =
StringSplitter(theLine, LineSep.c_str());
283 int strsize = SplitedLine[6].size();
284 std::string SplitedLine2 = SplitedLine[6].substr(1, strsize - 2);
286 vector<string> SplitedLine3 =
StringSplitter(SplitedLine2,
string(
",").c_str());
287 from_string<double>(antenna_position[i][0], SplitedLine3[0], std::dec);
288 from_string<double>(antenna_position[i][1], SplitedLine3[1], std::dec);
289 from_string<double>(antenna_position[i][2], SplitedLine3[2], std::dec);
291 int strsize2 = SplitedLine[8].size();
292 std::string SplitedLine4 = SplitedLine[8].substr(1, strsize2 - 2);
299 fx_core_relative_position = fx_core_relative_position *
meter;
300 fy_core_relative_position = fy_core_relative_position *
meter;
301 fz_core_relative_position = fz_core_relative_position *
meter;
302 pulses[i].SetRelativeCoordinates(fx_core_relative_position, fy_core_relative_position, fz_core_relative_position);
305 vector<int> CountStartTime(fantennas_number, 0);
306 vector<int> CountEmptyBins(fantennas_number, 0);
308 double e_field[3] = { 0, 0, 0 };
317 string LineSep =
" ";
322 vector<string> SplitedLine =
StringSplitter(theLine, LineSep.c_str());
323 from_string<double>(binTime, SplitedLine[0], std::dec);
324 binTime = binTime *
ns;
327 from_string<double>(
fxefield, SplitedLine[1+3*i], std::dec);
328 from_string<double>(
fyefield, SplitedLine[2+3*i], std::dec);
329 from_string<double>(
fzefield, SplitedLine[3+3*i], std::dec);
336 if (e_field[0] && e_field[1] && e_field[2])
338 if (CountEmptyBins[i] >= 1) {
339 TraceV3D& pulsestimeseries = pulses[i].GetEfieldTimeSeries();
343 if (CountEmptyBins[i] >= 1 && CountStartTime[i] == 0) {
344 pulses[i].SetStartTime(binTime);
370 const string msg =
"Cannot write to SELFASFile - read-only file";
int GetNEvents() override
std::ifstream finput_file
constexpr double centimeter
double ffirst_interaction_lenght
double fz_core_relative_position
void MakeRadioSimulation()
Make the RadioSimulation.
Class to hold and convert a point in geodetic coordinates.
bool HasSimShower() const
Data structure for a radio simulation (including several SimRadioPulses)
Mode
Available open modes.
void SetGroundParticleCoordinateSystemAzimuth(const double azimuth)
Set the azimuth angle of the shower. Angle in x-y plane wrt. to the x axis (0 is from east)...
#define INFO(message)
Macro for logging informational messages.
utl::SVector< 3, double > Vector3D
Status FindEvent(const unsigned int eventId) override
seek Event id set cursor there
void SetRunNumber(const int runnum)
Set the run number of the RadioSimulation.
std::string fprimary_particle
void fail(const std::string &name)
A TimeStamp holds GPS second and nanosecond for some event.
void SetEventNumber(const int eventnum)
Set the event number of the RadioSimulation.
std::vector< std::string > StringSplitter(const std::string &line, const std::string &sep)
Interface class to access Shower Simulated parameters.
void Open(const std::string &fileName, const Mode mode, utl::Branch *const b=nullptr) override
boost::shared_ptr< const CoordinateTransformer > CoordinateSystemPtr
Shared pointer for coordinate systems.
Class representing a document branch.
Status
Return code for seek operation.
double GetHeight() const
Get the height.
void SetEventTime(const utl::TimeStamp &t)
Set the event time of the RadioSimulation.
RadioSimulation & GetRadioSimulation()
Get the radio simulation data.
unsigned int events_remaining
double fsimulated_particles
void SetCoreCoordinates(const double x, const double y, const double z)
Set the core position coordinates of the RadioSimulation.
Base for exceptions in the SELFAS reader.
bool from_string(T &t, const std::string &s, std::ios_base &(*f)(std::ios_base &))
void SetEnergy(const double theEnergy)
Set the energy of the shower primary particle.
void AddSimRadioPulse(const SimRadioPulse &rp)
Add a radio pulse to the RadioSimulation.
bool fhas_multiple_scattering
Status Read(evt::Event &theEvent) override
read current event advance cursor by 1
Status GotoPosition(const unsigned int pos) override
goto by position in the file
void SetPrimaryParticle(const int type)
Set the type of the shower primary particle.
void SetGroundParticleCoordinateSystemZenith(const double zenith)
Set the zenith angle of the shower. Room angle between z-axis and direction from where the shower is ...
Template class for a FADC data or calibrated data container. Use the typedefs (TraceD, TraceI, etc.) defined in Trace-fwd.h.
double multiple_scattering
double fy_core_relative_position
unsigned int fCurrentPosition
void PushBack(const T &value)
Insert a single value at the end.
#define ERROR(message)
Macro for logging error messages.
double fx_core_relative_position
constexpr double electronvolt
void Write(const evt::Event &theEvent) override