CMS 3D CMS Logo

List of all members | Classes | Public Member Functions | Private Member Functions | Static Private Attributes
DTTime2DriftParametrization Class Reference

#include <DTTime2DriftParametrization.h>

Classes

struct  drift_distance
 Structure used to return output values. More...
 

Public Member Functions

bool computeDriftDistance_mean (double time, double alpha, double by, double bz, short interpolate, drift_distance *dx) const
 
bool computeDriftDistance_mode (double time, double alpha, double by, double bz, short interpolate, drift_distance *dx) const
 
 DTTime2DriftParametrization ()
 Constructor. More...
 
virtual ~DTTime2DriftParametrization ()
 Destructor. More...
 

Private Member Functions

unsigned short MB_DT_Check_boundaries (double distime, double alpha, double by, double bz, short ifl) const
 
double MB_DT_delta_x (double, double *) const
 
double MB_DT_dist (double, double *) const
 
unsigned short MB_DT_drift_distance (double time, double alpha, double by, double bz, drift_distance *DX, short interpolate) const
 Calculate drift distance and spread. More...
 
void MB_DT_Get_grid_points (double alpha, double by, double bz, unsigned short *p_alpha, unsigned short *p_By, unsigned short *p_Bz, unsigned short *q_alpha, unsigned short *q_By, unsigned short *q_Bz) const
 
void MB_DT_Get_grid_values (double Var, unsigned short *pi, unsigned short *pj, short Initial, unsigned short N, const double *Values) const
 
double MB_DT_MLInterpolation (double *al, double *by, double *bz, double *f) const
 
double MB_DT_sigma_t_m (double, double *) const
 
double MB_DT_sigma_t_p (double, double *) const
 

Static Private Attributes

static const double alpha_value [11]
 
static const double By_value [5]
 
static const double Bz_value [5]
 
static const double fun_sigma_t [11][5][5][7]
 
static const double fun_x [11][5][5][15]
 
static const double velocitySkew
 

Detailed Description

This class access the cell parametrization by Pablo Garcia-Abia and Jesus Puerta (CIEMAT). The two public methods act as an interface for the parametrization converting the reference frame and the units accordingly to CMSSW convention.

Author
Pablo Garcia-Abia and Jesus Puerta (CIEMAT, Madrid)

Definition at line 18 of file DTTime2DriftParametrization.h.

Constructor & Destructor Documentation

◆ DTTime2DriftParametrization()

DTTime2DriftParametrization::DTTime2DriftParametrization ( )

Constructor.

Definition at line 18 of file DTTime2DriftParametrization.cc.

18 {}

◆ ~DTTime2DriftParametrization()

DTTime2DriftParametrization::~DTTime2DriftParametrization ( )
virtual

Destructor.

Definition at line 20 of file DTTime2DriftParametrization.cc.

20 {}

Member Function Documentation

◆ computeDriftDistance_mean()

bool DTTime2DriftParametrization::computeDriftDistance_mean ( double  time,
double  alpha,
double  by,
double  bz,
short  interpolate,
drift_distance dx 
) const

Compute the drift distance and relative errors (cm). The drift distance is computed as the MEAN value of the distance distribution for this particular time. This method takes care of the conversions of units and reference frame used by CMSSW and the parametrization. time is in ns, alpha (=atan(x/-z)) in rad, by and bz are the magnetic field in the layer RF. False is returned if the parametrization fails

Definition at line 52 of file DTTime2DriftParametrization.cc.

References alpha, PVValHelper::dx, RemoveAddSevLevel::flag, HiCaloJetParameters_cff::interpolate, SiStripPI::max, MB_DT_drift_distance(), Geom::pi(), mathSSE::sqrt(), and protons_cff::time.

Referenced by DTParametrizedDriftAlgo::compute().

