RecoLocalCalo
EcalRecAlgos
plugins
EcalSeverityLevelESProducer.cc
Go to the documentation of this file.
1
#include <memory>
2
#include "
FWCore/Framework/interface/ModuleFactory.h
"
3
#include "
FWCore/Framework/interface/ESProducer.h
"
4
#include "
FWCore/Framework/interface/ESProductHost.h
"
5
#include "
FWCore/Framework/interface/ESHandle.h
"
6
#include "
FWCore/ParameterSet/interface/ParameterSet.h
"
7
#include "
FWCore/Utilities/interface/ReusableObjectHolder.h
"
8
#include "
RecoLocalCalo/EcalRecAlgos/interface/EcalSeverityLevelAlgoRcd.h
"
9
#include "
CondFormats/DataRecord/interface/EcalChannelStatusRcd.h
"
10
#include "
RecoLocalCalo/EcalRecAlgos/interface/EcalSeverityLevelAlgo.h
"
11
12
/*
13
Provide a hook to retrieve the EcalSeverityLevelAlgo
14
through the EventSetup
15
16
Appartently there is no smarter way to do it in CMSSW
17
18
Author: Stefano Argiro
19
*/
20
21
class
EcalSeverityLevelESProducer
:
public
edm::ESProducer
{
22
public
:
23
EcalSeverityLevelESProducer
(
const
edm::ParameterSet
& iConfig);
24
25
typedef
std::shared_ptr<EcalSeverityLevelAlgo>
ReturnType
;
26
27
ReturnType
produce
(
const
EcalSeverityLevelAlgoRcd
& iRecord);
28
29
private
:
30
void
setupChannelStatus
(
const
EcalChannelStatusRcd
&,
EcalSeverityLevelAlgo
*);
31
32
using
HostType
=
edm::ESProductHost<EcalSeverityLevelAlgo, EcalChannelStatusRcd>
;
33
34
edm::ReusableObjectHolder<HostType>
holder_
;
35
edm::ParameterSet
const
pset_
;
36
edm::ESGetToken<EcalChannelStatus, EcalChannelStatusRcd>
const
channelToken_
;
37
};
38
39
EcalSeverityLevelESProducer::EcalSeverityLevelESProducer
(
const
edm::ParameterSet
& iConfig)
40
: pset_(iConfig), channelToken_(setWhatProduced(this).consumesFrom<
EcalChannelStatus
,
EcalChannelStatusRcd
>()) {}
41
42
EcalSeverityLevelESProducer::ReturnType
EcalSeverityLevelESProducer::produce
(
const
EcalSeverityLevelAlgoRcd
& iRecord) {
43
auto
host
=
holder_
.
makeOrGet
([
this
]() {
return
new
HostType
(
pset_
); });
44
45
host
->ifRecordChanges<
EcalChannelStatusRcd
>(iRecord,
46
[
this
,
h
=
host
.get()](
auto
const
& rec) {
setupChannelStatus
(rec,
h
); });
47
48
return
host
;
49
}
50
51
void
EcalSeverityLevelESProducer::setupChannelStatus
(
const
EcalChannelStatusRcd
& chs,
EcalSeverityLevelAlgo
*
algo
) {
52
algo
->setChannelStatus(chs.
get
(
channelToken_
));
53
}
54
55
//define this as a plug-in
56
DEFINE_FWK_EVENTSETUP_MODULE
(
EcalSeverityLevelESProducer
);
EcalSeverityLevelESProducer::HostType
edm::ESProductHost< EcalSeverityLevelAlgo, EcalChannelStatusRcd > HostType
Definition:
EcalSeverityLevelESProducer.cc:32
EcalSeverityLevelAlgo
Definition:
EcalSeverityLevelAlgo.h:33
EcalSeverityLevelESProducer::channelToken_
const edm::ESGetToken< EcalChannelStatus, EcalChannelStatusRcd > channelToken_
Definition:
EcalSeverityLevelESProducer.cc:36
ESHandle.h
EcalSeverityLevelAlgoRcd.h
EcalSeverityLevelESProducer::ReturnType
std::shared_ptr< EcalSeverityLevelAlgo > ReturnType
Definition:
EcalSeverityLevelESProducer.cc:25
ESProducer.h
EcalCondObjectContainer
Definition:
EcalCondObjectContainer.h:13
query.host
string host
Definition:
query.py:115
edm::ReusableObjectHolder< HostType >
edm::ReusableObjectHolder::makeOrGet
std::shared_ptr< T > makeOrGet(F iFunc)
If there isn't an object already available, creates a new one using iFunc.
Definition:
ReusableObjectHolder.h:126
cmsdt::algo
algo
Definition:
constants.h:164
ReusableObjectHolder.h
EcalSeverityLevelESProducer::holder_
edm::ReusableObjectHolder< HostType > holder_
Definition:
EcalSeverityLevelESProducer.cc:34
EcalSeverityLevelESProducer::pset_
const edm::ParameterSet pset_
Definition:
EcalSeverityLevelESProducer.cc:35
EcalSeverityLevelAlgoRcd
Definition:
EcalSeverityLevelAlgoRcd.h:12
h
EcalSeverityLevelAlgo.h
EcalSeverityLevelESProducer::setupChannelStatus
void setupChannelStatus(const EcalChannelStatusRcd &, EcalSeverityLevelAlgo *)
Definition:
EcalSeverityLevelESProducer.cc:51
edm::ParameterSet
Definition:
ParameterSet.h:47
EcalChannelStatusRcd
Definition:
EcalChannelStatusRcd.h:5
EcalSeverityLevelESProducer
Definition:
EcalSeverityLevelESProducer.cc:21
edm::ESGetToken
Definition:
EventSetup.h:48
EcalSeverityLevelESProducer::produce
ReturnType produce(const EcalSeverityLevelAlgoRcd &iRecord)
Definition:
EcalSeverityLevelESProducer.cc:42
ModuleFactory.h
edm::ESProductHost
Definition:
ESProductHost.h:93
DEFINE_FWK_EVENTSETUP_MODULE
#define DEFINE_FWK_EVENTSETUP_MODULE(type)
Definition:
ModuleFactory.h:60
EcalSeverityLevelESProducer::EcalSeverityLevelESProducer
EcalSeverityLevelESProducer(const edm::ParameterSet &iConfig)
Definition:
EcalSeverityLevelESProducer.cc:39
edm::ESProducer
Definition:
ESProducer.h:104
ESProductHost.h
edm::eventsetup::EventSetupRecordImplementation::get
PRODUCT const & get(ESGetToken< PRODUCT, T > const &iToken) const
Definition:
EventSetupRecordImplementation.h:74
ParameterSet.h
EcalChannelStatusRcd.h
Generated for CMSSW Reference Manual by
1.8.16