src
RecoMuon
MuonIdentification
src
MuonCosmicsId.cc
Go to the documentation of this file.
1
#include "
RecoMuon/MuonIdentification/interface/MuonCosmicsId.h
"
2
#include "
DataFormats/TrackReco/interface/Track.h
"
3
4
bool
directionAlongMomentum
(
const
reco::Track
&
track
) {
5
// check is done in 2D
6
return
(
track
.innerPosition().x() -
track
.vx()) *
track
.px() + (
track
.innerPosition().y() -
track
.vy()) *
track
.py() >
7
0;
8
}
9
10
// returns angle and dPt/Pt
11
std::pair<double, double>
muonid::matchTracks
(
const
reco::Track
& ref,
const
reco::Track
& probe) {
12
std::pair<double, double>
result
(0, 0);
13
// When both tracks are reconstructed as outside going, sign is -1
14
// otherwise it's +1. There is also a crazy case of both are outside
15
// going, then sign is -1 as well.
16
int
match_sign =
directionAlongMomentum
(ref) ==
directionAlongMomentum
(probe) ? -1 : +1;
17
double
sprod = ref.
px
() * probe.
px
() + ref.
py
() * probe.
py
() + ref.
pz
() * probe.
pz
();
18
double
argCos = match_sign * (sprod / ref.
p
() / probe.
p
());
19
if
(argCos < -1.0)
20
argCos = -1.0;
21
if
(argCos > 1.0)
22
argCos = 1.0;
23
result
.first = acos(argCos);
24
result
.second = fabs(probe.
pt
() - ref.
pt
()) /
sqrt
(ref.
pt
() * probe.
pt
());
//SK: take a geom-mean pt
25
return
result
;
26
}
27
28
reco::TrackRef
muonid::findOppositeTrack
(
const
edm::Handle<reco::TrackCollection>
&
tracks
,
29
const
reco::Track
& muonTrack,
30
double
angleMatch,
31
double
momentumMatch) {
32
for
(
unsigned
int
i
= 0;
i
<
tracks
->size(); ++
i
) {
33
// When both tracks are reconstructed as outside going, sign is -1
34
// otherwise it's +1. There is also a crazy case of both are outside
35
// going, then sign is -1 as well.
36
const
std::pair<double, double>&
match
=
matchTracks
(muonTrack,
tracks
->at(
i
));
37
if
(
match
.first < angleMatch &&
match
.second < momentumMatch)
38
return
reco::TrackRef
(
tracks
,
i
);
39
}
40
return
reco::TrackRef
();
41
}
muonid::findOppositeTrack
reco::TrackRef findOppositeTrack(const edm::Handle< reco::TrackCollection > &collection, const reco::Track &muon, double angleMatch=0.01, double momentumMatch=0.05)
Definition:
MuonCosmicsId.cc:28
mps_fire.i
i
Definition:
mps_fire.py:428
mps_fire.result
result
Definition:
mps_fire.py:311
edm::Ref< TrackCollection >
reco::TrackBase::px
double px() const
x coordinate of momentum vector
Definition:
TrackBase.h:640
reco::TrackBase::p
double p() const
momentum vector magnitude
Definition:
TrackBase.h:631
edm::Handle< reco::TrackCollection >
reco::TrackBase::py
double py() const
y coordinate of momentum vector
Definition:
TrackBase.h:643
MuonCosmicsId.h
muonid::matchTracks
std::pair< double, double > matchTracks(const reco::Track &ref, const reco::Track &probe)
Definition:
MuonCosmicsId.cc:11
reco::TrackBase::pt
double pt() const
track transverse momentum
Definition:
TrackBase.h:637
directionAlongMomentum
bool directionAlongMomentum(const reco::Track &track)
Definition:
MuonCosmicsId.cc:4
mathSSE::sqrt
T sqrt(T t)
Definition:
SSEVec.h:19
HLT_2022v12_cff.track
track
Definition:
HLT_2022v12_cff.py:9241
tracks
auto const & tracks
cannot be loose
Definition:
CAHitNtupletGeneratorKernelsImpl.h:148
reco::TrackRef
edm::Ref< TrackCollection > TrackRef
persistent reference to a Track
Definition:
TrackFwd.h:20
reco::TrackBase::pz
double pz() const
z coordinate of momentum vector
Definition:
TrackBase.h:646
reco::Track
Definition:
Track.h:27
Track.h
match
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
Definition:
Utils.h:10
Generated for CMSSW Reference Manual by
1.8.14