CMS 3D CMS Logo

Classes | Public Member Functions | Private Member Functions | Static Private Attributes

DTTime2DriftParametrization Class Reference

#include <DTTime2DriftParametrization.h>

List of all members.

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.
virtual ~DTTime2DriftParametrization ()
 Destructor.

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.
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 [N_alpha]
static const double By_value [N_By]
static const double Bz_value [N_Bz]
static const double fun_sigma_t [N_alpha][N_By][N_Bz][N_Sigma_t]
static const double fun_x [N_alpha][N_By][N_Bz][N_Par_x]
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.

{}
DTTime2DriftParametrization::~DTTime2DriftParametrization ( ) [virtual]

Destructor.

Definition at line 22 of file DTTime2DriftParametrization.cc.

{}

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(), 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.

                                                                                      {
  // NOTE: This method takes care of convertion of the units in order to use the CMSSW conventions

  // The convention used by the parametrization for the reference frame are different
  // with respect to CMSSW
  // X_par = X_CMSSW; Y_par=Z_CMSSW; Z_par = -Y_CMSSW 
  float By_par = bz;  // Bnorm
  float Bz_par = -by; // Bwire
 
  // Express alpha in degrees
  float alpha_par = alpha * 180./Geom::pi();

  //--------------------------------------------------------------------
  // Calculate the drift distance and the resolution from the parametrization
  unsigned short flag =
    MB_DT_drift_distance(time, alpha_par, By_par, Bz_par, dx, interpolate);

  if(flag!=1)
    return false;

  // Convert from mm (used by the parametrization) to cm (used by CMSSW)
  dx->v_drift = dx->v_drift/10.;
  dx->x_drift = dx->x_drift/10.;
  dx->delta_x = dx->delta_x/10.;
  dx->x_width_m = dx->x_width_m/10.;
  dx->x_width_p = dx->x_width_p/10.;

  // Correct drift time for the difference between mode and mean
  dx->x_drift = std::max(0.,dx->x_drift - (dx->x_width_p-dx->x_width_m)*sqrt(2./Geom::pi()));

  return true;

 }
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(), pi, DTTime2DriftParametrization::drift_distance::v_drift, DTTime2DriftParametrization::drift_distance::x_drift, DTTime2DriftParametrization::drift_distance::x_width_m, and DTTime2DriftParametrization::drift_distance::x_width_p.

                                                                                      {
  // NOTE: This method takes care of convertion of the units in order to use the CMSSW conventions

  // The convention used by the parametrization for the reference frame are different
  // with respect to CMSSW
  // X_par = X_CMSSW; Y_par=Z_CMSSW; Z_par = -Y_CMSSW 
  float By_par = bz;  // Bnorm
  float Bz_par = -by; // Bwire
 
  // Express alpha in degrees 
  float alpha_par = alpha * 180./Geom::pi();

  //--------------------------------------------------------------------
  // Calculate the drift distance and the resolution from the parametrization
  unsigned short flag =
    MB_DT_drift_distance(time, alpha_par, By_par, Bz_par, dx, interpolate);

  if(flag!=1)
    return false;

  // Convert from mm (used by the parametrization) to cm (used by CMSSW)
  dx->v_drift = dx->v_drift/10.;
  dx->x_drift = dx->x_drift/10.;
  dx->delta_x = dx->delta_x/10.;
  dx->x_width_m = dx->x_width_m/10.;
  dx->x_width_p = dx->x_width_p/10.;

  return true;

 }
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 matplotRender::t.

Referenced by MB_DT_drift_distance().

                                                                              {
      double t2 = t*t;

#ifdef MB_DT_DEBUG
      printf("MB_DT_delta_x:  time = %f\n",t);
#endif

//
// Now distances are in microns. Divide by 1000 to get mm.
//
      if ( t <= par[12] ) { return ( -0.001 * (par[1] + par[2] *t + par[3] *t2) ); }
      if ( t <= par[13] ) { return ( -0.001 * (par[4] + par[5] *t + par[6] *t2 + par[7]*t2*t + par[8]*t2*t2) ); }
                            return ( -0.001 * (par[9] + par[10]*t + par[11]*t2) );
}
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().

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

                                                                                           {
      unsigned short i, j, n_func, ial, iby, ibz;
      unsigned short i_alpha, i_By, i_Bz;
      unsigned short j_alpha, j_By, j_Bz;

      double OffSet;
      double par_x[N_Par_x];
      double par_sigma_t[N_Sigma_t];

      double V_al[3], V_by[3], V_bz[3];

      double DXV_v_drift  [N_Func];
      double DXV_x_drift  [N_Func];
      double DXV_delta_x  [N_Func];
      double DXV_x_width_m[N_Func];
      double DXV_x_width_p[N_Func];

      DX->v_drift   = -1;
      DX->x_drift   = -1;
      DX->delta_x   = -1;
      DX->x_width_m = -1;
      DX->x_width_p = -1;

/* Check 'interpolate' and initialize DXV */

      switch(interpolate) {
         case 1:  n_func = N_Func;
                  for ( j=0 ; j<N_Func ; j++ ) {
                     DXV_v_drift[j]   = -1;
                     DXV_x_drift[j]   = -1;
                     DXV_delta_x[j]   = -1;
                     DXV_x_width_m[j] = -1;
                     DXV_x_width_p[j] = -1;
                  }
                  break ;

         case 0:  n_func = 1;
                  break ;

         default: printf ("*** ERROR, MB_DT_drift_distance:  invalid interpolate value = %d\n",interpolate);
                  return (0);
      }

#ifdef MB_DT_DEBUG

/* Dump input values */

      printf ("\nMB_DT_drift_distance:  Function called with values:\n\n");
      printf ("MB_DT_drift_distance:    time  = %f\n",time );
      printf ("MB_DT_drift_distance:    alpha = %f\n",alpha);
      printf ("MB_DT_drift_distance:    by    = %f\n",by   );
      printf ("MB_DT_drift_distance:    bz    = %f\n",bz   );

#endif

/* Take into account the symmetries of the parametrisations */

      by = fabs(by);         //  f-1 (By) = f-1 (-By)

      if ( bz < 0 ) {        //  f-1 (alpha,Bz) = f-1 (-alpha, -Bz)
         bz    = -bz;
         alpha = -alpha;
      }

/* Check boundaries of the variables and take the closest values */

      MB_DT_Check_boundaries (time, alpha, by, bz, -1) ;

      MB_DT_Get_grid_points (alpha, by, bz, &i_alpha, &i_By, &i_Bz, &j_alpha, &j_By, &j_Bz) ;

#ifdef MB_DT_DEBUG
      printf("MB_DT_drift_distance:\n");
      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]);
      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]);
      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]);
