Jpp
Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | Static Private Member Functions | List of all members
JAANET::getMUPAGEHeader Struct Reference

Match header for MUPAGE. More...

#include <JHeadToolkit.hh>

Inheritance diagram for JAANET::getMUPAGEHeader:
JAANET::JHead

Public Member Functions

 getMUPAGEHeader ()
 Default constructor. More...
 
const JHeadgetHeader () const
 Get header. More...
 
JHeadgetHeader ()
 Get header. More...
 
void setHeader (const JHead &header)
 Set header. 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 bool option=true) 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)
 

Static Public Member Functions

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...
 

Public Attributes

JAANET::start_run start_run
 
JAANET::XSecFile XSecFile
 
JAANET::detector detector
 
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::DAQ DAQ
 
JAANET::tgen tgen
 
JAANET::primary primary
 
JAANET::end_event end_event
 

Static Public Attributes

static const std::string GENHEN = "GENHEN"
 Generators. More...
 
static const std::string GENIE = "GENIE"
 
static const std::string GSEAGEN = "gSeaGen"
 
static const std::string MUPAGE = "HEMAS-DPM"
 
static const std::string JSIRENE = "JSirene"
 
static const std::string KM3 = "KM3"
 
static const std::string KM3SIM = "KM3Sim"
 

Static Private Member Functions

template<class T >
static bool match (const T &first, const T &second)
 Test match. More...
 
template<class T >
static bool match (const std::vector< T > &first, const std::vector< T > &second)
 Test one container is subset of other container or vice versa. More...
 
template<class T >
static bool match (const JHead &first, const JHead &second, const bool option, T JHead::*pd)
 Test match of given data member of headers. More...
 

Detailed Description

Match header for MUPAGE.

Definition at line 24 of file JHeadToolkit.hh.

Constructor & Destructor Documentation

◆ getMUPAGEHeader()

JAANET::getMUPAGEHeader::getMUPAGEHeader ( )
inline

Default constructor.

Definition at line 30 of file JHeadToolkit.hh.

31  {
32  this->livetime.numberOfSeconds = 1.0;
33 
34  this->push(&JHead::livetime);
35  }

Member Function Documentation

◆ getHeader() [1/2]

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

Get header.

Returns
header

Definition at line 884 of file JHead.hh.

885  {
886  return static_cast<const JHead&>(*this);
887  }

◆ getHeader() [2/2]

JHead& JAANET::JHead::getHeader ( )
inlineinherited

Get header.

Returns
header

Definition at line 895 of file JHead.hh.

896  {
897  return static_cast<JHead&>(*this);
898  }

◆ setHeader()

void JAANET::JHead::setHeader ( const JHead header)
inlineinherited

Set header.

Parameters
headerheader

Definition at line 906 of file JHead.hh.

907  {
908  static_cast<JHead&>(*this) = header;
909  }

◆ pull() [1/2]

template<class T >
const_iterator JAANET::JHead::pull ( T JHead::*  pd) const
inlineinherited

Pull given data member from Head.

Parameters
pdpointer to data member
Returns
iterator of Head

Definition at line 919 of file JHead.hh.

920  {
921  return this->find(JROOT::getDataMember(pd)->GetName());
922  }

◆ pull() [2/2]

template<class T >
iterator JAANET::JHead::pull ( T JHead::*  pd)
inlineinherited

Pull given data member from Head.

Parameters
pdpointer to data member
Returns
iterator of Head

Definition at line 932 of file JHead.hh.

933  {
934  return this->find(JROOT::getDataMember(pd)->GetName());
935  }

◆ push()

template<class T >
void JAANET::JHead::push ( T JHead::*  pd)
inlineinherited

Push given data member to Head.

Parameters
pdpointer to data member

Definition at line 944 of file JHead.hh.

945  {
946  (*this)[JROOT::getDataMember(pd)->GetName()] = "";
947  }

◆ erase()

template<class T >
void JAANET::JHead::erase ( T JHead::*  pd)
inlineinherited

Remove given data member from Head.

Parameters
pdpointer to data member

Definition at line 956 of file JHead.hh.

957  {
958  iterator p = this->pull(pd);
959 
960  if (p != this->end()) {
961 
962  this->*pd = T();
963 
964  static_cast<Head*>(this)->erase(p);
965  }
966  }

