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";
128 float offTimeNegMult, offTimePosMult, offTimeNeg, offTimePos;
145 if (
muon.isTimeValid()) {
148 float positiveTime = 0;
149 if (
muon.time().timeAtIpInOut < offTimeNegMult ||
muon.time().timeAtIpInOut > offTimePosMult)
151 if (
muon.time().timeAtIpInOut > 0.)
152 positiveTime =
muon.time().timeAtIpInOut;
161 if (outertrack->phi() > 0)
169 for (reco::MuonCollection::const_iterator iMuon = muonHandle->begin(); iMuon != muonHandle->end();
171 if (!iMuon->isGlobalMuon())
175 if (
muon.isTimeValid()) {
177 if (checkedTrack->phi() < 0 && isUp) {
181 }
else if (checkedTrack->phi() > 0 && !isUp) {
194 if (
muon.time().timeAtIpInOut < offTimeNeg ||
muon.time().timeAtIpInOut > offTimePos)
199 if (!isLoose &&
result > 0) {
215 if (
muon.isGlobalMuon())
217 else if (
muon.isTrackerMuon())
219 else if (
muon.isStandAloneMuon() ||
muon.isRPCMuon() ||
muon.isGEMMuon() ||
muon.isME0Muon())
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;
267 if (!
muon.isGlobalMuon())
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());
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;
402 if (
muon.isGlobalMuon())
404 else if (
muon.isTrackerMuon() ||
muon.isRPCMuon())
406 else if (
muon.isStandAloneMuon())
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();
422 if (
track.isNonnull()) {
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())
464 if (
muons->innerTrack() ==
muon.innerTrack() &&
muons->outerTrack() ==
muon.outerTrack())
468 if (
muons->isGlobalMuon())
470 if (fabs((*tracks).dxy(RefVtx)) >
hIpTrdxy_)
492 bool checkVertex)
const {
497 if (
muon.isGlobalMuon()) {
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;
606 for (reco::VertexCollection::const_iterator it =
vertices.begin(); it !=
vertices.end(); ++it) {
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
float combinedCosmicID(const edm::Event &, const edm::EventSetup &iSetup, const reco::Muon &, bool CheckMuonID, bool checkVertex) const
combined cosmic-likeness: 0 == not cosmic-like
T getParameter(std::string const &) const
edm::ESHandle< GlobalTrackingGeometry > trackingGeometry() const
get the tracking geometry
reco::TrackRef findOppositeTrack(const edm::Handle< reco::TrackCollection > &collection, const reco::Track &muon, double angleMatch=0.01, double momentumMatch=0.05)
edm::ESGetToken< GlobalTrackingGeometry, GlobalTrackingGeometryRecord > geometryToken_
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) ...
T const * product() const
std::vector< Track > TrackCollection
collection of Tracks
bool isNonnull() const
Checks for non-null.
std::vector< edm::EDGetTokenT< reco::TrackCollection > > trackTokens_
std::vector< Vertex > VertexCollection
collection of Vertex objects
double offTimeNegLooseMult_
const GeomDet * idToDet(DetId) 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_
std::vector< edm::EDGetTokenT< reco::MuonCollection > > muonTokens_
float segmentCompatibility(const reco::Muon &muon, reco::Muon::ArbitrationType arbitrationType=reco::Muon::SegmentAndTrackArbitration)
unsigned int nMuons(const edm::Event &) const
get number of muons in the vent
edm::InputTag inputVertexCollection_
reco::MuonCosmicCompatibility fillCompatibility(const reco::Muon &muon, edm::Event &, const edm::EventSetup &)
fill cosmic compatibility variables
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 ...
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
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
int numberOfMatches(ArbitrationType type=SegmentAndTrackArbitration) const
get number of chambers with matched segments
bool checkMuonID(const reco::Muon &) const
tag a muon as cosmic based on the muonID information
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
XYZPointD XYZPoint
point in space with cartesian internal representation
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 ...
unsigned int eventActivity(const edm::Event &, const reco::Muon &) const
returns cosmic-likeness based on the event activity information: tracker track multiplicity and verte...
edm::EDGetTokenT< reco::VertexCollection > vertexToken_
MuonCosmicCompatibilityFiller(const edm::ParameterSet &, edm::ConsumesCollector &)
const Surface::PositionType & position() const
The position (origin of the R.F.)
std::vector< edm::InputTag > inputTrackCollections_
~MuonCosmicCompatibilityFiller()
edm::InputTag inputCosmicMuonCollection_
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 muonTiming(const edm::Event &iEvent, const reco::Muon &muon, bool isLoose) const
check muon time (DT and CSC) information: 0 == prompt-like
float overlapCompatibility
cosmic-likeness based on overlap with traversing cosmic muon (only muon/STA hits are used) ...
double offTimePosLooseMult_
float ipCompatibility
cosmic-likeness based on the 2D impact parameters (dxy, dz wrt to PV). 0 == cosmic-like ...
float vertexCompatibility
cosmic-likeness based on the event activity information: tracker track multiplicity and vertex qualit...