CMS 3D CMS Logo

Public Member Functions | Private Attributes

DTTracoLUTs Class Reference

#include <DTTracoLUTs.h>

List of all members.

Public Member Functions

 DTTracoLUTs (std::string filename)
 constructor
unsigned short int getBendAng (int pos, int ang, int qualflag) const
 return bending angle from pos and ang
unsigned short int getPhiRad (int pos, int qualflag) const
 get radial angle from traco position and flag: 0=outer, 1=inner, 2=correl.
unsigned short int getPsi (int ang) const
 get psi angle from traco k parameter
int load ()
 load look-up tables
void print () const
 print look-up tables
void reset ()
 reset look-up tables
int size_phiLUT (int i) const
int size_psiLUT () const
 return number of entries in the LUT
virtual ~DTTracoLUTs ()
 destructor

Private Attributes

std::string _testfile
LUT phi_lut [3]
LUT psi_lut

Detailed Description

Look-up tables for traco angle and position

Date:
2006/07/19 10:24:02
Revision:
1.1
Author:
S. Vanini - INFN Padova

Definition at line 36 of file DTTracoLUTs.h.


Constructor & Destructor Documentation

DTTracoLUTs::DTTracoLUTs ( std::string  filename)

constructor

Definition at line 45 of file DTTracoLUTs.cc.

                                       :
                        _testfile(testfile) {
}
DTTracoLUTs::~DTTracoLUTs ( ) [virtual]

destructor

Definition at line 54 of file DTTracoLUTs.cc.

References gen::k, phi_lut, and psi_lut.

                          {

  psi_lut.clear();
  for(int k=0;k<3;k++)
    phi_lut[k].clear();
}

Member Function Documentation

unsigned short int DTTracoLUTs::getBendAng ( int  pos,
int  ang,
int  qualflag 
) const

return bending angle from pos and ang

Definition at line 182 of file DTTracoLUTs.cc.

References phi_lut, pos, and psi_lut.

                                                                           {
  // bendAng = psi - phi  : psi ha risoluzione 12, phi 9, quindi devo riportarli alla
  // stessa risoluzione con : phi/8 (scarto i 3 bit meno significativi). 
  // Il risultato ha risoluzione 10 bits. 
  unsigned short int BendAng = ( (psi_lut)[ang+512] - ((phi_lut[flag])[pos]/8) ) & 0x3FF;    //10 bits
   
  //cout << "Bending angle is:" << hex << BendAng << endl; 
  //cout << "Abs of bending angle is:" << hex << abs(BendAng) << endl; 


  return BendAng;
}
unsigned short int DTTracoLUTs::getPhiRad ( int  pos,
int  qualflag 
) const

get radial angle from traco position and flag: 0=outer, 1=inner, 2=correl.

Definition at line 150 of file DTTracoLUTs.cc.

References phi, and phi_lut.

                                                                {
  unsigned short int phi = (phi_lut[flag])[pos]  &  0xFFF;     //12 bits
  //int sgn = (phi_lut[flag])[pos]  &  0x800;     //bit 12 for sign
  //if(sgn)
    //phi = - phi;

  return phi;
}
unsigned short int DTTracoLUTs::getPsi ( int  ang) const

get psi angle from traco k parameter

Definition at line 162 of file DTTracoLUTs.cc.

References psi_lut.

                                                    {

  unsigned short int ipsi = (psi_lut)[ang+512]; //scritto in complemento a due 
/*
  //debug: try with formula
  float fpsi = atan( ((float)(ang) * 4.2) /(18 * 1.3 * 30 ));
  fpsi*=512;
  if(fpsi<=0)fpsi-=1.0;
  int ipsi = (int)fpsi;
  // if outside range set to lower edge
  if( ipsi>= 512 ||
      ipsi< -512 ) ipsi=-512;
cout << "psi is="<<ipsi <<endl;
*/
   return ipsi;
}
int DTTracoLUTs::load ( )

load look-up tables

