45 : inputMuonCollections_(iConfig.getParameter<std::
vector<edm::
InputTag> >(
"InputMuonCollections")),
46 inputTrackCollections_(iConfig.getParameter<std::
vector<edm::
InputTag> >(
"InputTrackCollections")),
47 inputCosmicMuonCollection_(iConfig.getParameter<edm::
InputTag>(
"InputCosmicMuonCollection")),
48 inputVertexCollection_(iConfig.getParameter<edm::
InputTag>(
"InputVertexCollection")) {
103 const std::string theCategory =
"MuonCosmicCompatibilityFiller";
107 float timeCompatibility =
muonTiming(iEvent, muon,
false);
110 float ipCompatibility =
pvMatches(iEvent, muon,
false);
112 float combinedCompatibility =
combinedCosmicID(iEvent, iSetup, muon,
false,
false);
128 float offTimeNegMult, offTimePosMult, offTimeNeg, offTimePos;
148 float positiveTime = 0;
156 if (!isLoose && result == 0 && positiveTime >
corrTimePos_) {
161 if (outertrack->phi() > 0)
169 for (reco::MuonCollection::const_iterator iMuon = muonHandle->begin(); iMuon != muonHandle->end();
171 if (!iMuon->isGlobalMuon())
177 if (checkedTrack->phi() < 0 && isUp) {
181 }
else if (checkedTrack->phi() > 0 && !isUp) {
199 if (!isLoose && result > 0) {
218 track = muon.
track();
222 for (
unsigned int iColl = 0; iColl <
trackTokens_.size(); ++iColl) {
237 unsigned int nGlb = 0;
243 for (reco::MuonCollection::const_iterator iMuon = muonHandle->begin(); iMuon != muonHandle->end(); ++iMuon) {
244 if (!iMuon->isGlobalMuon())
266 bool overlappingMuon =
false;
279 RefVtx.SetXYZ(0, 0, 0);
284 for (reco::VertexCollection::const_iterator it = vertices.begin(); it != vertices.end(); ++it) {
285 RefVtx = it->position();
289 for (reco::MuonCollection::const_iterator cosmicMuon = muonHandle->begin(); cosmicMuon != muonHandle->end();
291 if (cosmicMuon->innerTrack() == muon.
innerTrack() || cosmicMuon->outerTrack() == muon.
outerTrack())
298 if (outertrack->phi() > 0)
302 int RecHitsMuon = outertrack->numberOfValidHits();
303 int RecHitsCosmicMuon = 0;
315 if ((*coshit)->isValid()) {
316 DetId id((*coshit)->geographicalId());
317 double hity = trackingGeometry->idToDet(
id)->position().y();
323 if (isUp && hity > 0)
325 if (!isUp && hity < 0)
341 GlobalPoint muonRefVtx(outertrack->vx(), outertrack->vy(), outertrack->vz());
342 GlobalPoint cosmicRefVtx(costrack->vx(), costrack->vy(), costrack->vz());
349 if ((*trkhit)->isValid()) {
352 if ((*coshit)->isValid()) {
353 if ((*trkhit)->geographicalId() == (*coshit)->geographicalId()) {
354 if (((*trkhit)->localPosition() - (*coshit)->localPosition()).
mag() < 10
e-5)
365 if (RecHitsMuon != 0)
366 fraction = shared / (double)RecHitsMuon;
369 overlappingMuon =
true;
375 return overlappingMuon;
383 bool isLoose)
const {
384 float maxdxyMult, maxdzMult, maxdxy, maxdz;
405 track = muon.
track();
409 bool multipleMu =
false;
414 RefVtx.SetXYZ(0, 0, 0);
419 for (reco::VertexCollection::const_iterator it = vertices.begin(); it != vertices.end(); ++it) {
420 RefVtx = it->position();
426 if (fabs((*track).dxy(RefVtx)) < maxdxyMult || fabs((*track).dz(RefVtx)) < maxdzMult) {
436 if (fabs((*track).dxy(RefVtx)) < maxdxy || fabs((*track).dz(RefVtx)) < maxdz) {
440 if (!isLoose && fabs((*track).dxy(RefVtx)) >
largedxy_)
448 if (result == 0 && multipleMu) {
460 for (reco::MuonCollection::const_iterator
muons = muonHandle->begin();
muons != muonHandle->end(); ++
muons) {
461 if (!
muons->isGlobalMuon())
468 if (
muons->isGlobalMuon())
469 tracks =
muons->innerTrack();
470 if (fabs((*tracks).dxy(RefVtx)) >
hIpTrdxy_)
473 if (vertices.begin() == vertices.end())
478 if (TMath::Prob(vertices.front().chi2(), (int)(vertices.front().ndof())) >
hIpTrvProb_)
492 bool checkVertex)
const {
500 unsigned int looseIp =
pvMatches(iEvent, muon,
true);
501 unsigned int tightIp =
pvMatches(iEvent, muon,
false);
502 float looseTime =
muonTiming(iEvent, muon,
true);
503 float tightTime =
muonTiming(iEvent, muon,
false);
508 if (checkVertex && cosmicVertex == 0)
516 double weight_btob = 2.0;
517 double weight_ip = 2.0;
518 double weight_time = 1.0;
519 double weight_overlap = 0.5;
525 if (backToback >= 1) {
527 result += weight_btob * 2.;
532 result -= weight_btob * 0.5;
540 result += weight_ip * 2.0;
541 if (backToback == 0) {
543 if (tightTime == 0) {
544 if (looseTime == 0 && !isOverlapping)
545 result -= weight_ip * 1.0;
548 }
else if (tightIp >= 2) {
552 result -= weight_ip * 1.0;
559 if (backToback >= 1) {
561 result += weight_time * tightTime;
562 else if (looseIp == 0)
563 result += weight_time * 0.25;
566 if (backToback >= 1 && tightIp == 0)
567 result += weight_time * 0.25;
572 if (backToback == 0 && isOverlapping) {
574 if (tightIp == 0 && tightTime >= 1) {
575 result += weight_overlap * 1.0;
604 if (vertices.begin() == vertices.end())
606 for (reco::VertexCollection::const_iterator it = vertices.begin(); it != vertices.end(); ++it) {
607 if ((TMath::Prob(it->chi2(), (int)it->ndof()) >
minvProb_) && (fabs(it->z()) <=
maxvertZ_) &&
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
reco::TrackRef findOppositeTrack(const edm::Handle< reco::TrackCollection > &collection, const reco::Track &muon, double angleMatch=0.01, double momentumMatch=0.05)
bool isNonnull() const
Checks for non-null.
uint16_t *__restrict__ id
edm::ESGetToken< GlobalTrackingGeometry, GlobalTrackingGeometryRecord > geometryToken_
virtual TrackRef innerTrack() const
bool getByToken(EDGetToken token, Handle< PROD > &result) const
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
unsigned int nMuons(const edm::Event &) const
get number of muons in the vent
std::vector< Track > TrackCollection
collection of Tracks
std::vector< edm::EDGetTokenT< reco::TrackCollection > > trackTokens_
std::vector< Vertex > VertexCollection
collection of Vertex objects
unsigned int pvMatches(const edm::Event &, const reco::Muon &, bool) const
return cosmic-likeness based on the 2D impact parameters (dxy, dz wrt to PV). 0 == cosmic-like ...
auto const & tracks
cannot be loose
TrackRef track() const override
reference to a Track
double offTimeNegLooseMult_
float combinedCosmicID(const edm::Event &, const edm::EventSetup &iSetup, const reco::Muon &, bool CheckMuonID, bool checkVertex) const
combined cosmic-likeness: 0 == not cosmic-like
MuonTime time() const
get DT/CSC combined timing information
bool isTrackerMuon() const override
std::vector< Muon > MuonCollection
collection of Muon objects
float backToBackCompatibility
cosmic-likeness based on presence of a track in opp side: 0 == no matching opp tracks ...
double offTimePosTightMult_
edm::EDGetTokenT< reco::MuonCollection > cosmicToken_
double offTimeNegTightMult_
unsigned int backToBack2LegCosmic(const edm::Event &, const reco::Muon &) const
return cosmic-likeness based on presence of a track in opp side: 0 == no matching opp tracks ...
std::vector< edm::EDGetTokenT< reco::MuonCollection > > muonTokens_
float segmentCompatibility(const reco::Muon &muon, reco::Muon::ArbitrationType arbitrationType=reco::Muon::SegmentAndTrackArbitration)
edm::InputTag inputVertexCollection_
TrackRef standAloneMuon() const override
reference to a stand-alone muon Track
reco::MuonCosmicCompatibility fillCompatibility(const reco::Muon &muon, edm::Event &, const edm::EventSetup &)
fill cosmic compatibility variables
unsigned int eventActivity(const edm::Event &, const reco::Muon &) const
returns cosmic-likeness based on the event activity information: tracker track multiplicity and verte...
virtual TrackRef outerTrack() const
reference to Track reconstructed in the muon detector only
bool isGoodMuon(const reco::Muon &muon, SelectionType type, reco::Muon::ArbitrationType arbitrationType=reco::Muon::SegmentAndTrackArbitration)
main GoodMuon wrapper call
float timeCompatibility
cosmic-likeness based on time: 0 == prompt-like
T const * product() const
XYZPointD XYZPoint
point in space with cartesian internal representation
edm::EDGetTokenT< reco::VertexCollection > vertexToken_
T getParameter(std::string const &) const
MuonCosmicCompatibilityFiller(const edm::ParameterSet &, edm::ConsumesCollector &)
int numberOfMatches(ArbitrationType type=SegmentAndTrackArbitration) const
get number of chambers with matched segments
edm::ESHandle< GlobalTrackingGeometry > trackingGeometry() const
get the tracking geometry
std::vector< edm::InputTag > inputTrackCollections_
float muonTiming(const edm::Event &iEvent, const reco::Muon &muon, bool isLoose) const
check muon time (DT and CSC) information: 0 == prompt-like
~MuonCosmicCompatibilityFiller()
bool checkMuonID(const reco::Muon &) const
tag a muon as cosmic based on the muonID information
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
edm::InputTag inputCosmicMuonCollection_
bool isOverlappingMuon(const edm::Event &, const edm::EventSetup &iSetup, const reco::Muon &) const
returns cosmic-likeness based on overlap with traversing cosmic muon (only muon/STA hits are used) ...
bool checkMuonSegments(const reco::Muon &muon) const
tag a muon as cosmic based on segment compatibility and the number of segment matches ...
std::vector< edm::InputTag > inputMuonCollections_
float cosmicCompatibility
combined cosmic-likeness: 0 == not cosmic-like
float overlapCompatibility
cosmic-likeness based on overlap with traversing cosmic muon (only muon/STA hits are used) ...
bool isGlobalMuon() const override
double offTimePosLooseMult_
float ipCompatibility
cosmic-likeness based on the 2D impact parameters (dxy, dz wrt to PV). 0 == cosmic-like ...
bool isStandAloneMuon() const override
float vertexCompatibility
cosmic-likeness based on the event activity information: tracker track multiplicity and vertex qualit...