27 produces<L1MuDTChambPhContainer>();
28 produces<L1MuDTChambThContainer>();
29 produces<L1MuDTTrackContainer>(
"DATA");
33 verbose_ =
pset.getUntrackedParameter<
bool>(
"verbose",
false);
35 Raw_token = consumes<FEDRawDataCollection>(DTTFInputTag);
49 if (!fillRawData(
e, phi_data, the_data, tra_data))
52 phi_product->setContainer(phi_data);
53 the_product->setContainer(the_data);
54 tra_product->setContainer(tra_data);
87 vector<int> DTTFWordContainer;
88 vector<int>::iterator DTTFiterator;
96 int addr1[2] = {3, 3};
97 int addr2[2] = {15, 15};
98 int addr3[2] = {15, 15};
99 int addr4[2] = {15, 15};
107 e.getByToken(Raw_token,
data);
109 if (dttfdata.
size() == 0)
112 int *dataWord1 =
new int;
113 int *dataWord2 =
new int;
114 unsigned char *LineFED = dttfdata.
data();
115 *dataWord2 = *((
int *)LineFED);
117 *dataWord1 = *((
int *)LineFED);
120 BOEevTy = ((*dataWord1) & 0xFF000000) >> 24;
121 DTTFId = ((*dataWord2) & 0x000FFF00) >> 8;
123 if ((BOEevTy != 0x50) || (DTTFId != 0x030C)) {
125 edm::LogWarning(
"dttf_unpacker") <<
"Not a DTTF header " << hex << *dataWord1;
137 *dataWord2 = *((
int *)LineFED);
139 *dataWord1 = *((
int *)LineFED);
140 int chkEOE = ((*dataWord1) & 0xFFF00000) >> 20;
143 while (chkEOE != 0xA00) {
146 DTTFWord = *dataWord1;
147 DTTFWordContainer.push_back(DTTFWord);
148 DTTFWord = *dataWord2;
149 DTTFWordContainer.push_back(DTTFWord);
152 *dataWord2 = *((
int *)LineFED);
154 *dataWord1 = *((
int *)LineFED);
155 chkEOE = ((*dataWord1) & 0xFFF00000) >> 20;
160 edm::LogWarning(
"dttf_unpacker") <<
"Warning : number of DTTF lines > 3026 ";
173 evtLgth = ((*dataWord1) & 0x00FFFFFF);
174 CRC = ((*dataWord2) & 0xFFFF0000) >> 16;
180 edm::LogWarning(
"dttf_unpacker") <<
"Calculated CRC " << hex << newCRC <<
" differs from CRC in trailer " << hex
187 if (
lines != evtLgth) {
197 for (DTTFiterator = DTTFWordContainer.begin(); DTTFiterator != DTTFWordContainer.end(); DTTFiterator++) {
198 DTTFChan = ((*DTTFiterator) & 0xFF000000) >> 24;
200 bitsID = ((*DTTFiterator) & 0xF0000000) >> 28;
202 int bxID = bxNr(DTTFChan);
205 int wheelID =
wheel(DTTFChan);
208 int sectorID =
sector(DTTFChan);
209 if (sectorID == -999)
213 if (wheelID != 0 && bitsID <= 0x9) {
214 int wheelPh = (
abs(wheelID) - 1) * wheelID /
abs(wheelID);
221 if ((bitsID >> 1) == 0) {
224 if ((bitsID >> 1) == 1) {
227 if ((bitsID >> 1) == 4) {
230 if ((bitsID >> 1) == 2) {
234 if (stationID != 3) {
235 ts2tag = (bitsID) & 0x1;
236 tsqual = (~(*DTTFiterator) & 0x07) - 1;
237 ba = (~(*DTTFiterator) & 0x1FF8) >> 3;
240 ra = (~(*DTTFiterator) & 0x1FFE000) >> 13;
244 ts2tag = (bitsID) & 0x1;
245 tsqual = (~(*DTTFiterator) & 0x07) - 1;
246 ra = (~(*DTTFiterator) & 0x7FF8) >> 3;
251 if (tsqual != 7 && wheelID != -1) {
252 phiSegments.push_back(
253 L1MuDTChambPhDigi(bxID + ts2tag, wheelPh, sectorID, stationID, ra, ba, tsqual, ts2tag, 0));
259 if (wheelID == 0 && bitsID <= 0x4) {
260 int wheelTh = bitsID - 2;
262 int posALL, posBTI[7];
264 if (wheelTh == -2 || wheelTh == -1 ||
266 (sectorID == 0 || sectorID == 3 || sectorID == 4 || sectorID == 7 || sectorID == 8 || sectorID == 11))) {
267 posALL = ~(*DTTFiterator) & 0x7F;
268 posBTI[0] = ~(*DTTFiterator) & 0x01;
269 posBTI[1] = (~(*DTTFiterator) & 0x02) >> 1;
270 posBTI[2] = (~(*DTTFiterator) & 0x04) >> 2;
271 posBTI[3] = (~(*DTTFiterator) & 0x08) >> 3;
272 posBTI[4] = (~(*DTTFiterator) & 0x10) >> 4;
273 posBTI[5] = (~(*DTTFiterator) & 0x20) >> 5;
274 posBTI[6] = (~(*DTTFiterator) & 0x40) >> 6;
280 posALL = ~(*DTTFiterator) & 0x3F80;
281 posBTI[0] = (~(*DTTFiterator) & 0x0080) >> 7;
282 posBTI[1] = (~(*DTTFiterator) & 0x0100) >> 8;
283 posBTI[2] = (~(*DTTFiterator) & 0x0200) >> 9;
284 posBTI[3] = (~(*DTTFiterator) & 0x0400) >> 10;
285 posBTI[4] = (~(*DTTFiterator) & 0x0800) >> 11;
286 posBTI[5] = (~(*DTTFiterator) & 0x1000) >> 12;
287 posBTI[6] = (~(*DTTFiterator) & 0x2000) >> 13;
293 posALL = ~(*DTTFiterator) & 0x1FC000;
294 posBTI[0] = (~(*DTTFiterator) & 0x004000) >> 14;
295 posBTI[1] = (~(*DTTFiterator) & 0x008000) >> 15;
296 posBTI[2] = (~(*DTTFiterator) & 0x010000) >> 16;
297 posBTI[3] = (~(*DTTFiterator) & 0x020000) >> 17;
298 posBTI[4] = (~(*DTTFiterator) & 0x040000) >> 18;
299 posBTI[5] = (~(*DTTFiterator) & 0x080000) >> 19;
300 posBTI[6] = (~(*DTTFiterator) & 0x100000) >> 20;
308 posALL = ~(*DTTFiterator) & 0x7F;
309 posBTI[6] = ~(*DTTFiterator) & 0x01;
310 posBTI[5] = (~(*DTTFiterator) & 0x02) >> 1;
311 posBTI[4] = (~(*DTTFiterator) & 0x04) >> 2;
312 posBTI[3] = (~(*DTTFiterator) & 0x08) >> 3;
313 posBTI[2] = (~(*DTTFiterator) & 0x10) >> 4;
314 posBTI[1] = (~(*DTTFiterator) & 0x20) >> 5;
315 posBTI[0] = (~(*DTTFiterator) & 0x40) >> 6;
321 posALL = ~(*DTTFiterator) & 0x3F80;
322 posBTI[6] = (~(*DTTFiterator) & 0x0080) >> 7;
323 posBTI[5] = (~(*DTTFiterator) & 0x0100) >> 8;
324 posBTI[4] = (~(*DTTFiterator) & 0x0200) >> 9;
325 posBTI[3] = (~(*DTTFiterator) & 0x0400) >> 10;
326 posBTI[2] = (~(*DTTFiterator) & 0x0800) >> 11;
327 posBTI[1] = (~(*DTTFiterator) & 0x1000) >> 12;
328 posBTI[0] = (~(*DTTFiterator) & 0x2000) >> 13;
334 posALL = ~(*DTTFiterator) & 0x1FC000;
335 posBTI[6] = (~(*DTTFiterator) & 0x004000) >> 14;
336 posBTI[5] = (~(*DTTFiterator) & 0x008000) >> 15;
337 posBTI[4] = (~(*DTTFiterator) & 0x010000) >> 16;
338 posBTI[3] = (~(*DTTFiterator) & 0x020000) >> 17;
339 posBTI[2] = (~(*DTTFiterator) & 0x040000) >> 18;
340 posBTI[1] = (~(*DTTFiterator) & 0x080000) >> 19;
341 posBTI[0] = (~(*DTTFiterator) & 0x100000) >> 20;
351 if (wheelID != 0 && bitsID >= 0xA && bitsID <= 0xB) {
352 int candID = bitsID - 0xA;
354 addr4[candID] = ((*DTTFiterator) & 0x0F);
355 addr3[candID] = ((*DTTFiterator) & 0xF0) >> 4;
356 addr2[candID] = ((*DTTFiterator) & 0xF00) >> 8;
357 addr1[candID] = ((*DTTFiterator) & 0x3000) >> 12;
362 if (wheelID != 0 && bitsID >= 0xC) {
370 qual = (~(*DTTFiterator) & 0x07);
371 phi = ((*DTTFiterator) & 0x7F8) >> 3;
372 ch = (~(*DTTFiterator) & 0x800) >> 11;
373 pt = (~(*DTTFiterator) & 0x1F000) >> 12;
397 if (wheelID == 0 && bitsID >= 0x8) {
398 int wheelTh = bitsID & 0x7;
402 etaALL = ~(*DTTFiterator) & 0x007F;
404 etTrack[bxID + 1][sectorID][wheelTh][0] = (*DTTFiterator) & 0x003F;
405 efTrack[bxID + 1][sectorID][wheelTh][0] = (~(*DTTFiterator) & 0x0040) >> 6;
408 etaALL = (~(*DTTFiterator) & 0x3F80) >> 7;
410 etTrack[bxID + 1][sectorID][wheelTh][1] = ((*DTTFiterator) & 0x1F80) >> 7;
411 efTrack[bxID + 1][sectorID][wheelTh][1] = (~(*DTTFiterator) & 0x2000) >> 13;
425 int bxTh =
i->bx() + 1;
426 int sectorTh =
i->scNum();
427 int wheelTh =
i->whNum() + 3;
430 int muonTh =
i->TrkTag();
432 i->setEtaPacked(etTrack[bxTh][sectorTh][wheelTh][muonTh]);
433 i->setFineHaloPacked(efTrack[bxTh][sectorTh][wheelTh][muonTh]);
451 for (
int i = 0;
i < 3;
i++) {
452 for (
int j = 0;
j < 12;
j++) {
453 for (
int k = 0;
k < 6;
k++) {
454 for (
int l = 0;
l < 2;
l++) {
455 etTrack[
i][
j][
k][
l] = 0;
456 efTrack[
i][
j][
k][
l] = 0;
476 if (sector < 0 || sector > 11) {
492 int myChannel = channel;
497 if (myChannel < 0 || myChannel > 251) {
501 int myBx = 1 - (myChannel % 3);
507 int myChannel = channel;
512 if (myChannel < 0 || myChannel > 251) {
516 return myChannel / 21;
520 int myChannel = channel;
525 if (myChannel < 0 || myChannel > 251) {
529 int myWheel = ((myChannel % 21) / 3) - 3;
size_t size() const
Lenght of the data buffer in bytes.
const L1MuDTChambThContainer::The_Container & t_data()
void produce(edm::Event &e, const edm::EventSetup &c) override
Produce digis out of raw data.
DTTFFEDReader(const edm::ParameterSet &pset)
Constructor.
std::vector< L1MuDTTrackCand > TrackContainer
Abs< T >::type abs(const T &t)
std::vector< L1MuDTChambPhDigi > Phi_Container
std::vector< L1MuDTChambThDigi > The_Container
TrackContainer::iterator TrackIterator
void process(edm::Event &e)
void calcCRC(long, int &)
char data[epos_bytes_allocation]
const L1MuDTTrackContainer::TrackContainer & k_data()
int channel(int wheel, int sector, int bx)
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
void analyse(edm::Event &e)
Log< level::Warning, false > LogWarning
bool fillRawData(edm::Event &e, L1MuDTChambPhContainer::Phi_Container &phi_data, L1MuDTChambThContainer::The_Container &the_data, L1MuDTTrackContainer::TrackContainer &tra_data)
Generate and fill FED raw data for a full event.
const L1MuDTChambPhContainer::Phi_Container & p_data()
~DTTFFEDReader() override
Destructor.