Jpp  18.4.0
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Types | Public Member Functions | List of all members
JAANET::JEvtWeightKM3BUU Struct Reference

Implementation of event weighting for KM3BUU data. More...

#include <JEvtWeightKM3BUU.hh>

Inheritance diagram for JAANET::JEvtWeightKM3BUU:
JAANET::JEvtWeightFactorHelper< JEvtWeightFactor_t > JLANG::JClonable< JClonable_t, JDerived_t >

Public Types

typedef JEvtWeightFactorHelper
< JEvtWeightFactor_t > 
JEvtWeightFactorHelper_t
 
typedef std::shared_ptr
< JEvtWeightFactor_t > 
pointer_type
 
typedef JClonable< JClonable_t >
::clone_type 
clone_type
 

Public Member Functions

 JEvtWeightKM3BUU ()
 Default constructor. More...
 
 JEvtWeightKM3BUU (const JHead &header)
 Constructor. More...
 
 JEvtWeightKM3BUU (const JHead &header, const JFlux &flux)
 Constructor. More...
 
 JEvtWeightKM3BUU (const JEvtWeightKM3BUU &object)
 Copy constructor. More...
 
void configure (const JHead &header) override
 Weight configuration. More...
 
bool check (const JHead &header) const override
 Check whether header is consistent with this event weighter. More...
 
double getWeight (const Evt &evt) const override
 Get weight of given event. More...
 
void configure (const JEvtWeightFactor_t &factor)
 Configure event-weight factor. More...
 
JEvtWeightFactor_t & getEvtWeightFactor () const
 Get reference to event-weight factor. More...
 
double getFactor (const Evt &evt) const
 Get weight-factor of given event. More...
 
virtual clone_type clone () const override
 Get clone of this object. More...
 

Detailed Description

Implementation of event weighting for KM3BUU data.

Definition at line 34 of file JEvtWeightKM3BUU.hh.

Member Typedef Documentation

template<class JEvtWeightFactor_t>
typedef JEvtWeightFactorHelper<JEvtWeightFactor_t> JAANET::JEvtWeightFactorHelper< JEvtWeightFactor_t >::JEvtWeightFactorHelper_t
inherited

Definition at line 32 of file JEvtWeightFactorHelper.hh.

template<class JEvtWeightFactor_t>
typedef std::shared_ptr<JEvtWeightFactor_t> JAANET::JEvtWeightFactorHelper< JEvtWeightFactor_t >::pointer_type
inherited

Definition at line 33 of file JEvtWeightFactorHelper.hh.

template<class JClonable_t, class JDerived_t = JNullType>
typedef JClonable<JClonable_t>::clone_type JLANG::JClonable< JClonable_t, JDerived_t >::clone_type
inherited

Definition at line 61 of file JClonable.hh.

Constructor & Destructor Documentation

JAANET::JEvtWeightKM3BUU::JEvtWeightKM3BUU ( )
inline

Default constructor.

Definition at line 41 of file JEvtWeightKM3BUU.hh.

41  :
42  JFluxHelper()
43  {}
JEvtWeightFactorHelper< JFlux > JFluxHelper
Type definition of event-weight factor helper for flux functions.
JAANET::JEvtWeightKM3BUU::JEvtWeightKM3BUU ( const JHead header)
inline

Constructor.

Parameters
headerheader

Definition at line 51 of file JEvtWeightKM3BUU.hh.

51  :
52  JFluxHelper()
53  {
54  configure(header);
55  }
JEvtWeightFactorHelper< JFlux > JFluxHelper
Type definition of event-weight factor helper for flux functions.
void configure(const JHead &header) override
Weight configuration.
JAANET::JEvtWeightKM3BUU::JEvtWeightKM3BUU ( const JHead header,
const JFlux flux 
)
inline

Constructor.

Parameters
headerheader
fluxflux

Definition at line 64 of file JEvtWeightKM3BUU.hh.

65  :
66  JFluxHelper()
67  {
68  configure(header);
70  }
JEvtWeightFactorHelper< JFlux > JFluxHelper
Type definition of event-weight factor helper for flux functions.
void configure(const JEvtWeightFactor_t &factor)
Configure event-weight factor.
void configure(const JHead &header) override
Weight configuration.
JAANET::JEvtWeightKM3BUU::JEvtWeightKM3BUU ( const JEvtWeightKM3BUU object)
inline

Copy constructor.

Parameters
objectoriginal object

Definition at line 78 of file JEvtWeightKM3BUU.hh.

79  {
80  this->norm = object.norm;
81 
82  if (static_cast<const JFluxHelper&>(object)) {
83  JFluxHelper::configure(*(object.get()));
84  }
85  }
void configure(const JEvtWeightFactor_t &factor)
Configure event-weight factor.

Member Function Documentation

void JAANET::JEvtWeightKM3BUU::configure ( const JHead header)
inlineoverride

Weight configuration.

Parameters
headerheader

Definition at line 93 of file JEvtWeightKM3BUU.hh.

