Jpp
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | Protected Member Functions | Protected Attributes | List of all members
JAANET::JWeightFileScanner< JFileScanner_t > Struct Template Reference

Template file scanner with event weight. More...

#include <JWeightFileScanner.hh>

Inheritance diagram for JAANET::JWeightFileScanner< JFileScanner_t >:
JAANET::JWeightEventHelper JAANET::JHead JLANG::JSharedPointer< JClass_t, JMemory_t > Head JLANG::JSharedCounter JLANG::JStorage< JClass_t, JMemory_t > TObject std::map< std::string, std::string > JLANG::JPointer< JClass_t > JLANG::JAbstractPointer< JClass_t > JLANG::JEquals< JAbstractPointer< JClass_t > >

Public Types

typedef JPointer< JClass_t > pointer_type
 
typedef JStorage< JClass_t,
JMemory_t > 
storage_type
 
typedef JMemory_t< JClass_t > memory_type
 

Public Member Functions

 JWeightFileScanner ()
 Default constructor. More...
 
 JWeightFileScanner (const JMultipleFileScanner_t &input_files, const JWeightEvent &weight, const JLimit &limit=JLimit())
 Constructor. More...
 
bool configure (const JMultipleFileScanner_t &input_files, const JWeightEvent &weight, const JLimit &limit=JLimit())
 Configure. More...
 
bool configure (const JMultipleFileScanner_t &input_files)
 Configuration. More...
 
double getWeight (const Evt &evt) const
 Get weight of given event. More...
 
Vec coord_origin () const
 Get coordinate origin. 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 Head. More...
 
bool is_valid () const
 Check validity of pointer. 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)
 
 ClassDef (Head, 2)
 
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 translate () const
 Get coordinate translation. More...
 
const JSharedPointergetSharedPointer () const
 Get shared pointer. More...
 
JSharedPointergetSharedPointer ()
 Get shared pointer. More...
 
void setSharedPointer (const JSharedPointer &object)
 Set shared pointer. More...
 
virtual void reset ()
 Reset pointer. More...
 
template<class T >
void reset (const JPointer< T > &pointer)
 Reset pointer. More...
 
void reset (JClass_t *p)
 Reset pointer. More...
 
template<class T >
void set (const JPointer< T > &pointer)
 Set pointer. More...
 
void initialise ()
 Initialise counter. More...
 
void attach (const JSharedCounter &object)
 Attach this counter to given shared counter object. More...
 
bool detach ()
 Detach. More...
 
void recreate ()
 Recreate object in memory. More...
 
void create ()
 Create object in memory. More...
 
void create (const unsigned int size)
 Create array of objects in memory. More...
 
virtual JClass_t * get () const
 Get pointer. More...
 
JClass_t *const & getReference () const
 Get rereference to internal pointer. More...
 
JClass_t *& getReference ()
 Get rereference to internal pointer. More...
 
virtual bool equals (const JAbstractPointer &object) const
 Equals. More...
 
JClass_t * operator-> () const
 Smart pointer operator. More...
 
 operator JClass_t * () const
 Type conversion operator. More...
 

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

Protected Member Functions

void set (const JSharedPointer &object)
 Set pointer. More...
 
virtual void set (JClass_t *p)
 Set pointer. More...
 
void release ()
 Release memory. More...
 

Protected Attributes

int * counter
 
JClass_t * __p
 pointer to object More...
 

Detailed Description

template<class JFileScanner_t = JMultipleFileScanner<Evt>>
struct JAANET::JWeightFileScanner< JFileScanner_t >

Template file scanner with event weight.

Definition at line 22 of file JWeightFileScanner.hh.

Member Typedef Documentation

template<class JClass_t, template< class > class JMemory_t = JNew>
typedef JPointer<JClass_t> JLANG::JSharedPointer< JClass_t, JMemory_t >::pointer_type
inherited

Definition at line 34 of file JSharedPointer.hh.

template<class JClass_t, template< class > class JMemory_t = JNew>
typedef JStorage<JClass_t, JMemory_t> JLANG::JSharedPointer< JClass_t, JMemory_t >::storage_type
inherited

Definition at line 35 of file JSharedPointer.hh.

template<class JClass_t, template< class > class JMemory_t = JNew>
typedef JMemory_t<JClass_t> JLANG::JStorage< JClass_t, JMemory_t >::memory_type
inherited

