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
0017 #include "CommonTools/RecoUtils/interface/PF_PU_AssoMap.h"
0018
0019
0020
0021
0022
0023
0024
0025
0026 PF_PU_AssoMap::PF_PU_AssoMap(const edm::ParameterSet& iConfig) : PF_PU_AssoMapAlgos(iConfig, consumesCollector()) {
0027
0028
0029 input_AssociationType_ = iConfig.getParameter<edm::InputTag>("AssociationType");
0030
0031 token_TrackCollection_ = consumes<reco::TrackCollection>(iConfig.getParameter<edm::InputTag>("TrackCollection"));
0032
0033
0034
0035 if (input_AssociationType_.label() == "TracksToVertex") {
0036 produces<TrackToVertexAssMap>();
0037 } else {
0038 if (input_AssociationType_.label() == "VertexToTracks") {
0039 produces<VertexToTrackAssMap>();
0040 } else {
0041 if (input_AssociationType_.label() == "Both") {
0042 produces<TrackToVertexAssMap>();
0043 produces<VertexToTrackAssMap>();
0044 } else {
0045 std::cout << "No correct InputTag for AssociationType!" << std::endl;
0046 std::cout << "Won't produce any AssociationMap!" << std::endl;
0047 }
0048 }
0049 }
0050 }
0051
0052 PF_PU_AssoMap::~PF_PU_AssoMap() {
0053
0054
0055 }
0056
0057
0058
0059
0060
0061
0062 void PF_PU_AssoMap::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) {
0063 using namespace edm;
0064 using namespace std;
0065 using namespace reco;
0066
0067
0068 Handle<TrackCollection> trkcollH;
0069 iEvent.getByToken(token_TrackCollection_, trkcollH);
0070
0071 string asstype = input_AssociationType_.label();
0072
0073 PF_PU_AssoMapAlgos::GetInputCollections(iEvent, iSetup);
0074
0075 if (asstype == "TracksToVertex" || asstype == "VertexToTracks" || asstype == "Both") {
0076 auto mappings = createMappings(trkcollH);
0077 if (asstype == "TracksToVertex" || asstype == "Both") {
0078 iEvent.put(SortAssociationMap(&(*mappings.first), trkcollH));
0079 }
0080 if (asstype == "VertexToTracks" || asstype == "Both") {
0081 iEvent.put(std::move(mappings.second));
0082 }
0083 }
0084 }
0085
0086
0087 void PF_PU_AssoMap::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0088
0089
0090 edm::ParameterSetDescription desc;
0091 desc.setUnknown();
0092 descriptions.addDefault(desc);
0093 }
0094
0095
0096 DEFINE_FWK_MODULE(PF_PU_AssoMap);