CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription
const &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 
- Public Member Functions inherited from edm::EDConsumerBase
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

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::InputTag input_SourceColl_
 
edm::InputTag input_VertexCollection_
 
edm::InputTag input_VertexPFCandAssociationMap_
 
int negativeQuality_
 

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Protected Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
- 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 54 of file PFCand_NoPU_WithAM.h.

Constructor & Destructor Documentation

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

Definition at line 46 of file PFCand_NoPU_WithAM.cc.

References edm::ParameterSet::getParameter().

47 {
48  //now do what ever other initialization is needed
49 
50  input_AssociationType_ = iConfig.getParameter<InputTag>("AssociationType");
51 
52  input_VertexPFCandAssociationMap_ = iConfig.getParameter<InputTag>("VertexPFCandAssociationMap");
53 
54  input_VertexCollection_ = iConfig.getParameter<InputTag>("VertexCollection");
55 
56  input_MinQuality_ = iConfig.getParameter<int>("MinQuality");
57 
58  if ( input_MinQuality_ >= 3) {
59  negativeQuality_ = -1;
60  } else {
61  if ( input_MinQuality_ >= 1) {
62  negativeQuality_ = -2;
63  } else{
64  negativeQuality_ = -3;
65  }
66  }
67 
68 
69  //register your products
70 
71  if ( input_AssociationType_.label() == "PFCandsToVertex" ) {
72  produces<PFCandidateCollection>("P2V");
73  } else {
74  if ( input_AssociationType_.label() == "VertexToPFCands" ) {
75  produces<PFCandidateCollection>("V2P");
76  } else {
77  if ( input_AssociationType_.label() == "Both" ) {
78  produces<PFCandidateCollection>("P2V");
79  produces<PFCandidateCollection>("V2P");
80  } else {
81  edm::LogWarning("FirstVertexParticles") << "No correct InputTag for AssociationType!" << std::endl
82  << "Won't produce any PFCandidateCollection!" << std::endl;
83  }
84  }
85  }
86 
87 }
T getParameter(std::string const &) const
edm::InputTag input_VertexPFCandAssociationMap_
edm::InputTag input_VertexCollection_
std::string const & label() const
Definition: InputTag.h:42
edm::InputTag input_AssociationType_
PFCand_NoPU_WithAM::~PFCand_NoPU_WithAM ( )

Definition at line 90 of file PFCand_NoPU_WithAM.cc.

91 {
92 
93  // do anything here that needs to be done at desctruction time
94  // (e.g. close files, deallocate resources etc.)
95 
96 }

Member Function Documentation

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

Definition at line 196 of file PFCand_NoPU_WithAM.cc.

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

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

Implements edm::EDProducer.

Definition at line 104 of file PFCand_NoPU_WithAM.cc.

References edm::first(), edm::Event::getByLabel(), edm::helpers::KeyVal< K, V >::key, edm::Event::put(), edm::second(), findQualityFiles::size, and edm::helpers::KeyVal< K, V >::val.

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

105 {
106 
107  auto_ptr<PFCandidateCollection> p2v_firstvertex(new PFCandidateCollection() );
108  auto_ptr<PFCandidateCollection> v2p_firstvertex(new PFCandidateCollection() );
109 
110  bool p2vassmap = false;
111  bool v2passmap = false;
112 
113  //get the input vertex<->pf-candidate association map
116 
117  string asstype = input_AssociationType_.label();
118 
119  if ( ( asstype == "PFCandsToVertex" ) || ( asstype == "Both" ) ) {
120  if ( iEvent.getByLabel(input_VertexPFCandAssociationMap_, p2vAM ) ) {
121  p2vassmap = true;
122  }
123  }
124 
125  if ( ( asstype == "VertexToPFCands" ) || ( asstype == "Both" ) ) {
126  if ( iEvent.getByLabel(input_VertexPFCandAssociationMap_, v2pAM ) ) {
127  v2passmap = true;
128  }
129  }
130 
131  if ( !p2vassmap && !v2passmap ) {
132  edm::LogWarning("FirstVertexParticles") << "PFCand_NoPU_WithAM:: No input collection could be found" << endl;
133  return;
134  }
135 
136  if ( p2vassmap ) {
137 
138  if ( p2vAM->size()==0 ) {
139  iEvent.put( p2v_firstvertex, "P2V" );
140  return;
141  }
142 
143  const PFCandQualityPairVector pfccoll = p2vAM->begin()->val;
144 
145  //get the candidates associated to the first vertex and store them in a pf-candidate collection
146  for ( unsigned int pfccoll_ite = 0; pfccoll_ite < pfccoll.size(); pfccoll_ite++ ) {
147 
148  PFCandidateRef pfcand = pfccoll[pfccoll_ite].first;
149  int quality = pfccoll[pfccoll_ite].second;
150 
151  if ( (quality>=input_MinQuality_) || ( (quality<0) && (quality>=negativeQuality_) ) ) {
152  p2v_firstvertex->push_back( *pfcand );
153  }
154 
155  }
156 
157  iEvent.put( p2v_firstvertex, "P2V" );
158 
159  }
160 
161  if ( v2passmap ) {
162 
163  //get the input vertex collection
164  Handle<VertexCollection> input_vtxcollH;
165  iEvent.getByLabel(input_VertexCollection_,input_vtxcollH);
166 
167  VertexRef firstVertexRef(input_vtxcollH,0);
168 
170 
171  for(v2p_ite=v2pAM->begin(); v2p_ite!=v2pAM->end(); v2p_ite++){
172 
173  PFCandidateRef pfcand = v2p_ite->key;
174 
175  for(unsigned v_ite = 0; v_ite<(v2p_ite->val).size(); v_ite++){
176 
177  VertexRef vtxref = (v2p_ite->val)[v_ite].first;
178  int quality = (v2p_ite->val)[v_ite].second;
179 
180  if ( (vtxref==firstVertexRef) && ( (quality>=input_MinQuality_) || ( (quality<0) && (quality>=negativeQuality_) ) ) ) {
181  v2p_firstvertex->push_back( *pfcand);
182  }
183 
184  }
185 
186  }
187 
188  iEvent.put( v2p_firstvertex, "V2P" );
189 
190  }
191 
192 }
U second(std::pair< T, U > const &p)
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:116
std::vector< PFCandQualityPair > PFCandQualityPairVector
bool first
Definition: L1TdeRCT.cc:79
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:390
std::vector< reco::PFCandidate > PFCandidateCollection
collection of PFCandidates
edm::InputTag input_VertexPFCandAssociationMap_
edm::InputTag input_VertexCollection_
std::string const & label() const
Definition: InputTag.h:42
edm::InputTag input_AssociationType_
tuple size
Write out results.

Member Data Documentation

edm::InputTag PFCand_NoPU_WithAM::input_AssociationType_
private

Definition at line 68 of file PFCand_NoPU_WithAM.h.

int PFCand_NoPU_WithAM::input_MinQuality_
private

Definition at line 74 of file PFCand_NoPU_WithAM.h.

edm::InputTag PFCand_NoPU_WithAM::input_SourceColl_
private

Definition at line 66 of file PFCand_NoPU_WithAM.h.

edm::InputTag PFCand_NoPU_WithAM::input_VertexCollection_
private

Definition at line 72 of file PFCand_NoPU_WithAM.h.

edm::InputTag PFCand_NoPU_WithAM::input_VertexPFCandAssociationMap_
private

Definition at line 70 of file PFCand_NoPU_WithAM.h.

int PFCand_NoPU_WithAM::negativeQuality_
private

Definition at line 75 of file PFCand_NoPU_WithAM.h.