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  //now do what ever other initialization is needed
35 
36  input_AssociationType_ = iConfig.getParameter<edm::InputTag>("AssociationType");
37 
39  consumes<reco::PFCandidateCollection>(iConfig.getParameter<edm::InputTag>("PFCandidateCollection"));
40 
41  //register your products
42 
43  if (input_AssociationType_.label() == "PFCandsToVertex") {
44  produces<PFCandToVertexAssMap>();
45  } else {
46  if (input_AssociationType_.label() == "VertexToPFCands") {
47  produces<VertexToPFCandAssMap>();
48  } else {
49  if (input_AssociationType_.label() == "Both") {
50  produces<PFCandToVertexAssMap>();
51  produces<VertexToPFCandAssMap>();
52  } else {
53  std::cout << "No correct InputTag for AssociationType!" << std::endl;
54  std::cout << "Won't produce any AssociationMap!" << std::endl;
55  }
56  }
57  }
58 }
59 
61 
62 //
63 // member functions
64 //
65 
66 // ------------ method called to produce the data ------------
68  using namespace edm;
69  using namespace std;
70  using namespace reco;
71 
72  //get the input pfCandidateCollection
74  iEvent.getByToken(token_PFCandidates_, pfCandH);
75 
76  string asstype = input_AssociationType_.label();
77 
79 
80  if (asstype == "PFCandsToVertex" || asstype == "VertexToPFCands" || asstype == "Both") {
81  auto mappings = createMappings(pfCandH, iSetup);
82  if (asstype == "PFCandsToVertex" || asstype == "Both") {
83  iEvent.put(SortPFCandAssociationMap(&(*mappings.first), &iEvent.productGetter()));
84  }
85  if (asstype == "VertexToPFCands" || asstype == "Both") {
86  iEvent.put(std::move(mappings.second));
87  }
88  }
89 }
90 
91 // ------------ method fills 'descriptions' with the allowed parameters for the module ------------
93  //The following says we do not know what parameters are allowed so do no validation
94  // Please change this to state exactly what you do use, even if it is no parameters
96  desc.setUnknown();
97  descriptions.addDefault(desc);
98 }
99 
100 //define this as a plug-in
PFCand_AssoMap::~PFCand_AssoMap
~PFCand_AssoMap() override
Definition: PFCand_AssoMap.cc:60
Handle.h
MessageLogger.h
PFCand_AssoMap::produce
void produce(edm::Event &, const edm::EventSetup &) override
Definition: PFCand_AssoMap.cc:67
PFCand_AssoMap::PFCand_AssoMap
PFCand_AssoMap(const edm::ParameterSet &)
Definition: PFCand_AssoMap.cc:33
edm
HLT enums.
Definition: AlignableModifier.h:19
gather_cfg.cout
cout
Definition: gather_cfg.py:144
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
PFCand_AssoMapAlgos::GetInputCollections
void GetInputCollections(edm::Event &, const edm::EventSetup &) override
Definition: PFCand_AssoMapAlgos.cc:27
PFCand_AssoMapAlgos::createMappings
std::pair< std::unique_ptr< PFCandToVertexAssMap >, std::unique_ptr< VertexToPFCandAssMap > > createMappings(edm::Handle< reco::PFCandidateCollection > pfCandH, const edm::EventSetup &iSetup)
Definition: PFCand_AssoMapAlgos.cc:43
reco
fixed size matrix
Definition: AlignmentAlgorithmBase.h:45
edm::Handle
Definition: AssociativeIterator.h:50
edm::InputTag::label
std::string const & label() const
Definition: InputTag.h:36
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
PFCand_AssoMap::token_PFCandidates_
edm::EDGetTokenT< reco::PFCandidateCollection > token_PFCandidates_
Definition: PFCand_AssoMap.h:50
PFCand_AssoMapAlgos
Definition: PFCand_AssoMapAlgos.h:41
edm::ConfigurationDescriptions
Definition: ConfigurationDescriptions.h:28
edm::ParameterSet
Definition: ParameterSet.h:36
PFCand_AssoMap.h
PFCand_AssoMap::input_AssociationType_
edm::InputTag input_AssociationType_
Definition: PFCand_AssoMap.h:48
iEvent
int iEvent
Definition: GenABIO.cc:224
edm::ParameterSetDescription::setUnknown
void setUnknown()
Definition: ParameterSetDescription.cc:39
edm::EventSetup
Definition: EventSetup.h:57
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
eostools.move
def move(src, dest)
Definition: eostools.py:511
std
Definition: JetResolutionObject.h:76
PFCand_AssoMapAlgos::SortPFCandAssociationMap
std::unique_ptr< PFCandToVertexAssMap > SortPFCandAssociationMap(PFCandToVertexAssMap *, edm::EDProductGetter const *getter)
Definition: PFCand_AssoMapAlgos.cc:127
PFCand_AssoMap::fillDescriptions
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Definition: PFCand_AssoMap.cc:92
View.h
PFCand_AssoMap
Definition: PFCand_AssoMap.h:36
edm::Event
Definition: Event.h:73
edm::ConfigurationDescriptions::addDefault
void addDefault(ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:99
edm::InputTag
Definition: InputTag.h:15