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<> edm::stream::EDProducerBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 PATGenJetSlimmer (const edm::ParameterSet &iConfig)
 
virtual void produce (edm::Event &iEvent, const edm::EventSetup &iSetup)
 
virtual ~PATGenJetSlimmer ()
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
- Public Member Functions inherited from edm::stream::EDProducerBase
 EDProducerBase ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDProducerBase ()
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
std::vector< edm::ProductResolverIndex > const & indiciesForPutProducts (BranchType iBranchType) const
 
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription const &)> registrationCallback () const
 used by the fwk to register list of products More...
 
void resolvePutIndicies (BranchType iBranchType, std::unordered_multimap< std::string, edm::ProductResolverIndex > const &iIndicies, std::string const &moduleLabel)
 
virtual ~ProducerBase () noexcept(false)
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Attributes

const bool clearDaughters_
 reset daughters to an empty vector More...
 
const StringCutObjectSelector< reco::GenJetcut_
 
const bool dropSpecific_
 drop the specific More...
 
const edm::EDGetTokenT< edm::Association< std::vector< pat::PackedGenParticle > > > gp2pgp_
 
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
 
- Public Types inherited from edm::stream::EDProducerBase
typedef EDProducerAdaptorBase ModuleType
 
- Public Types inherited from edm::ProducerBase
typedef ProductRegistryHelper::TypeLabelList TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::stream::EDProducerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

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 47 of file PATGenJetSlimmer.cc.

47  :
49  gp2pgp_(consumes<edm::Association<std::vector<pat::PackedGenParticle> > >(iConfig.getParameter<edm::InputTag>("packedGenParticles"))),
50  cut_(iConfig.getParameter<std::string>("cut")),
51  clearDaughters_(iConfig.getParameter<bool>("clearDaughters")),
52  dropSpecific_(iConfig.getParameter<bool>("dropSpecific"))
53 {
54  produces<std::vector<reco::GenJet> >();
55  produces< edm::Association<std::vector<reco::GenJet> > >("slimmedGenJetAssociation");
56 }
T getParameter(std::string const &) const
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
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_
virtual pat::PATGenJetSlimmer::~PATGenJetSlimmer ( )
inlinevirtual

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 
)
virtual

Definition at line 59 of file PATGenJetSlimmer.cc.

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

Referenced by ~PATGenJetSlimmer().

59  {
60  using namespace edm;
61  using namespace std;
62 
64  iEvent.getByToken(src_, src);
65 
66  auto out = std::make_unique<vector<reco::GenJet> >();
67  out->reserve(src->size());
68 
70  iEvent.getByToken(gp2pgp_,gp2pgp);
71 
72  auto genJetSlimmedGenJetAssociation = make_unique< edm::Association<std::vector<reco::GenJet> > > ();
73 
74  auto mapping = std::make_unique<std::vector<int> >();
75  mapping->reserve(src->size());
76 
77  for (View<reco::GenJet>::const_iterator it = src->begin(), ed = src->end(); it != ed; ++it) {
78  if (!cut_(*it)) {
79  mapping->push_back(-1);
80  continue;
81  }
82 
83  out->push_back(*it);
84  reco::GenJet & jet = out->back();
85 
86  mapping->push_back(it-src->begin());
87 
88 
89  if (clearDaughters_) {
90  jet.clearDaughters();
91  }
92  else // rekey
93  {
94  //copy old
96  jet.clearDaughters();
97  std::map<unsigned int,reco::CandidatePtr> ptrs;
98  for(unsigned int i=0;i<old.size();i++)
99  {
100 // if(! ((*gp2pgp)[old[i]]).isNonnull()) {
101 // 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;
102 // }
103  ptrs[((*gp2pgp)[old[i]]).key()]=refToPtr((*gp2pgp)[old[i]]);
104  }
105  for(std::map<unsigned int,reco::CandidatePtr>::iterator itp=ptrs.begin();itp!=ptrs.end();itp++) //iterate on sorted items
106  {
107  jet.addDaughter(itp->second);
108  }
109 
110 
111  }
112  if (dropSpecific_) {
114  }
115 
116  }
117 
119 
120  auto asso = std::make_unique<edm::Association<std::vector<reco::GenJet> > >(orphanHandle);
121  edm::Association< std::vector<reco::GenJet> >::Filler slimmedAssoFiller(*asso);
122  slimmedAssoFiller.insert(src, mapping->begin(), mapping->end());
123  slimmedAssoFiller.fill();
124 
125 
126  iEvent.put(std::move(asso),"slimmedGenJetAssociation");
127 }
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:122
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:460
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
const daughters & daughterPtrVector() const
references to daughtes
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 39 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 bool pat::PATGenJetSlimmer::dropSpecific_
private

drop the specific

Definition at line 41 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 edm::EDGetTokenT<edm::View<reco::GenJet> > pat::PATGenJetSlimmer::src_
private

Definition at line 33 of file PATGenJetSlimmer.cc.

Referenced by produce().