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 ()
 
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 ()
 
ProductHolderIndex indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndex > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndex > &) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) 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_VertexCollection_
 
edm::InputTag input_VertexPFCandAssociationMap_
 

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
typedef WorkerT< EDProducerWorkerType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Protected Member Functions inherited from edm::EDProducer
CurrentProcessingContext const * currentContext () const
 
- 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 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  input_VertexPFCandAssociationMap_ = iConfig.getParameter<InputTag>("VertexPFCandAssociationMap");
51 
52  input_VertexCollection_ = iConfig.getParameter<InputTag>("VertexCollection");
53 
54  input_MinQuality_ = iConfig.getParameter<int>("MinQuality");
55 
56  //register your products
57 
58  if ( input_AssociationType_.label() == "PFCandsToVertex" ) {
59  produces<PFCandidateCollection>("P2V");
60  } else {
61  if ( input_AssociationType_.label() == "VertexToPFCands" ) {
62  produces<PFCandidateCollection>("V2P");
63  } else {
64  if ( input_AssociationType_.label() == "Both" ) {
65  produces<PFCandidateCollection>("P2V");
66  produces<PFCandidateCollection>("V2P");
67  } else {
68  cout << "No correct InputTag for AssociationType!" << endl;
69  cout << "Won't produce any PFCandiateCollection!" << endl;
70  }
71  }
72  }
73 
74 }
T getParameter(std::string const &) const
edm::InputTag input_VertexPFCandAssociationMap_
edm::InputTag input_VertexCollection_
std::string const & label() const
Definition: InputTag.h:42
tuple cout
Definition: gather_cfg.py:121
edm::InputTag input_AssociationType_
PFCand_NoPU_WithAM::~PFCand_NoPU_WithAM ( )

Definition at line 77 of file PFCand_NoPU_WithAM.cc.

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

Member Function Documentation

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

Definition at line 189 of file PFCand_NoPU_WithAM.cc.

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

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

Implements edm::EDProducer.

Definition at line 91 of file PFCand_NoPU_WithAM.cc.

References gather_cfg::cout, 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().

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

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 70 of file PFCand_NoPU_WithAM.h.

edm::InputTag PFCand_NoPU_WithAM::input_VertexCollection_
private

Definition at line 68 of file PFCand_NoPU_WithAM.h.

edm::InputTag PFCand_NoPU_WithAM::input_VertexPFCandAssociationMap_
private

Definition at line 66 of file PFCand_NoPU_WithAM.h.