CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 &)
 
 ~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_
 
double deltaPt_
 
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_
 
int nChamberMatches_
 
unsigned int nTrackThreshold_
 
double offTimeNegLoose_
 
double offTimeNegLooseMult_
 
double offTimeNegTight_
 
double offTimeNegTightMult_
 
double offTimePosLoose_
 
double offTimePosLooseMult_
 
double offTimePosTight_
 
double offTimePosTightMult_
 
double segmentComp_
 
MuonServiceProxyservice_
 
double sharedFrac_
 
int sharedHits_
 

Detailed Description

Description: class for cosmic muon identification

Date:
2010/09/13 12:44:08
Revision:
1.2
Author
: A. Everett, Purdue University
: A. Svyatkovskiy, Purdue University
: H.D. Yoo, Purdue University

Description: class for cosmic muon identification

Date:
2011/10/28 22:10:34
Revision:
1.4
Author
: A. Everett, Purdue University
: A. Svyatkovskiy, Purdue University
: H.D. Yoo, Purdue University

Definition at line 32 of file MuonCosmicCompatibilityFiller.h.

Constructor & Destructor Documentation

MuonCosmicCompatibilityFiller::MuonCosmicCompatibilityFiller ( const edm::ParameterSet iConfig)

Definition at line 55 of file MuonCosmicCompatibilityFiller.cc.

References angleThreshold_, corrTimeNeg_, corrTimePos_, deltaPt_, edm::ParameterSet::getParameter(), hIpTrdxy_, hIpTrvProb_, ipThreshold_, largedxy_, largedxyMult_, maxdxyLoose_, maxdxyLooseMult_, maxdxyTight_, maxdxyTightMult_, maxdzLoose_, maxdzLooseMult_, maxdzTight_, maxdzTightMult_, maxvertRho_, maxvertZ_, minvProb_, MuonServiceProxy_cff::MuonServiceProxy, nChamberMatches_, offTimeNegLoose_, offTimeNegLooseMult_, offTimeNegTight_, offTimeNegTightMult_, offTimePosLoose_, offTimePosLooseMult_, offTimePosTight_, offTimePosTightMult_, segmentComp_, service_, sharedFrac_, and sharedHits_.

55  :
56  inputMuonCollections_(iConfig.getParameter<std::vector<edm::InputTag> >("InputMuonCollections")),
57  inputTrackCollections_(iConfig.getParameter<std::vector<edm::InputTag> >("InputTrackCollections")),
58  inputCosmicMuonCollection_(iConfig.getParameter<edm::InputTag>("InputCosmicMuonCollection")),
59  inputVertexCollection_(iConfig.getParameter<edm::InputTag>("InputVertexCollection")),
60  service_(0)
61 {
62  // service parameters
63  edm::ParameterSet serviceParameters = iConfig.getParameter<edm::ParameterSet>("ServiceParameters");
64  service_ = new MuonServiceProxy(serviceParameters);
65 
66  //kinematic vars
67  angleThreshold_ = iConfig.getParameter<double>("angleCut");
68  deltaPt_ = iConfig.getParameter<double>("deltaPt");
69  //time
70  offTimePosTightMult_ = iConfig.getParameter<double>("offTimePosTightMult");
71  offTimeNegTightMult_ = iConfig.getParameter<double>("offTimeNegTightMult");
72  offTimePosTight_ = iConfig.getParameter<double>("offTimePosTight");
73  offTimeNegTight_ = iConfig.getParameter<double>("offTimeNegTight");
74  offTimePosLooseMult_ = iConfig.getParameter<double>("offTimePosLooseMult");
75  offTimeNegLooseMult_ = iConfig.getParameter<double>("offTimeNegLooseMult");
76  offTimePosLoose_ = iConfig.getParameter<double>("offTimePosLoose");
77  offTimeNegLoose_ = iConfig.getParameter<double>("offTimeNegLoose");
78  corrTimeNeg_ = iConfig.getParameter<double>("corrTimeNeg");
79  corrTimePos_ = iConfig.getParameter<double>("corrTimePos");
80  //rechits
81  sharedHits_ = iConfig.getParameter<int>("sharedHits");
82  sharedFrac_ = iConfig.getParameter<double>("sharedFrac");
83  ipThreshold_ = iConfig.getParameter<double>("ipCut");
84  //segment comp, matches
85  nChamberMatches_ = iConfig.getParameter<int>("nChamberMatches");
86  segmentComp_ = iConfig.getParameter<double>("segmentComp");
87  //ip, vertex
88  maxdzLooseMult_ = iConfig.getParameter<double>("maxdzLooseMult");
89  maxdxyLooseMult_ = iConfig.getParameter<double>("maxdxyLooseMult");
90  maxdzTightMult_ = iConfig.getParameter<double>("maxdzTightMult");
91  maxdxyTightMult_ = iConfig.getParameter<double>("maxdxyTightMult");
92  maxdzLoose_ = iConfig.getParameter<double>("maxdzLoose");
93  maxdxyLoose_ = iConfig.getParameter<double>("maxdxyLoose");
94  maxdzTight_ = iConfig.getParameter<double>("maxdzTight");
95  maxdxyTight_ = iConfig.getParameter<double>("maxdxyTight");
96  largedxyMult_ = iConfig.getParameter<double>("largedxyMult");
97  largedxy_ = iConfig.getParameter<double>("largedxy");
98  hIpTrdxy_ = iConfig.getParameter<double>("hIpTrdxy");
99  hIpTrvProb_ = iConfig.getParameter<double>("hIpTrvProb");
100  minvProb_ = iConfig.getParameter<double>("minvProb");
101  maxvertZ_ = iConfig.getParameter<double>("maxvertZ");
102  maxvertRho_ = iConfig.getParameter<double>("maxvertRho");
103 // nTrackThreshold_ = iConfig.getParameter<unsigned int>("nTrackThreshold");
104 }
T getParameter(std::string const &) const
std::vector< edm::InputTag > inputTrackCollections_
std::vector< edm::InputTag > inputMuonCollections_
MuonCosmicCompatibilityFiller::~MuonCosmicCompatibilityFiller ( )

