src
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/ParameterSet/interface/ConfigurationDescriptions.h
"
7
#include "
FWCore/ParameterSet/interface/ParameterSetDescription.h
"
8
#include "
FWCore/Utilities/interface/transform.h
"
9
#include "
FWCore/Utilities/interface/InputTag.h
"
10
#include "
DataFormats/Common/interface/CloneTrait.h
"
11
#include <vector>
12
13
class
L1TPFCandMultiMerger
:
public
edm::global::EDProducer
<> {
14
public
:
15
explicit
L1TPFCandMultiMerger
(
const
edm::ParameterSet
&);
16
~L1TPFCandMultiMerger
()
override
;
17
static
void
fillDescriptions
(
edm::ConfigurationDescriptions
& descriptions);
18
19
private
:
20
void
produce
(
edm::StreamID
,
edm::Event
&,
const
edm::EventSetup
&)
const override
;
21
22
std::vector<std::string>
instances_
,
regionalInstances_
;
23
std::vector<bool>
alsoRegional_
;
// aligned with instances_
24
std::vector<edm::EDGetTokenT<l1t::PFCandidateCollection>>
tokens_
;
25
std::vector<edm::EDGetTokenT<l1t::PFCandidateRegionalOutput>>
regionalTokens_
;
26
};
27
28
L1TPFCandMultiMerger::L1TPFCandMultiMerger
(
const
edm::ParameterSet
& iConfig)
29
: instances_(iConfig.getParameter<
std
::
vector
<
std
::
string
>>(
"labelsToMerge"
)),
30
regionalInstances_(iConfig.getParameter<
std
::
vector
<
std
::
string
>>(
"regionalLabelsToMerge"
)) {
31
const
std::vector<edm::InputTag>&
pfProducers
= iConfig.
getParameter
<std::vector<edm::InputTag>>(
"pfProducers"
);
32
tokens_
.reserve(
instances_
.size() *
pfProducers
.size());
33
for
(
const
std::string
&
instance
:
instances_
) {
34
for
(
const
edm::InputTag
&
tag
:
pfProducers
) {
35
tokens_
.push_back(consumes<l1t::PFCandidateCollection>(
edm::InputTag
(
tag
.label(),
instance
,
tag
.process())));
36
}
37
produces<l1t::PFCandidateCollection>(
instance
);
38
// check if regional output is needed too
39
if
(
std::find
(
regionalInstances_
.begin(),
regionalInstances_
.end(),
instance
) !=
regionalInstances_
.end()) {
40
alsoRegional_
.push_back(
true
);
41
for
(
const
edm::InputTag
&
tag
:
pfProducers
) {
42
regionalTokens_
.push_back(
43
consumes<l1t::PFCandidateRegionalOutput>(
edm::InputTag
(
tag
.label(),
instance
+
"Regional"
,
tag
.process())));
44
}
45
produces<l1t::PFCandidateRegionalOutput>(
instance
+
"Regional"
);
46
}
else
{
47
alsoRegional_
.push_back(
false
);
48
}
49
}
50
// check that regional output is not requested without the standard one
51
for
(
const
std::string
&
instance
:
regionalInstances_
) {
52
auto
match
=
std::find
(
instances_
.begin(),
instances_
.end(),
instance
);
53
if
(
match
==
instances_
.end()) {
54
throw
cms::Exception
(
"Configuration"
,
"The regional label '"
+
instance
+
"' is not in labelsToMerge\n"
);
55
}
56
}
57
}
58
59
L1TPFCandMultiMerger::~L1TPFCandMultiMerger
() {}
60
61
void
L1TPFCandMultiMerger::produce
(
edm::StreamID
,
edm::Event
&
iEvent
,
const
edm::EventSetup
&)
const
{
62
edm::Handle<l1t::PFCandidateCollection>
handle
;
63
edm::Handle<l1t::PFCandidateRegionalOutput>
regionalHandle;
64
unsigned
int
ninstances =
instances_
.size(), nproducers =
tokens_
.size() / ninstances;
65
std::vector<int>
keys
;
66
for
(
unsigned
int
ii
= 0,
it
= 0, irt = 0;
ii
< ninstances; ++
ii
) {
67
auto
out
= std::make_unique<l1t::PFCandidateCollection>();
68
std::unique_ptr<l1t::PFCandidateRegionalOutput> regout;
69
if
(
alsoRegional_
[
ii
]) {
70
auto
refprod =
iEvent
.getRefBeforePut<
l1t::PFCandidateCollection
>(
instances_
[
ii
]);
71
regout = std::make_unique<l1t::PFCandidateRegionalOutput>(
edm::RefProd<l1t::PFCandidateCollection>
(refprod));
72
}
73
for
(
unsigned
int
ip = 0; ip < nproducers; ++ip, ++
it
) {
74
iEvent
.getByToken(
tokens_
[
it
],
handle
);
75
unsigned
int
offset
=
out
->size();
76
out
->insert(
out
->end(),
handle
->begin(),
handle
->end());
77
if
(
alsoRegional_
[
ii
]) {
78
iEvent
.getByToken(
regionalTokens_
[irt++], regionalHandle);
79
const
auto
&
src
= *regionalHandle;
80
for
(
unsigned
int
ireg = 0, nreg =
src
.nRegions(); ireg < nreg; ++ireg) {
81
auto
region
=
src
.region(ireg);
82
keys
.clear();
83
for
(
auto
iter =
region
.begin(), iend =
region
.end(); iter != iend; ++iter) {
84
keys
.push_back(iter.idx() +
offset
);
85
}
86
regout->addRegion(
keys
,
src
.eta(ireg),
src
.phi(ireg));
87
}
88
}
89
}
90
iEvent
.put(
std::move
(
out
),
instances_
[
ii
]);
91
if
(
alsoRegional_
[
ii
]) {
92
iEvent
.put(
std::move
(regout),
instances_
[
ii
] +
"Regional"
);
93
}
94
}
95
}
96
97
void
L1TPFCandMultiMerger::fillDescriptions
(
edm::ConfigurationDescriptions
& descriptions) {
98
// l1tLayer1
99
edm::ParameterSetDescription
desc
;
100
desc
.add<std::vector<edm::InputTag>>(
"pfProducers"
,
101
{
102
edm::InputTag
(
"l1tLayer1Barrel"
),
103
edm::InputTag
(
"l1tLayer1HGCal"
),
104
edm::InputTag
(
"l1tLayer1HGCalNoTK"
),
105
edm::InputTag
(
"l1tLayer1HF"
),
106
});
107
desc
.add<std::vector<std::string>>(
"labelsToMerge"
,
108
{
109
"PF"
,
110
"Puppi"
,
111
"Calo"
,
112
"TK"
,
113
});
114
desc
.add<std::vector<std::string>>(
"regionalLabelsToMerge"
,
115
{
116
"Puppi"
,
117
});
118
descriptions.
addWithDefaultLabel
(
desc
);
119
}
120
121
#include "
FWCore/Framework/interface/MakerMacros.h
"
122
DEFINE_FWK_MODULE
(
L1TPFCandMultiMerger
);
edm::ConfigurationDescriptions::addWithDefaultLabel
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)
Definition:
ConfigurationDescriptions.cc:87
ProducerED_cfi.InputTag
InputTag
Definition:
ProducerED_cfi.py:5
L1TPFCandMultiMerger::~L1TPFCandMultiMerger
~L1TPFCandMultiMerger() override
Definition:
L1TPFCandMultiMerger.cc:59
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition:
ParameterSet.h:307
Exception
Definition:
hltDiff.cc:245
instance
static PFTauRenderPlugin instance
Definition:
PFTauRenderPlugin.cc:70
l1ctLayer1_cff.pfProducers
pfProducers
Definition:
l1ctLayer1_cff.py:435
edm::StreamID
Definition:
StreamID.h:30
Event.h
l1t::PFCandidateCollection
std::vector< l1t::PFCandidate > PFCandidateCollection
Definition:
PFCandidate.h:86
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:61
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
HLT_IsoTrack_cff.offset
offset
Definition:
HLT_IsoTrack_cff.py:5
edm::ParameterSetDescription
Definition:
ParameterSetDescription.h:52
ParameterSet.h
relativeConstraints.keys
keys
Definition:
relativeConstraints.py:89
iEvent
int iEvent
Definition:
GenABIO.cc:224
ParameterSetDescription.h
makeGlobalPositionRcd_cfg.tag
tag
Definition:
makeGlobalPositionRcd_cfg.py:6
edm::RefProd
Definition:
EDProductfwd.h:25
submitPVResolutionJobs.desc
string desc
Definition:
submitPVResolutionJobs.py:263
L1TPFCandMultiMerger
Definition:
L1TPFCandMultiMerger.cc:13
L1TPFCandMultiMerger::alsoRegional_
std::vector< bool > alsoRegional_
Definition:
L1TPFCandMultiMerger.cc:23
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
L1TPFCandMultiMerger::tokens_
std::vector< edm::EDGetTokenT< l1t::PFCandidateCollection > > tokens_
Definition:
L1TPFCandMultiMerger.cc:24
EDProducer.h
L1TPFCandMultiMerger::fillDescriptions
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Definition:
L1TPFCandMultiMerger.cc:97
ALPAKA_ACCELERATOR_NAMESPACE::vertexFinder::it
auto & it
Definition:
splitVertices.h:27
L1TPFCandMultiMerger::instances_
std::vector< std::string > instances_
Definition:
L1TPFCandMultiMerger.cc:22
edm::InputTag
Definition:
InputTag.h:15
trackerHitRTTI::vector
Definition:
trackerHitRTTI.h:21
L1TPFCandMultiMerger::L1TPFCandMultiMerger
L1TPFCandMultiMerger(const edm::ParameterSet &)
Definition:
L1TPFCandMultiMerger.cc:28
InputTag.h
edm::ParameterSet
Definition:
ParameterSet.h:48
nano_mu_digi_cff.region
region
Definition:
nano_mu_digi_cff.py:45
match
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
Definition:
Utils.h:10
ConfigurationDescriptions.h
L1TPFCandMultiMerger::regionalTokens_
std::vector< edm::EDGetTokenT< l1t::PFCandidateRegionalOutput > > regionalTokens_
Definition:
L1TPFCandMultiMerger.cc:25
edm::Event
Definition:
Event.h:73
CloneTrait.h
MakerMacros.h
PFCandidate.h
L1TPFCandMultiMerger::regionalInstances_
std::vector< std::string > regionalInstances_
Definition:
L1TPFCandMultiMerger.cc:22
eostools.move
def move(src, dest)
Definition:
eostools.py:511
edm::ConfigurationDescriptions
Definition:
ConfigurationDescriptions.h:28
Generated for CMSSW Reference Manual by
1.8.14