CMS 3D CMS Logo

GenJetGenPartMerger.cc
Go to the documentation of this file.
1 
2 // system include files
3 #include <memory>
4 
5 // user include files
8 
11 
14 
17 
19 
20 //
21 // class declaration
22 //
23 
25 public:
26  explicit GenJetGenPartMerger(const edm::ParameterSet&);
27  ~GenJetGenPartMerger() override;
28 
29 private:
30  void beginStream(edm::StreamID) override;
31  void produce(edm::Event&, const edm::EventSetup&) override;
32  void endStream() override;
33 
37 };
38 
39 //
40 // constants, enums and typedefs
41 //
42 
43 //
44 // static data member definitions
45 //
46 
47 //
48 // constructors and destructor
49 //
51  : jetToken_(consumes<reco::GenJetCollection>(iConfig.getParameter<edm::InputTag>("srcJet"))),
52  partToken_(consumes<reco::GenParticleCollection>(iConfig.getParameter<edm::InputTag>("srcPart"))),
53  tauAncToken_(consumes<edm::ValueMap<bool>>(iConfig.getParameter<edm::InputTag>("hasTauAnc"))) {
54  produces<reco::GenJetCollection>("merged");
55  produces<edm::ValueMap<bool>>("hasTauAnc");
56 }
57 
59 
60 //
61 // member functions
62 //
63 
64 // ------------ method called to produce the data ------------
66  using namespace edm;
67  std::unique_ptr<reco::GenJetCollection> merged(new reco::GenJetCollection);
68 
69  std::vector<bool> hasTauAncValues;
70 
72  iEvent.getByToken(jetToken_, jetHandle);
73 
75  iEvent.getByToken(partToken_, partHandle);
76 
77  edm::Handle<edm::ValueMap<bool>> tauAncHandle;
78  iEvent.getByToken(tauAncToken_, tauAncHandle);
79 
80  for (unsigned int ijet = 0; ijet < jetHandle->size(); ++ijet) {
81  auto jet = jetHandle->at(ijet);
82  merged->push_back(reco::GenJet(jet));
83  reco::GenJetRef jetRef(jetHandle, ijet);
84  hasTauAncValues.push_back((*tauAncHandle)[jetRef]);
85  }
86 
87  for (auto& part : *partHandle) {
89  jet.setP4(part.p4());
90  jet.setPdgId(part.pdgId());
91  jet.setCharge(part.charge());
92  merged->push_back(jet);
93  hasTauAncValues.push_back(false);
94  }
95 
96  auto newmerged = iEvent.put(std::move(merged), "merged");
97 
98  std::unique_ptr<edm::ValueMap<bool>> out(new edm::ValueMap<bool>());
100  filler.insert(newmerged, hasTauAncValues.begin(), hasTauAncValues.end());
101  filler.fill();
102 
103  iEvent.put(std::move(out), "hasTauAnc");
104 }
105 
106 // ------------ method called once each stream before processing any runs, lumis or events ------------
108 
109 // ------------ method called once each stream after processing all runs, lumis and events ------------
111 
112 //define this as a plug-in
edm::StreamID
Definition: StreamID.h:30
GenJetGenPartMerger::tauAncToken_
const edm::EDGetTokenT< edm::ValueMap< bool > > tauAncToken_
Definition: GenJetGenPartMerger.cc:36
GenJetCollection.h
electrons_cff.bool
bool
Definition: electrons_cff.py:366
reco::GenJet
Jets made from MC generator particles.
Definition: GenJet.h:23
reco::GenJetCollection
std::vector< GenJet > GenJetCollection
collection of GenJet objects
Definition: GenJetCollection.h:14
edm::EDGetTokenT< reco::GenJetCollection >
edm
HLT enums.
Definition: AlignableModifier.h:19
GenJetGenPartMerger::~GenJetGenPartMerger
~GenJetGenPartMerger() override
Definition: GenJetGenPartMerger.cc:58
GenJetGenPartMerger::beginStream
void beginStream(edm::StreamID) override
Definition: GenJetGenPartMerger.cc:107
HLT_FULL_cff.InputTag
InputTag
Definition: HLT_FULL_cff.py:89285
reco::GenParticleCollection
std::vector< GenParticle > GenParticleCollection
collection of GenParticles
Definition: GenParticleFwd.h:13
EDProducer.h
reco
fixed size matrix
Definition: AlignmentAlgorithmBase.h:45
edm::Handle< reco::GenJetCollection >
edm::Ref
Definition: AssociativeIterator.h:58
GenParticle.h
GenJetGenPartMerger::GenJetGenPartMerger
GenJetGenPartMerger(const edm::ParameterSet &)
Definition: GenJetGenPartMerger.cc:50
MakerMacros.h
part
part
Definition: HCALResponse.h:20
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
edm::ParameterSet
Definition: ParameterSet.h:47
Event.h
trigObjTnPSource_cfi.filler
filler
Definition: trigObjTnPSource_cfi.py:21
iEvent
int iEvent
Definition: GenABIO.cc:224
edm::stream::EDProducer
Definition: EDProducer.h:38
edm::EventSetup
Definition: EventSetup.h:58
GenJetGenPartMerger::jetToken_
const edm::EDGetTokenT< reco::GenJetCollection > jetToken_
Definition: GenJetGenPartMerger.cc:34
GenJetGenPartMerger::produce
void produce(edm::Event &, const edm::EventSetup &) override
Definition: GenJetGenPartMerger.cc:65
ValueMap.h
GenJetGenPartMerger
Definition: GenJetGenPartMerger.cc:24
eostools.move
def move(src, dest)
Definition: eostools.py:511
Frameworkfwd.h
metsig::jet
Definition: SignAlgoResolutions.h:47
GenJetGenPartMerger::partToken_
const edm::EDGetTokenT< reco::GenParticleCollection > partToken_
Definition: GenJetGenPartMerger.cc:35
edm::ValueMap
Definition: ValueMap.h:107
MillePedeFileConverter_cfg.out
out
Definition: MillePedeFileConverter_cfg.py:31
edm::helper::Filler
Definition: ValueMap.h:22
ParameterSet.h
edm::Event
Definition: Event.h:73
StreamID.h
GenJetGenPartMerger::endStream
void endStream() override
Definition: GenJetGenPartMerger.cc:110