◆ match() [1/4]

bool JAANET::JHead::match ( const JHead header,
const bool  option = true 
) const
inlineinherited

Test match of headers.

Note that if option is set to false, the match applies only to data which have a corresponding entry in the underlying map of the given header.

Parameters
headersecond header
optionoption
Returns
true if matches; else false

Definition at line 979 of file JHead.hh.

980  {
981  return (match(*this, header, option, &JHead::cut_primary) &&
982  match(*this, header, option, &JHead::cut_seamuon) &&
983  match(*this, header, option, &JHead::cut_in) &&
984  match(*this, header, option, &JHead::cut_nu) &&
985  match(*this, header, option, &JHead::physics) &&
986  match(*this, header, option, &JHead::simul) &&
987  match(*this, header, option, &JHead::spectrum) &&
988  match(*this, header, option, &JHead::can) &&
989  match(*this, header, option, &JHead::fixedcan) &&
990  match(*this, header, option, &JHead::genvol) &&
991  match(*this, header, option, &JHead::coord_origin) &&
992  match(*this, header, option, &JHead::norma) &&
993  match(*this, header, option, &JHead::livetime) &&
994  match(*this, header, option, &JHead::seabottom) &&
995  match(*this, header, option, &JHead::primary) &&
996  match(*this, header, option, &JHead::DAQ));
997  }

◆ match() [2/4]

template<class T >
static bool JAANET::JHead::match ( const T &  first,
const T &  second 
)
inlinestaticprivateinherited

Test match.

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

Definition at line 1164 of file JHead.hh.

1166  {
1167  return first.match(second);
1168  }

◆ match() [3/4]

template<class T >
static bool JAANET::JHead::match ( const std::vector< T > &  first,
const std::vector< T > &  second 
)
inlinestaticprivateinherited

Test one container is subset of other container or vice versa.

Parameters
firstfirst object
secondsecond object
Returns
true if first (second) is subset of second (first); else false

Definition at line 1179 of file JHead.hh.

1181  {
1182  size_t ns = 0;
1183 
1184  for (typename std::vector<T>::const_iterator ix = first.begin(); ix != first.end(); ++ix) {
1185  for (typename std::vector<T>::const_iterator iy = second.begin(); iy != second.end(); ++iy) {
1186  if (match(*ix, *iy)) {
1187  ++ns;
1188  }
1189  }
1190  }
1191 
1192  return ns == first.size() || ns == second.size();
1193  }

◆ match() [4/4]

template<class T >
static bool JAANET::JHead::match ( const JHead first,
const JHead second,
const bool  option,
T JHead::*  pd 
)
inlinestaticprivateinherited

Test match of given data member of headers.

Note that if option is set to false, the match applies only to data which have a corresponding tag in the underlying map of the second header.

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

Definition at line 1209 of file JHead.hh.

1213  {
1214  if (option || second.pull(pd) != second.end())
1215  return match(first.*pd, second.*pd);
1216  else
1217  return true;
1218  }

◆ less()

bool JAANET::JHead::less ( const JHead header) const
inlineinherited

Comparison of headers.

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

Definition at line 1006 of file JHead.hh.

1007  {
1008  if (primary.less(header.primary))
1009  return true;
1010  else if (header.primary.less(primary))
1011  return false;
1012  else
1013  return cut_primary.less(header.cut_primary);
1014  }

◆ add()

JHead& JAANET::JHead::add ( const JHead header)
inlineinherited

Addition of headers.

Parameters
headerheader
Returns
this header

Definition at line 1023 of file JHead.hh.

1024  {
1025  if (match(header)) {
1026 
1027  genvol .add(header.genvol);
1028  norma .add(header.norma);
1029  livetime.add(header.livetime);
1030  DAQ .add(header.DAQ);
1031 
1032  } else {
1033 
1034  THROW(JException, "JHead::add() headers do not match.");
1035  }
1036 
1037  return *this;
1038  }

◆ getEquationParameters()

static JLANG::JEquationParameters& JAANET::JHead::getEquationParameters ( )
inlinestaticinherited

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

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

Definition at line 1106 of file JHead.hh.

1107  {
1108  static JLANG::JEquationParameters parameters(":", "\n", "", "");
1109 
1110  return parameters;
1111  }

◆ setEquationParameters()

static void JAANET::JHead::setEquationParameters ( const JLANG::JEquationParameters equation)
inlinestaticinherited

Set equation parameters.

Parameters
equationequation parameters

Definition at line 1119 of file JHead.hh.

1120  {
1121  getEquationParameters() = equation;
1122  }

◆ read()

std::istream & JAANET::JHead::read ( std::istream &  in)
inherited

Read header from input.

Parameters
ininput stream
Returns
input stream

Definition at line 41 of file JHead.cc.

42  {
43  using namespace std;
44  using namespace JPP;
45 
46  JStringStream is(in);
47 
48  if (getFileStatus(is.str().c_str())) {
49  is.load();
50  }
51 
53 
54  JRootReadableClass cls(*this);
55 
56  for (JEquation equation; reader >> equation && equation.getKey() != end_event::Class_Name(); ) {
57 
58  JRedirectString redirect(reader, equation.getValue());
59 
60  const JRootReadableClass abc = cls.find(equation.getKey().c_str());
61 
62  if (abc.is_valid()) {
63  reader.getObject(abc);
64  }
65 
66  (*this)[equation.getKey()] = equation.getValue();
67  }
68 
69  return in;
70  }

◆ write()

std::ostream & JAANET::JHead::write ( std::ostream &  out) const
inherited

Write header to output.

Parameters
outoutput stream
headerheader
Returns
output stream
Parameters
outoutput stream
Returns
output stream

Definition at line 79 of file JHead.cc.

80  {
81  using namespace std;
82  using namespace JPP;
83 
84  JRootWriter writer(out, JHead::getEquationParameters(), JAAnetDictionary::getInstance());
85 
86  JRootWritableClass cls(*this);
87 
88  TIterator* i = cls.getClass()->GetListOfDataMembers()->MakeIterator();
89 
90  for (const TDataMember* p; (p = (const TDataMember*) i->Next()) != NULL; ) {
91  if (!JRootClass::is_static(*p)) {
92  if (this->find(p->GetName()) != this->end() ||
93  cls.get(*p) == JRootClass(&JHead::start_run) ||
94  cls.get(*p) == JRootClass(&JHead::end_event)) {
95  writer.put(p->GetName(), cls.get(*p), true);
96  }
97  }
98  }
99 
100  return out << flush;
101  }

◆ print()

std::ostream & JAANET::JHead::print ( std::ostream &  out) const
inherited

Print header to output.

Parameters
outoutput stream
Returns
output stream

Definition at line 110 of file JHead.cc.

111  {
112  using namespace std;
113  using namespace JPP;
114 
115  const JEquationParameters& parameters = JHead::getEquationParameters();
116 
117  JRootWriter writer(out, parameters, JAAnetDictionary::getInstance());
118 
119  JRootWritableClass cls(*this);
120 
121  TIterator* i = cls.getClass()->GetListOfDataMembers()->MakeIterator();
122 
124 
125  for (const TDataMember* p; (p = (const TDataMember*) i->Next()) != NULL; ) {
126  if (!JRootClass::is_static(*p)) {
127  if (cls.get(*p) != JRootClass(&JHead::end_event))
128  writer.put(p->GetName(), cls.get(*p), true);
129  else
130  end_event = make_pair(p->GetName(), cls.get(*p));
131  }
132  }
133 
134  for (JHead::const_iterator i = this->begin(); i != this->end(); ++i) {
135  if (!cls.find(i->first.c_str()).is_valid()) {
136  out << i->first << parameters.getDefaultSeparator() << parameters.getDefaultWhiteSpace() << i->second << parameters.getDefaultEndOfLine();
137  }
138  }
139 
140  writer.put(end_event.first, end_event.second, true);
141 
142  return out << flush;
143  }

◆ ClassDef()

JAANET::JHead::ClassDef ( JHead  ,
 
)
inherited

Member Data Documentation

◆ GENHEN

const std::string JAANET::JHead::GENHEN = "GENHEN"
staticinherited

Generators.

Applications.

Definition at line 845 of file JHead.hh.

◆ GENIE

const std::string JAANET::JHead::GENIE = "GENIE"
staticinherited

Definition at line 846 of file JHead.hh.

◆ GSEAGEN

const std::string JAANET::JHead::GSEAGEN = "gSeaGen"
staticinherited

