The Head class reflects the header of Monte-Carlo event files, which consists of keys (also referred to as "tags") and values.
More...
#include <Head.hh>
|
bool | have_line (std::string key) const |
| Check availability of data with the given key. More...
|
|
const std::string & | get_line (std::string key) const |
| Get data with the given key. More...
|
|
std::string & | get_line (std::string key) |
| Get data with the given key. More...
|
|
void | set_line (std::string key, std::string line) |
| Set data with the given key. More...
|
|
std::string | get_field (std::string key, int idx) const |
| Get data with the given key at given index. More...
|
|
int | get_index_of_field (std::string key, std::string field) const |
| Get index of data with the given key at given field. More...
|
|
std::string | get_field (std::string key, std::string field) const |
| Get data with the given key at given field. More...
|
|
void | set_field (std::string key, std::string field, std::string value) |
| Set data with the given key at given field. More...
|
|
void | print (std::ostream &out=std::cout) const |
| Print header. More...
|
|
double | ngen () const |
| Get the number of generated events needed for computing event rates. More...
|
|
double | daq_livetime () const |
| Get the the live time provided by the DAQ sytstem (=number of processed timeslices * frametime). More...
|
|
double | mc_livetime () const |
| Get the Monte Carlo live time. More...
|
|
Vec | coord_origin () const |
| Get coordinate origin. More...
|
|
Vec | translate () const |
| Get coordinate translation. More...
|
|
virtual | ~Head () |
|
| ClassDef (Head, 2) |
|
The Head class reflects the header of Monte-Carlo event files, which consists of keys (also referred to as "tags") and values.
Definition at line 66 of file Head.hh.
bool Head::have_line |
( |
std::string |
key | ) |
const |
|
inline |
Check availability of data with the given key.
- Parameters
-
- Returns
- true if data are available; else false
Definition at line 75 of file Head.hh.
77 return count( key ) != 0;
const std::string& Head::get_line |
( |
std::string |
key | ) |
const |
|
inline |
Get data with the given key.
This method throws a run-time exception if no data are available.
- Parameters
-
- Returns
- data
Definition at line 87 of file Head.hh.
std::string& Head::get_line |
( |
std::string |
key | ) |
|
|
inline |
Get data with the given key.
This method throws a run-time exception if no data are available.
- Parameters
-
- Returns
- data
Definition at line 99 of file Head.hh.
101 return this->at(key);
void Head::set_line |
( |
std::string |
key, |
|
|
std::string |
line |
|
) |
| |
|
inline |
Set data with the given key.
- Parameters
-
Definition at line 110 of file Head.hh.
std::string Head::get_field |
( |
std::string |
key, |
|
|
int |
idx |
|
) |
| const |
|
inline |
Get data with the given key at given index.
This method throws a run-time exception if no data are available.
- Parameters
-
- Returns
- data
Definition at line 123 of file Head.hh.
129 if ( idx < 0 || idx >
int (
v.size() ) )
131 THROW(
Exception,
"Cannot find word number " << idx <<
" in line " <<
get_line(key) <<
" for key: " << key);
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
const std::string & get_line(std::string key) const
Get data with the given key.
std::vector< std::string > splitstring(const std::string &str, char delim= ' ')
Split string at delimiter.
int Head::get_index_of_field |
( |
std::string |
key, |
|
|
std::string |
field |
|
) |
| const |
|
inline |
Get index of data with the given key at given field.
Note that this method uses the dictionary define in method Head::_hdr_dict.
- Parameters
-
- Returns
- index (-1 if not present)
Definition at line 145 of file Head.hh.
148 auto i = std::find (
v.begin(),
v.end(), field );
149 if (i==
v.end())
return -1;
150 return i -
v.begin();
static std::map< std::string, std::vector< std::string > > & _hdr_dict()
Get internal description of the known lines in header.
std::string Head::get_field |
( |
std::string |
key, |
|
|
std::string |
field |
|
) |
| const |
|
inline |
Get data with the given key at given field.
This method throws a run-time exception if no field is available.
Note that this method uses the dictionary define in method Head::_hdr_dict.
- Parameters
-
- Returns
- data
Definition at line 163 of file Head.hh.
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
int get_index_of_field(std::string key, std::string field) const
Get index of data with the given key at given field.
std::string get_field(std::string key, int idx) const
Get data with the given key at given index.
void Head::set_field |
( |
std::string |
key, |
|
|
std::string |
field, |
|
|
std::string |
value |
|
) |
| |
|
inline |
Set data with the given key at given field.
This method throws a run-time exception if no field available.
Note that this method uses the dictionary define in method Head::_hdr_dict.
- Parameters
-
key | key |
field | field |
value | vakue |
Definition at line 186 of file Head.hh.
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 <<
" ";
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
int get_index_of_field(std::string key, std::string field) const
Get index of data with the given key at given field.
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.
std::vector< std::string > splitstring(const std::string &str, char delim= ' ')
Split string at delimiter.
void Head::print |
( |
std::ostream & |
out = std::cout | ) |
const |
|
inline |
Print header.
- Parameters
-
Definition at line 221 of file Head.hh.
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;
Get internal description of the known lines in header.
- Returns
- internal dictionary
Definition at line 238 of file Head.hh.
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"
std::vector< std::string > splitstring(const std::string &str, char delim= ' ')
Split string at delimiter.
double Head::ngen |
( |
| ) |
const |
|
inline |
Get the number of generated events needed for computing event rates.
- Returns
- number of events
Definition at line 288 of file Head.hh.
290 return stod (
get_field(
"genvol",
"numberOfEvents") );
std::string get_field(std::string key, int idx) const
Get data with the given key at given index.
double Head::daq_livetime |
( |
| ) |
const |
|
inline |
Get the the live time provided by the DAQ sytstem (=number of processed timeslices * frametime).
- Returns
- live time [s]
Definition at line 298 of file Head.hh.
300 return stod (
get_field(
"DAQ",
"livetime") );
std::string get_field(std::string key, int idx) const
Get data with the given key at given index.
double Head::mc_livetime |
( |
| ) |
const |
|
inline |
Get the Monte Carlo live time.
- Returns
- live time [s]
Definition at line 309 of file Head.hh.
311 return stod (
get_field(
"livetime",
"numberOfSeconds") );
std::string get_field(std::string key, int idx) const
Get data with the given key at given index.
Vec Head::coord_origin |
( |
| ) |
const |
|
inline |
Get coordinate origin.
- Returns
- position
Definition at line 319 of file Head.hh.
The Vec class is a straightforward 3-d vector, which also works in pyroot.
std::string get_field(std::string key, int idx) const
Get data with the given key at given index.
Vec Head::translate |
( |
| ) |
const |
|
inline |
Get coordinate translation.
- Returns
- translation
Definition at line 331 of file Head.hh.
The Vec class is a straightforward 3-d vector, which also works in pyroot.
std::string get_field(std::string key, int idx) const
Get data with the given key at given index.
Head::ClassDef |
( |
Head |
, |
|
|
2 |
|
|
) |
| |
The documentation for this struct was generated from the following file: