CalibFormats
CastorObjects
src
CastorChannelCoder.cc
Go to the documentation of this file.
1
7
#include <iostream>
8
9
#include "
CalibFormats/CastorObjects/interface/CastorChannelCoder.h
"
10
#include "
CalibFormats/CastorObjects/interface/QieShape.h
"
11
12
CastorChannelCoder::CastorChannelCoder
(
const
float
fOffset[16],
const
float
fSlope[16]) {
// [CapId][Range]
13
for
(
int
range
= 0;
range
< 4;
range
++) {
14
for
(
int
capId = 0; capId < 4; capId++) {
15
mOffset
[capId][
range
] = fOffset[
index
(capId,
range
)];
16
mSlope
[capId][
range
] = fSlope[
index
(capId,
range
)];
17
}
18
}
19
}
20
21
double
CastorChannelCoder::charge
(
const
reco::castor::QieShape
& fShape,
int
fAdc,
int
fCapId)
const
{
22
int
range
= (fAdc >> 6) & 0x3;
23
double
charge
= fShape.
linearization
(fAdc) /
mSlope
[fCapId][
range
] +
mOffset
[fCapId][
range
];
24
// std::cout << "CastorChannelCoder::charge-> " << fAdc << '/' << fCapId
25
// << " result: " << charge << std::endl;
26
return
charge
;
27
}
28
29
int
CastorChannelCoder::adc
(
const
reco::castor::QieShape
& fShape,
double
fCharge,
int
fCapId)
const
{
30
int
adc
= -1;
//nothing found yet
31
// search for the range
32
for
(
int
range
= 0;
range
< 4;
range
++) {
33
double
qieCharge = (fCharge -
mOffset
[fCapId][
range
]) *
mSlope
[fCapId][
range
];
34
double
qieChargeMax = fShape.
linearization
(32 *
range
+ 31) + 0.5 * fShape.
binSize
(32 *
range
+ 31);
35
if
(
range
== 3 && qieCharge > qieChargeMax)
36
adc
= 127;
// overflow
37
if
(qieCharge > qieChargeMax)
38
continue
;
// next range
39
for
(
int
bin
= 32 *
range
;
bin
< 32 * (
range
+ 1);
bin
++) {
40
if
(qieCharge < fShape.
linearization
(
bin
) + 0.5 * fShape.
binSize
(
bin
)) {
41
adc
=
bin
;
42
break
;
43
}
44
}
45
if
(
adc
>= 0)
46
break
;
// found
47
}
48
if
(
adc
< 0)
49
adc
= 0;
// underflow
50
51
// std::cout << "CastorChannelCoder::adc-> " << fCharge << '/' << fCapId
52
// << " result: " << adc << std::endl;
53
return
adc
;
54
}
CastorChannelCoder::mOffset
double mOffset[4][4]
Definition:
CastorChannelCoder.h:26
FastTimerService_cff.range
range
Definition:
FastTimerService_cff.py:34
reco::castor::QieShape
Definition:
QieShape.h:13
CastorChannelCoder.h
CastorChannelCoder::index
int index(int fCapId, int Range)
Definition:
CastorChannelCoder.h:23
reco::castor::QieShape::binSize
double binSize(int fAdc) const
Definition:
QieShape.h:19
CastorChannelCoder::mSlope
double mSlope[4][4]
Definition:
CastorChannelCoder.h:27
CastorChannelCoder::CastorChannelCoder
CastorChannelCoder(const float fOffset[16], const float fSlope[16])
Definition:
CastorChannelCoder.cc:12
QieShape.h
newFWLiteAna.bin
bin
Definition:
newFWLiteAna.py:161
CastorChannelCoder::charge
double charge(const reco::castor::QieShape &fShape, int fAdc, int fCapId) const
ADC[0..127]+capid[0..3]->fC conversion.
Definition:
CastorChannelCoder.cc:21
reco::castor::QieShape::linearization
double linearization(int fAdc) const
Definition:
QieShape.h:17
CastorChannelCoder::adc
int adc(const reco::castor::QieShape &fShape, double fCharge, int fCapId) const
fC + capid[0..3] -> ADC conversion
Definition:
CastorChannelCoder.cc:29
Generated for CMSSW Reference Manual by
1.8.16