Go to the documentation of this file.    1 #ifndef IO_ASCII_INCLUDED 
    2 #define IO_ASCII_INCLUDED 
   15 #include "TDatabasePDG.h" 
   22   const char* 
const  hit_t           =  
"hit:";
 
   43   const char* 
const bx    = 
"bx";    
 
   44   const char* 
const by    = 
"by";    
 
   45   const char* 
const ichan = 
"ichan";
 
   46   const char* 
const cc    = 
"cc";
 
   69   inline bool startswith( 
const std::string& a, 
const std::string& b ) 
 
   71     if ( a.find( b ) == 0 ) 
return true;
 
   81   inline std::string 
trim(
const std::string& s)
 
   85     if ( s==
"" ) 
return s;
 
   90     for (i1=0; i1< s.length(); i1++)
 
   92         if ( !isspace (s[i1]) ) 
break;
 
   94     for (i2 = s.length()-1 ; i2 >i1 ; i2--)
 
   96         if ( !isspace (s[i2]) ) 
break;
 
   98     return s.substr( i1, i2-i1+1 );
 
  115   return TDatabasePDG::Instance()->ConvertGeant3ToPdg( 
geant3_code );  
 
  130   return TDatabasePDG::Instance()->ConvertPdgToGeant3( 
pdg_code );  
 
  143   is >> 
v.x >> 
v.y >> 
v.z;
 
  156   os << 
v.x << 
' ' << 
v.y << 
' ' << 
v.z;
 
  168 inline bool read ( 
Hit& h, std::istream& is, 
bool read_mc = 
false  )
 
  210   os << tag << 
' ' << h.
id << 
' ' << om_id << 
' ' << h.
a << 
' ' << h.
t;
 
  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());
 
  316   os << tag << 
' ' << t.
id <<
' '<< t.
pos <<
' '<< t.
dir <<
' '<< t.
E << 
' ' << t.
t;
 
  331       os << 
' ' << t.
type << endl;
 
  370   istringstream il(ss);
 
  371   for ( 
double x; il >> x ; ) 
r.push_back( x );
 
  386   vec.insert( vec.begin(), value );
 
  398 inline bool read ( 
Evt& evt, std::istream& is, 
bool skip_hits = 
false )
 
  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' );
 
  592 inline bool write( 
const Evt& evt, std::ostream& os)
 
  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");
 
 
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
 
The Evt class respresent a Monte Carlo (MC) event as well as an offline event.
 
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).
 
The Head class reflects the header of Monte-Carlo event files, which consists of keys (also referred ...
 
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
 
The Vec class is a straightforward 3-d vector, which also works in pyroot.
 
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