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