Go to the documentation of this file. 1 #ifndef HEAD_HH_INCLUDED
2 #define HEAD_HH_INCLUDED
31 while (
getline(ss, token, delim))
r.push_back(token);
50 return count( key ) != 0;
60 const std::string&
get_line( std::string key )
const
83 void set_line( std::string key, std::string line )
96 std::string
get_field( std::string key,
int idx )
const
102 if ( idx < 0 || idx >
int (
v.size() ) )
104 THROW(
Exception,
"Cannot find word number " << idx <<
" in line " <<
get_line(key) <<
" for key: " << key);
121 auto i = std::find (
v.begin(),
v.end(), field );
122 if (i==
v.end())
return -1;
123 return i -
v.begin();
136 std::string
get_field( std::string key, std::string field )
const
159 void set_field( std::string key, std::string field, std::string value )
163 if ( field ==
"" )
get_line( key ) = value;
169 THROW(
Exception,
"GFailed to find field in header line: " << key <<
" " << field);
175 while (
int( vals.size() ) <= idx ) vals.push_back(
"0");
192 void print ( std::ostream& out = std::cout )
const
194 if (count(
"start_run")) out<<
"start_run: " << at(
"start_run") << std::endl;
196 for(
auto& p : *
this )
198 if ( p.first ==
"start_run" || p.first ==
"end_event" )
continue;
199 out<< p.first <<
": " << p.second << std::endl ;
201 out<<
"end_event:" << std::endl;
216 if (
r.size() > 0 )
return r;
220 "cut_primary cut_seamuon cut_in cut_nu:Emin Emax cosTmin cosTmax\n"
221 "generator physics simul: program version date time\n"
222 "seed:program level iseed\n"
223 "PM1_type_area:type area TTS\n"
225 "model:interaction muon scattering numberOfEnergyBins\n"
227 "genvol:zmin zmax r volume numberOfEvents\n"
229 "coord_origin:x y z\n"
231 "genhencut:gDir Emin\n"
233 "norma:primaryFlux numberOfPrimaries\n"
234 "livetime:numberOfSeconds errorOfSeconds\n"
235 "flux:type key file_1 file_2\n"
237 "fixedcan:xcenter ycenter zmin zmax radius\n"
261 return stod (
get_field(
"genvol",
"numberOfEvents") );
271 return stod (
get_field(
"DAQ",
"livetime") );
282 return stod (
get_field(
"livetime",
"numberOfSeconds") );
static std::map< std::string, std::vector< std::string > > & _hdr_dict()
Get internal description of the known lines in header.
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.
double daq_livetime() const
Get the the live time provided by the DAQ sytstem (=number of processed timeslices * frametime).
std::vector< std::string > splitstring(const std::string &str, char delim=' ')
Split string into separate tokens.
Vec translate() const
Get coordinate translation.
The Head class reflects the header of Monte-Carlo event files, which consists of keys (also referred ...
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
void print(std::ostream &out=std::cout) const
Print header.
std::ostream & operator<<(std::ostream &out, const Head &h)
Print header.
const std::string & get_line(std::string key) const
Get data with the given key.
std::string get_field(std::string key, int idx) const
Get data with the given key at given index.
int get_index_of_field(std::string key, std::string field) const
Get index of data with the given key at given field.
Vec coord_origin() const
Get coordinate origin.
The Vec class is a straightforward 3-d vector, which also works in pyroot.
double mc_livetime() const
Get the Monte Carlo live time.
void set_line(std::string key, std::string line)
Set data with the given key.
std::istream & getline(std::istream &in, JString &object)
Read string from input stream until end of line.
std::string & get_line(std::string key)
Get data with the given key.
double ngen() const
Get the number of generated events needed for computing event rates.
bool have_line(std::string key) const
Check availability of data with the given key.