CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
MuonCosmicCompatibilityFiller Class Reference

#include <MuonCosmicCompatibilityFiller.h>

Public Member Functions

reco::MuonCosmicCompatibility fillCompatibility (const reco::Muon &muon, edm::Event &, const edm::EventSetup &)
 fill cosmic compatibility variables More...
 
 MuonCosmicCompatibilityFiller (const edm::ParameterSet &, edm::ConsumesCollector &)
 
 ~MuonCosmicCompatibilityFiller ()
 

Private Member Functions

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 More...
 
bool checkMuonID (const reco::Muon &) const
 tag a muon as cosmic based on the muonID information More...
 
bool checkMuonSegments (const reco::Muon &muon) const
 tag a muon as cosmic based on segment compatibility and the number of segment matches More...
 
float combinedCosmicID (const edm::Event &, const edm::EventSetup &iSetup, const reco::Muon &, bool CheckMuonID, bool checkVertex) const
 combined cosmic-likeness: 0 == not cosmic-like More...
 
unsigned int eventActivity (const edm::Event &, const reco::Muon &) const
 returns cosmic-likeness based on the event activity information: tracker track multiplicity and vertex quality. 0 == cosmic-like More...
 
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) More...
 
float muonTiming (const edm::Event &iEvent, const reco::Muon &muon, bool isLoose) const
 check muon time (DT and CSC) information: 0 == prompt-like More...
 
unsigned int nMuons (const edm::Event &) const
 get number of muons in the vent More...
 
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 More...
 

Private Attributes

double angleThreshold_
 
double corrTimeNeg_
 
double corrTimePos_
 
edm::EDGetTokenT< reco::MuonCollectioncosmicToken_
 
double deltaPt_
 
edm::ESGetToken< GlobalTrackingGeometry, GlobalTrackingGeometryRecordgeometryToken_
 
double hIpTrdxy_
 
double hIpTrvProb_
 
edm::InputTag inputCosmicMuonCollection_
 
std::vector< edm::InputTaginputMuonCollections_
 
std::vector< edm::InputTaginputTrackCollections_
 
edm::InputTag inputVertexCollection_
 
double ipThreshold_
 
double largedxy_
 
double largedxyMult_
 
double maxdxyLoose_
 
double maxdxyLooseMult_
 
double maxdxyTight_
 
double maxdxyTightMult_
 
double maxdzLoose_
 
double maxdzLooseMult_
 
double maxdzTight_
 
double maxdzTightMult_
 
double maxvertRho_
 
double maxvertZ_
 
double minvProb_
 
std::vector< edm::EDGetTokenT< reco::MuonCollection > > muonTokens_
 
int nChamberMatches_
 
unsigned int nTrackThreshold_
 
double offTimeNegLoose_
 
double offTimeNegLooseMult_
 
double offTimeNegTight_
 
double offTimeNegTightMult_
 
double offTimePosLoose_
 
double offTimePosLooseMult_
 
double offTimePosTight_
 
double offTimePosTightMult_
 
double segmentComp_
 
double sharedFrac_
 
int sharedHits_
 
std::vector< edm::EDGetTokenT< reco::TrackCollection > > trackTokens_
 
edm::EDGetTokenT< reco::VertexCollectionvertexToken_
 

Detailed Description

Description: class for cosmic muon identification

Author
: A. Everett, Purdue University
: A. Svyatkovskiy, Purdue University
: H.D. Yoo, Purdue University

Definition at line 43 of file MuonCosmicCompatibilityFiller.h.

Constructor & Destructor Documentation

◆ MuonCosmicCompatibilityFiller()

MuonCosmicCompatibilityFiller::MuonCosmicCompatibilityFiller ( const edm::ParameterSet iConfig,
edm::ConsumesCollector iC 
)

Definition at line 43 of file MuonCosmicCompatibilityFiller.cc.

