CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Attributes
DTTracoLUTs Class Reference

#include <DTTracoLUTs.h>

Public Member Functions

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

Private Attributes

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

Detailed Description

Look-up tables for traco angle and position

Author
S. Vanini - INFN Padova

Definition at line 34 of file DTTracoLUTs.h.

Constructor & Destructor Documentation

DTTracoLUTs::DTTracoLUTs ( std::string  filename)

constructor

Definition at line 45 of file DTTracoLUTs.cc.

45  :
47 }
std::string _testfile
Definition: DTTracoLUTs.h:71
DTTracoLUTs::~DTTracoLUTs ( )
virtual

destructor

Definition at line 54 of file DTTracoLUTs.cc.

References hitfit::clear(), relval_steps::k, phi_lut, and psi_lut.

54  {
55 
56  psi_lut.clear();
57  for(int k=0;k<3;k++)
58  phi_lut[k].clear();
59 }
LUT phi_lut[3]
Definition: DTTracoLUTs.h:69
void clear(CLHEP::HepGenMatrix &m)
Helper function: Reset all elements of a matrix to 0.
Definition: matutil.cc:167

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, and psi_lut.

182  {
183  // bendAng = psi - phi : psi ha risoluzione 12, phi 9, quindi devo riportarli alla
184  // stessa risoluzione con : phi/8 (scarto i 3 bit meno significativi).
185  // Il risultato ha risoluzione 10 bits.
186  unsigned short int BendAng = ( (psi_lut)[ang+512] - ((phi_lut[flag])[pos]/8) ) & 0x3FF; //10 bits
187 
188  //cout << "Bending angle is:" << hex << BendAng << endl;
189  //cout << "Abs of bending angle is:" << hex << abs(BendAng) << endl;
190 
191 
192  return BendAng;
193 }
LUT phi_lut[3]
Definition: DTTracoLUTs.h:69
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.

150  {
151  unsigned short int phi = (phi_lut[flag])[pos] & 0xFFF; //12 bits
152  //int sgn = (phi_lut[flag])[pos] & 0x800; //bit 12 for sign
153  //if(sgn)
154  //phi = - phi;
155 
156  return phi;
157 }
LUT phi_lut[3]
Definition: DTTracoLUTs.h:69
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.

162  {
163 
164  unsigned short int ipsi = (psi_lut)[ang+512]; //scritto in complemento a due
165 /*
166  //debug: try with formula
167  float fpsi = atan( ((float)(ang) * 4.2) /(18 * 1.3 * 30 ));
168  fpsi*=512;
169  if(fpsi<=0)fpsi-=1.0;
170  int ipsi = (int)fpsi;
171  // if outside range set to lower edge
172  if( ipsi>= 512 ||
173  ipsi< -512 ) ipsi=-512;
174 cout << "psi is="<<ipsi <<endl;
175 */
176  return ipsi;
177 }
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 y.

80  {
81 
82  // get file name in current directory
83  string ang_file = _testfile + ".anglut";
84  string pos_file = _testfile + ".poslut";
85 
86  // open file for PSI
87  DTTPGLutFile filePSI(ang_file);
88  if ( filePSI.open() != 0 ) return -1;
89 
90  // ignore comment lines
91  //filePSI.ignoreLines(14);
92 
93  // read file for PSI values ---> psi is 10 bits, 9+sign(10,11...16), resolution 9 bits,
94  for(int u=0;u<1024;u++){
95  int word = filePSI.readHex(); //read a 16 bits word
96  //int psi = word & 0x01FF; //bits 0,1,...8
97  //int sgn = word & 0x0200; //bit 9
98  //if(sgn)
99  //psi = -psi;
100  psi_lut.push_back(word); //positive value
101  }
102  filePSI.close();
103 
104  // open file for PHI
105  DTTPGLutFile filePHI(pos_file);
106  if ( filePHI.open() != 0 ) return -1;
107 
108  // read file for PHI values ---> phi is 12 bits, 11+sign(12..16), resolution 12 bits
109  for(int y=0;y<3;y++){ //3 series of values: I-outer, II-innner, III-correlated
110  for(int h=0;h<512;h++){
111  int phi = filePHI.readHex();
112  //phi &= 0x0FFF; //get 12 bits
113  //int sgn = phi;
114  //sgn >> 11; //bit 12 for sign
115  //sgn &= 0x01;
116  //if(sgn==1) //negative value
117  //phi = -phi;
118  phi_lut[y].push_back(phi); //positive value
119  }
120  }
121  filePHI.close();
122  return 0;
123 }
LUT phi_lut[3]
Definition: DTTracoLUTs.h:69
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4
std::string _testfile
Definition: DTTracoLUTs.h:71
void DTTracoLUTs::print ( void  ) const

print look-up tables

Definition at line 129 of file DTTracoLUTs.cc.

References gather_cfg::cout, TauDecayModes::dec, visualization-live-secondInstance_cfg::m, phi_lut, psi_lut, and x.

129  {
130 
131  cout << endl;
132  cout << "L1 barrel Traco look-up tables :" << endl;
133  cout << "====================================================" << endl;
134  cout << endl;
135 
136 // int i = 0;
137  // for debugging
138  for(int x=0;x<1024;x++)
139  cout << "K=" << x << " ---> " << hex << psi_lut[x] << dec << endl;
140  for(int m=0;m<512;m++)
141  cout << "X=" << m << " ---> " << hex << (phi_lut[0])[m] << " "
142  << (phi_lut[1])[m] << " "
143  << (phi_lut[2])[m] << " " << dec << endl;
144 
145 }
LUT phi_lut[3]
Definition: DTTracoLUTs.h:69
tuple cout
Definition: gather_cfg.py:121
void DTTracoLUTs::reset ( void  )

reset look-up tables

Definition at line 69 of file DTTracoLUTs.cc.

References hitfit::clear(), relval_steps::k, phi_lut, and psi_lut.

69  {
70 
71  psi_lut.clear();
72  for(int k=0;k<3;k++)
73  phi_lut[k].clear();
74 }
LUT phi_lut[3]
Definition: DTTracoLUTs.h:69
void clear(CLHEP::HepGenMatrix &m)
Helper function: Reset all elements of a matrix to 0.
Definition: matutil.cc:167
int DTTracoLUTs::size_phiLUT ( int  i) const
inline

Definition at line 65 of file DTTracoLUTs.h.

References i, and phi_lut.

65 { return phi_lut[i].size(); }
int i
Definition: DBlmapReader.cc:9
LUT phi_lut[3]
Definition: DTTracoLUTs.h:69
int DTTracoLUTs::size_psiLUT ( ) const
inline

return number of entries in the LUT

Definition at line 64 of file DTTracoLUTs.h.

References psi_lut.

64 { return psi_lut.size(); }

Member Data Documentation

std::string DTTracoLUTs::_testfile
private

Definition at line 71 of file DTTracoLUTs.h.

Referenced by load().

LUT DTTracoLUTs::phi_lut[3]
private

Definition at line 69 of file DTTracoLUTs.h.

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

LUT DTTracoLUTs::psi_lut
private

Definition at line 70 of file DTTracoLUTs.h.

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