File indexing completed on 2024-04-06 12:01:11
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016 #include "CommonTools/RecoUtils/interface/PFCand_AssoMap.h"
0017
0018
0019 #include <memory>
0020 #include <vector>
0021 #include <string>
0022
0023
0024
0025 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0026
0027 #include "DataFormats/Common/interface/Handle.h"
0028 #include "DataFormats/Common/interface/View.h"
0029
0030
0031
0032
0033 PFCand_AssoMap::PFCand_AssoMap(const edm::ParameterSet& iConfig) : PFCand_AssoMapAlgos(iConfig, consumesCollector()) {
0034
0035
0036 input_AssociationType_ = iConfig.getParameter<edm::InputTag>("AssociationType");
0037
0038 token_PFCandidates_ =
0039 consumes<reco::PFCandidateCollection>(iConfig.getParameter<edm::InputTag>("PFCandidateCollection"));
0040
0041
0042
0043 if (input_AssociationType_.label() == "PFCandsToVertex") {
0044 produces<PFCandToVertexAssMap>();
0045 } else {
0046 if (input_AssociationType_.label() == "VertexToPFCands") {
0047 produces<VertexToPFCandAssMap>();
0048 } else {
0049 if (input_AssociationType_.label() == "Both") {
0050 produces<PFCandToVertexAssMap>();
0051 produces<VertexToPFCandAssMap>();
0052 } else {
0053 std::cout << "No correct InputTag for AssociationType!" << std::endl;
0054 std::cout << "Won't produce any AssociationMap!" << std::endl;
0055 }
0056 }
0057 }
0058 }
0059
0060 PFCand_AssoMap::~PFCand_AssoMap() {}
0061
0062
0063
0064
0065
0066
0067 void PFCand_AssoMap::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) {
0068 using namespace edm;
0069 using namespace std;
0070 using namespace reco;
0071
0072
0073 Handle<PFCandidateCollection> pfCandH;
0074 iEvent.getByToken(token_PFCandidates_, pfCandH);
0075
0076 string asstype = input_AssociationType_.label();
0077
0078 PFCand_AssoMapAlgos::GetInputCollections(iEvent, iSetup);
0079
0080 if (asstype == "PFCandsToVertex" || asstype == "VertexToPFCands" || asstype == "Both") {
0081 auto mappings = createMappings(pfCandH);
0082 if (asstype == "PFCandsToVertex" || asstype == "Both") {
0083 iEvent.put(SortPFCandAssociationMap(&(*mappings.first), &iEvent.productGetter()));
0084 }
0085 if (asstype == "VertexToPFCands" || asstype == "Both") {
0086 iEvent.put(std::move(mappings.second));
0087 }
0088 }
0089 }
0090
0091
0092 void PFCand_AssoMap::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0093
0094
0095 edm::ParameterSetDescription desc;
0096 desc.setUnknown();
0097 descriptions.addDefault(desc);
0098 }
0099
0100
0101 DEFINE_FWK_MODULE(PFCand_AssoMap);