Definition at line 33 of file JStorage.hh.

Constructor & Destructor Documentation

template<class JFileScanner_t = JMultipleFileScanner<Evt>>
JAANET::JWeightFileScanner< JFileScanner_t >::JWeightFileScanner ( )
inline

Default constructor.

Definition at line 29 of file JWeightFileScanner.hh.

30  {}
template<class JFileScanner_t = JMultipleFileScanner<Evt>>
JAANET::JWeightFileScanner< JFileScanner_t >::JWeightFileScanner ( const JMultipleFileScanner_t input_files,
const JWeightEvent weight,
const JLimit limit = JLimit() 
)
inline

Constructor.

Parameters
input_filesinput files
weightevent weight
limitlimit

Definition at line 40 of file JWeightFileScanner.hh.

43  {
44  this->configure(input_files, weight);
45  }
bool configure(const JMultipleFileScanner_t &input_files, const JWeightEvent &weight, const JLimit &limit=JLimit())
Configure.

Member Function Documentation

template<class JFileScanner_t = JMultipleFileScanner<Evt>>
bool JAANET::JWeightFileScanner< JFileScanner_t >::configure ( const JMultipleFileScanner_t input_files,
const JWeightEvent weight,
const JLimit limit = JLimit() 
)
inline

Configure.

Parameters
input_filesinput files
weightevent weight
limitlimit

Definition at line 55 of file JWeightFileScanner.hh.

58  {
59  using namespace JPP;
60 
61  JFileScanner_t::configure(input_files, limit);
62 
63  this->reset(weight.clone());
64 
65  return JWeightEventHelper::configure(input_files);
66  }
virtual clone_type clone() const
Get clone of this object.
Definition: JClonable.hh:69
void configure(const T &value, const JAbstractCollection< JAbscissa_t > &bounds, JBool< false > option)
Configuration of value.
bool configure(const JMultipleFileScanner_t &input_files)
Configuration.
virtual void reset()
Reset pointer.
bool JAANET::JWeightEventHelper::configure ( const JMultipleFileScanner_t input_files)
inlineinherited

Configuration.

Parameters
input_filesinput files
Returns
true if okay; else false

Definition at line 37 of file JWeightEventHelper.hh.

38  {
39  setHeader(JSUPPORT::getHeader(input_files));
40 
41  if (is_valid())
42  return get()->configure(getHeader());
43  else
44  return false;
45  }
void setHeader(const JHead &header)
Set header.
Definition: JHead.hh:903
const JHead & getHeader() const
Get header.
Definition: JHead.hh:881
bool is_valid() const
Check validity of pointer.
Head getHeader(const JMultipleFileScanner_t &file_list)
Get Monte Carlo header.
bool configure(const JMultipleFileScanner_t &input_files)
Configuration.
double JAANET::JWeightEventHelper::getWeight ( const Evt evt) const
inlineinherited

Get weight of given event.

Parameters
evtevent
Returns
weight [1/s]

Definition at line 54 of file JWeightEventHelper.hh.

55  {
56  if (is_valid())
57  return get()->getWeight(evt);
58  else
59  THROW(JNullPointerException, "JWeightEventHelper::getWeight(): null pointer.");
60  }
double getWeight(const Evt &evt) const
Get weight of given event.
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
Definition: JException.hh:670
bool is_valid() const
Check validity of pointer.
Exception for null pointer operation.
Definition: JException.hh:216
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
const JHead& JAANET::JHead::getHeader ( ) const
inlineinherited

Get header.

Returns
header

Definition at line 881 of file JHead.hh.

882  {
883  return static_cast<const JHead&>(*this);
884  }
Monte Carlo run header.
Definition: JHead.hh:836
JHead& JAANET::JHead::getHeader ( )
inlineinherited

Get header.

Returns
header

Definition at line 892 of file JHead.hh.

893  {
894  return static_cast<JHead&>(*this);
895  }
Monte Carlo run header.
Definition: JHead.hh:836
void JAANET::JHead::setHeader ( const JHead header)
inlineinherited

Set header.

Parameters
headerheader

Definition at line 903 of file JHead.hh.

904  {
905  static_cast<JHead&>(*this) = header;
906  }
Monte Carlo run header.
Definition: JHead.hh:836
template<class T >
bool JAANET::JHead::is_valid ( T JHead::*  pd) const
inlineinherited

Check validity of given data member in Head.

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

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

