CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:133
edm::EDGetTokenT< CaloParticleCollection > CPCollectionToken_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:539
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
edm::EDGetTokenT< hgcal::LayerClusterToCaloParticleAssociator > associatorToken_
edm::EDGetTokenT< reco::CaloClusterCollection > LCCollectionToken_
#define LogTrace(id)
void produce(edm::StreamID, edm::Event &, const edm::EventSetup &) const override
int iEvent
Definition: GenABIO.cc:224
def move
Definition: eostools.py:511
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
LCToCPAssociatorEDProducer(const edm::ParameterSet &)
#define str(s)