CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
PFCand_AssoMap.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: PFCand_AssoMap
4 // Class: PFCand_AssoMap
5 //
10 //
11 // Original Author: Matthias Geisler
12 // Created: Wed Apr 18 14:48:37 CEST 2012
13 // $Id: PFCand_AssoMap.cc,v 1.6 2012/12/06 14:02:13 mgeisler Exp $
14 //
15 //
17 
18 // system include files
19 #include <memory>
20 #include <vector>
21 #include <string>
22 
23 // user include files
24 
26 
29 
30 //
31 // constructors and destructor
32 //
34 {
35 
36  //now do what ever other initialization is needed
37 
38  input_AssociationType_ = iConfig.getParameter<edm::InputTag>("AssociationType");
39 
40  input_PFCandidates_ = iConfig.getParameter<edm::InputTag>("PFCandidateCollection");
41 
42  //register your products
43 
44  if ( input_AssociationType_.label() == "PFCandsToVertex" ) {
45  produces<PFCandToVertexAssMap>();
46  } else {
47  if ( input_AssociationType_.label() == "VertexToPFCands" ) {
48  produces<VertexToPFCandAssMap>();
49  } else {
50  if ( input_AssociationType_.label() == "Both" ) {
51  produces<PFCandToVertexAssMap>();
52  produces<VertexToPFCandAssMap>();
53  } else {
54  edm::LogWarning("Prtcl2VtxAssociation") << "No correct InputTag for AssociationType!" << std::endl
55  << "Won't produce any AssociationMap!" << std::endl;
56  }
57  }
58  }
59 
60 }
61 
62 
64 {
65 }
66 
67 
68 //
69 // member functions
70 //
71 
72 // ------------ method called to produce the data ------------
73 void
75 {
76 
77  using namespace edm;
78  using namespace std;
79  using namespace reco;
80 
81  //get the input pfCandidateCollection
83  iEvent.getByLabel(input_PFCandidates_,pfCandH);
84 
85  string asstype = input_AssociationType_.label();
86 
88 
90 
91  if ( ( asstype == "PFCandsToVertex" ) || ( asstype == "Both" ) ) {
92  auto_ptr<PFCandToVertexAssMap> PFCand2Vertex = CreatePFCandToVertexMap(pfCandH, iSetup);
93  iEvent.put( SortPFCandAssociationMap( &(*PFCand2Vertex) ) );
94  }
95 
96  if ( ( asstype == "VertexToPFCands" ) || ( asstype == "Both" ) ) {
97  auto_ptr<VertexToPFCandAssMap> Vertex2PFCand = CreateVertexToPFCandMap(pfCandH, iSetup);
98  iEvent.put( Vertex2PFCand );
99  }
100 
101 }
102 
103 // ------------ method fills 'descriptions' with the allowed parameters for the module ------------
104 void
106  //The following says we do not know what parameters are allowed so do no validation
107  // Please change this to state exactly what you do use, even if it is no parameters
109  desc.setUnknown();
110  descriptions.addDefault(desc);
111 }
112 
113 //define this as a plug-in
T getParameter(std::string const &) const
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
int iEvent
Definition: GenABIO.cc:243
void addDefault(ParameterSetDescription const &psetDescription)
std::auto_ptr< VertexToPFCandAssMap > CreateVertexToPFCandMap(edm::Handle< reco::PFCandidateCollection >, const edm::EventSetup &)
std::auto_ptr< PFCandToVertexAssMap > CreatePFCandToVertexMap(edm::Handle< reco::PFCandidateCollection >, const edm::EventSetup &)
std::auto_ptr< PFCandToVertexAssMap > SortPFCandAssociationMap(PFCandToVertexAssMap *)
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:116
edm::InputTag input_AssociationType_
void SetMotherPointer(edm::Handle< reco::PFCandidateCollection > &)
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:390
void GetPFCandInputCollections(edm::Event &, const edm::EventSetup &)
std::string const & label() const
Definition: InputTag.h:42
PFCand_AssoMap(const edm::ParameterSet &)
virtual void produce(edm::Event &, const edm::EventSetup &)
edm::InputTag input_PFCandidates_