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