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
 
bool hasAbilityToProduceInLumis () const final
 
bool hasAbilityToProduceInRuns () const final
 

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<>
typedef CacheContexts< T... > CacheTypes
 
typedef CacheTypes::GlobalCache GlobalCache
 
typedef AbilityChecker< T... > HasAbility
 
typedef CacheTypes::LuminosityBlockCache LuminosityBlockCache
 
typedef LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCacheLuminosityBlockContext
 
typedef CacheTypes::LuminosityBlockSummaryCache LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache, GlobalCacheRunContext
 
typedef CacheTypes::RunSummaryCache 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 }
T getParameter(std::string const &) const
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 ( )
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.

References DEFINE_FWK_MODULE.

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(), objects.autophobj::filler, edm::Event::getByToken(), edm::helper::Filler< Map >::insert(), metsig::jet, jetToken_, eostools::move(), MillePedeFileConverter_cfg::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:125
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:517
std::vector< GenJet > GenJetCollection
collection of GenJet objects
void setCharge(Charge q) final
set electric charge
Definition: LeafCandidate.h:93
Jets made from MC generator particles.
Definition: GenJet.h:25
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_
void setPdgId(int pdgId) final
void setP4(const LorentzVector &p4) final
set 4-momentum
def move(src, dest)
Definition: eostools.py:511

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().