CMS 3D CMS Logo

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

#include <PFCand_NoPU_WithAM.h>

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

Public Member Functions

 PFCand_NoPU_WithAM (const edm::ParameterSet &)
 
- Public Member Functions inherited from edm::global::EDProducer<>
 EDProducer ()=default
 
 EDProducer (const EDProducer &)=delete
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
EDProduceroperator= (const EDProducer &)=delete
 
bool wantsGlobalLuminosityBlocks () const final
 
bool wantsGlobalRuns () const final
 
bool wantsInputProcessBlocks () const final
 
bool wantsProcessBlocks () 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
 
std::vector< bool > const & recordProvenanceList () 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)
 
TypeLabelList const & typeLabelList () const
 used by the fwk to register the list of products of this module More...
 
 ~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
 
std::vector< ESProxyIndex > const & esGetTokenIndicesVector (edm::Transition iTrans) const
 
std::vector< ESRecordIndex > const & esGetTokenRecordIndicesVector (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::array< std::vector< ModuleDescription const *> *, NumBranchTypes > &modulesAll, std::vector< ModuleProcessName > &modulesInPreviousProcesses, 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 selectInputProcessBlocks (ProductRegistry const &productRegistry, ProcessBlockHelperBase const &processBlockHelperBase)
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProxyIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 
- Static Public Member Functions inherited from edm::global::EDProducerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 

Private Member Functions

void produce (edm::StreamID, edm::Event &, const edm::EventSetup &) const override
 

Private Attributes

edm::InputTag input_AssociationType_
 
int input_MinQuality_
 
edm::EDGetTokenT< PFCandToVertexAssMaptoken_PFCandToVertexAssMap_
 
edm::EDGetTokenT< reco::VertexCollectiontoken_VertexCollection_
 
edm::EDGetTokenT< VertexToPFCandAssMaptoken_VertexToPFCandAssMap_
 

Additional Inherited Members

- Public Types inherited from edm::global::EDProducerBase
typedef EDProducerBase ModuleType
 
- Public Types inherited from edm::ProducerBase
template<typename T >
using BranchAliasSetterT = ProductRegistryHelper::BranchAliasSetterT< T >
 
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
 
- Protected Member Functions inherited from edm::ProducerBase
template<Transition Tr = Transition::Event>
auto produces (std::string instanceName) noexcept
 declare what type of product will make and with which optional label More...
 
template<Transition B>
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
template<BranchType B>
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
template<typename ProductType , Transition B>
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<class ProductType >
BranchAliasSetterT< ProductType > produces ()
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces ()
 
template<class ProductType >
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<typename ProductType , Transition B>
BranchAliasSetterT< ProductType > produces ()
 
template<Transition Tr = Transition::Event>
auto produces () noexcept
 
ProducesCollector producesCollector ()
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< Bconsumes (edm::InputTag tag) noexcept
 
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<Transition Tr = Transition::Event>
constexpr auto esConsumes ()
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag)
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
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)
 
void resetItemsToGetFrom (BranchType iType)
 

Detailed Description

Definition at line 53 of file PFCand_NoPU_WithAM.h.

Constructor & Destructor Documentation

◆ PFCand_NoPU_WithAM()

PFCand_NoPU_WithAM::PFCand_NoPU_WithAM ( const edm::ParameterSet iConfig)
explicit

Definition at line 44 of file PFCand_NoPU_WithAM.cc.

References gather_cfg::cout, and edm::ParameterSet::getParameter().