53  {
54  // NOTE: This method takes care of convertion of the units in order to use the CMSSW conventions
55 
56  // The convention used by the parametrization for the reference frame are different
57  // with respect to CMSSW
58  // X_par = X_CMSSW; Y_par=Z_CMSSW; Z_par = -Y_CMSSW
59  float By_par = bz; // Bnorm
60  float Bz_par = -by; // Bwire
61 
62  // Express alpha in degrees
63  float alpha_par = alpha * 180. / Geom::pi();
64 
65  //--------------------------------------------------------------------
66  // Calculate the drift distance and the resolution from the parametrization
67  unsigned short flag = MB_DT_drift_distance(time, alpha_par, By_par, Bz_par, dx, interpolate);
68 
69  if (flag != 1)
70  return false;
71 
72  // Convert from mm (used by the parametrization) to cm (used by CMSSW)
73  dx->v_drift = dx->v_drift / 10.;
74  dx->x_drift = dx->x_drift / 10.;
75  dx->delta_x = dx->delta_x / 10.;
76  dx->x_width_m = dx->x_width_m / 10.;
77  dx->x_width_p = dx->x_width_p / 10.;
78 
79  // Correct drift time for the difference between mode and mean
80  dx->x_drift = std::max(0., dx->x_drift - (dx->x_width_p - dx->x_width_m) * sqrt(2. / Geom::pi()));
81 
82  return true;
83 }
float alpha
Definition: AMPTWrapper.h:105
unsigned short MB_DT_drift_distance(double time, double alpha, double by, double bz, drift_distance *DX, short interpolate) const
Calculate drift distance and spread.
T sqrt(T t)
Definition: SSEVec.h:19
constexpr double pi()
Definition: Pi.h:31

◆ computeDriftDistance_mode()

bool DTTime2DriftParametrization::computeDriftDistance_mode ( double  time,
double  alpha,
double  by,
double  bz,
short  interpolate,
drift_distance dx 
) const

Compute the drift distance and relative errors (cm). The drift distance is computed as the MODE value of the distance distribution for this particular time. This method takes care of the conversions of units and reference frame used by CMSSW and the parametrization. time is in ns, alpha (=atan(x/-z)) in rad, by and bz are the magnetic field in the layer RF. False is returned if the parametrization fails

Definition at line 22 of file DTTime2DriftParametrization.cc.

References alpha, PVValHelper::dx, RemoveAddSevLevel::flag, HiCaloJetParameters_cff::interpolate, MB_DT_drift_distance(), Geom::pi(), and protons_cff::time.

23  {
24  // NOTE: This method takes care of convertion of the units in order to use the CMSSW conventions
25 
26  // The convention used by the parametrization for the reference frame are different
27  // with respect to CMSSW
28  // X_par = X_CMSSW; Y_par=Z_CMSSW; Z_par = -Y_CMSSW
29  float By_par = bz; // Bnorm
30  float Bz_par = -by; // Bwire
31 
32  // Express alpha in degrees
33  float alpha_par = alpha * 180. / Geom::pi();
34 
35  //--------------------------------------------------------------------
36  // Calculate the drift distance and the resolution from the parametrization
37  unsigned short flag = MB_DT_drift_distance(time, alpha_par, By_par, Bz_par, dx, interpolate);
38 
39  if (flag != 1)
40  return false;
41 
42  // Convert from mm (used by the parametrization) to cm (used by CMSSW)
43  dx->v_drift = dx->v_drift / 10.;
44  dx->x_drift = dx->x_drift / 10.;
45  dx->delta_x = dx->delta_x / 10.;
46  dx->x_width_m = dx->x_width_m / 10.;
47  dx->x_width_p = dx->x_width_p / 10.;
48 
49  return true;
50 }
float alpha
Definition: AMPTWrapper.h:105
unsigned short MB_DT_drift_distance(double time, double alpha, double by, double bz, drift_distance *DX, short interpolate) const
Calculate drift distance and spread.
constexpr double pi()
Definition: Pi.h:31

◆ MB_DT_Check_boundaries()

unsigned short DTTime2DriftParametrization::MB_DT_Check_boundaries ( double  distime,
double  alpha,
double  by,
double  bz,
short  ifl 
) const
private

Referenced by MB_DT_drift_distance().

◆ MB_DT_delta_x()

double DTTime2DriftParametrization::MB_DT_delta_x ( double  t,
double *  par 
) const
private

Definition at line 252 of file DTTime2DriftParametrization.cc.

References submitPVValidationJobs::t, and RandomServiceHelper::t2.

Referenced by MB_DT_drift_distance().