Definition at line 106 of file MuonCosmicCompatibilityFiller.cc.

References service_.

106  {
107  if (service_) delete service_;
108 }

Member Function Documentation

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 222 of file MuonCosmicCompatibilityFiller.cc.

References angleThreshold_, deltaPt_, muonid::findOppositeTrack(), edm::Event::getByLabel(), reco::Muon::innerTrack(), inputTrackCollections_, reco::Muon::isGlobalMuon(), reco::Muon::isStandAloneMuon(), reco::Muon::isTrackerMuon(), query::result, and reco::Muon::track().

Referenced by combinedCosmicID(), and fillCompatibility().

222  {
223 
224  unsigned int result = 0; //no partners - collision
225  reco::TrackRef track;
226  if ( muon.isGlobalMuon() ) track = muon.innerTrack();
227  else if ( muon.isTrackerMuon() ) track = muon.track();
228  else if ( muon.isStandAloneMuon() ) return false;
229 
230  for (unsigned int iColl = 0; iColl<inputTrackCollections_.size(); ++iColl){
232  iEvent.getByLabel(inputTrackCollections_[iColl],trackHandle);
233  if (muonid::findOppositeTrack(trackHandle, *track, angleThreshold_, deltaPt_).isNonnull()) {
234  result++;
235  }
236  } //loop over track collections
237 
238  return result;
239 }
reco::TrackRef findOppositeTrack(const edm::Handle< reco::TrackCollection > &collection, const reco::Track &muon, double angleMatch=0.01, double momentumMatch=0.05)
virtual TrackRef innerTrack() const
Definition: Muon.h:49
bool isTrackerMuon() const
Definition: Muon.h:212
virtual TrackRef track() const
reference to a Track
Definition: Muon.h:50
bool isGlobalMuon() const
Definition: Muon.h:211
bool isStandAloneMuon() const
Definition: Muon.h:213
tuple result
Definition: query.py:137
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:356
std::vector< edm::InputTag > inputTrackCollections_
bool MuonCosmicCompatibilityFiller::checkMuonID ( const reco::Muon imuon) const
private

tag a muon as cosmic based on the muonID information

Definition at line 605 of file MuonCosmicCompatibilityFiller.cc.

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

606 {
607  bool result = false;
608  // initial set up using Jordan's study: GlobalMuonPromptTight + TMOneStationLoose
610 
611  return result;
612 }
tuple result
Definition: query.py:137
bool isGoodMuon(const reco::Muon &muon, SelectionType type, reco::Muon::ArbitrationType arbitrationType=reco::Muon::SegmentAndTrackArbitration)
main GoodMuon wrapper call
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 614 of file MuonCosmicCompatibilityFiller.cc.

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

614  {
615 
616  bool result = false;
617  if (imuon.numberOfMatches() < nChamberMatches_ && muon::segmentCompatibility(imuon) < segmentComp_) result = true;
618 
619  return result;
620 }
tuple result
Definition: query.py:137
float segmentCompatibility(const reco::Muon &muon, reco::Muon::ArbitrationType arbitrationType=reco::Muon::SegmentAndTrackArbitration)
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 481 of file MuonCosmicCompatibilityFiller.cc.

References backToBack2LegCosmic(), eventActivity(), reco::Muon::isGlobalMuon(), isOverlappingMuon(), muonTiming(), pvMatches(), and query::result.

Referenced by fillCompatibility().

