Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 14:30:14

0001 //-------------------------------------------------
0002 //
0003 //   Class: DTAngleParam.cc
0004 //
0005 //   Description:
0006 //       Provide time_vs_x_b functions for different angle values
0007 //
0008 //
0009 //   Author List:
0010 //   P. Ronchese           INFN - PADOVA
0011 //   Modifications:
0012 //
0013 //
0014 //--------------------------------------------------
0015 
0016 //-----------------------
0017 // This Class's Header --
0018 //-----------------------
0019 #include "DTAngleParam.h"
0020 
0021 //-------------
0022 // C Headers --
0023 //-------------
0024 #include <cmath>
0025 
0026 //---------------
0027 // C++ Headers --
0028 //---------------
0029 #include <iostream>
0030 
0031 //-------------------------------
0032 // Collaborating Class Headers --
0033 //-------------------------------
0034 
0035 //----------------
0036 // Constructors --
0037 //----------------
0038 
0039 DTAngleParam::DTAngleParam()
0040     :  // default constructor : assume 0 angle
0041       _angle(0.0),
0042       l_func(9),
0043       h_func(10) {}
0044 
0045 DTAngleParam::DTAngleParam(float angle) {
0046   // determine angle bin in -45/+45 range by steps of 5
0047 
0048   int i_ang = static_cast<int>(angle + 45.0);
0049   int l_bin;
0050 
0051   if (i_ang < 0)
0052     l_bin = 0;
0053   else if (i_ang >= 90)
0054     l_bin = 17;
0055   else
0056     l_bin = i_ang / 5;
0057 
0058   int h_bin = l_bin + 1;
0059 
0060   // store actual angle and function parameters for lower/higher bin bounds
0061   _angle = angle;
0062   l_func = ParamFunc(l_bin);
0063   h_func = ParamFunc(h_bin);
0064 }
0065 
0066 //--------------
0067 // Destructor --
0068 //--------------
0069 
0070 DTAngleParam::~DTAngleParam() {}
0071 
0072 //--------------
0073 // Operations --
0074 //--------------
0075 
0076 float DTAngleParam::time(float bwire, float xcoor) const {
0077   // compute drift time for lower/higher bin bounds
0078   float l_time = l_func.time(bwire, xcoor);
0079   float h_time = h_func.time(bwire, xcoor);
0080 
0081   // interpolate times for actual angle
0082   return l_time + ((h_time - l_time) * l_func.dist(_angle) / l_func.dist(h_func));
0083 }
0084 
0085 const int DTAngleParam::table_num_terms[19] = {7, 7, 6, 7, 8, 7, 5, 6, 5, 7, 4, 2, 7, 8, 6, 6, 6, 8, 7};
0086 
0087 const int DTAngleParam::table_pow_field[190] = {
0088     0,  0,  0,  0,  1,  1,  1,  -1, -1, -1, 0,  0,  0,  0,  1,  1,  1,  -1, -1, -1, 0,  0,  0,  0,  2,  2,  -1, -1,
0089     -1, -1, 0,  0,  0,  1,  1,  0,  1,  -1, -1, -1, 0,  0,  0,  0,  2,  1,  1,  1,  -1, -1, 0,  0,  3,  0,  0,  2,
0090     1,  -1, -1, -1, 0,  0,  1,  1,  1,  -1, -1, -1, -1, -1, 0,  0,  0,  0,  1,  1,  -1, -1, -1, -1, 0,  0,  1,  1,
0091     1,  -1, -1, -1, -1, -1, 0,  0,  0,  2,  0,  3,  1,  -1, -1, -1, 0,  0,  0,  0,  -1, -1, -1, -1, -1, -1, 0,  0,
0092     -1, -1, -1, -1, -1, -1, -1, -1, 0,  0,  0,  0,  2,  1,  3,  -1, -1, -1, 0,  0,  0,  0,  3,  1,  1,  2,  -1, -1,
0093     0,  0,  0,  1,  0,  1,  -1, -1, -1, -1, 0,  0,  0,  0,  1,  1,  -1, -1, -1, -1, 0,  0,  0,  0,  1,  1,  -1, -1,
0094     -1, -1, 0,  0,  0,  0,  1,  1,  1,  2,  -1, -1, 0,  0,  0,  0,  1,  1,  1,  -1, -1, -1};
0095 
0096 const int DTAngleParam::table_pow_xcoor[190] = {
0097     0,  1,  3,  2,  0,  1,  2,  -1, -1, -1, 0,  1,  3,  2,  0,  1,  2,  -1, -1, -1, 0,  1,  3,  2,  0,  1,  -1, -1,
0098     -1, -1, 0,  1,  3,  0,  1,  2,  2,  -1, -1, -1, 0,  1,  3,  2,  1,  0,  1,  2,  -1, -1, 0,  1,  0,  3,  2,  1,
0099     0,  -1, -1, -1, 0,  1,  0,  1,  2,  -1, -1, -1, -1, -1, 0,  1,  3,  2,  0,  2,  -1, -1, -1, -1, 0,  1,  0,  1,
0100     2,  -1, -1, -1, -1, -1, 0,  1,  3,  1,  2,  0,  2,  -1, -1, -1, 0,  1,  3,  2,  -1, -1, -1, -1, -1, -1, 0,  1,
0101     -1, -1, -1, -1, -1, -1, -1, -1, 0,  1,  3,  2,  0,  2,  0,  -1, -1, -1, 0,  1,  3,  2,  0,  0,  2,  0,  -1, -1,
0102     0,  1,  3,  0,  2,  2,  -1, -1, -1, -1, 0,  1,  3,  2,  0,  1,  -1, -1, -1, -1, 0,  1,  3,  2,  0,  1,  -1, -1,
0103     -1, -1, 0,  1,  3,  2,  0,  1,  2,  0,  -1, -1, 0,  1,  3,  2,  0,  1,  2,  -1, -1, -1};
0104 
0105 const float DTAngleParam::table_offsc[19] = {-1.6341677E-03,
0106                                              -1.9150710E-03,
0107                                              -1.9032805E-03,
0108                                              -1.9542247E-03,
0109                                              -1.9582238E-03,
0110                                              -1.8554466E-03,
0111                                              -1.9125413E-03,
0112                                              -1.9741140E-03,
0113                                              -1.9815513E-03,
0114                                              -1.9835865E-03,
0115                                              -1.9833876E-03,
0116                                              -1.8502035E-03,
0117                                              -1.9108272E-03,
0118                                              -1.9580512E-03,
0119                                              -1.9557050E-03,
0120                                              -1.8146527E-03,
0121                                              -1.7686716E-03,
0122                                              -1.7501116E-03,
0123                                              -1.6865443E-03};
0124 
0125 const float DTAngleParam::table_coeff[190] = {0.32362,
0126                                               -0.10029,
0127                                               0.33372E-01,
0128                                               -0.97290E-01,
0129                                               0.14761,
0130                                               -0.15878,
0131                                               0.43523E-01,
0132                                               0,
0133                                               0,
0134                                               0,
0135 
0136                                               0.32860,
0137                                               -0.11620,
0138                                               0.25506E-01,
0139                                               -0.75019E-01,
0140                                               0.11910,
0141                                               -0.98917E-01,
0142                                               0.18437E-01,
0143                                               0,
0144                                               0,
0145                                               0,
0146 
0147                                               0.34235,
0148                                               -0.14353,
0149                                               0.17375E-01,
0150                                               -0.48856E-01,
0151                                               0.27060,
0152                                               -0.14935,
0153                                               0,
0154                                               0,
0155                                               0,
0156                                               0,
0157 
0158                                               0.34117,
0159                                               -0.15159,
0160                                               0.11491E-01,
0161                                               0.89598E-01,
0162                                               -0.67190E-01,
0163                                               -0.32898E-01,
0164                                               0.10769E-01,
0165                                               0,
0166                                               0,
0167                                               0,
0168 
0169                                               0.34218,
0170                                               -0.14871,
0171                                               0.99750E-02,
0172                                               -0.31434E-01,
0173                                               0.41733E-01,
0174                                               0.76480E-01,
0175                                               -0.90189E-01,
0176                                               0.21807E-01,
0177                                               0,
0178                                               0,
0179 
0180                                               0.34941,
0181                                               -0.15649,
0182                                               0.31413,
0183                                               0.99644E-02,
0184                                               -0.29251E-01,
0185                                               -0.56078E-01,
0186                                               0.11125E-01,
0187                                               0,
0188                                               0,
0189                                               0,
0190 
0191                                               0.35068,
0192                                               -0.17724,
0193                                               0.59457E-01,
0194                                               -0.73007E-01,
0195                                               0.24587E-01,
0196                                               0,
0197                                               0,
0198                                               0,
0199                                               0,
0200                                               0,
0201 
0202                                               0.35073,
0203                                               -0.16944,
0204                                               0.46646E-02,
0205                                               -0.12188E-01,
0206                                               0.26793E-01,
0207                                               -0.90753E-02,
0208                                               0,
0209                                               0,
0210                                               0,
0211                                               0,
0212 
0213                                               0.35095,
0214                                               -0.17652,
0215                                               0.34244E-01,
0216                                               -0.25854E-01,
0217                                               0.33369E-02,
0218                                               0,
0219                                               0,
0220                                               0,
0221                                               0,
0222                                               0,
0223 
0224                                               0.35302,
0225                                               -0.17322,
0226                                               0.19561E-02,
0227                                               -0.59183E-01,
0228                                               -0.63050E-02,
0229                                               0.16520,
0230                                               0.62952E-02,
0231                                               0,
0232                                               0,
0233                                               0,
0234 
0235                                               0.34995,
0236                                               -0.16756,
0237                                               0.35931E-02,
0238                                               -0.11169E-01,
0239                                               0,
0240                                               0,
0241                                               0,
0242                                               0,
0243                                               0,
0244                                               0,
0245 
0246                                               0.34867,
0247                                               -0.17543,
0248                                               0,
0249                                               0,
0250                                               0,
0251                                               0,
0252                                               0,
0253                                               0,
0254                                               0,
0255                                               0,
0256 
0257                                               0.34773,
0258                                               -0.16523,
0259                                               0.46184E-02,
0260                                               -0.14212E-01,
0261                                               -0.11195,
0262                                               0.60685E-02,
0263                                               0.20589,
0264                                               0,
0265                                               0,
0266                                               0,
0267 
0268                                               0.34647,
0269                                               -0.16158,
0270                                               0.57246E-02,
0271                                               -0.17762E-01,
0272                                               -0.41158,
0273                                               -0.41086E-01,
0274                                               0.72317E-02,
0275                                               0.17672,
0276                                               0,
0277                                               0,
0278 
0279                                               0.34311,
0280                                               -0.15890,
0281                                               0.67728E-02,
0282                                               -0.27006E-01,
0283                                               -0.20412E-01,
0284                                               0.77523E-02,
0285                                               0,
0286                                               0,
0287                                               0,
0288                                               0,
0289 
0290                                               0.33889,
0291                                               -0.14902,
0292                                               0.10912E-01,
0293                                               -0.32543E-01,
0294                                               -0.47053E-01,
0295                                               0.26043E-01,
0296                                               0,
0297                                               0,
0298                                               0,
0299                                               0,
0300 
0301                                               0.33616,
0302                                               -0.13829,
0303                                               0.15988E-01,
0304                                               -0.47280E-01,
0305                                               -0.71785E-01,
0306                                               0.40111E-01,
0307                                               0,
0308                                               0,
0309                                               0,
0310                                               0,
0311 
0312                                               0.33327,
0313                                               -0.13235,
0314                                               0.23152E-01,
0315                                               -0.62435E-01,
0316                                               -0.11302,
0317                                               0.10277,
0318                                               -0.30199E-01,
0319                                               0.52548E-01,
0320                                               0,
0321                                               0,
0322 
0323                                               0.33239,
0324                                               -0.14388,
0325                                               0.22312E-01,
0326                                               -0.55883E-01,
0327                                               -0.95301E-01,
0328                                               0.92658E-01,
0329                                               -0.21228E-01,
0330                                               0,
0331                                               0,
0332                                               0};
0333 
0334 DTAngleParam::ParamFunc::ParamFunc() {
0335   /*
0336    // default constructor: assume central bin ( 0 angle )
0337    bin_angle = 0.0;
0338    num_terms = table_num_terms+ 9;
0339    pow_field = table_pow_field+ 90;
0340    pow_xcoor = table_pow_xcoor+ 90;
0341    offsc     = table_offsc    + 9;
0342    coeff     = table_coeff    + 90;
0343   */
0344 }
0345 
0346 DTAngleParam::ParamFunc::ParamFunc(int bin) {
0347   // store bound
0348   bin_angle = (bin * 5.0) - 45.0;
0349   // select parameters inside tables
0350   num_terms = table_num_terms + bin;
0351   pow_field = table_pow_field + (bin * 10);
0352   pow_xcoor = table_pow_xcoor + (bin * 10);
0353   offsc = table_offsc + bin;
0354   coeff = table_coeff + (bin * 10);
0355 }
0356 
0357 /*
0358 void DTAngleParam::ParamFunc::set(int bin) {
0359 
0360  // reset bound
0361  bin_angle = (bin*5.0)-45.0;
0362  // select parameters inside tables
0363  num_terms = table_num_terms+ bin;
0364  pow_field = table_pow_field+(bin*10);
0365  pow_xcoor = table_pow_xcoor+(bin*10);
0366  offsc     = table_offsc    + bin;
0367  coeff     = table_coeff    +(bin*10);
0368 
0369 }
0370 */
0371 
0372 DTAngleParam::ParamFunc::~ParamFunc() {}
0373 
0374 float DTAngleParam::ParamFunc::time(float bwire, float xcoor) const {
0375   // compute drift time
0376 
0377   // set constant offset
0378   float y = *offsc;
0379 
0380   // build up polynomial
0381   int i;
0382   // int j;
0383   // float x;
0384   for (i = 0; i < *num_terms; i++) {
0385     //  x = 1.0;
0386     //  for ( j = 0 ; j < pow_field[i] ; j++ ) x *= bwire;
0387     //  for ( j = 0 ; j < pow_xcoor[i] ; j++ ) x *= xcoor;
0388     //  y += (*coeff)*x;
0389     y += coeff[i] * pow(bwire, pow_field[i]) * pow(xcoor, pow_xcoor[i]);
0390   }
0391 
0392   return y;
0393 }