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 hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndRuns () 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

◆ PATGenJetSlimmer()

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

Definition at line 48 of file PATGenJetSlimmer.cc.

49  : src_(consumes<edm::View<reco::GenJet> >(iConfig.getParameter<edm::InputTag>("src"))),
50  gp2pgp_(consumes<edm::Association<std::vector<pat::PackedGenParticle> > >(
51  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  produces<std::vector<reco::GenJet> >();
58  produces<edm::Association<std::vector<reco::GenJet> > >("slimmedGenJetAssociation");
59 }

◆ ~PATGenJetSlimmer()

pat::PATGenJetSlimmer::~PATGenJetSlimmer ( )
inlineoverride

Definition at line 28 of file PATGenJetSlimmer.cc.

28 {}

Member Function Documentation

◆ produce()

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

Definition at line 61 of file PATGenJetSlimmer.cc.

61  {
62  using namespace edm;
63  using namespace std;
64 
66  iEvent.getByToken(src_, src);
67 
68  auto out = std::make_unique<vector<reco::GenJet> >();
69  out->reserve(src->size());
70 
72  iEvent.getByToken(gp2pgp_, gp2pgp);
73 
74  auto genJetSlimmedGenJetAssociation = make_unique<edm::Association<std::vector<reco::GenJet> > >();
75 
76  auto mapping = std::make_unique<std::vector<int> >();
77  mapping->reserve(src->size());
78 
79  unsigned nl = 0; // number of loose jets
80  for (View<reco::GenJet>::const_iterator it = src->begin(), ed = src->end(); it != ed; ++it) {
81  bool selectedLoose = false;
82  if (nLoose_ > 0 && nl < nLoose_ && cutLoose_(*it)) {
83  selectedLoose = true;
84  ++nl;
85  }
86 
87  bool pass = cut_(*it) || selectedLoose;
88  if (!pass) {
89  mapping->push_back(-1);
90  continue;
91  }
92 
93  out->push_back(*it);
94  reco::GenJet& jet = out->back();
95 
96  mapping->push_back(it - src->begin());
97 
98  if (clearDaughters_) {
99  jet.clearDaughters();
100  } else // rekey
101  {
102  //copy old
103  reco::CompositePtrCandidate::daughters old = jet.daughterPtrVector();
104  jet.clearDaughters();
105  std::map<unsigned int, reco::CandidatePtr> ptrs;
106  for (unsigned int i = 0; i < old.size(); i++) {
107  // if(! ((*gp2pgp)[old[i]]).isNonnull()) {
108  // 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;
109  // }
110  ptrs[((*gp2pgp)[old[i]]).key()] = refToPtr((*gp2pgp)[old[i]]);
111  }
112  for (std::map<unsigned int, reco::CandidatePtr>::iterator itp = ptrs.begin(); itp != ptrs.end();
113  itp++) //iterate on sorted items
114  {
115  jet.addDaughter(itp->second);
116  }
117  }
118  if (dropSpecific_) {
119  jet.setSpecific(reco::GenJet::Specific());
120  }
121  }
122 
124 
125  auto asso = std::make_unique<edm::Association<std::vector<reco::GenJet> > >(orphanHandle);
126  edm::Association<std::vector<reco::GenJet> >::Filler slimmedAssoFiller(*asso);
127  slimmedAssoFiller.insert(src, mapping->begin(), mapping->end());
128  slimmedAssoFiller.fill();
129 
130  iEvent.put(std::move(asso), "slimmedGenJetAssociation");
131 }

References mps_fire::i, iEvent, metsig::jet, crabWrapper::key, taus_updatedMVAIds_cff::mapping, eostools::move(), MillePedeFileConverter_cfg::out, edm::refToPtr(), and TrackRefitter_38T_cff::src.

Member Data Documentation

◆ clearDaughters_

const bool pat::PATGenJetSlimmer::clearDaughters_
private

reset daughters to an empty vector

Definition at line 41 of file PATGenJetSlimmer.cc.

◆ cut_

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

Definition at line 36 of file PATGenJetSlimmer.cc.

◆ cutLoose_

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

Definition at line 37 of file PATGenJetSlimmer.cc.

◆ dropSpecific_

const bool pat::PATGenJetSlimmer::dropSpecific_
private

drop the specific

Definition at line 43 of file PATGenJetSlimmer.cc.

◆ gp2pgp_

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

Definition at line 34 of file PATGenJetSlimmer.cc.

◆ nLoose_

const unsigned pat::PATGenJetSlimmer::nLoose_
private

Definition at line 38 of file PATGenJetSlimmer.cc.

◆ src_

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

Definition at line 33 of file PATGenJetSlimmer.cc.

mps_fire.i
i
Definition: mps_fire.py:355
reco::GenJet
Jets made from MC generator particles.
Definition: GenJet.h:23
edm
HLT enums.
Definition: AlignableModifier.h:19
pat::PATGenJetSlimmer::cutLoose_
const StringCutObjectSelector< reco::GenJet > cutLoose_
Definition: PATGenJetSlimmer.cc:37
edm::Handle
Definition: AssociativeIterator.h:50
edm::refToPtr
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
reco::GenJet::Specific
Definition: GenJet.h:25
pat::PATGenJetSlimmer::clearDaughters_
const bool clearDaughters_
reset daughters to an empty vector
Definition: PATGenJetSlimmer.cc:41
pat::PATGenJetSlimmer::cut_
const StringCutObjectSelector< reco::GenJet > cut_
Definition: PATGenJetSlimmer.cc:36
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::View
Definition: CaloClusterFwd.h:14
pat::PATGenJetSlimmer::gp2pgp_
const edm::EDGetTokenT< edm::Association< std::vector< pat::PackedGenParticle > > > gp2pgp_
Definition: PATGenJetSlimmer.cc:34
pat::PATGenJetSlimmer::dropSpecific_
const bool dropSpecific_
drop the specific
Definition: PATGenJetSlimmer.cc:43
TrackRefitter_38T_cff.src
src
Definition: TrackRefitter_38T_cff.py:24
iEvent
int iEvent
Definition: GenABIO.cc:224
pat::PATGenJetSlimmer::nLoose_
const unsigned nLoose_
Definition: PATGenJetSlimmer.cc:38
edm::Association
Definition: Association.h:18
reco::CompositePtrCandidate::daughters
std::vector< CandidatePtr > daughters
collection of references to daughters
Definition: CompositePtrCandidate.h:20
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
eostools.move
def move(src, dest)
Definition: eostools.py:511
std
Definition: JetResolutionObject.h:76
edm::OrphanHandle
Definition: EDProductfwd.h:39
metsig::jet
Definition: SignAlgoResolutions.h:47
pat::PATGenJetSlimmer::src_
const edm::EDGetTokenT< edm::View< reco::GenJet > > src_
Definition: PATGenJetSlimmer.cc:33
edm::View::const_iterator
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:86
MillePedeFileConverter_cfg.out
out
Definition: MillePedeFileConverter_cfg.py:31
crabWrapper.key
key
Definition: crabWrapper.py:19
taus_updatedMVAIds_cff.mapping
mapping
Definition: taus_updatedMVAIds_cff.py:28
edm::InputTag
Definition: InputTag.h:15