482  {
483 
484  float result = 0.0;
485 
486  // return >=1 = identify as cosmic muon (the more like cosmics, the higher is the number)
487  // return 0.0 = identify as collision muon
488  if( muon.isGlobalMuon() ) {
489 
490  unsigned int cosmicVertex = eventActivity(iEvent, muon);
491  bool isOverlapping = isOverlappingMuon(iEvent, iSetup, muon);
492  unsigned int looseIp = pvMatches(iEvent, muon, true);
493  unsigned int tightIp = pvMatches(iEvent, muon, false);
494  float looseTime = muonTiming(iEvent, muon, true);
495  float tightTime = muonTiming(iEvent, muon, false);
496  unsigned int backToback = backToBack2LegCosmic(iEvent,muon);
497  //bool cosmicSegment = checkMuonSegments(muon);
498 
499  //short cut to reject cosmic event
500  if (checkVertex && cosmicVertex == 0) return 10.0;
501 
502  // compatibility (0 - 10)
503  // weight is assigned by the performance of individual module
504  // btob: ~90% eff / ~0% misid
505  // ip: ~90% eff / ~0% misid
506  // time: ~30% eff / ~0% misid
507  double weight_btob = 2.0;
508  double weight_ip = 2.0;
509  double weight_time = 1.0;
510  double weight_overlap = 0.5;
511 
512  // collision muon should have compatibility < 4 (0 - 4)
513  // cosmic muon should have compatibility >= 4 (4 - 10)
514 
515  // b-to-b (max comp.: 4.0)
516  if( backToback >= 1 ) {
517  //in this case it is cosmic for sure
518  result += weight_btob*2.;
519  if( tightIp == 1 ) {
520  // check with other observables to reduce mis-id (subtract compatibilities)
521  if( looseIp == 1 ) {
522  if( backToback < 2 ) result -= weight_btob*0.5;
523  }
524  }
525  }
526 
527  // ip (max comp.: 4.0)
528  if( tightIp == 0 ) {
529  //in this case it is cosmic for sure
530  result += weight_ip*2.0;
531  if( backToback == 0 ) {
532  // check with other observables to reduce mis-id (subtract compatibilities)
533  if( tightTime == 0 ) {
534  if( looseTime == 0 && !isOverlapping ) result -= weight_ip*1.0;
535  }
536  }
537  }
538  else if( tightIp >= 2 ) {
539  // in this case it is almost collision-like (reduce compatibility)
540  // if multi pvs: comp = -2.0
541  if( backToback >= 1 ) result -= weight_ip*1.0;
542  }
543 
544  // timing (max comp.: 2.0)
545  if( tightTime > 0 ) {
546  // bonus track
547  if( looseTime > 0 ) {
548  if( backToback >= 1 ) {
549  if( tightIp == 0 ) result += weight_time*tightTime;
550  else if( looseIp == 0 ) result += weight_time*0.25;
551  }
552  }
553  else {
554  if( backToback >= 1 && tightIp == 0 ) result += weight_time*0.25;
555  }
556  }
557 
558  // overlapping
559  if( backToback == 0 && isOverlapping ) {
560  // bonus track
561  if( tightIp == 0 && tightTime >= 1 ) {
562  result += weight_overlap*1.0;
563  }
564  }
565  }//is global muon
566 
567 
568 // if (CheckMuonID && cosmicSegment) result += 4;
569 
570  return result;
571 }
bool isGlobalMuon() const
Definition: Muon.h:211
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 ...
tuple result
Definition: query.py:137
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
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) ...
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 579 of file MuonCosmicCompatibilityFiller.cc.

References edm::HandleBase::failedToGet(), edm::Event::getByLabel(), inputTrackCollections_, inputVertexCollection_, maxvertRho_, maxvertZ_, minvProb_, edm::Handle< T >::product(), query::result, and testEve_cfg::tracks.

Referenced by combinedCosmicID(), and fillCompatibility().

580 {
581 
582  unsigned int result = 0; //no good vertices - cosmic-like
583 
584  //check track activity
586  iEvent.getByLabel(inputTrackCollections_[0],tracks);
587  if (!tracks.failedToGet() && tracks->size() < 3) return 0;
588 
589  //cosmic event should have zero good vertices
591  if (!iEvent.getByLabel(inputVertexCollection_,pvHandle)) {return 0;} else {
592  const reco::VertexCollection & vertices = *pvHandle.product();
593  //check if vertex collection is empty
594  if (vertices.begin() == vertices.end()) return 0;
595  for(reco::VertexCollection::const_iterator it=vertices.begin() ; it!=vertices.end() ; ++it){
596  if ((TMath::Prob(it->chi2(),(int)it->ndof()) > minvProb_) && (fabs(it->z()) <= maxvertZ_) && (fabs(it->position().rho()) <= maxvertRho_)) result++;
597  }
598  }
599  return result;
600 }
std::vector< Vertex > VertexCollection
collection of Vertex objects
Definition: VertexFwd.h:9
tuple result
Definition: query.py:137
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:356
bool failedToGet() const
Definition: HandleBase.h:80
tuple tracks
Definition: testEve_cfg.py:39
T const * product() const
Definition: Handle.h:74
std::vector< edm::InputTag > inputTrackCollections_
reco::MuonCosmicCompatibility MuonCosmicCompatibilityFiller::fillCompatibility ( const reco::Muon muon,
edm::Event iEvent,
const edm::EventSetup iSetup 
)

fill cosmic compatibility variables

Definition at line 111 of file MuonCosmicCompatibilityFiller.cc.

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

Referenced by CosmicsMuonIdProducer::produce().

