CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
PFCandidateMuonUntagger Class Reference

Take: More...

Inheritance diagram for PFCandidateMuonUntagger:
edm::global::EDProducer<> edm::global::EDProducerBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 PFCandidateMuonUntagger (const edm::ParameterSet &)
 
void produce (edm::StreamID iID, edm::Event &, const edm::EventSetup &) const override
 
 ~PFCandidateMuonUntagger () override
 
- Public Member Functions inherited from edm::global::EDProducer<>
 EDProducer ()=default
 
bool hasAbilityToProduceInLumis () const final
 
bool hasAbilityToProduceInRuns () const final
 
bool wantsGlobalLuminosityBlocks () const final
 
bool wantsGlobalRuns () const final
 
bool wantsStreamLuminosityBlocks () const final
 
bool wantsStreamRuns () const final
 
- Public Member Functions inherited from edm::global::EDProducerBase
 EDProducerBase ()
 
ModuleDescription const & moduleDescription () const
 
 ~EDProducerBase () override
 
- 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 ()
 
std::vector< edm::ProductResolverIndex > const & putTokenIndexToProductResolverIndex () const
 
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, ModuleToResolverIndicies const &iIndicies, std::string const &moduleLabel)
 
 ~ProducerBase () noexcept(false) override
 
- 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
 
ESProxyIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
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
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProxyIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Member Functions

template<typename H1 >
void writeValueMap (edm::Event &out, const H1 &from, const std::vector< int > values, const std::string &name)
 

Private Attributes

edm::EDGetTokenT< edm::Association< std::vector< reco::Muon > > > oldToNewMuons_
 
edm::EDGetTokenT< std::vector< reco::PFCandidate > > pfcandidates_
 

Additional Inherited Members

- Public Types inherited from edm::global::EDProducerBase
typedef EDProducerBase ModuleType
 
- Public Types inherited from edm::ProducerBase
using ModuleToResolverIndicies = std::unordered_multimap< std::string, std::tuple< edm::TypeID const *, const char *, edm::ProductResolverIndex >>
 
typedef ProductRegistryHelper::TypeLabelList TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::global::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 ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
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

Take:

Definition at line 24 of file PFCandidateMuonUntagger.cc.

Constructor & Destructor Documentation

PFCandidateMuonUntagger::PFCandidateMuonUntagger ( const edm::ParameterSet iConfig)

Definition at line 47 of file PFCandidateMuonUntagger.cc.

47  :
48  pfcandidates_(consumes<std::vector<reco::PFCandidate>>(iConfig.getParameter<edm::InputTag>("pfcandidates"))),
49  oldToNewMuons_(consumes<edm::Association<std::vector<reco::Muon>>>(iConfig.getParameter<edm::InputTag>("oldToNewMuons")))
50 {
51  produces<std::vector<reco::PFCandidate>>();
52  produces<std::vector<reco::PFCandidate>>("discarded");
53  produces<edm::ValueMap<reco::PFCandidateRef>>();
54 }
T getParameter(std::string const &) const
edm::EDGetTokenT< edm::Association< std::vector< reco::Muon > > > oldToNewMuons_
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
edm::EDGetTokenT< std::vector< reco::PFCandidate > > pfcandidates_
PFCandidateMuonUntagger::~PFCandidateMuonUntagger ( )
inlineoverride

Definition at line 27 of file PFCandidateMuonUntagger.cc.

References produce().

27 {};

Member Function Documentation

void PFCandidateMuonUntagger::produce ( edm::StreamID  iID,
edm::Event iEvent,
const edm::EventSetup  
) const
override

Definition at line 56 of file PFCandidateMuonUntagger.cc.

References funct::abs(), popcon2dropbox::copy(), DEFINE_FWK_MODULE, edm::helper::Filler< Map >::fill(), objects.autophobj::filler, edm::Event::getByToken(), mps_fire::i, edm::helper::Filler< Map >::insert(), eostools::move(), gen::n, lumidbDDL::newToOld(), lumidbDDL::oldToNew(), oldToNewMuons_, packedPFCandidateRefMixer_cfi::pf, packedPFCandidateRefMixer_cfi::pf2pf, pfcandidates_, and edm::Event::put().

Referenced by JSONExport.JsonExport::export(), HTMLExport.HTMLExport::export(), HTMLExport.HTMLExportStatic::export(), and ~PFCandidateMuonUntagger().

