CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_10_patch2/src/CommonTools/RecoUtils/plugins/PFCand_AssoMap.cc

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 //
00003 // Package:    PFCand_AssoMap
00004 // Class:      PFCand_AssoMap
00005 // 
00010 //
00011 // Original Author:  Matthias Geisler
00012 //         Created:  Wed Apr 18 14:48:37 CEST 2012
00013 // $Id: PFCand_AssoMap.cc,v 1.6 2012/12/06 14:02:13 mgeisler Exp $
00014 //
00015 //
00016 #include "CommonTools/RecoUtils/interface/PFCand_AssoMap.h"
00017 
00018 // system include files
00019 #include <memory>
00020 #include <vector>
00021 #include <string>
00022 
00023 // user include files
00024 
00025 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00026 
00027 #include "DataFormats/Common/interface/Handle.h"
00028 #include "DataFormats/Common/interface/View.h"
00029 
00030 //
00031 // constructors and destructor
00032 //
00033 PFCand_AssoMap::PFCand_AssoMap(const edm::ParameterSet& iConfig):PFCand_AssoMapAlgos(iConfig)
00034 {
00035 
00036    //now do what ever other initialization is needed
00037 
00038         input_AssociationType_ = iConfig.getParameter<edm::InputTag>("AssociationType");
00039 
00040         input_PFCandidates_ = iConfig.getParameter<edm::InputTag>("PFCandidateCollection");
00041 
00042    //register your products
00043 
00044         if ( input_AssociationType_.label() == "PFCandsToVertex" ) {
00045           produces<PFCandToVertexAssMap>();
00046         } else {
00047           if ( input_AssociationType_.label() == "VertexToPFCands" ) {
00048             produces<VertexToPFCandAssMap>();
00049           } else {
00050             if ( input_AssociationType_.label() == "Both" ) {
00051               produces<PFCandToVertexAssMap>();
00052               produces<VertexToPFCandAssMap>();
00053             } else {
00054               std::cout << "No correct InputTag for AssociationType!" << std::endl;
00055               std::cout << "Won't produce any AssociationMap!" << std::endl;
00056             }
00057           }
00058         }
00059   
00060 }
00061 
00062 
00063 PFCand_AssoMap::~PFCand_AssoMap()
00064 {
00065 }
00066 
00067 
00068 //
00069 // member functions
00070 //
00071 
00072 // ------------ method called to produce the data  ------------
00073 void
00074 PFCand_AssoMap::produce(edm::Event& iEvent, const edm::EventSetup& iSetup)
00075 {
00076 
00077   using namespace edm;
00078   using namespace std;
00079   using namespace reco;
00080   
00081         //get the input pfCandidateCollection
00082         Handle<PFCandidateCollection> pfCandH;
00083         iEvent.getByLabel(input_PFCandidates_,pfCandH);
00084         
00085         string asstype = input_AssociationType_.label();
00086 
00087         PFCand_AssoMapAlgos::GetInputCollections(iEvent,iSetup);
00088 
00089         if ( ( asstype == "PFCandsToVertex" ) || ( asstype == "Both" ) ) {
00090           auto_ptr<PFCandToVertexAssMap> PFCand2Vertex = CreatePFCandToVertexMap(pfCandH, iSetup);
00091           iEvent.put( SortPFCandAssociationMap( &(*PFCand2Vertex) ) );
00092         }
00093  
00094         if ( ( asstype == "VertexToPFCands" ) || ( asstype == "Both" ) ) {
00095           auto_ptr<VertexToPFCandAssMap> Vertex2PFCand = CreateVertexToPFCandMap(pfCandH, iSetup);
00096           iEvent.put( Vertex2PFCand );  
00097         }
00098 
00099 }
00100 
00101 // ------------ method fills 'descriptions' with the allowed parameters for the module  ------------
00102 void
00103 PFCand_AssoMap::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
00104   //The following says we do not know what parameters are allowed so do no validation
00105   // Please change this to state exactly what you do use, even if it is no parameters
00106   edm::ParameterSetDescription desc;
00107   desc.setUnknown();
00108   descriptions.addDefault(desc);
00109 }
00110 
00111 //define this as a plug-in
00112 DEFINE_FWK_MODULE(PFCand_AssoMap);