94  {
95  using namespace JPP;
96 
97  if (check(header)) {
98 
99  const double Nevents = header.genvol.numberOfEvents;
100  const double dt = (header.tgen.numberOfSeconds > 0.0 ?
101  header.tgen.numberOfSeconds : 1.0);
102 
103  norm = 1.0 / Nevents / dt;
104 
105  } else {
106 
107  THROW(JValueOutOfRange, "JEvtWeightKM3BUU::configure(): Provided header is inconsistent with KM3BUU.");
108  }
109  }
bool check(const JHead &header) const override
Check whether header is consistent with this event weighter.
double numberOfEvents
Number of events.
Definition: JHead.hh:721
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
Definition: JException.hh:712
JAANET::tgen tgen
Definition: JHead.hh:1606
JAANET::genvol genvol
Definition: JHead.hh:1597
double numberOfSeconds
Time in seconds.
Definition: JHead.hh:1135
bool JAANET::JEvtWeightKM3BUU::check ( const JHead header) const
inlineoverride

Check whether header is consistent with this event weighter.

Parameters
headerheader
Returns
true if consistent; else false

Definition at line 118 of file JEvtWeightKM3BUU.hh.

119  {
120  return is_km3buu(header);
121  }
bool is_km3buu(const JHead &header)
Check for generator.
double JAANET::JEvtWeightKM3BUU::getWeight ( const Evt evt) const
inlineoverride

Get weight of given event.

Parameters
evtevent
Returns
weight [Hz]

Definition at line 130 of file JEvtWeightKM3BUU.hh.

131  {
132  using namespace JPP;
133 
134  if (static_cast<const JFluxHelper&>(*this) &&
135  evt.w.size() > WEIGHTLIST_DIFFERENTIAL_EVENT_RATE) {
136 
137  return evt.w[WEIGHTLIST_DIFFERENTIAL_EVENT_RATE] * getFactor(evt) * getNormalisation(evt);
138 
139  } else if (evt.w.size() > WEIGHTLIST_RESCALED_EVENT_RATE) {
140 
141  return evt.w[WEIGHTLIST_RESCALED_EVENT_RATE];
142 
143  } else if (evt.w.size() > WEIGHTLIST_EVENT_RATE) {
144 
145  return evt.w[WEIGHTLIST_EVENT_RATE] * getNormalisation(evt);
146 
147  } else {
148 
149  if (!static_cast<const JFluxHelper&>(*this)) {
150  THROW(JNullPointerException, "JEvtWeightKM3BUU::getWeight(): Unspecified flux function.");
151  } else {
152  THROW(JIndexOutOfRange, "JEvtWeightKM3BUU::getWeight(): Empty " << (evt.w.size() < 3 ? "w2-" : "w3-") << "weight.");
153  }
154  }
155  }
static const int WEIGHTLIST_RESCALED_EVENT_RATE
Rescaled event rate [s-1].
Definition: weightlist.hh:17
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
Definition: JException.hh:712
std::vector< double > w
MC: Weights w[0]=w1, w[1]=w2, w[2]=w3 (see e.g. Tag list or km3net-dataformat/definitions) ...
Definition: Evt.hh:42
static const int WEIGHTLIST_EVENT_RATE
Event rate [s-1].
Definition: weightlist.hh:15
double getFactor(const Evt &evt) const
Get weight-factor of given event.
static const int WEIGHTLIST_DIFFERENTIAL_EVENT_RATE
Event rate per unit of flux (c.f. taglist document) [GeV m2 sr].
Definition: weightlist.hh:14
template<class JEvtWeightFactor_t>
void JAANET::JEvtWeightFactorHelper< JEvtWeightFactor_t >::configure ( const JEvtWeightFactor_t &  factor)
inlineinherited

Configure event-weight factor.

Parameters
factorevent-weight factor

Definition at line 59 of file JEvtWeightFactorHelper.hh.

60  {
61  using namespace JPP;
62 
63  JEvtWeightFactor_t* p = dynamic_cast<JEvtWeightFactor_t*>(factor.clone());
64 
65  if (p != NULL) {
66  this->reset(p);
67  } else {
68  THROW(JNullPointerException, "JEvtWeightFactorHelper::configure(): Invalid downcast to class derived from JEvtWeightFactor.");
69  }
70  }
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
Definition: JException.hh:712
void reset(T &value)
Reset value.
template<class JEvtWeightFactor_t>
JEvtWeightFactor_t& JAANET::JEvtWeightFactorHelper< JEvtWeightFactor_t >::getEvtWeightFactor ( ) const
inlineinherited

Get reference to event-weight factor.

Returns
reference to event-weight factor

Definition at line 78 of file JEvtWeightFactorHelper.hh.

79  {
80  using namespace JPP;
81 
82  if (static_cast<const JEvtWeightFactorHelper_t&>(*this)) {
83  return *(this->get());
84  } else {
85  THROW(JNullPointerException, "JEvtWeightFactorHelper::getEvtWeightFactor(): Event-weight factor is not set.");
86  }
87  }
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
Definition: JException.hh:712
template<class JEvtWeightFactor_t>
double JAANET::JEvtWeightFactorHelper< JEvtWeightFactor_t >::getFactor ( const Evt evt) const
inlineinherited

Get weight-factor of given event.

Parameters
evtevent
Returns
event-weight factor

Definition at line 96 of file JEvtWeightFactorHelper.hh.

97  {
98  const JEvtWeightFactor_t& weightFactor = getEvtWeightFactor();
99 
100  return weightFactor.getFactor(evt);
101  }
JEvtWeightFactor_t & getEvtWeightFactor() const
Get reference to event-weight factor.
template<class JClonable_t, class JDerived_t = JNullType>
virtual clone_type JLANG::JClonable< JClonable_t, JDerived_t >::clone ( ) const
inlineoverridevirtualinherited

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