252  {
253  double t2 = t * t;
254 
255 #ifdef MB_DT_DEBUG
256  printf("MB_DT_delta_x: time = %f\n", t);
257 #endif
258 
259  //
260  // Now distances are in microns. Divide by 1000 to get mm.
261  //
262  if (t <= par[12]) {
263  return (-0.001 * (par[1] + par[2] * t + par[3] * t2));
264  }
265  if (t <= par[13]) {
266  return (-0.001 * (par[4] + par[5] * t + par[6] * t2 + par[7] * t2 * t + par[8] * t2 * t2));
267  }
268  return (-0.001 * (par[9] + par[10] * t + par[11] * t2));
269 }

◆ MB_DT_dist()

double DTTime2DriftParametrization::MB_DT_dist ( double  time,
double *  par 
) const
private

Definition at line 271 of file DTTime2DriftParametrization.cc.

References protons_cff::time.

Referenced by MB_DT_drift_distance().

271  {
272  return (time * par[0]); // par[0] is the drift velocity, 'dist' is the linear part of the drift distance
273 }

◆ MB_DT_drift_distance()

unsigned short DTTime2DriftParametrization::MB_DT_drift_distance ( double  time,
double  alpha,
double  by,
double  bz,
drift_distance DX,
short  interpolate 
) const
private

Calculate drift distance and spread.

Definition at line 85 of file DTTime2DriftParametrization.cc.

References alpha, alpha_value, By_value, Bz_value, DTTime2DriftParametrization::drift_distance::delta_x, fun_sigma_t, fun_x, mps_fire::i, HiCaloJetParameters_cff::interpolate, dqmiolumiharvest::j, MB_DT_Check_boundaries(), MB_DT_delta_x(), MB_DT_dist(), MB_DT_Get_grid_points(), MB_DT_MLInterpolation(), MB_DT_sigma_t_m(), MB_DT_sigma_t_p(), N_Par_x, N_Sigma_t, protons_cff::time, DTTime2DriftParametrization::drift_distance::v_drift, DTTime2DriftParametrization::drift_distance::x_drift, DTTime2DriftParametrization::drift_distance::x_width_m, and DTTime2DriftParametrization::drift_distance::x_width_p.

Referenced by computeDriftDistance_mean(), and computeDriftDistance_mode().

