CMS 3D CMS Logo

MuonHitHelper.cc
Go to the documentation of this file.
2 
3 bool MuonHitHelper::isDT(unsigned int detId) {
4  return (DetId(detId)).det() == DetId::Muon &&
5  (DetId(detId)).subdetId() == MuonSubdetId::DT;
6 }
7 
8 bool MuonHitHelper::isGEM(unsigned int detId) {
9  return (DetId(detId)).det() == DetId::Muon &&
10  (DetId(detId)).subdetId() == MuonSubdetId::GEM;
11 }
12 
13 bool MuonHitHelper::isCSC(unsigned int detId) {
14  return (DetId(detId)).det() == DetId::Muon &&
15  (DetId(detId)).subdetId() == MuonSubdetId::CSC;
16 }
17 
18 bool MuonHitHelper::isRPC(unsigned int detId) {
19  return (DetId(detId)).det() == DetId::Muon &&
20  (DetId(detId)).subdetId() == MuonSubdetId::RPC;
21 }
22 
23 bool MuonHitHelper::isME0(unsigned int detId) {
24  return (DetId(detId)).det() == DetId::Muon &&
25  (DetId(detId)).subdetId() == MuonSubdetId::ME0;
26 }
27 
28 int MuonHitHelper::chamber(const DetId& id) {
29  if (id.det() != DetId::Detector::Muon) return -99;
30  int chamberN = 0;
31  switch (id.subdetId()) {
32  case MuonSubdetId::GEM:
33  chamberN = GEMDetId(id).chamber();
34  break;
35  case MuonSubdetId::RPC:
36  // works only for endcap!!
37  chamberN = RPCDetId(id).sector();
38  break;
39  case MuonSubdetId::CSC:
40  chamberN = CSCDetId(id).chamber();
41  break;
42  case MuonSubdetId::ME0:
43  chamberN = ME0DetId(id).chamber();
44  break;
45  case MuonSubdetId::DT:
46  chamberN = DTChamberId(id).sector();
47  break;
48  };
49  return chamberN;
50 }
51 
52 // return MuonType for a particular DetId
53 int MuonHitHelper::toGEMType(int st, int ri) {
54  if (st == 1) {
55  if (ri == 1) return GEM_ME11;
56  } else if (st == 2) {
57  if (ri == 1) return GEM_ME21;
58  }
59  return GEM_ALL;
60 }
61 
62 int MuonHitHelper::toRPCType(int re, int st, int ri) {
63  // endcap
64  if (std::abs(re) == 1) {
65  if (st == 1) {
66  if (ri == 2) return RPC_ME12;
67  if (ri == 3) return RPC_ME13;
68  } else if (st == 2) {
69  if (ri == 2) return RPC_ME22;
70  if (ri == 3) return RPC_ME23;
71  } else if (st == 3) {
72  if (ri == 1) return RPC_ME31;
73  if (ri == 2) return RPC_ME32;
74  if (ri == 3) return RPC_ME33;
75  } else if (st == 4) {
76  if (ri == 1) return RPC_ME41;
77  if (ri == 2) return RPC_ME42;
78  if (ri == 3) return RPC_ME43;
79  }
80  }
81  // Barrel
82  else {
83  if (ri == -2) {
84  if (st == 1) return RPC_MB21n;
85  if (st == 2) return RPC_MB22n;
86  if (st == 3) return RPC_MB23n;
87  if (st == 4) return RPC_MB24n;
88  } else if (ri == -1) {
89  if (st == 1) return RPC_MB11n;
90  if (st == 2) return RPC_MB12n;
91  if (st == 3) return RPC_MB13n;
92  if (st == 4) return RPC_MB14n;
93  } else if (ri == 0) {
94  if (st == 1) return RPC_MB01;
95  if (st == 2) return RPC_MB02;
96  if (st == 3) return RPC_MB03;
97  if (st == 4) return RPC_MB04;
98  } else if (ri == 1) {
99  if (st == 1) return RPC_MB11p;
100  if (st == 2) return RPC_MB12p;
101  if (st == 3) return RPC_MB13p;
102  if (st == 4) return RPC_MB14p;
103  } else if (ri == 2) {
104  if (st == 1) return RPC_MB21p;
105  if (st == 2) return RPC_MB22p;
106  if (st == 3) return RPC_MB23p;
107  if (st == 4) return RPC_MB24p;
108  }
109  }
110  return RPC_ALL;
111 }
112 
113 int MuonHitHelper::toDTType(int wh, int st) {
114  if (wh == -2) {
115  if (st == 1) return DT_MB21n;
116  if (st == 2) return DT_MB22n;
117  if (st == 3) return DT_MB23n;
118  if (st == 4) return DT_MB24n;
119  }
120  if (wh == -1) {
121  if (st == 1) return DT_MB11n;
122  if (st == 2) return DT_MB12n;
123  if (st == 3) return DT_MB13n;
124  if (st == 4) return DT_MB14n;
125  }
126  if (wh == 0) {
127  if (st == 1) return DT_MB01;
128  if (st == 2) return DT_MB02;
129  if (st == 3) return DT_MB03;
130  if (st == 4) return DT_MB04;
131  }
132  if (wh == 1) {
133  if (st == 1) return DT_MB11p;
134  if (st == 2) return DT_MB12p;
135  if (st == 3) return DT_MB13p;
136  if (st == 4) return DT_MB14p;
137  }
138  if (wh == 2) {
139  if (st == 1) return DT_MB21p;
140  if (st == 2) return DT_MB22p;
141  if (st == 3) return DT_MB23p;
142  if (st == 4) return DT_MB24p;
143  }
144  return DT_ALL;
145 }
146 
147 int MuonHitHelper::toCSCType(int st, int ri) {
148  if (st == 1) {
149  if (ri == 0) return CSC_ME11;
150  if (ri == 1) return CSC_ME1b;
151  if (ri == 2) return CSC_ME12;
152  if (ri == 3) return CSC_ME13;
153  if (ri == 4) return CSC_ME1a;
154  } else if (st == 2) {
155  if (ri == 1) return CSC_ME21;
156  if (ri == 2) return CSC_ME22;
157  } else if (st == 3) {
158  if (ri == 1) return CSC_ME31;
159  if (ri == 2) return CSC_ME32;
160  } else if (st == 4) {
161  if (ri == 1) return CSC_ME41;
162  if (ri == 2) return CSC_ME42;
163  }
164  return CSC_ALL;
165 }
static int toCSCType(int st, int ri)
static bool isDT(unsigned int detId)
check detid type
Definition: MuonHitHelper.cc:3
int chamber() const
Definition: CSCDetId.h:68
static constexpr int GEM
Definition: MuonSubdetId.h:15
static bool isCSC(unsigned int detId)
static bool isME0(unsigned int detId)
int chamber() const
Chamber id: it identifies a chamber in a ring it goes from 1 to 36.
Definition: GEMDetId.h:74
static int toGEMType(int st, int ri)
int chamber() const
Chamber id: it identifies a chamber in a ring it goes from 1 to 36.
Definition: ME0DetId.h:51
static int chamber(const DetId &id)
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
static constexpr int ME0
Definition: MuonSubdetId.h:16
static bool isRPC(unsigned int detId)
Definition: DetId.h:18
static constexpr int RPC
Definition: MuonSubdetId.h:14
static bool isGEM(unsigned int detId)
Definition: MuonHitHelper.cc:8
int sector() const
Sector id: the group of chambers at same phi (and increasing r)
Definition: RPCDetId.h:102
int sector() const
Definition: DTChamberId.h:61
static constexpr int DT
Definition: MuonSubdetId.h:12
static int toRPCType(int re, int st, int ri)
static int toDTType(int wh, int st)
static constexpr int CSC
Definition: MuonSubdetId.h:13