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::JEvtWeightGSeaGen Struct Reference

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

#include <JEvtWeightGSeaGen.hh>

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

 JEvtWeightGSeaGen ()
 Default Constructor. More...
 
 JEvtWeightGSeaGen (const JHead &header)
 Constructor. More...
 
 JEvtWeightGSeaGen (const JHead &header, const JFlux &flux)
 Constructor. More...
 
 JEvtWeightGSeaGen (const JEvtWeightGSeaGen &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 GSeaGen data.

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

Default Constructor.

Definition at line 41 of file JEvtWeightGSeaGen.hh.

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

Constructor.

Parameters
headerheader

Definition at line 51 of file JEvtWeightGSeaGen.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::JEvtWeightGSeaGen::JEvtWeightGSeaGen ( const JHead header,
const JFlux flux 
)
inline

Constructor.

Parameters
headerheader
fluxflux

Definition at line 64 of file JEvtWeightGSeaGen.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::JEvtWeightGSeaGen::JEvtWeightGSeaGen ( const JEvtWeightGSeaGen object)
inline

Copy constructor.

Parameters
objectoriginal object

Definition at line 78 of file JEvtWeightGSeaGen.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::JEvtWeightGSeaGen::getName ( ) const
inlineoverridevirtual

Get name.

Returns
name

Definition at line 93 of file JEvtWeightGSeaGen.hh.

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

Weight normalisation configuration.

Parameters
headerheader

Definition at line 104 of file JEvtWeightGSeaGen.hh.

105  {
106  using namespace JPP;
107 
108  if (check(header)) {
109 
110  const double Nevents = header.genvol.numberOfEvents;
111  const double dt = (header.tgen.numberOfSeconds > 0.0 ?
112  header.tgen.numberOfSeconds : 1.0);
113 
114  setNormalisation(1.0 / Nevents / dt);
115 
116  } else {
117 
118  THROW(JValueOutOfRange, "JEvtWeightGSeaGen::configure(): Provided header is inconsistent with GSeaGen.");
119  }
120  }
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:1609
JAANET::genvol genvol
Definition: JHead.hh:1600
bool check(const JHead &header) const override
Check whether header is consistent with this event weighter.
double numberOfSeconds
Time in seconds.
Definition: JHead.hh:1135
bool JAANET::JEvtWeightGSeaGen::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 129 of file JEvtWeightGSeaGen.hh.

130  {
131  return is_gseagen(header);
132  }
bool is_gseagen(const JHead &header)
Check for generator.
Definition: JHeadToolkit.hh:61
double JAANET::JEvtWeightGSeaGen::getWeight ( const Evt evt) const
inlineoverride

Get weight of given event.

Parameters
evtevent
Returns
weight [Hz]

Definition at line 141 of file JEvtWeightGSeaGen.hh.

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