Definition at line 918 of file JHead.hh.

919  {
920  return (this->pull(pd) != this->end());
921  }
const_iterator pull(T JHead::*pd) const
Pull given data member from Head.
Definition: JHead.hh:931
template<class JClass_t>
bool JLANG::JAbstractPointer< JClass_t >::is_valid ( ) const
inlineinherited

Check validity of pointer.

Returns
true if pointer not null; else false

Definition at line 83 of file JAbstractPointer.hh.

84  {
85  return this->get() != NULL;
86  }
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 931 of file JHead.hh.

932  {
933  return this->find(JROOT::getDataMember(pd)->GetName());
934  }
const TDataMember * getDataMember(const JRootClass &parent, const JRootClass &member)
Get ROOT data member for given parent and member class.
Definition: JRootClass.hh:634
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 944 of file JHead.hh.

945  {
946  return this->find(JROOT::getDataMember(pd)->GetName());
947  }
const TDataMember * getDataMember(const JRootClass &parent, const JRootClass &member)
Get ROOT data member for given parent and member class.
Definition: JRootClass.hh:634
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 956 of file JHead.hh.

957  {
958  (*this)[JROOT::getDataMember(pd)->GetName()] = "";
959  }
const TDataMember * getDataMember(const JRootClass &parent, const JRootClass &member)
Get ROOT data member for given parent and member class.
Definition: JRootClass.hh:634
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 968 of file JHead.hh.

969  {
970  iterator p = this->pull(pd);
971 
972  if (p != this->end()) {
973 
974  this->*pd = T();
975 
976  static_cast<Head*>(this)->erase(p);
977  }
978  }
void erase(T JHead::*pd)
Remove given data member from Head.
Definition: JHead.hh:968
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:931
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 991 of file JHead.hh.

992  {
993  return (match(*this, header, option, &JHead::cut_primary) &&
994  match(*this, header, option, &JHead::cut_seamuon) &&
995  match(*this, header, option, &JHead::cut_in) &&
996  match(*this, header, option, &JHead::cut_nu) &&
997  match(*this, header, option, &JHead::physics) &&
998  match(*this, header, option, &JHead::simul) &&
999  match(*this, header, option, &JHead::spectrum) &&
1000  match(*this, header, option, &JHead::can) &&
1001  match(*this, header, option, &JHead::fixedcan) &&
1002  match(*this, header, option, &JHead::genvol) &&
1003  match(*this, header, option, &JHead::coord_origin) &&
1004  match(*this, header, option, &JHead::norma) &&
1005  match(*this, header, option, &JHead::livetime) &&
1006  match(*this, header, option, &JHead::seabottom) &&
1007  match(*this, header, option, &JHead::primary) &&
1008  match(*this, header, option, &JHead::DAQ));
1009  }
JAANET::genvol genvol
Definition: JHead.hh:1098
JAANET::norma norma
Definition: JHead.hh:1101
JAANET::cut_primary cut_primary
Definition: JHead.hh:1091
std::vector< JAANET::physics > physics
Definition: JHead.hh:1089
std::vector< JAANET::simul > simul
Definition: JHead.hh:1090
JAANET::fixedcan fixedcan
Definition: JHead.hh:1097
JAANET::can can
Definition: JHead.hh:1096
JAANET::cut_seamuon cut_seamuon
Definition: JHead.hh:1092
JAANET::livetime livetime
Definition: JHead.hh:1102
JAANET::seabottom seabottom
Definition: JHead.hh:1103
JAANET::spectrum spectrum
Definition: JHead.hh:1095
JAANET::primary primary
Definition: JHead.hh:1106
JAANET::cut_in cut_in
Definition: JHead.hh:1093
JAANET::cut_nu cut_nu
Definition: JHead.hh:1094
JAANET::DAQ DAQ
Definition: JHead.hh:1104
bool match(const JHead &header, const bool option=true) const
Test match of headers.
Definition: JHead.hh:991
Vec coord_origin() const
Get coordinate origin.
Definition: Head.hh:319
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 1018 of file JHead.hh.

1019  {
1020  if (primary.less(header.primary))
1021  return true;
1022  else if (header.primary.less(primary))
1023  return false;
1024  else
1025  return cut_primary.less(header.cut_primary);
1026  }
JAANET::cut_primary cut_primary
Definition: JHead.hh:1091
bool less(const primary &object) const
Comparison.
Definition: JHead.hh:790
JAANET::primary primary
Definition: JHead.hh:1106
bool less(const cut &object) const
Comparison.
Definition: JHead.hh:197
Primary particle.
Definition: JHead.hh:776
Phase space of primary particle.
Definition: JHead.hh:232
JHead& JAANET::JHead::add ( const JHead header)
inlineinherited

Addition of headers.

Parameters
headerheader
Returns
this header

Definition at line 1035 of file JHead.hh.

1036  {
1037  if (match(header)) {
1038 
1039  genvol .add(header.genvol);
1040  norma .add(header.norma);
1041  livetime.add(header.livetime);
1042  DAQ .add(header.DAQ);
1043 
1044  } else {
1045 
1046  THROW(JException, "JHead::add() headers do not match.");
1047  }
1048 
1049  return *this;
1050  }
norma & add(const norma &object)
Addition.
Definition: JHead.hh:587
JAANET::genvol genvol
Definition: JHead.hh:1098
Neutrino vertex volume.
Definition: JHead.hh:430
JAANET::norma norma
Definition: JHead.hh:1101
Livetime of DAQ data.
Definition: JHead.hh:716
livetime & add(const livetime &object)
Addition.
Definition: JHead.hh:631
#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:561
DAQ & add(const DAQ &object)
Addition.
Definition: JHead.hh:743
genvol & add(const genvol &object)
Addition.
Definition: JHead.hh:461
JAANET::livetime livetime
Definition: JHead.hh:1102
Normalisation of MUPAGE events.
Definition: JHead.hh:604
JAANET::DAQ DAQ
Definition: JHead.hh:1104
bool match(const JHead &header, const bool option=true) const
Test match of headers.
Definition: JHead.hh:991
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 1119 of file JHead.hh.

1120  {
1121  static JLANG::JEquationParameters parameters(":", "\n", "", "");
1122 
1123  return parameters;
1124  }
*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)
inlinestaticinherited

Set equation parameters.

Parameters
equationequation parameters

Definition at line 1132 of file JHead.hh.

1133  {
1134  getEquationParameters() = equation;
1135  }
static JLANG::JEquationParameters & getEquationParameters()
Get equation parameters corresponding to Monte Carlo ASCII format, i.e:
Definition: JHead.hh:1119
std::istream & JAANET::JHead::read ( std::istream &  in)
inherited

Read header from input.

Parameters
ininput stream
Returns
input stream

Definition at line 42 of file JHead.cc.

43  {
44  using namespace std;
45  using namespace JPP;
46 
47  JStringStream is(in);
48 
49  if (getFileStatus(is.str().c_str())) {
50  is.load();
51  }
52 
54 
55  JRootReadableClass cls(*this);
56 
57  for (JEquation equation; reader >> equation && equation.getKey() != end_event::Class_Name(); ) {
58 
59  JRedirectString redirect(reader, equation.getValue());
60 
61  const JRootReadableClass abc = cls.find(equation.getKey().c_str());
62 
63  if (abc.is_valid()) {
64  reader.getObject(abc);
65  }
66 
67  (*this)[equation.getKey()] = equation.getValue();
68  }
69 
70  return in;
71  }
esac print_variable DETECTOR INPUT_FILE OUTPUT_FILE CDF for TYPE in
Definition: JSirene.sh:45
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:1119
static JStat getFileStatus
Function object for file status.
Definition: JStat.hh:173
std::ostream & JAANET::JHead::write ( std::ostream &  out) const
inherited

Write header to output.

Parameters
outoutput stream
Returns
output stream

Definition at line 80 of file JHead.cc.

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

Print header to output.

Parameters
outoutput stream
Returns
output stream

Definition at line 111 of file JHead.cc.

