CalibTracker
SiStripESProducers
plugins
real
SiStripGainFactor.h
Go to the documentation of this file.
1
#ifndef CalibTracker_SiStripESProducers_SiStripGainFactor_h
2
#define CalibTracker_SiStripESProducers_SiStripGainFactor_h
3
4
#include "
FWCore/ParameterSet/interface/ParameterSet.h
"
5
#include "
FWCore/MessageLogger/interface/MessageLogger.h
"
6
7
#include "
CalibFormats/SiStripObjects/interface/SiStripGain.h
"
8
9
class
SiStripGainFactor
{
10
public
:
11
SiStripGainFactor
(
const
edm::ParameterSet
& iConfig)
12
:
automaticMode_
{iConfig.
getParameter
<
bool
>(
"AutomaticNormalization"
)},
13
printdebug_
{iConfig.getUntrackedParameter<
bool
>(
"printDebug"
,
false
)} {}
14
15
void
push_back_norm
(
double
norm) {
norm_
.push_back(norm); }
16
17
void
resetIfBadNorm
() {
18
bool
badNorm = std::find_if(
norm_
.begin(),
norm_
.end(), [](
double
x
) {
return
x
<= 0.; }) !=
norm_
.end();
19
20
if
(!
automaticMode_
&& badNorm) {
21
edm::LogError
(
"SiStripGainESProducer"
) <<
"[SiStripGainESProducer] - ERROR: negative or zero Normalization "
22
"factor provided. Assuming 1 for such factor"
23
<< std::endl;
24
norm_
= std::vector<double>(
norm_
.size(), 1.);
25
}
26
}
27
28
double
get
(
const
SiStripApvGain
&
gain
,
const
int
apvGainIndex)
const
{
29
double
NFactor = 0.;
30
31
if
(
automaticMode_
||
printdebug_
) {
32
std::vector<uint32_t> DetIds;
33
gain
.getDetIds(DetIds);
34
35
double
SumOfGains = 0.;
36
int
NGains
= 0;
37
for
(uint32_t detid : DetIds) {
38
SiStripApvGain::Range
detRange =
gain
.getRange(detid);
39
40
int
iComp = 0;
41
for
(std::vector<float>::const_iterator apvit = detRange.first; apvit != detRange.second; apvit++) {
42
SumOfGains += (*apvit);
43
NGains
++;
44
if
(
printdebug_
)
45
edm::LogInfo
(
"SiStripGainESProducer::produce()"
)
46
<<
"detid/component: "
<< detid <<
"/"
<< iComp <<
" gain factor "
<< *apvit;
47
iComp++;
48
}
49
}
50
51
if
(
automaticMode_
) {
52
if
(SumOfGains > 0 &&
NGains
> 0) {
53
NFactor = SumOfGains /
NGains
;
54
}
else
{
55
edm::LogError
(
56
"SiStripGainESProducer::produce() - ERROR: empty set of gain values received. Cannot compute "
57
"normalization factor. Assuming 1 for such factor"
)
58
<< std::endl;
59
NFactor = 1.;
60
}
61
}
62
}
63
64
if
(!
automaticMode_
) {
65
NFactor =
norm_
[apvGainIndex];
66
}
67
68
if
(
printdebug_
)
69
edm::LogInfo
(
"SiStripGainESProducer"
)
70
<<
" putting A SiStrip Gain object in eventSetup with normalization factor "
<< NFactor;
71
return
NFactor;
72
}
73
74
private
:
75
std::vector<double>
norm_
;
76
bool
automaticMode_
;
77
bool
printdebug_
;
78
};
79
80
#endif
MessageLogger.h
SiStripGainFactor::automaticMode_
bool automaticMode_
Definition:
SiStripGainFactor.h:76
SiStripGain.h
DDAxes::x
edm::LogInfo
Log< level::Info, false > LogInfo
Definition:
MessageLogger.h:125
SiStripGainFactor::SiStripGainFactor
SiStripGainFactor(const edm::ParameterSet &iConfig)
Definition:
SiStripGainFactor.h:11
SiStripGainFactor
Definition:
SiStripGainFactor.h:9
SiStripGainFactor::push_back_norm
void push_back_norm(double norm)
Definition:
SiStripGainFactor.h:15
edm::ParameterSet
Definition:
ParameterSet.h:47
SiStripGainFactor::get
double get(const SiStripApvGain &gain, const int apvGainIndex) const
Definition:
SiStripGainFactor.h:28
edm::LogError
Log< level::Error, false > LogError
Definition:
MessageLogger.h:123
PedestalClient_cfi.gain
gain
Definition:
PedestalClient_cfi.py:37
SiStripGainFactor::printdebug_
bool printdebug_
Definition:
SiStripGainFactor.h:77
SiStripApvGain::Range
std::pair< ContainerIterator, ContainerIterator > Range
Definition:
SiStripApvGain.h:28
SiStripGainFactor::resetIfBadNorm
void resetIfBadNorm()
Definition:
SiStripGainFactor.h:17
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition:
ParameterSet.h:303
NGains
constexpr int NGains
Definition:
EigenMatrixTypes.h:10
ParameterSet.h
SiStripApvGain
Definition:
SiStripApvGain.h:25
SiStripGainFactor::norm_
std::vector< double > norm_
Definition:
SiStripGainFactor.h:75
Generated for CMSSW Reference Manual by
1.8.16