9 constexpr
float square(
float x) {
return x * x; };
33 float minFracSharedHits) {
44 float eleGsfPt = eleGsfTk->pt();
45 float eleGsfEta = eleGsfTk->eta();
46 float eleGsfPhi = eleGsfTk->phi();
50 std::optional<float> eleCtfPt = std::nullopt;
51 std::optional<float> eleCtfEta = std::nullopt;
52 std::optional<float> eleCtfPhi = std::nullopt;
56 std::optional<int> ctfidx = std::nullopt;
57 int gsfidx =
static_cast<int>(eleGsfTk.key());
60 eleCtfPt = eleCtfTk->pt();
61 eleCtfEta = eleCtfTk->eta();
62 eleCtfPhi = eleCtfTk->phi();
63 ctfidx =
static_cast<int>(eleCtfTk.key());
67 std::vector<ConversionInfo> v_candidatePartners;
73 for (
auto ctftkItr = ctfTable.begin(); ctftkItr != ctfTable.end(); ++ctftkItr, ctftk_i++) {
74 if (useEleCtfTrack && ctftk_i == ctfidx.value())
77 auto ctftk = *ctftkItr;
89 if (useEleCtfTrack && eleCtfTk->charge() + ctftk.get<
Charge>() == 0 &&
90 deltaR2(eleCtfEta.value(), eleCtfPhi.value(), ctftk.get<
Eta>(), ctftk.get<
Phi>()) <
dR2Max) {
95 int deltaMissingHits = ctftk.get<
MissingInnerHits>() - eleCtfTk->missingInnerHits();
97 v_candidatePartners.push_back(
103 if (eleGsfTk->charge() + ctftk.get<
Charge>() == 0 &&
106 int deltaMissingHits = ctftk.get<
MissingInnerHits>() - eleGsfTk->missingInnerHits();
110 v_candidatePartners.push_back(
117 for (
auto gsftkItr = gsfTable.begin(); gsftkItr != gsfTable.end(); ++gsftkItr, gsftk_i++) {
119 if (gsfidx == gsftk_i)
122 auto gsftk = *gsftkItr;
135 if (useEleCtfTrack && eleCtfTk->charge() + gsftk.get<
Charge>() == 0 &&
136 deltaR2(eleCtfEta.value(), eleCtfPhi.value(), gsftk.get<
Eta>(), gsftk.get<
Phi>()) <
dR2Max) {
137 int deltaMissingHits = gsftk.get<
MissingInnerHits>() - eleCtfTk->missingInnerHits();
141 v_candidatePartners.push_back(
146 if (eleGsfTk->charge() + gsftk.get<
Charge>() == 0 &&
152 int deltaMissingHits = gsftk.get<
MissingInnerHits>() - eleGsfTk->missingInnerHits();
154 v_candidatePartners.push_back(
159 return v_candidatePartners;
167 float rEl = 100.f * ele.
pt() / (-0.3f * bFieldAtOrigin * ele.
charge());
168 float xEl = -1.f * (rEl - ele.
d0()) *
sin(ele.
phi());
169 float yEl = (rEl - ele.
d0()) *
cos(ele.
phi());
172 float rCand = 100.f * track.get<
Pt>() / (-0.3
f * bFieldAtOrigin * track.get<
Charge>());
173 float xCand = -1.f * (rCand - track.get<
D0>()) *
sin(track.get<
Phi>());
174 float yCand = (rCand - track.get<
D0>()) *
cos(track.get<
Phi>());
177 float d =
sqrt(
pow(xEl - xCand, 2) +
pow(yEl - yCand, 2));
178 float dist =
d - (rEl + rCand);
181 float dcot = ele.
pz() / ele.
pt() - track.get<
Pz>() / track.get<
Pt>();
184 float xa1 = xEl + (xCand - xEl) * rEl /
d;
185 float xa2 = xCand + (xEl - xCand) * rCand /
d;
186 float ya1 = yEl + (yCand - yEl) * rEl /
d;
187 float ya2 = yCand + (yEl - yCand) * rCand /
d;
189 float x = .5f * (xa1 + xa2);
190 float y = .5f * (ya1 + ya2);
196 float tempsign = ele.
px() * x + ele.
py() * y;
197 tempsign = tempsign /
std::abs(tempsign);
198 rconv = tempsign * rconv;
201 return {dist, dcot, rconv};
210 ConversionInfo const* closestConversion = &convCandidates.front();
212 if (convCandidates.size() == 1)
213 return *closestConversion;
215 float R =
pow(closestConversion->
dist, 2) +
pow(closestConversion->
dcot, 2);
217 for (
auto const&
temp : convCandidates) {
221 closestConversion = &
temp;
225 return *closestConversion;
232 if (v_convCandidates.empty())
235 if (v_convCandidates.size() == 1)
236 return v_convCandidates.at(0);
238 vector<ConversionInfo> v_0;
239 vector<ConversionInfo> v_1;
240 vector<ConversionInfo> v_2;
241 vector<ConversionInfo> v_3;
244 for (
auto const&
temp : v_convCandidates) {
245 if (
temp.radiusOfConversion <= -2)
248 if (
temp.flag == 0) {
255 if (
temp.flag == 1) {
259 if (
temp.flag == 2) {
263 if (
temp.flag == 3) {
bool isNonnull() const
Checks for non-null.
constexpr float maxRelGsfPtError
double d0() const
dxy parameter in perigee convention (d0 = -dxy)
float ctfGsfOverlap() const
TrackTable::const_iterator::value_type TrackRowView
ConversionInfo findBestConversionMatch(const std::vector< ConversionInfo > &v_convCandidates)
Sin< T >::type sin(const T &t)
const GsfTrackRef & gsfTrack() const
double phi() const
azimuthal angle of momentum vector
double px() const
x coordinate of momentum vector
ConversionInfo getConversionInfo(reco::Track const &el_track, TrackRowView const &track, float bFieldAtOrigin)
constexpr float maxRelGsfPtErrorForKfConv
constexpr float maxRefPtErrorForKfConv
constexpr float maxRelPtDiffForGsfConv
constexpr int maxDeltaMissingHitsForKFtoKF
constexpr float maxDistOrCotForKFtoKF
edm::soa::ViewFromTable_t< TrackTable > TrackTableView
constexpr float maxRelPtDiffForKfConv
std::vector< ConversionInfo > findConversions(const reco::GsfElectronCore &gsfElectron, TrackTableView ctfTable, TrackTableView gsfTable, float bFieldAtOrigin, float minFracSharedHits)
double pt() const
track transverse momentum
Cos< T >::type cos(const T &t)
Abs< T >::type abs(const T &t)
ConversionInfo const & arbitrateConversionPartnersbyR(const std::vector< ConversionInfo > &convCandidates)
double pz() const
z coordinate of momentum vector
constexpr auto deltaR2(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
static double square(double x)
TrackRef ctfTrack() const
constexpr int minNumberOfValidHits
constexpr float maxDist2Dcot2
int charge() const
track electric charge
constexpr int maxDeltaMissingHits
Power< A, B >::type pow(const A &a, const B &b)
const float radiusOfConversion
double py() const
y coordinate of momentum vector