86  {
87  unsigned short i, j, n_func, ial, iby, ibz;
88  unsigned short i_alpha, i_By, i_Bz;
89  unsigned short j_alpha, j_By, j_Bz;
90 
91  double OffSet;
92  double par_x[N_Par_x];
93  double par_sigma_t[N_Sigma_t];
94 
95  double V_al[3], V_by[3], V_bz[3];
96 
97  double DXV_v_drift[N_Func];
98  double DXV_x_drift[N_Func];
99  double DXV_delta_x[N_Func];
100  double DXV_x_width_m[N_Func];
101  double DXV_x_width_p[N_Func];
102 
103  DX->v_drift = -1;
104  DX->x_drift = -1;
105  DX->delta_x = -1;
106  DX->x_width_m = -1;
107  DX->x_width_p = -1;
108 
109  /* Check 'interpolate' and initialize DXV */
110 
111  switch (interpolate) {
112  case 1:
113  n_func = N_Func;
114  for (j = 0; j < N_Func; j++) {
115  DXV_v_drift[j] = -1;
116  DXV_x_drift[j] = -1;
117  DXV_delta_x[j] = -1;
118  DXV_x_width_m[j] = -1;
119  DXV_x_width_p[j] = -1;
120  }
121  break;
122 
123  case 0:
124  n_func = 1;
125  break;
126 
127  default:
128  printf("*** ERROR, MB_DT_drift_distance: invalid interpolate value = %d\n", interpolate);
129  return (0);
130  }
131 
132 #ifdef MB_DT_DEBUG
133 
134  /* Dump input values */
135 
136  printf("\nMB_DT_drift_distance: Function called with values:\n\n");
137  printf("MB_DT_drift_distance: time = %f\n", time);
138  printf("MB_DT_drift_distance: alpha = %f\n", alpha);
139  printf("MB_DT_drift_distance: by = %f\n", by);
140  printf("MB_DT_drift_distance: bz = %f\n", bz);
141 
142 #endif
143 
144  /* Take into account the symmetries of the parametrisations */
145 
146  by = fabs(by); // f-1 (By) = f-1 (-By)
147 
148  if (bz < 0) { // f-1 (alpha,Bz) = f-1 (-alpha, -Bz)
149  bz = -bz;
150  alpha = -alpha;
151  }
152 
153  /* Check boundaries of the variables and take the closest values */
154 
155  MB_DT_Check_boundaries(time, alpha, by, bz, -1);
156 
157  MB_DT_Get_grid_points(alpha, by, bz, &i_alpha, &i_By, &i_Bz, &j_alpha, &j_By, &j_Bz);
158 
159 #ifdef MB_DT_DEBUG
160  printf("MB_DT_drift_distance:\n");
161  printf("MB_DT_drift_distance: i_alpha j_alpha alpha_value's %d %d %.0f %.0f\n",
162  i_alpha,
163  j_alpha,
164  alpha_value[i_alpha],
165  alpha_value[j_alpha]);
166  printf("MB_DT_drift_distance: i_By j_By By_value's %d %d %.2f %.2f\n",
167  i_By,
168  j_By,
169  By_value[i_By],
170  By_value[j_By]);
171  printf("MB_DT_drift_distance: i_Bz j_Bz Bz_value's %d %d %.2f %.2f\n",
172  i_Bz,
173  j_Bz,
174  Bz_value[i_Bz],
175  Bz_value[j_Bz]);
176 #endif
177 
178  /* Get the parametrisations for the different grid points */
179 
180  for (j = 0; j < n_func; j++) {
181  ial = (j & 4) ? j_alpha : i_alpha;
182  iby = (j & 2) ? j_By : i_By;
183  ibz = (j & 1) ? j_Bz : i_Bz;
184 
185  for (i = 0; i < N_Par_x; i++)
186  par_x[i] = fun_x[ial][iby][ibz][i];
187  for (i = 0; i < N_Sigma_t; i++)
188  par_sigma_t[i] = fun_sigma_t[ial][iby][ibz][i];
189 
190  OffSet = par_x[N_Par_x - 1];
191 
192  DXV_v_drift[j] = par_x[0]; // drift velocity
193  DXV_delta_x[j] = MB_DT_delta_x(time, par_x); // deviation from linearity
194  // drift distance to the wire (signed)
195  DXV_x_drift[j] = MB_DT_dist(time, par_x) + DXV_delta_x[j] - OffSet * par_x[0];
196  // distance width ~ vd * sigma_t(x) (minus, left)
197  DXV_x_width_m[j] = MB_DT_sigma_t_m(DXV_x_drift[j], par_sigma_t) * DXV_v_drift[j];
198  // distance width ~ vd * sigma_t(x) (plus, right)
199  DXV_x_width_p[j] = MB_DT_sigma_t_p(DXV_x_drift[j], par_sigma_t) * DXV_v_drift[j];
200 
201 #ifdef MB_DT_DEBUG
202  printf("MB_DT_drift_LOOP: OffSet = %f\n", OffSet);
203  printf("MB_DT_drift_LOOP: time, v_drift, x_drift, lin, x_width_m, x_width_p = %f %f %f %f %f %f\n",
204  time,
205  DXV_v_drift[j],
206  DXV_x_drift[j],
207  DXV_delta_x[j],
208  DXV_x_width_m[j],
209  DXV_x_width_p[j]);
210 #endif
211  }
212 
213  /* Return interpolated or grid values */
214 
215  if (interpolate == 0) {
216  DX->v_drift = DXV_v_drift[0];
217  DX->delta_x = DXV_delta_x[0];
218  DX->x_drift = DXV_x_drift[0];
219  DX->x_width_m = DXV_x_width_m[0];
220  DX->x_width_p = DXV_x_width_p[0];
221  } else {
222  V_al[0] = alpha;
223  V_al[1] = alpha_value[i_alpha];
224  V_al[2] = alpha_value[j_alpha];
225  V_by[0] = by;
226  V_by[1] = By_value[i_By];
227  V_by[2] = By_value[j_By];
228  V_bz[0] = bz;
229  V_bz[1] = Bz_value[i_Bz];
230  V_bz[2] = Bz_value[j_Bz];
231 
232  DX->v_drift = MB_DT_MLInterpolation(V_al, V_by, V_bz, DXV_v_drift);
233  DX->delta_x = MB_DT_MLInterpolation(V_al, V_by, V_bz, DXV_delta_x);
234  DX->x_drift = MB_DT_MLInterpolation(V_al, V_by, V_bz, DXV_x_drift);
235  DX->x_width_m = MB_DT_MLInterpolation(V_al, V_by, V_bz, DXV_x_width_m);
236  DX->x_width_p = MB_DT_MLInterpolation(V_al, V_by, V_bz, DXV_x_width_p);
237  }
238 
239 #ifdef MB_DT_DEBUG
240  printf("MB_DT_drift_distance: time, v_drift, x_drift, lin, x_width_m, x_width_p = %f %f %f %f %f %f\n",
241  time,
242  DX->v_drift,
243  DX->x_drift,
244  DX->delta_x,
245  DX->x_width_m,
246  DX->x_width_p);
247 #endif
248 
249  return (1);
250 }
float alpha
Definition: AMPTWrapper.h:105
double MB_DT_sigma_t_p(double, double *) const
static const double fun_sigma_t[11][5][5][7]
double MB_DT_dist(double, double *) const
#define N_Par_x
double MB_DT_MLInterpolation(double *al, double *by, double *bz, double *f) const
unsigned short MB_DT_Check_boundaries(double distime, double alpha, double by, double bz, short ifl) const
double MB_DT_delta_x(double, double *) const
void MB_DT_Get_grid_points(double alpha, double by, double bz, unsigned short *p_alpha, unsigned short *p_By, unsigned short *p_Bz, unsigned short *q_alpha, unsigned short *q_By, unsigned short *q_Bz) const
static const double fun_x[11][5][5][15]
double MB_DT_sigma_t_m(double, double *) const
#define N_Sigma_t