112 {
113  const std::string theCategory = "MuonCosmicCompatibilityFiller";
114 
116 
117  service_->update(iSetup);
118 
119  float timeCompatibility = muonTiming(iEvent, muon, false);
120  float backToBackCompatibility = backToBack2LegCosmic(iEvent,muon);
121  float overlapCompatibility = isOverlappingMuon(iEvent,iSetup,muon);
122  float ipCompatibility = pvMatches(iEvent,muon,false);
123  float vertexCompatibility = eventActivity(iEvent,muon);
124  float combinedCompatibility = combinedCosmicID(iEvent,iSetup,muon,false,false);
125 
126  returnComp.timeCompatibility = timeCompatibility;
127  returnComp.backToBackCompatibility = backToBackCompatibility;
128  returnComp.overlapCompatibility = overlapCompatibility;
129  returnComp.cosmicCompatibility = combinedCompatibility;
130  returnComp.ipCompatibility = ipCompatibility;
131  returnComp.vertexCompatibility = vertexCompatibility;
132 
133  return returnComp;
134 
135 }
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 combinedCosmicID(const edm::Event &, const edm::EventSetup &iSetup, const reco::Muon &, bool CheckMuonID, bool checkVertex) const
combined cosmic-likeness: 0 == not cosmic-like
float backToBackCompatibility
cosmic-likeness based on presence of a track in opp side: 0 == no matching opp tracks ...
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 timeCompatibility
cosmic-likeness based on time: 0 == prompt-like
float muonTiming(const edm::Event &iEvent, const reco::Muon &muon, bool isLoose) const
check muon time (DT and CSC) information: 0 == prompt-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 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) ...
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...
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 267 of file MuonCosmicCompatibilityFiller.cc.

References alignCSCRings::e, edm::HandleBase::failedToGet(), edm::EventSetup::get(), edm::Event::getByLabel(), errorMatrix2Lands_multiChannel::id, reco::Muon::innerTrack(), inputCosmicMuonCollection_, inputVertexCollection_, reco::Muon::isGlobalMuon(), edm::Ref< C, T, F >::isNonnull(), mag(), reco::Muon::outerTrack(), edm::Handle< T >::product(), sharedFrac_, sharedHits_, and MuonServiceProxy::trackingGeometry().

Referenced by combinedCosmicID(), and fillCompatibility().

267  {
268 
269  // 4 steps in this module
270  // step1 : check whether it's 1leg cosmic muon or not
271  // step2 : both muons (muons and muonsFromCosmics1Leg) should have close IP
272  // step3 : both muons should share very close reference point
273  // step4 : check shared hits in both muon tracks
274 
275  // check if this muon is available in muonsFromCosmics collection
276  bool overlappingMuon = false; //false - not cosmic-like
277  if( !muon.isGlobalMuon() ) return false;
278 
279  // reco muons for cosmics
281  iEvent.getByLabel(inputCosmicMuonCollection_, muonHandle);
282 
283  // Global Tracking Geometry
284  ESHandle<GlobalTrackingGeometry> trackingGeometry;
285  iSetup.get<GlobalTrackingGeometryRecord>().get(trackingGeometry);
286 
287  // PV
288  math::XYZPoint RefVtx;
289  RefVtx.SetXYZ(0, 0, 0);
290 
292  iEvent.getByLabel(inputVertexCollection_,pvHandle);
293  const reco::VertexCollection & vertices = *pvHandle.product();
294  for(reco::VertexCollection::const_iterator it=vertices.begin() ; it!=vertices.end() ; ++it) {
295  RefVtx = it->position();
296  }
297 
298 
299  if( !muonHandle.failedToGet() ) {
300  for ( reco::MuonCollection::const_iterator cosmicMuon = muonHandle->begin();cosmicMuon != muonHandle->end(); ++cosmicMuon ) {
301  if ( cosmicMuon->innerTrack() == muon.innerTrack() || cosmicMuon->outerTrack() == muon.outerTrack()) return true;
302 
303  reco::TrackRef outertrack = muon.outerTrack();
304  reco::TrackRef costrack = cosmicMuon->outerTrack();
305 
306  bool isUp = false;
307  if( outertrack->phi() > 0 ) isUp = true;
308 
309  // shared hits
310  int RecHitsMuon = outertrack->numberOfValidHits();
311  int RecHitsCosmicMuon = 0;
312  int shared = 0;
313  // count hits for same hemisphere
314  if( costrack.isNonnull() ) {
315  int nhitsUp = 0;
316  int nhitsDown = 0;
317  // unused
318  // bool isCosmic1Leg = false;
319  // bool isCloseIP = false;
320  // bool isCloseRef = false;
321 
322  for( trackingRecHit_iterator coshit = costrack->recHitsBegin(); coshit != costrack->recHitsEnd(); coshit++ ) {
323  if( (*coshit)->isValid() ) {
324  DetId id((*coshit)->geographicalId());
325  double hity = trackingGeometry->idToDet(id)->position().y();
326  if( hity > 0 ) nhitsUp++;
327  if( hity < 0 ) nhitsDown++;
328 
329  if( isUp && hity > 0 ) RecHitsCosmicMuon++;
330  if( !isUp && hity < 0 ) RecHitsCosmicMuon++;
331  }
332  }
333  // step1
334  //UNUSED: if( nhitsUp > 0 && nhitsDown > 0 ) isCosmic1Leg = true;
335  //if( !isCosmic1Leg ) continue;
336 
337  if( outertrack.isNonnull() ) {
338  // step2
339  //UNUSED: const double ipErr = (double)outertrack->d0Error();
340  //UNUSED: double ipThreshold = max(ipThreshold_, ipErr);
341  //UNUSED: if( fabs(outertrack->dxy(RefVtx) + costrack->dxy(RefVtx)) < ipThreshold ) isCloseIP = true;
342  //if( !isCloseIP ) continue;
343 
344  // step3
345  GlobalPoint muonRefVtx( outertrack->vx(), outertrack->vy(), outertrack->vz() );
346  GlobalPoint cosmicRefVtx( costrack->vx(), costrack->vy(), costrack->vz() );
347  //UNUSED: float dist = (muonRefVtx - cosmicRefVtx).mag();
348  //UNUSED: if( dist < 0.1 ) isCloseRef = true;
349  //if( !isCloseRef ) continue;
350 
351  for( trackingRecHit_iterator trkhit = outertrack->recHitsBegin(); trkhit != outertrack->recHitsEnd(); trkhit++ ) {
352  if( (*trkhit)->isValid() ) {
353  for( trackingRecHit_iterator coshit = costrack->recHitsBegin(); coshit != costrack->recHitsEnd(); coshit++ ) {
354  if( (*coshit)->isValid() ) {
355  if( (*trkhit)->geographicalId() == (*coshit)->geographicalId() ) {
356  if( ((*trkhit)->localPosition() - (*coshit)->localPosition()).mag()< 10e-5 ) shared++;
357  }
358 
359  }
360  }
361  }
362  }
363  }
364  }
365  // step4
366  double fraction = -1;
367  if( RecHitsMuon != 0 ) fraction = shared/(double)RecHitsMuon;
368  // std::cout << "shared = " << shared << " " << fraction << " " << RecHitsMuon << " " << RecHitsCosmicMuon << std::endl;
369  if( shared > sharedHits_ && fraction > sharedFrac_ ) {
370  overlappingMuon = true;
371  break;
372  }
373  }
374  }
375 
376  return overlappingMuon;
377 }
virtual TrackRef innerTrack() const
Definition: Muon.h:49
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
bool isGlobalMuon() const
Definition: Muon.h:211
std::vector< Vertex > VertexCollection
collection of Vertex objects
Definition: VertexFwd.h:9
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:250
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:356
virtual TrackRef outerTrack() const
reference to Track reconstructed in the muon detector only
Definition: Muon.h:52
bool failedToGet() const
Definition: HandleBase.h:80
Definition: DetId.h:20
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:13
const T & get() const
Definition: EventSetup.h:55
T const * product() const
Definition: Handle.h:74
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 141 of file MuonCosmicCompatibilityFiller.cc.

