30 produces<FEDRawDataCollection>();
60 lines += phtrig->bxSize(-1, 1);
64 lines += thtrig->bxSize(-1, 1);
68 lines += trtrig->bxSize(-1, 1)*3;
72 unsigned char* LineFED=dttfdata.
data();
74 int* dataWord1 =
new int;
75 int* dataWord2 =
new int;
79 *dataWord1 = 0x50000000
81 *dataWord2 = 0x00030C00;
84 calcCRC(*dataWord1, *dataWord2, newCRC);
85 *((
int*)LineFED)=*dataWord2;
87 *((
int*)LineFED)=*dataWord1;
91 int TS1Id[4], TS2Id[4];
104 for ( tsphi = phtrig->getContainer()->begin();
105 tsphi != phtrig->getContainer()->end();
107 if ( tsphi->code() != 7 ) {
109 int wheelID = tsphi->whNum()+1;
110 if ( wheelID <= 0 ) wheelID -= 2;
111 int stationID = tsphi->stNum()-1;
112 int is2nd = tsphi->Ts2Tag();
114 int channelNr =
channel(wheelID, tsphi->scNum(), tsphi->bxNum()-is2nd);
115 if ( channelNr == 255 )
continue;
116 int TSId = ( is2nd == 0 ) ? TS1Id[stationID] : TS2Id[stationID];
118 *dataWord1 = ((channelNr&0xFF)<<24)
121 if ( stationID != 2 ){
122 *dataWord2 = ( (TSId&0x0FF)<<24)
123 + (~(tsphi->code()+1)&0x007)
124 + ( (~tsphi->phiB()&0x3FF)<<3)
125 + ( (~tsphi->phi()&0xFFF)<<13);
128 *dataWord2 = ( (TSId&0xFFFFF)<<12)
129 + (~(tsphi->code()+1)&0x00007)
130 + ( (~tsphi->phi()&0x00FFF)<<3);
133 calcCRC(*dataWord1, *dataWord2, newCRC);
135 *((
int*)LineFED)=*dataWord2;
137 *((
int*)LineFED)=*dataWord1;
145 for ( tsthe = thtrig->getContainer()->begin();
146 tsthe != thtrig->getContainer()->end();
149 int wheelTh = tsthe->whNum();
150 int sectorID = tsthe->scNum();
152 int channelNr =
channel(0, sectorID, tsthe->bxNum());
153 if ( channelNr == 255 )
continue;
154 int TSId = wheelTh+2;
156 *dataWord1 = ((channelNr&0xFF)<<24)
159 *dataWord2 = ((TSId&0x07)<<28)
162 int stationID = tsthe->stNum()-1;
163 for (
int bti = 0; bti < 7; bti++ )
164 if ( wheelTh == -2 || wheelTh == -1 ||
165 ( wheelTh == 0 && (sectorID == 0 || sectorID == 3 || sectorID == 4 || sectorID == 7 || sectorID == 8 || sectorID == 11) ) )
166 *dataWord2 -= (tsthe->position(bti)&0x1)<<(stationID*7+bti);
168 *dataWord2 -= (tsthe->position(6-bti)&0x1)<<(stationID*7+bti);
170 calcCRC(*dataWord1, *dataWord2, newCRC);
172 *((
int*)LineFED)=*dataWord2;
174 *((
int*)LineFED)=*dataWord1;
181 for ( tstrk = trtrig->getContainer()->begin();
182 tstrk != trtrig->getContainer()->end();
185 int channelNr =
channel(tstrk->whNum(), tstrk->scNum(), tstrk->bx());
186 if ( channelNr == 255 )
continue;
187 int TSId = ( tstrk->TrkTag() == 0 ) ? 0xAFFF : 0xBFFF;
189 *dataWord1 = ((channelNr&0xFF)<<24)
192 *dataWord2 = ( (TSId&0xFFFF)<<16)
193 + ( tstrk->stNum(4)&0x0000F)
194 + ((tstrk->stNum(3)&0x0000F)<<4)
195 + ((tstrk->stNum(2)&0x0000F)<<8)
196 + ((tstrk->stNum(1)&0x00003)<<12);
198 calcCRC(*dataWord1, *dataWord2, newCRC);
200 *((
int*)LineFED)=*dataWord2;
202 *((
int*)LineFED)=*dataWord1;
204 TSId = ( tstrk->TrkTag() == 0 ) ? 0xCFFE : 0xDFFE;
206 *dataWord1 = ((channelNr&0xFF)<<24)
209 *dataWord2 = ( (TSId&0xFFFE)<<16)
210 + ( ~tstrk->quality_packed()&0x0007)
211 + ( (tstrk->phi_packed()&0x00FF)<<3)
212 + ( (~tstrk->charge_packed()&0x0001)<<11)
213 + ( (~tstrk->pt_packed()&0x001F)<<12);
215 calcCRC(*dataWord1, *dataWord2, newCRC);
217 *((
int*)LineFED)=*dataWord2;
219 *((
int*)LineFED)=*dataWord1;
221 channelNr =
channel(0, tstrk->scNum(), tstrk->bx());
222 if ( channelNr == 255 )
continue;
223 TSId = (tstrk->whNum()+3)<<16;
224 TSId += ( tstrk->whNum() < 0 ) ? 0x8FFFC : 0x7FFFC;
226 *dataWord1 = ((channelNr&0xFF)<<24)
229 *dataWord2 = (TSId&0xFFFFC)<<12;
231 if ( tstrk->TrkTag() == 0 ) {
233 + ( tstrk->eta_packed()&0x003F)
234 + ((~tstrk->finehalo_packed()&0x0001)<<6);
238 + ( ( tstrk->eta_packed()&0x003F)<<7)
239 + ((~tstrk->finehalo_packed()&0x0001)<<13);
242 calcCRC(*dataWord1, *dataWord2, newCRC);
244 *((
int*)LineFED)=*dataWord2;
246 *((
int*)LineFED)=*dataWord1;
252 *dataWord1 = 0xA0000000
256 calcCRC(*dataWord1, *dataWord2&0xFFFF, newCRC);
258 *dataWord2 += (newCRC&0xFFFF)<<16;
261 *((
int*)LineFED)=*dataWord2;
263 *((
int*)LineFED)=*dataWord1;
279 if (
abs(bx) > 1) {
return myChannel; }
280 if ( sector < 0 || sector > 11) {
return myChannel; }
281 if (
abs(wheel) > 3) {
return myChannel; }
283 myChannel = sector*21 + wheel*3 - bx + 10 ;
285 if (myChannel > 125) myChannel += 2;
294 if (myChannel > 127) myChannel -= 2;
296 if (myChannel < 0 || myChannel > 251 ){
return -999; }
298 int myBx = 1-(myChannel%3);
307 if (myChannel > 127) myChannel -= 2;
309 if (myChannel < 0 || myChannel > 251 ){
return -999; }
318 if (myChannel > 127) myChannel -= 2;
320 if (myChannel < 0 || myChannel > 251 ){
return -999; }
322 int myWheel = ((myChannel%21)/3)-3;
329 int myCRC[16],
D[64],
C[16];
331 for(
int i=0;
i < 32;
i++ ){ D[
i]=(myD2>>
i)&0x1; }
332 for(
int i=0;
i < 32;
i++ ){ D[
i+32]=(myD1>>
i)&0x1; }
333 for(
int i=0;
i < 16;
i++ ){ C[
i]=(myC>>
i)&0x1; }
335 myCRC[0] = ( D[63] + D[62] + D[61] + D[60] + D[55] + D[54] +
336 D[53] + D[52] + D[51] + D[50] + D[49] + D[48] +
337 D[47] + D[46] + D[45] + D[43] + D[41] + D[40] +
338 D[39] + D[38] + D[37] + D[36] + D[35] + D[34] +
339 D[33] + D[32] + D[31] + D[30] + D[27] + D[26] +
340 D[25] + D[24] + D[23] + D[22] + D[21] + D[20] +
341 D[19] + D[18] + D[17] + D[16] + D[15] + D[13] +
342 D[12] + D[11] + D[10] + D[9] + D[8] + D[7] +
343 D[6] + D[5] + D[4] + D[3] + D[2] + D[1] +
344 D[0] + C[0] + C[1] + C[2] + C[3] + C[4] +
345 C[5] + C[6] + C[7] + C[12] + C[13] + C[14] +
348 myCRC[1] = ( D[63] + D[62] + D[61] + D[56] + D[55] + D[54] +
349 D[53] + D[52] + D[51] + D[50] + D[49] + D[48] +
350 D[47] + D[46] + D[44] + D[42] + D[41] + D[40] +
351 D[39] + D[38] + D[37] + D[36] + D[35] + D[34] +
352 D[33] + D[32] + D[31] + D[28] + D[27] + D[26] +
353 D[25] + D[24] + D[23] + D[22] + D[21] + D[20] +
354 D[19] + D[18] + D[17] + D[16] + D[14] + D[13] +
355 D[12] + D[11] + D[10] + D[9] + D[8] + D[7] +
356 D[6] + D[5] + D[4] + D[3] + D[2] + D[1] +
357 C[0] + C[1] + C[2] + C[3] + C[4] + C[5] +
358 C[6] + C[7] + C[8] + C[13] + C[14] + C[15] )%2;
360 myCRC[2] = ( D[61] + D[60] + D[57] + D[56] + D[46] + D[42] +
361 D[31] + D[30] + D[29] + D[28] + D[16] + D[14] +
362 D[1] + D[0] + C[8] + C[9] + C[12] + C[13] )%2;
364 myCRC[3] = ( D[62] + D[61] + D[58] + D[57] + D[47] + D[43] +
365 D[32] + D[31] + D[30] + D[29] + D[17] + D[15] +
366 D[2] + D[1] + C[9] + C[10] + C[13] + C[14] )%2;
368 myCRC[4] = ( D[63] + D[62] + D[59] + D[58] + D[48] + D[44] +
369 D[33] + D[32] + D[31] + D[30] + D[18] + D[16] +
370 D[3] + D[2] + C[0] + C[10] + C[11] + C[14] +
373 myCRC[5] = ( D[63] + D[60] + D[59] + D[49] + D[45] + D[34] +
374 D[33] + D[32] + D[31] + D[19] + D[17] + D[4] +
375 D[3] + C[1] + C[11] + C[12] + C[15] )%2;
377 myCRC[6] = ( D[61] + D[60] + D[50] + D[46] + D[35] + D[34] +
378 D[33] + D[32] + D[20] + D[18] + D[5] + D[4] +
379 C[2] + C[12] + C[13] )%2;
381 myCRC[7] = ( D[62] + D[61] + D[51] + D[47] + D[36] + D[35] +
382 D[34] + D[33] + D[21] + D[19] + D[6] + D[5] +
383 C[3] + C[13] + C[14] )%2;
385 myCRC[8] = ( D[63] + D[62] + D[52] + D[48] + D[37] + D[36] +
386 D[35] + D[34] + D[22] + D[20] + D[7] + D[6] +
387 C[0] + C[4] + C[14] + C[15] )%2;
389 myCRC[9] = ( D[63] + D[53] + D[49] + D[38] + D[37] + D[36] +
390 D[35] + D[23] + D[21] + D[8] + D[7] + C[1] +
393 myCRC[10] = ( D[54] + D[50] + D[39] + D[38] + D[37] + D[36] +
394 D[24] + D[22] + D[9] + D[8] + C[2] + C[6] )%2;
396 myCRC[11] = ( D[55] + D[51] + D[40] + D[39] + D[38] + D[37] +
397 D[25] + D[23] + D[10] + D[9] + C[3] + C[7] )%2;
399 myCRC[12] = ( D[56] + D[52] + D[41] + D[40] + D[39] + D[38] +
400 D[26] + D[24] + D[11] + D[10] + C[4] + C[8] )%2;
402 myCRC[13] = ( D[57] + D[53] + D[42] + D[41] + D[40] + D[39] +
403 D[27] + D[25] + D[12] + D[11] + C[5] + C[9] )%2;
405 myCRC[14] = ( D[58] + D[54] + D[43] + D[42] + D[41] + D[40] +
406 D[28] + D[26] + D[13] + D[12] + C[6] + C[10] )%2;
408 myCRC[15] = ( D[63] + D[62] + D[61] + D[60] + D[59] + D[54] +
409 D[53] + D[52] + D[51] + D[50] + D[49] + D[48] +
410 D[47] + D[46] + D[45] + D[44] + D[42] + D[40] +
411 D[39] + D[38] + D[37] + D[36] + D[35] + D[34] +
412 D[33] + D[32] + D[31] + D[30] + D[29] + D[26] +
413 D[25] + D[24] + D[23] + D[22] + D[21] + D[20] +
414 D[19] + D[18] + D[17] + D[16] + D[15] + D[14] +
415 D[12] + D[11] + D[10] + D[9] + D[8] + D[7] +
416 D[6] + D[5] + D[4] + D[3] + D[2] + D[1] +
417 D[0] + C[0] + C[1] + C[2] + C[3] + C[4] +
418 C[5] + C[6] + C[11] + C[12] + C[13] + C[14] +
422 for(
int i=0;
i<16 ;
i++){ tempC = tempC + (myCRC[
i]<<
i); }
T getParameter(std::string const &) const
EventNumber_t event() const
edm::InputTag getDTPHTFInputTag()
virtual ~DTTFFEDSim()
Destructor.
The_Container::const_iterator The_iterator
const FEDRawData & FEDData(int fedid) const
retrieve data for fed
edm::InputTag DTDigiInputTag
void resize(size_t newsize)
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
void calcCRC(int myD1, int myD2, int &myC)
edm::InputTag getDTDigiInputTag()
Abs< T >::type abs(const T &t)
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Phi_Container::const_iterator Phi_iterator
int channel(int wheel, int sector, int bx)
void produce(edm::Event &e, const edm::EventSetup &c)
Produce digis out of raw data.
TrackContainer::const_iterator Trackiterator
bool fillRawData(edm::Event &e, FEDRawDataCollection &data)
Generate and fill FED raw data for a full event.
char data[epos_bytes_allocation]
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
edm::InputTag DTPHTFInputTag
DecomposeProduct< arg, typename Div::arg > D
DTTFFEDSim(const edm::ParameterSet &pset)
Constructor.