Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-07-28 03:09:33

0001 // -*- C++ -*-
0002 //
0003 // Package:    PFCand_AssoMap
0004 // Class:      PFCand_AssoMap
0005 //
0006 /**\class PFCand_AssoMap PFCand_AssoMap.cc CommonTools/RecoUtils/plugins/PFCand_AssoMap.cc
0007 
0008   Description: Produces a map with association between pf candidates and their particular most probable vertex with a quality of this association
0009 */
0010 //
0011 // Original Author:  Matthias Geisler
0012 //         Created:  Wed Apr 18 14:48:37 CEST 2012
0013 // $Id: PFCand_AssoMap.cc,v 1.5 2012/11/21 09:52:27 mgeisler Exp $
0014 //
0015 //
0016 #include "CommonTools/RecoUtils/interface/PFCand_AssoMap.h"
0017 
0018 // system include files
0019 #include <memory>
0020 #include <vector>
0021 #include <string>
0022 
0023 // user include files
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 // constructors and destructor
0032 //
0033 PFCand_AssoMap::PFCand_AssoMap(const edm::ParameterSet& iConfig) : PFCand_AssoMapAlgos(iConfig, consumesCollector()) {
0034   //now do what ever other initialization is needed
0035 
0036   input_AssociationType_ = iConfig.getParameter<edm::InputTag>("AssociationType");
0037 
0038   token_PFCandidates_ =
0039       consumes<reco::PFCandidateCollection>(iConfig.getParameter<edm::InputTag>("PFCandidateCollection"));
0040 
0041   //register your products
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 // member functions
0064 //
0065 
0066 // ------------ method called to produce the data  ------------
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   //get the input pfCandidateCollection
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 // ------------ method fills 'descriptions' with the allowed parameters for the module  ------------
0092 void PFCand_AssoMap::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0093   //The following says we do not know what parameters are allowed so do no validation
0094   // Please change this to state exactly what you do use, even if it is no parameters
0095   edm::ParameterSetDescription desc;
0096   desc.setUnknown();
0097   descriptions.addDefault(desc);
0098 }
0099 
0100 //define this as a plug-in
0101 DEFINE_FWK_MODULE(PFCand_AssoMap);