References corrTimeNeg_, corrTimePos_, edm::HandleBase::failedToGet(), edm::Event::getByLabel(), inputMuonCollections_, edm::Ref< C, T, F >::isNonnull(), reco::Muon::isTimeValid(), nMuons(), offTimeNegLoose_, offTimeNegLooseMult_, offTimeNegTight_, offTimeNegTightMult_, offTimePosLoose_, offTimePosLooseMult_, offTimePosTight_, offTimePosTightMult_, reco::Muon::outerTrack(), pvMatches(), query::result, reco::Muon::time(), and reco::MuonTime::timeAtIpInOut.

Referenced by combinedCosmicID(), and fillCompatibility().

141  {
142 
143  float offTimeNegMult, offTimePosMult, offTimeNeg, offTimePos;
144 
145  if (isLoose) {
146  //use "loose" parameter set
147  offTimeNegMult = offTimeNegLooseMult_;
148  offTimePosMult = offTimePosLooseMult_;
149  offTimeNeg = offTimeNegLoose_;
150  offTimePos = offTimePosLoose_;
151  } else {
152  offTimeNegMult = offTimeNegTightMult_;
153  offTimePosMult = offTimePosTightMult_;
154  offTimeNeg = offTimeNegTight_;
155  offTimePos = offTimePosTight_;
156  }
157 
158  float result = 0.0;
159 
160  if( muon.isTimeValid() ) {
161  //case of multiple muon event
162  if (nMuons(iEvent) > 1) {
163 
164  float positiveTime = 0;
165  if ( muon.time().timeAtIpInOut < offTimeNegMult || muon.time().timeAtIpInOut > offTimePosMult) result = 1.;
166  if ( muon.time().timeAtIpInOut > 0.) positiveTime = muon.time().timeAtIpInOut;
167 
168  //special case, looking for time-correlation
169  // between muons in opposite hemispheres
170  if (!isLoose && result == 0 && positiveTime > corrTimePos_) {
171 
172  //check hemi of this muon
173  bool isUp = false;
174  reco::TrackRef outertrack = muon.outerTrack();
175  if( outertrack.isNonnull() ) {
176  if( outertrack->phi() > 0 ) isUp = true;
177 
178  //loop over muons in that event and find if there are any in the opposite hemi
180  iEvent.getByLabel(inputMuonCollections_[1], muonHandle);
181 
182  if( !muonHandle.failedToGet() ) {
183  for ( reco::MuonCollection::const_iterator iMuon = muonHandle->begin(); iMuon != muonHandle->end(); ++iMuon ) {
184  if (!iMuon->isGlobalMuon()) continue;
185 
186  reco::TrackRef checkedTrack = iMuon->outerTrack();
187  if( muon.isTimeValid() ) {
188 
189  // from bottom up
190  if (checkedTrack->phi() < 0 && isUp) {
191  if (iMuon->time().timeAtIpInOut < corrTimeNeg_) result = 1.0;
192  break;
193  } else if (checkedTrack->phi() > 0 && !isUp) {
194  // from top down
195  if (iMuon->time().timeAtIpInOut < corrTimeNeg_) result = 1.0;
196  break;
197  }
198  } //muon is time valid
199  }
200  }
201  } //track is nonnull
202  } //double check timing
203  } else {
204  //case of a single muon event
205  if ( muon.time().timeAtIpInOut < offTimeNeg || muon.time().timeAtIpInOut > offTimePos) result = 1.;
206  }
207  } //is time valid
208 
209 
210  if (!isLoose && result > 0) {
211  //check loose ip
212  if (pvMatches(iEvent, muon, true) == 0) result *= 2.;
213  }
214 
215  return result;
216 }
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 ...
MuonTime time() const
get timing information
Definition: Muon.h:132
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:250
tuple result
Definition: query.py:137
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:356
virtual TrackRef outerTrack() const
reference to Track reconstructed in the muon detector only
Definition: Muon.h:52
bool failedToGet() const
Definition: HandleBase.h:80
bool isTimeValid() const
Definition: Muon.h:130
std::vector< edm::InputTag > inputMuonCollections_
float timeAtIpInOut
Definition: MuonTime.h:14
unsigned int MuonCosmicCompatibilityFiller::nMuons ( const edm::Event iEvent) const
private

