Jpp
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | Static Public Member Functions | Public Attributes | Static Private Member Functions | Friends | List of all members
JAANET::JHead Struct Reference

Monte Carlo run header. More...

#include <JHead.hh>

Inheritance diagram for JAANET::JHead:
Head TObject std::map< std::string, std::string > JAANET::JWeightEventHelper JSUPPORT::JWeightFileScanner< JFileScanner_t >

Public Member Functions

 JHead ()
 Default constructor. More...
 
 JHead (const Head &header)
 Copy constructor. More...
 
virtual ~JHead ()
 Virtual destructor. More...
 
const JHeadgetHeader () const
 Get header. More...
 
JHeadgetHeader ()
 Get header. More...
 
void setHeader (const JHead &header)
 Set header. More...
 
template<class T >
bool is_valid (T JHead::*pd) const
 Check validity of given data member in JHead. More...
 
template<class T >
const_iterator pull (T JHead::*pd) const
 Pull given data member from Head. More...
 
template<class T >
iterator pull (T JHead::*pd)
 Pull given data member from Head. More...
 
template<class T >
void push (T JHead::*pd)
 Push given data member to Head. More...
 
template<class T >
void erase (T JHead::*pd)
 Remove given data member from Head. More...
 
bool match (const JHead &header) const
 Test match of headers. More...
 
bool less (const JHead &header) const
 Comparison of headers. More...
 
JHeadadd (const JHead &header)
 Addition of headers. More...
 
std::istream & read (std::istream &in)
 Read header from input. More...
 
std::ostream & write (std::ostream &out) const
 Write header to output. More...
 
std::ostream & print (std::ostream &out) const
 Print header to output. More...
 
 ClassDef (JHead, 3)
 
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...
 
std::string get_field (std::string key, std::string field) const
 Get data with the given key at given field. 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...
 
void set_field (std::string key, std::string field, std::string value)
 Set data with the given key at given field. 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...
 
 ClassDef (Head, 2)
 

Static Public Member Functions

template<class T >
static bool is_valid (const T &object)
 Check validity of given data member in JHead. More...
 
static JLANG::JEquationParametersgetEquationParameters ()
 Get equation parameters corresponding to Monte Carlo ASCII format, i.e: More...
 
static void setEquationParameters (const JLANG::JEquationParameters &equation)
 Set equation parameters. More...
 
static std::map< std::string,
std::vector< std::string > > & 
_hdr_dict ()
 Get internal description of the known lines in header. More...
 

Public Attributes

JAANET::start_run start_run
 
JAANET::XSecFile XSecFile
 
JAANET::drawing drawing
 
std::vector< JAANET::detectordetector
 
JAANET::muon_desc_file muon_desc_file
 
JAANET::target target
 
std::vector< JAANET::physicsphysics
 
std::vector< JAANET::simulsimul
 
JAANET::cut_primary cut_primary
 
JAANET::cut_seamuon cut_seamuon
 
JAANET::cut_in cut_in
 
JAANET::cut_nu cut_nu
 
JAANET::spectrum spectrum
 
JAANET::can can
 
JAANET::fixedcan fixedcan
 
JAANET::genvol genvol
 
JAANET::coord_origin coord_origin
 
JAANET::genhencut genhencut
 
JAANET::norma norma
 
JAANET::livetime livetime
 
JAANET::seabottom seabottom
 
JAANET::depth depth
 
JAANET::DAQ DAQ
 
JAANET::tgen tgen
 
JAANET::primary primary
 
JAANET::end_event end_event
 

Static Private Member Functions

template<class T >
static bool less (const T &first, const T &second)
 Comparison. More...
 
template<class T >
static bool match (const T &first, const T &second)
 Test match. More...
 
template<class T >
static bool less (const std::vector< T > &first, const std::vector< T > &second)
 Comparison of containers. More...
 
template<class T >
static bool match (const std::vector< T > &first, const std::vector< T > &second)
 Test is containers match. More...
 
template<class T >
static bool match (const JHead &first, const JHead &second, T JHead::*pd)
 Test match of given data member of headers. More...
 

Friends

bool operator== (const JHead &first, const JHead &second)
 Equal operator. More...
 
bool operator< (const JHead &first, const JHead &second)
 Less than operator. More...
 

Detailed Description

Monte Carlo run header.

This class extends the Head class so that the data from specific tags can be promoted to concrete data types.

Note that for the copy of new JHead data (e.g. data not obtained via a previous JAANET::copy) to become effective, the key words in the corresponding map of the Head class should be set.
To this end, member method JHead::push can be used.

Definition at line 1050 of file JHead.hh.

Constructor & Destructor Documentation

JAANET::JHead::JHead ( )
inline

Default constructor.

