Jpp  master_rocky
the software that should make you happy
Public Types | Public Member Functions | List of all members
JAANET::JEvtWeightKM3BUU Struct Referencefinal

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

#include <JEvtWeightKM3BUU.hh>

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

Public Types

typedef JEvtWeightFactorHelper::pointer_type 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...
 
const char *const getName () const override final
 Get name. More...
 
void configure (const JHead &header) override final
 Weight configuration. More...
 
bool check (const JHead &header) const override final
 Check whether header is consistent with this event weighter. More...
 
double getWeight (const Evt &evt) const override final
 Get weight of given event. More...
 
JFluxgetFlux () const
 Get reference to flux function. More...
 
double getFlux (const Evt &evt) const
 Get flux of given event. More...
 
void configure (const pointer_type &p)
 Configure event-weight factor. More...
 
void configure (const JEvtWeightFactor &factor)
 Configure event-weight factor. More...
 
JEvtWeightFactorgetFactor () const
 Get reference to event-weight factor. More...
 
double getFactor (const Evt &evt) const
 Get weight-factor of given event. More...
 
bool is_valid () const
 Check whether this event-weight factor is valid. More...
 
double operator() (const Evt &evt) const
 Get weight-factor of given event. More...
 
JProperties getProperties (const JEquationParameters &eqpars=JEvtWeightFactor::getEquationParameters())
 Get properties of this class. More...
 
JProperties getProperties (const JEquationParameters &eqpars=JEvtWeightFactor::getEquationParameters()) const
 Get properties of this class. 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

◆ pointer_type

Definition at line 26 of file JFluxHelper.hh.

◆ clone_type

template<class JClonable_t , class JDerived_t >
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

◆ JEvtWeightKM3BUU() [1/3]

JAANET::JEvtWeightKM3BUU::JEvtWeightKM3BUU ( )
inline

Default constructor.

Definition at line 41 of file JEvtWeightKM3BUU.hh.

41  :
42  JFluxHelper()
43  {}
JFluxHelper()
Default constructor.
Definition: JFluxHelper.hh:32

◆ JEvtWeightKM3BUU() [2/3]

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  }
void configure(const JHead &header) override final
Weight configuration.

◆ JEvtWeightKM3BUU() [3/3]

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  }
void configure(const pointer_type &p)
Configure event-weight factor.
Neutrino flux.
Definition: JHead.hh:906

Member Function Documentation

◆ getName()

const char* const JAANET::JEvtWeightKM3BUU::getName ( ) const
inlinefinaloverride

Get name.

Returns
name

Definition at line 78 of file JEvtWeightKM3BUU.hh.

79  {
80  return "KM3BUU";
81  }

◆ configure() [1/3]

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

Weight configuration.

Parameters
headerheader

Definition at line 89 of file JEvtWeightKM3BUU.hh.

90  {
91  using namespace JPP;
92 
93  if (check(header)) {
94 
95  const double Nevents = header.genvol.numberOfEvents;
96  const double dt = (header.tgen.numberOfSeconds > 0.0 ?
97  header.tgen.numberOfSeconds : 1.0);
98 
99  setNormalisation(1.0 / Nevents / dt);
100 
101  } else {
102 
103  THROW(JValueOutOfRange, "JEvtWeightKM3BUU::configure(): Provided header is inconsistent with KM3BUU.");
104  }
105  }
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
Definition: JException.hh:712
JAANET::tgen tgen
Definition: JHead.hh:1609
JAANET::genvol genvol
Definition: JHead.hh:1600
Exception for accessing a value in a collection that is outside of its range.
Definition: JException.hh:180
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
bool check(const JHead &header) const override final
Check whether header is consistent with this event weighter.
double numberOfEvents
Number of events.
Definition: JHead.hh:721
double numberOfSeconds
Time in seconds.
Definition: JHead.hh:1135

◆ check()

bool JAANET::JEvtWeightKM3BUU::check ( const JHead header) const
inlinefinaloverride

Check whether header is consistent with this event weighter.

Parameters
headerheader
Returns
true if consistent; else false

