Jpp  18.3.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::JEvtWeightCorsika Struct Reference

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

#include <JEvtWeightCorsika.hh>

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

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

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

Default Constructor.

Definition at line 42 of file JEvtWeightCorsika.hh.

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

Constructor.

Parameters
headerheader

Definition at line 52 of file JEvtWeightCorsika.hh.

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

Constructor.

Parameters
headerheader
fluxflux

Definition at line 65 of file JEvtWeightCorsika.hh.

67  {
68  configure(header);
70  }
void configure(const JHead &header) override
Weight configuration.
void configure(const JEvtWeightFactor_t &factor)
Configure event-weight factor.
JAANET::JEvtWeightCorsika::JEvtWeightCorsika ( const JEvtWeightCorsika object)
inline

Copy constructor.

Parameters
objectoriginal object

Definition at line 78 of file JEvtWeightCorsika.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::JEvtWeightCorsika::configure ( const JHead header)
inlineoverride

Weight configuration.

Parameters
headerheader

Definition at line 93 of file JEvtWeightCorsika.hh.

94  {
95  using namespace JPP;
96 
97  if (check(header)) {
98 
99  norm = 1.0 / header.genvol.numberOfEvents;
100 
101  } else {
102 
103  THROW(JValueOutOfRange, "JEvtWeightCorsika::configure(): Provided header is inconsistent with Corsika.");
104  }
105  }
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:1597
bool JAANET::JEvtWeightCorsika::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 114 of file JEvtWeightCorsika.hh.

115  {
116  return is_gseagen(header);
117  }
bool is_gseagen(const JHead &header)
Check for generator.
Definition: JHeadToolkit.hh:61
double JAANET::JEvtWeightCorsika::getWeight ( const Evt evt) const
inlineoverride

Get weight of given event.

Parameters
evtevent
Returns
weight [Hz]

Definition at line 126 of file JEvtWeightCorsika.hh.

127  {
128  using namespace JPP;
129 
130  const double& Nretries = evt.w2list[W2LIST_GSEAGEN_N_RETRIES];
131 
132  if (static_cast<const JFluxHelper&>(*this) &&
133  evt.w.size() > WEIGHTLIST_DIFFERENTIAL_EVENT_RATE) {
134 
135  return evt.w[WEIGHTLIST_DIFFERENTIAL_EVENT_RATE] * getFactor(evt) * getNormalisation(evt) / (1 + Nretries);
136 
137  } else if (evt.w.size() > WEIGHTLIST_RESCALED_EVENT_RATE) {
138 
139  return evt.w[WEIGHTLIST_RESCALED_EVENT_RATE];
140 
141  } else if (evt.w.size() > WEIGHTLIST_EVENT_RATE) {
142 
143  return evt.w[WEIGHTLIST_EVENT_RATE] * getNormalisation(evt) / (1 + Nretries);
144 
145  } else {
146 
147  if (!static_cast<const JFluxHelper&>(*this)) {
148  THROW(JNullPointerException, "JEvtWeightCorsika::getWeight(): Unspecified flux function.");
149  } else {
150  THROW(JIndexOutOfRange, "JEvtWeightCorsika::getWeight(): Empty " << (evt.w.size() < 3 ? "w2-" : "w3-") << "weight.");
151  }
152  }
153  }
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
static const int W2LIST_GSEAGEN_N_RETRIES
Number of extra chances given to each CORSIKA shower to hit the can.
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
std::vector< double > w2list
MC: factors that make up w[1]=w2 (see e.g. Tag list or km3net-dataformat/definitions) ...
Definition: Evt.hh:43
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: