28 produces<L1MuDTChambPhContainer>();
29 produces<L1MuDTChambThContainer>();
30 produces<L1MuDTTrackContainer>(
"DATA");
36 Raw_token = consumes<FEDRawDataCollection>(DTTFInputTag);
51 if (!fillRawData(e, phi_data, the_data, tra_data))
54 phi_product->setContainer(phi_data);
55 the_product->setContainer(the_data);
56 tra_product->setContainer(tra_data);
91 vector<int> DTTFWordContainer;
92 vector<int>::iterator DTTFiterator;
100 int addr1[2] = {3, 3};
101 int addr2[2] = {15, 15};
102 int addr3[2] = {15, 15};
103 int addr4[2] = {15, 15};
113 if (dttfdata.
size() == 0)
116 int *dataWord1 =
new int;
117 int *dataWord2 =
new int;
118 unsigned char *LineFED = dttfdata.
data();
119 *dataWord2 = *((
int *)LineFED);
121 *dataWord1 = *((
int *)LineFED);
124 BOEevTy = ((*dataWord1) & 0xFF000000) >> 24;
125 DTTFId = ((*dataWord2) & 0x000FFF00) >> 8;
127 if ((BOEevTy != 0x50) || (DTTFId != 0x030C)) {
130 <<
"Not a DTTF header " << hex << *dataWord1;
142 *dataWord2 = *((
int *)LineFED);
144 *dataWord1 = *((
int *)LineFED);
145 int chkEOE = ((*dataWord1) & 0xFFF00000) >> 20;
148 while (chkEOE != 0xA00) {
152 DTTFWord = *dataWord1;
153 DTTFWordContainer.push_back(DTTFWord);
154 DTTFWord = *dataWord2;
155 DTTFWordContainer.push_back(DTTFWord);
158 *dataWord2 = *((
int *)LineFED);
160 *dataWord1 = *((
int *)LineFED);
161 chkEOE = ((*dataWord1) & 0xFFF00000) >> 20;
167 <<
"Warning : number of DTTF lines > 3026 ";
180 evtLgth = ((*dataWord1) & 0x00FFFFFF);
181 CRC = ((*dataWord2) & 0xFFFF0000) >> 16;
188 <<
"Calculated CRC " << hex << newCRC
189 <<
" differs from CRC in trailer " << hex << CRC;
195 if (lines != evtLgth) {
198 <<
"Number of words read != event length " <<
dec << lines <<
" " 207 for (DTTFiterator = DTTFWordContainer.begin();
208 DTTFiterator != DTTFWordContainer.end(); DTTFiterator++) {
210 DTTFChan = ((*DTTFiterator) & 0xFF000000) >> 24;
212 bitsID = ((*DTTFiterator) & 0xF0000000) >> 28;
214 int bxID = bxNr(DTTFChan);
217 int wheelID =
wheel(DTTFChan);
220 int sectorID = sector(DTTFChan);
221 if (sectorID == -999)
225 if (wheelID != 0 && bitsID <= 0x9) {
227 int wheelPh = (
abs(wheelID) - 1) * wheelID /
abs(wheelID);
234 if ((bitsID >> 1) == 0) {
237 if ((bitsID >> 1) == 1) {
240 if ((bitsID >> 1) == 4) {
243 if ((bitsID >> 1) == 2) {
247 if (stationID != 3) {
249 ts2tag = (bitsID)&0
x1;
250 tsqual = (~(*DTTFiterator) & 0x07) - 1;
251 ba = (~(*DTTFiterator) & 0x1FF8) >> 3;
254 ra = (~(*DTTFiterator) & 0x1FFE000) >> 13;
259 ts2tag = (bitsID)&0
x1;
260 tsqual = (~(*DTTFiterator) & 0x07) - 1;
261 ra = (~(*DTTFiterator) & 0x7FF8) >> 3;
266 if (tsqual != 7 && wheelID != -1) {
268 sectorID, stationID, ra, ba,
275 if (wheelID == 0 && bitsID <= 0x4) {
277 int wheelTh = bitsID - 2;
279 int posALL, posBTI[7];
281 if (wheelTh == -2 || wheelTh == -1 ||
283 (sectorID == 0 || sectorID == 3 || sectorID == 4 || sectorID == 7 ||
284 sectorID == 8 || sectorID == 11))) {
286 posALL = ~(*DTTFiterator) & 0x7F;
287 posBTI[0] = ~(*DTTFiterator) & 0x01;
288 posBTI[1] = (~(*DTTFiterator) & 0x02) >> 1;
289 posBTI[2] = (~(*DTTFiterator) & 0x04) >> 2;
290 posBTI[3] = (~(*DTTFiterator) & 0x08) >> 3;
291 posBTI[4] = (~(*DTTFiterator) & 0x10) >> 4;
292 posBTI[5] = (~(*DTTFiterator) & 0x20) >> 5;
293 posBTI[6] = (~(*DTTFiterator) & 0x40) >> 6;
296 theSegments.push_back(
300 posALL = ~(*DTTFiterator) & 0x3F80;
301 posBTI[0] = (~(*DTTFiterator) & 0x0080) >> 7;
302 posBTI[1] = (~(*DTTFiterator) & 0x0100) >> 8;
303 posBTI[2] = (~(*DTTFiterator) & 0x0200) >> 9;
304 posBTI[3] = (~(*DTTFiterator) & 0x0400) >> 10;
305 posBTI[4] = (~(*DTTFiterator) & 0x0800) >> 11;
306 posBTI[5] = (~(*DTTFiterator) & 0x1000) >> 12;
307 posBTI[6] = (~(*DTTFiterator) & 0x2000) >> 13;
310 theSegments.push_back(
314 posALL = ~(*DTTFiterator) & 0x1FC000;
315 posBTI[0] = (~(*DTTFiterator) & 0x004000) >> 14;
316 posBTI[1] = (~(*DTTFiterator) & 0x008000) >> 15;
317 posBTI[2] = (~(*DTTFiterator) & 0x010000) >> 16;
318 posBTI[3] = (~(*DTTFiterator) & 0x020000) >> 17;
319 posBTI[4] = (~(*DTTFiterator) & 0x040000) >> 18;
320 posBTI[5] = (~(*DTTFiterator) & 0x080000) >> 19;
321 posBTI[6] = (~(*DTTFiterator) & 0x100000) >> 20;
324 theSegments.push_back(
331 posALL = ~(*DTTFiterator) & 0x7F;
332 posBTI[6] = ~(*DTTFiterator) & 0x01;
333 posBTI[5] = (~(*DTTFiterator) & 0x02) >> 1;
334 posBTI[4] = (~(*DTTFiterator) & 0x04) >> 2;
335 posBTI[3] = (~(*DTTFiterator) & 0x08) >> 3;
336 posBTI[2] = (~(*DTTFiterator) & 0x10) >> 4;
337 posBTI[1] = (~(*DTTFiterator) & 0x20) >> 5;
338 posBTI[0] = (~(*DTTFiterator) & 0x40) >> 6;
341 theSegments.push_back(
345 posALL = ~(*DTTFiterator) & 0x3F80;
346 posBTI[6] = (~(*DTTFiterator) & 0x0080) >> 7;
347 posBTI[5] = (~(*DTTFiterator) & 0x0100) >> 8;
348 posBTI[4] = (~(*DTTFiterator) & 0x0200) >> 9;
349 posBTI[3] = (~(*DTTFiterator) & 0x0400) >> 10;
350 posBTI[2] = (~(*DTTFiterator) & 0x0800) >> 11;
351 posBTI[1] = (~(*DTTFiterator) & 0x1000) >> 12;
352 posBTI[0] = (~(*DTTFiterator) & 0x2000) >> 13;
355 theSegments.push_back(
359 posALL = ~(*DTTFiterator) & 0x1FC000;
360 posBTI[6] = (~(*DTTFiterator) & 0x004000) >> 14;
361 posBTI[5] = (~(*DTTFiterator) & 0x008000) >> 15;
362 posBTI[4] = (~(*DTTFiterator) & 0x010000) >> 16;
363 posBTI[3] = (~(*DTTFiterator) & 0x020000) >> 17;
364 posBTI[2] = (~(*DTTFiterator) & 0x040000) >> 18;
365 posBTI[1] = (~(*DTTFiterator) & 0x080000) >> 19;
366 posBTI[0] = (~(*DTTFiterator) & 0x100000) >> 20;
369 theSegments.push_back(
377 if (wheelID != 0 && bitsID >= 0xA && bitsID <= 0xB) {
379 int candID = bitsID - 0xA;
381 addr4[candID] = ((*DTTFiterator) & 0x0F);
382 addr3[candID] = ((*DTTFiterator) & 0xF0) >> 4;
383 addr2[candID] = ((*DTTFiterator) & 0xF00) >> 8;
384 addr1[candID] = ((*DTTFiterator) & 0x3000) >> 12;
389 if (wheelID != 0 && bitsID >= 0xC) {
397 muonID = (bitsID & 0x1);
398 qual = (~(*DTTFiterator) & 0x07);
399 phi = ((*DTTFiterator) & 0x7F8) >> 3;
400 ch = (~(*DTTFiterator) & 0x800) >> 11;
401 pt = (~(*DTTFiterator) & 0x1F000) >> 12;
405 0, phi, 0, pt, ch, 1, 0, qual, bxID, wheelID, sectorID, muonID,
406 addr1[muonID], addr2[muonID], addr3[muonID], addr4[muonID]));
412 if (wheelID == 0 && bitsID >= 0x8) {
414 int wheelTh = bitsID & 0x7;
418 etaALL = ~(*DTTFiterator) & 0x007F;
420 etTrack[bxID + 1][sectorID][wheelTh][0] = (*DTTFiterator) & 0x003F;
421 efTrack[bxID + 1][sectorID][wheelTh][0] =
422 (~(*DTTFiterator) & 0x0040) >> 6;
425 etaALL = (~(*DTTFiterator) & 0x3F80) >> 7;
427 etTrack[bxID + 1][sectorID][wheelTh][1] =
428 ((*DTTFiterator) & 0x1F80) >> 7;
429 efTrack[bxID + 1][sectorID][wheelTh][1] =
430 (~(*DTTFiterator) & 0x2000) >> 13;
445 i != dtTracks.end();
i++) {
446 int bxTh =
i->bx() + 1;
447 int sectorTh =
i->scNum();
448 int wheelTh =
i->whNum() + 3;
451 int muonTh =
i->TrkTag();
453 i->setEtaPacked(etTrack[bxTh][sectorTh][wheelTh][muonTh]);
454 i->setFineHaloPacked(efTrack[bxTh][sectorTh][wheelTh][muonTh]);
478 for (
int i = 0;
i < 3;
i++) {
479 for (
int j = 0; j < 12; j++) {
480 for (
int k = 0;
k < 6;
k++) {
481 for (
int l = 0;
l < 2;
l++) {
482 etTrack[
i][j][
k][
l] = 0;
483 efTrack[
i][j][
k][
l] = 0;
504 if (sector < 0 || sector > 11) {
507 if (
abs(wheel) > 3) {
511 myChannel = sector * 21 + wheel * 3 - bx + 10;
521 int myChannel = channel;
526 if (myChannel < 0 || myChannel > 251) {
530 int myBx = 1 - (myChannel % 3);
537 int myChannel = channel;
542 if (myChannel < 0 || myChannel > 251) {
546 return myChannel / 21;
551 int myChannel = channel;
556 if (myChannel < 0 || myChannel > 251) {
560 int myWheel = ((myChannel % 21) / 3) - 3;
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
bool getByToken(EDGetToken token, Handle< PROD > &result) const
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.
const FEDRawData & FEDData(int fedid) const
retrieve data for fed
void clear(CLHEP::HepGenMatrix &m)
Helper function: Reset all elements of a matrix to 0.
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()
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
int channel(int wheel, int sector, int bx)
void analyse(edm::Event &e)
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
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.