Jpp - the software that should make you happy
Main Page
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Pages
software
JAAnet
JWeightGSeaGen.hh
Go to the documentation of this file.
1
#ifndef __JAANET__JWEIGHTGSEAGEN__
2
#define __JAANET__JWEIGHTGSEAGEN__
3
4
#include "
km3net-dataformat/offline/Head.hh
"
5
#include "
km3net-dataformat/offline/Evt.hh
"
6
7
#include "
JLang/JException.hh
"
8
#include "
JLang/JClonable.hh
"
9
10
#include "
JAAnet/JHead.hh
"
11
#include "
JAAnet/JFlux.hh
"
12
#include "
JAAnet/JFluxHelper.hh
"
13
#include "
JAAnet/JHeadToolkit.hh
"
14
#include "
JAAnet/JWeightEvent.hh
"
15
16
/**
17
* \author bjung
18
*/
19
20
namespace
JAANET {
21
22
using
JLANG::JClonable
;
23
using
JLANG::JIndexOutOfRange
;
24
using
JLANG::JNullPointerException
;
25
26
27
/**
28
* Implementation of event weighting for GSeaGen data.
29
*/
30
struct
JWeightGSeaGen
:
31
public
JClonable
<JWeightEvent, JWeightGSeaGen>,
32
public
JFluxHelper
33
{
34
/**
35
* Default Constructor.
36
*/
37
JWeightGSeaGen
() :
38
JFluxHelper
(),
39
W
(0.0)
40
{}
41
42
43
/**
44
* Constructor.
45
*
46
* \param header header
47
*/
48
JWeightGSeaGen
(
const
JHead
& header) :
49
JFluxHelper
()
50
{
51
configure
(header);
52
}
53
54
55
/**
56
* Constructor.
57
*
58
* \param header header
59
* \param flux flux
60
*/
61
JWeightGSeaGen
(
const
JHead
& header,
62
const
JFlux
&
flux
)
63
{
64
configure
(header);
65
JFluxHelper::configure
(flux);
66
}
67
68
69
/**
70
* Copy constructor.
71
*
72
* \param object original object
73
*/
74
JWeightGSeaGen
(
const
JWeightGSeaGen
&
object
)
75
{
76
this->
W
=
object
.W;
77
78
if
(
object
.
is_valid
()) {
79
JFluxHelper::configure
(*(
object
.
get
()));
80
}
81
}
82
83
84
/**
85
* Weight configuration.
86
*
87
* \param header header
88
*/
89
void
configure
(
const
JHead
& header)
override
90
{
91
const
double
N
= header.
genvol
.
numberOfEvents
;
92
const
double
dt = (header.
time_interval
.
t2
- header.
time_interval
.
t1
> 0.0 ?
93
header.
time_interval
.
t2
- header.
time_interval
.
t1
:
94
header.
tgen
.
numberOfSeconds
);
95
96
if
(
check
(header) && N > 0.0 && dt > 0.0) {
97
98
W
= 1.0 / N / dt;
99
100
}
else
{
101
102
THROW
(
JValueOutOfRange
,
"JWeightGSeaGen::configure(): Provided header is inconsistent with GSeaGen."
);
103
}
104
}
105
106
107
/**
108
* Check whether header is consistent with this event weighter.
109
*
110
* \param header header
111
* \return true if consistent; else false
112
*/
113
bool
check
(
const
JHead
& header)
const override
114
{
115
return
is_gseagen
(header);
116
}
117
118
119
/**
120
* Get weight of given event.
121
*
122
* \param evt event
123
* \return weight [Hz]
124
*/
125
double
getWeight
(
const
Evt
& evt)
const override
126
{
127
if
(
is_valid
() && evt.
w
.size() > 1) {
128
129
return
W
* evt.
w
[1] *
getFlux
(evt);
130
131
}
else
if
(evt.
w
.size() > 2) {
132
133
return
W
* evt.
w
[2];
134
135
}
else
{
136
137
if
(!
is_valid
()) {
138
THROW
(
JNullPointerException
,
"JWeightGSeaGen::getWeight(): Unspecified flux function."
);
139
}
else
{
140
THROW
(
JIndexOutOfRange
,
"JWeightGSeaGen::getWeight(): Empty "
<< (evt.
w
.size() < 3 ?
"w2-"
:
"w3-"
) <<
"weight."
);
141
}
142
}
143
}
144
145
146
private
:
147
148
double
W
;
149
};
150
}
151
152
#endif
JAANET::JWeightGSeaGen::getWeight
double getWeight(const Evt &evt) const override
Get weight of given event.
Definition:
JWeightGSeaGen.hh:125
JAANET::JHead::genvol
JAANET::genvol genvol
Definition:
JHead.hh:1408
JException.hh
Exceptions.
JFlux.hh
JAANET::time_interval::t1
double t1
Start time in seconds.
Definition:
JHead.hh:1043
JFluxHelper.hh
JAANET::is_gseagen
bool is_gseagen(const JHead &header)
Check for generator.
Definition:
JHeadToolkit.hh:60
JAANET::JFluxHelper::configure
void configure(const JFlux &function)
Flux configuration.
Definition:
JFluxHelper.hh:51
JAANET::genvol::numberOfEvents
double numberOfEvents
Number of events.
Definition:
JHead.hh:654
THROW
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
Definition:
JException.hh:670
JAANET::time_interval::t2
double t2
Stop time in seconds.
Definition:
JHead.hh:1044
Evt::w
std::vector< double > w
MC: Weights w[0]=w1, w[1]=w2, w[2]]=w3 (see e.g. Tag list)
Definition:
Evt.hh:39
JLANG::JAbstractPointer::is_valid
bool is_valid() const
Check validity of pointer.
Definition:
JAbstractPointer.hh:83
JClonable.hh
JAANET::JWeightGSeaGen::configure
void configure(const JHead &header) override
Weight configuration.
Definition:
JWeightGSeaGen.hh:89
JAANET::JWeightGSeaGen::check
bool check(const JHead &header) const override
Check whether header is consistent with this event weighter.
Definition:
JWeightGSeaGen.hh:113
JWeightEvent.hh
JLANG::JNullPointerException
Exception for null pointer operation.
Definition:
JException.hh:216
JAANET::flux
Neutrino flux.
Definition:
JHead.hh:839
JAANET::JFluxHelper
Helper class for event weighing.
Definition:
JFluxHelper.hh:23
JLANG::JClonable
Template class for object cloning.
Definition:
JClonable.hh:20
JAANET::JFluxHelper::getFlux
double getFlux(const Evt &evt) const
Get flux of given event.
Definition:
JFluxHelper.hh:63
JAANET::JWeightGSeaGen
Implementation of event weighting for GSeaGen data.
Definition:
JWeightGSeaGen.hh:30
JAANET::JFlux
Low-level interface for retrieving flux corresponding to an event.
Definition:
JFlux.hh:22
JAANET::JHead
Monte Carlo run header.
Definition:
JHead.hh:1113
JAANET::JHead::time_interval
JAANET::time_interval time_interval
Definition:
JHead.hh:1417
JAANET::JWeightGSeaGen::W
double W
Definition:
JWeightGSeaGen.hh:148
Evt.hh
JAANET::JWeightGSeaGen::JWeightGSeaGen
JWeightGSeaGen()
Default Constructor.
Definition:
JWeightGSeaGen.hh:37
JAANET::JHead::tgen
JAANET::tgen tgen
Definition:
JHead.hh:1416
JHeadToolkit.hh
JAANET::JWeightGSeaGen::JWeightGSeaGen
JWeightGSeaGen(const JHead &header)
Constructor.
Definition:
JWeightGSeaGen.hh:48
JLANG::JValueOutOfRange
Exception for accessing a value in a collection that is outside of its range.
Definition:
JException.hh:162
JLANG::JIndexOutOfRange
Exception for accessing an index in a collection that is outside of its range.
Definition:
JException.hh:90
JAANET::tgen::numberOfSeconds
double numberOfSeconds
Time in seconds.
Definition:
JHead.hh:1014
Head.hh
N
then usage $script[input file[working directory[option]]] nWhere option can be N
Definition:
JMuonPostfit.sh:37
Evt
The Evt class respresent a Monte Carlo (MC) event as well as an offline event.
Definition:
Evt.hh:19
JHead.hh
JAANET::JWeightGSeaGen::JWeightGSeaGen
JWeightGSeaGen(const JHead &header, const JFlux &flux)
Constructor.
Definition:
JWeightGSeaGen.hh:61
JAANET::JWeightGSeaGen::JWeightGSeaGen
JWeightGSeaGen(const JWeightGSeaGen &object)
Copy constructor.
Definition:
JWeightGSeaGen.hh:74
Generated by
1.8.5