112  {
113  using namespace std;
114  using namespace JPP;
115 
116  const JEquationParameters& parameters = JHead::getEquationParameters();
117 
118  JRootWriter writer(out, parameters, JAAnetDictionary::getInstance());
119 
120  JRootWritableClass cls(*this);
121 
122  TIterator* i = cls.getClass()->GetListOfDataMembers()->MakeIterator();
123 
125 
126  for (const TDataMember* p; (p = (const TDataMember*) i->Next()) != NULL; ) {
127  if (!JRootClass::is_static(*p)) {
128  if (cls.get(*p) != JRootClass(&JHead::end_event))
129  writer.put(p->GetName(), cls.get(*p), true);
130  else
131  end_event = make_pair(p->GetName(), cls.get(*p));
132  }
133  }
134 
135  for (JHead::const_iterator i = this->begin(); i != this->end(); ++i) {
136  if (!cls.find(i->first.c_str()).is_valid()) {
137  out << i->first << parameters.getDefaultSeparator() << parameters.getDefaultWhiteSpace() << i->second << parameters.getDefaultEndOfLine();
138  }
139  }
140 
141  writer.put(end_event.first, end_event.second, true);
142 
143  return out << flush;
144  }
*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
JAANET::end_event end_event
Definition: JHead.hh:1107
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:1119
bool is_valid(T JHead::*pd) const
Check validity of given data member in Head.
Definition: JHead.hh:918
JAANET::JHead::ClassDef ( JHead  ,
 
)
inherited
Head::ClassDef ( Head  ,
 
)
inherited
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:707
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  }
static std::map< std::string, std::vector< std::string > > & _hdr_dict()
Get internal description of the known lines in header.
Definition: Head.hh:238
data_type v[N+1][M+1]
Definition: JPolint.hh:707
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:709
data_type v[N+1][M+1]
Definition: JPolint.hh:707
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::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
template<class JClass_t, template< class > class JMemory_t = JNew>
const JSharedPointer& JLANG::JSharedPointer< JClass_t, JMemory_t >::getSharedPointer ( ) const
inlineinherited

Get shared pointer.

Returns
this shared pointer

Definition at line 95 of file JSharedPointer.hh.

96  {
97  return static_cast<const JSharedPointer&>(*this);
98  }
The template JSharedPointer class can be used to share a pointer to an object.
template<class JClass_t, template< class > class JMemory_t = JNew>
JSharedPointer& JLANG::JSharedPointer< JClass_t, JMemory_t >::getSharedPointer ( )
inlineinherited

Get shared pointer.

Returns
this shared pointer

Definition at line 106 of file JSharedPointer.hh.

107  {
108  return static_cast<JSharedPointer&>(*this);
109  }
The template JSharedPointer class can be used to share a pointer to an object.
template<class JClass_t, template< class > class JMemory_t = JNew>
void JLANG::JSharedPointer< JClass_t, JMemory_t >::setSharedPointer ( const JSharedPointer< JClass_t, JMemory_t > &  object)
inlineinherited

Set shared pointer.

Parameters
objectshared pointer

Definition at line 117 of file JSharedPointer.hh.

118  {
119  if (this->get() != object.get()) {
120 
121  this->reset();
122 
123  if (object.is_valid()) {
124  this->set(object);
125  }
126  }
127  }
void set(const JSharedPointer &object)
Set pointer.
bool is_valid() const
Check validity of pointer.
virtual void reset()
Reset pointer.
template<class JClass_t, template< class > class JMemory_t = JNew>
virtual void JLANG::JSharedPointer< JClass_t, JMemory_t >::reset ( )
inlinevirtualinherited

Reset pointer.

The reference counter is decremented by one and the object pointed to previously is deleted when its reference counter is zero.

Reimplemented from JLANG::JStorage< JClass_t, JMemory_t >.

Definition at line 171 of file JSharedPointer.hh.

172  {
173  if (this->detach()) {
175  }
176 
178  }
virtual void reset()
Reset pointer.
Definition: JStorage.hh:42
virtual void reset()
Reset pointer.
Definition: JPointer.hh:84
bool detach()
Detach.
template<class JClass_t>
template<class T >
void JLANG::JPointer< JClass_t >::reset ( const JPointer< T > &  pointer)
inlineinherited

Reset pointer.

Parameters
pointerpointer to object

Definition at line 108 of file JPointer.hh.

109  {
110  this->reset(pointer.get());
111  }
virtual void reset()
Reset pointer.
Definition: JPointer.hh:84
virtual JClass_t * get() const
Get pointer.
Definition: JPointer.hh:64
template<class JClass_t>
void JLANG::JAbstractPointer< JClass_t >::reset ( JClass_t *  p)
inlineinherited

Reset pointer.

Parameters
ppointer to object

Definition at line 94 of file JAbstractPointer.hh.