References angleThreshold_, edm::ConsumesCollector::consumes(), corrTimeNeg_, corrTimePos_, cosmicToken_, deltaPt_, edm::ConsumesCollector::esConsumes(), geometryToken_, edm::ParameterSet::getParameter(), hIpTrdxy_, hIpTrvProb_, mps_fire::i, inputCosmicMuonCollection_, inputMuonCollections_, inputTrackCollections_, inputVertexCollection_, ipThreshold_, largedxy_, largedxyMult_, maxdxyLoose_, maxdxyLooseMult_, maxdxyTight_, maxdxyTightMult_, maxdzLoose_, maxdzLooseMult_, maxdzTight_, maxdzTightMult_, maxvertRho_, maxvertZ_, minvProb_, muonTokens_, nChamberMatches_, offTimeNegLoose_, offTimeNegLooseMult_, offTimeNegTight_, offTimeNegTightMult_, offTimePosLoose_, offTimePosLooseMult_, offTimePosTight_, offTimePosTightMult_, segmentComp_, sharedFrac_, sharedHits_, trackTokens_, and vertexToken_.

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")) {
49  //kinematic vars
50  angleThreshold_ = iConfig.getParameter<double>("angleCut");
51  deltaPt_ = iConfig.getParameter<double>("deltaPt");
52  //time
53  offTimePosTightMult_ = iConfig.getParameter<double>("offTimePosTightMult");
54  offTimeNegTightMult_ = iConfig.getParameter<double>("offTimeNegTightMult");
55  offTimePosTight_ = iConfig.getParameter<double>("offTimePosTight");
56  offTimeNegTight_ = iConfig.getParameter<double>("offTimeNegTight");
57  offTimePosLooseMult_ = iConfig.getParameter<double>("offTimePosLooseMult");
58  offTimeNegLooseMult_ = iConfig.getParameter<double>("offTimeNegLooseMult");
59  offTimePosLoose_ = iConfig.getParameter<double>("offTimePosLoose");
60  offTimeNegLoose_ = iConfig.getParameter<double>("offTimeNegLoose");
61  corrTimeNeg_ = iConfig.getParameter<double>("corrTimeNeg");
62  corrTimePos_ = iConfig.getParameter<double>("corrTimePos");
63  //rechits
64  sharedHits_ = iConfig.getParameter<int>("sharedHits");
65  sharedFrac_ = iConfig.getParameter<double>("sharedFrac");
66  ipThreshold_ = iConfig.getParameter<double>("ipCut");
67  //segment comp, matches
68  nChamberMatches_ = iConfig.getParameter<int>("nChamberMatches");
69  segmentComp_ = iConfig.getParameter<double>("segmentComp");
70  //ip, vertex
71  maxdzLooseMult_ = iConfig.getParameter<double>("maxdzLooseMult");
72  maxdxyLooseMult_ = iConfig.getParameter<double>("maxdxyLooseMult");
73  maxdzTightMult_ = iConfig.getParameter<double>("maxdzTightMult");
74  maxdxyTightMult_ = iConfig.getParameter<double>("maxdxyTightMult");
75  maxdzLoose_ = iConfig.getParameter<double>("maxdzLoose");
76  maxdxyLoose_ = iConfig.getParameter<double>("maxdxyLoose");
77  maxdzTight_ = iConfig.getParameter<double>("maxdzTight");
78  maxdxyTight_ = iConfig.getParameter<double>("maxdxyTight");
79  largedxyMult_ = iConfig.getParameter<double>("largedxyMult");
80  largedxy_ = iConfig.getParameter<double>("largedxy");
81  hIpTrdxy_ = iConfig.getParameter<double>("hIpTrdxy");
82  hIpTrvProb_ = iConfig.getParameter<double>("hIpTrvProb");
83  minvProb_ = iConfig.getParameter<double>("minvProb");
84  maxvertZ_ = iConfig.getParameter<double>("maxvertZ");
85  maxvertRho_ = iConfig.getParameter<double>("maxvertRho");
86  // nTrackThreshold_ = iConfig.getParameter<unsigned int>("nTrackThreshold");
87 
88  for (unsigned int i = 0; i < inputMuonCollections_.size(); ++i)
90  for (unsigned int i = 0; i < inputTrackCollections_.size(); ++i)
92 
96 }
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
edm::ESGetToken< GlobalTrackingGeometry, GlobalTrackingGeometryRecord > geometryToken_
std::vector< Track > TrackCollection
collection of Tracks
Definition: TrackFwd.h:14
std::vector< edm::EDGetTokenT< reco::TrackCollection > > trackTokens_
std::vector< Vertex > VertexCollection
collection of Vertex objects
Definition: VertexFwd.h:9
std::vector< Muon > MuonCollection
collection of Muon objects
Definition: MuonFwd.h:9
edm::EDGetTokenT< reco::MuonCollection > cosmicToken_
std::vector< edm::EDGetTokenT< reco::MuonCollection > > muonTokens_
edm::EDGetTokenT< reco::VertexCollection > vertexToken_
std::vector< edm::InputTag > inputTrackCollections_
std::vector< edm::InputTag > inputMuonCollections_

◆ ~MuonCosmicCompatibilityFiller()

MuonCosmicCompatibilityFiller::~MuonCosmicCompatibilityFiller ( )

Definition at line 98 of file MuonCosmicCompatibilityFiller.cc.

98 {}

Member Function Documentation

◆ backToBack2LegCosmic()

unsigned int MuonCosmicCompatibilityFiller::backToBack2LegCosmic ( const edm::Event iEvent,
const reco::Muon muon 
) const
private

return cosmic-likeness based on presence of a track in opp side: 0 == no matching opp tracks

Definition at line 211 of file MuonCosmicCompatibilityFiller.cc.

References angleThreshold_, deltaPt_, muonid::findOppositeTrack(), iEvent, mps_fire::result, HLT_2023v12_cff::track, and trackTokens_.

Referenced by combinedCosmicID(), and fillCompatibility().

212  {
213  unsigned int result = 0; //no partners - collision
215  if (muon.isGlobalMuon())
216  track = muon.innerTrack();
217  else if (muon.isTrackerMuon())
218  track = muon.track();
219  else if (muon.isStandAloneMuon() || muon.isRPCMuon() || muon.isGEMMuon() || muon.isME0Muon())
220  return false;
221 
222  for (unsigned int iColl = 0; iColl < trackTokens_.size(); ++iColl) {
224  iEvent.getByToken(trackTokens_[iColl], trackHandle);
225  if (muonid::findOppositeTrack(trackHandle, *track, angleThreshold_, deltaPt_).isNonnull()) {
226  result++;
227  }
228  } //loop over track collections
229 
230  return result;
231 }
reco::TrackRef findOppositeTrack(const edm::Handle< reco::TrackCollection > &collection, const reco::Track &muon, double angleMatch=0.01, double momentumMatch=0.05)
std::vector< edm::EDGetTokenT< reco::TrackCollection > > trackTokens_
int iEvent
Definition: GenABIO.cc:224

◆ checkMuonID()

bool MuonCosmicCompatibilityFiller::checkMuonID ( const reco::Muon imuon) const
private

tag a muon as cosmic based on the muonID information

Definition at line 590 of file MuonCosmicCompatibilityFiller.cc.

References muon::GlobalMuonPromptTight, muon::isGoodMuon(), mps_fire::result, and muon::TMOneStationLoose.

590  {
591  bool result = false;
592  // initial set up using Jordan's study: GlobalMuonPromptTight + TMOneStationLoose
594  result = true;
595 
596  return result;
597 }
bool isGoodMuon(const reco::Muon &muon, SelectionType type, reco::Muon::ArbitrationType arbitrationType=reco::Muon::SegmentAndTrackArbitration)
main GoodMuon wrapper call

