CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_6/src/CommonTools/RecoUtils/plugins/PFCand_NoPU_WithAM.cc

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 //
00003 // Package:    PFCand_NoPU_WithAM
00004 // Class:      PFCand_NoPU_WithAM
00005 // 
00011 //
00012 // Original Author:  Matthias Geisler,32 4-B20,+41227676487,
00013 //         Created:  Thu Dec  1 16:07:41 CET 2011
00014 // $Id: PFCand_NoPU_WithAM.cc,v 1.3 2012/05/15 08:25:34 mgeisler Exp $
00015 //
00016 //
00017 #include "CommonTools/RecoUtils/interface/PFCand_NoPU_WithAM.h"
00018 
00019 // system include files
00020 #include <memory>
00021 #include <vector>
00022 
00023 // user include files
00024 #include "FWCore/Framework/interface/Frameworkfwd.h"
00025 #include "FWCore/Framework/interface/EDProducer.h"
00026 
00027 #include "FWCore/Framework/interface/Event.h"
00028 #include "FWCore/Framework/interface/Run.h"
00029 #include "FWCore/Framework/interface/MakerMacros.h"
00030 
00031 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00032 #include "FWCore/Utilities/interface/InputTag.h"
00033 
00034 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00035 #include "DataFormats/Common/interface/AssociationMap.h"
00036 #include "DataFormats/Common/interface/Handle.h"
00037 #include "DataFormats/Common/interface/OneToManyWithQuality.h"
00038 #include "DataFormats/Common/interface/OneToManyWithQualityGeneric.h"
00039 #include "DataFormats/Common/interface/View.h"
00040 
00041 #include "DataFormats/TrackReco/interface/Track.h"
00042 #include "DataFormats/TrackReco/interface/TrackFwd.h"
00043 #include "DataFormats/TrackReco/interface/TrackBase.h"
00044 #include "DataFormats/VertexReco/interface/Vertex.h"
00045 #include "DataFormats/VertexReco/interface/VertexFwd.h"
00046 
00047 #include "DataFormats/ParticleFlowCandidate/interface/PFCandidate.h"
00048 #include "DataFormats/ParticleFlowCandidate/interface/PFCandidateFwd.h"
00049 #include "DataFormats/ParticleFlowReco/interface/PFDisplacedVertex.h"
00050 #include "DataFormats/ParticleFlowReco/interface/PFDisplacedVertexFwd.h"
00051 #include "DataFormats/EgammaCandidates/interface/Conversion.h"
00052 #include "DataFormats/EgammaCandidates/interface/ConversionFwd.h"
00053 #include "DataFormats/Candidate/interface/VertexCompositeCandidate.h"
00054 #include "DataFormats/Candidate/interface/VertexCompositeCandidateFwd.h"
00055 
00056 //
00057 // constants, enums and typedefs
00058 //
00059    
00060 using namespace edm;
00061 using namespace std;
00062 using namespace reco;
00063 
00064   typedef AssociationMap<OneToManyWithQuality< VertexCollection, PFCandidateCollection, float> > PFCandVertexAssMap;
00065 
00066   typedef pair<PFCandidateRef, float> PFCandQualityPair;
00067   typedef vector< PFCandQualityPair > PFCandQualityPairVector;
00068 
00069 //
00070 // constructors and destructor
00071 //
00072 PFCand_NoPU_WithAM::PFCand_NoPU_WithAM(const edm::ParameterSet& iConfig)
00073 {
00074    //register your products
00075 
00076         produces<PFCandidateCollection>();
00077 
00078    //now do what ever other initialization is needed
00079 
00080         input_VertexPFCandAssociationMap_ = iConfig.getParameter<InputTag>("VertexPFCandAssociationMap");
00081   
00082 }
00083 
00084 
00085 PFCand_NoPU_WithAM::~PFCand_NoPU_WithAM()
00086 {
00087  
00088    // do anything here that needs to be done at desctruction time
00089    // (e.g. close files, deallocate resources etc.)
00090 
00091 }
00092 
00093 
00094 //
00095 // member functions
00096 //
00097 
00098 // ------------ method called to produce the data  ------------
00099 void
00100 PFCand_NoPU_WithAM::produce(edm::Event& iEvent, const edm::EventSetup& iSetup)
00101 {
00102 
00103         auto_ptr<PFCandidateCollection> firstvertexCandidates(new PFCandidateCollection() );
00104   
00105         //get the input vertex<->pfcandidate association map
00106         Handle<PFCandVertexAssMap> PFCandAmH;
00107         iEvent.getByLabel(input_VertexPFCandAssociationMap_,PFCandAmH); 
00108 
00109         PFCandQualityPairVector pfcColl; 
00110 
00111         if(PFCandAmH->size()!=0){
00112           pfcColl = PFCandAmH->begin()->val;
00113         }
00114 
00115         for(unsigned pfc_ite=0; pfc_ite<pfcColl.size(); pfc_ite++){
00116 
00117           PFCandidateRef candref = pfcColl[pfc_ite].first;  
00118           firstvertexCandidates->push_back(*candref);
00119 
00120         }
00121 
00122         iEvent.put( firstvertexCandidates );
00123 }
00124 
00125 // ------------ method fills 'descriptions' with the allowed parameters for the module  ------------
00126 void
00127 PFCand_NoPU_WithAM::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
00128   //The following says we do not know what parameters are allowed so do no validation
00129   // Please change this to state exactly what you do use, even if it is no parameters
00130   edm::ParameterSetDescription desc;
00131   desc.setUnknown();
00132   descriptions.addDefault(desc);
00133 }
00134 
00135 //define this as a plug-in
00136 DEFINE_FWK_MODULE(PFCand_NoPU_WithAM);