44  {
45  //now do what ever other initialization is needed
46 
47  input_AssociationType_ = iConfig.getParameter<InputTag>("AssociationType");
48 
50  mayConsume<PFCandToVertexAssMap>(iConfig.getParameter<InputTag>("VertexPFCandAssociationMap"));
52  mayConsume<VertexToPFCandAssMap>(iConfig.getParameter<InputTag>("VertexPFCandAssociationMap"));
53 
54  token_VertexCollection_ = mayConsume<VertexCollection>(iConfig.getParameter<InputTag>("VertexCollection"));
55 
56  input_MinQuality_ = iConfig.getParameter<int>("MinQuality");
57 
58  //register your products
59 
60  if (input_AssociationType_.label() == "PFCandsToVertex") {
61  produces<PFCandidateCollection>("P2V");
62  } else {
63  if (input_AssociationType_.label() == "VertexToPFCands") {
64  produces<PFCandidateCollection>("V2P");
65  } else {
66  if (input_AssociationType_.label() == "Both") {
67  produces<PFCandidateCollection>("P2V");
68  produces<PFCandidateCollection>("V2P");
69  } else {
70  cout << "No correct InputTag for AssociationType!" << endl;
71  cout << "Won't produce any PFCandiateCollection!" << endl;
72  }
73  }
74  }
75 }
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
edm::EDGetTokenT< reco::VertexCollection > token_VertexCollection_
edm::EDGetTokenT< VertexToPFCandAssMap > token_VertexToPFCandAssMap_
edm::EDGetTokenT< PFCandToVertexAssMap > token_PFCandToVertexAssMap_
std::string const & label() const
Definition: InputTag.h:36
edm::InputTag input_AssociationType_

Member Function Documentation

◆ fillDescriptions()

void PFCand_NoPU_WithAM::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 167 of file PFCand_NoPU_WithAM.cc.

References edm::ConfigurationDescriptions::addDefault(), and submitPVResolutionJobs::desc.

167  {
168  //The following says we do not know what parameters are allowed so do no validation
169  // Please change this to state exactly what you do use, even if it is no parameters
171 
172  desc.add<InputTag>("AssociationType");
173  desc.add<InputTag>("VertexPFCandAssociationMap");
174  desc.add<InputTag>("VertexCollection");
175  desc.add<int>("MinQuality");
176 
177  descriptions.addDefault(desc);
178 }
void addDefault(ParameterSetDescription const &psetDescription)

◆ produce()

void PFCand_NoPU_WithAM::produce ( edm::StreamID  ,
edm::Event iEvent,
const edm::EventSetup iSetup 
) const
overrideprivatevirtual

Implements edm::global::EDProducerBase.

Definition at line 82 of file PFCand_NoPU_WithAM.cc.

References edm::AssociationMap< Tag >::begin(), gather_cfg::cout, edm::AssociationMap< Tag >::end(), edm::first(), iEvent, edm::helpers::KeyVal< K, V >::key, eostools::move(), pfDeepBoostedJetPreprocessParams_cfi::pfcand, quality, edm::second(), findQualityFiles::size, and edm::helpers::KeyVal< K, V >::val.

