CMS 3D CMS Logo

/data/doxygen/doxygen-1.7.3/gen/CMSSW_4_2_8/src/DataFormats/MuonReco/src/Muon.cc

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