File indexing completed on 2024-04-06 12:30:44
0001
0002
0003
0004
0005
0006
0007
0008
0009 #include "Utils.h"
0010
0011 #include "DTAngleParam.h"
0012 #include "DTBNormParam.h"
0013
0014 #include <cmath>
0015 #include <iostream>
0016
0017
0018 float ShortDistCorrect(float x) {
0019 float mu_drift_corr = fabs(x);
0020 float min_dist = 0.03;
0021
0022 const float factor_range = 2.0;
0023 float short_range = factor_range * min_dist;
0024 float punch_dist = short_range - mu_drift_corr;
0025 if (punch_dist > 0.0)
0026 mu_drift_corr = short_range - punch_dist * (factor_range - 1.0) / factor_range;
0027
0028 return mu_drift_corr;
0029 }
0030
0031
0032
0033
0034
0035 float oldParametrization(float x, float theta, float Bwire, float Bnorm) {
0036
0037 Bwire = -Bwire;
0038
0039
0040
0041
0042 x = ShortDistCorrect(x);
0043
0044
0045
0046
0047 const float cell_width = 2.1;
0048
0049 const float volume_lim = cell_width - 0.0025;
0050 const float volume_par = cell_width - 0.1;
0051 const float edge_width = volume_lim - volume_par;
0052
0053
0054
0055 float xcoor = cell_width - fabs(x);
0056
0057 if (xcoor < 0.0)
0058 xcoor = 0.0;
0059
0060 if (xcoor > volume_lim) {
0061 return 0.0;
0062 }
0063
0064 xcoor *= (2 / cell_width);
0065
0066
0067
0068
0069
0070 float angle = theta;
0071 while (angle > 360.0)
0072 angle -= 360.0;
0073 if ((angle > 90.0) && (angle <= 270.0))
0074 angle -= 180.0;
0075 else if ((angle > 270.0) && (angle <= 360.0))
0076 angle -= 360.0;
0077
0078
0079 if (Bwire < 0.0) {
0080 Bwire = fabs(Bwire);
0081 angle = -angle;
0082 }
0083
0084
0085 bool out_of_volume = (xcoor > volume_par);
0086 float xpos = xcoor;
0087 if (out_of_volume) {
0088 xpos = xcoor;
0089 xcoor = volume_par;
0090 }
0091
0092 float mu_time_drift = 0.;
0093
0094
0095 DTAngleParam angle_func(angle);
0096 mu_time_drift = angle_func.time(Bwire, xcoor);
0097
0098
0099
0100 DTBNormParam bnorm_func(Bnorm);
0101 mu_time_drift += bnorm_func.tcor(xcoor);
0102
0103
0104 if (out_of_volume)
0105 mu_time_drift *= (1.0 - ((xpos - volume_par) / edge_width));
0106
0107
0108 mu_time_drift *= cell_width / 2.;
0109
0110 mu_time_drift *= 1000.0;
0111 return mu_time_drift;
0112 }