82  {
83  unique_ptr<PFCandidateCollection> p2v_firstvertex(new PFCandidateCollection());
84  unique_ptr<PFCandidateCollection> v2p_firstvertex(new PFCandidateCollection());
85 
86  bool p2vassmap = false;
87  bool v2passmap = false;
88 
89  //get the input vertex<->pf-candidate association map
92 
93  string asstype = input_AssociationType_.label();
94 
95  if ((asstype == "PFCandsToVertex") || (asstype == "Both")) {
96  if (iEvent.getByToken(token_PFCandToVertexAssMap_, p2vAM)) {
97  p2vassmap = true;
98  }
99  }
100 
101  if ((asstype == "VertexToPFCands") || (asstype == "Both")) {
102  if (iEvent.getByToken(token_VertexToPFCandAssMap_, v2pAM)) {
103  v2passmap = true;
104  }
105  }
106 
107  if (!p2vassmap && !v2passmap) {
108  cout << "No input collection could be found" << endl;
109  return;
110  }
111 
112  int negativeQuality = 0;
113  if (input_MinQuality_ >= 2) {
114  negativeQuality = -1;
115  } else {
116  if (input_MinQuality_ == 1) {
117  negativeQuality = -2;
118  } else {
119  negativeQuality = -3;
120  }
121  }
122 
123  if (p2vassmap) {
124  const PFCandQualityPairVector pfccoll = p2vAM->begin()->val;
125 
126  //get the candidates associated to the first vertex and store them in a pf-candidate collection
127  for (unsigned int pfccoll_ite = 0; pfccoll_ite < pfccoll.size(); pfccoll_ite++) {
128  PFCandidateRef pfcand = pfccoll[pfccoll_ite].first;
129  int quality = pfccoll[pfccoll_ite].second;
130 
131  if ((quality >= input_MinQuality_) || ((quality < 0) && (quality >= negativeQuality))) {
132  p2v_firstvertex->push_back(*pfcand);
133  }
134  }
135 
136  iEvent.put(std::move(p2v_firstvertex), "P2V");
137  }
138 
139  if (v2passmap) {
140  //get the input vertex collection
141  Handle<VertexCollection> input_vtxcollH;
142  iEvent.getByToken(token_VertexCollection_, input_vtxcollH);
143 
144  VertexRef firstVertexRef(input_vtxcollH, 0);
145 
147 
148  for (v2p_ite = v2pAM->begin(); v2p_ite != v2pAM->end(); v2p_ite++) {
149  PFCandidateRef pfcand = v2p_ite->key;
150 
151  for (unsigned v_ite = 0; v_ite < (v2p_ite->val).size(); v_ite++) {
152  VertexRef vtxref = (v2p_ite->val)[v_ite].first;
153  int quality = (v2p_ite->val)[v_ite].second;
154 
155  if ((vtxref == firstVertexRef) &&
156  ((quality >= input_MinQuality_) || ((quality < 0) && (quality >= negativeQuality)))) {
157  v2p_firstvertex->push_back(*pfcand);
158  }
159  }
160  }
161 
162  iEvent.put(std::move(v2p_firstvertex), "V2P");
163  }
164 }
size
Write out results.
edm::EDGetTokenT< reco::VertexCollection > token_VertexCollection_
std::vector< l1t::PFCandidate > PFCandidateCollection
Definition: PFCandidate.h:82
edm::EDGetTokenT< VertexToPFCandAssMap > token_VertexToPFCandAssMap_
edm::EDGetTokenT< PFCandToVertexAssMap > token_PFCandToVertexAssMap_
std::string const & label() const
Definition: InputTag.h:36
const_iterator end() const
last iterator over the map (read only)
U second(std::pair< T, U > const &p)
string quality
int iEvent
Definition: GenABIO.cc:224
std::vector< PFCandQualityPair > PFCandQualityPairVector
const_iterator begin() const
first iterator over the map (read only)
edm::InputTag input_AssociationType_
def move(src, dest)
Definition: eostools.py:511

Member Data Documentation

◆ input_AssociationType_

edm::InputTag PFCand_NoPU_WithAM::input_AssociationType_
private

Definition at line 64 of file PFCand_NoPU_WithAM.h.

◆ input_MinQuality_

int PFCand_NoPU_WithAM::input_MinQuality_
private

Definition at line 71 of file PFCand_NoPU_WithAM.h.

◆ token_PFCandToVertexAssMap_

edm::EDGetTokenT<PFCandToVertexAssMap> PFCand_NoPU_WithAM::token_PFCandToVertexAssMap_
private

Definition at line 66 of file PFCand_NoPU_WithAM.h.

◆ token_VertexCollection_

edm::EDGetTokenT<reco::VertexCollection> PFCand_NoPU_WithAM::token_VertexCollection_
private

Definition at line 69 of file PFCand_NoPU_WithAM.h.

◆ token_VertexToPFCandAssMap_

edm::EDGetTokenT<VertexToPFCandAssMap> PFCand_NoPU_WithAM::token_VertexToPFCandAssMap_
private

Definition at line 67 of file PFCand_NoPU_WithAM.h.