forked from cms-sw/cmssw
-
Notifications
You must be signed in to change notification settings - Fork 0
/
LayerClusterAssociatorByEnergyScoreProducer.cc
65 lines (50 loc) · 2.75 KB
/
LayerClusterAssociatorByEnergyScoreProducer.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
// Original author: Marco Rovere
// user include files
#include "FWCore/Framework/interface/Frameworkfwd.h"
#include "FWCore/Framework/interface/global/EDProducer.h"
#include "FWCore/Framework/interface/Event.h"
#include "FWCore/Framework/interface/MakerMacros.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "FWCore/Utilities/interface/EDGetToken.h"
#include "SimDataFormats/Associations/interface/LayerClusterToCaloParticleAssociator.h"
#include "LayerClusterAssociatorByEnergyScoreImpl.h"
class LayerClusterAssociatorByEnergyScoreProducer : public edm::global::EDProducer<> {
public:
explicit LayerClusterAssociatorByEnergyScoreProducer(const edm::ParameterSet &);
~LayerClusterAssociatorByEnergyScoreProducer() override;
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions);
private:
void produce(edm::StreamID, edm::Event &, const edm::EventSetup &) const override;
edm::EDGetTokenT<std::map<DetId, const HGCRecHit *>> hitMapToken_;
const bool hardScatterOnly_;
std::shared_ptr<hgcal::RecHitTools> rhtools_;
};
LayerClusterAssociatorByEnergyScoreProducer::LayerClusterAssociatorByEnergyScoreProducer(const edm::ParameterSet &ps)
: hitMapToken_(consumes<std::map<DetId, const HGCRecHit *>>(ps.getParameter<edm::InputTag>("hitMapTag"))),
hardScatterOnly_(ps.getParameter<bool>("hardScatterOnly")) {
rhtools_.reset(new hgcal::RecHitTools());
// Register the product
produces<hgcal::LayerClusterToCaloParticleAssociator>();
}
LayerClusterAssociatorByEnergyScoreProducer::~LayerClusterAssociatorByEnergyScoreProducer() {}
void LayerClusterAssociatorByEnergyScoreProducer::produce(edm::StreamID,
edm::Event &iEvent,
const edm::EventSetup &es) const {
rhtools_->getEventSetup(es);
edm::Handle<std::map<DetId, const HGCRecHit *>> hitMapHandle;
iEvent.getByToken(hitMapToken_, hitMapHandle);
const std::map<DetId, const HGCRecHit *> *hitMap = &*hitMapHandle;
auto impl = std::make_unique<LayerClusterAssociatorByEnergyScoreImpl>(
iEvent.productGetter(), hardScatterOnly_, rhtools_, hitMap);
std::unique_ptr<hgcal::LayerClusterToCaloParticleAssociator> toPut(
std::make_unique<hgcal::LayerClusterToCaloParticleAssociator>(std::move(impl)));
iEvent.put(std::move(toPut));
}
void LayerClusterAssociatorByEnergyScoreProducer::fillDescriptions(edm::ConfigurationDescriptions &cfg) {
edm::ParameterSetDescription desc;
desc.add<edm::InputTag>("hitMapTag", edm::InputTag("HGCRecHitMapProducer"));
desc.add<bool>("hardScatterOnly", true);
cfg.add("layerClusterAssociatorByEnergyScore", desc);
}
//define this as a plug-in
DEFINE_FWK_MODULE(LayerClusterAssociatorByEnergyScoreProducer);