◆ checkMuonSegments()

bool MuonCosmicCompatibilityFiller::checkMuonSegments ( const reco::Muon muon) const
private

tag a muon as cosmic based on segment compatibility and the number of segment matches

Definition at line 599 of file MuonCosmicCompatibilityFiller.cc.

References nChamberMatches_, reco::Muon::numberOfMatches(), mps_fire::result, segmentComp_, and muon::segmentCompatibility().

599  {
600  bool result = false;
601  if (imuon.numberOfMatches() < nChamberMatches_ && muon::segmentCompatibility(imuon) < segmentComp_)
602  result = true;
603 
604  return result;
605 }
float segmentCompatibility(const reco::Muon &muon, reco::Muon::ArbitrationType arbitrationType=reco::Muon::SegmentAndTrackArbitration)

◆ combinedCosmicID()

float MuonCosmicCompatibilityFiller::combinedCosmicID ( const edm::Event iEvent,
const edm::EventSetup iSetup,
const reco::Muon muon,
bool  CheckMuonID,
bool  checkVertex 
) const
private

combined cosmic-likeness: 0 == not cosmic-like

Definition at line 460 of file MuonCosmicCompatibilityFiller.cc.

References backToBack2LegCosmic(), eventActivity(), iEvent, isOverlappingMuon(), muonTiming(), pvMatches(), and mps_fire::result.

Referenced by fillCompatibility().

464  {
465  float result = 0.0;
466 
467  // return >=1 = identify as cosmic muon (the more like cosmics, the higher is the number)
468  // return 0.0 = identify as collision muon
469  if (muon.isGlobalMuon()) {
470  unsigned int cosmicVertex = eventActivity(iEvent, muon);
471  bool isOverlapping = isOverlappingMuon(iEvent, iSetup, muon);
472  unsigned int looseIp = pvMatches(iEvent, muon, true);
473  unsigned int tightIp = pvMatches(iEvent, muon, false);
474  float looseTime = muonTiming(iEvent, muon, true);
475  float tightTime = muonTiming(iEvent, muon, false);
476  unsigned int backToback = backToBack2LegCosmic(iEvent, muon);
477  //bool cosmicSegment = checkMuonSegments(muon);
478 
479  //short cut to reject cosmic event
480  if (checkVertex && cosmicVertex == 0)
481  return 10.0;
482 
483  // compatibility (0 - 10)
484  // weight is assigned by the performance of individual module
485  // btob: ~90% eff / ~0% misid
486  // ip: ~90% eff / ~0% misid
487  // time: ~30% eff / ~0% misid
488  double weight_btob = 2.0;
489  double weight_ip = 2.0;
490  double weight_time = 1.0;
491  double weight_overlap = 0.5;
492 
493  // collision muon should have compatibility < 4 (0 - 4)
494  // cosmic muon should have compatibility >= 4 (4 - 10)
495 
496  // b-to-b (max comp.: 4.0)
497  if (backToback >= 1) {
498  //in this case it is cosmic for sure
499  result += weight_btob * 2.;
500  if (tightIp == 1) {
501  // check with other observables to reduce mis-id (subtract compatibilities)
502  if (looseIp == 1) {
503  if (backToback < 2)
504  result -= weight_btob * 0.5;
505  }
506  }
507  }
508 
509  // ip (max comp.: 4.0)
510  if (tightIp == 0) {
511  //in this case it is cosmic for sure
512  result += weight_ip * 2.0;
513  if (backToback == 0) {
514  // check with other observables to reduce mis-id (subtract compatibilities)
515  if (tightTime == 0) {
516  if (looseTime == 0 && !isOverlapping)
517  result -= weight_ip * 1.0;
518  }
519  }
520  } else if (tightIp >= 2) {
521  // in this case it is almost collision-like (reduce compatibility)
522  // if multi pvs: comp = -2.0
523  if (backToback >= 1)
524  result -= weight_ip * 1.0;
525  }
526 
527  // timing (max comp.: 2.0)
528  if (tightTime > 0) {
529  // bonus track
530  if (looseTime > 0) {
531  if (backToback >= 1) {
532  if (tightIp == 0)
533  result += weight_time * tightTime;
534  else if (looseIp == 0)
535  result += weight_time * 0.25;
536  }
537  } else {
538  if (backToback >= 1 && tightIp == 0)
539  result += weight_time * 0.25;
540  }
541  }
542 
543  // overlapping
544  if (backToback == 0 && isOverlapping) {
545  // bonus track
546  if (tightIp == 0 && tightTime >= 1) {
547  result += weight_overlap * 1.0;
548  }
549  }
550  } //is global muon
551 
552  // if (CheckMuonID && cosmicSegment) result += 4;
553 
554  return result;
555 }
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) ...
int iEvent
Definition: GenABIO.cc:224
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 ...
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...
float muonTiming(const edm::Event &iEvent, const reco::Muon &muon, bool isLoose) const
check muon time (DT and CSC) information: 0 == prompt-like

◆ eventActivity()

unsigned int MuonCosmicCompatibilityFiller::eventActivity ( const edm::Event iEvent,
const reco::Muon muon 
) const
private

returns cosmic-likeness based on the event activity information: tracker track multiplicity and vertex quality. 0 == cosmic-like

Definition at line 560 of file MuonCosmicCompatibilityFiller.cc.

References iEvent, createfilelist::int, maxvertRho_, maxvertZ_, minvProb_, edm::Handle< T >::product(), mps_fire::result, DiMuonV_cfg::tracks, trackTokens_, vertexToken_, and AlignmentTracksFromVertexSelector_cfi::vertices.

Referenced by combinedCosmicID(), and fillCompatibility().

