CMS 3D CMS Logo

TrackTools.h
Go to the documentation of this file.
1 #ifndef L1TMuonEndCap_TrackTools_h
2 #define L1TMuonEndCap_TrackTools_h
3 
4 #include <cmath>
5 
8 
9 namespace emtf {
10 
11  // Please refers to DN-2015/017 for uGMT conventions
12 
13  int calc_ring(int station, int csc_ID, int strip);
14 
15  int calc_chamber(int station, int sector, int subsector, int ring, int csc_ID);
16 
17  int calc_uGMT_chamber(int csc_ID, int subsector, int neighbor, int station);
18 
19  // ___________________________________________________________________________
20  // coordinate ranges: phi[-180, 180] or [-pi, pi], theta[0, 90] or [0, pi/2]
21  inline double range_phi_deg(double deg) {
22  while (deg < -180.) deg += 360.;
23  while (deg >= +180.) deg -= 360.;
24  return deg;
25  }
26 
27  inline double range_phi_rad(double rad) {
28  while (rad < -M_PI) rad += 2.*M_PI;
29  while (rad >= +M_PI) rad -= 2.*M_PI;
30  return rad;
31  }
32 
33  inline double range_theta_deg(double deg) {
34  deg = fabs(deg);
35  while (deg >= 180.) deg -= 180.;
36  if (deg >= 180./2.) deg = 180. - deg;
37  return deg;
38  }
39 
40  inline double range_theta_rad(double rad) {
41  rad = fabs(rad);
42  while (rad >= M_PI) rad -= M_PI;
43  if (rad >= M_PI/2.) rad = M_PI - rad;
44  return rad;
45  }
46 
47  // ___________________________________________________________________________
48  // radians, degrees
49  inline double deg_to_rad(double deg) {
50  constexpr double factor = M_PI/180.;
51  return deg * factor;
52  }
53 
54  inline double rad_to_deg(double rad) {
55  constexpr double factor = 180./M_PI;
56  return rad * factor;
57  }
58 
59  // ___________________________________________________________________________
60  // pt
61  inline double calc_pt(int bits) {
62  double pt = static_cast<double>(bits);
63  pt = 0.5 * (pt - 1);
64  return pt;
65  }
66 
67  inline int calc_pt_GMT(double val) {
68  val = (val * 2) + 1;
69  int gmt_pt = static_cast<int>(std::round(val));
70  gmt_pt = (gmt_pt > 511) ? 511 : gmt_pt;
71  return gmt_pt;
72  }
73 
74  // ___________________________________________________________________________
75  // eta
76  inline double calc_eta(int bits) {
77  double eta = static_cast<double>(bits);
78  eta *= 0.010875;
79  return eta;
80  }
81 
82  //inline double calc_eta_corr(int bits, int endcap) { // endcap [-1,+1]
83  // bits = (endcap == -1) ? bits+1 : bits;
84  // double eta = static_cast<double>(bits);
85  // eta *= 0.010875;
86  // return eta;
87  //}
88 
89  inline double calc_eta_from_theta_rad(double theta_rad) {
90  double eta = -1. * std::log(std::tan(theta_rad/2.));
91  return eta;
92  }
93 
94  inline double calc_eta_from_theta_deg(double theta_deg, int endcap) { // endcap [-1,+1]
95  double theta_rad = deg_to_rad(range_theta_deg(theta_deg)); // put theta in [0, 90] range
96  double eta = calc_eta_from_theta_rad(theta_rad);
97  eta = (endcap == -1) ? -eta : eta;
98  return eta;
99  }
100 
101  inline int calc_eta_GMT(double val) {
102  val /= 0.010875;
103  int gmt_eta = static_cast<int>(std::round(val));
104  return gmt_eta;
105  }
106 
107  // ___________________________________________________________________________
108  // theta
109  inline double calc_theta_deg_from_int(int theta_int) {
110  double theta = static_cast<double>(theta_int);
111  theta = theta * (45.0-8.5)/128. + 8.5;
112  return theta;
113  }
114 
115  inline double calc_theta_rad_from_int(int theta_int) {
116  return deg_to_rad(calc_theta_deg_from_int(theta_int));
117  }
118 
119  inline double calc_theta_rad(double eta) {
120  double theta_rad = 2. * std::atan(std::exp(-1.*eta));
121  return theta_rad;
122  }
123 
124  inline double calc_theta_deg(double eta) {
125  return rad_to_deg(calc_theta_rad(eta));
126  }
127 
128  inline int calc_theta_int(double theta, int endcap) { // theta in deg, endcap [-1,+1]
129  theta = (endcap == -1) ? (180. - theta) : theta;
130  theta = (theta - 8.5) * 128./(45.0-8.5);
131  int theta_int = static_cast<int>(std::round(theta));
132  return theta_int;
133  }
134 
135  inline int calc_theta_int_rpc(double theta, int endcap) { // theta in deg, endcap [-1,+1]
136  theta = (endcap == -1) ? (180. - theta) : theta;
137  theta = (theta - 8.5) * (128./4.)/(45.0-8.5); // 4x coarser resolution
138  int theta_int = static_cast<int>(std::round(theta));
139  return theta_int;
140  }
141 
142  inline double calc_theta_rad_from_eta(double eta) {
143  double theta = std::atan2(1.0, std::sinh(eta)); // cot(theta) = sinh(eta)
144  return theta;
145  }
146 
147  inline double calc_theta_deg_from_eta(double eta) {
148  return rad_to_deg(calc_theta_rad_from_eta(eta));
149  }
150 
151  // ___________________________________________________________________________
152  // phi
153  inline double calc_phi_glob_deg(double loc, int sector) { // loc in deg, sector [1-6]
154  double glob = loc + 15. + (60. * (sector-1));
155  glob = (glob < 180.) ? glob : glob - 360.;
156  return glob;
157  }
158 
159  inline double calc_phi_glob_rad(double loc, int sector) { // loc in rad, sector [1-6]
160  return deg_to_rad(calc_phi_glob_deg(rad_to_deg(loc), sector));
161  }
162 
163  inline double calc_phi_loc_deg(int bits) {
164  double loc = static_cast<double>(bits);
165  loc = (loc/60.) - 22.;
166  return loc;
167  }
168 
169  inline double calc_phi_loc_rad(int bits) {
170  return deg_to_rad(calc_phi_loc_deg(bits));
171  }
172 
173  //inline double calc_phi_loc_deg_corr(int bits, int endcap) { // endcap [-1,+1]
174  // double loc = static_cast<double>(bits);
175  // loc = (loc/60.) - 22.;
176  // loc = (endcap == -1) ? loc - (36./60.) : loc - (28./60.);
177  // return loc;
178  //}
179 
180  //inline double calc_phi_loc_rad_corr(int bits, int endcap) { // endcap [-1,+1]
181  // return deg_to_rad(calc_phi_loc_deg_corr(bits, endcap));
182  //}
183 
184  inline double calc_phi_loc_deg_from_glob(double glob, int sector) { // glob in deg, sector [1-6]
185  glob = range_phi_deg(glob); // put phi in [-180,180] range
186  double loc = glob - 15. - (60. * (sector-1));
187  return loc;
188  }
189 
190  inline int calc_phi_loc_int(double glob, int sector) { // glob in deg, sector [1-6]
191  double loc = calc_phi_loc_deg_from_glob(glob, sector);
192  loc = ((loc + 22.) < 0.) ? loc + 360. : loc;
193  loc = (loc + 22.) * 60.;
194  int phi_int = static_cast<int>(std::round(loc));
195  return phi_int;
196  }
197 
198  inline int calc_phi_loc_int_rpc(double glob, int sector) { // glob in deg, sector [1-6]
199  double loc = calc_phi_loc_deg_from_glob(glob, sector);
200  loc = ((loc + 22.) < 0.) ? loc + 360. : loc;
201  loc = (loc + 22.) * 60./4.; // 4x coarser resolution
202  int phi_int = static_cast<int>(std::round(loc));
203  return phi_int;
204  }
205 
206  inline double calc_phi_GMT_deg(int bits) {
207  double phi = static_cast<double>(bits);
208  phi = (phi * 360./576.) + (180./576.);
209  return phi;
210  }
211 
212  //inline double calc_phi_GMT_deg_corr(int bits) { // AWB mod 09.02.16
213  // return (bits * 0.625 * 1.0208) + 0.3125 * 1.0208 + 0.552;
214  //}
215 
216  inline double calc_phi_GMT_rad(int bits) {
217  return deg_to_rad(calc_phi_GMT_deg(bits));
218  }
219 
220  inline int calc_phi_GMT_int(double val) { // phi in deg
221  val = range_phi_deg(val); // put phi in [-180,180] range
222  val = (val - 180./576.) / (360./576.);
223  int gmt_phi = static_cast<int>(std::round(val));
224  return gmt_phi;
225  }
226 
227 } // namespace emtf
228 
229 #endif
int calc_eta_GMT(double val)
Definition: TrackTools.h:101
double calc_pt(int bits)
Definition: TrackTools.h:61
int calc_chamber(int station, int sector, int subsector, int ring, int csc_ID)
Definition: TrackTools.cc:21
double calc_phi_glob_rad(double loc, int sector)
Definition: TrackTools.h:159
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision bits
Geom::Theta< T > theta() const
double calc_phi_loc_deg(int bits)
Definition: TrackTools.h:163
int calc_uGMT_chamber(int csc_ID, int subsector, int neighbor, int station)
Definition: TrackTools.cc:42
double calc_theta_rad(double eta)
Definition: TrackTools.h:119
int calc_phi_loc_int(double glob, int sector)
Definition: TrackTools.h:190
double calc_phi_loc_deg_from_glob(double glob, int sector)
Definition: TrackTools.h:184
Definition: Event.h:15
double calc_phi_loc_rad(int bits)
Definition: TrackTools.h:169
double calc_theta_deg_from_eta(double eta)
Definition: TrackTools.h:147
int calc_theta_int_rpc(double theta, int endcap)
Definition: TrackTools.h:135
double calc_theta_rad_from_int(int theta_int)
Definition: TrackTools.h:115
double calc_eta_from_theta_rad(double theta_rad)
Definition: TrackTools.h:89
double calc_theta_deg_from_int(int theta_int)
Definition: TrackTools.h:109
Tan< T >::type tan(const T &t)
Definition: Tan.h:22
int calc_phi_loc_int_rpc(double glob, int sector)
Definition: TrackTools.h:198
int calc_pt_GMT(double val)
Definition: TrackTools.h:67
double calc_phi_glob_deg(double loc, int sector)
Definition: TrackTools.h:153
double calc_theta_rad_from_eta(double eta)
Definition: TrackTools.h:142
double calc_theta_deg(double eta)
Definition: TrackTools.h:124
int calc_theta_int(double theta, int endcap)
Definition: TrackTools.h:128
#define M_PI
double range_phi_rad(double rad)
Definition: TrackTools.h:27
double range_theta_rad(double rad)
Definition: TrackTools.h:40
int calc_phi_GMT_int(double val)
Definition: TrackTools.h:220
double deg_to_rad(double deg)
Definition: TrackTools.h:49
int calc_ring(int station, int csc_ID, int strip)
Definition: TrackTools.cc:5
double calc_eta_from_theta_deg(double theta_deg, int endcap)
Definition: TrackTools.h:94
double calc_phi_GMT_deg(int bits)
Definition: TrackTools.h:206
double rad_to_deg(double rad)
Definition: TrackTools.h:54
double range_theta_deg(double deg)
Definition: TrackTools.h:33
double calc_phi_GMT_rad(int bits)
Definition: TrackTools.h:216
double calc_eta(int bits)
Definition: TrackTools.h:76
#define constexpr
double range_phi_deg(double deg)
Definition: TrackTools.h:21