CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
GenJetGenPartMerger Class Reference
Inheritance diagram for GenJetGenPartMerger:
edm::stream::EDProducer<>

Public Member Functions

 GenJetGenPartMerger (const edm::ParameterSet &)
 
 ~GenJetGenPartMerger () override
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
 EDProducer (const EDProducer &)=delete
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
const EDProduceroperator= (const EDProducer &)=delete
 

Private Member Functions

void beginStream (edm::StreamID) override
 
void endStream () override
 
void produce (edm::Event &, const edm::EventSetup &) override
 

Private Attributes

const StringCutObjectSelector< reco::Candidatecut_
 
const edm::EDGetTokenT< reco::GenJetCollectionjetToken_
 
const edm::EDGetTokenT< reco::GenParticleCollectionpartToken_
 
const edm::EDGetTokenT< edm::ValueMap< bool > > tauAncToken_
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer<>
using CacheTypes = CacheContexts< T... >
 
using GlobalCache = typename CacheTypes::GlobalCache
 
using HasAbility = AbilityChecker< T... >
 
using InputProcessBlockCache = typename CacheTypes::InputProcessBlockCache
 
using LuminosityBlockCache = typename CacheTypes::LuminosityBlockCache
 
using LuminosityBlockContext = LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCache >
 
using LuminosityBlockSummaryCache = typename CacheTypes::LuminosityBlockSummaryCache
 
using RunCache = typename CacheTypes::RunCache
 
using RunContext = RunContextT< RunCache, GlobalCache >
 
using RunSummaryCache = typename CacheTypes::RunSummaryCache
 

Detailed Description

Definition at line 26 of file GenJetGenPartMerger.cc.

Constructor & Destructor Documentation

◆ GenJetGenPartMerger()

GenJetGenPartMerger::GenJetGenPartMerger ( const edm::ParameterSet iConfig)
explicit

Definition at line 53 of file GenJetGenPartMerger.cc.

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 }
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
const edm::EDGetTokenT< reco::GenJetCollection > jetToken_
const StringCutObjectSelector< reco::Candidate > cut_
const edm::EDGetTokenT< reco::GenParticleCollection > partToken_
const edm::EDGetTokenT< edm::ValueMap< bool > > tauAncToken_

◆ ~GenJetGenPartMerger()

GenJetGenPartMerger::~GenJetGenPartMerger ( )
override

Definition at line 62 of file GenJetGenPartMerger.cc.

62 {}

Member Function Documentation

◆ beginStream()

void GenJetGenPartMerger::beginStream ( edm::StreamID  )
overrideprivate

Definition at line 113 of file GenJetGenPartMerger.cc.

113 {}

◆ endStream()

void GenJetGenPartMerger::endStream ( )
overrideprivate

Definition at line 116 of file GenJetGenPartMerger.cc.

116 {}

◆ produce()

void GenJetGenPartMerger::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivate

Definition at line 69 of file GenJetGenPartMerger.cc.

References cut_, trigObjTnPSource_cfi::filler, iEvent, metsig::jet, jetToken_, eostools::move(), MillePedeFileConverter_cfg::out, partToken_, and tauAncToken_.

69  {
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 }
std::vector< GenJet > GenJetCollection
collection of GenJet objects
int iEvent
Definition: GenABIO.cc:224
Jets made from MC generator particles.
Definition: GenJet.h:23
part
Definition: HCALResponse.h:20
const edm::EDGetTokenT< reco::GenJetCollection > jetToken_
const StringCutObjectSelector< reco::Candidate > cut_
HLT enums.
const edm::EDGetTokenT< reco::GenParticleCollection > partToken_
const edm::EDGetTokenT< edm::ValueMap< bool > > tauAncToken_
def move(src, dest)
Definition: eostools.py:511

Member Data Documentation

◆ cut_

const StringCutObjectSelector<reco::Candidate> GenJetGenPartMerger::cut_
private

Definition at line 38 of file GenJetGenPartMerger.cc.

Referenced by produce().

◆ jetToken_

const edm::EDGetTokenT<reco::GenJetCollection> GenJetGenPartMerger::jetToken_
private

Definition at line 36 of file GenJetGenPartMerger.cc.

Referenced by produce().

◆ partToken_

const edm::EDGetTokenT<reco::GenParticleCollection> GenJetGenPartMerger::partToken_
private

Definition at line 37 of file GenJetGenPartMerger.cc.

Referenced by produce().

◆ tauAncToken_

const edm::EDGetTokenT<edm::ValueMap<bool> > GenJetGenPartMerger::tauAncToken_
private

Definition at line 39 of file GenJetGenPartMerger.cc.

Referenced by produce().