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  std::cout << "No correct InputTag for AssociationType!" << std::endl;
55  std::cout << "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 
89  if ( ( asstype == "PFCandsToVertex" ) || ( asstype == "Both" ) ) {
90  auto_ptr<PFCandToVertexAssMap> PFCand2Vertex = CreatePFCandToVertexMap(pfCandH, iSetup);
91  iEvent.put( SortPFCandAssociationMap( &(*PFCand2Vertex) ) );
92  }
93 
94  if ( ( asstype == "VertexToPFCands" ) || ( asstype == "Both" ) ) {
95  auto_ptr<VertexToPFCandAssMap> Vertex2PFCand = CreateVertexToPFCandMap(pfCandH, iSetup);
96  iEvent.put( Vertex2PFCand );
97  }
98 
99 }
100 
101 // ------------ method fills 'descriptions' with the allowed parameters for the module ------------
102 void
104  //The following says we do not know what parameters are allowed so do no validation
105  // Please change this to state exactly what you do use, even if it is no parameters
107  desc.setUnknown();
108  descriptions.addDefault(desc);
109 }
110 
111 //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:85
edm::InputTag input_AssociationType_
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:356
void GetInputCollections(edm::Event &, const edm::EventSetup &)
std::string const & label() const
Definition: InputTag.h:25
PFCand_AssoMap(const edm::ParameterSet &)
virtual void produce(edm::Event &, const edm::EventSetup &)
tuple cout
Definition: gather_cfg.py:121
edm::InputTag input_PFCandidates_