get number of muons in the vent

Definition at line 245 of file MuonCosmicCompatibilityFiller.cc.

References edm::HandleBase::failedToGet(), edm::Event::getByLabel(), and inputMuonCollections_.

Referenced by muonTiming(), and pvMatches().

245  {
246 
247  unsigned int nGlb = 0;
248 
250  iEvent.getByLabel(inputMuonCollections_[1], muonHandle);
251 
252  if( !muonHandle.failedToGet() ) {
253  for ( reco::MuonCollection::const_iterator iMuon = muonHandle->begin(); iMuon != muonHandle->end(); ++iMuon ) {
254  if (!iMuon->isGlobalMuon()) continue;
255  nGlb++;
256  }
257  }
258 
259  return nGlb;
260 }
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:356
bool failedToGet() const
Definition: HandleBase.h:80
std::vector< edm::InputTag > inputMuonCollections_
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 383 of file MuonCosmicCompatibilityFiller.cc.

References edm::HandleBase::failedToGet(), edm::Event::getByLabel(), hIpTrdxy_, hIpTrvProb_, reco::Muon::innerTrack(), inputMuonCollections_, inputVertexCollection_, reco::Muon::isGlobalMuon(), edm::Ref< C, T, F >::isNonnull(), reco::Muon::isStandAloneMuon(), reco::Muon::isTrackerMuon(), largedxy_, largedxyMult_, maxdxyLoose_, maxdxyLooseMult_, maxdxyTight_, maxdxyTightMult_, maxdzLoose_, maxdzLooseMult_, maxdzTight_, maxdzTightMult_, patZpeak::muons, nMuons(), reco::Muon::outerTrack(), edm::Handle< T >::product(), query::result, reco::Muon::standAloneMuon(), reco::Muon::track(), and testEve_cfg::tracks.

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