560  {
561  unsigned int result = 0; //no good vertices - cosmic-like
562 
563  //check track activity
565  iEvent.getByToken(trackTokens_[0], tracks);
566  if (!tracks.failedToGet() && tracks->size() < 3)
567  return 0;
568 
569  //cosmic event should have zero good vertices
571  if (!iEvent.getByToken(vertexToken_, pvHandle)) {
572  return 0;
573  } else {
574  const reco::VertexCollection& vertices = *pvHandle.product();
575  //check if vertex collection is empty
576  if (vertices.begin() == vertices.end())
577  return 0;
578  for (reco::VertexCollection::const_iterator it = vertices.begin(); it != vertices.end(); ++it) {
579  if ((TMath::Prob(it->chi2(), (int)it->ndof()) > minvProb_) && (fabs(it->z()) <= maxvertZ_) &&
580  (fabs(it->position().rho()) <= maxvertRho_))
581  result++;
582  }
583  }
584  return result;
585 }
T const * product() const
Definition: Handle.h:70
std::vector< edm::EDGetTokenT< reco::TrackCollection > > trackTokens_
std::vector< Vertex > VertexCollection
collection of Vertex objects
Definition: VertexFwd.h:9
int iEvent
Definition: GenABIO.cc:224
edm::EDGetTokenT< reco::VertexCollection > vertexToken_

◆ fillCompatibility()

reco::MuonCosmicCompatibility MuonCosmicCompatibilityFiller::fillCompatibility ( const reco::Muon muon,
edm::Event iEvent,
const edm::EventSetup iSetup 
)

fill cosmic compatibility variables

Definition at line 100 of file MuonCosmicCompatibilityFiller.cc.

References backToBack2LegCosmic(), reco::MuonCosmicCompatibility::backToBackCompatibility, combinedCosmicID(), reco::MuonCosmicCompatibility::cosmicCompatibility, eventActivity(), iEvent, reco::MuonCosmicCompatibility::ipCompatibility, isOverlappingMuon(), muonTiming(), reco::MuonCosmicCompatibility::overlapCompatibility, pvMatches(), AlCaHLTBitMon_QueryRunRegistry::string, reco::MuonCosmicCompatibility::timeCompatibility, and reco::MuonCosmicCompatibility::vertexCompatibility.

Referenced by CosmicsMuonIdProducer::produce().

102  {
103  const std::string theCategory = "MuonCosmicCompatibilityFiller";
104 
106 
107  float timeCompatibility = muonTiming(iEvent, muon, false);
108  float backToBackCompatibility = backToBack2LegCosmic(iEvent, muon);
109  float overlapCompatibility = isOverlappingMuon(iEvent, iSetup, muon);
110  float ipCompatibility = pvMatches(iEvent, muon, false);
111  float vertexCompatibility = eventActivity(iEvent, muon);
112  float combinedCompatibility = combinedCosmicID(iEvent, iSetup, muon, false, false);
113 
114  returnComp.timeCompatibility = timeCompatibility;
115  returnComp.backToBackCompatibility = backToBackCompatibility;
116  returnComp.overlapCompatibility = overlapCompatibility;
117  returnComp.cosmicCompatibility = combinedCompatibility;
118  returnComp.ipCompatibility = ipCompatibility;
119  returnComp.vertexCompatibility = vertexCompatibility;
120 
121  return returnComp;
122 }
float combinedCosmicID(const edm::Event &, const edm::EventSetup &iSetup, const reco::Muon &, bool CheckMuonID, bool checkVertex) const
combined cosmic-likeness: 0 == not cosmic-like
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) ...
float backToBackCompatibility
cosmic-likeness based on presence of a track in opp side: 0 == no matching opp tracks ...
int iEvent
Definition: GenABIO.cc:224
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 ...
float timeCompatibility
cosmic-likeness based on time: 0 == prompt-like
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...
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) ...
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...

◆ isOverlappingMuon()

bool MuonCosmicCompatibilityFiller::isOverlappingMuon ( const edm::Event iEvent,
const edm::EventSetup iSetup,
const reco::Muon muon 
) const
private

returns cosmic-likeness based on overlap with traversing cosmic muon (only muon/STA hits are used)

Definition at line 256 of file MuonCosmicCompatibilityFiller.cc.

References cosmicToken_, MillePedeFileConverter_cfg::e, edm::HandleBase::failedToGet(), HLT_2023v12_cff::fraction, geometryToken_, edm::EventSetup::getHandle(), iEvent, edm::Ref< C, T, F >::isNonnull(), mag(), edm::Handle< T >::product(), sharedFrac_, sharedHits_, MuonServiceProxy::trackingGeometry(), vertexToken_, and AlignmentTracksFromVertexSelector_cfi::vertices.

Referenced by combinedCosmicID(), and fillCompatibility().

