00001 #include "DataFormats/MuonReco/interface/Muon.h"
00002 #include "DataFormats/MuonDetId/interface/MuonSubdetId.h"
00003 #include "DataFormats/MuonReco/interface/MuonSelectors.h"
00004
00005 using namespace reco;
00006
00007 Muon::Muon( Charge q, const LorentzVector & p4, const Point & vtx ) :
00008 RecoCandidate( q, p4, vtx, -13 * q ) {
00009 energyValid_ = false;
00010 timeValid_ = false;
00011 matchesValid_ = false;
00012 isolationValid_ = false;
00013 caloCompatibility_ = -9999.;
00014 type_ = 0;
00015 }
00016
00017 Muon::Muon() {
00018 energyValid_ = false;
00019 timeValid_ = false;
00020 matchesValid_ = false;
00021 isolationValid_ = false;
00022 caloCompatibility_ = -9999.;
00023 type_ = 0;
00024 }
00025
00026 bool Muon::overlap( const Candidate & c ) const {
00027 const RecoCandidate * o = dynamic_cast<const RecoCandidate *>( & c );
00028 return ( o != 0 &&
00029 ( checkOverlap( track(), o->track() ) ||
00030 checkOverlap( standAloneMuon(), o->standAloneMuon() ) ||
00031 checkOverlap( combinedMuon(), o->combinedMuon() ) ||
00032 checkOverlap( standAloneMuon(), o->track() ) ||
00033 checkOverlap( combinedMuon(), o->track() ) )
00034 );
00035 }
00036
00037 Muon * Muon::clone() const {
00038 return new Muon( * this );
00039 }
00040
00041 TrackRef Muon::track() const
00042 {
00043 return track_;
00044 }
00045
00046 TrackRef Muon::standAloneMuon() const
00047 {
00048 return standAloneMuon_;
00049 }
00050
00051 TrackRef Muon::combinedMuon() const
00052 {
00053 return combinedMuon_;
00054 }
00055
00056 void Muon::setTrack( const TrackRef & t )
00057 {
00058 track_ = t;
00059 }
00060
00061 void Muon::setStandAlone( const TrackRef & t )
00062 {
00063 standAloneMuon_ = t;
00064 }
00065
00066 void Muon::setCombined( const TrackRef & t )
00067 {
00068 combinedMuon_ = t;
00069 }
00070
00071 int Muon::numberOfMatches( ArbitrationType type ) const
00072 {
00073 int matches(0);
00074 for( std::vector<MuonChamberMatch>::const_iterator chamberMatch = muMatches_.begin();
00075 chamberMatch != muMatches_.end(); chamberMatch++ )
00076 {
00077 if(chamberMatch->segmentMatches.empty()) continue;
00078 if(type == NoArbitration) {
00079 matches++;
00080 continue;
00081 }
00082
00083 for( std::vector<MuonSegmentMatch>::const_iterator segmentMatch = chamberMatch->segmentMatches.begin();
00084 segmentMatch != chamberMatch->segmentMatches.end(); segmentMatch++ )
00085 {
00086 if(type == SegmentArbitration)
00087 if(segmentMatch->isMask(MuonSegmentMatch::BestInChamberByDR)) {
00088 matches++;
00089 break;
00090 }
00091 if(type == SegmentAndTrackArbitration)
00092 if(segmentMatch->isMask(MuonSegmentMatch::BestInChamberByDR) &&
00093 segmentMatch->isMask(MuonSegmentMatch::BelongsToTrackByDR)) {
00094 matches++;
00095 break;
00096 }
00097 if(type > 1<<7)
00098 if(segmentMatch->isMask(type)) {
00099 matches++;
00100 break;
00101 }
00102 }
00103 }
00104
00105 return matches;
00106 }
00107
00108 unsigned int Muon::stationMask( ArbitrationType type ) const
00109 {
00110 unsigned int totMask(0);
00111 unsigned int curMask(0);
00112 for( std::vector<MuonChamberMatch>::const_iterator chamberMatch = muMatches_.begin();
00113 chamberMatch != muMatches_.end(); chamberMatch++ )
00114 {
00115 if(chamberMatch->segmentMatches.empty()) continue;
00116 if(type == NoArbitration) {
00117 curMask = 1<<(chamberMatch->station()-1)+4*(chamberMatch->detector()-1);
00118
00119 if(!(totMask & curMask))
00120 totMask += curMask;
00121 continue;
00122 }
00123
00124 for( std::vector<MuonSegmentMatch>::const_iterator segmentMatch = chamberMatch->segmentMatches.begin();
00125 segmentMatch != chamberMatch->segmentMatches.end(); segmentMatch++ )
00126 {
00127 if(type == SegmentArbitration)
00128 if(segmentMatch->isMask(MuonSegmentMatch::BestInStationByDR)) {
00129 curMask = 1<<(chamberMatch->station()-1)+4*(chamberMatch->detector()-1);
00130
00131 if(!(totMask & curMask))
00132 totMask += curMask;
00133 break;
00134 }
00135 if(type == SegmentAndTrackArbitration)
00136 if(segmentMatch->isMask(MuonSegmentMatch::BestInStationByDR) &&
00137 segmentMatch->isMask(MuonSegmentMatch::BelongsToTrackByDR)) {
00138 curMask = 1<<(chamberMatch->station()-1)+4*(chamberMatch->detector()-1);
00139
00140 if(!(totMask & curMask))
00141 totMask += curMask;
00142 break;
00143 }
00144 if(type > 1<<7)
00145 if(segmentMatch->isMask(type)) {
00146 curMask = 1<<(chamberMatch->station()-1)+4*(chamberMatch->detector()-1);
00147
00148 if(!(totMask & curMask))
00149 totMask += curMask;
00150 break;
00151 }
00152 }
00153 }
00154
00155 return totMask;
00156 }
00157
00158 unsigned int Muon::stationGapMaskDistance( float distanceCut ) const
00159 {
00160 unsigned int totMask(0);
00161 for( int stationIndex = 1; stationIndex < 5; stationIndex++ )
00162 {
00163 for( int detectorIndex = 1; detectorIndex < 4; detectorIndex++ )
00164 {
00165 unsigned int curMask(0);
00166 for( std::vector<MuonChamberMatch>::const_iterator chamberMatch = muMatches_.begin();
00167 chamberMatch != muMatches_.end(); chamberMatch++ )
00168 {
00169 if(!(chamberMatch->station()==stationIndex && chamberMatch->detector()==detectorIndex)) continue;
00170
00171 float edgeX = chamberMatch->edgeX;
00172 float edgeY = chamberMatch->edgeY;
00173 if(edgeX<0 && fabs(edgeX)>fabs(distanceCut) &&
00174 edgeY<0 && fabs(edgeY)>fabs(distanceCut))
00175 {
00176 curMask = 0;
00177 break;
00178 }
00179 if( ( fabs(edgeX) < fabs(distanceCut) && edgeY < fabs(distanceCut) ) ||
00180 ( fabs(edgeY) < fabs(distanceCut) && edgeX < fabs(distanceCut) ) )
00181 curMask = 1<<(stationIndex-1)+4*(detectorIndex-1);
00182 }
00183
00184 totMask += curMask;
00185 }
00186 }
00187
00188 return totMask;
00189 }
00190
00191 unsigned int Muon::stationGapMaskPull( float sigmaCut ) const
00192 {
00193 unsigned int totMask(0);
00194 for( int stationIndex = 1; stationIndex < 5; stationIndex++ )
00195 {
00196 for( int detectorIndex = 1; detectorIndex < 4; detectorIndex++ )
00197 {
00198 unsigned int curMask(0);
00199 for( std::vector<MuonChamberMatch>::const_iterator chamberMatch = muMatches_.begin();
00200 chamberMatch != muMatches_.end(); chamberMatch++ )
00201 {
00202 if(!(chamberMatch->station()==stationIndex && chamberMatch->detector()==detectorIndex)) continue;
00203
00204 float edgeX = chamberMatch->edgeX;
00205 float edgeY = chamberMatch->edgeY;
00206 float xErr = chamberMatch->xErr+0.000001;
00207 float yErr = chamberMatch->yErr+0.000001;
00208 if(edgeX<0 && fabs(edgeX/xErr)>fabs(sigmaCut) &&
00209 edgeY<0 && fabs(edgeY/yErr)>fabs(sigmaCut))
00210 {
00211 curMask = 0;
00212 break;
00213 }
00214 if( ( fabs(edgeX/xErr) < fabs(sigmaCut) && edgeY/yErr < fabs(sigmaCut) ) ||
00215 ( fabs(edgeY/yErr) < fabs(sigmaCut) && edgeX/xErr < fabs(sigmaCut) ) )
00216 curMask = 1<<(stationIndex-1)+4*(detectorIndex-1);
00217 }
00218
00219 totMask += curMask;
00220 }
00221 }
00222
00223 return totMask;
00224 }
00225
00226 int Muon::numberOfSegments( int station, int muonSubdetId, ArbitrationType type ) const
00227 {
00228 int segments(0);
00229 for( std::vector<MuonChamberMatch>::const_iterator chamberMatch = muMatches_.begin();
00230 chamberMatch != muMatches_.end(); chamberMatch++ )
00231 {
00232 if(chamberMatch->segmentMatches.empty()) continue;
00233 if(!(chamberMatch->station()==station && chamberMatch->detector()==muonSubdetId)) continue;
00234
00235 if(type == NoArbitration) {
00236 segments += chamberMatch->segmentMatches.size();
00237 continue;
00238 }
00239
00240 for( std::vector<MuonSegmentMatch>::const_iterator segmentMatch = chamberMatch->segmentMatches.begin();
00241 segmentMatch != chamberMatch->segmentMatches.end(); segmentMatch++ )
00242 {
00243 if(type == SegmentArbitration)
00244 if(segmentMatch->isMask(MuonSegmentMatch::BestInStationByDR)) {
00245 segments++;
00246 break;
00247 }
00248 if(type == SegmentAndTrackArbitration)
00249 if(segmentMatch->isMask(MuonSegmentMatch::BestInStationByDR) &&
00250 segmentMatch->isMask(MuonSegmentMatch::BelongsToTrackByDR)) {
00251 segments++;
00252 break;
00253 }
00254 if(type > 1<<7)
00255 if(segmentMatch->isMask(type)) {
00256 segments++;
00257 break;
00258 }
00259 }
00260 }
00261
00262 return segments;
00263 }
00264
00265 const std::vector<const MuonChamberMatch*> Muon::chambers( int station, int muonSubdetId ) const
00266 {
00267 std::vector<const MuonChamberMatch*> chambers;
00268 for(std::vector<MuonChamberMatch>::const_iterator chamberMatch = muMatches_.begin();
00269 chamberMatch != muMatches_.end(); chamberMatch++)
00270 if(chamberMatch->station()==station && chamberMatch->detector()==muonSubdetId)
00271 chambers.push_back(&(*chamberMatch));
00272 return chambers;
00273 }
00274
00275 std::pair<const MuonChamberMatch*,const MuonSegmentMatch*> Muon::pair( const std::vector<const MuonChamberMatch*> &chambers,
00276 ArbitrationType type ) const
00277 {
00278 MuonChamberMatch* m = 0;
00279 MuonSegmentMatch* s = 0;
00280 std::pair<const MuonChamberMatch*,const MuonSegmentMatch*> chamberSegmentPair(m,s);
00281
00282 if(chambers.empty()) return chamberSegmentPair;
00283 for( std::vector<const MuonChamberMatch*>::const_iterator chamberMatch = chambers.begin();
00284 chamberMatch != chambers.end(); chamberMatch++ )
00285 {
00286 if((*chamberMatch)->segmentMatches.empty()) continue;
00287 if(type == NoArbitration)
00288 return std::make_pair(*chamberMatch, &((*chamberMatch)->segmentMatches.front()));
00289
00290 for( std::vector<MuonSegmentMatch>::const_iterator segmentMatch = (*chamberMatch)->segmentMatches.begin();
00291 segmentMatch != (*chamberMatch)->segmentMatches.end(); segmentMatch++ )
00292 {
00293 if(type == SegmentArbitration)
00294 if(segmentMatch->isMask(MuonSegmentMatch::BestInStationByDR))
00295 return std::make_pair(*chamberMatch, &(*segmentMatch));
00296 if(type == SegmentAndTrackArbitration)
00297 if(segmentMatch->isMask(MuonSegmentMatch::BestInStationByDR) &&
00298 segmentMatch->isMask(MuonSegmentMatch::BelongsToTrackByDR))
00299 return std::make_pair(*chamberMatch, &(*segmentMatch));
00300 if(type > 1<<7)
00301 if(segmentMatch->isMask(type))
00302 return std::make_pair(*chamberMatch, &(*segmentMatch));
00303 }
00304 }
00305
00306 return chamberSegmentPair;
00307 }
00308
00309 float Muon::dX( int station, int muonSubdetId, ArbitrationType type ) const
00310 {
00311 std::pair<const MuonChamberMatch*,const MuonSegmentMatch*> chamberSegmentPair = pair(chambers(station,muonSubdetId),type);
00312 if(chamberSegmentPair.first==0 || chamberSegmentPair.second==0) return 999999;
00313 if(! chamberSegmentPair.second->hasPhi()) return 999999;
00314 return chamberSegmentPair.first->x-chamberSegmentPair.second->x;
00315 }
00316
00317 float Muon::dY( int station, int muonSubdetId, ArbitrationType type ) const
00318 {
00319 if(station==4 && muonSubdetId==MuonSubdetId::DT) return 999999;
00320 std::pair<const MuonChamberMatch*,const MuonSegmentMatch*> chamberSegmentPair = pair(chambers(station,muonSubdetId),type);
00321 if(chamberSegmentPair.first==0 || chamberSegmentPair.second==0) return 999999;
00322 if(! chamberSegmentPair.second->hasZed()) return 999999;
00323 return chamberSegmentPair.first->y-chamberSegmentPair.second->y;
00324 }
00325
00326 float Muon::dDxDz( int station, int muonSubdetId, ArbitrationType type ) const
00327 {
00328 std::pair<const MuonChamberMatch*,const MuonSegmentMatch*> chamberSegmentPair = pair(chambers(station,muonSubdetId),type);
00329 if(chamberSegmentPair.first==0 || chamberSegmentPair.second==0) return 999999;
00330 if(! chamberSegmentPair.second->hasPhi()) return 999999;
00331 return chamberSegmentPair.first->dXdZ-chamberSegmentPair.second->dXdZ;
00332 }
00333
00334 float Muon::dDyDz( int station, int muonSubdetId, ArbitrationType type ) const
00335 {
00336 if(station==4 && muonSubdetId==MuonSubdetId::DT) return 999999;
00337 std::pair<const MuonChamberMatch*,const MuonSegmentMatch*> chamberSegmentPair = pair(chambers(station,muonSubdetId),type);
00338 if(chamberSegmentPair.first==0 || chamberSegmentPair.second==0) return 999999;
00339 if(! chamberSegmentPair.second->hasZed()) return 999999;
00340 return chamberSegmentPair.first->dYdZ-chamberSegmentPair.second->dYdZ;
00341 }
00342
00343 float Muon::pullX( int station, int muonSubdetId, ArbitrationType type, bool includeSegmentError ) const
00344 {
00345 std::pair<const MuonChamberMatch*,const MuonSegmentMatch*> chamberSegmentPair = pair(chambers(station,muonSubdetId),type);
00346 if(chamberSegmentPair.first==0 || chamberSegmentPair.second==0) return 999999;
00347 if(! chamberSegmentPair.second->hasPhi()) return 999999;
00348 if(includeSegmentError)
00349 return (chamberSegmentPair.first->x-chamberSegmentPair.second->x)/sqrt(pow(chamberSegmentPair.first->xErr,2)+pow(chamberSegmentPair.second->xErr,2));
00350 return (chamberSegmentPair.first->x-chamberSegmentPair.second->x)/chamberSegmentPair.first->xErr;
00351 }
00352
00353 float Muon::pullY( int station, int muonSubdetId, ArbitrationType type, bool includeSegmentError) const
00354 {
00355 if(station==4 && muonSubdetId==MuonSubdetId::DT) return 999999;
00356 std::pair<const MuonChamberMatch*,const MuonSegmentMatch*> chamberSegmentPair = pair(chambers(station,muonSubdetId),type);
00357 if(chamberSegmentPair.first==0 || chamberSegmentPair.second==0) return 999999;
00358 if(! chamberSegmentPair.second->hasZed()) return 999999;
00359 if(includeSegmentError)
00360 return (chamberSegmentPair.first->y-chamberSegmentPair.second->y)/sqrt(pow(chamberSegmentPair.first->yErr,2)+pow(chamberSegmentPair.second->yErr,2));
00361 return (chamberSegmentPair.first->y-chamberSegmentPair.second->y)/chamberSegmentPair.first->yErr;
00362 }
00363
00364 float Muon::pullDxDz( int station, int muonSubdetId, ArbitrationType type, bool includeSegmentError ) const
00365 {
00366 std::pair<const MuonChamberMatch*,const MuonSegmentMatch*> chamberSegmentPair = pair(chambers(station,muonSubdetId),type);
00367 if(chamberSegmentPair.first==0 || chamberSegmentPair.second==0) return 999999;
00368 if(! chamberSegmentPair.second->hasPhi()) return 999999;
00369 if(includeSegmentError)
00370 return (chamberSegmentPair.first->dXdZ-chamberSegmentPair.second->dXdZ)/sqrt(pow(chamberSegmentPair.first->dXdZErr,2)+pow(chamberSegmentPair.second->dXdZErr,2));
00371 return (chamberSegmentPair.first->dXdZ-chamberSegmentPair.second->dXdZ)/chamberSegmentPair.first->dXdZErr;
00372 }
00373
00374 float Muon::pullDyDz( int station, int muonSubdetId, ArbitrationType type, bool includeSegmentError ) const
00375 {
00376 if(station==4 && muonSubdetId==MuonSubdetId::DT) return 999999;
00377 std::pair<const MuonChamberMatch*,const MuonSegmentMatch*> chamberSegmentPair = pair(chambers(station,muonSubdetId),type);
00378 if(chamberSegmentPair.first==0 || chamberSegmentPair.second==0) return 999999;
00379 if(! chamberSegmentPair.second->hasZed()) return 999999;
00380 if(includeSegmentError)
00381 return (chamberSegmentPair.first->dYdZ-chamberSegmentPair.second->dYdZ)/sqrt(pow(chamberSegmentPair.first->dYdZErr,2)+pow(chamberSegmentPair.second->dYdZErr,2));
00382 return (chamberSegmentPair.first->dYdZ-chamberSegmentPair.second->dYdZ)/chamberSegmentPair.first->dYdZErr;
00383 }
00384
00385 float Muon::segmentX( int station, int muonSubdetId, ArbitrationType type ) const
00386 {
00387 std::pair<const MuonChamberMatch*,const MuonSegmentMatch*> chamberSegmentPair = pair(chambers(station,muonSubdetId),type);
00388 if(chamberSegmentPair.first==0 || chamberSegmentPair.second==0) return 999999;
00389 if(! chamberSegmentPair.second->hasPhi()) return 999999;
00390 return chamberSegmentPair.second->x;
00391 }
00392
00393 float Muon::segmentY( int station, int muonSubdetId, ArbitrationType type ) const
00394 {
00395 if(station==4 && muonSubdetId==MuonSubdetId::DT) return 999999;
00396 std::pair<const MuonChamberMatch*,const MuonSegmentMatch*> chamberSegmentPair = pair(chambers(station,muonSubdetId),type);
00397 if(chamberSegmentPair.first==0 || chamberSegmentPair.second==0) return 999999;
00398 if(! chamberSegmentPair.second->hasZed()) return 999999;
00399 return chamberSegmentPair.second->y;
00400 }
00401
00402 float Muon::segmentDxDz( int station, int muonSubdetId, ArbitrationType type ) const
00403 {
00404 std::pair<const MuonChamberMatch*,const MuonSegmentMatch*> chamberSegmentPair = pair(chambers(station,muonSubdetId),type);
00405 if(chamberSegmentPair.first==0 || chamberSegmentPair.second==0) return 999999;
00406 if(! chamberSegmentPair.second->hasPhi()) return 999999;
00407 return chamberSegmentPair.second->dXdZ;
00408 }
00409
00410 float Muon::segmentDyDz( int station, int muonSubdetId, ArbitrationType type ) const
00411 {
00412 if(station==4 && muonSubdetId==MuonSubdetId::DT) return 999999;
00413 std::pair<const MuonChamberMatch*,const MuonSegmentMatch*> chamberSegmentPair = pair(chambers(station,muonSubdetId),type);
00414 if(chamberSegmentPair.first==0 || chamberSegmentPair.second==0) return 999999;
00415 if(! chamberSegmentPair.second->hasZed()) return 999999;
00416 return chamberSegmentPair.second->dYdZ;
00417 }
00418
00419 float Muon::segmentXErr( int station, int muonSubdetId, ArbitrationType type ) const
00420 {
00421 std::pair<const MuonChamberMatch*,const MuonSegmentMatch*> chamberSegmentPair = pair(chambers(station,muonSubdetId),type);
00422 if(chamberSegmentPair.first==0 || chamberSegmentPair.second==0) return 999999;
00423 if(! chamberSegmentPair.second->hasPhi()) return 999999;
00424 return chamberSegmentPair.second->xErr;
00425 }
00426
00427 float Muon::segmentYErr( int station, int muonSubdetId, ArbitrationType type ) const
00428 {
00429 if(station==4 && muonSubdetId==MuonSubdetId::DT) return 999999;
00430 std::pair<const MuonChamberMatch*,const MuonSegmentMatch*> chamberSegmentPair = pair(chambers(station,muonSubdetId),type);
00431 if(chamberSegmentPair.first==0 || chamberSegmentPair.second==0) return 999999;
00432 if(! chamberSegmentPair.second->hasZed()) return 999999;
00433 return chamberSegmentPair.second->yErr;
00434 }
00435
00436 float Muon::segmentDxDzErr( int station, int muonSubdetId, ArbitrationType type ) const
00437 {
00438 std::pair<const MuonChamberMatch*,const MuonSegmentMatch*> chamberSegmentPair = pair(chambers(station,muonSubdetId),type);
00439 if(chamberSegmentPair.first==0 || chamberSegmentPair.second==0) return 999999;
00440 if(! chamberSegmentPair.second->hasPhi()) return 999999;
00441 return chamberSegmentPair.second->dXdZErr;
00442 }
00443
00444 float Muon::segmentDyDzErr( int station, int muonSubdetId, ArbitrationType type ) const
00445 {
00446 if(station==4 && muonSubdetId==MuonSubdetId::DT) return 999999;
00447 std::pair<const MuonChamberMatch*,const MuonSegmentMatch*> chamberSegmentPair = pair(chambers(station,muonSubdetId),type);
00448 if(chamberSegmentPair.first==0 || chamberSegmentPair.second==0) return 999999;
00449 if(! chamberSegmentPair.second->hasZed()) return 999999;
00450 return chamberSegmentPair.second->dYdZErr;
00451 }
00452
00453 float Muon::trackEdgeX( int station, int muonSubdetId, ArbitrationType type ) const
00454 {
00455 const std::vector<const MuonChamberMatch*> muonChambers = chambers(station, muonSubdetId);
00456 if(muonChambers.empty()) return 999999;
00457
00458 std::pair<const MuonChamberMatch*,const MuonSegmentMatch*> chamberSegmentPair = pair(muonChambers,type);
00459 if(chamberSegmentPair.first==0 || chamberSegmentPair.second==0) {
00460 float dist = 999999;
00461 float supVar = 999999;
00462 for(std::vector<const MuonChamberMatch*>::const_iterator muonChamber = muonChambers.begin();
00463 muonChamber != muonChambers.end(); ++muonChamber) {
00464 float currDist = (*muonChamber)->dist();
00465 if(currDist<dist) {
00466 dist = currDist;
00467 supVar = (*muonChamber)->edgeX;
00468 }
00469 }
00470 return supVar;
00471 } else return chamberSegmentPair.first->edgeX;
00472 }
00473
00474 float Muon::trackEdgeY( int station, int muonSubdetId, ArbitrationType type ) const
00475 {
00476 const std::vector<const MuonChamberMatch*> muonChambers = chambers(station, muonSubdetId);
00477 if(muonChambers.empty()) return 999999;
00478
00479 std::pair<const MuonChamberMatch*,const MuonSegmentMatch*> chamberSegmentPair = pair(muonChambers,type);
00480 if(chamberSegmentPair.first==0 || chamberSegmentPair.second==0) {
00481 float dist = 999999;
00482 float supVar = 999999;
00483 for(std::vector<const MuonChamberMatch*>::const_iterator muonChamber = muonChambers.begin();
00484 muonChamber != muonChambers.end(); ++muonChamber) {
00485 float currDist = (*muonChamber)->dist();
00486 if(currDist<dist) {
00487 dist = currDist;
00488 supVar = (*muonChamber)->edgeY;
00489 }
00490 }
00491 return supVar;
00492 } else return chamberSegmentPair.first->edgeY;
00493 }
00494
00495 float Muon::trackX( int station, int muonSubdetId, ArbitrationType type ) const
00496 {
00497 const std::vector<const MuonChamberMatch*> muonChambers = chambers(station, muonSubdetId);
00498 if(muonChambers.empty()) return 999999;
00499
00500 std::pair<const MuonChamberMatch*,const MuonSegmentMatch*> chamberSegmentPair = pair(muonChambers,type);
00501 if(chamberSegmentPair.first==0 || chamberSegmentPair.second==0) {
00502 float dist = 999999;
00503 float supVar = 999999;
00504 for(std::vector<const MuonChamberMatch*>::const_iterator muonChamber = muonChambers.begin();
00505 muonChamber != muonChambers.end(); ++muonChamber) {
00506 float currDist = (*muonChamber)->dist();
00507 if(currDist<dist) {
00508 dist = currDist;
00509 supVar = (*muonChamber)->x;
00510 }
00511 }
00512 return supVar;
00513 } else return chamberSegmentPair.first->x;
00514 }
00515
00516 float Muon::trackY( int station, int muonSubdetId, ArbitrationType type ) const
00517 {
00518 const std::vector<const MuonChamberMatch*> muonChambers = chambers(station, muonSubdetId);
00519 if(muonChambers.empty()) return 999999;
00520
00521 std::pair<const MuonChamberMatch*,const MuonSegmentMatch*> chamberSegmentPair = pair(muonChambers,type);
00522 if(chamberSegmentPair.first==0 || chamberSegmentPair.second==0) {
00523 float dist = 999999;
00524 float supVar = 999999;
00525 for(std::vector<const MuonChamberMatch*>::const_iterator muonChamber = muonChambers.begin();
00526 muonChamber != muonChambers.end(); ++muonChamber) {
00527 float currDist = (*muonChamber)->dist();
00528 if(currDist<dist) {
00529 dist = currDist;
00530 supVar = (*muonChamber)->y;
00531 }
00532 }
00533 return supVar;
00534 } else return chamberSegmentPair.first->y;
00535 }
00536
00537 float Muon::trackDxDz( int station, int muonSubdetId, ArbitrationType type ) const
00538 {
00539 const std::vector<const MuonChamberMatch*> muonChambers = chambers(station, muonSubdetId);
00540 if(muonChambers.empty()) return 999999;
00541
00542 std::pair<const MuonChamberMatch*,const MuonSegmentMatch*> chamberSegmentPair = pair(muonChambers,type);
00543 if(chamberSegmentPair.first==0 || chamberSegmentPair.second==0) {
00544 float dist = 999999;
00545 float supVar = 999999;
00546 for(std::vector<const MuonChamberMatch*>::const_iterator muonChamber = muonChambers.begin();
00547 muonChamber != muonChambers.end(); ++muonChamber) {
00548 float currDist = (*muonChamber)->dist();
00549 if(currDist<dist) {
00550 dist = currDist;
00551 supVar = (*muonChamber)->dXdZ;
00552 }
00553 }
00554 return supVar;
00555 } else return chamberSegmentPair.first->dXdZ;
00556 }
00557
00558 float Muon::trackDyDz( int station, int muonSubdetId, ArbitrationType type ) const
00559 {
00560 const std::vector<const MuonChamberMatch*> muonChambers = chambers(station, muonSubdetId);
00561 if(muonChambers.empty()) return 999999;
00562
00563 std::pair<const MuonChamberMatch*,const MuonSegmentMatch*> chamberSegmentPair = pair(muonChambers,type);
00564 if(chamberSegmentPair.first==0 || chamberSegmentPair.second==0) {
00565 float dist = 999999;
00566 float supVar = 999999;
00567 for(std::vector<const MuonChamberMatch*>::const_iterator muonChamber = muonChambers.begin();
00568 muonChamber != muonChambers.end(); ++muonChamber) {
00569 float currDist = (*muonChamber)->dist();
00570 if(currDist<dist) {
00571 dist = currDist;
00572 supVar = (*muonChamber)->dYdZ;
00573 }
00574 }
00575 return supVar;
00576 } else return chamberSegmentPair.first->dYdZ;
00577 }
00578
00579 float Muon::trackXErr( int station, int muonSubdetId, ArbitrationType type ) const
00580 {
00581 const std::vector<const MuonChamberMatch*> muonChambers = chambers(station, muonSubdetId);
00582 if(muonChambers.empty()) return 999999;
00583
00584 std::pair<const MuonChamberMatch*,const MuonSegmentMatch*> chamberSegmentPair = pair(muonChambers,type);
00585 if(chamberSegmentPair.first==0 || chamberSegmentPair.second==0) {
00586 float dist = 999999;
00587 float supVar = 999999;
00588 for(std::vector<const MuonChamberMatch*>::const_iterator muonChamber = muonChambers.begin();
00589 muonChamber != muonChambers.end(); ++muonChamber) {
00590 float currDist = (*muonChamber)->dist();
00591 if(currDist<dist) {
00592 dist = currDist;
00593 supVar = (*muonChamber)->xErr;
00594 }
00595 }
00596 return supVar;
00597 } else return chamberSegmentPair.first->xErr;
00598 }
00599
00600 float Muon::trackYErr( int station, int muonSubdetId, ArbitrationType type ) const
00601 {
00602 const std::vector<const MuonChamberMatch*> muonChambers = chambers(station, muonSubdetId);
00603 if(muonChambers.empty()) return 999999;
00604
00605 std::pair<const MuonChamberMatch*,const MuonSegmentMatch*> chamberSegmentPair = pair(muonChambers,type);
00606 if(chamberSegmentPair.first==0 || chamberSegmentPair.second==0) {
00607 float dist = 999999;
00608 float supVar = 999999;
00609 for(std::vector<const MuonChamberMatch*>::const_iterator muonChamber = muonChambers.begin();
00610 muonChamber != muonChambers.end(); ++muonChamber) {
00611 float currDist = (*muonChamber)->dist();
00612 if(currDist<dist) {
00613 dist = currDist;
00614 supVar = (*muonChamber)->yErr;
00615 }
00616 }
00617 return supVar;
00618 } else return chamberSegmentPair.first->yErr;
00619 }
00620
00621 float Muon::trackDxDzErr( int station, int muonSubdetId, ArbitrationType type ) const
00622 {
00623 const std::vector<const MuonChamberMatch*> muonChambers = chambers(station, muonSubdetId);
00624 if(muonChambers.empty()) return 999999;
00625
00626 std::pair<const MuonChamberMatch*,const MuonSegmentMatch*> chamberSegmentPair = pair(muonChambers,type);
00627 if(chamberSegmentPair.first==0 || chamberSegmentPair.second==0) {
00628 float dist = 999999;
00629 float supVar = 999999;
00630 for(std::vector<const MuonChamberMatch*>::const_iterator muonChamber = muonChambers.begin();
00631 muonChamber != muonChambers.end(); ++muonChamber) {
00632 float currDist = (*muonChamber)->dist();
00633 if(currDist<dist) {
00634 dist = currDist;
00635 supVar = (*muonChamber)->dXdZErr;
00636 }
00637 }
00638 return supVar;
00639 } else return chamberSegmentPair.first->dXdZErr;
00640 }
00641
00642 float Muon::trackDyDzErr( int station, int muonSubdetId, ArbitrationType type ) const
00643 {
00644 const std::vector<const MuonChamberMatch*> muonChambers = chambers(station, muonSubdetId);
00645 if(muonChambers.empty()) return 999999;
00646
00647 std::pair<const MuonChamberMatch*,const MuonSegmentMatch*> chamberSegmentPair = pair(muonChambers,type);
00648 if(chamberSegmentPair.first==0 || chamberSegmentPair.second==0) {
00649 float dist = 999999;
00650 float supVar = 999999;
00651 for(std::vector<const MuonChamberMatch*>::const_iterator muonChamber = muonChambers.begin();
00652 muonChamber != muonChambers.end(); ++muonChamber) {
00653 float currDist = (*muonChamber)->dist();
00654 if(currDist<dist) {
00655 dist = currDist;
00656 supVar = (*muonChamber)->dYdZErr;
00657 }
00658 }
00659 return supVar;
00660 } else return chamberSegmentPair.first->dYdZErr;
00661 }
00662
00663 float Muon::trackDist( int station, int muonSubdetId, ArbitrationType type ) const
00664 {
00665 const std::vector<const MuonChamberMatch*> muonChambers = chambers(station, muonSubdetId);
00666 if(muonChambers.empty()) return 999999;
00667
00668 std::pair<const MuonChamberMatch*,const MuonSegmentMatch*> chamberSegmentPair = pair(muonChambers,type);
00669 if(chamberSegmentPair.first==0 || chamberSegmentPair.second==0) {
00670 float dist = 999999;
00671 for(std::vector<const MuonChamberMatch*>::const_iterator muonChamber = muonChambers.begin();
00672 muonChamber != muonChambers.end(); ++muonChamber) {
00673 float currDist = (*muonChamber)->dist();
00674 if(currDist<dist) dist = currDist;
00675 }
00676 return dist;
00677 } else return chamberSegmentPair.first->dist();
00678 }
00679
00680 float Muon::trackDistErr( int station, int muonSubdetId, ArbitrationType type ) const
00681 {
00682 const std::vector<const MuonChamberMatch*> muonChambers = chambers(station, muonSubdetId);
00683 if(muonChambers.empty()) return 999999;
00684
00685 std::pair<const MuonChamberMatch*,const MuonSegmentMatch*> chamberSegmentPair = pair(muonChambers,type);
00686 if(chamberSegmentPair.first==0 || chamberSegmentPair.second==0) {
00687 float dist = 999999;
00688 float supVar = 999999;
00689 for(std::vector<const MuonChamberMatch*>::const_iterator muonChamber = muonChambers.begin();
00690 muonChamber != muonChambers.end(); ++muonChamber) {
00691 float currDist = (*muonChamber)->dist();
00692 if(currDist<dist) {
00693 dist = currDist;
00694 supVar = (*muonChamber)->distErr();
00695 }
00696 }
00697 return supVar;
00698 } else return chamberSegmentPair.first->distErr();
00699 }
00700
00701 void Muon::setIsolation( const MuonIsolation& isoR03, const MuonIsolation& isoR05 )
00702 {
00703 isolationR03_ = isoR03;
00704 isolationR05_ = isoR05;
00705 isolationValid_ = true;
00706 }
00707
00708 float Muon::segmentCompatibility() const
00709 {
00710 return muon::segmentCompatibility( *this );
00711 }
00712
00713 bool Muon::isGood( SelectionType type ) const
00714 {
00715 return muon::isGoodMuon( *this, type );
00716 }
00717