File indexing completed on 2024-04-06 12:01:05
0001 #ifndef CommonTools_ParticleFlow_PFCandidateFwdPtrFactory_h
0002 #define CommonTools_ParticleFlow_PFCandidateFwdPtrFactory_h
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013 #include "DataFormats/ParticleFlowCandidate/interface/PFCandidate.h"
0014 #include "DataFormats/ParticleFlowCandidate/interface/PFCandidateFwd.h"
0015
0016 namespace reco {
0017 struct PFCandidateFwdPtrFactory {
0018 edm::FwdPtr<reco::PFCandidate> operator()(edm::View<reco::PFCandidate> const& view, unsigned int i) const {
0019 edm::Ptr<reco::PFCandidate> ptr = view.ptrAt(i);
0020 edm::Ptr<reco::PFCandidate> backPtr = ptr;
0021 if (ptr.isNonnull() && ptr.isAvailable() && ptr->numberOfSourceCandidatePtrs() > 0) {
0022 edm::Ptr<reco::Candidate> basePtr = ptr->sourceCandidatePtr(0);
0023 if (basePtr.isNonnull() && basePtr.isAvailable())
0024 backPtr = edm::Ptr<reco::PFCandidate>(basePtr);
0025 }
0026 return edm::FwdPtr<reco::PFCandidate>(ptr, backPtr);
0027 }
0028 };
0029 }
0030
0031 #endif