Definition at line 1056 of file JHead.hh.

1057  {}
JAANET::JHead::JHead ( const Head header)
inline

Copy constructor.

Parameters
headerheader

Definition at line 1065 of file JHead.hh.

1066  {
1067  copy(header, *this);
1068  }
void copy(const Head &from, JHead &to)
Copy header from from to to.
Definition: JHead.cc:139
virtual JAANET::JHead::~JHead ( )
inlinevirtual

Virtual destructor.

Definition at line 1074 of file JHead.hh.

1075  {}

Member Function Documentation

const JHead& JAANET::JHead::getHeader ( ) const
inline

Get header.

Returns
header

Definition at line 1083 of file JHead.hh.

1084  {
1085  return static_cast<const JHead&>(*this);
1086  }
Monte Carlo run header.
Definition: JHead.hh:1050
JHead& JAANET::JHead::getHeader ( )
inline

Get header.

Returns
header

Definition at line 1094 of file JHead.hh.

1095  {
1096  return static_cast<JHead&>(*this);
1097  }
Monte Carlo run header.
Definition: JHead.hh:1050
void JAANET::JHead::setHeader ( const JHead header)
inline

Set header.

Parameters
headerheader

Definition at line 1105 of file JHead.hh.

1106  {
1107  static_cast<JHead&>(*this) = header;
1108  }
Monte Carlo run header.
Definition: JHead.hh:1050
template<class T >
bool JAANET::JHead::is_valid ( T JHead::*  pd) const
inline

Check validity of given data member in JHead.

The validity is defined by the presence of the name of the data member in the underlying map.

Parameters
pdpointer to data member
Returns
true if valid; else false

Definition at line 1120 of file JHead.hh.

1121  {
1122  return (this->pull(pd) != this->end());
1123  }
const_iterator pull(T JHead::*pd) const
Pull given data member from Head.
Definition: JHead.hh:1150
template<class T >
static bool JAANET::JHead::is_valid ( const T object)
inlinestatic

Check validity of given data member in JHead.

The validity is defined by difference between actual and default value.

Parameters
objectobject
Returns
true if valid; else false

Definition at line 1135 of file JHead.hh.

1136  {
1137  static const T value;
1138 
1139  return (object.less(value) || value.less(object));
1140  }
bool less(const JHead &header) const
Comparison of headers.
Definition: JHead.hh:1235
do set_variable OUTPUT_DIRECTORY $WORKDIR T
template<class T >
const_iterator JAANET::JHead::pull ( T JHead::*  pd) const
inline

Pull given data member from Head.

Parameters
pdpointer to data member
Returns
iterator of Head

Definition at line 1150 of file JHead.hh.

1151  {
1152  return this->find(JROOT::getDataMember(pd)->GetName());
1153  }
const TDataMember * getDataMember(const JRootClass &parent, const JRootClass &member)
Get ROOT data member for given parent and member class.
Definition: JRootClass.hh:636
template<class T >
iterator JAANET::JHead::pull ( T JHead::*  pd)
inline

Pull given data member from Head.

Parameters
pdpointer to data member
Returns
iterator of Head

Definition at line 1163 of file JHead.hh.

1164  {
1165  return this->find(JROOT::getDataMember(pd)->GetName());
1166  }
const TDataMember * getDataMember(const JRootClass &parent, const JRootClass &member)
Get ROOT data member for given parent and member class.
Definition: JRootClass.hh:636
template<class T >
void JAANET::JHead::push ( T JHead::*  pd)
inline

Push given data member to Head.

Parameters
pdpointer to data member

Definition at line 1175 of file JHead.hh.

1176  {
1177  (*this)[JROOT::getDataMember(pd)->GetName()] = "";
1178  }
const TDataMember * getDataMember(const JRootClass &parent, const JRootClass &member)
Get ROOT data member for given parent and member class.
Definition: JRootClass.hh:636
template<class T >
void JAANET::JHead::erase ( T JHead::*  pd)
inline

Remove given data member from Head.

Parameters
pdpointer to data member

Definition at line 1187 of file JHead.hh.

