CMS 3D CMS Logo

LCToCPAssociatorEDProducer.cc
Go to the documentation of this file.
1 //
2 // Original Author: Leonardo Cristella
3 // Created: Thu Dec 3 10:52:11 CET 2020
4 //
5 //
6 
7 // system include files
8 #include <memory>
9 #include <string>
10 
11 // user include files
13 
16 
18 
20 
22 
26 
28 
29 //
30 // class decleration
31 //
32 
34 public:
36  ~LCToCPAssociatorEDProducer() override;
37 
38 private:
39  void produce(edm::StreamID, edm::Event &, const edm::EventSetup &) const override;
40 
44 };
45 
47  produces<hgcal::SimToRecoCollection>();
48  produces<hgcal::RecoToSimCollection>();
49 
50  CPCollectionToken_ = consumes<CaloParticleCollection>(pset.getParameter<edm::InputTag>("label_cp"));
51  LCCollectionToken_ = consumes<reco::CaloClusterCollection>(pset.getParameter<edm::InputTag>("label_lc"));
53  consumes<hgcal::LayerClusterToCaloParticleAssociator>(pset.getParameter<edm::InputTag>("associator"));
54 }
55 
57 
58 //
59 // member functions
60 //
61 
62 // ------------ method called to produce the data ------------
64  using namespace edm;
65 
67  iEvent.getByToken(associatorToken_, theAssociator);
68 
69  Handle<CaloParticleCollection> CPCollection;
70  iEvent.getByToken(CPCollectionToken_, CPCollection);
71 
73  iEvent.getByToken(LCCollectionToken_, LCCollection);
74 
75  // associate LC and CP
76  LogTrace("AssociatorValidator") << "Calling associateRecoToSim method\n";
77  hgcal::RecoToSimCollection recSimColl = theAssociator->associateRecoToSim(LCCollection, CPCollection);
78 
79  LogTrace("AssociatorValidator") << "Calling associateSimToReco method\n";
80  hgcal::SimToRecoCollection simRecColl = theAssociator->associateSimToReco(LCCollection, CPCollection);
81 
82  auto rts = std::make_unique<hgcal::RecoToSimCollection>(recSimColl);
83  auto str = std::make_unique<hgcal::SimToRecoCollection>(simRecColl);
84 
85  iEvent.put(std::move(rts));
86  iEvent.put(std::move(str));
87 }
88 
89 // define this as a plug-in
hgcal::SimToRecoCollection associateSimToReco(const edm::Handle< reco::CaloClusterCollection > &cCCH, const edm::Handle< CaloParticleCollection > &cPCH) const
Associate a CaloParticle to LayerClusters.
edm::EDGetTokenT< CaloParticleCollection > CPCollectionToken_
edm::EDGetTokenT< hgcal::LayerClusterToCaloParticleAssociator > associatorToken_
edm::EDGetTokenT< reco::CaloClusterCollection > LCCollectionToken_
#define LogTrace(id)
hgcal::RecoToSimCollection associateRecoToSim(const edm::Handle< reco::CaloClusterCollection > &cCCH, const edm::Handle< CaloParticleCollection > &cPCH) const
Associate a LayerCluster to CaloParticles.
void produce(edm::StreamID, edm::Event &, const edm::EventSetup &) const override
int iEvent
Definition: GenABIO.cc:224
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
HLT enums.
LCToCPAssociatorEDProducer(const edm::ParameterSet &)
#define str(s)
def move(src, dest)
Definition: eostools.py:511