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 
21 
22 //
23 // class declaration
24 //
25 
27 public:
28  explicit GenJetGenPartMerger(const edm::ParameterSet&);
29  ~GenJetGenPartMerger() override;
30 
31 private:
32  void beginStream(edm::StreamID) override;
33  void produce(edm::Event&, const edm::EventSetup&) override;
34  void endStream() override;
35 
40 };
41 
42 //
43 // constants, enums and typedefs
44 //
45 
46 //
47 // static data member definitions
48 //
49 
50 //
51 // constructors and destructor
52 //
54  : jetToken_(consumes<reco::GenJetCollection>(iConfig.getParameter<edm::InputTag>("srcJet"))),
55  partToken_(consumes<reco::GenParticleCollection>(iConfig.getParameter<edm::InputTag>("srcPart"))),
56  cut_(iConfig.getParameter<std::string>("cut")),
57  tauAncToken_(consumes<edm::ValueMap<bool>>(iConfig.getParameter<edm::InputTag>("hasTauAnc"))) {
58  produces<reco::GenJetCollection>("merged");
59  produces<edm::ValueMap<bool>>("hasTauAnc");
60 }
61 
63 
64 //
65 // member functions
66 //
67 
68 // ------------ method called to produce the data ------------
70  using namespace edm;
71  std::unique_ptr<reco::GenJetCollection> merged(new reco::GenJetCollection);
72 
73  std::vector<bool> hasTauAncValues;
74 
76  iEvent.getByToken(jetToken_, jetHandle);
77 
79  iEvent.getByToken(partToken_, partHandle);
80 
81  edm::Handle<edm::ValueMap<bool>> tauAncHandle;
82  iEvent.getByToken(tauAncToken_, tauAncHandle);
83 
84  for (unsigned int ijet = 0; ijet < jetHandle->size(); ++ijet) {
85  auto jet = jetHandle->at(ijet);
86  if (cut_(jet)) {
87  merged->push_back(reco::GenJet(jet));
88  reco::GenJetRef jetRef(jetHandle, ijet);
89  hasTauAncValues.push_back((*tauAncHandle)[jetRef]);
90  }
91  }
92 
93  for (auto& part : *partHandle) {
95  jet.setP4(part.p4());
96  jet.setPdgId(part.pdgId());
97  jet.setCharge(part.charge());
98  merged->push_back(jet);
99  hasTauAncValues.push_back(false);
100  }
101 
102  auto newmerged = iEvent.put(std::move(merged), "merged");
103 
104  std::unique_ptr<edm::ValueMap<bool>> out(new edm::ValueMap<bool>());
106  filler.insert(newmerged, hasTauAncValues.begin(), hasTauAncValues.end());
107  filler.fill();
108 
109  iEvent.put(std::move(out), "hasTauAnc");
110 }
111 
112 // ------------ method called once each stream before processing any runs, lumis or events ------------
114 
115 // ------------ method called once each stream after processing all runs, lumis and events ------------
117 
118 //define this as a plug-in
edm::StreamID
Definition: StreamID.h:30
GenJetGenPartMerger::tauAncToken_
const edm::EDGetTokenT< edm::ValueMap< bool > > tauAncToken_
Definition: GenJetGenPartMerger.cc:39
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:62
GenJetGenPartMerger::beginStream
void beginStream(edm::StreamID) override
Definition: GenJetGenPartMerger.cc:113
HLT_FULL_cff.InputTag
InputTag
Definition: HLT_FULL_cff.py:89301
reco::GenParticleCollection
std::vector< GenParticle > GenParticleCollection
collection of GenParticles
Definition: GenParticleFwd.h:13
EDProducer.h
reco
fixed size matrix
Definition: AlignmentAlgorithmBase.h:46
edm::Handle< reco::GenJetCollection >
edm::Ref
Definition: AssociativeIterator.h:58
GenParticle.h
GenJetGenPartMerger::GenJetGenPartMerger
GenJetGenPartMerger(const edm::ParameterSet &)
Definition: GenJetGenPartMerger.cc:53
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
GenJetGenPartMerger::cut_
const StringCutObjectSelector< reco::Candidate > cut_
Definition: GenJetGenPartMerger.cc:38
trigObjTnPSource_cfi.filler
filler
Definition: trigObjTnPSource_cfi.py:21
iEvent
int iEvent
Definition: GenABIO.cc:224
edm::stream::EDProducer
Definition: EDProducer.h:36
edm::EventSetup
Definition: EventSetup.h:58
GenJetGenPartMerger::jetToken_
const edm::EDGetTokenT< reco::GenJetCollection > jetToken_
Definition: GenJetGenPartMerger.cc:36
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
GenJetGenPartMerger::produce
void produce(edm::Event &, const edm::EventSetup &) override
Definition: GenJetGenPartMerger.cc:69
ValueMap.h
GenJetGenPartMerger
Definition: GenJetGenPartMerger.cc:26
eostools.move
def move(src, dest)
Definition: eostools.py:511
std
Definition: JetResolutionObject.h:76
StringCutObjectSelector.h
Frameworkfwd.h
metsig::jet
Definition: SignAlgoResolutions.h:47
GenJetGenPartMerger::partToken_
const edm::EDGetTokenT< reco::GenParticleCollection > partToken_
Definition: GenJetGenPartMerger.cc:37
edm::ValueMap
Definition: ValueMap.h:107
StringCutObjectSelector< reco::Candidate >
MillePedeFileConverter_cfg.out
out
Definition: MillePedeFileConverter_cfg.py:31
edm::helper::Filler
Definition: ValueMap.h:22
ParameterSet.h
edm::Event
Definition: Event.h:73
StringObjectFunction.h
StreamID.h
GenJetGenPartMerger::endStream
void endStream() override
Definition: GenJetGenPartMerger.cc:116