14 std::shared_ptr<GlobalCoordsObtainer> &globalcoordsobtainer)
17 LogDebug(
"MuonPathFitter") <<
"MuonPathAnalyzer: constructor";
28 while (ifin3.good()) {
33 int wh, st, se, maxdrift;
40 while (ifind.good()) {
41 ifind >> wh >> st >> se >> maxdrift;
51 LogDebug(
"MuonPathFitter") <<
"MuonPathAnalyzer: destructor";
65 int COEFF_WIDTH_POSITION,
66 int COEFF_WIDTH_SLOPE,
68 int PRECISSION_POSITION,
71 int PROD_RESIZE_POSITION,
72 int PROD_RESIZE_SLOPE,
75 const int PARTIALS_PRECISSION = 4;
76 const int PARTIALS_SHR_T0 = PRECISSION_T0 - PARTIALS_PRECISSION;
77 const int PARTIALS_SHR_POSITION = PRECISSION_POSITION - PARTIALS_PRECISSION;
78 const int PARTIALS_SHR_SLOPE = PRECISSION_SLOPE - PARTIALS_PRECISSION;
79 const int PARTIALS_WIDTH_T0 = PROD_RESIZE_T0 - PARTIALS_SHR_T0;
80 const int PARTIALS_WIDTH_POSITION = PROD_RESIZE_POSITION - PARTIALS_SHR_POSITION;
81 const int PARTIALS_WIDTH_SLOPE = PROD_RESIZE_SLOPE - PARTIALS_SHR_SLOPE;
83 const int WIDTH_TO_PREC = 11 + PARTIALS_PRECISSION;
84 const int WIDTH_SLOPE_PREC = 14 + PARTIALS_PRECISSION;
85 const int WIDTH_POSITION_PREC = WIDTH_SLOPE_PREC + 1;
87 const int SEMICHAMBER_H_PRECISSION = 13 + PARTIALS_PRECISSION;
88 const float SEMICHAMBER_H_REAL = ((235. / 2.) / (16. * 6.5)) *
std::pow(2, SEMICHAMBER_H_PRECISSION);
89 const int SEMICHAMBER_H = (
int)SEMICHAMBER_H_REAL;
91 const int SEMICHAMBER_RES_SHR = SEMICHAMBER_H_PRECISSION;
93 const int LYRANDAHALF_RES_SHR = 4;
95 const int CHI2_CALC_RES_BITS = 7;
100 std::vector<int> normalized_times;
101 std::vector<int> normalized_wirepos;
117 std::vector<int> tmp_dif_bx_vector;
123 normalized_times.push_back(tmp_norm_time);
126 std::vector<int> tmp_wirepos_vector;
132 normalized_wirepos.push_back(tmp_wirepos);
134 normalized_times.push_back(-1);
135 normalized_wirepos.push_back(-1);
143 std::vector<int> xi_arr;
146 int min_hit_time = 999999, max_hit_time = 0;
150 auto tmp_xi_incr = normalized_wirepos[
i];
151 tmp_xi_incr += (-1 + 2 * fit_common_in.
lateralities[
i]) * normalized_times[
i];
154 std::vector<int> tmp_xi_incr_vector;
159 xi_arr.push_back(tmp_xi_incr);
162 if (normalized_times[
i] < min_hit_time) {
163 min_hit_time = normalized_times[
i];
165 if (normalized_times[
i] > max_hit_time) {
166 max_hit_time = normalized_times[
i];
169 xi_arr.push_back(-1);
177 std::vector<int> products_t0;
178 std::vector<int> products_position;
179 std::vector<int> products_slope;
182 products_t0.push_back(-1);
183 products_position.push_back(-1);
184 products_slope.push_back(-1);
196 int t0_prec = 0, position_prec = 0, slope_prec = 0;
201 t0_prec += products_t0[
i] >> PARTIALS_SHR_T0;
202 position_prec += products_position[
i] >> PARTIALS_SHR_POSITION;
203 slope_prec += products_slope[
i] >> PARTIALS_SHR_SLOPE;
211 std::vector<int> t0_prec_vector, position_prec_vector, slope_prec_vector;
235 int norm_t0 = ((t0_prec >> (PARTIALS_PRECISSION - 1)) + 1) >> 1;
236 int norm_position = ((position_prec >> (PARTIALS_PRECISSION - 1)) + 1) >> 1;
237 int norm_slope = ((slope_prec >> (PARTIALS_PRECISSION - 1)) + 1) >> 1;
240 std::vector<int> res_partials_arr;
243 res_partials_arr.push_back(-1);
245 int tmp_position_prec = position_prec - (xi_arr[
i] << PARTIALS_PRECISSION);
247 tmp_position_prec +=
std::pow(2, PARTIALS_PRECISSION - 1);
249 tmp_position_prec += (-1 + 2 * fit_common_in.
lateralities[
i]) * t0_prec;
250 res_partials_arr.push_back(tmp_position_prec);
257 int slope_x_halfchamb = (((
long int)slope_prec * (
long int)SEMICHAMBER_H)) >> SEMICHAMBER_RES_SHR;
259 slope_x_halfchamb = 0;
260 int slope_x_3semicells = (slope_prec * 3) >> LYRANDAHALF_RES_SHR;
261 int slope_x_1semicell = (slope_prec * 1) >> LYRANDAHALF_RES_SHR;
270 res_partials_arr[
i] -= slope_x_3semicells;
272 res_partials_arr[
i] -= slope_x_1semicell;
274 res_partials_arr[
i] += slope_x_1semicell;
276 res_partials_arr[
i] += slope_x_3semicells;
284 std::vector<int> residuals, position_prec_arr;
287 residuals.push_back(-1);
288 position_prec_arr.push_back(-1);
290 int tmp_position_prec = res_partials_arr[
i];
291 tmp_position_prec += (-1 + 2 * (
int)(
i >=
NUM_LAYERS)) * slope_x_halfchamb;
292 position_prec_arr.push_back(tmp_position_prec);
293 residuals.push_back(
abs(tmp_position_prec >> PARTIALS_PRECISSION));
306 int t0_bx_sign = ((
int)(norm_t0 < 0)) * 1;
307 int t0_bx_abs =
abs(norm_t0 >> 5);
311 int slope = norm_slope;
314 if (norm_t0 < min_t0)
316 if (norm_t0 > max_t0)
320 std::vector<int> squared_residuals;
323 squared_residuals.push_back(-1);
325 squared_residuals.push_back(residuals[
i] * residuals[
i]);
332 std::vector<int> tmp_vector;
333 int tmp_position_prec = (position_prec_arr[
i] >> PARTIALS_PRECISSION);
353 chi2 += squared_residuals[
i];
365 fit_common_out.
t0 =
t0;
369 return fit_common_out;
373 short COEFF_WIDTH_T0,
374 short COEFF_WIDTH_POSITION,
375 short COEFF_WIDTH_SLOPE,
380 for (
int i = LOLY;
i <= HILY;
i++) {
384 ctr += COEFF_WIDTH_T0;
386 for (
int i = LOLY;
i <= HILY;
i++) {
390 ctr += COEFF_WIDTH_POSITION;
392 for (
int i = LOLY;
i <= HILY;
i++) {
396 ctr += COEFF_WIDTH_SLOPE;
int maxdriftinfo_[5][4][14]
std::vector< int > lateralities
std::vector< SLhitP > hits
edm::FileInPath maxdrift_filename_
edm::ESGetToken< DTGeometry, MuonGeometryRecord > dtGeomH
std::string fullPath() const
void vhdl_int_to_signed(int value, std::vector< int > &v)
static const double slope[3]
int vhdl_signed_to_int(std::vector< int > v)
bool vhdl_resize_signed_ok(std::vector< int > v, int new_size)
std::vector< int > vhdl_slice(std::vector< int > v, int upper, int lower)
constexpr int WIDTH_COARSED_TIME
constexpr int WIREPOS_WIDTH
constexpr int T0_CUT_TOLERANCE
std::map< int, float > shiftinfo_
constexpr int CELL_SEMILENGTH
void vhdl_resize_unsigned(std::vector< int > &v, int new_size)
void vhdl_resize_signed(std::vector< int > &v, int new_size)
Abs< T >::type abs(const T &t)
constexpr int WIDTH_FULL_TIME
MuonPathFitter(const edm::ParameterSet &pset, edm::ConsumesCollector &iC, std::shared_ptr< GlobalCoordsObtainer > &globalcoordsobtainer)
edm::FileInPath shift_filename_
std::shared_ptr< GlobalCoordsObtainer > globalcoordsobtainer_
coeffs_t RomDataConvert(std::vector< int > slv, short COEFF_WIDTH_T0, short COEFF_WIDTH_POSITION, short COEFF_WIDTH_SLOPE, short LOLY, short HILY)
constexpr int GENERIC_COEFF_WIDTH
constexpr int WIDTH_DIFBX
void vhdl_int_to_unsigned(int value, std::vector< int > &v)
bool vhdl_resize_unsigned_ok(std::vector< int > v, int new_size)
static int position[264][3]
static unsigned int const shift
constexpr int WIREPOS_NORM_LSB_IGNORED
~MuonPathFitter() override
fit_common_out_t fit(fit_common_in_t fit_common_in, int XI_WIDTH, int COEFF_WIDTH_T0, int COEFF_WIDTH_POSITION, int COEFF_WIDTH_SLOPE, int PRECISSION_T0, int PRECISSION_POSITION, int PRECISSION_SLOPE, int PROD_RESIZE_T0, int PROD_RESIZE_POSITION, int PROD_RESIZE_SLOPE, int MAX_DRIFT_TDC, int sl)
Power< A, B >::type pow(const A &a, const B &b)
std::vector< int > hits_valid