Jpp  18.3.1
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::JEvtWeightMupage Struct Reference

Implementation of event weighing for MUPAGE data. More...

#include <JEvtWeightMupage.hh>

Inheritance diagram for JAANET::JEvtWeightMupage:
JLANG::JClonable< JClonable_t, JDerived_t > JAANET::JEvtWeightFactorHelper< JEvtWeightFactor >

Public Types

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

Public Member Functions

 JEvtWeightMupage ()
 Default Constructor. More...
 
 JEvtWeightMupage (const JHead &header)
 Constructor. More...
 
 JEvtWeightMupage (const JHead &header, const JEvtWeightFactor &factor)
 Constructor. More...
 
 JEvtWeightMupage (const JEvtWeightMupage &object)
 Copy constructor. More...
 
void configure (const JHead &header) override
 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 rate of given event. More...
 
virtual clone_type clone () const override
 Get clone of this object. More...
 
void configure (const JEvtWeightFactor &factor)
 Configure event-weight factor. More...
 
JEvtWeightFactorgetEvtWeightFactor () const
 Get reference to event-weight factor. More...
 
double getFactor (const Evt &evt) const
 Get weight-factor of given event. More...
 

Detailed Description

Implementation of event weighing for MUPAGE data.

Definition at line 33 of file JEvtWeightMupage.hh.

Member Typedef Documentation

Definition at line 37 of file JEvtWeightMupage.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.

Definition at line 33 of file JEvtWeightFactorHelper.hh.

Constructor & Destructor Documentation

JAANET::JEvtWeightMupage::JEvtWeightMupage ( )
inline

Default Constructor.

Definition at line 43 of file JEvtWeightMupage.hh.

JAANET::JEvtWeightMupage::JEvtWeightMupage ( const JHead header)
inline

Constructor.

Parameters
headerheader

Definition at line 53 of file JEvtWeightMupage.hh.

53  :
55  {
56  configure(header);
57  }
void configure(const JHead &header) override
Configuration.
JAANET::JEvtWeightMupage::JEvtWeightMupage ( const JHead header,
const JEvtWeightFactor factor 
)
inline

Constructor.

Parameters
headerheader
factorfactor

Definition at line 66 of file JEvtWeightMupage.hh.

68  {
69  configure(header);
71  }
void configure(const JHead &header) override
Configuration.
void configure(const JEvtWeightFactor_t &factor)
Configure event-weight factor.
JAANET::JEvtWeightMupage::JEvtWeightMupage ( const JEvtWeightMupage object)
inline

Copy constructor.

Parameters
objectoriginal object

Definition at line 79 of file JEvtWeightMupage.hh.

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

Member Function Documentation

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

Configuration.

Parameters
headerheader

Definition at line 94 of file JEvtWeightMupage.hh.

95  {
96  using namespace JPP;
97 
98  if (check(header)) {
99 
100  const double dt = ( header.time_interval.t2 - header.time_interval.t1 > 0.0 ?
101  header.time_interval.t2 - header.time_interval.t1 :
102  (header.livetime.numberOfSeconds > 0.0 ?
103  header.livetime.numberOfSeconds : 1.0) );
104 
105  norm = 1.0 / dt;
106 
107  } else {
108 
109  THROW(JValueOutOfRange, "JEvtWeightMupage::configure(): Provided header is inconsistent with MUPAGE.");
110  }
111  }
double t1
Start time in seconds.
Definition: JHead.hh:1164
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
Definition: JException.hh:712
double t2
Stop time in seconds.
Definition: JHead.hh:1165
JAANET::time_interval time_interval
Definition: JHead.hh:1607
bool check(const JHead &header) const override
Check whether header is consistent with this event weighter.
double numberOfSeconds
Live time [s].
Definition: JHead.hh:896
JAANET::livetime livetime
Definition: JHead.hh:1601
bool JAANET::JEvtWeightMupage::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 120 of file JEvtWeightMupage.hh.

121  {
122  return is_mupage(header);
123  }
bool is_mupage(const JHead &header)
Check for generator.
Definition: JHeadToolkit.hh:85
double JAANET::JEvtWeightMupage::getWeight ( const Evt evt) const
inlineoverride

Get rate of given event.

Parameters
evtevent
Returns
weight [1/s]

Definition at line 132 of file JEvtWeightMupage.hh.

133  {
134  if (static_cast<const JEvtWeightFactorHelper_t&>(*this)) {
135 
136  return getFactor(evt) * getNormalisation(evt);
137 
138  } else if (evt.w.size() > WEIGHTLIST_RESCALED_EVENT_RATE) {
139 
140  return evt.w[WEIGHTLIST_RESCALED_EVENT_RATE];
141 
142  } else {
143 
144  return getNormalisation(evt);
145  }
146  }
static const int WEIGHTLIST_RESCALED_EVENT_RATE
Rescaled event rate [s-1].
Definition: weightlist.hh:17
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
double getFactor(const Evt &evt) const
Get weight-factor of given event.
template<class JClonable_t, class JDerived_t = JNullType>
virtual clone_type JLANG::JClonable< JClonable_t, JDerived_t >::clone ( ) const
inlineoverridevirtualinherited
void JAANET::JEvtWeightFactorHelper< JEvtWeightFactor >::configure ( const JEvtWeightFactor 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
virtual clone_type clone() const override
Get clone of this object.
Definition: JClonable.hh:69
void reset(T &value)
Reset value.
JEvtWeightFactor & JAANET::JEvtWeightFactorHelper< JEvtWeightFactor >::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
double JAANET::JEvtWeightFactorHelper< JEvtWeightFactor >::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 & getEvtWeightFactor() const
Get reference to event-weight factor.

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