258  {
259  // 4 steps in this module
260  // step1 : check whether it's 1leg cosmic muon or not
261  // step2 : both muons (muons and muonsFromCosmics1Leg) should have close IP
262  // step3 : both muons should share very close reference point
263  // step4 : check shared hits in both muon tracks
264 
265  // check if this muon is available in muonsFromCosmics collection
266  bool overlappingMuon = false; //false - not cosmic-like
267  if (!muon.isGlobalMuon())
268  return false;
269 
270  // reco muons for cosmics
272  iEvent.getByToken(cosmicToken_, muonHandle);
273 
274  // Global Tracking Geometry
275  ESHandle<GlobalTrackingGeometry> trackingGeometry = iSetup.getHandle(geometryToken_);
276 
277  // PV
278  math::XYZPoint RefVtx;
279  RefVtx.SetXYZ(0, 0, 0);
280 
282  iEvent.getByToken(vertexToken_, pvHandle);
283  const reco::VertexCollection& vertices = *pvHandle.product();
284  for (reco::VertexCollection::const_iterator it = vertices.begin(); it != vertices.end(); ++it) {
285  RefVtx = it->position();
286  }
287 
288  if (!muonHandle.failedToGet()) {
289  for (reco::MuonCollection::const_iterator cosmicMuon = muonHandle->begin(); cosmicMuon != muonHandle->end();
290  ++cosmicMuon) {
291  if (cosmicMuon->innerTrack() == muon.innerTrack() || cosmicMuon->outerTrack() == muon.outerTrack())
292  return true;
293 
294  reco::TrackRef outertrack = muon.outerTrack();
295  reco::TrackRef costrack = cosmicMuon->outerTrack();
296 
297  // shared hits
298  int RecHitsMuon = outertrack->numberOfValidHits();
299  int shared = 0;
300  if (costrack.isNonnull()) {
301  // unused
302  // bool isCosmic1Leg = false;
303  // bool isCloseIP = false;
304  // bool isCloseRef = false;
305 
306  if (outertrack.isNonnull()) {
307  // step2
308  //UNUSED: const double ipErr = (double)outertrack->d0Error();
309  //UNUSED: double ipThreshold = max(ipThreshold_, ipErr);
310  //UNUSED: if( fabs(outertrack->dxy(RefVtx) + costrack->dxy(RefVtx)) < ipThreshold ) isCloseIP = true;
311  //if( !isCloseIP ) continue;
312 
313  // step3
314  //GlobalPoint muonRefVtx(outertrack->vx(), outertrack->vy(), outertrack->vz());
315  //GlobalPoint cosmicRefVtx(costrack->vx(), costrack->vy(), costrack->vz());
316  //UNUSED: float dist = (muonRefVtx - cosmicRefVtx).mag();
317  //UNUSED: if( dist < 0.1 ) isCloseRef = true;
318  //if( !isCloseRef ) continue;
319 
320  for (trackingRecHit_iterator trkhit = outertrack->recHitsBegin(); trkhit != outertrack->recHitsEnd();
321  trkhit++) {
322  if ((*trkhit)->isValid()) {
323  for (trackingRecHit_iterator coshit = costrack->recHitsBegin(); coshit != costrack->recHitsEnd();
324  coshit++) {
325  if ((*coshit)->isValid()) {
326  if ((*trkhit)->geographicalId() == (*coshit)->geographicalId()) {
327  if (((*trkhit)->localPosition() - (*coshit)->localPosition()).mag() < 10e-5)
328  shared++;
329  }
330  }
331  }
332  }
333  }
334  }
335  }
336  // step4
337  double fraction = -1;
338  if (RecHitsMuon != 0)
339  fraction = shared / (double)RecHitsMuon;
340  if (shared > sharedHits_ && fraction > sharedFrac_) {
341  overlappingMuon = true;
342  break;
343  }
344  }
345  }
346 
347  return overlappingMuon;
348 }
edm::ESGetToken< GlobalTrackingGeometry, GlobalTrackingGeometryRecord > geometryToken_
T const * product() const
Definition: Handle.h:70
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:238
std::vector< Vertex > VertexCollection
collection of Vertex objects
Definition: VertexFwd.h:9
bool failedToGet() const
Definition: HandleBase.h:72
int iEvent
Definition: GenABIO.cc:224
edm::EDGetTokenT< reco::MuonCollection > cosmicToken_
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
Definition: EventSetup.h:130
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
edm::EDGetTokenT< reco::VertexCollection > vertexToken_

◆ muonTiming()

float MuonCosmicCompatibilityFiller::muonTiming ( const edm::Event iEvent,
const reco::Muon muon,
bool  isLoose 
) const
private

check muon time (DT and CSC) information: 0 == prompt-like

Definition at line 127 of file MuonCosmicCompatibilityFiller.cc.

References corrTimeNeg_, corrTimePos_, edm::HandleBase::failedToGet(), iEvent, nano_mu_reco_cff::isLoose, edm::Ref< C, T, F >::isNonnull(), muonTokens_, nMuons(), offTimeNegLoose_, offTimeNegLooseMult_, offTimeNegTight_, offTimeNegTightMult_, offTimePosLoose_, offTimePosLooseMult_, offTimePosTight_, offTimePosTightMult_, pvMatches(), and mps_fire::result.

Referenced by combinedCosmicID(), and fillCompatibility().

