CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
makeCompositeCandidate.h
Go to the documentation of this file.
1 #ifndef CandUtils_makeCompositeCandidate_h
2 #define CandUtils_makeCompositeCandidate_h
5 #include <memory>
6 
7 namespace helpers {
8  struct CompositeCandidateMaker {
9  CompositeCandidateMaker( std::auto_ptr<reco::CompositeCandidate> cmp ) :
10  cmp_( cmp ) {
11  }
12  void addDaughter( const reco::Candidate & dau ) {
13  cmp_->addDaughter( dau );
14  }
15  template<typename S>
16  std::auto_ptr<reco::Candidate> operator[]( const S & setup ) {
17  setup.set( * cmp_ );
18  return release();
19  }
20  private:
21  std::auto_ptr<reco::CompositeCandidate> cmp_;
22  std::auto_ptr<reco::Candidate> release() {
23  std::auto_ptr<reco::Candidate> ret( cmp_.get() );
24  cmp_.release();
25  return ret;
26  }
27  };
28 }
29 
32  const reco::Candidate & c2 );
33 
36  const reco::Candidate & c2,
37  const reco::Candidate & c3 );
38 
41  const reco::Candidate & c2,
42  const reco::Candidate & c3 );
43 
44 
47  const reco::Candidate & c2,
48  const reco::Candidate & c3,
49  const reco::Candidate & c4 );
50 
51 template<typename C>
53 makeCompositeCandidate( const typename C::const_iterator & begin,
54  const typename C::const_iterator & end ) {
56  cmp( std::auto_ptr<reco::CompositeCandidate>( new reco::CompositeCandidate ) );
57  for( typename C::const_iterator i = begin; i != end; ++ i )
58  cmp.addDaughter( * i );
59  return cmp;
60 }
61 
64  const reco::CandidateRef & c2 );
65 
68  const reco::CandidateRef & c2,
69  const reco::CandidateRef & c3 );
70 
73  const reco::CandidateRef & c2,
74  const reco::CandidateRef & c3,
75  const reco::CandidateRef & c4 );
76 
77 template<typename C>
79 makeCompositeCandidateWithRefsToMaster( const typename C::const_iterator & begin,
80  const typename C::const_iterator & end ) {
82  cmp( std::auto_ptr<reco::CompositeCandidate>( new reco::CompositeCandidate ) );
83  for( typename C::const_iterator i = begin; i != end; ++ i )
84  cmp.addDaughter( ShallowCloneCandidate( CandidateBaseRef( * i ) ) );
85  return cmp;
86 }
87 
88 #endif
int i
Definition: DBlmapReader.cc:9
std::auto_ptr< reco::CompositeCandidate > cmp_
void addDaughter(const reco::Candidate &dau)
std::auto_ptr< reco::Candidate > operator[](const S &setup)
#define end
Definition: vmac.h:38
helpers::CompositeCandidateMaker makeCompositeCandidateWithRefsToMaster(const reco::CandidateRef &c1, const reco::CandidateRef &c2)
edm::RefToBase< Candidate > CandidateBaseRef
persistent reference to an object in a collection of Candidate objects
Definition: CandidateFwd.h:31
#define begin
Definition: vmac.h:31
helpers::CompositeCandidateMaker makeCompositeCandidate(const reco::Candidate &c1, const reco::Candidate &c2)
std::auto_ptr< reco::Candidate > release()
CompositeCandidateMaker(std::auto_ptr< reco::CompositeCandidate > cmp)
void setup(std::vector< TH2F > &depth, std::string name, std::string units="")