Jpp
Main Page
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Pages
software
JFit
JEnergy.hh
Go to the documentation of this file.
1
#ifndef __JFIT__JENERGY__
2
#define __JFIT__JENERGY__
3
4
#include <cmath>
5
#include <limits>
6
7
#include "
JLang/JComparable.hh
"
8
#include "
JMath/JMath.hh
"
9
10
11
/**
12
* \author mdejong
13
*/
14
15
namespace
JFIT {}
16
namespace
JPP {
using namespace
JFIT; }
17
18
namespace
JFIT {
19
20
/**
21
* Data structure for fit of energy.
22
* The internal value is equal to the logarithm of the energy.
23
*/
24
class
JEnergy
:
25
public
JMATH::JMath
<JEnergy>,
26
public
JLANG::JComparable
<JEnergy>
27
{
28
public
:
29
/**
30
* Default constructor.
31
*/
32
JEnergy
() :
33
__X
(0.0)
34
{}
35
36
37
/**
38
* Constructor.
39
*
40
* \param X x-value [log(E/GeV)]
41
*/
42
JEnergy
(
const
double
X) :
43
__X
(X)
44
{}
45
46
47
/**
48
* Get Energy.
49
*
50
* \return Energy
51
*/
52
const
JEnergy
&
getEnergy
()
const
53
{
54
return
static_cast<
const
JEnergy
&
>
(*this);
55
}
56
57
58
/**
59
* Set Energy.
60
*
61
* \param energy Energy
62
*/
63
void
setEnergy
(
const
JEnergy
&
energy
)
64
{
65
static_cast<
JEnergy
&
>
(*this) =
energy
;
66
}
67
68
69
/**
70
* Less than method.
71
*
72
* \param X Energy [log(E/GeV)]
73
* \return true if this energy less than given energy; else false
74
*/
75
bool
less
(
const
JEnergy
& X)
const
76
{
77
return
__X
< X.
__X
;
78
}
79
80
81
/**
82
* Prefix unary minus.
83
*
84
* \return Energy
85
*/
86
JEnergy
&
negate
()
87
{
88
__X
= -
__X
;
89
90
return
*
this
;
91
}
92
93
94
/**
95
* Addition operator.
96
*
97
* \param value Energy
98
* \return Energy
99
*/
100
JEnergy
&
add
(
const
JEnergy
& value)
101
{
102
__X
+= value.
__X
;
103
104
return
*
this
;
105
}
106
107
108
/**
109
* Subtraction operator.
110
*
111
* \param value Energy
112
* \return Energy
113
*/
114
JEnergy
&
sub
(
const
JEnergy
& value)
115
{
116
__X
-= value.
__X
;
117
118
return
*
this
;
119
}
120
121
122
/**
123
* Multiplication operator.
124
*
125
* \param value multiplication factor
126
* \return Energy
127
*/
128
JEnergy
&
mul
(
const
double
value)
129
{
130
__X
*= value;
131
132
return
*
this
;
133
}
134
135
136
/**
137
* Division operator.
138
*
139
* \param value multiplication factor
140
* \return Energy
141
*/
142
JEnergy
&
div
(
const
double
value)
143
{
144
__X
/= value;
145
146
return
*
this
;
147
}
148
149
150
/**
151
* Get energy.
152
*
153
* \return Energy [log(E/GeV)]
154
*/
155
double
getX
()
const
156
{
157
return
__X
;
158
}
159
160
161
/**
162
* Get energy.
163
*
164
* \return Energy [GeV]
165
*/
166
double
getE
()
const
167
{
168
return
pow(10.0,
__X
);
169
}
170
171
172
/**
173
* Put energy.
174
*
175
* \param E Energy [GeV]
176
*/
177
void
putE
(
const
double
E
)
178
{
179
__X
= log10(E);
180
}
181
182
183
/**
184
* Get derivative of energy.
185
*
186
* \return dE/dx [GeV]
187
*/
188
double
getDE
()
const
189
{
190
return
getE
() * log(10.0);
191
}
192
193
194
/**
195
* Get absolute value.
196
*
197
* \param energy energy
198
*/
199
friend
inline
double
fabs
(
const
JEnergy
&
energy
)
200
{
201
return
std::fabs(energy.
__X
);
202
}
203
204
205
/**
206
* Get minimum possible value.
207
*
208
* \return minimum possible value
209
*/
210
static
JEnergy
min
()
211
{
212
return
JEnergy
(-std::numeric_limits<double>::max());
213
}
214
215
216
/**
217
* Get maximum possible value.
218
*
219
* \return maximum possible value
220
*/
221
static
JEnergy
max
()
222
{
223
return
JEnergy
(+std::numeric_limits<double>::max());
224
}
225
226
227
/**
228
* Read object from input.
229
*
230
* \param in input stream
231
* \param object object
232
* \return input stream
233
*/
234
friend
inline
std::istream&
operator>>
(std::istream&
in
,
JEnergy
&
object
)
235
{
236
in >>
object
.__X;
237
238
return
in
;
239
}
240
241
242
/**
243
* Write object to output.
244
*
245
* \param out output stream
246
* \param object object
247
* \return output stream
248
*/
249
friend
inline
std::ostream&
operator<<
(std::ostream& out,
const
JEnergy
&
object
)
250
{
251
out <<
object
.__X;
252
253
return
out;
254
}
255
256
257
typedef
double
JEnergy
::*
parameter_type
;
258
259
static
parameter_type
pE
() {
return
&
JEnergy::__X
; }
260
261
protected
:
262
double
__X
;
263
};
264
}
265
266
#endif
JFIT::JEnergy::getE
double getE() const
Get energy.
Definition:
JEnergy.hh:166
JFIT::JEnergy::max
static JEnergy max()
Get maximum possible value.
Definition:
JEnergy.hh:221
JFIT::JEnergy::__X
double __X
Definition:
JEnergy.hh:262
JMATH::JMath
Auxiliary base class for aritmetic operations of derived class types.
Definition:
JMath.hh:26
JFIT::JEnergy::getDE
double getDE() const
Get derivative of energy.
Definition:
JEnergy.hh:188
in
esac print_variable DETECTOR INPUT_FILE OUTPUT_FILE CDF for TYPE in
Definition:
JSirene.sh:45
JFIT::JEnergy::less
bool less(const JEnergy &X) const
Less than method.
Definition:
JEnergy.hh:75
JFIT::JEnergy::JEnergy
JEnergy()
Default constructor.
Definition:
JEnergy.hh:32
JFIT::JEnergy::sub
JEnergy & sub(const JEnergy &value)
Subtraction operator.
Definition:
JEnergy.hh:114
JFIT::JEnergy::JEnergy
JEnergy(const double X)
Constructor.
Definition:
JEnergy.hh:42
JFIT::JEnergy::fabs
friend double fabs(const JEnergy &energy)
Get absolute value.
Definition:
JEnergy.hh:199
JFIT::JEnergy::div
JEnergy & div(const double value)
Division operator.
Definition:
JEnergy.hh:142
JFIT::JEnergy::negate
JEnergy & negate()
Prefix unary minus.
Definition:
JEnergy.hh:86
JFIT::JEnergy::parameter_type
double JEnergy::* parameter_type
Definition:
JEnergy.hh:257
JComparable.hh
JLANG::JComparable
Template definition of auxiliary base class for comparison of data structures.
Definition:
JComparable.hh:24
JFIT::JEnergy::getX
double getX() const
Get energy.
Definition:
JEnergy.hh:155
JFIT::JEnergy::pE
static parameter_type pE()
Definition:
JEnergy.hh:259
JFIT::JEnergy::putE
void putE(const double E)
Put energy.
Definition:
JEnergy.hh:177
JFIT::JEnergy::operator>>
friend std::istream & operator>>(std::istream &in, JEnergy &object)
Read object from input.
Definition:
JEnergy.hh:234
energy
then for APP in event gandalf start energy
Definition:
JMuonMCEvt.sh:42
JFIT::JEnergy::min
static JEnergy min()
Get minimum possible value.
Definition:
JEnergy.hh:210
JMath.hh
Base class for data structures with artithmetic capabilities.
JFIT::JEnergy
Data structure for fit of energy.
Definition:
JEnergy.hh:24
JFIT::JEnergy::getEnergy
const JEnergy & getEnergy() const
Get Energy.
Definition:
JEnergy.hh:52
JFIT::JEnergy::setEnergy
void setEnergy(const JEnergy &energy)
Set Energy.
Definition:
JEnergy.hh:63
JFIT::JEnergy::operator<<
friend std::ostream & operator<<(std::ostream &out, const JEnergy &object)
Write object to output.
Definition:
JEnergy.hh:249
JFIT::JEnergy::mul
JEnergy & mul(const double value)
Multiplication operator.
Definition:
JEnergy.hh:128
JFIT::JEnergy::add
JEnergy & add(const JEnergy &value)
Addition operator.
Definition:
JEnergy.hh:100
E
then usage $script[input file[working directory[option]]] nWhere option can be E
Definition:
JMuonPostfit.sh:37
Generated by
1.8.5