383  {
384 
385  float maxdxyMult, maxdzMult, maxdxy, maxdz;
386 
387  if (isLoose) {
388  //use "loose" parameter set
389  maxdxyMult = maxdxyLooseMult_;
390  maxdzMult = maxdzLooseMult_;
391  maxdxy = maxdxyLoose_;
392  maxdz = maxdzLoose_;
393  } else {
394  maxdxyMult = maxdxyTightMult_;
395  maxdzMult = maxdzTightMult_;
396  maxdxy = maxdxyTight_;
397  maxdz = maxdzTight_;
398  }
399 
400  unsigned int result = 0;
401 
402  reco::TrackRef track;
403  if ( muon.isGlobalMuon() ) track = muon.innerTrack();
404  else if ( muon.isTrackerMuon() ) track = muon.track();
405  else if ( muon.isStandAloneMuon()) track = muon.standAloneMuon();
406 
407  bool multipleMu = false;
408  if (nMuons(iEvent) > 1) multipleMu = true;
409 
410  math::XYZPoint RefVtx;
411  RefVtx.SetXYZ(0, 0, 0);
412 
414  iEvent.getByLabel(inputVertexCollection_,pvHandle);
415  const reco::VertexCollection & vertices = *pvHandle.product();
416  for(reco::VertexCollection::const_iterator it=vertices.begin() ; it!=vertices.end() ; ++it){
417  RefVtx = it->position();
418 
419  if ( track.isNonnull() ) {
420  if (multipleMu) {
421  //multiple muon event
422 
423  if ( fabs( (*track).dxy(RefVtx) ) < maxdxyMult || fabs( (*track).dz(RefVtx) ) < maxdzMult) {
424  result++;
425 
426  //case of extra large dxy
427  if (!isLoose && fabs( (*track).dxy(RefVtx) ) > largedxyMult_) result -= 1;
428 
429  }
430  } else {
431  //single muon event
432 
433  if (fabs( (*track).dxy(RefVtx) ) < maxdxy || fabs( (*track).dz(RefVtx) ) < maxdz) {
434  result++;
435 
436  //case of extra large dxy
437  if (!isLoose && fabs( (*track).dxy(RefVtx) ) > largedxy_) result -= 1;
438 
439  }
440  }
441  }//track is nonnull
442 }//loop over vertices
443 
444  //special case for non-cosmic large ip muons
445  if (result == 0 && multipleMu) {
446  // consider all reco muons in an event
448  iEvent.getByLabel(inputMuonCollections_[1], muonHandle);
449 
450  //cosmic event should have zero good vertices
452  iEvent.getByLabel(inputVertexCollection_,pvHandle);
453  const reco::VertexCollection & vertices = *pvHandle.product();
454 
455  //find the "other" one
456  if( !muonHandle.failedToGet() ) {
457  for ( reco::MuonCollection::const_iterator muons = muonHandle->begin(); muons != muonHandle->end(); ++muons ) {
458  if (!muons->isGlobalMuon()) continue;
459  //skip this track
460  if ( muons->innerTrack() == muon.innerTrack() && muons->outerTrack() == muon.outerTrack()) continue;
461  //check ip and vertex of the "other" muon
463  if (muons->isGlobalMuon()) tracks = muons->innerTrack();
464  if (fabs((*tracks).dxy(RefVtx)) > hIpTrdxy_) continue;
465  //check if vertex collection is empty
466  if (vertices.begin() == vertices.end()) continue;
467  //for(reco::VertexCollection::const_iterator it=vertices.begin() ; it!=vertices.end() ; ++it) {
468  //find matching vertex by position
469  //if (fabs(it->z() - tracks->vz()) > 0.01) continue; //means will not be untagged from cosmics
470  if (TMath::Prob(vertices.front().chi2(),(int)(vertices.front().ndof())) > hIpTrvProb_) result = 1;
471  //}
472  }
473  }
474  }
475 
476  return result;
477 
478 }
virtual TrackRef innerTrack() const
Definition: Muon.h:49
bool isTrackerMuon() const
Definition: Muon.h:212
unsigned int nMuons(const edm::Event &) const
get number of muons in the vent
virtual TrackRef track() const
reference to a Track
Definition: Muon.h:50
bool isGlobalMuon() const
Definition: Muon.h:211
std::vector< Vertex > VertexCollection
collection of Vertex objects
Definition: VertexFwd.h:9
bool isStandAloneMuon() const
Definition: Muon.h:213
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:250
tuple result
Definition: query.py:137
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:356
virtual TrackRef outerTrack() const
reference to Track reconstructed in the muon detector only
Definition: Muon.h:52
bool failedToGet() const
Definition: HandleBase.h:80
tuple tracks
Definition: testEve_cfg.py:39
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:13
T const * product() const
Definition: Handle.h:74
tuple muons
Definition: patZpeak.py:38
std::vector< edm::InputTag > inputMuonCollections_
virtual TrackRef standAloneMuon() const
reference to a stand-alone muon Track
Definition: Muon.h:53

Member Data Documentation

double MuonCosmicCompatibilityFiller::angleThreshold_
private
double MuonCosmicCompatibilityFiller::corrTimeNeg_
private

Definition at line 104 of file MuonCosmicCompatibilityFiller.h.

Referenced by MuonCosmicCompatibilityFiller(), and muonTiming().

double MuonCosmicCompatibilityFiller::corrTimePos_
private

Definition at line 103 of file MuonCosmicCompatibilityFiller.h.

Referenced by MuonCosmicCompatibilityFiller(), and muonTiming().

double MuonCosmicCompatibilityFiller::deltaPt_
private
double MuonCosmicCompatibilityFiller::hIpTrdxy_
private

Definition at line 89 of file MuonCosmicCompatibilityFiller.h.

Referenced by MuonCosmicCompatibilityFiller(), and pvMatches().

double MuonCosmicCompatibilityFiller::hIpTrvProb_
private

Definition at line 90 of file MuonCosmicCompatibilityFiller.h.

Referenced by MuonCosmicCompatibilityFiller(), and pvMatches().

edm::InputTag MuonCosmicCompatibilityFiller::inputCosmicMuonCollection_
private

Definition at line 75 of file MuonCosmicCompatibilityFiller.h.

Referenced by isOverlappingMuon().

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

Definition at line 73 of file MuonCosmicCompatibilityFiller.h.

Referenced by muonTiming(), nMuons(), and pvMatches().

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

Definition at line 74 of file MuonCosmicCompatibilityFiller.h.

Referenced by backToBack2LegCosmic(), and eventActivity().

edm::InputTag MuonCosmicCompatibilityFiller::inputVertexCollection_
private

Definition at line 76 of file MuonCosmicCompatibilityFiller.h.

Referenced by eventActivity(), isOverlappingMuon(), and pvMatches().

double MuonCosmicCompatibilityFiller::ipThreshold_
private

Definition at line 109 of file MuonCosmicCompatibilityFiller.h.

Referenced by MuonCosmicCompatibilityFiller().

double MuonCosmicCompatibilityFiller::largedxy_
private