◆ MB_DT_Get_grid_points()

void DTTime2DriftParametrization::MB_DT_Get_grid_points ( double  alpha,
double  by,
double  bz,
unsigned short *  p_alpha,
unsigned short *  p_By,
unsigned short *  p_Bz,
unsigned short *  q_alpha,
unsigned short *  q_By,
unsigned short *  q_Bz 
) const
private

Referenced by MB_DT_drift_distance().

◆ MB_DT_Get_grid_values()

void DTTime2DriftParametrization::MB_DT_Get_grid_values ( double  Var,
unsigned short *  pi,
unsigned short *  pj,
short  Initial,
unsigned short  N,
const double *  Values 
) const
private

◆ MB_DT_MLInterpolation()

double DTTime2DriftParametrization::MB_DT_MLInterpolation ( double *  al,
double *  by,
double *  bz,
double *  f 
) const
private

Referenced by MB_DT_drift_distance().

◆ MB_DT_sigma_t_m()

double DTTime2DriftParametrization::MB_DT_sigma_t_m ( double  ,
double *   
) const
private

Referenced by MB_DT_drift_distance().

◆ MB_DT_sigma_t_p()

double DTTime2DriftParametrization::MB_DT_sigma_t_p ( double  ,
double *   
) const
private

Referenced by MB_DT_drift_distance().

Member Data Documentation

◆ alpha_value

const double DTTime2DriftParametrization::alpha_value[11]
staticprivate

Definition at line 79 of file DTTime2DriftParametrization.h.

Referenced by MB_DT_drift_distance().

◆ By_value

const double DTTime2DriftParametrization::By_value[5]
staticprivate

Definition at line 80 of file DTTime2DriftParametrization.h.

Referenced by MB_DT_drift_distance().

◆ Bz_value

const double DTTime2DriftParametrization::Bz_value[5]
staticprivate

Definition at line 81 of file DTTime2DriftParametrization.h.

Referenced by MB_DT_drift_distance().

◆ fun_sigma_t

const double DTTime2DriftParametrization::fun_sigma_t[11][5][5][7]
staticprivate

Definition at line 85 of file DTTime2DriftParametrization.h.

Referenced by MB_DT_drift_distance().

◆ fun_x

const double DTTime2DriftParametrization::fun_x
staticprivate

Definition at line 84 of file DTTime2DriftParametrization.h.

Referenced by MB_DT_drift_distance().

◆ velocitySkew

const double DTTime2DriftParametrization::velocitySkew
staticprivate

Definition at line 88 of file DTTime2DriftParametrization.h.