1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
|
#ifndef Candidate_LeafRefCandidateT_h
#define Candidate_LeafRefCandidateT_h
/** \class reco::LeafRefCandidateT
*
* particle candidate with no constituent nor daughters, that takes the 3-vector
* from a constituent T (where T satisfies T->pt(), etc, like a TrackRef), and the mass is set
*
* \author Luca Lista, INFN
*
*/
#include "DataFormats/Candidate/interface/LeafCandidate.h"
#include "DataFormats/Common/interface/RefCoreWithIndex.h"
namespace reco {
class LeafRefCandidateT : public LeafCandidate {
public:
/// collection of daughter candidates
typedef CandidateCollection daughters;
/// electric charge type
typedef int Charge;
/// Lorentz vector
typedef math::XYZTLorentzVector LorentzVector;
/// Lorentz vector
typedef math::PtEtaPhiMLorentzVector PolarLorentzVector;
/// point in the space
typedef math::XYZPoint Point;
/// point in the space
typedef math::XYZVector Vector;
typedef unsigned int index;
/// default constructor
LeafRefCandidateT() {}
// constructor from T
template <class REF>
LeafRefCandidateT(const REF& c, float m)
: LeafCandidate(c->charge(), PolarLorentzVector(c->pt(), c->eta(), c->phi(), m), c->vertex()),
ref_(c.refCore(), c.key()) {}
/// destructor
~LeafRefCandidateT() override {}
protected:
// get the ref (better be the correct ref!)
template <typename REF>
REF getRef() const {
return REF(ref_.toRefCore(), ref_.index());
}
public:
/// number of daughters
size_t numberOfDaughters() const final { return 0; }
/// return daughter at a given position (throws an exception)
const Candidate* daughter(size_type) const final { return nullptr; }
/// number of mothers
size_t numberOfMothers() const final { return 0; }
/// return mother at a given position (throws an exception)
const Candidate* mother(size_type) const final { return nullptr; }
/// return daughter at a given position (throws an exception)
Candidate* daughter(size_type) final { return nullptr; }
/// return daughter with a specified role name
Candidate* daughter(const std::string& s) final { return nullptr; }
/// return daughter with a specified role name
const Candidate* daughter(const std::string& s) const final { return nullptr; }
/// return the number of source Candidates
/// ( the candidates used to construct this Candidate)
size_t numberOfSourceCandidatePtrs() const final { return 0; }
/// return a Ptr to one of the source Candidates
/// ( the candidates used to construct this Candidate)
CandidatePtr sourceCandidatePtr(size_type i) const final {
static const CandidatePtr dummyPtr;
return dummyPtr;
}
/// This only happens if the concrete Candidate type is ShallowCloneCandidate
bool hasMasterClone() const final { return false; }
/// returns ptr to master clone, if existing.
/// Throws an exception unless the concrete Candidate type is ShallowCloneCandidate
const CandidateBaseRef& masterClone() const final {
static const CandidateBaseRef dummyRef;
return dummyRef;
}
/// returns true if this candidate has a ptr to a master clone.
/// This only happens if the concrete Candidate type is ShallowClonePtrCandidate
bool hasMasterClonePtr() const final { return false; }
/// returns ptr to master clone, if existing.
/// Throws an exception unless the concrete Candidate type is ShallowClonePtrCandidate
const CandidatePtr& masterClonePtr() const final {
static const CandidatePtr dummyPtr;
return dummyPtr;
}
/// cast master clone reference to a concrete type
template <typename Ref>
Ref masterRef() const {
Ref dummyRef;
return dummyRef;
}
/// get a component
template <typename C>
C get() const {
if (hasMasterClone())
return masterClone()->template get<C>();
else
return reco::get<C>(*this);
}
/// get a component
template <typename C, typename Tag>
C get() const {
if (hasMasterClone())
return masterClone()->template get<C, Tag>();
else
return reco::get<C, Tag>(*this);
}
/// get a component
template <typename C>
C get(size_type i) const {
if (hasMasterClone())
return masterClone()->template get<C>(i);
else
return reco::get<C>(*this, i);
}
/// get a component
template <typename C, typename Tag>
C get(size_type i) const {
if (hasMasterClone())
return masterClone()->template get<C, Tag>(i);
else
return reco::get<C, Tag>(*this, i);
}
/// number of components
template <typename C>
size_type numberOf() const {
if (hasMasterClone())
return masterClone()->template numberOf<C>();
else
return reco::numberOf<C>(*this);
}
/// number of components
template <typename C, typename Tag>
size_type numberOf() const {
if (hasMasterClone())
return masterClone()->template numberOf<C, Tag>();
else
return reco::numberOf<C, Tag>(*this);
}
bool isElectron() const final { return false; }
bool isMuon() const final { return false; }
bool isStandAloneMuon() const final { return false; }
bool isGlobalMuon() const final { return false; }
bool isTrackerMuon() const final { return false; }
bool isCaloMuon() const final { return false; }
bool isPhoton() const final { return false; }
bool isConvertedPhoton() const final { return false; }
bool isJet() const final { return false; }
CMS_CLASS_VERSION(13)
protected:
/// check overlap with another Candidate
bool overlap(const Candidate&) const override;
virtual bool overlap(const LeafRefCandidateT&) const;
template <typename, typename, typename>
friend struct component;
friend class ::OverlapChecker;
friend class ShallowCloneCandidate;
friend class ShallowClonePtrCandidate;
protected:
edm::RefCoreWithIndex ref_;
private:
///
/// Hide these from all users:
///
/*
virtual void setCharge( Charge q ) final {}
virtual void setThreeCharge( Charge qx3 ) final {}
virtual void setP4( const LorentzVector & p4 ) final {}
virtual void setP4( const PolarLorentzVector & p4 ) final {}
virtual void setPz( double pz ) final {}
virtual void setVertex( const Point & vertex ) final {}
virtual void setPdgId( int pdgId ) final {}
virtual void setStatus( int status ) final {}
virtual void setLongLived() final {}
virtual void setMassConstraint() final {}
virtual double vertexChi2() const final { return 0.; }
virtual double vertexNdof() const final { return 0.; }
virtual double vertexNormalizedChi2() const final { return 0.; }
virtual double vertexCovariance(int i, int j) const final { return 0.; }
virtual void fillVertexCovariance(CovarianceMatrix & v) const final {}
*/
};
inline bool LeafRefCandidateT::overlap(const Candidate& o) const {
return (p4() == o.p4()) && (vertex() == o.vertex()) && (charge() == o.charge());
}
inline bool LeafRefCandidateT::overlap(const LeafRefCandidateT& o) const {
return (ref_.id() == o.ref_.id()) && (ref_.index() == o.ref_.index());
}
} // namespace reco
#endif
|