Definition at line 88 of file MuonCosmicCompatibilityFiller.h.

Referenced by MuonCosmicCompatibilityFiller(), and pvMatches().

double MuonCosmicCompatibilityFiller::largedxyMult_
private

Definition at line 87 of file MuonCosmicCompatibilityFiller.h.

Referenced by MuonCosmicCompatibilityFiller(), and pvMatches().

double MuonCosmicCompatibilityFiller::maxdxyLoose_
private

Definition at line 79 of file MuonCosmicCompatibilityFiller.h.

Referenced by MuonCosmicCompatibilityFiller(), and pvMatches().

double MuonCosmicCompatibilityFiller::maxdxyLooseMult_
private

Definition at line 83 of file MuonCosmicCompatibilityFiller.h.

Referenced by MuonCosmicCompatibilityFiller(), and pvMatches().

double MuonCosmicCompatibilityFiller::maxdxyTight_
private

Definition at line 81 of file MuonCosmicCompatibilityFiller.h.

Referenced by MuonCosmicCompatibilityFiller(), and pvMatches().

double MuonCosmicCompatibilityFiller::maxdxyTightMult_
private

Definition at line 85 of file MuonCosmicCompatibilityFiller.h.

Referenced by MuonCosmicCompatibilityFiller(), and pvMatches().

double MuonCosmicCompatibilityFiller::maxdzLoose_
private

Definition at line 80 of file MuonCosmicCompatibilityFiller.h.

Referenced by MuonCosmicCompatibilityFiller(), and pvMatches().

double MuonCosmicCompatibilityFiller::maxdzLooseMult_
private

Definition at line 84 of file MuonCosmicCompatibilityFiller.h.

Referenced by MuonCosmicCompatibilityFiller(), and pvMatches().

double MuonCosmicCompatibilityFiller::maxdzTight_
private

Definition at line 82 of file MuonCosmicCompatibilityFiller.h.

Referenced by MuonCosmicCompatibilityFiller(), and pvMatches().

double MuonCosmicCompatibilityFiller::maxdzTightMult_
private

Definition at line 86 of file MuonCosmicCompatibilityFiller.h.

Referenced by MuonCosmicCompatibilityFiller(), and pvMatches().

double MuonCosmicCompatibilityFiller::maxvertRho_
private

Definition at line 93 of file MuonCosmicCompatibilityFiller.h.

Referenced by eventActivity(), and MuonCosmicCompatibilityFiller().

double MuonCosmicCompatibilityFiller::maxvertZ_
private

Definition at line 92 of file MuonCosmicCompatibilityFiller.h.

Referenced by eventActivity(), and MuonCosmicCompatibilityFiller().

double MuonCosmicCompatibilityFiller::minvProb_
private

Definition at line 91 of file MuonCosmicCompatibilityFiller.h.

Referenced by eventActivity(), and MuonCosmicCompatibilityFiller().

int MuonCosmicCompatibilityFiller::nChamberMatches_
private
unsigned int MuonCosmicCompatibilityFiller::nTrackThreshold_
private

Definition at line 94 of file MuonCosmicCompatibilityFiller.h.

double MuonCosmicCompatibilityFiller::offTimeNegLoose_
private

Definition at line 96 of file MuonCosmicCompatibilityFiller.h.

Referenced by MuonCosmicCompatibilityFiller(), and muonTiming().

double MuonCosmicCompatibilityFiller::offTimeNegLooseMult_
private

Definition at line 100 of file MuonCosmicCompatibilityFiller.h.

Referenced by MuonCosmicCompatibilityFiller(), and muonTiming().

double MuonCosmicCompatibilityFiller::offTimeNegTight_
private

Definition at line 98 of file MuonCosmicCompatibilityFiller.h.

Referenced by MuonCosmicCompatibilityFiller(), and muonTiming().

double MuonCosmicCompatibilityFiller::offTimeNegTightMult_
private

Definition at line 102 of file MuonCosmicCompatibilityFiller.h.

Referenced by MuonCosmicCompatibilityFiller(), and muonTiming().

double MuonCosmicCompatibilityFiller::offTimePosLoose_
private

Definition at line 95 of file MuonCosmicCompatibilityFiller.h.

Referenced by MuonCosmicCompatibilityFiller(), and muonTiming().

double MuonCosmicCompatibilityFiller::offTimePosLooseMult_
private

Definition at line 99 of file MuonCosmicCompatibilityFiller.h.

Referenced by MuonCosmicCompatibilityFiller(), and muonTiming().

double MuonCosmicCompatibilityFiller::offTimePosTight_
private

Definition at line 97 of file MuonCosmicCompatibilityFiller.h.

Referenced by MuonCosmicCompatibilityFiller(), and muonTiming().

double MuonCosmicCompatibilityFiller::offTimePosTightMult_
private

Definition at line 101 of file MuonCosmicCompatibilityFiller.h.

Referenced by MuonCosmicCompatibilityFiller(), and muonTiming().

double MuonCosmicCompatibilityFiller::segmentComp_
private
MuonServiceProxy* MuonCosmicCompatibilityFiller::service_
private
double MuonCosmicCompatibilityFiller::sharedFrac_
private
int MuonCosmicCompatibilityFiller::sharedHits_
private