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.

Date:
2007/04/19 11:08:17
Revision:
1.1
Author
Pablo Garcia-Abia and Jesus Puerta (CIEMAT, Madrid)

Definition at line 23 of file DTTime2DriftParametrization.h.

Constructor & Destructor Documentation

DTTime2DriftParametrization::DTTime2DriftParametrization ( )

Constructor.

Definition at line 20 of file DTTime2DriftParametrization.cc.

20 {}
DTTime2DriftParametrization::~DTTime2DriftParametrization ( )
virtual

Destructor.

Definition at line 22 of file DTTime2DriftParametrization.cc.

22 {}

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

References DTTime2DriftParametrization::drift_distance::delta_x, 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.

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

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

References lumiQTWidget::t.

Referenced by MB_DT_drift_distance().

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

Definition at line 258 of file DTTime2DriftParametrization.cc.

Referenced by MB_DT_drift_distance().

258  {
259  return ( time * par[0] ); // par[0] is the drift velocity, 'dist' is the linear part of the drift distance
260 }
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 102 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().

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

Referenced by MB_DT_drift_distance().

const double DTTime2DriftParametrization::By_value[5]
staticprivate

Definition at line 111 of file DTTime2DriftParametrization.h.

Referenced by MB_DT_drift_distance().

const double DTTime2DriftParametrization::Bz_value[5]
staticprivate

Definition at line 112 of file DTTime2DriftParametrization.h.

Referenced by MB_DT_drift_distance().

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

Definition at line 116 of file DTTime2DriftParametrization.h.

Referenced by MB_DT_drift_distance().

const double DTTime2DriftParametrization::fun_x
staticprivate

Definition at line 115 of file DTTime2DriftParametrization.h.

Referenced by MB_DT_drift_distance().

const double DTTime2DriftParametrization::velocitySkew
staticprivate

Definition at line 119 of file DTTime2DriftParametrization.h.