Definition at line 847 of file JHead.hh.

◆ MUPAGE

const std::string JAANET::JHead::MUPAGE = "HEMAS-DPM"
staticinherited

Definition at line 848 of file JHead.hh.

◆ JSIRENE

const std::string JAANET::JHead::JSIRENE = "JSirene"
staticinherited

Definition at line 849 of file JHead.hh.

◆ KM3

const std::string JAANET::JHead::KM3 = "KM3"
staticinherited

Definition at line 850 of file JHead.hh.

◆ KM3SIM

const std::string JAANET::JHead::KM3SIM = "KM3Sim"
staticinherited

Definition at line 851 of file JHead.hh.

◆ start_run

JAANET::start_run JAANET::JHead::start_run
inherited

Definition at line 1071 of file JHead.hh.

◆ XSecFile

JAANET::XSecFile JAANET::JHead::XSecFile
inherited

Definition at line 1072 of file JHead.hh.

◆ detector

JAANET::detector JAANET::JHead::detector
inherited

Definition at line 1073 of file JHead.hh.

◆ muon_desc_file

JAANET::muon_desc_file JAANET::JHead::muon_desc_file
inherited

Definition at line 1074 of file JHead.hh.

◆ target

JAANET::target JAANET::JHead::target
inherited

Definition at line 1075 of file JHead.hh.

◆ physics

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

Definition at line 1076 of file JHead.hh.

◆ simul

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

Definition at line 1077 of file JHead.hh.

◆ cut_primary

JAANET::cut_primary JAANET::JHead::cut_primary
inherited

Definition at line 1078 of file JHead.hh.

◆ cut_seamuon

JAANET::cut_seamuon JAANET::JHead::cut_seamuon
inherited

Definition at line 1079 of file JHead.hh.

◆ cut_in

JAANET::cut_in JAANET::JHead::cut_in
inherited

Definition at line 1080 of file JHead.hh.

◆ cut_nu

JAANET::cut_nu JAANET::JHead::cut_nu
inherited

Definition at line 1081 of file JHead.hh.

◆ spectrum

JAANET::spectrum JAANET::JHead::spectrum
inherited

Definition at line 1082 of file JHead.hh.

◆ can

JAANET::can JAANET::JHead::can
inherited

Definition at line 1083 of file JHead.hh.

◆ fixedcan

JAANET::fixedcan JAANET::JHead::fixedcan
inherited

Definition at line 1084 of file JHead.hh.

◆ genvol

JAANET::genvol JAANET::JHead::genvol
inherited

Definition at line 1085 of file JHead.hh.

◆ coord_origin

JAANET::coord_origin JAANET::JHead::coord_origin
inherited

Definition at line 1086 of file JHead.hh.

◆ genhencut

JAANET::genhencut JAANET::JHead::genhencut
inherited

Definition at line 1087 of file JHead.hh.

◆ norma

JAANET::norma JAANET::JHead::norma
inherited

Definition at line 1088 of file JHead.hh.

◆ livetime

JAANET::livetime JAANET::JHead::livetime
inherited

Definition at line 1089 of file JHead.hh.

◆ seabottom

JAANET::seabottom JAANET::JHead::seabottom
inherited

Definition at line 1090 of file JHead.hh.

◆ DAQ

JAANET::DAQ JAANET::JHead::DAQ
inherited

Definition at line 1091 of file JHead.hh.

◆ tgen

JAANET::tgen JAANET::JHead::tgen
inherited

Definition at line 1092 of file JHead.hh.

◆ primary

JAANET::primary JAANET::JHead::primary
inherited

Definition at line 1093 of file JHead.hh.

◆ end_event

JAANET::end_event JAANET::JHead::end_event
inherited

Definition at line 1094 of file JHead.hh.


