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 == "VertexToPFCands" || asstype == "Both") {
90  auto mappings = createMappings(pfCandH, iSetup);
91  if (asstype == "PFCandsToVertex" || asstype == "Both") {
92  iEvent.put( SortPFCandAssociationMap( &(*mappings.first), &iEvent.productGetter() ) );
93  }
94  if (asstype == "VertexToPFCands" || asstype == "Both") {
95  iEvent.put( std::move(mappings.second));
96  }
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
void GetInputCollections(edm::Event &, const edm::EventSetup &) override
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:125
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:517
EDProductGetter const & productGetter() const
Definition: Event.cc:93
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
std::pair< std::unique_ptr< PFCandToVertexAssMap >, std::unique_ptr< VertexToPFCandAssMap > > createMappings(edm::Handle< reco::PFCandidateCollection > pfCandH, const edm::EventSetup &iSetup)
int iEvent
Definition: GenABIO.cc:224
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
void addDefault(ParameterSetDescription const &psetDescription)
edm::InputTag input_AssociationType_
~PFCand_AssoMap() override
edm::EDGetTokenT< reco::PFCandidateCollection > token_PFCandidates_
void produce(edm::Event &, const edm::EventSetup &) override
std::string const & label() const
Definition: InputTag.h:36
fixed size matrix
HLT enums.
PFCand_AssoMap(const edm::ParameterSet &)
std::unique_ptr< PFCandToVertexAssMap > SortPFCandAssociationMap(PFCandToVertexAssMap *, edm::EDProductGetter const *getter)
def move(src, dest)
Definition: eostools.py:511