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.;
235 for (
unsigned int iColl = 0; iColl<
trackTokens_.size(); ++iColl){
252 unsigned int nGlb = 0;
258 for ( reco::MuonCollection::const_iterator iMuon = muonHandle->begin(); iMuon != muonHandle->end(); ++iMuon ) {
259 if (!iMuon->isGlobalMuon())
continue;
281 bool overlappingMuon =
false;
294 RefVtx.SetXYZ(0, 0, 0);
299 for(reco::VertexCollection::const_iterator it=vertices.begin() ; it!=vertices.end() ; ++it) {
300 RefVtx = it->position();
305 for ( reco::MuonCollection::const_iterator cosmicMuon = muonHandle->begin();cosmicMuon != muonHandle->end(); ++cosmicMuon ) {
306 if ( cosmicMuon->innerTrack() == muon.
innerTrack() || cosmicMuon->outerTrack() == muon.
outerTrack())
return true;
312 if( outertrack->phi() > 0 ) isUp =
true;
315 int RecHitsMuon = outertrack->numberOfValidHits();
316 int RecHitsCosmicMuon = 0;
328 if( (*coshit)->isValid() ) {
329 DetId id((*coshit)->geographicalId());
331 if( hity > 0 ) nhitsUp++;
332 if( hity < 0 ) nhitsDown++;
334 if( isUp && hity > 0 ) RecHitsCosmicMuon++;
335 if( !isUp && hity < 0 ) RecHitsCosmicMuon++;
350 GlobalPoint muonRefVtx( outertrack->vx(), outertrack->vy(), outertrack->vz() );
351 GlobalPoint cosmicRefVtx( costrack->vx(), costrack->vy(), costrack->vz() );
356 for(
trackingRecHit_iterator trkhit = outertrack->recHitsBegin(); trkhit != outertrack->recHitsEnd(); trkhit++ ) {
357 if( (*trkhit)->isValid() ) {
359 if( (*coshit)->isValid() ) {
360 if( (*trkhit)->geographicalId() == (*coshit)->geographicalId() ) {
361 if( ((*trkhit)->localPosition() - (*coshit)->localPosition()).
mag()< 10
e-5 ) shared++;
372 if( RecHitsMuon != 0 ) fraction = shared/(double)RecHitsMuon;
375 overlappingMuon =
true;
381 return overlappingMuon;
390 float maxdxyMult, maxdzMult, maxdxy, maxdz;
412 bool multipleMu =
false;
413 if (
nMuons(iEvent) > 1) multipleMu =
true;
416 RefVtx.SetXYZ(0, 0, 0);
421 for(reco::VertexCollection::const_iterator it=vertices.begin() ; it!=vertices.end() ; ++it){
422 RefVtx = it->position();
428 if ( fabs( (*track).dxy(RefVtx) ) < maxdxyMult || fabs( (*track).dz(RefVtx) ) < maxdzMult) {
432 if (!isLoose && fabs( (*track).dxy(RefVtx) ) >
largedxyMult_) result -= 1;
438 if (fabs( (*track).dxy(RefVtx) ) < maxdxy || fabs( (*track).dz(RefVtx) ) < maxdz) {
442 if (!isLoose && fabs( (*track).dxy(RefVtx) ) >
largedxy_) result -= 1;
450 if (result == 0 && multipleMu) {
462 for ( reco::MuonCollection::const_iterator
muons = muonHandle->begin();
muons != muonHandle->end(); ++
muons ) {
463 if (!
muons->isGlobalMuon())
continue;
468 if (
muons->isGlobalMuon()) tracks =
muons->innerTrack();
469 if (fabs((*tracks).dxy(RefVtx)) >
hIpTrdxy_)
continue;
471 if (vertices.begin() == vertices.end())
continue;
475 if (TMath::Prob(vertices.front().chi2(),(
int)(vertices.front().ndof())) >
hIpTrvProb_) result = 1;
497 unsigned int looseIp =
pvMatches(iEvent, muon,
true);
498 unsigned int tightIp =
pvMatches(iEvent, muon,
false);
499 float looseTime =
muonTiming(iEvent, muon,
true);
500 float tightTime =
muonTiming(iEvent, muon,
false);
505 if (checkVertex && cosmicVertex == 0)
return 10.0;
512 double weight_btob = 2.0;
513 double weight_ip = 2.0;
514 double weight_time = 1.0;
515 double weight_overlap = 0.5;
521 if( backToback >= 1 ) {
523 result += weight_btob*2.;
527 if( backToback < 2 ) result -= weight_btob*0.5;
535 result += weight_ip*2.0;
536 if( backToback == 0 ) {
538 if( tightTime == 0 ) {
539 if( looseTime == 0 && !isOverlapping ) result -= weight_ip*1.0;
543 else if( tightIp >= 2 ) {
546 if( backToback >= 1 ) result -= weight_ip*1.0;
550 if( tightTime > 0 ) {
552 if( looseTime > 0 ) {
553 if( backToback >= 1 ) {
554 if( tightIp == 0 ) result += weight_time*tightTime;
555 else if( looseIp == 0 ) result += weight_time*0.25;
559 if( backToback >= 1 && tightIp == 0 ) result += weight_time*0.25;
564 if( backToback == 0 && isOverlapping ) {
566 if( tightIp == 0 && tightTime >= 1 ) {
567 result += weight_overlap*1.0;
592 if (!tracks.
failedToGet() && tracks->size() < 3)
return 0;
599 if (vertices.begin() == vertices.end())
return 0;
600 for(reco::VertexCollection::const_iterator it=vertices.begin() ; it!=vertices.end() ; ++it){
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 DT/CSC combined 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_
const Surface::PositionType & position() const
The position (origin of the R.F.)
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_
const GeomDet * idToDet(DetId) const override
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...