Go to the documentation of this file.00001 #ifndef CandUtils_makeCompositeCandidate_h
00002 #define CandUtils_makeCompositeCandidate_h
00003 #include "DataFormats/Candidate/interface/CompositeCandidate.h"
00004 #include "DataFormats/Candidate/interface/CompositePtrCandidate.h"
00005 #include "DataFormats/Candidate/interface/ShallowCloneCandidate.h"
00006 #include <memory>
00007
00008 namespace helpers {
00009 struct CompositeCandidateMaker {
00010 CompositeCandidateMaker(std::auto_ptr<reco::CompositeCandidate> cmp) :
00011 cmp_( cmp ) {
00012 }
00013 void addDaughter(const reco::Candidate & dau) {
00014 cmp_->addDaughter( dau );
00015 }
00016 template<typename S>
00017 std::auto_ptr<reco::Candidate> operator[]( const S & setup ) {
00018 setup.set( * cmp_ );
00019 return release();
00020 }
00021 private:
00022 std::auto_ptr<reco::CompositeCandidate> cmp_;
00023 std::auto_ptr<reco::Candidate> release() {
00024 std::auto_ptr<reco::Candidate> ret( cmp_.get() );
00025 cmp_.release();
00026 return ret;
00027 }
00028 };
00029
00030 struct CompositePtrCandidateMaker {
00031 CompositePtrCandidateMaker(std::auto_ptr<reco::CompositePtrCandidate> cmp) :
00032 cmp_( cmp ) {
00033 }
00034 void addDaughter(const reco::CandidatePtr & dau) {
00035 cmp_->addDaughter( dau );
00036 }
00037 template<typename S>
00038 std::auto_ptr<reco::Candidate> operator[]( const S & setup ) {
00039 setup.set( * cmp_ );
00040 return release();
00041 }
00042 private:
00043 std::auto_ptr<reco::CompositePtrCandidate> cmp_;
00044 std::auto_ptr<reco::Candidate> release() {
00045 std::auto_ptr<reco::Candidate> ret( cmp_.get() );
00046 cmp_.release();
00047 return ret;
00048 }
00049 };
00050 }
00051
00052 helpers::CompositeCandidateMaker
00053 makeCompositeCandidate(const reco::Candidate & c1,
00054 const reco::Candidate & c2);
00055
00056 helpers::CompositeCandidateMaker
00057 makeCompositeCandidate(const reco::Candidate & c1,
00058 const reco::Candidate & c2,
00059 const reco::Candidate & c3);
00060
00061 helpers::CompositeCandidateMaker
00062 makeCompositeCandidate(const reco::Candidate & c1,
00063 const reco::Candidate & c2,
00064 const reco::Candidate & c3);
00065
00066
00067 helpers::CompositeCandidateMaker
00068 makeCompositeCandidate(const reco::Candidate & c1,
00069 const reco::Candidate & c2,
00070 const reco::Candidate & c3,
00071 const reco::Candidate & c4);
00072
00073 template<typename C>
00074 helpers::CompositeCandidateMaker
00075 makeCompositeCandidate(const typename C::const_iterator & begin,
00076 const typename C::const_iterator & end) {
00077 helpers::CompositeCandidateMaker
00078 cmp(std::auto_ptr<reco::CompositeCandidate>(new reco::CompositeCandidate) );
00079 for(typename C::const_iterator i = begin; i != end; ++ i)
00080 cmp.addDaughter(* i);
00081 return cmp;
00082 }
00083
00084 helpers::CompositeCandidateMaker
00085 makeCompositeCandidateWithRefsToMaster(const reco::CandidateRef & c1,
00086 const reco::CandidateRef & c2);
00087
00088 helpers::CompositeCandidateMaker
00089 makeCompositeCandidateWithRefsToMaster(const reco::CandidateRef & c1,
00090 const reco::CandidateRef & c2,
00091 const reco::CandidateRef & c3);
00092
00093 helpers::CompositeCandidateMaker
00094 makeCompositeCandidateWithRefsToMaster(const reco::CandidateRef & c1,
00095 const reco::CandidateRef & c2,
00096 const reco::CandidateRef & c3,
00097 const reco::CandidateRef & c4);
00098
00099 template<typename C>
00100 helpers::CompositeCandidateMaker
00101 makeCompositeCandidateWithRefsToMaster(const typename C::const_iterator & begin,
00102 const typename C::const_iterator & end) {
00103 helpers::CompositeCandidateMaker
00104 cmp(std::auto_ptr<reco::CompositeCandidate>(new reco::CompositeCandidate));
00105 for(typename C::const_iterator i = begin; i != end; ++ i)
00106 cmp.addDaughter(ShallowCloneCandidate(CandidateBaseRef(* i)));
00107 return cmp;
00108 }
00109
00110 helpers::CompositePtrCandidateMaker
00111 makeCompositePtrCandidate(const reco::CandidatePtr & c1,
00112 const reco::CandidatePtr & c2);
00113
00114 helpers::CompositePtrCandidateMaker
00115 makeCompositePtrCandidate(const reco::CandidatePtr & c1,
00116 const reco::CandidatePtr & c2,
00117 const reco::CandidatePtr & c3);
00118
00119 helpers::CompositePtrCandidateMaker
00120 makeCompositePtrCandidate(const reco::CandidatePtr & c1,
00121 const reco::CandidatePtr & c2,
00122 const reco::CandidatePtr & c3);
00123
00124
00125 helpers::CompositePtrCandidateMaker
00126 makeCompositePtrCandidate(const reco::CandidatePtr & c1,
00127 const reco::CandidatePtr & c2,
00128 const reco::CandidatePtr & c3,
00129 const reco::CandidatePtr & c4);
00130
00131 #endif