Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #include "L1TriggerConfig/DTTPGConfig/interface/DTConfigLUTs.h"
00018
00019
00020
00021
00022 #include <math.h>
00023 #include <cstring>
00024
00025
00026
00027
00028
00029 #include "FWCore/Utilities/interface/Exception.h"
00030
00031
00032
00033
00034 DTConfigLUTs::DTConfigLUTs(const edm::ParameterSet& ps) {
00035 setDefaults(ps);
00036 }
00037
00038 DTConfigLUTs::DTConfigLUTs(bool debugLUTS, unsigned short int * buffer) {
00039
00040 m_debug = debugLUTS;
00041
00042
00043 if (buffer[2]!=0xA8){
00044 throw cms::Exception("DTTPG") << "===> ConfigLUTs constructor : not a LUT string!" << std::endl;
00045 }
00046
00047
00048 short int memory_lut[7];
00049 int c=3;
00050 for(int i=0;i<7;i++){
00051 memory_lut[i] = (buffer[c]<<8) | buffer[c+1];
00052 c += 2;
00053
00054 }
00055
00056
00057 int btic = memory_lut[0];
00058 float d;
00059 DSPtoIEEE32( memory_lut[1], memory_lut[2], &d );
00060 float Xcn;
00061 DSPtoIEEE32( memory_lut[3], memory_lut[4], &Xcn );
00062 int wheel = memory_lut[5];
00063
00064
00065 setBTIC(btic);
00066 setD(d);
00067 setXCN(Xcn);
00068 setWHEEL(wheel);
00069
00070 return;
00071 }
00072
00073
00074
00075
00076 DTConfigLUTs::~DTConfigLUTs() {}
00077
00078
00079
00080
00081
00082 void
00083 DTConfigLUTs::setDefaults(const edm::ParameterSet& m_ps) {
00084
00085
00086 m_debug = m_ps.getUntrackedParameter<bool>("Debug");
00087
00088
00089 m_btic = m_ps.getUntrackedParameter<int>("BTIC");
00090
00091
00092 m_d = m_ps.getUntrackedParameter<double>("D");
00093
00094
00095 m_Xcn = m_ps.getUntrackedParameter<double>("XCN");
00096
00097
00098 m_wheel = m_ps.getUntrackedParameter<int>("WHEEL");
00099 }
00100
00101 void
00102 DTConfigLUTs::print() const {
00103
00104 std::cout << "******************************************************************************" << std::endl;
00105 std::cout << "* DTTrigger configuration : LUT parameters *" << std::endl;
00106 std::cout << "******************************************************************************" << std::endl << std::endl;
00107 std::cout << "Debug flag : " << debug() << std::endl;
00108 std::cout << "BTIC parameter : " << m_btic << std::endl;
00109 std::cout << "d: distance vertex to normal, unit cm. " << m_d << std::endl;
00110 std::cout << "Xcn: distance vertex to normal, unit cm. " << m_Xcn << std::endl;
00111 std::cout << "wheel sign " << m_wheel << std::endl;
00112 std::cout << "******************************************************************************" << std::endl;
00113 }
00114
00115 void
00116 DTConfigLUTs::DSPtoIEEE32(short DSPmantissa, short DSPexp, float *f)
00117 {
00118 DSPexp -= 15;
00119 *f = DSPmantissa * (float)pow( 2.0, DSPexp );
00120 return;
00121 }
00122
00123
00124 void
00125 DTConfigLUTs::IEEE32toDSP(float f, short int & DSPmantissa, short int & DSPexp)
00126 {
00127 long int *pl=0, lm;
00128 bool sign=false;
00129
00130 DSPmantissa = 0;
00131 DSPexp = 0;
00132
00133 if( f!=0.0 )
00134 {
00135
00136 memcpy(pl,&f,sizeof(float));
00137 if((*pl & 0x80000000)!=0)
00138 sign=true;
00139 lm = ( 0x800000 | (*pl & 0x7FFFFF));
00140 lm >>= 9;
00141 lm &= 0x7FFF;
00142 DSPexp = ((*pl>>23)&0xFF)-126;
00143 DSPmantissa = (short)lm;
00144 if(sign)
00145 DSPmantissa = - DSPmantissa;
00146
00147 }
00148 return;
00149 }
00150
00151
00152
00153