1 #ifndef HEAD_HH_INCLUDED 
    2 #define HEAD_HH_INCLUDED 
   27   s.erase( s.begin(), std::find_if(s.begin(), s.end(), [](
int ch) {
 
   28     return !std::isspace(ch);
 
   32   s.erase(std::find_if(s.rbegin(), s.rend(), [](
int ch) {
 
   33     return !std::isspace(ch);
 
   53   while (
getline(ss, token, delim))
 
   56     if (token != 
"") 
r.push_back(token);
 
   77     return count( key ) != 0;
 
   87   const std::string& 
get_line( std::string key )
 const 
  101     return this->at(key);
 
  129     if ( idx < 0 || idx >= 
int ( 
v.size() ) )
 
  131       THROW(
Exception, 
"Cannot find word number " << idx << 
" in line " << 
get_line(key) << 
" for key: " << key);
 
  148     auto i = std::find (
v.begin(), 
v.end(), field );
 
  149     if (i == 
v.end()) 
return -1;
 
  150     return i - 
v.begin();
 
  163   std::string 
get_field( std::string key, std::string field )
 const 
  186   void set_field( std::string key, std::string field, std::string value )
 
  190     if ( field == 
"" ) 
get_line( key ) = value;
 
  196       THROW(
Exception, 
"GFailed to find field in header line: " << key << 
" " << field);
 
  202     while ( 
int( vals.size() ) <= idx ) vals.push_back(
"0");
 
  207     for (
unsigned i = 0; i < vals.size() ; i++ )
 
  210       if ( i != vals.size() - 1) ss << 
" ";
 
  221   void print ( std::ostream& out = std::cout )
 const 
  223     if (
count(
"start_run")) out << 
"start_run: " << at(
"start_run") << std::endl;
 
  225     for ( 
auto& p : *
this )
 
  227       if ( p.first == 
"start_run" || p.first == 
"end_event" ) 
continue;
 
  228       out << p.first << 
": " << p.second << std::endl ;
 
  230     out << 
"end_event:" << std::endl;
 
  245     if ( 
r.size() > 0 ) 
return r;
 
  249       "cut_primary cut_seamuon cut_in cut_nu:Emin Emax cosTmin cosTmax\n" 
  250       "generator physics simul:program version date time\n" 
  251       "seed:program level iseed\n" 
  252       "PM1_type_area:type area TTS\n" 
  254       "model:interaction muon scattering numberOfEnergyBins\n" 
  256       "genvol:zmin zmax r volume numberOfEvents\n" 
  258       "coord_origin:x y z\n" 
  260       "genhencut:gDir Emin\n" 
  262       "norma:primaryFlux numberOfPrimaries\n" 
  263       "livetime:numberOfSeconds errorOfSeconds\n" 
  264       "flux:type key file_1 file_2\n" 
  266       "fixedcan:xcenter ycenter zmin zmax radius\n" 
  290     return stod ( 
get_field(
"genvol", 
"numberOfEvents") );
 
  300     return stod ( 
get_field(
"DAQ", 
"livetime") );
 
  311     return stod ( 
get_field(
"livetime", 
"numberOfSeconds") );
 
std::string & get_line(std::string key)
Get data with the given key. 
void set_field(std::string key, std::string field, std::string value)
Set data with the given key at given field. 
std::string get_field(std::string key, std::string field) const 
Get data with the given key at given field. 
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message. 
bool have_line(std::string key) const 
Check availability of data with the given key. 
double mc_livetime() const 
Get the Monte Carlo live time. 
int get_index_of_field(std::string key, std::string field) const 
Get index of data with the given key at given field. 
The Vec class is a straightforward 3-d vector, which also works in pyroot. 
void print(std::ostream &out=std::cout) const 
Print header. 
std::istream & getline(std::istream &in, JString &object)
Read string from input stream until end of line. 
static void trimstring(std::string &s)
Trim a string in place. 
The Head class reflects the header of Monte-Carlo event files, which consists of keys (also referred ...
double ngen() const 
Get the number of generated events needed for computing event rates. 
void set_line(std::string key, std::string line)
Set data with the given key. 
const std::string & get_line(std::string key) const 
Get data with the given key. 
double daq_livetime() const 
Get the the live time provided by the DAQ sytstem (=number of processed timeslices * frametime)...
std::string get_field(std::string key, int idx) const 
Get data with the given key at given index. 
Vec translate() const 
Get coordinate translation. 
std::vector< std::string > splitstring(const std::string &str, char delim= ' ')
Split string at delimiter. 
Vec coord_origin() const 
Get coordinate origin. 
static std::map< std::string, std::vector< std::string > > & _hdr_dict()
Get internal description of the known lines in header.