Definition at line 114 of file JEvtWeightKM3BUU.hh.

115  {
116  return is_km3buu(header);
117  }
bool is_km3buu(const JHead &header)
Check for generator.

◆ getWeight()

double JAANET::JEvtWeightKM3BUU::getWeight ( const Evt evt) const
inlinefinaloverride

Get weight of given event.

Parameters
evtevent
Returns
weight [Hz]

Definition at line 126 of file JEvtWeightKM3BUU.hh.

127  {
128  using namespace JPP;
129 
130  if (static_cast<const JFluxHelper&>(*this) &&
131  evt.w.size() > WEIGHTLIST_DIFFERENTIAL_EVENT_RATE) {
132 
133  return evt.w[WEIGHTLIST_DIFFERENTIAL_EVENT_RATE] * getFactor(evt) * getNormalisation(evt);
134 
135  } else if (evt.w.size() > WEIGHTLIST_RESCALED_EVENT_RATE) {
136 
137  return evt.w[WEIGHTLIST_RESCALED_EVENT_RATE];
138 
139  } else if (evt.w.size() > WEIGHTLIST_EVENT_RATE) {
140 
141  return evt.w[WEIGHTLIST_EVENT_RATE] * getNormalisation(evt);
142 
143  } else {
144 
145  if (!static_cast<const JFluxHelper&>(*this)) {
146  THROW(JNullPointerException, "JEvtWeightKM3BUU::getWeight(): Unspecified flux function.");
147  } else {
148  THROW(JIndexOutOfRange, "JEvtWeightKM3BUU::getWeight(): Empty " << (evt.w.size() < 3 ? "w2-" : "w3-") << "weight.");
149  }
150  }
151  }
Exception for accessing an index in a collection that is outside of its range.
Definition: JException.hh:108
Exception for null pointer operation.
Definition: JException.hh:234
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
JEvtWeightFactor & getFactor() const
Get reference to event-weight factor.
Helper class for flux function.
Definition: JFluxHelper.hh:25
static const int WEIGHTLIST_DIFFERENTIAL_EVENT_RATE
Event rate per unit of flux (c.f. taglist document) [GeV m2 sr].
Definition: weightlist.hh:14
static const int WEIGHTLIST_RESCALED_EVENT_RATE
Rescaled event rate [s-1].
Definition: weightlist.hh:17
static const int WEIGHTLIST_EVENT_RATE
Event rate [s-1].
Definition: weightlist.hh:15

◆ getFlux() [1/2]

JFlux& JAANET::JFluxHelper::getFlux ( ) const
inlineinherited

Get reference to flux function.

Returns
reference to flux function

Definition at line 62 of file JFluxHelper.hh.

63  {
64  using namespace JPP;
65 
66  JEvtWeightFactor& factor = this->getFactor();
67 
68  JFlux* p = dynamic_cast<JFlux*>(&factor);
69 
70  if (p != NULL) {
71  return *p;
72  } else {
73  THROW(JNullPointerException, "JFluxHelper::getFlux(): Cannot convert event-weight factor to flux function.");
74  }
75  }
Abstract base class for specifiable event-weight factors.
Low-level interface for retrieving the flux corresponding to a given event.
Definition: JFlux.hh:23

◆ getFlux() [2/2]

double JAANET::JFluxHelper::getFlux ( const Evt evt) const
inlineinherited

Get flux of given event.

Parameters
evtevent
Returns
flux [GeV^-1 * m^-2 * sr^-1 * s^-1]

Definition at line 84 of file JFluxHelper.hh.

85  {
86  return getFactor(evt);
87  }

◆ configure() [2/3]

void JAANET::JEvtWeightFactorHelper::configure ( const pointer_type p)
inlineinherited

Configure event-weight factor.

Parameters
ppointer to event-weight factor

Definition at line 68 of file JEvtWeightFactorHelper.hh.

69  {
70  static_cast<pointer_type&>(*this) = p;
71  }
std::shared_ptr< JEvtWeightFactor > pointer_type

◆ configure() [3/3]