127  {
128  float offTimeNegMult, offTimePosMult, offTimeNeg, offTimePos;
129 
130  if (isLoose) {
131  //use "loose" parameter set
132  offTimeNegMult = offTimeNegLooseMult_;
133  offTimePosMult = offTimePosLooseMult_;
134  offTimeNeg = offTimeNegLoose_;
135  offTimePos = offTimePosLoose_;
136  } else {
137  offTimeNegMult = offTimeNegTightMult_;
138  offTimePosMult = offTimePosTightMult_;
139  offTimeNeg = offTimeNegTight_;
140  offTimePos = offTimePosTight_;
141  }
142 
143  float result = 0.0;
144 
145  if (muon.isTimeValid()) {
146  //case of multiple muon event
147  if (nMuons(iEvent) > 1) {
148  float positiveTime = 0;
149  if (muon.time().timeAtIpInOut < offTimeNegMult || muon.time().timeAtIpInOut > offTimePosMult)
150  result = 1.;
151  if (muon.time().timeAtIpInOut > 0.)
152  positiveTime = muon.time().timeAtIpInOut;
153 
154  //special case, looking for time-correlation
155  // between muons in opposite hemispheres
156  if (!isLoose && result == 0 && positiveTime > corrTimePos_) {
157  //check hemi of this muon
158  bool isUp = false;
159  reco::TrackRef outertrack = muon.outerTrack();
160  if (outertrack.isNonnull()) {
161  if (outertrack->phi() > 0)
162  isUp = true;
163 
164  //loop over muons in that event and find if there are any in the opposite hemi
166  iEvent.getByToken(muonTokens_[1], muonHandle);
167 
168  if (!muonHandle.failedToGet()) {
169  for (reco::MuonCollection::const_iterator iMuon = muonHandle->begin(); iMuon != muonHandle->end();
170  ++iMuon) {
171  if (!iMuon->isGlobalMuon())
172  continue;
173 
174  reco::TrackRef checkedTrack = iMuon->outerTrack();
175  if (muon.isTimeValid()) {
176  // from bottom up
177  if (checkedTrack->phi() < 0 && isUp) {
178  if (iMuon->time().timeAtIpInOut < corrTimeNeg_)
179  result = 1.0;
180  break;
181  } else if (checkedTrack->phi() > 0 && !isUp) {
182  // from top down
183  if (iMuon->time().timeAtIpInOut < corrTimeNeg_)
184  result = 1.0;
185  break;
186  }
187  } //muon is time valid
188  }
189  }
190  } //track is nonnull
191  } //double check timing
192  } else {
193  //case of a single muon event
194  if (muon.time().timeAtIpInOut < offTimeNeg || muon.time().timeAtIpInOut > offTimePos)
195  result = 1.;
196  }
197  } //is time valid
198 
199  if (!isLoose && result > 0) {
200  //check loose ip
201  if (pvMatches(iEvent, muon, true) == 0)
202  result *= 2.;
203  }
204 
205  return result;
206 }
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:238
bool failedToGet() const
Definition: HandleBase.h:72
int iEvent
Definition: GenABIO.cc:224
std::vector< edm::EDGetTokenT< reco::MuonCollection > > muonTokens_
unsigned int nMuons(const edm::Event &) const
get number of muons in the vent
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 ...

◆ nMuons()

unsigned int MuonCosmicCompatibilityFiller::nMuons ( const edm::Event iEvent) const
private

get number of muons in the vent

Definition at line 236 of file MuonCosmicCompatibilityFiller.cc.

References edm::HandleBase::failedToGet(), iEvent, and muonTokens_.

Referenced by muonTiming(), and pvMatches().

236  {
237  unsigned int nGlb = 0;
238 
240  iEvent.getByToken(muonTokens_[1], muonHandle);
241 
242  if (!muonHandle.failedToGet()) {
243  for (reco::MuonCollection::const_iterator iMuon = muonHandle->begin(); iMuon != muonHandle->end(); ++iMuon) {
244  if (!iMuon->isGlobalMuon())
245  continue;
246  nGlb++;
247  }
248  }
249 
250  return nGlb;
251 }
bool failedToGet() const
Definition: HandleBase.h:72
int iEvent
Definition: GenABIO.cc:224
std::vector< edm::EDGetTokenT< reco::MuonCollection > > muonTokens_

◆ pvMatches()

unsigned int MuonCosmicCompatibilityFiller::pvMatches ( const edm::Event iEvent,
const reco::Muon muon,
bool  isLoose 
) const
private

return cosmic-likeness based on the 2D impact parameters (dxy, dz wrt to PV). 0 == cosmic-like

Definition at line 353 of file MuonCosmicCompatibilityFiller.cc.

References edm::HandleBase::failedToGet(), hIpTrdxy_, hIpTrvProb_, iEvent, createfilelist::int, nano_mu_reco_cff::isLoose, largedxy_, largedxyMult_, maxdxyLoose_, maxdxyLooseMult_, maxdxyTight_, maxdxyTightMult_, maxdzLoose_, maxdzLooseMult_, maxdzTight_, maxdzTightMult_, DiMuonV_cfg::muons, muonTokens_, nMuons(), edm::Handle< T >::product(), mps_fire::result, HLT_2023v12_cff::track, DiMuonV_cfg::tracks, vertexToken_, and AlignmentTracksFromVertexSelector_cfi::vertices.

Referenced by combinedCosmicID(), fillCompatibility(), and muonTiming().

