CMS 3D CMS Logo

makeNamedCompositeCandidate.h

Go to the documentation of this file.
00001 #ifndef CandUtils_makeNamedCompositeCandidate_h
00002 #define CandUtils_makeNamedCompositeCandidate_h
00003 #include "DataFormats/Candidate/interface/NamedCompositeCandidate.h"
00004 #include "DataFormats/Candidate/interface/ShallowCloneCandidate.h"
00005 #include <memory>
00006 #include <string>
00007 
00008 namespace helpers {
00009   struct NamedCompositeCandidateMaker {
00010     NamedCompositeCandidateMaker( std::auto_ptr<reco::NamedCompositeCandidate> cmp ) :
00011       cmp_( cmp ) {
00012     }
00013     void addDaughter( const reco::Candidate & dau, std::string name ) {
00014       cmp_->addDaughter( dau, name );
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::NamedCompositeCandidate> 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 
00031 helpers::NamedCompositeCandidateMaker 
00032 makeNamedCompositeCandidate( const reco::Candidate & c1, std::string s1,
00033                              const reco::Candidate & c2, std::string s2 );
00034 
00035 helpers::NamedCompositeCandidateMaker 
00036 makeNamedCompositeCandidate( const reco::Candidate & c1, std::string s1,
00037                              const reco::Candidate & c2, std::string s2,
00038                              const reco::Candidate & c3, std::string s3 );
00039 
00040 helpers::NamedCompositeCandidateMaker 
00041 makeNamedCompositeCandidate( const reco::Candidate & c1, std::string s1,
00042                              const reco::Candidate & c2, std::string s2,
00043                              const reco::Candidate & c3, std::string s3 );
00044 
00045 
00046 helpers::NamedCompositeCandidateMaker 
00047 makeNamedCompositeCandidate( const reco::Candidate & c1, std::string s1,
00048                              const reco::Candidate & c2, std::string s2,
00049                              const reco::Candidate & c3, std::string s3,
00050                              const reco::Candidate & c4, std::string s4 );
00051 
00052 template<typename C>
00053 helpers::NamedCompositeCandidateMaker 
00054 makeNamedCompositeCandidate( const typename C::const_iterator & begin, 
00055                              const typename C::const_iterator & end,
00056                              const std::vector<std::string>::const_iterator sbegin,
00057                              const std::vector<std::string>::const_iterator send ) {
00058   helpers::NamedCompositeCandidateMaker 
00059     cmp( std::auto_ptr<reco::NamedCompositeCandidate>( new reco::NamedCompositeCandidate ) );
00060   std::vector<std::string>::const_iterator si = sbegin;
00061   for( typename C::const_iterator i = begin; i != end && si != send; ++ i, ++si ) 
00062     cmp.addDaughter( * i, * si );
00063   return cmp;
00064 }
00065 
00066 helpers::NamedCompositeCandidateMaker 
00067 makeNamedCompositeCandidateWithRefsToMaster( const reco::CandidateRef & c1, std::string s1, 
00068                                              const reco::CandidateRef & c2, std::string s2 );
00069 
00070 helpers::NamedCompositeCandidateMaker 
00071 makeNamedCompositeCandidateWithRefsToMaster( const reco::CandidateRef & c1, std::string s1, 
00072                                              const reco::CandidateRef & c2, std::string s2,
00073                                              const reco::CandidateRef & c3, std::string s3 );
00074 
00075 helpers::NamedCompositeCandidateMaker 
00076 makeNamedCompositeCandidateWithRefsToMaster( const reco::CandidateRef & c1, std::string s1, 
00077                                              const reco::CandidateRef & c2, std::string s2,
00078                                              const reco::CandidateRef & c3, std::string s3,
00079                                              const reco::CandidateRef & c4, std::string s4 );
00080 
00081 template<typename C>
00082 helpers::NamedCompositeCandidateMaker 
00083 makeNamedCompositeCandidateWithRefsToMaster( const typename C::const_iterator & begin, 
00084                                              const typename C::const_iterator & end,
00085                              const std::vector<std::string>::const_iterator sbegin,
00086                              const std::vector<std::string>::const_iterator send ) {
00087   helpers::NamedCompositeCandidateMaker 
00088     cmp( std::auto_ptr<reco::NamedCompositeCandidate>( new reco::NamedCompositeCandidate ) );
00089   std::vector<std::string>::const_iterator si = sbegin;
00090   for( typename C::const_iterator i = begin; i != end && si != send; ++ i, ++ si ) 
00091     cmp.addDaughter( ShallowCloneCandidate( CandidateBaseRef( * i ) ), * si );
00092   return cmp;
00093 }
00094 
00095 #endif

Generated on Tue Jun 9 17:41:04 2009 for CMSSW by  doxygen 1.5.4