Definition at line 80 of file DTTracoLUTs.cc.

References _testfile, DTTPGLutFile::close(), h, DTTPGLutFile::open(), phi, phi_lut, psi_lut, DTTPGLutFile::readHex(), and detailsBasic3DVector::y.

                      {

  // get file name in current directory
  string ang_file = _testfile + ".anglut";
  string pos_file = _testfile + ".poslut";
 
  // open file for PSI 
  DTTPGLutFile filePSI(ang_file);
  if ( filePSI.open() != 0 ) return -1;

  // ignore comment lines 
  //filePSI.ignoreLines(14);

  // read file for PSI values --->   psi is 10 bits, 9+sign(10,11...16), resolution 9 bits, 
  for(int u=0;u<1024;u++){
      int word  = filePSI.readHex();  //read a 16 bits word
      //int psi = word & 0x01FF;    //bits  0,1,...8
      //int sgn = word & 0x0200;    //bit 9
      //if(sgn)
        //psi = -psi;
      psi_lut.push_back(word);      //positive value
  }
  filePSI.close();
 
  // open file for PHI 
  DTTPGLutFile filePHI(pos_file);
  if ( filePHI.open() != 0 ) return -1;

  // read file for PHI values    --->  phi is 12 bits, 11+sign(12..16), resolution 12 bits
  for(int y=0;y<3;y++){     //3 series of values: I-outer, II-innner, III-correlated
    for(int h=0;h<512;h++){
        int phi  = filePHI.readHex();
        //phi &= 0x0FFF;                //get 12 bits
        //int sgn = phi;
        //sgn >> 11;                    //bit 12 for sign
        //sgn &= 0x01;
        //if(sgn==1)                    //negative value
          //phi = -phi;
        phi_lut[y].push_back(phi);  //positive value
    }
  } 
  filePHI.close();
  return 0;
}
void DTTracoLUTs::print ( void  ) const

print look-up tables

Definition at line 129 of file DTTracoLUTs.cc.

References gather_cfg::cout, m, phi_lut, psi_lut, and x.

                              {

  cout << endl;
  cout << "L1 barrel Traco look-up tables :" << endl;
  cout << "====================================================" << endl;
  cout << endl;

//  int i = 0;
  //  for debugging
  for(int x=0;x<1024;x++)
    cout << "K=" << x << " ---> " << hex << psi_lut[x] << dec << endl;
  for(int m=0;m<512;m++)
    cout << "X=" << m << " ---> " << hex << (phi_lut[0])[m] << "  " 
                                  << (phi_lut[1])[m] << "  " 
                                  << (phi_lut[2])[m] << "  " << dec << endl; 

}
void DTTracoLUTs::reset ( void  )

reset look-up tables

Definition at line 69 of file DTTracoLUTs.cc.

References gen::k, phi_lut, and psi_lut.

                        {

  psi_lut.clear();
  for(int k=0;k<3;k++)
    phi_lut[k].clear();
}
int DTTracoLUTs::size_phiLUT ( int  i) const [inline]

Definition at line 67 of file DTTracoLUTs.h.

References i, and phi_lut.

{ return phi_lut[i].size(); }
int DTTracoLUTs::size_psiLUT ( ) const [inline]

return number of entries in the LUT

Definition at line 66 of file DTTracoLUTs.h.

References psi_lut.

{ return psi_lut.size(); }

Member Data Documentation

std::string DTTracoLUTs::_testfile [private]

Definition at line 73 of file DTTracoLUTs.h.

Referenced by load().

LUT DTTracoLUTs::phi_lut[3] [private]

Definition at line 71 of file DTTracoLUTs.h.

Referenced by getBendAng(), getPhiRad(), load(), print(), reset(), size_phiLUT(), and ~DTTracoLUTs().

Definition at line 72 of file DTTracoLUTs.h.

Referenced by getBendAng(), getPsi(), load(), print(), reset(), size_psiLUT(), and ~DTTracoLUTs().