355  {
356  float maxdxyMult, maxdzMult, maxdxy, maxdz;
357 
358  if (isLoose) {
359  //use "loose" parameter set
360  maxdxyMult = maxdxyLooseMult_;
361  maxdzMult = maxdzLooseMult_;
362  maxdxy = maxdxyLoose_;
363  maxdz = maxdzLoose_;
364  } else {
365  maxdxyMult = maxdxyTightMult_;
366  maxdzMult = maxdzTightMult_;
367  maxdxy = maxdxyTight_;
368  maxdz = maxdzTight_;
369  }
370 
371  unsigned int result = 0;
372 
374  if (muon.isGlobalMuon())
375  track = muon.innerTrack();
376  else if (muon.isTrackerMuon() || muon.isRPCMuon())
377  track = muon.track();
378  else if (muon.isStandAloneMuon())
379  track = muon.standAloneMuon();
380 
381  bool multipleMu = false;
382  if (nMuons(iEvent) > 1)
383  multipleMu = true;
384 
385  math::XYZPoint RefVtx;
386  RefVtx.SetXYZ(0, 0, 0);
387 
389  iEvent.getByToken(vertexToken_, pvHandle);
390  const reco::VertexCollection& vertices = *pvHandle.product();
391  for (reco::VertexCollection::const_iterator it = vertices.begin(); it != vertices.end(); ++it) {
392  RefVtx = it->position();
393 
394  if (track.isNonnull()) {
395  if (multipleMu) {
396  //multiple muon event
397 
398  if (fabs((*track).dxy(RefVtx)) < maxdxyMult || fabs((*track).dz(RefVtx)) < maxdzMult) {
399  result++;
400 
401  //case of extra large dxy
402  if (!isLoose && fabs((*track).dxy(RefVtx)) > largedxyMult_)
403  result -= 1;
404  }
405  } else {
406  //single muon event
407 
408  if (fabs((*track).dxy(RefVtx)) < maxdxy || fabs((*track).dz(RefVtx)) < maxdz) {
409  result++;
410 
411  //case of extra large dxy
412  if (!isLoose && fabs((*track).dxy(RefVtx)) > largedxy_)
413  result -= 1;
414  }
415  }
416  } //track is nonnull
417  } //loop over vertices
418 
419  //special case for non-cosmic large ip muons
420  if (result == 0 && multipleMu) {
421  // consider all reco muons in an event
423  iEvent.getByToken(muonTokens_[1], muonHandle);
424 
425  //cosmic event should have zero good vertices
427  iEvent.getByToken(vertexToken_, pvHandle);
428  const reco::VertexCollection& vertices = *pvHandle.product();
429 
430  //find the "other" one
431  if (!muonHandle.failedToGet()) {
432  for (reco::MuonCollection::const_iterator muons = muonHandle->begin(); muons != muonHandle->end(); ++muons) {
433  if (!muons->isGlobalMuon())
434  continue;
435  //skip this track
436  if (muons->innerTrack() == muon.innerTrack() && muons->outerTrack() == muon.outerTrack())
437  continue;
438  //check ip and vertex of the "other" muon
440  if (muons->isGlobalMuon())
441  tracks = muons->innerTrack();
442  if (fabs((*tracks).dxy(RefVtx)) > hIpTrdxy_)
443  continue;
444  //check if vertex collection is empty
445  if (vertices.begin() == vertices.end())
446  continue;
447  //for(reco::VertexCollection::const_iterator it=vertices.begin() ; it!=vertices.end() ; ++it) {
448  //find matching vertex by position
449  //if (fabs(it->z() - tracks->vz()) > 0.01) continue; //means will not be untagged from cosmics
450  if (TMath::Prob(vertices.front().chi2(), (int)(vertices.front().ndof())) > hIpTrvProb_)
451  result = 1;
452  //}
453  }
454  }
455  }
456 
457  return result;
458 }
T const * product() const
Definition: Handle.h:70
std::vector< Vertex > VertexCollection
collection of Vertex objects
Definition: VertexFwd.h:9
muons
the two sets of parameters below are mutually exclusive, depending if RECO or ALCARECO is used the us...
Definition: DiMuonV_cfg.py:212
bool failedToGet() const
Definition: HandleBase.h:72
int iEvent
Definition: GenABIO.cc:224
std::vector< edm::EDGetTokenT< reco::MuonCollection > > muonTokens_
unsigned int nMuons(const edm::Event &) const
get number of muons in the vent
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
edm::EDGetTokenT< reco::VertexCollection > vertexToken_

Member Data Documentation

◆ angleThreshold_

double MuonCosmicCompatibilityFiller::angleThreshold_
private

◆ corrTimeNeg_

double MuonCosmicCompatibilityFiller::corrTimeNeg_
private

Definition at line 117 of file MuonCosmicCompatibilityFiller.h.

Referenced by MuonCosmicCompatibilityFiller(), and muonTiming().

◆ corrTimePos_

double MuonCosmicCompatibilityFiller::corrTimePos_
private

Definition at line 116 of file MuonCosmicCompatibilityFiller.h.

Referenced by MuonCosmicCompatibilityFiller(), and muonTiming().

◆ cosmicToken_

edm::EDGetTokenT<reco::MuonCollection> MuonCosmicCompatibilityFiller::cosmicToken_
private

◆ deltaPt_

double MuonCosmicCompatibilityFiller::deltaPt_
private

◆ geometryToken_

edm::ESGetToken<GlobalTrackingGeometry, GlobalTrackingGeometryRecord> MuonCosmicCompatibilityFiller::geometryToken_
private

◆ hIpTrdxy_

double MuonCosmicCompatibilityFiller::hIpTrdxy_
private

Definition at line 102 of file MuonCosmicCompatibilityFiller.h.

Referenced by MuonCosmicCompatibilityFiller(), and pvMatches().

◆ hIpTrvProb_

double MuonCosmicCompatibilityFiller::hIpTrvProb_
private

Definition at line 103 of file MuonCosmicCompatibilityFiller.h.

Referenced by MuonCosmicCompatibilityFiller(), and pvMatches().

◆ inputCosmicMuonCollection_

edm::InputTag MuonCosmicCompatibilityFiller::inputCosmicMuonCollection_
private

Definition at line 83 of file MuonCosmicCompatibilityFiller.h.

Referenced by MuonCosmicCompatibilityFiller().

◆ inputMuonCollections_

std::vector<edm::InputTag> MuonCosmicCompatibilityFiller::inputMuonCollections_
private

Definition at line 81 of file MuonCosmicCompatibilityFiller.h.

Referenced by MuonCosmicCompatibilityFiller().

◆ inputTrackCollections_

std::vector<edm::InputTag> MuonCosmicCompatibilityFiller::inputTrackCollections_
private

Definition at line 82 of file MuonCosmicCompatibilityFiller.h.

Referenced by MuonCosmicCompatibilityFiller().

◆ inputVertexCollection_

edm::InputTag MuonCosmicCompatibilityFiller::inputVertexCollection_
private

Definition at line 84 of file MuonCosmicCompatibilityFiller.h.

Referenced by MuonCosmicCompatibilityFiller().

◆ ipThreshold_

double MuonCosmicCompatibilityFiller::ipThreshold_
private

Definition at line 122 of file MuonCosmicCompatibilityFiller.h.

Referenced by MuonCosmicCompatibilityFiller().

◆ largedxy_

double MuonCosmicCompatibilityFiller::largedxy_
private

Definition at line 101 of file MuonCosmicCompatibilityFiller.h.

Referenced by MuonCosmicCompatibilityFiller(), and pvMatches().

