CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 21 of file DTTime2DriftParametrization.h.

Constructor & Destructor Documentation

DTTime2DriftParametrization::DTTime2DriftParametrization ( )

Constructor.

Definition at line 18 of file DTTime2DriftParametrization.cc.

18 {}
DTTime2DriftParametrization::~DTTime2DriftParametrization ( )
virtual

Destructor.

Definition at line 20 of file DTTime2DriftParametrization.cc.

20 {}

Member Function Documentation

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 61 of file DTTime2DriftParametrization.cc.

References DTTime2DriftParametrization::drift_distance::delta_x, bookConverter::max, MB_DT_drift_distance(), Geom::pi(), mathSSE::sqrt(), DTTime2DriftParametrization::drift_distance::v_drift, DTTime2DriftParametrization::drift_distance::x_drift, DTTime2DriftParametrization::drift_distance::x_width_m, and DTTime2DriftParametrization::drift_distance::x_width_p.

66  {
67  // NOTE: This method takes care of convertion of the units in order to use the CMSSW conventions
68 
69  // The convention used by the parametrization for the reference frame are different
70  // with respect to CMSSW
71  // X_par = X_CMSSW; Y_par=Z_CMSSW; Z_par = -Y_CMSSW
72  float By_par = bz; // Bnorm
73  float Bz_par = -by; // Bwire
74 
75  // Express alpha in degrees
76  float alpha_par = alpha * 180./Geom::pi();
77 
78  //--------------------------------------------------------------------
79  // Calculate the drift distance and the resolution from the parametrization
80  unsigned short flag =
81  MB_DT_drift_distance(time, alpha_par, By_par, Bz_par, dx, interpolate);
82 
83  if(flag!=1)
84  return false;
85 
86  // Convert from mm (used by the parametrization) to cm (used by CMSSW)
87  dx->v_drift = dx->v_drift/10.;
88  dx->x_drift = dx->x_drift/10.;
89  dx->delta_x = dx->delta_x/10.;
90  dx->x_width_m = dx->x_width_m/10.;
91  dx->x_width_p = dx->x_width_p/10.;
92 
93  // Correct drift time for the difference between mode and mean
94  dx->x_drift = std::max(0.,dx->x_drift - (dx->x_width_p-dx->x_width_m)*sqrt(2./Geom::pi()));
95 
96  return true;
97 
98  }
float alpha
Definition: AMPTWrapper.h:95
T sqrt(T t)
Definition: SSEVec.h:48
double pi()
Definition: Pi.h:31
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.
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 24 of file DTTime2DriftParametrization.cc.

References DTTime2DriftParametrization::drift_distance::delta_x, MB_DT_drift_distance(), Geom::pi(), DTTime2DriftParametrization::drift_distance::v_drift, DTTime2DriftParametrization::drift_distance::x_drift, DTTime2DriftParametrization::drift_distance::x_width_m, and DTTime2DriftParametrization::drift_distance::x_width_p.

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

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

Definition at line 240 of file DTTime2DriftParametrization.cc.

References lumiQTWidget::t.

Referenced by MB_DT_drift_distance().

240  {
241  double t2 = t*t;
242 
243 #ifdef MB_DT_DEBUG
244  printf("MB_DT_delta_x: time = %f\n",t);
245 #endif
246 
247 //
248 // Now distances are in microns. Divide by 1000 to get mm.
249 //
250  if ( t <= par[12] ) { return ( -0.001 * (par[1] + par[2] *t + par[3] *t2) ); }
251  if ( t <= par[13] ) { return ( -0.001 * (par[4] + par[5] *t + par[6] *t2 + par[7]*t2*t + par[8]*t2*t2) ); }
252  return ( -0.001 * (par[9] + par[10]*t + par[11]*t2) );
253 }
double DTTime2DriftParametrization::MB_DT_dist ( double  time,
double *  par 
) const
private

Definition at line 256 of file DTTime2DriftParametrization.cc.

Referenced by MB_DT_drift_distance().

256  {
257  return ( time * par[0] ); // par[0] is the drift velocity, 'dist' is the linear part of the drift distance
258 }
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 100 of file DTTime2DriftParametrization.cc.

References alpha, alpha_value, By_value, Bz_value, DTTime2DriftParametrization::drift_distance::delta_x, fun_sigma_t, fun_x, i, 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, 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().

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

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
double DTTime2DriftParametrization::MB_DT_MLInterpolation ( double *  al,
double *  by,
double *  bz,
double *  f 
) const
private

Referenced by MB_DT_drift_distance().

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

Referenced by MB_DT_drift_distance().

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

Referenced by MB_DT_drift_distance().

Member Data Documentation

const double DTTime2DriftParametrization::alpha_value[11]
staticprivate

Definition at line 108 of file DTTime2DriftParametrization.h.

Referenced by MB_DT_drift_distance().

const double DTTime2DriftParametrization::By_value[5]
staticprivate

Definition at line 109 of file DTTime2DriftParametrization.h.

Referenced by MB_DT_drift_distance().

const double DTTime2DriftParametrization::Bz_value[5]
staticprivate

Definition at line 110 of file DTTime2DriftParametrization.h.

Referenced by MB_DT_drift_distance().

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

Definition at line 114 of file DTTime2DriftParametrization.h.

Referenced by MB_DT_drift_distance().

const double DTTime2DriftParametrization::fun_x
staticprivate

Definition at line 113 of file DTTime2DriftParametrization.h.

Referenced by MB_DT_drift_distance().

const double DTTime2DriftParametrization::velocitySkew
staticprivate

Definition at line 117 of file DTTime2DriftParametrization.h.