48 inputMuonCollections_(iConfig.getParameter<std::vector<edm::
InputTag> >(
"InputMuonCollections")),
49 inputTrackCollections_(iConfig.getParameter<std::vector<edm::
InputTag> >(
"InputTrackCollections")),
50 inputCosmicMuonCollection_(iConfig.getParameter<edm::
InputTag>(
"InputCosmicMuonCollection")),
51 inputVertexCollection_(iConfig.getParameter<edm::
InputTag>(
"InputVertexCollection")),
117 const std::string theCategory =
"MuonCosmicCompatibilityFiller";
123 float timeCompatibility =
muonTiming(iEvent, muon,
false);
126 float ipCompatibility =
pvMatches(iEvent,muon,
false);
128 float combinedCompatibility =
combinedCosmicID(iEvent,iSetup,muon,
false,
false);
147 float offTimeNegMult, offTimePosMult, offTimeNeg, offTimePos;
168 float positiveTime = 0;
174 if (!isLoose && result == 0 && positiveTime >
corrTimePos_) {
180 if( outertrack->phi() > 0 ) isUp =
true;
187 for ( reco::MuonCollection::const_iterator iMuon = muonHandle->begin(); iMuon != muonHandle->end(); ++iMuon ) {
188 if (!iMuon->isGlobalMuon())
continue;
194 if (checkedTrack->phi() < 0 && isUp) {
195 if (iMuon->time().timeAtIpInOut <
corrTimeNeg_) result = 1.0;
197 }
else if (checkedTrack->phi() > 0 && !isUp) {
199 if (iMuon->time().timeAtIpInOut <
corrTimeNeg_) result = 1.0;
214 if (!isLoose && result > 0) {
216 if (
pvMatches(iEvent, muon,
true) == 0) result *= 2.;
234 for (
unsigned int iColl = 0; iColl<
trackTokens_.size(); ++iColl){
251 unsigned int nGlb = 0;
257 for ( reco::MuonCollection::const_iterator iMuon = muonHandle->begin(); iMuon != muonHandle->end(); ++iMuon ) {
258 if (!iMuon->isGlobalMuon())
continue;
280 bool overlappingMuon =
false;
293 RefVtx.SetXYZ(0, 0, 0);
298 for(reco::VertexCollection::const_iterator it=vertices.begin() ; it!=vertices.end() ; ++it) {
299 RefVtx = it->position();
304 for ( reco::MuonCollection::const_iterator cosmicMuon = muonHandle->begin();cosmicMuon != muonHandle->end(); ++cosmicMuon ) {
305 if ( cosmicMuon->innerTrack() == muon.
innerTrack() || cosmicMuon->outerTrack() == muon.
outerTrack())
return true;
311 if( outertrack->phi() > 0 ) isUp =
true;
314 int RecHitsMuon = outertrack->numberOfValidHits();
315 int RecHitsCosmicMuon = 0;
327 if( (*coshit)->isValid() ) {
328 DetId id((*coshit)->geographicalId());
329 double hity = trackingGeometry->idToDet(
id)->position().y();
330 if( hity > 0 ) nhitsUp++;
331 if( hity < 0 ) nhitsDown++;
333 if( isUp && hity > 0 ) RecHitsCosmicMuon++;
334 if( !isUp && hity < 0 ) RecHitsCosmicMuon++;
349 GlobalPoint muonRefVtx( outertrack->vx(), outertrack->vy(), outertrack->vz() );
350 GlobalPoint cosmicRefVtx( costrack->vx(), costrack->vy(), costrack->vz() );
355 for(
trackingRecHit_iterator trkhit = outertrack->recHitsBegin(); trkhit != outertrack->recHitsEnd(); trkhit++ ) {
356 if( (*trkhit)->isValid() ) {
358 if( (*coshit)->isValid() ) {
359 if( (*trkhit)->geographicalId() == (*coshit)->geographicalId() ) {
360 if( ((*trkhit)->localPosition() - (*coshit)->localPosition()).
mag()< 10
e-5 ) shared++;
371 if( RecHitsMuon != 0 ) fraction = shared/(double)RecHitsMuon;
374 overlappingMuon =
true;
380 return overlappingMuon;
389 float maxdxyMult, maxdzMult, maxdxy, maxdz;
411 bool multipleMu =
false;
412 if (
nMuons(iEvent) > 1) multipleMu =
true;
415 RefVtx.SetXYZ(0, 0, 0);
420 for(reco::VertexCollection::const_iterator it=vertices.begin() ; it!=vertices.end() ; ++it){
421 RefVtx = it->position();
427 if ( fabs( (*track).dxy(RefVtx) ) < maxdxyMult || fabs( (*track).dz(RefVtx) ) < maxdzMult) {
431 if (!isLoose && fabs( (*track).dxy(RefVtx) ) >
largedxyMult_) result -= 1;
437 if (fabs( (*track).dxy(RefVtx) ) < maxdxy || fabs( (*track).dz(RefVtx) ) < maxdz) {
441 if (!isLoose && fabs( (*track).dxy(RefVtx) ) >
largedxy_) result -= 1;
449 if (result == 0 && multipleMu) {
461 for ( reco::MuonCollection::const_iterator
muons = muonHandle->begin();
muons != muonHandle->end(); ++
muons ) {
462 if (!
muons->isGlobalMuon())
continue;
467 if (
muons->isGlobalMuon()) tracks =
muons->innerTrack();
468 if (fabs((*tracks).dxy(RefVtx)) >
hIpTrdxy_)
continue;
470 if (vertices.begin() == vertices.end())
continue;
474 if (TMath::Prob(vertices.front().chi2(),(int)(vertices.front().ndof())) >
hIpTrvProb_) result = 1;
496 unsigned int looseIp =
pvMatches(iEvent, muon,
true);
497 unsigned int tightIp =
pvMatches(iEvent, muon,
false);
498 float looseTime =
muonTiming(iEvent, muon,
true);
499 float tightTime =
muonTiming(iEvent, muon,
false);
504 if (checkVertex && cosmicVertex == 0)
return 10.0;
511 double weight_btob = 2.0;
512 double weight_ip = 2.0;
513 double weight_time = 1.0;
514 double weight_overlap = 0.5;
520 if( backToback >= 1 ) {
522 result += weight_btob*2.;
526 if( backToback < 2 ) result -= weight_btob*0.5;
534 result += weight_ip*2.0;
535 if( backToback == 0 ) {
537 if( tightTime == 0 ) {
538 if( looseTime == 0 && !isOverlapping ) result -= weight_ip*1.0;
542 else if( tightIp >= 2 ) {
545 if( backToback >= 1 ) result -= weight_ip*1.0;
549 if( tightTime > 0 ) {
551 if( looseTime > 0 ) {
552 if( backToback >= 1 ) {
553 if( tightIp == 0 ) result += weight_time*tightTime;
554 else if( looseIp == 0 ) result += weight_time*0.25;
558 if( backToback >= 1 && tightIp == 0 ) result += weight_time*0.25;
563 if( backToback == 0 && isOverlapping ) {
565 if( tightIp == 0 && tightTime >= 1 ) {
566 result += weight_overlap*1.0;
591 if (!tracks.
failedToGet() && tracks->size() < 3)
return 0;
598 if (vertices.begin() == vertices.end())
return 0;
599 for(reco::VertexCollection::const_iterator it=vertices.begin() ; it!=vertices.end() ; ++it){
600 if ((TMath::Prob(it->chi2(),(int)it->ndof()) >
minvProb_) && (fabs(it->z()) <=
maxvertZ_) && (fabs(it->position().rho()) <=
maxvertRho_)) result++;
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
T getParameter(std::string const &) const
reco::TrackRef findOppositeTrack(const edm::Handle< reco::TrackCollection > &collection, const reco::Track &muon, double angleMatch=0.01, double momentumMatch=0.05)
bool isNonnull() const
Checks for non-null.
virtual TrackRef innerTrack() const
bool getByToken(EDGetToken token, Handle< PROD > &result) const
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
bool isTrackerMuon() const
unsigned int nMuons(const edm::Event &) const
get number of muons in the vent
std::vector< Track > TrackCollection
collection of Tracks
virtual TrackRef track() const
reference to a Track
bool isGlobalMuon() const
std::vector< edm::EDGetTokenT< reco::TrackCollection > > trackTokens_
std::vector< Vertex > VertexCollection
collection of Vertex objects
unsigned int pvMatches(const edm::Event &, const reco::Muon &, bool) const
return cosmic-likeness based on the 2D impact parameters (dxy, dz wrt to PV). 0 == cosmic-like ...
bool isStandAloneMuon() const
double offTimeNegLooseMult_
float combinedCosmicID(const edm::Event &, const edm::EventSetup &iSetup, const reco::Muon &, bool CheckMuonID, bool checkVertex) const
combined cosmic-likeness: 0 == not cosmic-like
MuonTime time() const
get timing information
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_
MuonServiceProxy * service_
edm::EDGetTokenT< reco::MuonCollection > cosmicToken_
double offTimeNegTightMult_
unsigned int backToBack2LegCosmic(const edm::Event &, const reco::Muon &) const
return cosmic-likeness based on presence of a track in opp side: 0 == no matching opp tracks ...
std::vector< edm::EDGetTokenT< reco::MuonCollection > > muonTokens_
float segmentCompatibility(const reco::Muon &muon, reco::Muon::ArbitrationType arbitrationType=reco::Muon::SegmentAndTrackArbitration)
edm::InputTag inputVertexCollection_
reco::MuonCosmicCompatibility fillCompatibility(const reco::Muon &muon, edm::Event &, const edm::EventSetup &)
fill cosmic compatibility variables
unsigned int eventActivity(const edm::Event &, const reco::Muon &) const
returns cosmic-likeness based on the event activity information: tracker track multiplicity and verte...
virtual TrackRef outerTrack() const
reference to Track reconstructed in the muon detector only
bool isGoodMuon(const reco::Muon &muon, SelectionType type, reco::Muon::ArbitrationType arbitrationType=reco::Muon::SegmentAndTrackArbitration)
main GoodMuon wrapper call
float timeCompatibility
cosmic-likeness based on time: 0 == prompt-like
T const * product() const
XYZPointD XYZPoint
point in space with cartesian internal representation
edm::EDGetTokenT< reco::VertexCollection > vertexToken_
MuonCosmicCompatibilityFiller(const edm::ParameterSet &, edm::ConsumesCollector &)
int numberOfMatches(ArbitrationType type=SegmentAndTrackArbitration) const
get number of chambers with matched segments
edm::ESHandle< GlobalTrackingGeometry > trackingGeometry() const
get the tracking geometry
std::vector< edm::InputTag > inputTrackCollections_
float muonTiming(const edm::Event &iEvent, const reco::Muon &muon, bool isLoose) const
check muon time (DT and CSC) information: 0 == prompt-like
~MuonCosmicCompatibilityFiller()
bool checkMuonID(const reco::Muon &) const
tag a muon as cosmic based on the muonID information
edm::InputTag inputCosmicMuonCollection_
bool isOverlappingMuon(const edm::Event &, const edm::EventSetup &iSetup, const reco::Muon &) const
returns cosmic-likeness based on overlap with traversing cosmic muon (only muon/STA hits are used) ...
bool checkMuonSegments(const reco::Muon &muon) const
tag a muon as cosmic based on segment compatibility and the number of segment matches ...
std::vector< edm::InputTag > inputMuonCollections_
float cosmicCompatibility
combined cosmic-likeness: 0 == not cosmic-like
float overlapCompatibility
cosmic-likeness based on overlap with traversing cosmic muon (only muon/STA hits are used) ...
double offTimePosLooseMult_
TrackingRecHitCollection::base::const_iterator trackingRecHit_iterator
iterator over a vector of reference to TrackingRecHit in the same collection
float ipCompatibility
cosmic-likeness based on the 2D impact parameters (dxy, dz wrt to PV). 0 == cosmic-like ...
virtual TrackRef standAloneMuon() const
reference to a stand-alone muon Track
float vertexCompatibility
cosmic-likeness based on the event activity information: tracker track multiplicity and vertex qualit...