39 for(
int i = 0; selectionTypeStringToEnumMap[
i].
label && (!
found); ++
i)
40 if (! strcmp(label.c_str(), selectionTypeStringToEnumMap[
i].
label)) {
42 value = selectionTypeStringToEnumMap[
i].
value;
46 if (! found)
throw cms::Exception(
"MuonSelectorError") << label <<
" is not a recognized SelectionType";
52 double maxChamberDist,
53 double maxChamberDistPull,
56 unsigned int theMask = 0;
58 for(
int stationIdx = 1; stationIdx < 5; ++stationIdx)
59 for(
int detectorIdx = 1; detectorIdx < 3; ++detectorIdx)
60 if(muon.
trackDist(stationIdx,detectorIdx,arbitrationType) < maxChamberDist &&
61 muon.
trackDist(stationIdx,detectorIdx,arbitrationType)/muon.
trackDistErr(stationIdx,detectorIdx,arbitrationType) < maxChamberDistPull)
62 theMask += 1<<((stationIdx-1)+4*(detectorIdx-1));
74 bool use_weight_regain_at_chamber_boundary =
true;
75 bool use_match_dist_penalty =
true;
77 int nr_of_stations_crossed = 0;
78 int nr_of_stations_with_segment = 0;
79 std::vector<int> stations_w_track(8);
80 std::vector<int> station_has_segmentmatch(8);
81 std::vector<int> station_was_crossed(8);
82 std::vector<float> stations_w_track_at_boundary(8);
83 std::vector<float> station_weight(8);
84 int position_in_stations = 0;
85 float full_weight = 0.;
87 for(
int i = 1;
i<=8; ++
i) {
92 if( muon.
trackDist(
i,1,arbitrationType) < 999999 ) {
93 ++nr_of_stations_crossed;
94 station_was_crossed[
i-1] = 1;
95 if(muon.
trackDist(
i,1,arbitrationType) > -10. ) stations_w_track_at_boundary[
i-1] = muon.
trackDist(
i,1,arbitrationType);
96 else stations_w_track_at_boundary[
i-1] = 0.;
98 if( muon.
segmentX(
i,1,arbitrationType) < 999999 ) {
99 ++nr_of_stations_with_segment;
100 station_has_segmentmatch[
i-1] = 1;
104 if( muon.
trackDist(
i-4,2,arbitrationType) < 999999 ) {
105 ++nr_of_stations_crossed;
106 station_was_crossed[
i-1] = 1;
107 if(muon.
trackDist(
i-4,2,arbitrationType) > -10. ) stations_w_track_at_boundary[
i-1] = muon.
trackDist(
i-4,2,arbitrationType);
108 else stations_w_track_at_boundary[
i-1] = 0.;
110 if( muon.
segmentX(
i-4,2,arbitrationType) < 999999 ) {
111 ++nr_of_stations_with_segment;
112 station_has_segmentmatch[
i-1] = 1;
131 const float attenuate_weight_regain = 0.5;
133 for(
int i = 1;
i<=8; ++
i) {
139 if( station_was_crossed[
i-1] > 0 ) {
145 ++position_in_stations;
147 switch ( nr_of_stations_crossed ) {
149 station_weight[
i-1] = 1.;
152 if ( position_in_stations == 1 ) station_weight[
i-1] = 0.33;
153 else station_weight[
i-1] = 0.67;
156 if ( position_in_stations == 1 ) station_weight[
i-1] = 0.23;
157 else if( position_in_stations == 2 ) station_weight[
i-1] = 0.33;
158 else station_weight[
i-1] = 0.44;
161 if ( position_in_stations == 1 ) station_weight[
i-1] = 0.10;
162 else if( position_in_stations == 2 ) station_weight[
i-1] = 0.20;
163 else if( position_in_stations == 3 ) station_weight[
i-1] = 0.30;
164 else station_weight[
i-1] = 0.40;
171 station_weight[
i-1] = 1./nr_of_stations_crossed;
174 if( use_weight_regain_at_chamber_boundary ) {
175 if(station_has_segmentmatch[
i-1] <= 0 && stations_w_track_at_boundary[
i-1] != 0. ) {
179 station_weight[
i-1] = station_weight[
i-1]*attenuate_weight_regain*0.5*(TMath::Erf(stations_w_track_at_boundary[
i-1]/6.)+1.);
181 else if(station_has_segmentmatch[
i-1] <= 0 && stations_w_track_at_boundary[
i-1] == 0.) {
183 station_weight[
i-1] = 0.;
187 if(station_has_segmentmatch[
i-1] <= 0) station_weight[
i-1] = 0.;
190 if( station_has_segmentmatch[
i-1] > 0 && 42 == 42 ) {
192 if( muon.
dY(
i,1,arbitrationType) < 999999 && muon.
dX(
i,1,arbitrationType) < 999999) {
194 TMath::Sqrt(TMath::Power(muon.
pullX(
i,1,arbitrationType),2.)+TMath::Power(muon.
pullY(
i,1,arbitrationType),2.))> 1. ) {
196 if(use_match_dist_penalty) {
198 if(TMath::Sqrt(TMath::Power(muon.
dX(
i,1,arbitrationType),2.)+TMath::Power(muon.
dY(
i,1,arbitrationType),2.)) < 3. && TMath::Sqrt(TMath::Power(muon.
pullX(
i,1,arbitrationType),2.)+TMath::Power(muon.
pullY(
i,1,arbitrationType),2.)) > 3. ) {
199 station_weight[
i-1] *= 1./TMath::Power(
200 TMath::Max((
double)TMath::Sqrt(TMath::Power(muon.
dX(
i,1,arbitrationType),2.)+TMath::Power(muon.
dY(
i,1,arbitrationType),2.)),(
double)1.),.25);
203 station_weight[
i-1] *= 1./TMath::Power(
204 TMath::Sqrt(TMath::Power(muon.
pullX(
i,1,arbitrationType),2.)+TMath::Power(muon.
pullY(
i,1,arbitrationType),2.)),.25);
209 else if (muon.
dY(
i,1,arbitrationType) >= 999999) {
210 if( muon.
pullX(
i,1,arbitrationType) > 1. ) {
212 if(use_match_dist_penalty) {
214 if( muon.
dX(
i,1,arbitrationType) < 3. && muon.
pullX(
i,1,arbitrationType) > 3. ) {
215 station_weight[
i-1] *= 1./TMath::Power(
TMath::Max((
double)muon.
dX(
i,1,arbitrationType),(double)1.),.25);
218 station_weight[
i-1] *= 1./TMath::Power(muon.
pullX(
i,1,arbitrationType),.25);
224 if( muon.
pullY(
i,1,arbitrationType) > 1. ) {
226 if(use_match_dist_penalty) {
228 if( muon.
dY(
i,1,arbitrationType) < 3. && muon.
pullY(
i,1,arbitrationType) > 3. ) {
229 station_weight[
i-1] *= 1./TMath::Power(
TMath::Max((
double)muon.
dY(
i,1,arbitrationType),(double)1.),.25);
232 station_weight[
i-1] *= 1./TMath::Power(muon.
pullY(
i,1,arbitrationType),.25);
240 TMath::Sqrt(TMath::Power(muon.
pullX(
i-4,2,arbitrationType),2.)+TMath::Power(muon.
pullY(
i-4,2,arbitrationType),2.)) > 1. ) {
242 if(use_match_dist_penalty) {
244 if(TMath::Sqrt(TMath::Power(muon.
dX(
i-4,2,arbitrationType),2.)+TMath::Power(muon.
dY(
i-4,2,arbitrationType),2.)) < 3. && TMath::Sqrt(TMath::Power(muon.
pullX(
i-4,2,arbitrationType),2.)+TMath::Power(muon.
pullY(
i-4,2,arbitrationType),2.)) > 3. ) {
245 station_weight[
i-1] *= 1./TMath::Power(
246 TMath::Max((
double)TMath::Sqrt(TMath::Power(muon.
dX(
i-4,2,arbitrationType),2.)+TMath::Power(muon.
dY(
i-4,2,arbitrationType),2.)),(
double)1.),.25);
249 station_weight[
i-1] *= 1./TMath::Power(
250 TMath::Sqrt(TMath::Power(muon.
pullX(
i-4,2,arbitrationType),2.)+TMath::Power(muon.
pullY(
i-4,2,arbitrationType),2.)),.25);
263 station_weight[
i-1] = 0.;
267 full_weight += station_weight[
i-1];
273 if( nr_of_stations_crossed == 0 ) {
288 double minCompatibility,
291 bool goodMuon =
false;
297 else goodMuon =
false;
310 int minNumberOfMatches,
315 double maxChamberDist,
316 double maxChamberDistPull,
318 bool syncMinNMatchesNRequiredStationsInBarrelOnly,
319 bool applyAlsoAngularCuts)
322 bool goodMuon =
false;
327 if(minNumberOfMatches == 0)
return true;
329 unsigned int theStationMask = muon.
stationMask(arbitrationType);
330 unsigned int theRequiredStationMask =
RequiredStationMask(muon, maxChamberDist, maxChamberDistPull, arbitrationType);
334 int numRequiredStations = 0;
335 for(
int it = 0; it < 8; ++it) {
336 if(theStationMask & 1<<it) ++numSegs;
337 if(theRequiredStationMask & 1<<it) ++numRequiredStations;
342 if (syncMinNMatchesNRequiredStationsInBarrelOnly) {
344 if (fabs(muon.
eta()) < 1.2) {
345 if(minNumberOfMatches > numRequiredStations)
346 minNumberOfMatches = numRequiredStations;
347 if(minNumberOfMatches < 1)
348 minNumberOfMatches = 1;
351 if(minNumberOfMatches > numRequiredStations)
352 minNumberOfMatches = numRequiredStations;
353 if(minNumberOfMatches < 1)
354 minNumberOfMatches = 1;
357 if(numSegs >= minNumberOfMatches) goodMuon = 1;
364 if(theRequiredStationMask) {
365 for(
int stationIdx = 7; stationIdx >= 0; --stationIdx)
366 if(theRequiredStationMask & 1<<stationIdx){
367 if(theStationMask & 1<<stationIdx) {
368 lastSegBit = stationIdx;
377 for(
int stationIdx = 7; stationIdx >= 0; --stationIdx)
378 if(theStationMask & 1<<stationIdx) {
379 lastSegBit = stationIdx;
384 if(!goodMuon)
return false;
388 station = lastSegBit < 4 ? lastSegBit+1 : lastSegBit-3;
389 detector = lastSegBit < 4 ? 1 : 2;
392 if(fabs(muon.
pullX(station,detector,arbitrationType,1)) > maxAbsPullX &&
393 fabs(muon.
dX(station,detector,arbitrationType)) > maxAbsDx)
396 if(applyAlsoAngularCuts && fabs(muon.
pullDxDz(station,detector,arbitrationType,1)) > maxAbsPullX)
400 if (maxAbsDy < 999999) {
404 if(fabs(muon.
pullY(station,2,arbitrationType,1)) > maxAbsPullY &&
405 fabs(muon.
dY(station,2,arbitrationType)) > maxAbsDy)
408 if(applyAlsoAngularCuts && fabs(muon.
pullDyDz(station,2,arbitrationType,1)) > maxAbsPullY)
426 for (
int stationIdx = station; stationIdx > 0; --stationIdx) {
427 if(! (theStationMask & 1<<(stationIdx-1)))
430 if(muon.
dY(stationIdx,1,arbitrationType) > 999998)
433 if(fabs(muon.
pullY(stationIdx,1,arbitrationType,1)) > maxAbsPullY &&
434 fabs(muon.
dY(stationIdx,1,arbitrationType)) > maxAbsDy) {
438 if(applyAlsoAngularCuts && fabs(muon.
pullDyDz(stationIdx,1,arbitrationType,1)) > maxAbsPullY)
461 unsigned int theStationMask = muon.
stationMask(arbitrationType);
464 if (! theStationMask)
return false;
471 bool existsGoodDTSegX =
false;
472 bool existsDTSegY =
false;
476 for(
int stationIdx = 0; stationIdx <= 7; ++stationIdx)
477 if(theStationMask & 1<<stationIdx) {
478 station = stationIdx < 4 ? stationIdx+1 : stationIdx-3;
479 detector = stationIdx < 4 ? 1 : 2;
481 if((fabs(muon.
pullX(station,detector,arbitrationType,1)) > maxAbsPullX &&
482 fabs(muon.
dX(station,detector,arbitrationType)) > maxAbsDx) ||
483 (applyAlsoAngularCuts && fabs(muon.
pullDxDz(station,detector,arbitrationType,1)) > maxAbsPullX))
485 else if (detector == 1)
486 existsGoodDTSegX =
true;
489 if (maxAbsDy < 999999) {
491 if((fabs(muon.
pullY(station,2,arbitrationType,1)) > maxAbsPullY &&
492 fabs(muon.
dY(station,2,arbitrationType)) > maxAbsDy) ||
493 (applyAlsoAngularCuts && fabs(muon.
pullDyDz(station,2,arbitrationType,1)) > maxAbsPullY))
497 if(muon.
dY(station,1,arbitrationType) > 999998)
502 if((fabs(muon.
pullY(station,1,arbitrationType,1)) > maxAbsPullY &&
503 fabs(muon.
dY(station,1,arbitrationType)) > maxAbsDy) ||
504 (applyAlsoAngularCuts && fabs(muon.
pullDyDz(station,1,arbitrationType,1)) > maxAbsPullY)) {
521 if (maxAbsDy < 999999) {
524 else if (existsGoodDTSegX)
570 return muon.
isTrackerMuon() &&
isGoodMuon(muon,
TMLastStation,2,3,3,1E9,1E9,-3,-3,arbitrationType,
true,
false);
573 return muon.
isTrackerMuon() &&
isGoodMuon(muon,
TMLastStation,2,3,3,3,3,-3,-3,arbitrationType,
true,
false);
576 return muon.
isTrackerMuon() &&
isGoodMuon(muon,
TMOneStation,1,3,3,1E9,1E9,1E9,1E9,arbitrationType,
false,
false);
579 return muon.
isTrackerMuon() &&
isGoodMuon(muon,
TMOneStation,1,3,3,3,3,1E9,1E9,arbitrationType,
false,
false);
582 if (muon.
pt() < 8. && fabs(muon.
eta()) < 1.2)
583 return muon.
isTrackerMuon() &&
isGoodMuon(muon,
TMOneStation,1,3,3,1E9,1E9,1E9,1E9,arbitrationType,
false,
false);
585 return muon.
isTrackerMuon() &&
isGoodMuon(muon,
TMLastStation,2,3,3,1E9,1E9,-3,-3,arbitrationType,
false,
false);
588 if (muon.
pt() < 8. && fabs(muon.
eta()) < 1.2)
589 return muon.
isTrackerMuon() &&
isGoodMuon(muon,
TMOneStation,1,3,3,3,3,1E9,1E9,arbitrationType,
false,
false);
591 return muon.
isTrackerMuon() &&
isGoodMuon(muon,
TMLastStation,2,3,3,3,3,-3,-3,arbitrationType,
false,
false);
611 return muon.
isTrackerMuon() &&
isGoodMuon(muon,
TMLastStation,2,3,3,1E9,1E9,-3,-3,arbitrationType,
false,
true);
614 return muon.
isTrackerMuon() &&
isGoodMuon(muon,
TMLastStation,2,3,3,3,3,-3,-3,arbitrationType,
false,
true);
617 return muon.
isTrackerMuon() &&
isGoodMuon(muon,
TMOneStation,1,3,3,1E9,1E9,1E9,1E9,arbitrationType,
false,
true);
620 return muon.
isTrackerMuon() &&
isGoodMuon(muon,
TMOneStation,1,3,3,3,3,1E9,1E9,arbitrationType,
false,
true);
623 if (muon.
pt() < 8. && fabs(muon.
eta()) < 1.2)
624 return muon.
isTrackerMuon() &&
isGoodMuon(muon,
TMOneStation,1,3,3,1E9,1E9,1E9,1E9,arbitrationType,
false,
false);
626 return muon.
isTrackerMuon() &&
isGoodMuon(muon,
TMLastStation,2,3,3,1E9,1E9,-3,-3,arbitrationType,
true,
false);
629 if (muon.
pt() < 8. && fabs(muon.
eta()) < 1.2)
630 return muon.
isTrackerMuon() &&
isGoodMuon(muon,
TMOneStation,1,3,3,3,3,1E9,1E9,arbitrationType,
false,
false);
632 return muon.
isTrackerMuon() &&
isGoodMuon(muon,
TMLastStation,2,3,3,3,3,-3,-3,arbitrationType,
true,
false);
640 double pullX,
double pullY,
bool checkAdjacentChambers)
644 unsigned int betterMuon = ( muon1.
pt() > muon2.
pt() ? 1 : 2 );
645 for ( std::vector<reco::MuonChamberMatch>::const_iterator chamber1 = muon1.
matches().begin();
646 chamber1 != muon1.
matches().end(); ++chamber1 )
647 for ( std::vector<reco::MuonChamberMatch>::const_iterator chamber2 = muon2.
matches().begin();
648 chamber2 != muon2.
matches().end(); ++chamber2 )
655 if ( chamber1->id == chamber2->id ){
657 if ( fabs(chamber1->x-chamber2->x) <
658 pullX *
sqrt(chamber1->xErr*chamber1->xErr+chamber2->xErr*chamber2->xErr) )
660 if ( betterMuon == 1 )
664 if ( nMatches1==0 || nMatches2==0 )
return true;
667 if ( fabs(chamber1->y-chamber2->y) <
668 pullY *
sqrt(chamber1->yErr*chamber1->yErr+chamber2->yErr*chamber2->yErr) )
670 if ( betterMuon == 1 )
674 if ( nMatches1==0 || nMatches2==0 )
return true;
677 if ( ! checkAdjacentChambers )
continue;
685 if ( id1.
ring() != id2.
ring() )
continue;
693 if ( fabs(chamber1->edgeX) > chamber1->xErr*pullX )
continue;
694 if ( fabs(chamber2->edgeX) > chamber2->xErr*pullX )
continue;
695 if ( chamber1->x * chamber2->x < 0 ) {
696 if ( betterMuon == 1 )
700 if ( nMatches1==0 || nMatches2==0 )
return true;
float trackDistErr(int station, int muonSubdetId, ArbitrationType type=SegmentAndTrackArbitration) const
virtual TrackRef innerTrack() const
bool isTrackerMuon() const
bool isGlobalMuon() const
float trkKink
value of the kink algorithm applied to the inner track stub
bool isMatchesValid() const
float dY(int station, int muonSubdetId, ArbitrationType type=SegmentAndTrackArbitration) const
bool isStandAloneMuon() const
float trkRelChi2
chi2 value for the inner track stub with respect to the global track
virtual double eta() const
momentum pseudorapidity
float caloCompatibility(const reco::Muon &muon)
SelectionType
Selector type.
bool overlap(const reco::Muon &muon1, const reco::Muon &muon2, double pullX=1.0, double pullY=1.0, bool checkAdjacentChambers=false)
ArbitrationType
define arbitration schemes
MuonQuality combinedQuality() const
get energy deposition information
float pullDxDz(int station, int muonSubdetId, ArbitrationType type=SegmentAndTrackArbitration, bool includeSegmentError=true) const
float segmentCompatibility(const reco::Muon &muon, reco::Muon::ArbitrationType arbitrationType=reco::Muon::SegmentAndTrackArbitration)
bool isQualityValid() const
unsigned int stationMask(ArbitrationType type=SegmentAndTrackArbitration) const
virtual TrackRef outerTrack() const
reference to Track reconstructed in the muon detector only
float pullY(int station, int muonSubdetId, ArbitrationType type=SegmentAndTrackArbitration, bool includeSegmentError=true) const
float segmentX(int station, int muonSubdetId, ArbitrationType type=SegmentAndTrackArbitration) const
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 staRelChi2
chi2 value for the outer track stub with respect to the global track
SelectionType selectionTypeFromString(const std::string &label)
virtual double pt() const
transverse momentum
a lightweight "map" for selection type string label and enum value
unsigned int RequiredStationMask(const reco::Muon &muon, double maxChamberDist, double maxChamberDistPull, reco::Muon::ArbitrationType arbitrationType)
std::vector< MuonChamberMatch > & matches()
get muon matching information
float trackDist(int station, int muonSubdetId, ArbitrationType type=SegmentAndTrackArbitration) const
float dX(int station, int muonSubdetId, ArbitrationType type=SegmentAndTrackArbitration) const
float caloCompatibility() const
float pullDyDz(int station, int muonSubdetId, ArbitrationType type=SegmentAndTrackArbitration, bool includeSegmentError=true) const
virtual TrackRef globalTrack() const
reference to Track reconstructed in both tracked and muon detector
float pullX(int station, int muonSubdetId, ArbitrationType type=SegmentAndTrackArbitration, bool includeSegmentError=true) const