Jpp
Main Page
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Pages
software
JAAnet
JVolume.hh
Go to the documentation of this file.
1
#ifndef __JAANET__JVOLUME__
2
#define __JAANET__JVOLUME__
3
4
#include <cmath>
5
6
#include "TAxis.h"
7
8
#include "
km3net-dataformat/offline/Head.hh
"
9
#include "
JAAnet/JHead.hh
"
10
11
12
/**
13
* \author mdejong
14
*/
15
16
namespace
JAANET {}
17
namespace
JPP {
using namespace
JAANET; }
18
19
namespace
JAANET {
20
21
/**
22
* Auxiliary class for histogramming of effective volume.
23
* In this, it is assumed that events are generated according \f$\frac{dN}{dE} \propto E^{\alpha}\f$.
24
* The weight is expressed in \f$\mathrm{km}^{3}\f$.
25
*/
26
struct
JVolume
{
27
/**
28
* Constructor.
29
*
30
* \param head Monte Carlo run header
31
* \param Elog10 application of log10 to energy
32
*/
33
JVolume
(
const
Head
& head,
34
const
bool
Elog10 =
false
) :
35
elog
(Elog10),
36
Emin
(1.0),
37
Emax
(1.0),
38
alpha
(0.0),
39
Wall
(1.0)
40
{
41
const
JHead
buffer(head);
42
43
if
(buffer.
is_valid
(&
JHead::spectrum
) &&
44
buffer.
is_valid
(&
JHead::cut_nu
) &&
45
buffer.
is_valid
(&
JHead::genvol
)) {
46
47
alpha
= buffer.
spectrum
.
alpha
;
48
Emin
= buffer.
cut_nu
.
Emin
;
49
Emax
= buffer.
cut_nu
.
Emax
;
50
Wall
= 1.0e-9 * (
getW
(
Emax
) -
getW
(
Emin
)) * buffer.
genvol
.
volume
/ buffer.
genvol
.
numberOfEvents
;
// km^3
51
52
}
else
if
(buffer.
is_valid
(&
JHead::cut_in
) &&
53
buffer.
is_valid
(&
JHead::livetime
)) {
54
55
Emin
= buffer.
cut_in
.
Emin
;
56
Emax
= buffer.
cut_in
.
Emax
;
57
Wall
= 1.0 / buffer.
livetime
.
numberOfSeconds
;
// Hz
58
}
59
}
60
61
62
/**
63
* Get spectral index of energy distribution.
64
*
65
* \return spectral index
66
*/
67
inline
double
getAlpha
()
const
68
{
69
return
alpha
;
70
}
71
72
73
/**
74
* Get generation dependent weight.
75
*
76
* \return weight
77
*/
78
inline
double
getWall
()
const
79
{
80
return
Wall
;
81
}
82
83
84
/**
85
* Get minimal abscissa value.
86
*
87
* \return abscissa value
88
*/
89
inline
Double_t
getXmin
()
const
90
{
91
return
getX
(
Emin
);
92
}
93
94
95
/**
96
* Get maximal abscissa value.
97
*
98
* \return abscissa value
99
*/
100
inline
Double_t
getXmax
()
const
101
{
102
return
getX
(
Emax
);
103
}
104
105
106
/**
107
* Get abscissa value.
108
*
109
* \param E energy
110
* \param constrain constrain
111
* \return abscissa value
112
*/
113
inline
Double_t
getX
(
const
Double_t
E
,
double
constrain =
false
)
const
114
{
115
const
double
x = (
elog
? log10(E) :
E
);
116
117
if
(constrain) {
118
if
(x <
getXmin
()) {
119
return
getXmin
();
120
}
else
if
(x >
getXmax
()) {
121
return
getXmax
();
122
}
123
}
124
125
return
x;
126
}
127
128
129
/**
130
* Get energy.
131
*
132
* \param x abscissa value
133
* \param constrain constrain
134
* \return energy
135
*/
136
inline
Double_t
getE
(
const
Double_t x,
double
constrain =
false
)
const
137
{
138
const
double
E
= (
elog
?
pow
(10.0, x) : x);
139
140
if
(constrain) {
141
if
(E <
Emin
) {
142
return
Emin
;
143
}
else
if
(E >
Emax
) {
144
return
Emax
;
145
}
146
}
147
148
return
E
;
149
}
150
151
152
/**
153
* Get bin width corrected energy spectrum dependent weight.
154
*
155
* \param axis axis
156
* \param E energy
157
* \return weight [km^3]
158
*/
159
inline
Double_t
getW
(TAxis* axis,
const
Double_t
E
)
const
160
{
161
const
Int_t index = axis->FindBin(
getX
(E));
162
163
const
Double_t xmin = axis->GetBinLowEdge(index);
164
const
Double_t xmax = axis->GetBinUpEdge (index);
165
166
const
Double_t Wmin =
getW
(
getE
(xmin));
167
const
Double_t Wmax =
getW
(
getE
(xmax));
168
169
return
Wall
/ (Wmax - Wmin);
170
}
171
172
173
/**
174
* Get generation dependent integral value of given energy.
175
*
176
* \param E energy
177
* \return integral value
178
*/
179
inline
double
getW
(
const
double
E
)
const
180
{
181
if
(
alpha
!= -1.0)
182
return
pow
(E, 1.0 +
alpha
) / (1.0 +
alpha
);
183
else
184
return
log(E);
185
}
186
187
188
/**
189
* Multiply weight.
190
*
191
* \param factor factor
192
* \return this volume
193
*/
194
JVolume
&
mul
(
const
double
factor)
195
{
196
Wall
*= factor;
197
198
return
*
this
;
199
}
200
201
202
/**
203
* Divide weight.
204
*
205
* \param factor factor
206
* \return this volume
207
*/
208
JVolume
&
div
(
const
double
factor)
209
{
210
Wall
/= factor;
211
212
return
*
this
;
213
}
214
215
216
protected
:
217
bool
elog
;
//!< histogram option
218
double
Emin
;
//!< minimal energy
219
double
Emax
;
//!< maximal energy
220
double
alpha
;
//!< spectral index
221
double
Wall
;
//!< generation volume
222
};
223
}
224
225
#endif
JAANET::JHead::genvol
JAANET::genvol genvol
Definition:
JHead.hh:1341
JAANET::JVolume::getXmin
Double_t getXmin() const
Get minimal abscissa value.
Definition:
JVolume.hh:89
JAANET::genvol::volume
double volume
Volume [m^3].
Definition:
JHead.hh:653
JAANET::spectrum::alpha
double alpha
Energy spectrum: .
Definition:
JHead.hh:500
JAANET::genvol::numberOfEvents
double numberOfEvents
Number of events.
Definition:
JHead.hh:654
JAANET::JVolume::getXmax
Double_t getXmax() const
Get maximal abscissa value.
Definition:
JVolume.hh:100
JAANET::cut::Emax
double Emax
Maximal energy [GeV].
Definition:
JHead.hh:352
JAANET::JVolume::getX
Double_t getX(const Double_t E, double constrain=false) const
Get abscissa value.
Definition:
JVolume.hh:113
JAANET::JVolume::Wall
double Wall
generation volume
Definition:
JVolume.hh:221
JAANET::JVolume::getWall
double getWall() const
Get generation dependent weight.
Definition:
JVolume.hh:78
JAANET::JVolume::getAlpha
double getAlpha() const
Get spectral index of energy distribution.
Definition:
JVolume.hh:67
JAANET::JVolume
Auxiliary class for histogramming of effective volume.
Definition:
JVolume.hh:26
JAANET::JVolume::JVolume
JVolume(const Head &head, const bool Elog10=false)
Constructor.
Definition:
JVolume.hh:33
JAANET::JHead::livetime
JAANET::livetime livetime
Definition:
JHead.hh:1345
JAANET::JVolume::div
JVolume & div(const double factor)
Divide weight.
Definition:
JVolume.hh:208
JAANET::JVolume::getW
Double_t getW(TAxis *axis, const Double_t E) const
Get bin width corrected energy spectrum dependent weight.
Definition:
JVolume.hh:159
JAANET::JVolume::getE
Double_t getE(const Double_t x, double constrain=false) const
Get energy.
Definition:
JVolume.hh:136
JMATH::pow
T pow(const T &x, const double y)
Power .
Definition:
JMath.hh:98
JAANET::JHead::spectrum
JAANET::spectrum spectrum
Definition:
JHead.hh:1338
JAANET::JVolume::alpha
double alpha
spectral index
Definition:
JVolume.hh:220
JAANET::JVolume::mul
JVolume & mul(const double factor)
Multiply weight.
Definition:
JVolume.hh:194
JAANET::JHead
Monte Carlo run header.
Definition:
JHead.hh:1050
Head
The Head class reflects the header of Monte-Carlo event files, which consists of keys (also referred ...
Definition:
Head.hh:66
JAANET::JVolume::getW
double getW(const double E) const
Get generation dependent integral value of given energy.
Definition:
JVolume.hh:179
JAANET::JHead::cut_in
JAANET::cut_in cut_in
Definition:
JHead.hh:1336
JAANET::JVolume::elog
bool elog
histogram option
Definition:
JVolume.hh:217
JAANET::JHead::cut_nu
JAANET::cut_nu cut_nu
Definition:
JHead.hh:1337
Head.hh
JAANET::JHead::is_valid
bool is_valid(T JHead::*pd) const
Check validity of given data member in JHead.
Definition:
JHead.hh:1120
JAANET::cut::Emin
double Emin
Minimal energy [GeV].
Definition:
JHead.hh:351
JAANET::livetime::numberOfSeconds
double numberOfSeconds
Live time [s].
Definition:
JHead.hh:829
JAANET::JVolume::Emin
double Emin
minimal energy
Definition:
JVolume.hh:218
E
then usage $script[input file[working directory[option]]] nWhere option can be E
Definition:
JMuonPostfit.sh:37
JHead.hh
JAANET::JVolume::Emax
double Emax
maximal energy
Definition:
JVolume.hh:219
Generated by
1.8.5