1188  {
1189  iterator p = this->pull(pd);
1190 
1191  if (p != this->end()) {
1192 
1193  this->*pd = T();
1194 
1195  static_cast<Head*>(this)->erase(p);
1196  }
1197  }
void erase(T JHead::*pd)
Remove given data member from Head.
Definition: JHead.hh:1187
do set_variable OUTPUT_DIRECTORY $WORKDIR T
The Head class reflects the header of Monte-Carlo event files, which consists of keys (also referred ...
Definition: Head.hh:66
const_iterator pull(T JHead::*pd) const
Pull given data member from Head.
Definition: JHead.hh:1150
bool JAANET::JHead::match ( const JHead header) const
inline

Test match of headers.

Parameters
headersecond header
Returns
true if matches; else false

Definition at line 1206 of file JHead.hh.

1207  {
1208  return (match(*this, header, &JHead::cut_primary) &&
1209  match(*this, header, &JHead::cut_seamuon) &&
1210  match(*this, header, &JHead::cut_in) &&
1211  match(*this, header, &JHead::cut_nu) &&
1212  match(*this, header, &JHead::detector) &&
1213  match(*this, header, &JHead::physics) &&
1214  match(*this, header, &JHead::simul) &&
1215  match(*this, header, &JHead::spectrum) &&
1216  match(*this, header, &JHead::can) &&
1217  match(*this, header, &JHead::fixedcan) &&
1218  match(*this, header, &JHead::genvol) &&
1219  match(*this, header, &JHead::coord_origin) &&
1220  match(*this, header, &JHead::norma) &&
1221  match(*this, header, &JHead::livetime) &&
1222  match(*this, header, &JHead::seabottom) &&
1223  match(*this, header, &JHead::depth) &&
1224  match(*this, header, &JHead::primary) &&
1225  match(*this, header, &JHead::DAQ));
1226  }
JAANET::depth depth
Definition: JHead.hh:1347
JAANET::genvol genvol
Definition: JHead.hh:1341
JAANET::norma norma
Definition: JHead.hh:1344
JAANET::cut_primary cut_primary
Definition: JHead.hh:1334
std::vector< JAANET::physics > physics
Definition: JHead.hh:1332
bool match(const JHead &header) const
Test match of headers.
Definition: JHead.hh:1206
std::vector< JAANET::simul > simul
Definition: JHead.hh:1333
JAANET::fixedcan fixedcan
Definition: JHead.hh:1340
JAANET::can can
Definition: JHead.hh:1339
JAANET::cut_seamuon cut_seamuon
Definition: JHead.hh:1335
JAANET::livetime livetime
Definition: JHead.hh:1345
JAANET::seabottom seabottom
Definition: JHead.hh:1346
JAANET::spectrum spectrum
Definition: JHead.hh:1338
JAANET::primary primary
Definition: JHead.hh:1350
std::vector< JAANET::detector > detector
Definition: JHead.hh:1329
JAANET::cut_in cut_in
Definition: JHead.hh:1336
JAANET::cut_nu cut_nu
Definition: JHead.hh:1337
JAANET::DAQ DAQ
Definition: JHead.hh:1348
Vec coord_origin() const
Get coordinate origin.
Definition: Head.hh:319
bool JAANET::JHead::less ( const JHead header) const
inline

Comparison of headers.

Parameters
headerheader
Returns
true if this header less than given header; else false

Definition at line 1235 of file JHead.hh.

1236  {
1237 #define RETURN_IF_DIFFERENT(A, B) \
1238  if (less(A,B)) { return true; } \
1239  if (less(B,A)) { return false; }
1240 
1241  // compare physics
1242 
1243  RETURN_IF_DIFFERENT(this->physics, header.physics);
1244 
1245  // compare simulation
1246 
1247  RETURN_IF_DIFFERENT(this->simul, header.simul);
1248 
1249  // compare generation data
1250 
1251  RETURN_IF_DIFFERENT(this->primary, header.primary);
1252  RETURN_IF_DIFFERENT(this->spectrum, header.spectrum);
1255  RETURN_IF_DIFFERENT(this->cut_in, header.cut_in);
1256  RETURN_IF_DIFFERENT(this->cut_nu, header.cut_nu);
1257  RETURN_IF_DIFFERENT(this->genvol, header.genvol);
1258 
1259  // compare compatibility
1260 
1261  if (is_valid(this->livetime) == is_valid(header.livetime) &&
1262  is_valid(this->DAQ) == is_valid(header.DAQ)) {
1263  return false;
1264  }
1265 
1266  THROW(JException, "JHead::less() headers do not compare.");
1267 
1268 #undef RETURN_IF_DIFFERENT
1269  }
Phase space of incident neutrino.
Definition: JHead.hh:393
JAANET::genvol genvol
Definition: JHead.hh:1341
Neutrino vertex volume.
Definition: JHead.hh:583
Livetime of DAQ data.
Definition: JHead.hh:919
#define RETURN_IF_DIFFERENT(A, B)
Phase space of incoming particle.
Definition: JHead.hh:383
Generator for simulation.
Definition: JHead.hh:460
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
Definition: JException.hh:670
JAANET::cut_primary cut_primary
Definition: JHead.hh:1334
std::vector< JAANET::physics > physics
Definition: JHead.hh:1332
std::vector< JAANET::simul > simul
Definition: JHead.hh:1333
Physics information.
Definition: JHead.hh:450
JAANET::cut_seamuon cut_seamuon
Definition: JHead.hh:1335
JAANET::livetime livetime
Definition: JHead.hh:1345
JAANET::spectrum spectrum
Definition: JHead.hh:1338
JAANET::primary primary
Definition: JHead.hh:1350
Normalisation of MUPAGE events.
Definition: JHead.hh:768
JAANET::cut_in cut_in
Definition: JHead.hh:1336
Primary particle.
Definition: JHead.hh:990
JAANET::cut_nu cut_nu
Definition: JHead.hh:1337
Phase space of atmospheric muon generation.
Definition: JHead.hh:373
Phase space of primary particle.
Definition: JHead.hh:363
bool is_valid(T JHead::*pd) const
Check validity of given data member in JHead.
Definition: JHead.hh:1120
JAANET::DAQ DAQ
Definition: JHead.hh:1348
Neutrino energy spectrum.
Definition: JHead.hh:470
JHead& JAANET::JHead::add ( const JHead header)
inline

Addition of headers.

Parameters
headerheader
Returns
this header

Definition at line 1278 of file JHead.hh.

1279  {
1280  if (match(header)) {
1281 
1282  genvol .add(header.genvol);
1283  norma .add(header.norma);
1284  livetime.add(header.livetime);
1285  DAQ .add(header.DAQ);
1286 
1287  } else {
1288 
1289  THROW(JException, "JHead::add() headers do not match.");
1290  }
1291 
1292  return *this;
1293  }
norma & add(const norma &object)
Addition.
Definition: JHead.hh:751
JAANET::genvol genvol
Definition: JHead.hh:1341
Neutrino vertex volume.
Definition: JHead.hh:583
JAANET::norma norma
Definition: JHead.hh:1344
Livetime of DAQ data.
Definition: JHead.hh:919
livetime & add(const livetime &object)
Addition.
Definition: JHead.hh:806
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
Definition: JException.hh:670
Normlisation of CORSIKA events.
Definition: JHead.hh:725
bool match(const JHead &header) const
Test match of headers.
Definition: JHead.hh:1206
DAQ & add(const DAQ &object)
Addition.
Definition: JHead.hh:957
genvol & add(const genvol &object)
Addition.
Definition: JHead.hh:625
JAANET::livetime livetime
Definition: JHead.hh:1345
Normalisation of MUPAGE events.
Definition: JHead.hh:768
JAANET::DAQ DAQ
Definition: JHead.hh:1348
static JLANG::JEquationParameters& JAANET::JHead::getEquationParameters ( )
inlinestatic

Get equation parameters corresponding to Monte Carlo ASCII format, i.e:

   <key>: <value> [<value>]*
   <key>: <value> [<value>]*
Returns
equation parameters

Definition at line 1363 of file JHead.hh.

1364  {
1365  static JLANG::JEquationParameters parameters(":", "\n", "", "");
1366 
1367  return parameters;
1368  }
*fatal Wrong number of arguments esac JCookie sh typeset Z DETECTOR typeset Z SOURCE_RUN typeset Z TARGET_RUN set_variable PARAMETERS_FILE $WORKDIR parameters
Definition: diff-Tuna.sh:38
Simple data structure to support I/O of equations (see class JLANG::JEquation).
static void JAANET::JHead::setEquationParameters ( const JLANG::JEquationParameters equation)
inlinestatic

Set equation parameters.

Parameters
equationequation parameters

Definition at line 1376 of file JHead.hh.

1377  {
1378  getEquationParameters() = equation;
1379  }
static JLANG::JEquationParameters & getEquationParameters()
Get equation parameters corresponding to Monte Carlo ASCII format, i.e:
Definition: JHead.hh:1363
std::istream & JAANET::JHead::read ( std::istream &  in)

Read header from input.

Parameters
ininput stream
Returns
input stream

Definition at line 30 of file JHead.cc.

31  {
32  using namespace std;
33  using namespace JPP;
34 
35  JStringStream is(in);
36 
37  if (getFileStatus(is.str().c_str())) {
38  is.load();
39  }
40 
42 
43  JRootReadableClass cls(*this);
44 
45  for (JEquation equation; reader >> equation && equation.getKey() != end_event::Class_Name(); ) {
46 
47  JRedirectString redirect(reader, equation.getValue());
48 
49  const JRootReadableClass abc = cls.find(equation.getKey().c_str());
50 
51  if (abc.is_valid()) {
52  reader.getObject(abc);
53  }
54 
55  (*this)[equation.getKey()] = equation.getValue();
56  }
57 
58  return in;
59  }
is
Definition: JDAQCHSM.chsm:167
T & getInstance(const T &object)
Get static instance from temporary object.
Definition: JObject.hh:75
static JLANG::JEquationParameters & getEquationParameters()
Get equation parameters corresponding to Monte Carlo ASCII format, i.e:
Definition: JHead.hh:1363
static JStat getFileStatus
Function object for file status.
Definition: JStat.hh:173
then fatal Wrong number of arguments fi set_variable DETECTOR $argv[1] set_variable INPUT_FILE $argv[2] eval JPrintDetector a $DETECTOR O IDENTIFIER eval JPrintDetector a $DETECTOR O SUMMARY source JAcoustics sh $DETECTOR_ID typeset A TRIPODS get_tripods $WORKDIR tripod txt TRIPODS for EMITTER in
Definition: JCanberra.sh:36
std::ostream & JAANET::JHead::write ( std::ostream &  out) const

Write header to output.

Parameters
outoutput stream
Returns
output stream

Definition at line 68 of file JHead.cc.

69  {
70  using namespace std;
71  using namespace JPP;
72 
73  JRootWriter writer(out, JHead::getEquationParameters(), JAAnetDictionary::getInstance());
74 
75  JRootWritableClass cls(*this);
76 
77  TIterator* i = cls.getClass()->GetListOfDataMembers()->MakeIterator();
78 
79  for (const TDataMember* p; (p = (const TDataMember*) i->Next()) != NULL; ) {
80  if (!JRootClass::is_static(*p)) {
81  if (this->find(p->GetName()) != this->end() ||
82  cls.get(*p) == JRootClass(&JHead::start_run) ||
83  cls.get(*p) == JRootClass(&JHead::end_event)) {
84  writer.put(p->GetName(), cls.get(*p), true);
85  }
86  }
87  }
88 
89  return out << flush;
90  }
JAANET::end_event end_event
Definition: JHead.hh:1351
T & getInstance(const T &object)
Get static instance from temporary object.
Definition: JObject.hh:75
static JLANG::JEquationParameters & getEquationParameters()
Get equation parameters corresponding to Monte Carlo ASCII format, i.e:
Definition: JHead.hh:1363
JAANET::start_run start_run
Definition: JHead.hh:1326
std::ostream & JAANET::JHead::print ( std::ostream &  out) const

Print header to output.

Parameters
outoutput stream
Returns
output stream

Definition at line 99 of file JHead.cc.

100  {
101  using namespace std;
102  using namespace JPP;
103 
104  JRootWriter writer(out, JHead::getEquationParameters(), JAAnetDictionary::getInstance());
105 
106  JRootWritableClass cls(*this);
107 
108  TIterator* i = cls.getClass()->GetListOfDataMembers()->MakeIterator();
109 
111 
112  for (const TDataMember* p; (p = (const TDataMember*) i->Next()) != NULL; ) {
113  if (!JRootClass::is_static(*p)) {
114  if (cls.get(*p) != JRootClass(&JHead::end_event))
115  writer.put(p->GetName(), cls.get(*p), true);
116  else
117  end_event = make_pair(p->GetName(), cls.get(*p));
118  }
119  }
120 
121  for (JHead::const_iterator i = this->begin(); i != this->end(); ++i) {
122  if (!cls.find(i->first.c_str()).is_valid()) {
123  writer.put(i->first, i->second);
124  }
125  }
126 
127  writer.put(end_event.first, end_event.second, true);
128 
129  return out << flush;
130  }
JAANET::end_event end_event
Definition: JHead.hh:1351
T & getInstance(const T &object)
Get static instance from temporary object.
Definition: JObject.hh:75
static JLANG::JEquationParameters & getEquationParameters()
Get equation parameters corresponding to Monte Carlo ASCII format, i.e:
Definition: JHead.hh:1363
bool is_valid(T JHead::*pd) const
Check validity of given data member in JHead.
Definition: JHead.hh:1120
JAANET::JHead::ClassDef ( JHead  ,
 
)
template<class T >
static bool JAANET::JHead::less ( const T first,
const T second 
)
inlinestaticprivate

Comparison.

Parameters
firstfirst object
secondsecond object
Returns
true if first less than second; else false

Definition at line 1420 of file JHead.hh.

1422  {
1423  return first.less(second);
1424  }
then echo The file $DIR KM3NeT_00000001_00000000 root already please rename or remove it first
template<class T >
static bool JAANET::JHead::match ( const T first,
const T second 
)
inlinestaticprivate

Test match.

Parameters
firstfirst object
secondsecond object
Returns
true if matches; else false

Definition at line 1435 of file JHead.hh.

1437  {
1438  return first.match(second);
1439  }
then echo The file $DIR KM3NeT_00000001_00000000 root already please rename or remove it first
template<class T >
static bool JAANET::JHead::less ( const std::vector< T > &  first,
const std::vector< T > &  second 
)
inlinestaticprivate

Comparison of containers.

It is assumed that the containers are ordered in the same way.

Parameters
firstfirst object
secondsecond object
Returns
true if first is less than second; else false

Definition at line 1451 of file JHead.hh.

1453  {
1454  if (first.size() == second.size()) {
1455 
1456  for (size_t i = 0; i != first.size(); ++i) {
1457  if (less(first[i], second[i])) {
1458  return true;
1459  }
1460  }
1461 
1462  return false;
1463 
1464  } else {
1465 
1466  return first.size() < second.size();
1467  }
1468  }
bool less(const JHead &header) const
Comparison of headers.
Definition: JHead.hh:1235
template<class T >
static bool JAANET::JHead::match ( const std::vector< T > &  first,
const std::vector< T > &  second 
)
inlinestaticprivate

Test is containers match.

It is assumed that the containers are ordered in the same way.

Parameters
firstfirst object
secondsecond object
Returns
true if matches; else false

Definition at line 1480 of file JHead.hh.

1482  {
1483  for (size_t i = 0; i != first.size() && i != second.size(); ++i) {
1484  if (!match(first[i], second[i])) {
1485  return false;
1486  }
1487  }
1488 
1489  return first.size() == second.size();
1490  }
bool match(const JHead &header) const
Test match of headers.
Definition: JHead.hh:1206
template<class T >
static bool JAANET::JHead::match ( const JHead first,
const JHead second,
T JHead::*  pd 
)
inlinestaticprivate

Test match of given data member of headers.

Parameters
firstfirst header
secondsecond header
pdpointer to data member
Returns
true if matches; else false

Definition at line 1502 of file JHead.hh.

1505  {
1506  return match(first.*pd, second.*pd);
1507  }
bool match(const JHead &header) const
Test match of headers.
Definition: JHead.hh:1206
bool Head::have_line ( std::string  key) const
inlineinherited

Check availability of data with the given key.

Parameters
keykey
Returns
true if data are available; else false

Definition at line 75 of file Head.hh.

76  {
77  return count( key ) != 0;
78  }
std::vector< int > count
Definition: JAlgorithm.hh:184
const std::string& Head::get_line ( std::string  key) const
inlineinherited

Get data with the given key.


This method throws a run-time exception if no data are available.

Parameters
keykey
Returns
data

Definition at line 87 of file Head.hh.

88  {
89  return this->at(key);
90  }
std::string& Head::get_line ( std::string  key)
inlineinherited

Get data with the given key.


This method throws a run-time exception if no data are available.

Parameters
keykey
Returns
data

Definition at line 99 of file Head.hh.

100  {
101  return this->at(key);
102  }
void Head::set_line ( std::string  key,
std::string  line 
)
inlineinherited

Set data with the given key.

Parameters
keykey
linedata

Definition at line 110 of file Head.hh.

111  {
113  }
std::string Head::get_field ( std::string  key,
int  idx 
) const
inlineinherited

Get data with the given key at given index.


This method throws a run-time exception if no data are available.

Parameters
keykey
idxindex
Returns
data

Definition at line 123 of file Head.hh.

124  {
125  using namespace std;
126 
128 
129  if ( idx < 0 || idx >= int ( v.size() ) )
130  {
131  THROW(Exception, "Cannot find word number " << idx << " in line " << get_line(key) << " for key: " << key);
132  }
133  return v[idx];
134  }
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
Definition: JException.hh:670
General exception.
Definition: Exception.hh:13
const std::string & get_line(std::string key) const
Get data with the given key.
Definition: Head.hh:87
data_type v[N+1][M+1]
Definition: JPolint.hh:740
std::vector< std::string > splitstring(const std::string &str, char delim= ' ')
Split string at delimiter.
Definition: Head.hh:45
std::string Head::get_field ( std::string  key,
std::string  field 
) const
inlineinherited

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
keykey
fieldfield
Returns
data

Definition at line 163 of file Head.hh.

164  {
165  int idx = get_index_of_field(key, field);
166 
167  if ( idx == -1 )
168  {
169  THROW(Exception, "Failed to find" << key << " " << field);
170  }
171 
172  return get_field( key, idx );
173  }
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
Definition: JException.hh:670
int get_index_of_field(std::string key, std::string field) const
Get index of data with the given key at given field.
Definition: Head.hh:145
General exception.
Definition: Exception.hh:13
std::string get_field(std::string key, int idx) const
Get data with the given key at given index.
Definition: Head.hh:123
int Head::get_index_of_field ( std::string  key,
std::string  field 
) const
inlineinherited

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
keykey
fieldfield
Returns
index (-1 if not present)

Definition at line 145 of file Head.hh.

146  {
147  auto v = _hdr_dict()[key];
148  auto i = std::find (v.begin(), v.end(), field );
149  if (i == v.end()) return -1;
150  return i - v.begin();
151  }
data_type v[N+1][M+1]
Definition: JPolint.hh:740
static std::map< std::string, std::vector< std::string > > & _hdr_dict()
Get internal description of the known lines in header.
Definition: Head.hh:238
void Head::set_field ( std::string  key,
std::string  field,
std::string  value 
)
inlineinherited

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
keykey
fieldfield
valuevakue

Definition at line 186 of file Head.hh.

187  {
188  using namespace std;
189 
190  if ( field == "" ) get_line( key ) = value;
191 
192  int idx = get_index_of_field( key, field );
193 
194  if ( idx < 0 )
195  {
196  THROW(Exception, "GFailed to find field in header line: " << key << " " << field);
197  }
198 
199  vector<string> vals = splitstring( get_line( key ) );
200 
201  // if the fields before do not exist, add padding
202  while ( int( vals.size() ) <= idx ) vals.push_back("0");
203 
204  vals[idx] = value;
205  ostringstream ss;
206 
207  for (unsigned i = 0; i < vals.size() ; i++ )
208  {
209  ss << vals[i];
210  if ( i != vals.size() - 1) ss << " ";
211  }
212  set_line( key, ss.str() );
213 
214  }
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
Definition: JException.hh:670
int get_index_of_field(std::string key, std::string field) const
Get index of data with the given key at given field.
Definition: Head.hh:145
General exception.
Definition: Exception.hh:13
void set_line(std::string key, std::string line)
Set data with the given key.
Definition: Head.hh:110
const std::string & get_line(std::string key) const
Get data with the given key.
Definition: Head.hh:87
std::vector< std::string > splitstring(const std::string &str, char delim= ' ')
Split string at delimiter.
Definition: Head.hh:45
static std::map<std::string, std::vector<std::string> >& Head::_hdr_dict ( )
inlinestaticinherited

Get internal description of the known lines in header.

Returns
internal dictionary

Definition at line 238 of file Head.hh.

239  {
240  using namespace std;
241 
242  // map with, for each tag (key), a vector of field-names
243 
244  static map<string, vector<string> > r;
245  if ( r.size() > 0 ) return r;
246 
247  string desc =
248  "DAQ:livetime\n"
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"
253  "PDF:i1 i2\n"
254  "model:interaction muon scattering numberOfEnergyBins\n"
255  "can:zmin zmax r\n"
256  "genvol:zmin zmax r volume numberOfEvents\n"
257  "merge:time gain\n"
258  "coord_origin:x y z\n"
259  "translate:x y z\n"
260  "genhencut:gDir Emin\n"
261  "k40:rate time\n"
262  "norma:primaryFlux numberOfPrimaries\n"
263  "livetime:numberOfSeconds errorOfSeconds\n"
264  "flux:type key file_1 file_2\n"
265  "spectrum:alpha\n"
266  "fixedcan:xcenter ycenter zmin zmax radius\n"
267  "start_run:run_id";
268 
269  for ( auto line : splitstring(desc, '\n') )
270  {
271  auto v = splitstring( line, ':');
272 
273  vector< string > fields = splitstring( v[1] );
274  for ( auto key : splitstring( v[0] ) )
275  {
276  r[key] = fields;
277  }
278  }
279  return r;
280  }
data_type r[M+1]
Definition: JPolint.hh:742
data_type v[N+1][M+1]
Definition: JPolint.hh:740
std::vector< std::string > splitstring(const std::string &str, char delim= ' ')
Split string at delimiter.
Definition: Head.hh:45
double Head::ngen ( ) const
inlineinherited

Get the number of generated events needed for computing event rates.

Returns
number of events

Definition at line 288 of file Head.hh.

289  {
290  return stod ( get_field("genvol", "numberOfEvents") );
291  }
std::string get_field(std::string key, int idx) const
Get data with the given key at given index.
Definition: Head.hh:123
double Head::daq_livetime ( ) const
inlineinherited

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.

299  {
300  return stod ( get_field("DAQ", "livetime") );
301  }
std::string get_field(std::string key, int idx) const
Get data with the given key at given index.
Definition: Head.hh:123
double Head::mc_livetime ( ) const
inlineinherited

Get the Monte Carlo live time.

Returns
live time [s]

Definition at line 309 of file Head.hh.

310  {
311  return stod ( get_field("livetime", "numberOfSeconds") );
312  }
std::string get_field(std::string key, int idx) const
Get data with the given key at given index.
Definition: Head.hh:123
Vec Head::coord_origin ( ) const
inlineinherited

Get coordinate origin.

Returns
position

Definition at line 319 of file Head.hh.

320  {
321  return Vec( stod( get_field("coord_origin", "x") ),
322  stod( get_field("coord_origin", "y") ),
323  stod( get_field("coord_origin", "z") ));
324  }
The Vec class is a straightforward 3-d vector, which also works in pyroot.
Definition: Vec.hh:12
std::string get_field(std::string key, int idx) const
Get data with the given key at given index.
Definition: Head.hh:123
Vec Head::translate ( ) const
inlineinherited

Get coordinate translation.

Returns
translation

Definition at line 331 of file Head.hh.

332  {
333  return Vec( stod( get_field("translate", "x") ),
334  stod( get_field("translate", "y") ),
335  stod( get_field("translate", "z") ));
336  }
The Vec class is a straightforward 3-d vector, which also works in pyroot.
Definition: Vec.hh:12
std::string get_field(std::string key, int idx) const
Get data with the given key at given index.
Definition: Head.hh:123
Head::ClassDef ( Head  ,
 
)
inherited

Friends And Related Function Documentation

bool operator== ( const JHead first,
const JHead second 
)
friend

Equal operator.

Note that this operator uses the JHead::match method.

Parameters
firstfirst header
secondsecond header
Returns
true if two headers are equal; else false

Definition at line 1305 of file JHead.hh.

1307  {
1308  return first.match(second);
1309  }
bool match(const JHead &header) const
Test match of headers.
Definition: JHead.hh:1206
bool operator< ( const JHead first,
const JHead second 
)
friend

Less than operator.

Parameters
firstfirst header
secondsecond header
Returns
true if first header is less than second header; else false

Definition at line 1319 of file JHead.hh.

1321  {
1322  return first.less(second);
1323  }
bool less(const JHead &header) const
Comparison of headers.
Definition: JHead.hh:1235

Member Data Documentation

JAANET::start_run JAANET::JHead::start_run

Definition at line 1326 of file JHead.hh.

JAANET::XSecFile JAANET::JHead::XSecFile

Definition at line 1327 of file JHead.hh.

JAANET::drawing JAANET::JHead::drawing

Definition at line 1328 of file JHead.hh.

std::vector<JAANET::detector> JAANET::JHead::detector

Definition at line 1329 of file JHead.hh.

JAANET::muon_desc_file JAANET::JHead::muon_desc_file

Definition at line 1330 of file JHead.hh.

JAANET::target JAANET::JHead::target

Definition at line 1331 of file JHead.hh.

std::vector<JAANET::physics> JAANET::JHead::physics

Definition at line 1332 of file JHead.hh.

std::vector<JAANET::simul> JAANET::JHead::simul

Definition at line 1333 of file JHead.hh.

JAANET::cut_primary JAANET::JHead::cut_primary

Definition at line 1334 of file JHead.hh.

JAANET::cut_seamuon JAANET::JHead::cut_seamuon

Definition at line 1335 of file JHead.hh.

JAANET::cut_in JAANET::JHead::cut_in

Definition at line 1336 of file JHead.hh.

JAANET::cut_nu JAANET::JHead::cut_nu

Definition at line 1337 of file JHead.hh.

JAANET::spectrum JAANET::JHead::spectrum

Definition at line 1338 of file JHead.hh.

JAANET::can JAANET::JHead::can

Definition at line 1339 of file JHead.hh.

JAANET::fixedcan JAANET::JHead::fixedcan

Definition at line 1340 of file JHead.hh.

JAANET::genvol JAANET::JHead::genvol

Definition at line 1341 of file JHead.hh.

JAANET::coord_origin JAANET::JHead::coord_origin

Definition at line 1342 of file JHead.hh.

JAANET::genhencut JAANET::JHead::genhencut

Definition at line 1343 of file JHead.hh.

JAANET::norma JAANET::JHead::norma

Definition at line 1344 of file JHead.hh.

JAANET::livetime JAANET::JHead::livetime

Definition at line 1345 of file JHead.hh.

JAANET::seabottom JAANET::JHead::seabottom

Definition at line 1346 of file JHead.hh.

JAANET::depth JAANET::JHead::depth

Definition at line 1347 of file JHead.hh.

JAANET::DAQ JAANET::JHead::DAQ

Definition at line 1348 of file JHead.hh.

JAANET::tgen JAANET::JHead::tgen

Definition at line 1349 of file JHead.hh.

JAANET::primary JAANET::JHead::primary

Definition at line 1350 of file JHead.hh.

JAANET::end_event JAANET::JHead::end_event

Definition at line 1351 of file JHead.hh.


The documentation for this struct was generated from the following files: