Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #ifndef CommonTools_ParticleFlow_PFCandidateWithSrcPtrFactor_h
0002 #define CommonTools_ParticleFlow_PFCandidateWithSrcPtrFactor_h
0003 
0004 /**
0005   \class    reco::PFCandidateWithSrcPtrFactory PFCandidateWithSrcPtrFactory.h  "CommonTools/ParticleFlow/interface/PFCandidateWithSrcPtrFactory.h"
0006   \brief    Creates a PFCandidate from an input FwdPtr, and sets the "source" Ptr to the FwdPtr.backPtr 
0007 
0008 
0009   \author   Salvatore Rappoccio
0010 */
0011 
0012 #include "DataFormats/ParticleFlowCandidate/interface/PFCandidate.h"
0013 #include "DataFormats/ParticleFlowCandidate/interface/PFCandidateFwd.h"
0014 
0015 namespace reco {
0016   class PFCandidateWithSrcPtrFactory {
0017   public:
0018     reco::PFCandidate operator()(edm::FwdPtr<reco::PFCandidate> const& input) const {
0019       reco::PFCandidate output(*input);
0020 
0021       if (input.backPtr().isAvailable())
0022         output.setSourceCandidatePtr(input.backPtr());
0023       else  //we are in a job where the original collection is gone
0024         output.setSourceCandidatePtr(input.ptr());
0025       return output;
0026     }
0027   };
0028 }  // namespace reco
0029 
0030 #endif