CalibTracker
SiStripESProducers
plugins
fake
SiStripApvGainFakeESSource.cc
Go to the documentation of this file.
1
// -*- C++ -*-
2
//
3
// Package: CalibTracker/SiStripESProducers
4
// Class: SiStripApvGainFakeESSource
5
//
14
// system include files
15
#include <memory>
16
17
// user include files
18
#include "
FWCore/Framework/interface/ESProducer.h
"
19
#include "
FWCore/Framework/interface/EventSetupRecordIntervalFinder.h
"
20
21
#include "
CondFormats/SiStripObjects/interface/SiStripApvGain.h
"
22
#include "
CondFormats/DataRecord/interface/SiStripCondDataRecords.h
"
23
#include "
FWCore/ParameterSet/interface/ParameterSet.h
"
24
25
#include "
CalibTracker/SiStripCommon/interface/SiStripDetInfoFileReader.h
"
26
27
class
SiStripApvGainFakeESSource
:
public
edm::ESProducer
,
public
edm::EventSetupRecordIntervalFinder
{
28
public
:
29
SiStripApvGainFakeESSource
(
const
edm::ParameterSet
&);
30
~SiStripApvGainFakeESSource
()
override
;
31
32
void
setIntervalFor
(
const
edm::eventsetup::EventSetupRecordKey
&,
33
const
edm::IOVSyncValue
& iov,
34
edm::ValidityInterval
& iValidity)
override
;
35
36
typedef
std::unique_ptr<SiStripApvGain>
ReturnType
;
37
ReturnType
produce
(
const
SiStripApvGainRcd
&);
38
39
private
:
40
std::string
m_genMode
;
41
double
m_meanGain
;
42
double
m_sigmaGain
;
43
double
m_minimumPosValue
;
44
uint32_t
m_printDebug
;
45
SiStripDetInfoFileReader
m_detInfoFileReader
;
46
};
47
48
#include "
FWCore/MessageLogger/interface/MessageLogger.h
"
49
#include "CLHEP/Random/RandGauss.h"
50
51
SiStripApvGainFakeESSource::SiStripApvGainFakeESSource
(
const
edm::ParameterSet
& iConfig) {
52
setWhatProduced
(
this
);
53
findingRecord<SiStripApvGainRcd>();
54
55
m_genMode
= iConfig.
getParameter
<
std::string
>(
"genMode"
);
56
m_meanGain
= iConfig.
getParameter
<
double
>(
"MeanGain"
);
57
m_sigmaGain
= iConfig.
getParameter
<
double
>(
"SigmaGain"
);
58
m_minimumPosValue
= iConfig.
getParameter
<
double
>(
"MinPositiveGain"
);
59
m_printDebug
= iConfig.
getUntrackedParameter
<uint32_t>(
"printDebug"
, 5);
60
m_detInfoFileReader
=
61
SiStripDetInfoFileReader
{iConfig.
getParameter
<
edm::FileInPath
>(
"SiStripDetInfoFile"
).
fullPath
()};
62
}
63
64
SiStripApvGainFakeESSource::~SiStripApvGainFakeESSource
() {}
65
66
void
SiStripApvGainFakeESSource::setIntervalFor
(
const
edm::eventsetup::EventSetupRecordKey
&,
67
const
edm::IOVSyncValue
& iov,
68
edm::ValidityInterval
& iValidity) {
69
iValidity =
edm::ValidityInterval
{iov.
beginOfTime
(), iov.
endOfTime
()};
70
}
71
72
// ------------ method called to produce the data ------------
73
SiStripApvGainFakeESSource::ReturnType
SiStripApvGainFakeESSource::produce
(
const
SiStripApvGainRcd
& iRecord) {
74
using namespace
edm::es
;
75
76
auto
apvGain = std::make_unique<SiStripApvGain>();
77
78
uint32_t
count
{0};
79
for
(
const
auto
& elm :
m_detInfoFileReader
.
getAllData
()) {
80
std::vector<float> theSiStripVector;
81
for
(
unsigned
short
j
= 0;
j
< elm.second.nApvs; ++
j
) {
82
float
gainValue;
83
if
(
m_genMode
==
"default"
) {
84
gainValue =
m_meanGain
;
85
}
else
if
(
m_genMode
==
"gaussian"
) {
86
gainValue = CLHEP::RandGauss::shoot(
m_meanGain
,
m_sigmaGain
);
87
if
(gainValue <=
m_minimumPosValue
) {
88
gainValue =
m_minimumPosValue
;
89
}
90
}
else
{
91
LogDebug
(
"SiStripApvGain"
) <<
"ERROR: wrong genMode specifier : "
<<
m_genMode
92
<<
", please select one of \"default\" or \"gaussian\""
;
93
exit
(1);
94
}
95
96
if
(
count
<
m_printDebug
) {
97
edm::LogInfo
(
"SiStripApvGainGenerator"
) <<
"detid: "
<< elm.first <<
" Apv: "
<<
j
<<
" gain: "
<< gainValue;
98
}
99
theSiStripVector.push_back(gainValue);
100
}
101
++
count
;
102
103
if
(!apvGain->put(elm.first,
SiStripApvGain::Range
{theSiStripVector.begin(), theSiStripVector.end()})) {
104
edm::LogError
(
"SiStripApvGainGenerator"
) <<
" detid already exists"
;
105
}
106
}
107
108
return
apvGain;
109
}
110
111
//define this as a plug-in
112
#include "
FWCore/Framework/interface/SourceFactory.h
"
113
DEFINE_FWK_EVENTSETUP_SOURCE
(
SiStripApvGainFakeESSource
);
SiStripApvGainFakeESSource::~SiStripApvGainFakeESSource
~SiStripApvGainFakeESSource() override
Definition:
SiStripApvGainFakeESSource.cc:64
MessageLogger.h
contentValuesFiles.fullPath
fullPath
Definition:
contentValuesFiles.py:64
edm::LogInfo
Definition:
MessageLogger.h:254
edm::ESProducer::setWhatProduced
auto setWhatProduced(T *iThis, const es::Label &iLabel={})
Definition:
ESProducer.h:138
edm::ValidityInterval
Definition:
ValidityInterval.h:28
SiStripApvGainFakeESSource::m_meanGain
double m_meanGain
Definition:
SiStripApvGainFakeESSource.cc:41
ESProducer.h
edm::ParameterSet::getUntrackedParameter
T getUntrackedParameter(std::string const &, T const &) const
SiStripDetInfoFileReader
Definition:
SiStripDetInfoFileReader.h:30
edm::EventSetupRecordIntervalFinder
Definition:
EventSetupRecordIntervalFinder.h:33
SiStripApvGainFakeESSource::ReturnType
std::unique_ptr< SiStripApvGain > ReturnType
Definition:
SiStripApvGainFakeESSource.cc:36
edm::eventsetup::EventSetupRecordKey
Definition:
EventSetupRecordKey.h:30
edm::FileInPath
Definition:
FileInPath.h:64
SiStripApvGainFakeESSource::setIntervalFor
void setIntervalFor(const edm::eventsetup::EventSetupRecordKey &, const edm::IOVSyncValue &iov, edm::ValidityInterval &iValidity) override
Definition:
SiStripApvGainFakeESSource.cc:66
SiStripApvGainFakeESSource
Definition:
SiStripApvGainFakeESSource.cc:27
SiStripApvGainFakeESSource::m_printDebug
uint32_t m_printDebug
Definition:
SiStripApvGainFakeESSource.cc:44
SiStripDetInfoFileReader.h
SiStripApvGain.h
edm::IOVSyncValue
Definition:
IOVSyncValue.h:31
DEFINE_FWK_EVENTSETUP_SOURCE
#define DEFINE_FWK_EVENTSETUP_SOURCE(type)
Definition:
SourceFactory.h:91
EventSetupRecordIntervalFinder.h
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition:
AlCaHLTBitMon_QueryRunRegistry.py:256
SourceFactory.h
SiStripApvGainFakeESSource::m_sigmaGain
double m_sigmaGain
Definition:
SiStripApvGainFakeESSource.cc:42
LogDebug
#define LogDebug(id)
Definition:
MessageLogger.h:670
edm::ParameterSet
Definition:
ParameterSet.h:36
edm::LogError
Definition:
MessageLogger.h:183
SiStripCondDataRecords.h
SiStripApvGainFakeESSource::produce
ReturnType produce(const SiStripApvGainRcd &)
Definition:
SiStripApvGainFakeESSource.cc:73
edm::IOVSyncValue::endOfTime
static const IOVSyncValue & endOfTime()
Definition:
IOVSyncValue.cc:82
KineDebug3::count
void count()
Definition:
KinematicConstrainedVertexUpdatorT.h:21
SiStripApvGainRcd
Definition:
SiStripCondDataRecords.h:8
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
SiStripApvGain::Range
std::pair< ContainerIterator, ContainerIterator > Range
Definition:
SiStripApvGain.h:28
SiStripDetInfoFileReader::getAllData
const std::map< uint32_t, DetInfo > & getAllData() const
Definition:
SiStripDetInfoFileReader.h:58
SiStripApvGainFakeESSource::m_minimumPosValue
double m_minimumPosValue
Definition:
SiStripApvGainFakeESSource.cc:43
edm::es
Definition:
es_Label.h:33
edm::IOVSyncValue::beginOfTime
static const IOVSyncValue & beginOfTime()
Definition:
IOVSyncValue.cc:88
edm::ESProducer
Definition:
ESProducer.h:101
beamvalidation.exit
def exit(msg="")
Definition:
beamvalidation.py:53
ParameterSet.h
SiStripApvGainFakeESSource::m_genMode
std::string m_genMode
Definition:
SiStripApvGainFakeESSource.cc:40
SiStripApvGainFakeESSource::SiStripApvGainFakeESSource
SiStripApvGainFakeESSource(const edm::ParameterSet &)
Definition:
SiStripApvGainFakeESSource.cc:51
dqmiolumiharvest.j
j
Definition:
dqmiolumiharvest.py:66
SiStripApvGainFakeESSource::m_detInfoFileReader
SiStripDetInfoFileReader m_detInfoFileReader
Definition:
SiStripApvGainFakeESSource.cc:45
Generated for CMSSW Reference Manual by
1.8.16