Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 // -*- C++ -*-
0002 //
0003 // Package:    PF_PU_AssoMap
0004 // Class:      PF_PU_AssoMap
0005 //
0006 /**\class PF_PU_AssoMap PF_PU_AssoMap.cc CommonTools/RecoUtils/plugins/PF_PU_AssoMap.cc
0007 
0008  Description: Produces a map with association between tracks and their particular most probable vertex with a quality of this association
0009 
0010 */
0011 //
0012 // Original Author:  Matthias Geisler,32 4-B20,+41227676487,
0013 // $Id$
0014 //
0015 //
0016 
0017 #include "CommonTools/RecoUtils/interface/PF_PU_AssoMap.h"
0018 
0019 //
0020 // static data member definitions
0021 //
0022 
0023 //
0024 // constructors and destructor
0025 //
0026 PF_PU_AssoMap::PF_PU_AssoMap(const edm::ParameterSet& iConfig) : PF_PU_AssoMapAlgos(iConfig, consumesCollector()) {
0027   //now do what ever other initialization is needed
0028 
0029   input_AssociationType_ = iConfig.getParameter<edm::InputTag>("AssociationType");
0030 
0031   token_TrackCollection_ = consumes<reco::TrackCollection>(iConfig.getParameter<edm::InputTag>("TrackCollection"));
0032 
0033   //register your products
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   // do anything here that needs to be done at destruction time
0054   // (e.g. close files, deallocate resources etc.)
0055 }
0056 
0057 //
0058 // member functions
0059 //
0060 
0061 // ------------ method called to produce the data  ------------
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   //get the input track collection
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 // ------------ method fills 'descriptions' with the allowed parameters for the module  ------------
0087 void PF_PU_AssoMap::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0088   //The following says we do not know what parameters are allowed so do no validation
0089   // Please change this to state exactly what you do use, even if it is no parameters
0090   edm::ParameterSetDescription desc;
0091   desc.setUnknown();
0092   descriptions.addDefault(desc);
0093 }
0094 
0095 //define this as a plug-in
0096 DEFINE_FWK_MODULE(PF_PU_AssoMap);