#include <string>
#include <istream>
#include <ostream>
#include <sstream>
#include "Evt.hh"
#include "Hit.hh"
#include "Trk.hh"
#include "Head.hh"
#include "Exception.hh"
#include "TDatabasePDG.h"
Go to the source code of this file.
|
bool | io_stringutil::startswith (const std::string &a, const std::string &b) |
| Check if string starts with given text. More...
|
|
std::string | io_stringutil::trim (const std::string &s) |
| Remove leading and trailing white spaces. More...
|
|
int | pdg_code (int geant3_code) |
| Convert Geant3 to PDG particle type. More...
|
|
int | geant3_code (int pdg_code) |
| Convert PDG to Geant3 particle type. More...
|
|
bool | read (Vec &v, std::istream &is) |
| Read a Vec(tor) from a stream. More...
|
|
bool | write (const Vec &v, std::ostream &os) |
| Write a Vec(tor) to a stream. More...
|
|
bool | read (Hit &h, std::istream &is, bool read_mc=false) |
| Read a hit from a stream. More...
|
|
bool | write (const Hit &h, std::ostream &os, const std::string &tag=mc_keys::hit_t) |
| Write a hit to a stream. More...
|
|
bool | read (Trk &t, std::istream &is, const std::string &tag=mc_keys::track_in_t) |
| Read track from a stream. More...
|
|
bool | write (const Trk &t, std::ostream &os, std::string tag=mc_keys::track_in_t) |
| Write track to a stream. More...
|
|
std::vector< double > | read_line_to_vector (std::istream &is) |
| Read data. More...
|
|
template<typename T > |
void | push_front (std::vector< T > &vec, T &value) |
| Put value in front of data. More...
|
|
bool | read (Evt &evt, std::istream &is, bool skip_hits=false) |
| Read event from a stream. More...
|
|
bool | write (const Evt &evt, std::ostream &os) |
| Write event to a stream. More...
|
|
bool | read (Head &hdr, std::istream &is) |
| Read header from a stream. More...
|
|
bool | write (const Head &hdr, std::ostream &os) |
| Write header to a stream. More...
|
|
◆ pdg_code()
int pdg_code |
( |
int |
geant3_code | ) |
|
|
inline |
Convert Geant3 to PDG particle type.
- Parameters
-
- Returns
- PDG code
Definition at line 110 of file io_ascii.hh.
115 return TDatabasePDG::Instance()->ConvertGeant3ToPdg(
geant3_code );
◆ geant3_code()
int geant3_code |
( |
int |
pdg_code | ) |
|
|
inline |
Convert PDG to Geant3 particle type.
- Parameters
-
- Returns
- Geant3 code
Definition at line 124 of file io_ascii.hh.
130 return TDatabasePDG::Instance()->ConvertPdgToGeant3(
pdg_code );
◆ read() [1/5]
bool read |
( |
Vec & |
v, |
|
|
std::istream & |
is |
|
) |
| |
|
inline |
Read a Vec(tor) from a stream.
- Parameters
-
- Returns
- true if correctly read; else false
Definition at line 141 of file io_ascii.hh.
143 is >>
v.x >>
v.y >>
v.z;
◆ write() [1/5]
bool write |
( |
const Vec & |
v, |
|
|
std::ostream & |
os |
|
) |
| |
|
inline |
Write a Vec(tor) to a stream.
- Parameters
-
- Returns
- true if correctly written; else false
Definition at line 154 of file io_ascii.hh.
156 os <<
v.x <<
' ' <<
v.y <<
' ' <<
v.z;
◆ read() [2/5]
bool read |
( |
Hit & |
h, |
|
|
std::istream & |
is, |
|
|
bool |
read_mc = false |
|
) |
| |
|
inline |
Read a hit from a stream.
- Parameters
-
h | hit |
is | input stream |
read_mc | option to read also type and origin |
- Returns
- true if correctly read; else false
Definition at line 168 of file io_ascii.hh.
◆ write() [2/5]
bool write |
( |
const Hit & |
h, |
|
|
std::ostream & |
os, |
|
|
const std::string & |
tag = mc_keys::hit_t |
|
) |
| |
|
inline |
Write a hit to a stream.
- Parameters
-
h | hit |
os | output stream |
tag | tag |
- Returns
- true if correctly written; else false
Definition at line 206 of file io_ascii.hh.
210 os << tag <<
' ' << h.
id <<
' ' << om_id <<
' ' << h.
a <<
' ' << h.
t;
◆ read() [3/5]
Read track from a stream.
- Parameters
-
t | track |
is | input stream |
tag | tag |
- Returns
- true if correctly read; else false
Definition at line 227 of file io_ascii.hh.
233 istringstream ii(line);
237 if (!ii)
return false;
245 ii >> t.
type;
if (!ii)
return false;
248 if (!ii)
return true;
252 if (!ii)
return true;
260 ii >> t.
type;
if (!ii)
return false;
287 out <<
"Error reading trk ";
291 throw Exception(static_cast<ostringstream&>(out).str());
◆ write() [3/5]
Write track to a stream.
- Parameters
-
t | track |
os | output stream |
tag | tag |
- Returns
- true if correctly read; else false
Definition at line 305 of file io_ascii.hh.
316 os << tag <<
' ' << t.
id <<
' '<< t.
pos <<
' '<< t.
dir <<
' '<< t.
E <<
' ' << t.
t;
331 os <<
' ' << t.
type << endl;
◆ read_line_to_vector()
std::vector<double> read_line_to_vector |
( |
std::istream & |
is | ) |
|
|
inline |
Read data.
- Parameters
-
- Returns
- data
Definition at line 362 of file io_ascii.hh.
370 istringstream il(ss);
371 for (
double x; il >> x ; )
r.push_back( x );
◆ push_front()
Put value in front of data.
- Parameters
-
Definition at line 384 of file io_ascii.hh.
386 vec.insert( vec.begin(), value );
◆ read() [4/5]
bool read |
( |
Evt & |
evt, |
|
|
std::istream & |
is, |
|
|
bool |
skip_hits = false |
|
) |
| |
|
inline |
Read event from a stream.
- Parameters
-
evt | event |
is | input stream |
skip_hits | option to skip reading of hits |
- Returns
- true if correctly read; else false
Definition at line 398 of file io_ascii.hh.
409 is >> evt.
mc_id >> mc_event_type;
411 Trk trk_nu, trk_primary, trk_primary_lepton;
412 bool have_trk_nu(
false), have_trk_primary(
false), have_trk_primary_lepton(
false);
430 is.ignore( 1000,
'\n' );
442 evt.
hits.push_back( h );
452 evt.
trks.push_back( t );
456 read( trk_nu ,is,
w);
461 read( trk_primary, is,
w);
462 have_trk_primary =
true;
466 read( trk_primary_lepton, is,
w);
467 have_trk_primary_lepton =
true;
524 if ( have_trk_primary_lepton )
528 double min_edif = 1e100;
531 if ( t.
type != trk_primary_lepton.
type )
continue;
535 double edif = fabs( (t.
E / trk_primary_lepton.
E) -1 );
536 if (edif < min_edif )
551 if ( have_trk_primary )
570 is.ignore( 1000,
'\n' );
◆ write() [4/5]
bool write |
( |
const Evt & |
evt, |
|
|
std::ostream & |
os |
|
) |
| |
|
inline |
Write event to a stream.
- Parameters
-
- Returns
- true if correctly read; else false
Definition at line 592 of file io_ascii.hh.
◆ read() [5/5]
bool read |
( |
Head & |
hdr, |
|
|
std::istream & |
is |
|
) |
| |
|
inline |
Read header from a stream.
The stream may be positioned at any point before the tag mc_keys::start_run_t, which marks the beginning of the header. Information before the header (if any) is disgarded.
- Parameters
-
- Returns
- true if correctly read; else false
Definition at line 624 of file io_ascii.hh.
650 if (!start)
continue;
655 THROW(
Exception,
"Invalid line found when reading header at " << line);
661 for (
int i=1; hdr.find(key) != hdr.end() ; i++)
671 THROW(
Exception,
"Reading of MC header terminated before finding a start_run: tag. Please check your file");
◆ write() [5/5]
bool write |
( |
const Head & |
hdr, |
|
|
std::ostream & |
os |
|
) |
| |
|
inline |
Write header to a stream.
- Parameters
-
hdr | header |
os | output stream |
- Returns
- true if correctly written; else false
Definition at line 685 of file io_ascii.hh.
std::vector< Hit > hits
list of hits
const char *const track_primary_t
const char *const end_event_t
void clearusr()
Clear user data.
double pure_t
photon time before pmt simultion (MC only)
const char *const track_t
const char *const muon_decay_y
int origin
track id of the track that created this hit
std::vector< Trk > mc_trks
MC: list of MC truth tracks
std::vector< double > read_line_to_vector(std::istream &is)
Read data.
const char *const track_fit_t
const char *const energy_lost_in_can
bool startswith(const std::string &a, const std::string &b)
Check if string starts with given text.
int pmt_id
global PMT identifier as found in evt files
const char *const start_event_t
const char *const weights_t
const char *const center_on_can_y
double E
Energy (either MC truth or reconstructed)
The Trk class represents a Monte Carlo (MC) particle as well as a reconstructed track/shower.
const char *const muon_decay_x
std::string comment
use as you like
double t
track time (when the particle is at pos )
bool write(const Vec &v, std::ostream &os)
Write a Vec(tor) to a stream.
const char *const neutrino_t
const char *const w3list_t
const char *const muon_decay_t
int mc_id
identifier of the MC event (as found in ascii or antcc file).
double a
hit amplitude (in p.e.)
void push_front(std::vector< T > &vec, T &value)
Put value in front of data.
double len
length, if applicable
double t
hit time (from calibration or MC truth)
const char *const start_run_t
std::vector< std::string > splitstring(const std::string &str, char delim=' ')
Split string into separate tokens.
int dom_id
module identifier from the data (unique in the detector).
void setusr(const std::string &key, double value)
Set user data item with given key.
bool haveusr(const std::string &key) const
Check availability of user data of the item with given key.
double pure_a
amptitude before pmt simution (MC only)
const char *const center_on_can_x
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
const char *const hourangle_t
static std::ostream & getOstream()
Get output stream for conversion of exception.
void print(std::ostream &out=std::cout) const
Print header.
int type
MC: particle type in PDG encoding.
const char *const hourangle
void print(std::ostream &out) const
Print track.
bool read(Vec &v, std::istream &is)
Read a Vec(tor) from a stream.
std::string to_string(const T &value)
Convert value to string.
Vec pos
postion of the track at time t
double getusr(const std::string &key) const
Get user data item with given key.
const char *const primarylepton_t
std::string trim(const std::string &s)
Remove leading and trailing white spaces.
const char *const center_on_can_t
int id
offline event identifier
int pdg_code(int geant3_code)
Convert Geant3 to PDG particle type.
std::vector< Trk > trks
list of reconstructed tracks (can be several because of prefits,showers, etc).
std::vector< Hit > mc_hits
MC: list of MC truth hits.
int geant3_code(int pdg_code)
Convert PDG to Geant3 particle type.
const char *const center_on_can_z
std::vector< double > w
MC: Weights w[0]=w1, w[1]=w2, w[2]]=w3 (see e.g. Tag list)
std::istream & getline(std::istream &in, JString &object)
Read string from input stream until end of line.
unsigned int channel_id
PMT channel id {0,1, .., 31} local to moduke.
const char *const hit_raw_t
int type
particle type or parametrisation used for hit (mc only)
const char *const muon_decay_z
std::vector< double > w2list
MC: factors that make up w[1]=w2 (see e.g. Tag list)
const char *const track_in_t
std::vector< double > w3list
MC: atmospheric flux information.
const char *const w2list_t