21 cout <<
"enter in TCCBlockFormatter::DigiToRaw " << endl;
23 int HEADER_SIZE = 8 * 9;
34 int iDCC = TheMapping->
DCCid(detid);
35 int TCCid = TheMapping->
TCCid(detid);
38 cout <<
"Wrong TCCid in TCCBlockFormatter::DigiToRaw " << endl;
55 itcc_block = 2 * pair +
inner + 1;
62 int nsamples = trigprim.
size();
66 int iTT = TheMapping->
iTT(detid);
68 cout <<
"This is a TrigTower iDCC iTT iTCCBlock TCCid " <<
dec << iDCC <<
" " << iTT <<
" " << itcc_block <<
" "
71 cout <<
"ieta iphi " <<
dec << detid.
ieta() <<
" " << detid.
iphi() << endl;
72 if (iTT <= 0 || iTT > NTT_max) {
73 cout <<
"invalid iTT " << iTT << endl;
80 if ((
int)rawdata.
size() != HEADER_SIZE) {
81 FE_index = rawdata.
size() / 8 - NTCC * (Nrows_TCC + 1);
84 cout <<
"TCCid already there. FE_index = " << FE_index << endl;
87 cout <<
"New TTCid added on Raw data, TTCid = " <<
dec << TCCid <<
" 0x" << hex << TCCid << endl;
88 FE_index = rawdata.
size() / 8;
89 int fe_index = FE_index;
90 for (
int iblock = 0; iblock < NTCC; iblock++) {
92 unsigned char* ppData = rawdata.
data();
93 ppData[8 * fe_index] = TCCid & 0xFF;
94 ppData[8 * fe_index + 2] =
bx & 0xFF;
95 ppData[8 * fe_index + 3] = (
bx & 0xF00) >> 8;
96 ppData[8 * fe_index + 3] |= 0x60;
97 ppData[8 * fe_index + 4] = lv1 & 0xFF;
98 ppData[8 * fe_index + 5] = (lv1 & 0xF00) >> 8;
99 ppData[8 * fe_index + 6] = NTT_max;
100 ppData[8 * fe_index + 6] |= ((nsamples & 0x1) << 7);
101 ppData[8 * fe_index + 7] = ((nsamples & 0xE) >> 1);
102 ppData[8 * fe_index + 7] |= 0x60;
105 fe_index += Nrows_TCC + 1;
106 rawdata.
resize(rawdata.
size() + 8 * Nrows_TCC);
109 cout <<
"Added headers and empty lines : " << endl;
115 unsigned char* ppData = rawdata.
data();
116 for (
int iline = FE_index - 1;
iline < FE_index + (Nrows_TCC + 1) * NTCC - 1;
iline++) {
117 ppData[8 *
iline + 7] |= 0x60;
118 ppData[8 *
iline + 3] |= 0x60;
122 unsigned char* pData = rawdata.
data();
127 int irow = jTT / 4 + (itcc_block - 1) *
140 cout <<
"Now add tower " <<
dec << iTT <<
" irow ival " <<
dec << irow <<
" " <<
dec << ival << endl;
142 cout <<
"new data will be added at line " <<
dec << FE_index << endl;
146 int ttflag = trigprim.
ttFlag();
148 if (
debug_ && (ttflag != 0)) {
149 cout <<
"in TCCBlock : this tower has a non zero flag" << endl;
150 cout <<
"Fedid iTT flag " <<
dec << FEDid <<
" " << iTT <<
" "
151 <<
"0x" << hex << ttflag << endl;
153 pData[8 * FE_index + ival * 2] =
155 pData[8 * FE_index + ival * 2 + 1] = (ttflag << 1) + (fg & 0
x1);
158 int ibase = 8 * (FE_index - (
int)(jTT / 4) - 1);
159 pData[ibase] = TCCid & 0xFF;
160 pData[ibase + 6] = NTT_max;
161 pData[ibase + 6] |= ((nsamples & 0x1) << 7);
162 pData[ibase + 7] |= ((nsamples & 0xE) >> 1);
165 cout <<
"pData[8*FE_index + ival*2+1] = " << hex << (
int)pData[8 * FE_index + ival * 2 + 1] << endl;
167 cout <<
"ttflag ttflag<<1 " << hex << ttflag <<
" " << hex << (ttflag << 1) << endl;
169 cout <<
"fg&0x1 " << hex << (fg & 0x1) << endl;
171 cout <<
"sum " << hex << ((ttflag << 1) + (fg & 0
x1)) << endl;
173 pData[8 * FE_index + ival * 2 + 1] |= 0x60;
175 cout <<
"ttflag et fgbit " << hex << ttflag <<
" " << hex <<
et <<
" " << hex << fg << endl;