The documentation for this struct was generated from the following file:
JAANET::JHead::physics
std::vector< JAANET::physics > physics
Definition: JHead.hh:1076
JAANET::JHead::simul
std::vector< JAANET::simul > simul
Definition: JHead.hh:1077
JAANET::JHead::match
bool match(const JHead &header, const bool option=true) const
Test match of headers.
Definition: JHead.hh:979
JAANET::JHead::end_event
JAANET::end_event end_event
Definition: JHead.hh:1094
std::iterator
Definition: JSTDTypes.hh:18
JAANET::JHead::fixedcan
JAANET::fixedcan fixedcan
Definition: JHead.hh:1084
JAANET::cut::less
bool less(const cut &object) const
Comparison.
Definition: JHead.hh:187
JAANET::livetime::add
livetime & add(const livetime &object)
Addition.
Definition: JHead.hh:621
JAANET::JHead::livetime
JAANET::livetime livetime
Definition: JHead.hh:1089
JAANET::DAQ
Livetime of DAQ data.
Definition: JHead.hh:706
JLANG::getInstance
T & getInstance(const T &object)
Get static instance from temporary object.
Definition: JObject.hh:73
JAANET::JHead::coord_origin
JAANET::coord_origin coord_origin
Definition: JHead.hh:1086
JAANET::JHead::DAQ
JAANET::DAQ DAQ
Definition: JHead.hh:1091
JAANET::is_valid
bool is_valid(const T &value)
Check validity of given value.
Definition: JHead.hh:823
JAANET::JHead::cut_nu
JAANET::cut_nu cut_nu
Definition: JHead.hh:1081
JAANET::JHead::seabottom
JAANET::seabottom seabottom
Definition: JHead.hh:1090
std::vector
Definition: JSTDTypes.hh:12
JAANET::primary::less
bool less(const primary &object) const
Comparison.
Definition: JHead.hh:780
JAANET::JHead::start_run
JAANET::start_run start_run
Definition: JHead.hh:1071
JAANET::genvol::add
genvol & add(const genvol &object)
Addition.
Definition: JHead.hh:451
JPP
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Definition: JAAnetToolkit.hh:37
JAANET::JHead::cut_in
JAANET::cut_in cut_in
Definition: JHead.hh:1080
JROOT::getDataMember
const TDataMember * getDataMember(const JRootClass &parent, const JRootClass &member)
Get ROOT data member for given parent and member class.
Definition: JRootClass.hh:634
JAANET::JHead::pull
const_iterator pull(T JHead::*pd) const
Pull given data member from Head.
Definition: JHead.hh:919
JSYSTEM::getFileStatus
static JStat getFileStatus
Function object for file status.
Definition: JStat.hh:173
THROW
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
Definition: JException.hh:669
JAANET::cut_primary
Phase space of primary particle.
Definition: JHead.hh:222
JAANET::livetime::numberOfSeconds
double numberOfSeconds
Live time [s].
Definition: JHead.hh:644
std::pair
Definition: JSTDTypes.hh:15
JAANET::JHead::genvol
JAANET::genvol genvol
Definition: JHead.hh:1085
JAANET::JHead::can
JAANET::can can
Definition: JHead.hh:1083
JAANET::JHead::push
void push(T JHead::*pd)
Push given data member to Head.
Definition: JHead.hh:944
JLANG::JEquationParameters
Simple data structure to support I/O of equations (see class JLANG::JEquation).
Definition: JEquationParameters.hh:20
JAANET::JHead::norma
JAANET::norma norma
Definition: JHead.hh:1088
std
Definition: jaanetDictionary.h:36
JAANET::JHead::getEquationParameters
static JLANG::JEquationParameters & getEquationParameters()
Get equation parameters corresponding to Monte Carlo ASCII format, i.e:
Definition: JHead.hh:1106
JAANET::livetime
Normalisation of MUPAGE events.
Definition: JHead.hh:594
JAANET::JHead::cut_seamuon
JAANET::cut_seamuon cut_seamuon
Definition: JHead.hh:1079
JAANET::norma::add
norma & add(const norma &object)
Addition.
Definition: JHead.hh:577
JAANET::JHead::spectrum
JAANET::spectrum spectrum
Definition: JHead.hh:1082
JAANET::genvol
Neutrino vertex volume.
Definition: JHead.hh:420
JAANET::primary
Primary particle.
Definition: JHead.hh:766
JAANET::norma
Normlisation of CORSIKA events.
Definition: JHead.hh:551
JAANET::JHead::primary
JAANET::primary primary
Definition: JHead.hh:1093
JAANET::JHead::cut_primary
JAANET::cut_primary cut_primary
Definition: JHead.hh:1078
JAANET::DAQ::add
DAQ & add(const DAQ &object)
Addition.
Definition: JHead.hh:733