Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:54:11

0001 #include "DataFormats/MuonDetId/interface/DTChamberId.h"
0002 #include <DataFormats/MuonDetId/interface/MuonSubdetId.h>
0003 #include "DataFormats/MuonDetId/interface/CSCDetId.h"
0004 #include "DataFormats/MuonDetId/interface/RPCDetId.h"
0005 #include "DataFormats/MuonDetId/interface/GEMDetId.h"
0006 #include "DataFormats/MuonDetId/interface/ME0DetId.h"
0007 #include "DataFormats/MuonReco/interface/MuonChamberMatch.h"
0008 #include <cmath>
0009 using namespace reco;
0010 
0011 int MuonChamberMatch::station() const {
0012   if (detector() == MuonSubdetId::DT) {  // DT
0013     DTChamberId segId(id.rawId());
0014     return segId.station();
0015   }
0016   if (detector() == MuonSubdetId::CSC) {  // CSC
0017     CSCDetId segId(id.rawId());
0018     return segId.station();
0019   }
0020   if (detector() == MuonSubdetId::RPC) {  //RPC
0021     RPCDetId segId(id.rawId());
0022     return segId.station();
0023   }
0024   if (detector() == MuonSubdetId::GEM) {  //GEM
0025     GEMDetId segId(id.rawId());
0026     return segId.station();
0027   }
0028   if (detector() == MuonSubdetId::ME0) {  //ME0
0029     ME0DetId segId(id.rawId());
0030     return segId.station();
0031   }
0032   return -1;  // is this appropriate? fix this
0033 }
0034 
0035 std::pair<float, float> MuonChamberMatch::getDistancePair(float edgeX, float edgeY, float xErr, float yErr) const {
0036   if (edgeX > 9E5 && edgeY > 9E5 && xErr > 9E5 && yErr > 9E5)  // there is no track
0037     return std::make_pair(999999, 999999);
0038 
0039   float distance = 999999;
0040   float error = 999999;
0041 
0042   if (edgeX < 0 && edgeY < 0) {
0043     if (edgeX < edgeY) {
0044       distance = edgeY;
0045       error = yErr;
0046     } else {
0047       distance = edgeX;
0048       error = xErr;
0049     }
0050   }
0051   if (edgeX < 0 && edgeY > 0) {
0052     distance = edgeY;
0053     error = yErr;
0054   }
0055   if (edgeX > 0 && edgeY < 0) {
0056     distance = edgeX;
0057     error = xErr;
0058   }
0059   if (edgeX > 0 && edgeY > 0) {
0060     distance = sqrt(edgeX * edgeX + edgeY * edgeY);
0061     error = distance ? sqrt(edgeX * edgeX * xErr * xErr + edgeY * edgeY * yErr * yErr) / fabs(distance) : 0;
0062   }
0063 
0064   return std::make_pair(distance, error);
0065 }