CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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::Candidate
cut_
 
const edm::EDGetTokenT
< reco::GenJetCollection
jetToken_
 
const edm::EDGetTokenT
< reco::GenParticleCollection
partToken_
 
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 ( 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 }
const edm::EDGetTokenT< reco::GenJetCollection > jetToken_
const StringCutObjectSelector< reco::Candidate > cut_
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
const edm::EDGetTokenT< reco::GenParticleCollection > partToken_
const edm::EDGetTokenT< edm::ValueMap< bool > > tauAncToken_
GenJetGenPartMerger::~GenJetGenPartMerger ( )
override

Definition at line 62 of file GenJetGenPartMerger.cc.

62 {}

Member Function Documentation

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

Definition at line 113 of file GenJetGenPartMerger.cc.

113 {}
void GenJetGenPartMerger::endStream ( )
overrideprivate

Definition at line 116 of file GenJetGenPartMerger.cc.

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

Definition at line 69 of file GenJetGenPartMerger.cc.

References cut_, edm::helper::Filler< Map >::fill(), edm::Event::getByToken(), edm::helper::Filler< Map >::insert(), metsig::jet, jetToken_, isotrackNtupler::merged, eostools::move(), submitPVResolutionJobs::out, partToken_, edm::Event::put(), reco::LeafCandidate::setCharge(), reco::LeafCandidate::setP4(), reco::LeafCandidate::setPdgId(), 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 }
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:133
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:539
std::vector< GenJet > GenJetCollection
collection of GenJet objects
void setCharge(Charge q) final
set electric charge
def move
Definition: eostools.py:511
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_
const edm::EDGetTokenT< reco::GenParticleCollection > partToken_
const edm::EDGetTokenT< edm::ValueMap< bool > > tauAncToken_
void setPdgId(int pdgId) final
void setP4(const LorentzVector &p4) final
set 4-momentum

Member Data Documentation

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

Definition at line 38 of file GenJetGenPartMerger.cc.

Referenced by produce().

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

Definition at line 36 of file GenJetGenPartMerger.cc.

Referenced by produce().

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

Definition at line 37 of file GenJetGenPartMerger.cc.

Referenced by produce().

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

Definition at line 39 of file GenJetGenPartMerger.cc.

Referenced by produce().