95  {
96  if (this->get() != p) {
97 
98  this->reset();
99 
100  if (p != NULL) {
101  this->set(p);
102  }
103  }
104  }
virtual void reset()=0
Reset pointer.
virtual void set(JClass_t *p)=0
Set pointer.
template<class JClass_t, template< class > class JMemory_t = JNew>
void JLANG::JSharedPointer< JClass_t, JMemory_t >::set ( const JSharedPointer< JClass_t, JMemory_t > &  object)
inlineprotectedinherited

Set pointer.

The reference counter of the shared object pointed to is incremented by one.

Parameters
objectshared pointer

Definition at line 188 of file JSharedPointer.hh.

189  {
190  pointer_type::set(object.get());
191 
192  this->attach(object);
193  }
void attach(const JSharedCounter &object)
Attach this counter to given shared counter object.
virtual void set(JClass_t *p)
Set pointer.
Definition: JPointer.hh:75
template<class JClass_t, template< class > class JMemory_t = JNew>
virtual void JLANG::JSharedPointer< JClass_t, JMemory_t >::set ( JClass_t *  p)
inlineprotectedvirtualinherited

Set pointer.

The reference counter of the shared object pointed to is initialised to one.

Parameters
ppointer to derived class object

Reimplemented from JLANG::JPointer< JClass_t >.

Definition at line 202 of file JSharedPointer.hh.

203  {
205 
206  this->initialise();
207  }
void initialise()
Initialise counter.
virtual void set(JClass_t *p)
Set pointer.
Definition: JPointer.hh:75
template<class JClass_t>
template<class T >
void JLANG::JPointer< JClass_t >::set ( const JPointer< T > &  pointer)
inlineinherited

Set pointer.

Parameters
pointerpointer to object

Definition at line 96 of file JPointer.hh.

97  {
98  this->set(pointer.get());
99  }
virtual JClass_t * get() const
Get pointer.
Definition: JPointer.hh:64
virtual void set(JClass_t *p)
Set pointer.
Definition: JPointer.hh:75
void JLANG::JSharedCounter::initialise ( )
inlineinherited

Initialise counter.

Definition at line 33 of file JSharedCounter.hh.

34  {
35  detach();
36 
37  counter = new int(1);
38  }
bool detach()
Detach.
void JLANG::JSharedCounter::attach ( const JSharedCounter object)
inlineinherited

Attach this counter to given shared counter object.

Parameters
objectshared counter

Definition at line 46 of file JSharedCounter.hh.

47  {
48  detach();
49 
50  counter = object.counter;
51 
52  if (counter != NULL) {
53  ++(*counter);
54  }
55  }
bool detach()
Detach.
bool JLANG::JSharedCounter::detach ( )
inlineinherited

Detach.

Returns
true if counter at zero; else false

Definition at line 63 of file JSharedCounter.hh.

64  {
65  if (counter != NULL) {
66 
67  if (--(*counter) == 0) {
68 
69  delete counter;
70 
71  counter = NULL;
72 
73  return true;
74  }
75 
76  counter = NULL;
77  }
78 
79  return false;
80  }
template<class JClass_t, template< class > class JMemory_t = JNew>
void JLANG::JStorage< JClass_t, JMemory_t >::recreate ( )
inlineinherited

Recreate object in memory.

A new object is created if no memory is allocated yet, else the previously created object is maintained.

Definition at line 57 of file JStorage.hh.

58  {
59  if (!this->is_valid()) {
60  this->set(memory_type::create());
61  }
62  }
bool is_valid() const
Check validity of pointer.
virtual void set(JClass_t *p)
Set pointer.
Definition: JPointer.hh:75
template<class JClass_t, template< class > class JMemory_t = JNew>
void JLANG::JStorage< JClass_t, JMemory_t >::create ( )
inlineinherited

Create object in memory.

The memory allocated by a previously created object will be released.

Definition at line 69 of file JStorage.hh.

70  {
71  this->reset(memory_type::create());
72  }
virtual void reset()
Reset pointer.
Definition: JStorage.hh:42
template<class JClass_t, template< class > class JMemory_t = JNew>
void JLANG::JStorage< JClass_t, JMemory_t >::create ( const unsigned int  size)
inlineinherited

Create array of objects in memory.

The memory allocated by previously created objects will be released.

Parameters
sizenumber of elements

Definition at line 81 of file JStorage.hh.

82  {
83  this->reset(memory_type::create(size));
84  }
virtual void reset()
Reset pointer.
Definition: JStorage.hh:42
template<class JClass_t, template< class > class JMemory_t = JNew>
void JLANG::JStorage< JClass_t, JMemory_t >::release ( )
inlineprotectedinherited

