Jpp - the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JWeightEventToolkit.hh
Go to the documentation of this file.
1 #ifndef __JAANET__JWEIGHTEVENTTOOLKIT__
2 #define __JAANET__JWEIGHTEVENTTOOLKIT__
3 
4 #include <vector>
5 
8 
10 
11 #include "JAAnet/JHead.hh"
12 #include "JAAnet/JHeadToolkit.hh"
13 #include "JAAnet/JWeightEvent.hh"
14 #include "JAAnet/JFlux.hh"
15 #include "JAAnet/JFluxHelper.hh"
16 #include "JAAnet/JWeightDAQ.hh"
17 #include "JAAnet/JWeightMupage.hh"
18 #include "JAAnet/JWeightGSeaGen.hh"
19 #include "JAAnet/JWeightKM3BUU.hh"
20 
21 /**
22  * \author bjung
23  */
24 
25 namespace JAANET {
26 
29 
30 
31  /**
32  * Look-up table for event weighters.
33  */
34  struct JEventWeighter :
35  public std::vector< JSharedPointer<JWeightEvent> >
36  {
37  /*
38  * Constructor
39  */
41  {
42  this->push_back(new JWeightGSeaGen());
43  this->push_back(new JWeightKM3BUU());
44  this->push_back(new JWeightMupage());
45  this->push_back(new JWeightDAQ());
46  }
47 
48 
49  /**
50  * Get event weighter corresponding to given header.
51  *
52  * \param header header
53  * \return event weighter
54  */
55  const JWeightEvent& operator()(const JHead& header) const
56  {
57  for (const_iterator i = this->begin(); i != this->end(); ++i) {
58 
59  if ((*i)->check(header)) {
60 
61  return *(*i);
62  }
63  }
64 
65  THROW(JValueOutOfRange, "JEventWeighter::operator(): No event weighter found for given header.");
66  }
67  };
68 
69 
70  /**
71  * Check if given event weighter contains a specifiable flux function.
72  *
73  * \param weighter event weighter
74  * \return true if given event weighter contains a specifiable flux function; else false
75  */
76  inline bool hasFlux(const JWeightEvent& weighter)
77  {
78  return dynamic_cast<const JFluxHelper*>(&weighter) != NULL;
79  }
80 
81 
82  extern JEventWeighter getEventWeighter; //!< Function object for mapping header to event weighter.
83 }
84 
85 #endif
Implementation of event weighing for MUPAGE data.
bool hasFlux(const JWeightEvent &weighter)
Check if given event weighter contains a specifiable flux function.
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
Definition: JException.hh:670
Look-up table for event weighters.
The template JSharedPointer class can be used to share a pointer to an object.
Helper class for event weighing.
Definition: JFluxHelper.hh:23
const JWeightEvent & operator()(const JHead &header) const
Get event weighter corresponding to given header.
Low-level interface for event weighing.
Definition: JWeightEvent.hh:24
Implementation of event weighting for GSeaGen data.
JEventWeighter getEventWeighter
Function object for mapping header to event weighter.
Monte Carlo run header.
Definition: JHead.hh:1113
Implementation of event weighting for KM3BUU data.
Exception for accessing a value in a collection that is outside of its range.
Definition: JException.hh:162
Implementation of event weighing for DAQ data.
Definition: JWeightDAQ.hh:27