CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_6_2_5/src/CommonTools/RecoUtils/plugins/PF_PU_AssoMap.cc

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 //
00003 // Package:    PF_PU_AssoMap
00004 // Class:      PF_PU_AssoMap
00005 // 
00011 //
00012 // Original Author:  Matthias Geisler,32 4-B20,+41227676487,
00013 // $Id: PF_PU_AssoMap.cc,v 1.8 2012/11/21 09:56:19 mgeisler Exp $
00014 //
00015 //
00016 
00017 #include "CommonTools/RecoUtils/interface/PF_PU_AssoMap.h"
00018 
00019 //
00020 // static data member definitions
00021 //
00022 
00023 //
00024 // constructors and destructor
00025 //
00026 PF_PU_AssoMap::PF_PU_AssoMap(const edm::ParameterSet& iConfig):PF_PU_AssoMapAlgos(iConfig)
00027 {
00028 
00029    //now do what ever other initialization is needed
00030 
00031         input_AssociationType_ = iConfig.getParameter<edm::InputTag>("AssociationType");
00032 
00033         input_TrackCollection_ = iConfig.getParameter<edm::InputTag>("TrackCollection");
00034 
00035    //register your products
00036 
00037         if ( input_AssociationType_.label() == "TracksToVertex" ) {
00038           produces<TrackToVertexAssMap>();
00039         } else {
00040           if ( input_AssociationType_.label() == "VertexToTracks" ) {
00041             produces<VertexToTrackAssMap>();
00042           } else {
00043             if ( input_AssociationType_.label() == "Both" ) {
00044               produces<TrackToVertexAssMap>();
00045               produces<VertexToTrackAssMap>();
00046             } else {
00047               std::cout << "No correct InputTag for AssociationType!" << std::endl;
00048               std::cout << "Won't produce any AssociationMap!" << std::endl;
00049             }
00050           }
00051         }
00052 
00053   
00054 }
00055 
00056 
00057 PF_PU_AssoMap::~PF_PU_AssoMap()
00058 {
00059  
00060    // do anything here that needs to be done at destruction time
00061    // (e.g. close files, deallocate resources etc.)
00062 
00063 }
00064 
00065 
00066 //
00067 // member functions
00068 //
00069 
00070 // ------------ method called to produce the data  ------------
00071 void
00072 PF_PU_AssoMap::produce(edm::Event& iEvent, const edm::EventSetup& iSetup)
00073 {
00074 
00075   using namespace edm;
00076   using namespace std;
00077   using namespace reco;
00078 
00079     
00080         //get the input track collection     
00081         Handle<TrackCollection> trkcollH;
00082         iEvent.getByLabel(input_TrackCollection_, trkcollH);
00083         
00084         string asstype = input_AssociationType_.label();
00085 
00086         PF_PU_AssoMapAlgos::GetInputCollections(iEvent,iSetup);
00087 
00088         if ( ( asstype == "TracksToVertex" ) || ( asstype == "Both" ) ) {
00089           auto_ptr<TrackToVertexAssMap> Track2Vertex = CreateTrackToVertexMap(trkcollH, iSetup);
00090           iEvent.put( SortAssociationMap( &(*Track2Vertex) ) );
00091         }
00092  
00093         if ( ( asstype == "VertexToTracks" ) || ( asstype == "Both" ) ) {
00094           auto_ptr<VertexToTrackAssMap> Vertex2Track = CreateVertexToTrackMap(trkcollH, iSetup);
00095           iEvent.put( Vertex2Track );  
00096         }
00097  
00098 }
00099 
00100 // ------------ method fills 'descriptions' with the allowed parameters for the module  ------------
00101 void
00102 PF_PU_AssoMap::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
00103   //The following says we do not know what parameters are allowed so do no validation
00104   // Please change this to state exactly what you do use, even if it is no parameters
00105   edm::ParameterSetDescription desc;
00106   desc.setUnknown();
00107   descriptions.addDefault(desc);
00108 }
00109 
00110 //define this as a plug-in
00111 DEFINE_FWK_MODULE(PF_PU_AssoMap);