CMS 3D CMS Logo

makeNamedCompositeCandidate.h
Go to the documentation of this file.
1 #ifndef CandUtils_makeNamedCompositeCandidate_h
2 #define CandUtils_makeNamedCompositeCandidate_h
5 #include <memory>
6 #include <string>
7 
8 namespace helpers {
10  NamedCompositeCandidateMaker( std::unique_ptr<reco::NamedCompositeCandidate> cmp ) :
11  cmp_(std::move(cmp)) {}
12 
14  cmp_->addDaughter( dau, name );
15  }
16  template<typename S>
17  std::unique_ptr<reco::Candidate> operator[]( const S & setup ) {
18  setup.set( * cmp_ );
19  return release();
20  }
21  private:
22  std::unique_ptr<reco::NamedCompositeCandidate> cmp_;
23  std::unique_ptr<reco::Candidate> release() {
24  std::unique_ptr<reco::Candidate> ret( cmp_.get() );
25  cmp_.release();
26  return ret;
27  }
28  };
29 }
30 
33  const reco::Candidate & c2, std::string s2 );
34 
37  const reco::Candidate & c2, std::string s2,
38  const reco::Candidate & c3, std::string s3 );
39 
42  const reco::Candidate & c2, std::string s2,
43  const reco::Candidate & c3, std::string s3 );
44 
45 
48  const reco::Candidate & c2, std::string s2,
49  const reco::Candidate & c3, std::string s3,
50  const reco::Candidate & c4, std::string s4 );
51 
52 template<typename C>
54 makeNamedCompositeCandidate( const typename C::const_iterator & begin,
55  const typename C::const_iterator & end,
56  const std::vector<std::string>::const_iterator sbegin,
57  const std::vector<std::string>::const_iterator send ) {
59  cmp( std::unique_ptr<reco::NamedCompositeCandidate>( new reco::NamedCompositeCandidate ) );
60  std::vector<std::string>::const_iterator si = sbegin;
61  for( typename C::const_iterator i = begin; i != end && si != send; ++ i, ++si )
62  cmp.addDaughter( * i, * si );
63  return cmp;
64 }
65 
68  const reco::CandidateRef & c2, std::string s2 );
69 
72  const reco::CandidateRef & c2, std::string s2,
73  const reco::CandidateRef & c3, std::string s3 );
74 
77  const reco::CandidateRef & c2, std::string s2,
78  const reco::CandidateRef & c3, std::string s3,
79  const reco::CandidateRef & c4, std::string s4 );
80 
81 template<typename C>
83 makeNamedCompositeCandidateWithRefsToMaster( const typename C::const_iterator & begin,
84  const typename C::const_iterator & end,
85  const std::vector<std::string>::const_iterator sbegin,
86  const std::vector<std::string>::const_iterator send ) {
88  cmp( std::unique_ptr<reco::NamedCompositeCandidate>( new reco::NamedCompositeCandidate ) );
89  std::vector<std::string>::const_iterator si = sbegin;
90  for( typename C::const_iterator i = begin; i != end && si != send; ++ i, ++ si )
91  cmp.addDaughter( ShallowCloneCandidate( CandidateBaseRef( * i ) ), * si );
92  return cmp;
93 }
94 
95 #endif
void addDaughter(const reco::Candidate &dau, std::string name)
def setup(process, global_tag, zero_tesla=False)
Definition: GeneralSetup.py:2
std::unique_ptr< reco::Candidate > operator[](const S &setup)
helpers::NamedCompositeCandidateMaker makeNamedCompositeCandidate(const reco::Candidate &c1, std::string s1, const reco::Candidate &c2, std::string s2)
#define end
Definition: vmac.h:39
helpers::NamedCompositeCandidateMaker makeNamedCompositeCandidateWithRefsToMaster(const reco::CandidateRef &c1, std::string s1, const reco::CandidateRef &c2, std::string s2)
NamedCompositeCandidateMaker(std::unique_ptr< reco::NamedCompositeCandidate > cmp)
std::unique_ptr< reco::Candidate > release()
edm::RefToBase< Candidate > CandidateBaseRef
persistent reference to an object in a collection of Candidate objects
Definition: CandidateFwd.h:31
#define begin
Definition: vmac.h:32
std::unique_ptr< reco::NamedCompositeCandidate > cmp_
def move(src, dest)
Definition: eostools.py:511