Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:01:11

0001 #ifndef PFCand_AssoMapAlgos_h
0002 #define PFCand_AssoMapAlgos_h
0003 
0004 /**\class PF_PU_AssoMap PF_PU_AssoMap.cc CommonTools/RecoUtils/plugins/PF_PU_AssoMap.cc
0005 
0006  Description: Produces a map with association between tracks and their particular most probable vertex with a quality of this association
0007 */
0008 //
0009 // Original Author:  Matthias Geisler,32 4-B20,+41227676487,
0010 // $Id$
0011 //
0012 //
0013 #include "FWCore/Framework/interface/ConsumesCollector.h"
0014 
0015 #include "CommonTools/RecoUtils/interface/PF_PU_AssoMapAlgos.h"
0016 
0017 #include "DataFormats/ParticleFlowCandidate/interface/PFCandidate.h"
0018 #include "DataFormats/ParticleFlowCandidate/interface/PFCandidateFwd.h"
0019 #include "Geometry/Records/interface/GlobalTrackingGeometryRecord.h"
0020 
0021 namespace edm {
0022   class EDProductGetter;
0023 }
0024 
0025 //
0026 // constants, enums and typedefs
0027 //
0028 
0029 typedef edm::AssociationMap<edm::OneToManyWithQuality<reco::VertexCollection, reco::PFCandidateCollection, int>>
0030     PFCandToVertexAssMap;
0031 typedef edm::AssociationMap<edm::OneToManyWithQuality<reco::PFCandidateCollection, reco::VertexCollection, int>>
0032     VertexToPFCandAssMap;
0033 
0034 typedef std::pair<reco::PFCandidateRef, int> PFCandQualityPair;
0035 typedef std::vector<PFCandQualityPair> PFCandQualityPairVector;
0036 
0037 typedef std::pair<reco::VertexRef, PFCandQualityPair> VertexPfcQuality;
0038 
0039 typedef std::pair<reco::VertexRef, float> VertexPtsumPair;
0040 typedef std::vector<VertexPtsumPair> VertexPtsumVector;
0041 
0042 class PFCand_AssoMapAlgos : public PF_PU_AssoMapAlgos {
0043 public:
0044   //dedicated constructor for the algorithms
0045   PFCand_AssoMapAlgos(const edm::ParameterSet&, edm::ConsumesCollector&&);
0046 
0047   //get all needed collections at the beginning
0048   void GetInputCollections(edm::Event&, const edm::EventSetup&) override;
0049 
0050   //create the pf candidate to vertex association and the inverse map
0051   std::pair<std::unique_ptr<PFCandToVertexAssMap>, std::unique_ptr<VertexToPFCandAssMap>> createMappings(
0052       edm::Handle<reco::PFCandidateCollection> pfCandH);
0053 
0054   //create the pf candidate to vertex association map
0055   std::unique_ptr<PFCandToVertexAssMap> CreatePFCandToVertexMap(edm::Handle<reco::PFCandidateCollection>);
0056 
0057   //create the vertex to pf candidate association map
0058   std::unique_ptr<VertexToPFCandAssMap> CreateVertexToPFCandMap(edm::Handle<reco::PFCandidateCollection>);
0059 
0060   //function to sort the vertices in the AssociationMap by the sum of (pT - pT_Error)**2
0061   std::unique_ptr<PFCandToVertexAssMap> SortPFCandAssociationMap(PFCandToVertexAssMap*,
0062                                                                  edm::EDProductGetter const* getter);
0063 
0064 protected:
0065   //protected functions
0066 
0067 private:
0068   //private functions
0069 
0070   int input_MaxNumAssociations_;
0071 
0072   edm::EDGetTokenT<reco::VertexCollection> token_VertexCollection_;
0073   edm::Handle<reco::VertexCollection> vtxcollH;
0074 
0075   edm::EDGetTokenT<reco::BeamSpot> token_BeamSpot_;
0076   edm::Handle<reco::BeamSpot> beamspotH;
0077 
0078   const edm::ESGetToken<MagneticField, IdealMagneticFieldRecord> token_bField_;
0079   edm::ESHandle<MagneticField> bFieldH;
0080   const edm::ESGetToken<GlobalTrackingGeometry, GlobalTrackingGeometryRecord> token_TrackingGeometry_;
0081   edm::ESHandle<GlobalTrackingGeometry> trackingGeometryH;
0082 };
0083 
0084 #endif