Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 14:33:19

0001 #include "Validation/MuonHits/interface/MuonHitHelper.h"
0002 
0003 bool MuonHitHelper::isDT(unsigned int detId) {
0004   return (DetId(detId)).det() == DetId::Muon && (DetId(detId)).subdetId() == MuonSubdetId::DT;
0005 }
0006 
0007 bool MuonHitHelper::isGEM(unsigned int detId) {
0008   return (DetId(detId)).det() == DetId::Muon && (DetId(detId)).subdetId() == MuonSubdetId::GEM;
0009 }
0010 
0011 bool MuonHitHelper::isCSC(unsigned int detId) {
0012   return (DetId(detId)).det() == DetId::Muon && (DetId(detId)).subdetId() == MuonSubdetId::CSC;
0013 }
0014 
0015 bool MuonHitHelper::isRPC(unsigned int detId) {
0016   return (DetId(detId)).det() == DetId::Muon && (DetId(detId)).subdetId() == MuonSubdetId::RPC;
0017 }
0018 
0019 bool MuonHitHelper::isME0(unsigned int detId) {
0020   return (DetId(detId)).det() == DetId::Muon && (DetId(detId)).subdetId() == MuonSubdetId::ME0;
0021 }
0022 
0023 int MuonHitHelper::chamber(const DetId& id) {
0024   if (id.det() != DetId::Detector::Muon)
0025     return -99;
0026   int chamberN = 0;
0027   switch (id.subdetId()) {
0028     case MuonSubdetId::GEM:
0029       chamberN = GEMDetId(id).chamber();
0030       break;
0031     case MuonSubdetId::RPC:
0032       // works only for endcap!!
0033       chamberN = RPCDetId(id).sector();
0034       break;
0035     case MuonSubdetId::CSC:
0036       chamberN = CSCDetId(id).chamber();
0037       break;
0038     case MuonSubdetId::ME0:
0039       chamberN = ME0DetId(id).chamber();
0040       break;
0041     case MuonSubdetId::DT:
0042       chamberN = DTChamberId(id).sector();
0043       break;
0044   };
0045   return chamberN;
0046 }
0047 
0048 // return MuonType for a particular DetId
0049 int MuonHitHelper::toGEMType(int st, int ri) {
0050   if (st == 1) {
0051     if (ri == 1)
0052       return GEM_ME11;
0053   } else if (st == 2) {
0054     if (ri == 1)
0055       return GEM_ME21;
0056   }
0057   return GEM_ALL;
0058 }
0059 
0060 int MuonHitHelper::toRPCType(int re, int st, int ri) {
0061   // endcap
0062   if (std::abs(re) == 1) {
0063     if (st == 1) {
0064       if (ri == 2)
0065         return RPC_ME12;
0066       if (ri == 3)
0067         return RPC_ME13;
0068     } else if (st == 2) {
0069       if (ri == 2)
0070         return RPC_ME22;
0071       if (ri == 3)
0072         return RPC_ME23;
0073     } else if (st == 3) {
0074       if (ri == 1)
0075         return RPC_ME31;
0076       if (ri == 2)
0077         return RPC_ME32;
0078       if (ri == 3)
0079         return RPC_ME33;
0080     } else if (st == 4) {
0081       if (ri == 1)
0082         return RPC_ME41;
0083       if (ri == 2)
0084         return RPC_ME42;
0085       if (ri == 3)
0086         return RPC_ME43;
0087     }
0088   }
0089   // Barrel
0090   else {
0091     if (ri == -2) {
0092       if (st == 1)
0093         return RPC_MB21n;
0094       if (st == 2)
0095         return RPC_MB22n;
0096       if (st == 3)
0097         return RPC_MB23n;
0098       if (st == 4)
0099         return RPC_MB24n;
0100     } else if (ri == -1) {
0101       if (st == 1)
0102         return RPC_MB11n;
0103       if (st == 2)
0104         return RPC_MB12n;
0105       if (st == 3)
0106         return RPC_MB13n;
0107       if (st == 4)
0108         return RPC_MB14n;
0109     } else if (ri == 0) {
0110       if (st == 1)
0111         return RPC_MB01;
0112       if (st == 2)
0113         return RPC_MB02;
0114       if (st == 3)
0115         return RPC_MB03;
0116       if (st == 4)
0117         return RPC_MB04;
0118     } else if (ri == 1) {
0119       if (st == 1)
0120         return RPC_MB11p;
0121       if (st == 2)
0122         return RPC_MB12p;
0123       if (st == 3)
0124         return RPC_MB13p;
0125       if (st == 4)
0126         return RPC_MB14p;
0127     } else if (ri == 2) {
0128       if (st == 1)
0129         return RPC_MB21p;
0130       if (st == 2)
0131         return RPC_MB22p;
0132       if (st == 3)
0133         return RPC_MB23p;
0134       if (st == 4)
0135         return RPC_MB24p;
0136     }
0137   }
0138   return RPC_ALL;
0139 }
0140 
0141 int MuonHitHelper::toDTType(int wh, int st) {
0142   if (wh == -2) {
0143     if (st == 1)
0144       return DT_MB21n;
0145     if (st == 2)
0146       return DT_MB22n;
0147     if (st == 3)
0148       return DT_MB23n;
0149     if (st == 4)
0150       return DT_MB24n;
0151   }
0152   if (wh == -1) {
0153     if (st == 1)
0154       return DT_MB11n;
0155     if (st == 2)
0156       return DT_MB12n;
0157     if (st == 3)
0158       return DT_MB13n;
0159     if (st == 4)
0160       return DT_MB14n;
0161   }
0162   if (wh == 0) {
0163     if (st == 1)
0164       return DT_MB01;
0165     if (st == 2)
0166       return DT_MB02;
0167     if (st == 3)
0168       return DT_MB03;
0169     if (st == 4)
0170       return DT_MB04;
0171   }
0172   if (wh == 1) {
0173     if (st == 1)
0174       return DT_MB11p;
0175     if (st == 2)
0176       return DT_MB12p;
0177     if (st == 3)
0178       return DT_MB13p;
0179     if (st == 4)
0180       return DT_MB14p;
0181   }
0182   if (wh == 2) {
0183     if (st == 1)
0184       return DT_MB21p;
0185     if (st == 2)
0186       return DT_MB22p;
0187     if (st == 3)
0188       return DT_MB23p;
0189     if (st == 4)
0190       return DT_MB24p;
0191   }
0192   return DT_ALL;
0193 }
0194 
0195 int MuonHitHelper::toCSCType(int st, int ri) {
0196   if (st == 1) {
0197     if (ri == 0)
0198       return CSC_ME11;
0199     if (ri == 1)
0200       return CSC_ME1b;
0201     if (ri == 2)
0202       return CSC_ME12;
0203     if (ri == 3)
0204       return CSC_ME13;
0205     if (ri == 4)
0206       return CSC_ME1a;
0207   } else if (st == 2) {
0208     if (ri == 1)
0209       return CSC_ME21;
0210     if (ri == 2)
0211       return CSC_ME22;
0212   } else if (st == 3) {
0213     if (ri == 1)
0214       return CSC_ME31;
0215     if (ri == 2)
0216       return CSC_ME32;
0217   } else if (st == 4) {
0218     if (ri == 1)
0219       return CSC_ME41;
0220     if (ri == 2)
0221       return CSC_ME42;
0222   }
0223   return CSC_ALL;
0224 }