14#include "MucMappingAlg/MucFec.h"
15#include "MucMappingAlg/MucGeoConst.h"
18MucFec :: MucFec(
int id )
22 if( (
id < 0) || (
id > STRIP_NUM-1) )
24 cout <<
"Initialize failure, check id!" << endl;
33 m_StripOrder = DEFAULT_STRIP_ORDER;
34 m_ChainName =
"NoName";
40MucFec :: MucFec(
int id,
int stripOrder,
int part,
int segment,
int layer,
int firstStripID,
41 unsigned int vmeRecord,
string chainName)
48 if( (
id < 0) || (
id > STRIP_NUM-1) )
51 cout <<
"MucFec::Check id:\t" <<
id <<
"!" << endl;
53 if( (stripOrder != 1) && (stripOrder != -1) )
56 cout <<
"MucFec::Check stripOrder:\t" << stripOrder <<
"!" << endl;
58 if( (part < 0) || ( part >
PART_MAX-1) )
61 cout <<
"MucFec::Check part:\t" << part <<
"!" << endl;
66 cout <<
"MucFec::Check segment:\t" << segment <<
"!" << endl;
71 cout <<
"MucFec::Check layer:\t" << layer <<
"!" << endl;
73 if(
sizeof(vmeRecord) < 4 )
76 cout <<
"MucFec::Check record:\t" << vmeRecord <<
"!" << endl;
80 m_StripOrder = stripOrder;
84 m_FirstStripID = firstStripID;
85 m_ChainName = chainName;
86 m_VmeRecord = vmeRecord;
92void MucFec :: Initialize()
95 MucFec::DecodeVmeAddress();
96 MucFec::SetFiredStripNumber();
97 MucFec::SetFiredStripVect();
98 MucFec::EncodePowerpcRecord();
102void MucFec :: DecodeData()
104 m_Data = (
unsigned short)m_VmeRecord;
107void MucFec :: DecodeVmeAddress()
109 m_VmeAddress = (
unsigned short)(m_VmeRecord >> LENGTH);
110 m_Module = (m_VmeAddress >> MODULE_BIT) & 0xF;
111 m_Socket = (m_VmeAddress >> SOCKET_BIT) & 0x3;
112 m_FecID = m_VmeAddress & 0xF;
115void MucFec :: SetFiredStripNumber()
117 m_FiredStripNumber = 0;
118 for(
int i=0; i<STRIP_NUM; i++)
120 if( (m_Data>>i) & 1 )
121 m_FiredStripNumber++;
125void MucFec :: SetFiredStripVect()
127 m_FiredStripVect.clear();
128 int tempID[STRIP_NUM];
131 for(
int i=0; i<STRIP_NUM; i++)
133 if( (m_Data>>i) & 1 )
135 tempID[tempFired] = i;
141 for(
int i=0; i<tempFired; i++)
143 stripID = ((1 - m_StripOrder)/2) * (STRIP_NUM - 1) + (m_StripOrder * tempID[i]);
144 stripID += m_FirstStripID;
145 m_FiredStripVect.push_back( stripID );
149void MucFec :: EncodePowerpcRecord()
151 unsigned int address = ( (m_Part<<PART_BIT) | (m_Segment<<SEG_BIT) | (m_Layer<<LAY_BIT) | m_FirstStripID );
152 m_GeoAddress = (
unsigned short)
address;
153 m_PowerpcRecord = (
address << LENGTH ) | m_Data;
156void MucFec :: SetStripOrder(
int stripOrder )
158 m_StripOrder = stripOrder;
160 MucFec::SetFiredStripVect();
163void MucFec :: SetLocation(
int part,
int segment,
int layer )
169 MucFec::Initialize();
172void MucFec :: SetFirstStripID(
int firstStripID )
174 m_FirstStripID = firstStripID;
175 MucFec :: EncodePowerpcRecord();
176 MucFec :: SetFiredStripVect();
179void MucFec :: SetData(
unsigned short data )
182 m_VmeRecord = (m_VmeRecord | m_Data);
183 MucFec :: EncodePowerpcRecord();
184 MucFec :: SetFiredStripNumber();
185 MucFec :: SetFiredStripVect();
191int MucFec :: GetFiredStripNumber() {
return m_FiredStripNumber; }
193unsigned int MucFec :: GetPowerpcRecord() {
return m_PowerpcRecord; }
195vector< int >* MucFec :: GetFiredStripVect() {
return &m_FiredStripVect; }
197string MucFec :: GetBin(
unsigned int record )
199 const int SIZE =
sizeof(
unsigned int ) * 8;
202 unsigned int temp = 0;
203 for(
int i=0; i<SIZE; i++)
205 temp = record >> SIZE-i-1;
206 Bin += ( temp & 1 ) ?
"1" :
"0";
212string MucFec :: GetBin(
unsigned short record )
214 const int SIZE =
sizeof(
unsigned short ) * 8;
217 unsigned short temp = 0;
218 for(
int i=0; i<SIZE; i++)
220 temp = record >> SIZE-i-1;
221 Bin += ( temp & 1 ) ?
"1" :
"0";
227string MucFec :: GetVmeBin()
232string MucFec :: GetGeoBin()
237string MucFec :: GetDataBin()
string GetBin(unsigned int record)