L1Trigger
Phase2L1ParticleFlow
plugins
L1TPFCandMultiMerger.cc
Go to the documentation of this file.
1
#include "
DataFormats/L1TParticleFlow/interface/PFCandidate.h
"
2
3
#include "
FWCore/Framework/interface/global/EDProducer.h
"
4
#include "
FWCore/Framework/interface/Event.h
"
5
#include "
FWCore/ParameterSet/interface/ParameterSet.h
"
6
#include "
FWCore/Utilities/interface/transform.h
"
7
#include "
FWCore/Utilities/interface/InputTag.h
"
8
#include "
DataFormats/Common/interface/CloneTrait.h
"
9
#include <vector>
10
11
class
L1TPFCandMultiMerger
:
public
edm::global::EDProducer
<> {
12
public
:
13
explicit
L1TPFCandMultiMerger
(
const
edm::ParameterSet
&);
14
~L1TPFCandMultiMerger
()
override
;
15
16
private
:
17
void
produce
(
edm::StreamID
,
edm::Event
&,
const
edm::EventSetup
&)
const override
;
18
19
std::vector<std::string>
instances_
,
regionalInstances_
;
20
std::vector<bool>
alsoRegional_
;
// aligned with instances_
21
std::vector<edm::EDGetTokenT<l1t::PFCandidateCollection>>
tokens_
;
22
std::vector<edm::EDGetTokenT<l1t::PFCandidateRegionalOutput>>
regionalTokens_
;
23
};
24
25
L1TPFCandMultiMerger::L1TPFCandMultiMerger
(
const
edm::ParameterSet
& iConfig)
26
: instances_(iConfig.getParameter<
std
::
vector
<
std
::
string
>>(
"labelsToMerge"
)),
27
regionalInstances_(iConfig.getParameter<
std
::
vector
<
std
::
string
>>(
"regionalLabelsToMerge"
)) {
28
const
std::vector<edm::InputTag>&
pfProducers
= iConfig.
getParameter
<std::vector<edm::InputTag>>(
"pfProducers"
);
29
tokens_
.reserve(
instances_
.size() *
pfProducers
.size());
30
for
(
const
std::string
&
instance
:
instances_
) {
31
for
(
const
edm::InputTag
&
tag
:
pfProducers
) {
32
tokens_
.push_back(consumes<l1t::PFCandidateCollection>(
edm::InputTag
(
tag
.label(),
instance
,
tag
.process())));
33
}
34
produces<l1t::PFCandidateCollection>(
instance
);
35
// check if regional output is needed too
36
if
(
std::find
(
regionalInstances_
.begin(),
regionalInstances_
.end(),
instance
) !=
regionalInstances_
.end()) {
37
alsoRegional_
.push_back(
true
);
38
for
(
const
edm::InputTag
&
tag
:
pfProducers
) {
39
regionalTokens_
.push_back(
40
consumes<l1t::PFCandidateRegionalOutput>(
edm::InputTag
(
tag
.label(),
instance
+
"Regional"
,
tag
.process())));
41
}
42
produces<l1t::PFCandidateRegionalOutput>(
instance
+
"Regional"
);
43
}
else
{
44
alsoRegional_
.push_back(
false
);
45
}
46
}
47
// check that regional output is not requested without the standard one
48
for
(
const
std::string
&
instance
:
regionalInstances_
) {
49
auto
match
=
std::find
(
instances_
.begin(),
instances_
.end(),
instance
);
50
if
(
match
==
instances_
.end()) {
51
throw
cms::Exception
(
"Configuration"
,
"The regional label '"
+
instance
+
"' is not in labelsToMerge\n"
);
52
}
53
}
54
}
55
56
L1TPFCandMultiMerger::~L1TPFCandMultiMerger
() {}
57
58
void
L1TPFCandMultiMerger::produce
(
edm::StreamID
,
edm::Event
&
iEvent
,
const
edm::EventSetup
&)
const
{
59
edm::Handle<l1t::PFCandidateCollection>
handle
;
60
edm::Handle<l1t::PFCandidateRegionalOutput>
regionalHandle;
61
unsigned
int
ninstances =
instances_
.size(), nproducers =
tokens_
.size() / ninstances;
62
std::vector<int>
keys
;
63
for
(
unsigned
int
ii
= 0, it = 0, irt = 0;
ii
< ninstances; ++
ii
) {
64
auto
out
= std::make_unique<l1t::PFCandidateCollection>();
65
std::unique_ptr<l1t::PFCandidateRegionalOutput> regout;
66
if
(
alsoRegional_
[
ii
]) {
67
auto
refprod =
iEvent
.getRefBeforePut<
l1t::PFCandidateCollection
>(
instances_
[
ii
]);
68
regout = std::make_unique<l1t::PFCandidateRegionalOutput>(
edm::RefProd<l1t::PFCandidateCollection>
(refprod));
69
}
70
for
(
unsigned
int
ip = 0; ip < nproducers; ++ip, ++it) {
71
iEvent
.getByToken(
tokens_
[it],
handle
);
72
unsigned
int
offset
=
out
->size();
73
out
->insert(
out
->end(),
handle
->begin(),
handle
->end());
74
if
(
alsoRegional_
[
ii
]) {
75
iEvent
.getByToken(
regionalTokens_
[irt++], regionalHandle);
76
const
auto
&
src
= *regionalHandle;
77
for
(
unsigned
int
ireg = 0, nreg =
src
.nRegions(); ireg < nreg; ++ireg) {
78
auto
region
=
src
.region(ireg);
79
keys
.clear();
80
for
(
auto
iter =
region
.begin(), iend =
region
.end(); iter != iend; ++iter) {
81
keys
.push_back(iter.idx() +
offset
);
82
}
83
regout->addRegion(
keys
,
src
.eta(ireg),
src
.phi(ireg));
84
}
85
}
86
}
87
iEvent
.put(
std::move
(
out
),
instances_
[
ii
]);
88
if
(
alsoRegional_
[
ii
]) {
89
iEvent
.put(
std::move
(regout),
instances_
[
ii
] +
"Regional"
);
90
}
91
}
92
}
93
94
#include "
FWCore/Framework/interface/MakerMacros.h
"
95
DEFINE_FWK_MODULE
(
L1TPFCandMultiMerger
);
L1TPFCandMultiMerger::~L1TPFCandMultiMerger
~L1TPFCandMultiMerger() override
Definition:
L1TPFCandMultiMerger.cc:56
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition:
ParameterSet.h:303
Exception
Definition:
hltDiff.cc:245
instance
static PFTauRenderPlugin instance
Definition:
PFTauRenderPlugin.cc:70
edm::StreamID
Definition:
StreamID.h:30
Event.h
l1t::PFCandidateCollection
std::vector< l1t::PFCandidate > PFCandidateCollection
Definition:
PFCandidate.h:82
edm::Handle
Definition:
AssociativeIterator.h:50
std
Definition:
JetResolutionObject.h:76
L1TPFCandMultiMerger::produce
void produce(edm::StreamID, edm::Event &, const edm::EventSetup &) const override
Definition:
L1TPFCandMultiMerger.cc:58
spr::find
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition:
FindCaloHit.cc:19
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition:
AlCaHLTBitMon_QueryRunRegistry.py:256
ParameterSet.h
relativeConstraints.keys
keys
Definition:
relativeConstraints.py:89
l1pfCandidates_cfi.pfProducers
pfProducers
Definition:
l1pfCandidates_cfi.py:11
iEvent
int iEvent
Definition:
GenABIO.cc:224
makeGlobalPositionRcd_cfg.tag
tag
Definition:
makeGlobalPositionRcd_cfg.py:6
edm::RefProd
Definition:
EDProductfwd.h:25
L1TPFCandMultiMerger
Definition:
L1TPFCandMultiMerger.cc:11
L1TPFCandMultiMerger::alsoRegional_
std::vector< bool > alsoRegional_
Definition:
L1TPFCandMultiMerger.cc:20
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition:
MakerMacros.h:16
edm::EventSetup
Definition:
EventSetup.h:56
patZpeak.handle
handle
Definition:
patZpeak.py:25
edm::global::EDProducer
Definition:
EDProducer.h:32
transform.h
cuy.ii
ii
Definition:
cuy.py:589
TrackRefitter_38T_cff.src
src
Definition:
TrackRefitter_38T_cff.py:24
MillePedeFileConverter_cfg.out
out
Definition:
MillePedeFileConverter_cfg.py:31
HLT_2022v15_cff.region
region
Definition:
HLT_2022v15_cff.py:63022
L1TPFCandMultiMerger::tokens_
std::vector< edm::EDGetTokenT< l1t::PFCandidateCollection > > tokens_
Definition:
L1TPFCandMultiMerger.cc:21
EDProducer.h
L1TPFCandMultiMerger::instances_
std::vector< std::string > instances_
Definition:
L1TPFCandMultiMerger.cc:19
edm::InputTag
Definition:
InputTag.h:15
trackerHitRTTI::vector
Definition:
trackerHitRTTI.h:21
L1TPFCandMultiMerger::L1TPFCandMultiMerger
L1TPFCandMultiMerger(const edm::ParameterSet &)
Definition:
L1TPFCandMultiMerger.cc:25
InputTag.h
edm::ParameterSet
Definition:
ParameterSet.h:47
match
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
Definition:
Utils.h:10
L1TPFCandMultiMerger::regionalTokens_
std::vector< edm::EDGetTokenT< l1t::PFCandidateRegionalOutput > > regionalTokens_
Definition:
L1TPFCandMultiMerger.cc:22
edm::Event
Definition:
Event.h:73
CloneTrait.h
MakerMacros.h
PFCandidate.h
L1TPFCandMultiMerger::regionalInstances_
std::vector< std::string > regionalInstances_
Definition:
L1TPFCandMultiMerger.cc:19
eostools.move
def move(src, dest)
Definition:
eostools.py:511
hltrates_dqm_sourceclient-live_cfg.offset
offset
Definition:
hltrates_dqm_sourceclient-live_cfg.py:83
Generated for CMSSW Reference Manual by
1.8.14