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

Public Member Functions

 PFCand_NoPU_WithAM (const edm::ParameterSet &)
 
 ~PFCand_NoPU_WithAM ()
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDProducer ()
 
- 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
 
 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)
 

Static Public Member Functions

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

Private Member Functions

virtual void produce (edm::Event &, const edm::EventSetup &)
 

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::EDProducer
typedef EDProducer ModuleType
 
- Public Types inherited from edm::ProducerBase
typedef ProductRegistryHelper::TypeLabelList TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- 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

Definition at line 52 of file PFCand_NoPU_WithAM.h.

Constructor & Destructor Documentation

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().

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

Definition at line 78 of file PFCand_NoPU_WithAM.cc.

79 {
80 
81  // do anything here that needs to be done at desctruction time
82  // (e.g. close files, deallocate resources etc.)
83 
84 }

Member Function Documentation

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

Definition at line 190 of file PFCand_NoPU_WithAM.cc.

References edm::ConfigurationDescriptions::addDefault(), DEFINE_FWK_MODULE, and edm::ParameterSetDescription::setUnknown().

190  {
191  //The following says we do not know what parameters are allowed so do no validation
192  // Please change this to state exactly what you do use, even if it is no parameters
194  desc.setUnknown();
195  descriptions.addDefault(desc);
196 }
void addDefault(ParameterSetDescription const &psetDescription)
void PFCand_NoPU_WithAM::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
privatevirtual

Definition at line 92 of file PFCand_NoPU_WithAM.cc.

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

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

93 {
94 
95  unique_ptr<PFCandidateCollection> p2v_firstvertex(new PFCandidateCollection() );
96  unique_ptr<PFCandidateCollection> v2p_firstvertex(new PFCandidateCollection() );
97 
98  bool p2vassmap = false;
99  bool v2passmap = false;
100 
101  //get the input vertex<->pf-candidate association map
104 
105  string asstype = input_AssociationType_.label();
106 
107  if ( ( asstype == "PFCandsToVertex" ) || ( asstype == "Both" ) ) {
108  if ( iEvent.getByToken(token_PFCandToVertexAssMap_, p2vAM ) ) {
109  p2vassmap = true;
110  }
111  }
112 
113  if ( ( asstype == "VertexToPFCands" ) || ( asstype == "Both" ) ) {
114  if ( iEvent.getByToken(token_VertexToPFCandAssMap_, v2pAM ) ) {
115  v2passmap = true;
116  }
117  }
118 
119  if ( !p2vassmap && !v2passmap ) {
120  cout << "No input collection could be found" << endl;
121  return;
122  }
123 
124  int negativeQuality = 0;
125  if ( input_MinQuality_ >= 2) {
126  negativeQuality = -1;
127  } else {
128  if ( input_MinQuality_ == 1) {
129  negativeQuality = -2;
130  } else{
131  negativeQuality = -3;
132  }
133  }
134 
135  if ( p2vassmap ){
136 
137  const PFCandQualityPairVector pfccoll = p2vAM->begin()->val;
138 
139  //get the candidates associated to the first vertex and store them in a pf-candidate collection
140  for (unsigned int pfccoll_ite = 0; pfccoll_ite < pfccoll.size(); pfccoll_ite++){
141 
142  PFCandidateRef pfcand = pfccoll[pfccoll_ite].first;
143  int quality = pfccoll[pfccoll_ite].second;
144 
145  if ( (quality>=input_MinQuality_) || ( (quality<0) && (quality>=negativeQuality) ) ) {
146  p2v_firstvertex->push_back(*pfcand);
147 
148  }
149 
150  }
151 
152  iEvent.put(std::move(p2v_firstvertex), "P2V" );
153 
154  }
155 
156  if ( v2passmap ) {
157 
158  //get the input vertex collection
159  Handle<VertexCollection> input_vtxcollH;
160  iEvent.getByToken(token_VertexCollection_,input_vtxcollH);
161 
162  VertexRef firstVertexRef(input_vtxcollH,0);
163 
165 
166  for(v2p_ite=v2pAM->begin(); v2p_ite!=v2pAM->end(); v2p_ite++){
167 
168  PFCandidateRef pfcand = v2p_ite->key;
169 
170  for(unsigned v_ite = 0; v_ite<(v2p_ite->val).size(); v_ite++){
171 
172  VertexRef vtxref = (v2p_ite->val)[v_ite].first;
173  int quality = (v2p_ite->val)[v_ite].second;
174 
175  if ( (vtxref==firstVertexRef) && ( (quality>=input_MinQuality_) || ( (quality<0) && (quality>=negativeQuality) ) ) ) {
176  v2p_firstvertex->push_back(*pfcand);
177  }
178 
179  }
180 
181  }
182 
183  iEvent.put(std::move(v2p_firstvertex), "V2P" );
184 
185  }
186 }
size
Write out results.
edm::EDGetTokenT< reco::VertexCollection > token_VertexCollection_
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:122
const_iterator end() const
last iterator over the map (read only)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:460
edm::EDGetTokenT< VertexToPFCandAssMap > token_VertexToPFCandAssMap_
edm::EDGetTokenT< PFCandToVertexAssMap > token_PFCandToVertexAssMap_
U second(std::pair< T, U > const &p)
std::vector< PFCandQualityPair > PFCandQualityPairVector
std::vector< reco::PFCandidate > PFCandidateCollection
collection of PFCandidates
std::string const & label() const
Definition: InputTag.h:36
edm::InputTag input_AssociationType_
const_iterator begin() const
first iterator over the map (read only)
def move(src, dest)
Definition: eostools.py:510

Member Data Documentation

edm::InputTag PFCand_NoPU_WithAM::input_AssociationType_
private

Definition at line 64 of file PFCand_NoPU_WithAM.h.

int PFCand_NoPU_WithAM::input_MinQuality_
private

Definition at line 71 of file PFCand_NoPU_WithAM.h.

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

Definition at line 66 of file PFCand_NoPU_WithAM.h.

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

Definition at line 69 of file PFCand_NoPU_WithAM.h.

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

Definition at line 67 of file PFCand_NoPU_WithAM.h.