Jpp test-rotations-old
the software that should make you happy
Loading...
Searching...
No Matches
JEvtWeightMiscellaneous.hh
Go to the documentation of this file.
1#ifndef __JAANET__JEVTWEIGHTMISCELLANEOUS__
2#define __JAANET__JEVTWEIGHTMISCELLANEOUS__
3
5
8
9#include "JLang/JException.hh"
10#include "JLang/JClonable.hh"
11
12#include "JAAnet/JHead.hh"
14#include "JAAnet/JEvtWeight.hh"
17
18
19/**
20 * \author bjjung
21 */
22
23namespace JAANET {}
24namespace JPP { using namespace JAANET; }
25
26namespace JAANET {
27
28 using JLANG::JClonable;
29
30
31 /**
32 * Implementation of event weighing for miscellaneous data\n
33 * such as a merged offline file containing neutrinos and atmospheric muons.\n
34 * A uniform weight of 1.0 is applied to all events.
35 */
38 public JClonable<JEvtWeight, JEvtWeightMiscellaneous>
39 {
40 /**
41 * Default constructor.
42 */
46
47
48 /**
49 * Constructor.
50 *
51 * \param header header
52 */
55 {
56 configure(header);
57 }
58
59
60 /**
61 * Constructor.
62 *
63 * \param header header
64 * \param factor factor
65 */
67 const JEvtWeightFactor& factor) :
69 {
70 configure(header);
72 }
73
74
75 /**
76 * Get name.
77 *
78 * \return name
79 */
80 const char* const getName() const override final
81 {
82 return "Miscellaneous";
83 }
84
85
86 /**
87 * Configuration.
88 *
89 * \param header header
90 */
91 void configure(const JHead& header) override final
92 {
93 using namespace JPP;
94
95 if (check(header)) {
96
97 setNormalisation(1.0);
98
99 } else {
100
101 THROW(JValueOutOfRange, "JEvtWeightMiscellaneous::configure(): Provided header is inconsistent with a miscellaneous, merged offline file.");
102 }
103 }
104
105
106 /**
107 * Check whether header is consistent with this event weighter.
108 *
109 * \param header header
110 * \return true if consistent; else false
111 */
112 bool check(const JHead& header) const override final
113 {
114 return header.simul.empty() && !is_daq(header);
115 }
116
117
118 /**
119 * Get weight of given event.
120 *
121 * \param evt event
122 * \return weight [1/s]
123 */
124 double getWeight(const Evt& evt) const override final
125 {
126 if (static_cast<const JEvtWeightFactorHelper&>(*this)) {
127
128 return getFactor(evt) * getNormalisation(evt);
129
130 } else if (evt.w.size() > WEIGHTLIST_RESCALED_EVENT_RATE) {
131
132 return evt.w[WEIGHTLIST_RESCALED_EVENT_RATE];
133
134 } else {
135
136 return getNormalisation(evt);
137 }
138 }
139 };
140}
141
142#endif
Exceptions.
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
Monte Carlo run header.
Definition JHead.hh:1236
Exception for accessing a value in a collection that is outside of its range.
Extensions to Evt data format.
bool is_daq(const JHead &header)
Check for real data.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
The Evt class respresent a Monte Carlo (MC) event as well as an offline event.
Definition Evt.hh:21
Helper class for event-weight factor.
void configure(const pointer_type &p)
Configure event-weight factor.
JEvtWeightFactor & getFactor() const
Get reference to event-weight factor.
Abstract base class for specifiable event-weight factors.
Implementation of event weighing for miscellaneous data such as a merged offline file containing neut...
void configure(const JHead &header) override final
Configuration.
const char *const getName() const override final
Get name.
JEvtWeightMiscellaneous(const JHead &header, const JEvtWeightFactor &factor)
Constructor.
double getWeight(const Evt &evt) const override final
Get weight of given event.
bool check(const JHead &header) const override final
Check whether header is consistent with this event weighter.
JEvtWeightMiscellaneous(const JHead &header)
Constructor.
Template class for object cloning.
Definition JClonable.hh:59
static const int WEIGHTLIST_RESCALED_EVENT_RATE
Rescaled event rate [s-1].
Definition weightlist.hh:17