CMS 3D CMS Logo

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.5 2012/11/21 09:52:27 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 //
33 PFCand_AssoMap::PFCand_AssoMap(const edm::ParameterSet& iConfig):PFCand_AssoMapAlgos(iConfig, consumesCollector())
34 {
35 
36  //now do what ever other initialization is needed
37 
38  input_AssociationType_ = iConfig.getParameter<edm::InputTag>("AssociationType");
39 
40  token_PFCandidates_ = consumes<reco::PFCandidateCollection>(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.getByToken(token_PFCandidates_,pfCandH);
84 
85  string asstype = input_AssociationType_.label();
86 
88 
89  if ( ( asstype == "PFCandsToVertex" ) || ( asstype == "Both" ) ) {
90  unique_ptr<PFCandToVertexAssMap> PFCand2Vertex = CreatePFCandToVertexMap(pfCandH, iSetup);
91  iEvent.put( SortPFCandAssociationMap( &(*PFCand2Vertex), &iEvent.productGetter() ) );
92  }
93 
94  if ( ( asstype == "VertexToPFCands" ) || ( asstype == "Both" ) ) {
95  unique_ptr<VertexToPFCandAssMap> Vertex2PFCand = CreateVertexToPFCandMap(pfCandH, iSetup);
96  iEvent.put(std::move(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
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:122
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:457
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
EDProductGetter const & productGetter() const
Definition: Event.cc:56
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
int iEvent
Definition: GenABIO.cc:230
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 &)
edm::InputTag input_AssociationType_
edm::EDGetTokenT< reco::PFCandidateCollection > token_PFCandidates_
void GetInputCollections(edm::Event &, const edm::EventSetup &)
std::string const & label() const
Definition: InputTag.h:36
fixed size matrix
HLT enums.
PFCand_AssoMap(const edm::ParameterSet &)
virtual void produce(edm::Event &, const edm::EventSetup &)
std::unique_ptr< PFCandToVertexAssMap > SortPFCandAssociationMap(PFCandToVertexAssMap *, edm::EDProductGetter const *getter)
def move(src, dest)
Definition: eostools.py:510