DataFormats
EcalRecHit
src
EcalUncalibratedRecHit.cc
Go to the documentation of this file.
1
#include "
DataFormats/EcalRecHit/interface/EcalUncalibratedRecHit.h
"
2
#include "
FWCore/MessageLogger/interface/MessageLogger.h
"
3
#include <cmath>
4
5
EcalUncalibratedRecHit::EcalUncalibratedRecHit
()
6
: amplitude_(0.), amplitudeError_(0.), pedestal_(0.), jitter_(0.), chi2_(10000.), flags_(0), aux_(0) {
7
const
unsigned
int
nsample =
EcalDataFrame::MAXSAMPLES
;
8
for
(
unsigned
int
ibx = 0; ibx < nsample; ++ibx)
9
OOTamplitudes_
[ibx] = 0.;
10
}
11
12
EcalUncalibratedRecHit::EcalUncalibratedRecHit
(
13
const
DetId
&
id
,
float
ampl,
float
ped,
float
jit,
float
chi2
, uint32_t
flags
, uint32_t
aux
)
14
: amplitude_(ampl),
15
amplitudeError_(0.),
16
pedestal_(ped),
17
jitter_(jit),
18
chi2_(
chi2
),
19
flags_(
flags
),
20
aux_(
aux
),
21
id_(
id
) {
22
const
unsigned
int
nsample =
EcalDataFrame::MAXSAMPLES
;
23
for
(
unsigned
int
ibx = 0; ibx < nsample; ++ibx)
24
OOTamplitudes_
[ibx] = 0.;
25
}
26
27
bool
EcalUncalibratedRecHit::isSaturated
()
const
{
return
EcalUncalibratedRecHit::checkFlag
(
kSaturated
); }
28
29
float
EcalUncalibratedRecHit::jitterError
()
const
{
30
// stored in ps, but return BXs to match with jitter units
31
uint32_t
jitterErrorBits
= 0xFF &
aux_
;
32
// all bits off --> time reco bailed out (return negative value)
33
if
((0xFF &
jitterErrorBits
) == 0x00)
34
return
-1;
35
// all bits on --> time error over 5 ns (return large value)
36
if
((0xFF &
jitterErrorBits
) == 0xFF)
37
return
10000;
38
39
float
LSB = 1.26008;
40
uint8_t
exponent
=
jitterErrorBits
>> 5;
41
uint8_t significand =
jitterErrorBits
& ~(0x7 << 5);
42
return
(
float
)(
std::pow
(2,
exponent
) * significand * LSB) / (25. * 1000);
43
}
44
45
void
EcalUncalibratedRecHit::setJitterError
(
float
jitterErr) {
46
// use 8 bits (3 exp, 5 mant) and store in ps
47
// has range of 5 ps - 5000 ps
48
// expect input in BX units
49
// all bits off --> time reco bailed out
50
if
(jitterErr <= 0) {
51
aux_
= (~0xFF &
aux_
);
52
return
;
53
}
54
// all bits on --> time error over 5 ns
55
if
(25 * jitterErr >= 5) {
56
aux_
= (0xFF |
aux_
);
57
return
;
58
}
59
60
float
LSB = 1.26008;
61
float
quantityInLSB = (1000 * 25 * jitterErr) / LSB;
62
int
log2OfQuantity = (
int
)(log2(quantityInLSB));
63
int
exponentTmp = log2OfQuantity - 4;
64
uint8_t
exponent
= 0;
65
if
(exponentTmp > 0)
66
exponent
= exponentTmp;
67
uint8_t significand = (
int
)(std::lround(quantityInLSB /
std::pow
(2,
exponent
)));
68
uint32_t
jitterErrorBits
=
exponent
<< 5 | significand;
69
70
if
((0xFF &
jitterErrorBits
) == 0xFF)
71
jitterErrorBits
= 0xFE;
72
if
((0xFF &
jitterErrorBits
) == 0x00)
73
jitterErrorBits
= 0x01;
74
75
aux_
= (~0xFF &
aux_
) | (
jitterErrorBits
& 0xFF);
76
}
77
78
bool
EcalUncalibratedRecHit::isJitterValid
()
const
{
79
if
(
jitterError
() <= 0)
80
return
false
;
81
else
82
return
true
;
83
}
84
85
bool
EcalUncalibratedRecHit::isJitterErrorValid
()
const
{
86
if
(!
isJitterValid
())
87
return
false
;
88
if
(
jitterError
() >= 10000)
89
return
false
;
90
91
return
true
;
92
}
93
94
uint8_t
EcalUncalibratedRecHit::jitterErrorBits
()
const
{
95
uint8_t
jitterErrorBits
= 0xFF &
aux_
;
96
return
jitterErrorBits
;
97
}
98
99
void
EcalUncalibratedRecHit::setFlagBit
(
EcalUncalibratedRecHit::Flags
flag
) {
100
if
(
flag
==
kGood
) {
101
//then set all bits to zero;
102
flags_
= 0;
103
return
;
104
}
105
// else set the flagbit
106
flags_
|= 0x1 <<
flag
;
107
}
108
109
bool
EcalUncalibratedRecHit::checkFlag
(
EcalUncalibratedRecHit::Flags
flag
)
const
{
110
if
(
flag
==
kGood
) {
111
if
(!
flags_
)
112
return
true
;
113
else
114
return
false
;
115
}
// if all flags are unset, then hit is good
116
return
flags_
& (0x1 <<
flag
);
117
}
EcalDataFrame::MAXSAMPLES
static constexpr int MAXSAMPLES
Definition:
EcalDataFrame.h:48
MessageLogger.h
EcalUncalibratedRecHit::isJitterErrorValid
bool isJitterErrorValid() const
Definition:
EcalUncalibratedRecHit.cc:85
HLT_2018_cff.exponent
exponent
Definition:
HLT_2018_cff.py:51310
EcalUncalibratedRecHit::jitterError
float jitterError() const
Definition:
EcalUncalibratedRecHit.cc:29
EcalUncalibratedRecHit::jitterErrorBits
uint8_t jitterErrorBits() const
Definition:
EcalUncalibratedRecHit.cc:94
EcalUncalibratedRecHit.h
EcalUncalibratedRecHit::kGood
Definition:
EcalUncalibratedRecHit.h:13
hltPixelTracks_cff.chi2
chi2
Definition:
hltPixelTracks_cff.py:25
EcalUncalibratedRecHit::EcalUncalibratedRecHit
EcalUncalibratedRecHit()
Definition:
EcalUncalibratedRecHit.cc:5
EcalUncalibratedRecHit::setFlagBit
void setFlagBit(Flags flag)
Definition:
EcalUncalibratedRecHit.cc:99
DetId
Definition:
DetId.h:17
EcalUncalibratedRecHit::isJitterValid
bool isJitterValid() const
Definition:
EcalUncalibratedRecHit.cc:78
EcalUncalibratedRecHit::aux_
uint32_t aux_
Definition:
EcalUncalibratedRecHit.h:68
EcalUncalibratedRecHit::checkFlag
bool checkFlag(Flags flag) const
Definition:
EcalUncalibratedRecHit.cc:109
printConversionInfo.aux
aux
Definition:
printConversionInfo.py:19
createfilelist.int
int
Definition:
createfilelist.py:10
EcalUncalibratedRecHit::flags_
uint32_t flags_
Definition:
EcalUncalibratedRecHit.h:67
EcalUncalibratedRecHit::Flags
Flags
Definition:
EcalUncalibratedRecHit.h:12
EcalUncalibratedRecHit::setJitterError
void setJitterError(float jitterErr)
Definition:
EcalUncalibratedRecHit.cc:45
triggerObjects_cff.id
id
Definition:
triggerObjects_cff.py:31
EcalUncalibratedRecHit::isSaturated
bool isSaturated() const
Definition:
EcalUncalibratedRecHit.cc:27
EcalUncalibratedRecHit::kSaturated
Definition:
EcalUncalibratedRecHit.h:15
funct::pow
Power< A, B >::type pow(const A &a, const B &b)
Definition:
Power.h:30
HLT_2018_cff.flags
flags
Definition:
HLT_2018_cff.py:11758
EcalUncalibratedRecHit::OOTamplitudes_
float OOTamplitudes_[EcalDataFrame::MAXSAMPLES]
Definition:
EcalUncalibratedRecHit.h:65
RemoveAddSevLevel.flag
flag
Definition:
RemoveAddSevLevel.py:116
Generated for CMSSW Reference Manual by
1.8.16