Jpp  19.0.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::JEvtWeightGenhen Struct Reference

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

#include <JEvtWeightGenhen.hh>

Inheritance diagram for JAANET::JEvtWeightGenhen:
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

 JEvtWeightGenhen ()
 Default Constructor. More...
 
 JEvtWeightGenhen (const JHead &header)
 Constructor. More...
 
 JEvtWeightGenhen (const JHead &header, const JFlux &flux)
 Constructor. More...
 
 JEvtWeightGenhen (const JEvtWeightGenhen &object)
 Copy constructor. More...
 
virtual const char *const getName () const override
 Get name. More...
 
void configure (const JHead &header) override
 Weight normalisation 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 Genhen data.

Definition at line 34 of file JEvtWeightGenhen.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::JEvtWeightGenhen::JEvtWeightGenhen ( )
inline

Default Constructor.

Definition at line 41 of file JEvtWeightGenhen.hh.

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

Constructor.

Parameters
headerheader

Definition at line 51 of file JEvtWeightGenhen.hh.

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

Constructor.

Parameters
headerheader
fluxflux

Definition at line 64 of file JEvtWeightGenhen.hh.

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

Copy constructor.

Parameters
objectoriginal object

Definition at line 78 of file JEvtWeightGenhen.hh.

79  {
80  setNormalisation(object.getNormalisation());
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

virtual const char* const JAANET::JEvtWeightGenhen::getName ( ) const
inlineoverridevirtual

Get name.

Returns
name

Definition at line 93 of file JEvtWeightGenhen.hh.

94  {
95  return "Genhen";
96  }
void JAANET::JEvtWeightGenhen::configure ( const JHead header)
inlineoverride

Weight normalisation configuration.

Parameters
headerheader

Definition at line 104 of file JEvtWeightGenhen.hh.

105  {
106  using namespace JPP;
107 
108  if (check(header)) {
109 
110  const double Nevents = header.genvol.numberOfEvents;
111 
112  setNormalisation(1.0 / Nevents / (60*60*24*365));
113 
114  } else {
115 
116  THROW(JValueOutOfRange, "JEvtWeightGenhen::configure(): Provided header is inconsistent with Genhen.");
117  }
118  }
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
bool check(const JHead &header) const override
Check whether header is consistent with this event weighter.
JAANET::genvol genvol
Definition: JHead.hh:1600
bool JAANET::JEvtWeightGenhen::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 127 of file JEvtWeightGenhen.hh.

128  {
129  return is_genhen(header);
130  }
bool is_genhen(const JHead &header)
Check for generator.
Definition: JHeadToolkit.hh:37
double JAANET::JEvtWeightGenhen::getWeight ( const Evt evt) const
inlineoverride

Get weight of given event.

Parameters
evtevent
Returns
weight [Hz]

Definition at line 139 of file JEvtWeightGenhen.hh.

140  {
141  using namespace JPP;
142 
143  if (static_cast<const JFluxHelper&>(*this) &&
144  evt.w.size() > WEIGHTLIST_DIFFERENTIAL_EVENT_RATE) {
145 
146  return evt.w[WEIGHTLIST_DIFFERENTIAL_EVENT_RATE] * getFactor(evt) * getNormalisation(evt);
147 
148  } else if (evt.w.size() > WEIGHTLIST_RESCALED_EVENT_RATE) {
149 
150  return evt.w[WEIGHTLIST_RESCALED_EVENT_RATE];
151 
152  } else if (evt.w.size() > WEIGHTLIST_EVENT_RATE) {
153 
154  return evt.w[WEIGHTLIST_EVENT_RATE] * getNormalisation(evt);
155 
156  } else {
157 
158  if (!static_cast<const JFluxHelper&>(*this)) {
159  THROW(JNullPointerException, "JEvtWeightGenhen::getWeight(): Unspecified flux function.");
160  } else {
161  THROW(JIndexOutOfRange, "JEvtWeightGenhen::getWeight(): Empty " << (evt.w.size() < 3 ? "w2-" : "w3-") << "weight.");
162  }
163  }
164  }
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: