CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
pat::PATGenJetSlimmer Class Reference

Matcher of reconstructed objects to L1 Muons. More...

Inheritance diagram for pat::PATGenJetSlimmer:
edm::stream::EDProducer<>

Public Member Functions

 PATGenJetSlimmer (const edm::ParameterSet &iConfig)
 
void produce (edm::Event &iEvent, const edm::EventSetup &iSetup) override
 
 ~PATGenJetSlimmer () override
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
bool hasAbilityToProduceInLumis () const final
 
bool hasAbilityToProduceInRuns () const final
 

Private Attributes

const bool clearDaughters_
 reset daughters to an empty vector More...
 
const StringCutObjectSelector< reco::GenJetcut_
 
const StringCutObjectSelector< reco::GenJetcutLoose_
 
const bool dropSpecific_
 drop the specific More...
 
const edm::EDGetTokenT< edm::Association< std::vector< pat::PackedGenParticle > > > gp2pgp_
 
const unsigned nLoose_
 
const edm::EDGetTokenT< edm::View< reco::GenJet > > src_
 

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

Matcher of reconstructed objects to L1 Muons.

Author
Giovanni Petrucciani

Definition at line 25 of file PATGenJetSlimmer.cc.

Constructor & Destructor Documentation

pat::PATGenJetSlimmer::PATGenJetSlimmer ( const edm::ParameterSet iConfig)
explicit

Definition at line 49 of file PATGenJetSlimmer.cc.

49  :
50  src_(consumes<edm::View<reco::GenJet> >(iConfig.getParameter<edm::InputTag>("src"))),
51  gp2pgp_(consumes<edm::Association<std::vector<pat::PackedGenParticle> > >(iConfig.getParameter<edm::InputTag>("packedGenParticles"))),
52  cut_(iConfig.getParameter<std::string>("cut")),
53  cutLoose_(iConfig.getParameter<std::string>("cutLoose")),
54  nLoose_(iConfig.getParameter<unsigned>("nLoose")),
55  clearDaughters_(iConfig.getParameter<bool>("clearDaughters")),
56  dropSpecific_(iConfig.getParameter<bool>("dropSpecific"))
57 {
58  produces<std::vector<reco::GenJet> >();
59  produces< edm::Association<std::vector<reco::GenJet> > >("slimmedGenJetAssociation");
60 }
T getParameter(std::string const &) const
const StringCutObjectSelector< reco::GenJet > cutLoose_
const bool clearDaughters_
reset daughters to an empty vector
const StringCutObjectSelector< reco::GenJet > cut_
const edm::EDGetTokenT< edm::Association< std::vector< pat::PackedGenParticle > > > gp2pgp_
const bool dropSpecific_
drop the specific
const edm::EDGetTokenT< edm::View< reco::GenJet > > src_
pat::PATGenJetSlimmer::~PATGenJetSlimmer ( )
inlineoverride

Definition at line 28 of file PATGenJetSlimmer.cc.

References iEvent, and produce().

28 { }

Member Function Documentation

void pat::PATGenJetSlimmer::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
override

Definition at line 63 of file PATGenJetSlimmer.cc.

References reco::CompositePtrCandidate::addDaughter(), reco::CompositePtrCandidate::clearDaughters(), clearDaughters_, cut_, cutLoose_, reco::CompositePtrCandidate::daughterPtrVector(), DEFINE_FWK_MODULE, dropSpecific_, edm::Event::getByToken(), gp2pgp_, mps_fire::i, metsig::jet, crabWrapper::key, taus_updatedMVAIds_cff::mapping, eostools::move(), nLoose_, MillePedeFileConverter_cfg::out, edm::Event::put(), edm::refToPtr(), reco::GenJet::setSpecific(), TrackRefitter_38T_cff::src, and src_.

Referenced by ~PATGenJetSlimmer().

63  {
64  using namespace edm;
65  using namespace std;
66 
68  iEvent.getByToken(src_, src);
69 
70  auto out = std::make_unique<vector<reco::GenJet> >();
71  out->reserve(src->size());
72 
74  iEvent.getByToken(gp2pgp_,gp2pgp);
75 
76  auto genJetSlimmedGenJetAssociation = make_unique< edm::Association<std::vector<reco::GenJet> > > ();
77 
78  auto mapping = std::make_unique<std::vector<int> >();
79  mapping->reserve(src->size());
80 
81  unsigned nl = 0; // number of loose jets
82  for (View<reco::GenJet>::const_iterator it = src->begin(), ed = src->end(); it != ed; ++it) {
83 
84  bool selectedLoose = false;
85  if ( nLoose_ > 0 && nl < nLoose_ && cutLoose_(*it) ) {
86  selectedLoose = true;
87  ++nl;
88  }
89 
90  bool pass = cut_(*it) || selectedLoose;
91  if (!pass ) {
92  mapping->push_back(-1);
93  continue;
94  }
95 
96  out->push_back(*it);
97  reco::GenJet & jet = out->back();
98 
99  mapping->push_back(it-src->begin());
100 
101 
102  if (clearDaughters_) {
103  jet.clearDaughters();
104  }
105  else // rekey
106  {
107  //copy old
109  jet.clearDaughters();
110  std::map<unsigned int,reco::CandidatePtr> ptrs;
111  for(unsigned int i=0;i<old.size();i++)
112  {
113 // if(! ((*gp2pgp)[old[i]]).isNonnull()) {
114 // std::cout << "Missing ref for key" << old[i].key() << " pdgid " << old[i]->pdgId() << " st "<< old[i]->status() << " pt " << old[i]->pt() << " eta " << old[i]->eta() << std::endl;
115 // }
116  ptrs[((*gp2pgp)[old[i]]).key()]=refToPtr((*gp2pgp)[old[i]]);
117  }
118  for(std::map<unsigned int,reco::CandidatePtr>::iterator itp=ptrs.begin();itp!=ptrs.end();itp++) //iterate on sorted items
119  {
120  jet.addDaughter(itp->second);
121  }
122 
123 
124  }
125  if (dropSpecific_) {
127  }
128 
129  }
130 
132 
133  auto asso = std::make_unique<edm::Association<std::vector<reco::GenJet> > >(orphanHandle);
134  edm::Association< std::vector<reco::GenJet> >::Filler slimmedAssoFiller(*asso);
135  slimmedAssoFiller.insert(src, mapping->begin(), mapping->end());
136  slimmedAssoFiller.fill();
137 
138 
139  iEvent.put(std::move(asso),"slimmedGenJetAssociation");
140 }
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:137
Ptr< typename C::value_type > refToPtr(Ref< C, typename C::value_type, refhelper::FindUsingAdvance< C, typename C::value_type > > const &ref)
Definition: RefToPtr.h:18
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:579
const StringCutObjectSelector< reco::GenJet > cutLoose_
virtual const daughters & daughterPtrVector() const
references to daughtes
const bool clearDaughters_
reset daughters to an empty vector
const StringCutObjectSelector< reco::GenJet > cut_
const edm::EDGetTokenT< edm::Association< std::vector< pat::PackedGenParticle > > > gp2pgp_
const bool dropSpecific_
drop the specific
Jets made from MC generator particles.
Definition: GenJet.h:24
std::vector< CandidatePtr > daughters
collection of references to daughters
const edm::EDGetTokenT< edm::View< reco::GenJet > > src_
void clearDaughters()
clear daughter references
HLT enums.
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:86
void setSpecific(const Specific &spec)
set the specific (note: responsibility of keeping it consistent with the jet daughers belongs to the ...
Definition: GenJet.h:80
void addDaughter(const CandidatePtr &)
add a daughter via a reference
def move(src, dest)
Definition: eostools.py:510

Member Data Documentation

const bool pat::PATGenJetSlimmer::clearDaughters_
private

reset daughters to an empty vector

Definition at line 41 of file PATGenJetSlimmer.cc.

Referenced by produce().

const StringCutObjectSelector<reco::GenJet> pat::PATGenJetSlimmer::cut_
private

Definition at line 36 of file PATGenJetSlimmer.cc.

Referenced by produce().

const StringCutObjectSelector<reco::GenJet> pat::PATGenJetSlimmer::cutLoose_
private

Definition at line 37 of file PATGenJetSlimmer.cc.

Referenced by produce().

const bool pat::PATGenJetSlimmer::dropSpecific_
private

drop the specific

Definition at line 43 of file PATGenJetSlimmer.cc.

Referenced by produce().

const edm::EDGetTokenT<edm::Association<std::vector<pat::PackedGenParticle> > > pat::PATGenJetSlimmer::gp2pgp_
private

Definition at line 34 of file PATGenJetSlimmer.cc.

Referenced by produce().

const unsigned pat::PATGenJetSlimmer::nLoose_
private

Definition at line 38 of file PATGenJetSlimmer.cc.

Referenced by produce().

const edm::EDGetTokenT<edm::View<reco::GenJet> > pat::PATGenJetSlimmer::src_
private

Definition at line 33 of file PATGenJetSlimmer.cc.

Referenced by produce().