CMS 3D CMS Logo

MCToCPAssociatorEDProducer.cc
Go to the documentation of this file.
1 //
2 // Original Author: Leonardo Cristella
3 // Created: Tue Feb 2 10:52:11 CET 2021
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  ~MCToCPAssociatorEDProducer() override;
37 
38 private:
39  void produce(edm::StreamID, edm::Event &, const edm::EventSetup &) const override;
40 
44 };
45 
47  produces<hgcal::SimToRecoCollectionWithMultiClusters>();
48  produces<hgcal::RecoToSimCollectionWithMultiClusters>();
49 
50  CPCollectionToken_ = consumes<CaloParticleCollection>(pset.getParameter<edm::InputTag>("label_cp"));
51  MCCollectionToken_ = consumes<reco::HGCalMultiClusterCollection>(pset.getParameter<edm::InputTag>("label_mcl"));
53  consumes<hgcal::MultiClusterToCaloParticleAssociator>(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(MCCollectionToken_, MCCollection);
74 
75  // associate MutiCluster and CP
76  LogTrace("AssociatorValidator") << "Calling associateRecoToSim method"
77  << "\n";
79  theAssociator->associateRecoToSim(MCCollection, CPCollection);
80 
81  LogTrace("AssociatorValidator") << "Calling associateSimToReco method"
82  << "\n";
84  theAssociator->associateSimToReco(MCCollection, CPCollection);
85 
86  auto rts = std::make_unique<hgcal::RecoToSimCollectionWithMultiClusters>(recSimColl);
87  auto str = std::make_unique<hgcal::SimToRecoCollectionWithMultiClusters>(simRecColl);
88 
89  iEvent.put(std::move(rts));
90  iEvent.put(std::move(str));
91 }
92 
93 // define this as a plug-in
edm::EDGetTokenT< CaloParticleCollection > CPCollectionToken_
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
edm::EDGetTokenT< reco::HGCalMultiClusterCollection > MCCollectionToken_
#define LogTrace(id)
MCToCPAssociatorEDProducer(const edm::ParameterSet &)
edm::EDGetTokenT< hgcal::MultiClusterToCaloParticleAssociator > associatorToken_
int iEvent
Definition: GenABIO.cc:224
void produce(edm::StreamID, edm::Event &, const edm::EventSetup &) const override
hgcal::RecoToSimCollectionWithMultiClusters associateRecoToSim(const edm::Handle< reco::HGCalMultiClusterCollection > &cCCH, const edm::Handle< CaloParticleCollection > &cPCH) const
Associate a MultiCluster to CaloParticles.
HLT enums.
#define str(s)
def move(src, dest)
Definition: eostools.py:511
hgcal::SimToRecoCollectionWithMultiClusters associateSimToReco(const edm::Handle< reco::HGCalMultiClusterCollection > &cCCH, const edm::Handle< CaloParticleCollection > &cPCH) const
Associate a CaloParticle to MultiClusters.