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")),
113 const std::string theCategory =
"MuonCosmicCompatibilityFiller";
119 float timeCompatibility =
muonTiming(iEvent, muon,
false);
122 float ipCompatibility =
pvMatches(iEvent,muon,
false);
124 float combinedCompatibility =
combinedCosmicID(iEvent,iSetup,muon,
false,
false);
143 float offTimeNegMult, offTimePosMult, offTimeNeg, offTimePos;
164 float positiveTime = 0;
170 if (!isLoose && result == 0 && positiveTime >
corrTimePos_) {
176 if( outertrack->phi() > 0 ) isUp =
true;
183 for ( reco::MuonCollection::const_iterator iMuon = muonHandle->begin(); iMuon != muonHandle->end(); ++iMuon ) {
184 if (!iMuon->isGlobalMuon())
continue;
190 if (checkedTrack->phi() < 0 && isUp) {
191 if (iMuon->time().timeAtIpInOut <
corrTimeNeg_) result = 1.0;
193 }
else if (checkedTrack->phi() > 0 && !isUp) {
195 if (iMuon->time().timeAtIpInOut <
corrTimeNeg_) result = 1.0;
210 if (!isLoose && result > 0) {
212 if (
pvMatches(iEvent, muon,
true) == 0) result *= 2.;
247 unsigned int nGlb = 0;
253 for ( reco::MuonCollection::const_iterator iMuon = muonHandle->begin(); iMuon != muonHandle->end(); ++iMuon ) {
254 if (!iMuon->isGlobalMuon())
continue;
276 bool overlappingMuon =
false;
289 RefVtx.SetXYZ(0, 0, 0);
294 for(reco::VertexCollection::const_iterator it=vertices.begin() ; it!=vertices.end() ; ++it) {
295 RefVtx = it->position();
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;
307 if( outertrack->phi() > 0 ) isUp =
true;
310 int RecHitsMuon = outertrack->numberOfValidHits();
311 int RecHitsCosmicMuon = 0;
317 bool isCosmic1Leg =
false;
318 bool isCloseIP =
false;
319 bool isCloseRef =
false;
322 if( (*coshit)->isValid() ) {
323 DetId id((*coshit)->geographicalId());
324 double hity = trackingGeometry->idToDet(
id)->position().y();
325 if( hity > 0 ) nhitsUp++;
326 if( hity < 0 ) nhitsDown++;
328 if( isUp && hity > 0 ) RecHitsCosmicMuon++;
329 if( !isUp && hity < 0 ) RecHitsCosmicMuon++;
333 if( nhitsUp > 0 && nhitsDown > 0 ) isCosmic1Leg =
true;
338 const double ipErr = (double)outertrack->d0Error();
340 if( fabs(outertrack->dxy(RefVtx) + costrack->dxy(RefVtx)) < ipThreshold ) isCloseIP =
true;
344 GlobalPoint muonRefVtx( outertrack->vx(), outertrack->vy(), outertrack->vz() );
345 GlobalPoint cosmicRefVtx( costrack->vx(), costrack->vy(), costrack->vz() );
346 float dist = (muonRefVtx - cosmicRefVtx).
mag();
347 if( dist < 0.1 ) isCloseRef =
true;
350 for(
trackingRecHit_iterator trkhit = outertrack->recHitsBegin(); trkhit != outertrack->recHitsEnd(); trkhit++ ) {
351 if( (*trkhit)->isValid() ) {
353 if( (*coshit)->isValid() ) {
354 if( (*trkhit)->geographicalId() == (*coshit)->geographicalId() ) {
355 if( ((*trkhit)->localPosition() - (*coshit)->localPosition()).
mag()< 10e-5 ) shared++;
365 double fraction = -1;
366 if( RecHitsMuon != 0 ) fraction = shared/(double)RecHitsMuon;
369 overlappingMuon =
true;
375 return overlappingMuon;
384 float maxdxyMult, maxdzMult, maxdxy, maxdz;
406 bool multipleMu =
false;
407 if (
nMuons(iEvent) > 1) multipleMu =
true;
410 RefVtx.SetXYZ(0, 0, 0);
415 for(reco::VertexCollection::const_iterator it=vertices.begin() ; it!=vertices.end() ; ++it){
416 RefVtx = it->position();
422 if ( fabs( (*track).dxy(RefVtx) ) < maxdxyMult || fabs( (*track).dz(RefVtx) ) < maxdzMult) {
426 if (!isLoose && fabs( (*track).dxy(RefVtx) ) >
largedxyMult_) result -= 1;
432 if (fabs( (*track).dxy(RefVtx) ) < maxdxy || fabs( (*track).dz(RefVtx) ) < maxdz) {
436 if (!isLoose && fabs( (*track).dxy(RefVtx) ) >
largedxy_) result -= 1;
444 if (result == 0 && multipleMu) {
456 for ( reco::MuonCollection::const_iterator
muons = muonHandle->begin();
muons != muonHandle->end(); ++
muons ) {
457 if (!
muons->isGlobalMuon())
continue;
462 if (
muons->isGlobalMuon()) tracks =
muons->innerTrack();
463 if (fabs((*tracks).dxy(RefVtx)) >
hIpTrdxy_)
continue;
465 if (vertices.begin() == vertices.end())
continue;
469 if (TMath::Prob(vertices.front().chi2(),(int)(vertices.front().ndof())) >
hIpTrvProb_) result = 1;
491 unsigned int looseIp =
pvMatches(iEvent, muon,
true);
492 unsigned int tightIp =
pvMatches(iEvent, muon,
false);
493 float looseTime =
muonTiming(iEvent, muon,
true);
494 float tightTime =
muonTiming(iEvent, muon,
false);
499 if (checkVertex && cosmicVertex == 0)
return 10.0;
506 double weight_btob = 2.0;
507 double weight_ip = 2.0;
508 double weight_time = 1.0;
509 double weight_overlap = 0.5;
515 if( backToback >= 1 ) {
517 result += weight_btob*2.;
521 if( backToback < 2 ) result -= weight_btob*0.5;
529 result += weight_ip*2.0;
530 if( backToback == 0 ) {
532 if( tightTime == 0 ) {
533 if( looseTime == 0 && !isOverlapping ) result -= weight_ip*1.0;
537 else if( tightIp >= 2 ) {
540 if( backToback >= 1 ) result -= weight_ip*1.0;
544 if( tightTime > 0 ) {
546 if( looseTime > 0 ) {
547 if( backToback >= 1 ) {
548 if( tightIp == 0 ) result += weight_time*tightTime;
549 else if( looseIp == 0 ) result += weight_time*0.25;
553 if( backToback >= 1 && tightIp == 0 ) result += weight_time*0.25;
558 if( backToback == 0 && isOverlapping ) {
560 if( tightIp == 0 && tightTime >= 1 ) {
561 result += weight_overlap*1.0;
586 if (!tracks.
failedToGet() && tracks->size() < 3)
return 0;
593 if (vertices.begin() == vertices.end())
return 0;
594 for(reco::VertexCollection::const_iterator it=vertices.begin() ; it!=vertices.end() ; ++it){
595 if ((TMath::Prob(it->chi2(),(int)it->ndof()) >
minvProb_) && (fabs(it->z()) <=
maxvertZ_) && (fabs(it->position().rho()) <=
maxvertRho_)) result++;
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)
virtual TrackRef innerTrack() 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
virtual TrackRef track() const
reference to a Track
bool isGlobalMuon() const
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
float backToBackCompatibility
cosmic-likeness based on presence of a track in opp side: 0 == no matching opp tracks ...
bool isNonnull() const
Checks for non-null.
double offTimePosTightMult_
const T & max(const T &a, const T &b)
MuonServiceProxy * service_
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 ...
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...
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
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
int numberOfMatches(ArbitrationType type=SegmentAndTrackArbitration) const
get number of chambers with matched segments
float timeCompatibility
cosmic-likeness based on time: 0 == prompt-like
XYZPointD XYZPoint
point in space with cartesian internal representation
T const * product() const
MuonCosmicCompatibilityFiller(const edm::ParameterSet &)
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_
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...