57 {
59  iEvent.getByToken(oldToNewMuons_, oldToNewMuons);
60 
62  iEvent.getByToken(pfcandidates_, pfcandidates);
63 
64  int n = pfcandidates->size();
65  std::unique_ptr<std::vector<reco::PFCandidate>> copy(new std::vector<reco::PFCandidate>());
66  std::unique_ptr<std::vector<reco::PFCandidate>> discarded(new std::vector<reco::PFCandidate>());
67  copy->reserve(n);
68  std::vector<int> oldToNew(n), newToOld, badToOld;
69  newToOld.reserve(n);
70 
71  int i = -1;
72  for (const reco::PFCandidate &pf : *pfcandidates) {
73  ++i;
74  if (pf.muonRef().isNonnull()) {
75  reco::MuonRef newRef = (*oldToNewMuons)[pf.muonRef()];
76  if (abs(pf.pdgId()) == 13 && !newRef->isPFMuon()) { // was untagging
77  discarded->push_back(pf);
78  oldToNew[i] = (-discarded->size());
79  badToOld.push_back(i);
80  discarded->back().setMuonRef(newRef);
81  } else {
82  copy->push_back(pf);
83  oldToNew[i] = (copy->size());
84  newToOld.push_back(i);
85  copy->back().setMuonRef(newRef);
86  }
87  } else {
88  copy->push_back(pf);
89  oldToNew[i] = (copy->size());
90  newToOld.push_back(i);
91  }
92  }
93 
94  // Now we put things in the event
96  edm::OrphanHandle<std::vector<reco::PFCandidate>> badpf = iEvent.put(std::move(discarded), "discarded");
97 
98  std::unique_ptr<edm::ValueMap<reco::PFCandidateRef>> pf2pf(new edm::ValueMap<reco::PFCandidateRef>());
100  std::vector<reco::PFCandidateRef> refs; refs.reserve(n);
101  // old to new
102  for (i = 0; i < n; ++i) {
103  if (oldToNew[i] > 0) {
104  refs.push_back(reco::PFCandidateRef(newpf, oldToNew[i]-1));
105  } else {
106  refs.push_back(reco::PFCandidateRef(badpf,-oldToNew[i]-1));
107  }
108  }
109  filler.insert(pfcandidates, refs.begin(), refs.end());
110  // new good to old
111  refs.clear();
112  for (int i : newToOld) {
113  refs.push_back(reco::PFCandidateRef(pfcandidates,i));
114  }
115  filler.insert(newpf, refs.begin(), refs.end());
116  // new bad to old
117  refs.clear();
118  for (int i : badToOld) {
119  refs.push_back(reco::PFCandidateRef(pfcandidates,i));
120  }
121  filler.insert(badpf, refs.begin(), refs.end());
122  // done
123  filler.fill();
124  iEvent.put(std::move(pf2pf));
125 }
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:125
def copy(args, dbName)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:517
edm::EDGetTokenT< edm::Association< std::vector< reco::Muon > > > oldToNewMuons_
def oldToNew(schema)
Definition: lumidbDDL.py:402
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
Particle reconstructed by the particle flow algorithm.
Definition: PFCandidate.h:40
def newToOld(schema)
Definition: lumidbDDL.py:416
def move(src, dest)
Definition: eostools.py:511
edm::EDGetTokenT< std::vector< reco::PFCandidate > > pfcandidates_
template<typename H1 >
void PFCandidateMuonUntagger::writeValueMap ( edm::Event out,
const H1 &  from,
const std::vector< int >  values,
const std::string &  name 
)
inlineprivate

Definition at line 36 of file PFCandidateMuonUntagger.cc.

References objects.autophobj::filler, eostools::move(), and edm::Event::put().

36  {
37  typedef edm::ValueMap<int> IntMap;
38  std::unique_ptr<IntMap> intmap(new IntMap());
39  typename IntMap::Filler filler(*intmap);
40  filler.insert(from, values.begin(), values.end());
41  filler.fill();
42  out.put(std::move(intmap), name);
43  }
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:125
def move(src, dest)
Definition: eostools.py:511

Member Data Documentation

edm::EDGetTokenT<edm::Association<std::vector<reco::Muon> > > PFCandidateMuonUntagger::oldToNewMuons_
private

Definition at line 33 of file PFCandidateMuonUntagger.cc.

Referenced by produce().

edm::EDGetTokenT<std::vector<reco::PFCandidate> > PFCandidateMuonUntagger::pfcandidates_
private

Definition at line 32 of file PFCandidateMuonUntagger.cc.

Referenced by produce().