#endif

/* Get the parametrisations for the different grid points */

      for ( j=0 ; j<n_func ; j++ ) {

         ial = (j&4) ? j_alpha : i_alpha;
         iby = (j&2) ? j_By    : i_By   ;
         ibz = (j&1) ? j_Bz    : i_Bz   ;

         for ( i=0 ; i<N_Par_x   ; i++ ) par_x[i]       =       fun_x[ial][iby][ibz][i];
         for ( i=0 ; i<N_Sigma_t ; i++ ) par_sigma_t[i] = fun_sigma_t[ial][iby][ibz][i];

         OffSet = par_x[N_Par_x-1];

         DXV_v_drift[j]   = par_x[0];                                                       // drift velocity
         DXV_delta_x[j]   = MB_DT_delta_x (time, par_x);                                    // deviation from linearity
         DXV_x_drift[j]   = MB_DT_dist (time, par_x) + DXV_delta_x[j] - OffSet*par_x[0];    // drift distance to the wire (signed)
         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)
         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)

#ifdef MB_DT_DEBUG
         printf("MB_DT_drift_LOOP: OffSet = %f\n",OffSet);
         printf("MB_DT_drift_LOOP: time, v_drift, x_drift, lin, x_width_m, x_width_p = %f %f %f %f %f %f\n",
                                   time, DXV_v_drift[j], DXV_x_drift[j], DXV_delta_x[j], DXV_x_width_m[j], DXV_x_width_p[j]) ;
#endif
      }

/* Return interpolated or grid values */

      if ( interpolate == 0 ) {

         DX->v_drift   = DXV_v_drift[0];
         DX->delta_x   = DXV_delta_x[0];
         DX->x_drift   = DXV_x_drift[0];
         DX->x_width_m = DXV_x_width_m[0];
         DX->x_width_p = DXV_x_width_p[0];
      }
      else {

         V_al[0] = alpha ; V_al[1] = alpha_value[i_alpha] ; V_al[2] = alpha_value[j_alpha];
         V_by[0] = by    ; V_by[1] =    By_value[i_By]    ; V_by[2] =    By_value[j_By];
         V_bz[0] = bz    ; V_bz[1] =    Bz_value[i_Bz]    ; V_bz[2] =    Bz_value[j_Bz];

         DX->v_drift   = MB_DT_MLInterpolation (V_al, V_by, V_bz, DXV_v_drift  );
         DX->delta_x   = MB_DT_MLInterpolation (V_al, V_by, V_bz, DXV_delta_x  );
         DX->x_drift   = MB_DT_MLInterpolation (V_al, V_by, V_bz, DXV_x_drift  );
         DX->x_width_m = MB_DT_MLInterpolation (V_al, V_by, V_bz, DXV_x_width_m);
         DX->x_width_p = MB_DT_MLInterpolation (V_al, V_by, V_bz, DXV_x_width_p);
      }

#ifdef MB_DT_DEBUG
      printf("MB_DT_drift_distance: time, v_drift, x_drift, lin, x_width_m, x_width_p = %f %f %f %f %f %f\n",
                                    time, DX->v_drift, DX->x_drift, DX->delta_x, DX->x_width_m, DX->x_width_p) ;
#endif

      return (1);
}
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[N_alpha] [static, private]

Definition at line 110 of file DTTime2DriftParametrization.h.

Referenced by MB_DT_drift_distance().

const double DTTime2DriftParametrization::By_value[N_By] [static, private]

Definition at line 111 of file DTTime2DriftParametrization.h.

Referenced by MB_DT_drift_distance().

const double DTTime2DriftParametrization::Bz_value[N_Bz] [static, private]

Definition at line 112 of file DTTime2DriftParametrization.h.

Referenced by MB_DT_drift_distance().

const double DTTime2DriftParametrization::fun_sigma_t[N_alpha][N_By][N_Bz][N_Sigma_t] [static, private]

Definition at line 116 of file DTTime2DriftParametrization.h.

Referenced by MB_DT_drift_distance().

const double DTTime2DriftParametrization::fun_x [static, private]

Definition at line 115 of file DTTime2DriftParametrization.h.

Referenced by MB_DT_drift_distance().

const double DTTime2DriftParametrization::velocitySkew [static, private]

Definition at line 119 of file DTTime2DriftParametrization.h.