Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:29:39

0001 #ifndef SimDataFormats_Associations_TrackToGenParticleAssociator_h
0002 #define SimDataFormats_Associations_TrackToGenParticleAssociator_h
0003 
0004 /** \class TrackToGenParticleAssociator
0005  *  Interface for accessing a Track to GenParticle associator
0006  *
0007  *  \author cerati, magni
0008  */
0009 
0010 #include "DataFormats/Common/interface/Handle.h"
0011 #include "DataFormats/HepMCCandidate/interface/GenParticle.h"
0012 #include "DataFormats/HepMCCandidate/interface/GenParticleFwd.h"
0013 #include "DataFormats/Math/interface/LorentzVector.h"
0014 #include "SimDataFormats/Associations/interface/TrackAssociation.h"
0015 #include "SimDataFormats/Track/interface/SimTrackContainer.h"
0016 #include "SimDataFormats/Vertex/interface/SimVertexContainer.h"
0017 
0018 #include "SimDataFormats/Associations/interface/TrackToGenParticleAssociatorBaseImpl.h"
0019 
0020 #include <memory>
0021 
0022 // Note that the Association Map is filled with -ch2 and not chi2 because it is
0023 // ordered using std::greater: the track with the lowest association chi2 will
0024 // be the first in the output map.
0025 
0026 namespace reco {
0027   typedef edm::AssociationMap<
0028       edm::OneToManyWithQualityGeneric<reco::GenParticleCollection, edm::View<reco::Track>, double>>
0029       GenToRecoCollection;
0030   typedef edm::AssociationMap<
0031       edm::OneToManyWithQualityGeneric<edm::View<reco::Track>, reco::GenParticleCollection, double>>
0032       RecoToGenCollection;
0033 
0034   class TrackToGenParticleAssociator {
0035   public:
0036     /// Constructor
0037     TrackToGenParticleAssociator() = default;
0038 #ifndef __GCCXML__
0039     TrackToGenParticleAssociator(std::unique_ptr<reco::TrackToGenParticleAssociatorBaseImpl>);
0040 #endif
0041     ~TrackToGenParticleAssociator() = default;
0042     TrackToGenParticleAssociator(TrackToGenParticleAssociator &&) = default;
0043     TrackToGenParticleAssociator &operator=(TrackToGenParticleAssociator &&) = default;
0044     TrackToGenParticleAssociator(const TrackToGenParticleAssociator &) = delete;                   // stop default
0045     const TrackToGenParticleAssociator &operator=(const TrackToGenParticleAssociator &) = delete;  // stop default
0046 
0047     /// Association Sim To Reco with Collections (Gen Particle version)
0048     reco::RecoToGenCollection associateRecoToGen(const edm::RefToBaseVector<reco::Track> &tracks,
0049                                                  const edm::RefVector<reco::GenParticleCollection> &gens) const {
0050       return m_impl->associateRecoToGen(tracks, gens);
0051     }
0052     /// Association Sim To Reco with Collections (Gen Particle version)
0053     reco::GenToRecoCollection associateGenToReco(const edm::RefToBaseVector<reco::Track> &tracks,
0054                                                  const edm::RefVector<reco::GenParticleCollection> &gens) const {
0055       return m_impl->associateGenToReco(tracks, gens);
0056     }
0057 
0058     /// compare reco to sim the handle of reco::Track and GenParticle collections
0059     reco::RecoToGenCollection associateRecoToGen(const edm::Handle<edm::View<reco::Track>> &tCH,
0060                                                  const edm::Handle<reco::GenParticleCollection> &tPCH) const {
0061       return m_impl->associateRecoToGen(tCH, tPCH);
0062     }
0063 
0064     /// compare reco to sim the handle of reco::Track and GenParticle collections
0065     reco::GenToRecoCollection associateGenToReco(const edm::Handle<edm::View<reco::Track>> &tCH,
0066                                                  const edm::Handle<reco::GenParticleCollection> &tPCH) const {
0067       return m_impl->associateGenToReco(tCH, tPCH);
0068     }
0069 
0070   private:
0071     std::unique_ptr<TrackToGenParticleAssociatorBaseImpl> m_impl;
0072   };
0073 }  // namespace reco
0074 
0075 #endif