◆ largedxyMult_

double MuonCosmicCompatibilityFiller::largedxyMult_
private

Definition at line 100 of file MuonCosmicCompatibilityFiller.h.

Referenced by MuonCosmicCompatibilityFiller(), and pvMatches().

◆ maxdxyLoose_

double MuonCosmicCompatibilityFiller::maxdxyLoose_
private

Definition at line 92 of file MuonCosmicCompatibilityFiller.h.

Referenced by MuonCosmicCompatibilityFiller(), and pvMatches().

◆ maxdxyLooseMult_

double MuonCosmicCompatibilityFiller::maxdxyLooseMult_
private

Definition at line 96 of file MuonCosmicCompatibilityFiller.h.

Referenced by MuonCosmicCompatibilityFiller(), and pvMatches().

◆ maxdxyTight_

double MuonCosmicCompatibilityFiller::maxdxyTight_
private

Definition at line 94 of file MuonCosmicCompatibilityFiller.h.

Referenced by MuonCosmicCompatibilityFiller(), and pvMatches().

◆ maxdxyTightMult_

double MuonCosmicCompatibilityFiller::maxdxyTightMult_
private

Definition at line 98 of file MuonCosmicCompatibilityFiller.h.

Referenced by MuonCosmicCompatibilityFiller(), and pvMatches().

◆ maxdzLoose_

double MuonCosmicCompatibilityFiller::maxdzLoose_
private

Definition at line 93 of file MuonCosmicCompatibilityFiller.h.

Referenced by MuonCosmicCompatibilityFiller(), and pvMatches().

◆ maxdzLooseMult_

double MuonCosmicCompatibilityFiller::maxdzLooseMult_
private

Definition at line 97 of file MuonCosmicCompatibilityFiller.h.

Referenced by MuonCosmicCompatibilityFiller(), and pvMatches().

◆ maxdzTight_

double MuonCosmicCompatibilityFiller::maxdzTight_
private

Definition at line 95 of file MuonCosmicCompatibilityFiller.h.

Referenced by MuonCosmicCompatibilityFiller(), and pvMatches().

◆ maxdzTightMult_

double MuonCosmicCompatibilityFiller::maxdzTightMult_
private

Definition at line 99 of file MuonCosmicCompatibilityFiller.h.

Referenced by MuonCosmicCompatibilityFiller(), and pvMatches().

◆ maxvertRho_

double MuonCosmicCompatibilityFiller::maxvertRho_
private

◆ maxvertZ_

double MuonCosmicCompatibilityFiller::maxvertZ_
private

◆ minvProb_

double MuonCosmicCompatibilityFiller::minvProb_
private

◆ muonTokens_

std::vector<edm::EDGetTokenT<reco::MuonCollection> > MuonCosmicCompatibilityFiller::muonTokens_
private

◆ nChamberMatches_

int MuonCosmicCompatibilityFiller::nChamberMatches_
private

◆ nTrackThreshold_

unsigned int MuonCosmicCompatibilityFiller::nTrackThreshold_
private

Definition at line 107 of file MuonCosmicCompatibilityFiller.h.

◆ offTimeNegLoose_

double MuonCosmicCompatibilityFiller::offTimeNegLoose_
private

Definition at line 109 of file MuonCosmicCompatibilityFiller.h.

Referenced by MuonCosmicCompatibilityFiller(), and muonTiming().

◆ offTimeNegLooseMult_

double MuonCosmicCompatibilityFiller::offTimeNegLooseMult_
private

Definition at line 113 of file MuonCosmicCompatibilityFiller.h.

Referenced by MuonCosmicCompatibilityFiller(), and muonTiming().

◆ offTimeNegTight_

double MuonCosmicCompatibilityFiller::offTimeNegTight_
private

Definition at line 111 of file MuonCosmicCompatibilityFiller.h.

Referenced by MuonCosmicCompatibilityFiller(), and muonTiming().

◆ offTimeNegTightMult_

double MuonCosmicCompatibilityFiller::offTimeNegTightMult_
private

Definition at line 115 of file MuonCosmicCompatibilityFiller.h.

Referenced by MuonCosmicCompatibilityFiller(), and muonTiming().

◆ offTimePosLoose_

double MuonCosmicCompatibilityFiller::offTimePosLoose_
private

Definition at line 108 of file MuonCosmicCompatibilityFiller.h.

Referenced by MuonCosmicCompatibilityFiller(), and muonTiming().

◆ offTimePosLooseMult_

double MuonCosmicCompatibilityFiller::offTimePosLooseMult_
private

Definition at line 112 of file MuonCosmicCompatibilityFiller.h.

Referenced by MuonCosmicCompatibilityFiller(), and muonTiming().

◆ offTimePosTight_

double MuonCosmicCompatibilityFiller::offTimePosTight_
private

Definition at line 110 of file MuonCosmicCompatibilityFiller.h.

Referenced by MuonCosmicCompatibilityFiller(), and muonTiming().

◆ offTimePosTightMult_

double MuonCosmicCompatibilityFiller::offTimePosTightMult_
private

Definition at line 114 of file MuonCosmicCompatibilityFiller.h.

Referenced by MuonCosmicCompatibilityFiller(), and muonTiming().

◆ segmentComp_

double MuonCosmicCompatibilityFiller::segmentComp_
private

◆ sharedFrac_

double MuonCosmicCompatibilityFiller::sharedFrac_
private

◆ sharedHits_

int MuonCosmicCompatibilityFiller::sharedHits_
private

◆ trackTokens_

std::vector<edm::EDGetTokenT<reco::TrackCollection> > MuonCosmicCompatibilityFiller::trackTokens_
private

◆ vertexToken_

edm::EDGetTokenT<reco::VertexCollection> MuonCosmicCompatibilityFiller::vertexToken_
private