void JAANET::JEvtWeightFactorHelper::configure ( const JEvtWeightFactor factor)
inlineinherited

Configure event-weight factor.

Parameters
factorevent-weight factor

Definition at line 79 of file JEvtWeightFactorHelper.hh.

80  {
81  using namespace JPP;
82 
83  JEvtWeightFactor* p = dynamic_cast<JEvtWeightFactor*>(factor.clone());
84 
85  if (p != NULL) {
86  this->reset(p);
87  } else {
88  THROW(JNullPointerException, "JEvtWeightFactorHelper::configure(): Could not retrieve event-weight factor interface.");
89  }
90  }
void reset(T &value)
Reset value.
virtual clone_type clone() const override
Get clone of this object.
Definition: JClonable.hh:69

◆ getFactor() [1/2]

JEvtWeightFactor& JAANET::JEvtWeightFactorHelper::getFactor ( ) const
inlineinherited

Get reference to event-weight factor.

Returns
reference to event-weight factor

Definition at line 98 of file JEvtWeightFactorHelper.hh.

99  {
100  using namespace JPP;
101 
102  if (static_cast<const JEvtWeightFactorHelper&>(*this)) {
103  return *(this->get());
104  } else {
105  THROW(JNullPointerException, "JEvtWeightFactorHelper::getFactor(): Event-weight factor is not set.");
106  }
107  }
Helper class for event-weight factor.

◆ getFactor() [2/2]

double JAANET::JEvtWeightFactorHelper::getFactor ( const Evt evt) const
inlineinherited

Get weight-factor of given event.

Parameters
evtevent
Returns
event-weight factor

Definition at line 129 of file JEvtWeightFactorHelper.hh.

130  {
131  const JEvtWeightFactor& weightFactor = getFactor();
132 
133  return weightFactor.getFactor(evt);
134  }
virtual double getFactor(const Evt &evt) const =0
Get event-weight factor of given event.

◆ is_valid()

bool JAANET::JEvtWeightFactorHelper::is_valid ( ) const
inlineinherited

Check whether this event-weight factor is valid.

Returns
true if valid; else false

Definition at line 115 of file JEvtWeightFactorHelper.hh.

116  {
117  const JEvtWeightFactorHelper& helper = static_cast<const JEvtWeightFactorHelper&>(*this);
118 
119  return (helper && helper->is_valid());
120  }
bool is_valid() const
Check whether this event-weight factor is valid.

◆ operator()()

double JAANET::JEvtWeightFactorHelper::operator() ( const Evt evt) const
inlineinherited

Get weight-factor of given event.

Parameters
evtevent
Returns
event-weight factor

Definition at line 143 of file JEvtWeightFactorHelper.hh.

144  {
145  return getFactor(evt);
146  }

◆ getProperties() [1/2]

JProperties JAANET::JEvtWeightFactorHelper::getProperties ( const JEquationParameters eqpars = JEvtWeightFactor::getEquationParameters())
inlineinherited

Get properties of this class.

Parameters
eqparsequation parameters

Definition at line 154 of file JEvtWeightFactorHelper.hh.

155  {
156  const JEvtWeightFactor& weightFactor = getFactor();
157 
158  return weightFactor.getProperties(eqpars);
159  }
virtual JProperties getProperties(const JEquationParameters &eqpars=JEvtWeightFactor::getEquationParameters())
Get properties of this class.

◆ getProperties() [2/2]

JProperties JAANET::JEvtWeightFactorHelper::getProperties ( const JEquationParameters eqpars = JEvtWeightFactor::getEquationParameters()) const
inlineinherited

Get properties of this class.

Parameters
eqparsequation parameters

Definition at line 167 of file JEvtWeightFactorHelper.hh.

168  {
169  const JEvtWeightFactor& weightFactor = getFactor();
170 
171  return weightFactor.getProperties(eqpars);
172  }

◆ clone()

template<class JClonable_t , class JDerived_t >
virtual clone_type JLANG::JClonable< JClonable_t, JDerived_t >::clone ( ) const
inlineoverridevirtualinherited

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