Release memory.

Definition at line 91 of file JStorage.hh.

92  {
93  memory_type::release(this->get());
94  }
template<class JClass_t>
virtual JClass_t* JLANG::JPointer< JClass_t >::get ( ) const
inlinevirtualinherited
template<class JClass_t>
JClass_t* const& JLANG::JPointer< JClass_t >::getReference ( ) const
inlineinherited

Get rereference to internal pointer.

Returns
reference to internal pointer

Definition at line 119 of file JPointer.hh.

120  {
121  return __p;
122  }
JClass_t * __p
pointer to object
Definition: JPointer.hh:136
template<class JClass_t>
JClass_t* & JLANG::JPointer< JClass_t >::getReference ( )
inlineinherited

Get rereference to internal pointer.

Returns
reference to internal pointer

Definition at line 130 of file JPointer.hh.

131  {
132  return __p;
133  }
JClass_t * __p
pointer to object
Definition: JPointer.hh:136
template<class JClass_t>
virtual bool JLANG::JAbstractPointer< JClass_t >::equals ( const JAbstractPointer< JClass_t > &  object) const
inlinevirtualinherited

Equals.

The equality is evaluated by comparison of the internal pointers.

Parameters
objectabstract pointer
Returns
true if equals; else false

Definition at line 50 of file JAbstractPointer.hh.

51  {
52  return this->get() == object.get();
53  }
template<class JClass_t>
JClass_t* JLANG::JAbstractPointer< JClass_t >::operator-> ( ) const
inlineinherited

Smart pointer operator.

Returns
pointer to object

Definition at line 112 of file JAbstractPointer.hh.

113  {
114  if (!is_valid())
115  throw JNullPointerException("JAbstractPointer::operator->()");
116  else
117  return this->get();
118  }
bool is_valid() const
Check validity of pointer.
Exception for null pointer operation.
Definition: JException.hh:216
template<class JClass_t>
JLANG::JAbstractPointer< JClass_t >::operator JClass_t * ( ) const
inlineinherited

Type conversion operator.

Returns
pointer to object

Definition at line 126 of file JAbstractPointer.hh.

127  {
128  return this->get();
129  }

Member Data Documentation

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

Generators.

Applications.

Definition at line 842 of file JHead.hh.

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

Definition at line 843 of file JHead.hh.

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

Definition at line 844 of file JHead.hh.

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

Definition at line 845 of file JHead.hh.

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

Definition at line 846 of file JHead.hh.

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

Definition at line 847 of file JHead.hh.

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

Definition at line 848 of file JHead.hh.

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

Definition at line 1083 of file JHead.hh.

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

Definition at line 1084 of file JHead.hh.

JAANET::drawing JAANET::JHead::drawing
inherited

Definition at line 1085 of file JHead.hh.

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

Definition at line 1086 of file JHead.hh.

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

Definition at line 1087 of file JHead.hh.

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

Definition at line 1088 of file JHead.hh.

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

Definition at line 1089 of file JHead.hh.

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

Definition at line 1090 of file JHead.hh.

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

Definition at line 1091 of file JHead.hh.

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

Definition at line 1092 of file JHead.hh.

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

Definition at line 1093 of file JHead.hh.

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

Definition at line 1094 of file JHead.hh.

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

Definition at line 1095 of file JHead.hh.

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

Definition at line 1096 of file JHead.hh.

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

Definition at line 1097 of file JHead.hh.

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

Definition at line 1098 of file JHead.hh.

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

Definition at line 1099 of file JHead.hh.

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

Definition at line 1100 of file JHead.hh.

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

Definition at line 1101 of file JHead.hh.

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

Definition at line 1102 of file JHead.hh.

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

Definition at line 1103 of file JHead.hh.

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

Definition at line 1104 of file JHead.hh.

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

Definition at line 1105 of file JHead.hh.

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

Definition at line 1106 of file JHead.hh.

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

Definition at line 1107 of file JHead.hh.

int* JLANG::JSharedCounter::counter
protectedinherited

Definition at line 83 of file JSharedCounter.hh.

template<class JClass_t>
JClass_t* JLANG::JPointer< JClass_t >::__p
protectedinherited

pointer to object

Definition at line 136 of file JPointer.hh.


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