ATLAS Offline Software
Loading...
Searching...
No Matches
TgcSlbDataHelper.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3*/
4
5/*
6 SLB data helper class : store bit map
7 reconstruct to Hits and Coincidences
8 convert to celladdr and data
9
10 modified for new SL format H.Kurashige Aug.2008
11
12 author Tadashi Maeno
13 author Hisaya Kurashige Jan. 2008
14 author Susumu Oda Jun. 2009
15*/
16
17#include "TgcSlbDataHelper.h"
18
19#include "MuonRDO/TgcRawData.h"
20#include "TgcSlbData.h"
21
23 : AthMessaging("Muon::TgcSlbDataHelper") {}
24
26
27// reconstruct to Hits. subDetectorID and ROD ID are dummy
29 uint16_t subDetectorId, uint16_t rodId, const TgcSlbData* slb,
30 std::vector<TgcRawData*>& vChannel) const {
32 if ((slb->getType() == TgcSlbData::SLB_SL_F) ||
33 (slb->getType() == TgcSlbData::SLB_SL_E)) {
34 return;
35 } else {
36 if (slb->getType() == TgcSlbData::SLB_LPT_D_W) {
38 } else if (slb->getType() == TgcSlbData::SLB_LPT_D_S) {
40 } else if (slb->getType() == TgcSlbData::SLB_LPT_T_W) {
42 } else if (slb->getType() == TgcSlbData::SLB_LPT_T_S) {
44 } else if (slb->getType() == TgcSlbData::SLB_LPT_I_W ||
47 // Readout formatted Data use TgcRawData::SLB_TYPE_INNER_WIRE for
48 // Inner Strip Hits. http://cern.ch/atlas-tgc/doc/ROBformat.pdf
49 // Table 7 : SB type, bits 15..13 Since EI/FI Wire and Strip hold
50 // one SLB in common, we cannot use SLB type to distinguish Wire and
51 // Strip.
52 }
53 }
54
55 bool isFirstHit = true;
56 for (unsigned int iBc = TgcSlbData::BC_PREVIOUS; iBc < TgcSlbData::N_BC;
57 ++iBc) {
58 const bool* bitArray = slb->getBitArray(iBc);
59
60 // bit 0..39 is assigned for Trigger Data, ignore
61 const int TRIGGER_DATA_OFFSET = 40;
62 for (int ibit = TRIGGER_DATA_OFFSET; ibit < TgcSlbData::BITMAP_SIZE;
63 ++ibit) {
64 if (*(bitArray + ibit)) {
65 // cretae TgcRaw
66 TgcRawData* rCh = new TgcRawData(
67 iBc, subDetectorId, rodId, slb->getSswId(), slb->getSbLoc(),
68 slb->getL1Id(), slb->getBcId(), type, isAdjacent(ibit), 0,
69 ibit);
70 vChannel.push_back(rCh);
71
72 // DEBUG PRINT
73 if (isFirstHit) {
74 ATH_MSG_DEBUG("Tgc TgcSlbDataHelper::convertToHits :"
75 << " slb type =" << slb->getType());
76 isFirstHit = false;
77 }
78 ATH_MSG_DEBUG("TgcRawData : HIT "
79 << " BC:" << iBc << " subDetId:" << subDetectorId
80 << " rodId:" << rodId << " sswId:"
81 << slb->getSswId() << " sbLoc:" << slb->getSbLoc()
82 << " slbId:" << slb->getSlbId()
83 << " bit#:" << ibit);
84 } // endif
85 } // loop ibit
86 } // loop iBC
87}
88
89// reconstruct to Coincidences. subDetectorID and ROD ID are dummy
91 uint16_t subDetectorId, uint16_t rodId, const TgcSlbData* slb,
92 std::vector<TgcRawData*>& vChannel) const {
93 bool hit[8];
94 int delta[8];
95 int pos[8];
96
97 bool isFirstHit = true;
98
99 for (unsigned int iBc = TgcSlbData::BC_PREVIOUS; iBc < TgcSlbData::N_BC;
100 ++iBc) {
101 const bool* bitArray = slb->getBitArray(iBc);
102 bool forward;
103 uint16_t sector;
104
105 TgcRawData* rCh;
106 switch (slb->getType()) {
107 case TgcSlbData::SLB_LPT_D_W: // Doublet Wire
108 getLPTforDoublet(bitArray, hit, delta, pos);
109
110 for (int i = 0; i < N_LPT_D; ++i) {
111 if (!hit[i]) {
112 continue;
113 }
114 // create TgcRawData object
115 rCh = new TgcRawData(
116 iBc, subDetectorId, rodId, slb->getSswId(),
117 slb->getSbLoc(), slb->getL1Id(), slb->getBcId(),
118 TgcRawData::SLB_TYPE_DOUBLET_WIRE /*DOUBLET WIRE*/,
119 delta[i], 0, i, pos[i]);
120 vChannel.push_back(rCh);
121
122 // DEBUG PRINT
123 if (isFirstHit) {
125 "Tgc TgcSlbDataHelper::convertCoincidence :"
126 << " slb type =" << slb->getType());
127 isFirstHit = false;
128 }
131 ? "TgcRawData : LPT_D_W "
132 : "TgcRawData : LPT_D_S ")
133 << " BC:" << iBc << " subDetId:" << subDetectorId
134 << " rodId:" << rodId << " sswId:" << slb->getSswId()
135 << " sbLoc:" << slb->getSbLoc()
136 << " slbId:" << slb->getSlbId() << " sub: " << i
137 << " pos:" << pos[i] << " delta:" << delta[i]);
138 } // loop block (i)
139 break;
140
141 case TgcSlbData::SLB_LPT_D_S: // Doublet Strip
142 getLPTforDoublet(bitArray, hit, delta, pos);
143
144 for (int i = 0; i < N_LPT_D; ++i) {
145 if (!hit[i]) {
146 continue;
147 }
148 // create TgcRawData object
149 rCh = new TgcRawData(
150 iBc, subDetectorId, rodId, slb->getSswId(),
151 slb->getSbLoc(), slb->getL1Id(), slb->getBcId(),
152 TgcRawData::SLB_TYPE_DOUBLET_STRIP /*DOUBLET STRIP*/,
153 delta[i], 0, i, pos[i]);
154 vChannel.push_back(rCh);
155
156 if (isFirstHit) {
158 "Tgc TgcSlbDataHelper::convertCoincidence :"
159 << " slb type =" << slb->getType());
160 isFirstHit = false;
161 }
164 ? "TgcRawData : LPT_D_W "
165 : "TgcRawData : LPT_D_S ")
166 << " BC:" << iBc << " subDetId:" << subDetectorId
167 << " rodId:" << rodId << " sswId:" << slb->getSswId()
168 << " sbLoc:" << slb->getSbLoc()
169 << " slbId:" << slb->getSlbId() << " sub: " << i
170 << " pos:" << pos[i] << " delta:" << delta[i]);
171 } // loop block (i)
172 break;
173
174 case TgcSlbData::SLB_LPT_T_W: // Triplet Wire
175 getLPTforTripletWire(bitArray, hit, pos);
176 for (int i = 0; i < N_LPT_TW; ++i) {
177 if (!hit[i]) {
178 continue;
179 }
180 delta[i] = 0;
181 // create TgcRawData object
182 rCh = new TgcRawData(
183 iBc, subDetectorId, rodId, slb->getSswId(),
184 slb->getSbLoc(), slb->getL1Id(), slb->getBcId(),
185 TgcRawData::SLB_TYPE_TRIPLET_WIRE /*TRIPLET WIRE*/,
186 delta[i], 0, i, pos[i]);
187 vChannel.push_back(rCh);
188 if (isFirstHit) {
190 "Tgc TgcSlbDataHelper::convertCoincidence :"
191 << " slb type =" << slb->getType());
192 isFirstHit = false;
193 }
194 ATH_MSG_DEBUG("TgcRawData : LPT_T_W "
195 << " BC:" << iBc << " subDetId:"
196 << subDetectorId << " rodId:" << rodId
197 << " sswId:" << slb->getSswId()
198 << " sbLoc:" << slb->getSbLoc()
199 << " slbId:" << slb->getSlbId()
200 << " sub: " << i << " pos:" << pos[i]);
201 } // loop block
202 break;
203
204 case TgcSlbData::SLB_LPT_T_S: // Triplet Strip
205 getLPTforTripletStrip(bitArray, hit, pos);
206 for (int i = 0; i < N_LPT_TS; ++i) {
207 if (!hit[i]) {
208 continue;
209 }
210 delta[i] = 0;
211 int seg = 0;
212 int subc = i;
213 if (i > 3) {
214 seg = 1;
215 subc = i - 4;
216 }
217 // create TgcRawData object
218 rCh = new TgcRawData(
219 iBc, subDetectorId, rodId, slb->getSswId(),
220 slb->getSbLoc(), slb->getL1Id(), slb->getBcId(),
221 TgcRawData::SLB_TYPE_TRIPLET_STRIP /*TRIPLET STRIP*/,
222 delta[i], seg, subc, pos[i]);
223 vChannel.push_back(rCh);
224 if (isFirstHit) {
226 "Tgc TgcSlbDataHelper::convertCoincidence :"
227 << " slb type =" << slb->getType());
228 isFirstHit = false;
229 }
231 "TgcRawData : LPT_T_S "
232 << " BC:" << iBc << " subDetId:" << subDetectorId
233 << " rodId:" << rodId << " sswId:" << slb->getSswId()
234 << " sbLoc:" << slb->getSbLoc()
235 << " slbId:" << slb->getSlbId() << " seg: " << seg
236 << " sub: " << subc << " pos:" << pos[i]);
237 } // loop block (i)
238 break;
239
242 // Since EI/FI Wire and Strip hold one SLB in common,
243 // we cannot use SLB type to distinguish Wire and Strip.
246 getLPTforInner(bitArray, hit);
247 for (int i = 0; i < N_LPT_I; ++i) {
248 if (!hit[i]) {
249 continue;
250 }
251 rCh = new TgcRawData(
252 iBc, // uint16_t bcTag
253 subDetectorId, // uint16_t subDetectorId
254 rodId, // uint16_t rodId
255 slb->getSswId(), // uint16_t sswId
256 slb->getSbLoc(), // uint16_t slbId
257 slb->getL1Id(), // uint16_t l1Id
258 slb->getBcId(), // uint16_t bcId
259 (i < (N_LPT_I / 2)
261 : TgcRawData::
262 SLB_TYPE_INNER_WIRE), // TgcRawData::SlbType
263 // slbType
264 // TRIGA HIT (bits 0..3) is for Strip and TRIGB HIT
265 // (bits 4..7) is for Wire
266 // https://twiki.cern.ch/twiki/pub/Main/TgcDocument/celladdress2_asic_rev2.pdf
267 0, // int16_t delta, always for Tracklet Inner
268 static_cast<uint16_t>(
269 i >=
270 (N_LPT_I / 2)), // uint16_t seg, wire=1;strip=0
271 i % (N_LPT_I /
272 2), // uint16_t sub, Inner 0..3, TRIG0=sub0,
273 // TRIG1=sub1, TRIG2=sub2, TRIG3=sub3
274 // https://twiki.cern.ch/twiki/pub/Main/TgcDocument/celladdress2_asic_rev2.pdf
275 0); // uint16_t rphi, always for Tracklet Inner
276 vChannel.push_back(rCh);
277 if (isFirstHit) {
279 "Tgc TgcSlbDataHelper::convertCoincidence :"
280 << " slb type =" << slb->getType());
281 isFirstHit = false;
282 }
284 "TgcRawData : "
286 ? "LPT_I_S"
287 : "LPT_I_W")
288 << " BC:" << rCh->bcTag() << " subDetId:"
289 << rCh->subDetectorId() << " rodId:" << rCh->rodId()
290 << " sswId:" << rCh->sswId() << " sbLoc:"
291 << rCh->slbId() << " slbId:" << slb->getSlbId()
292 << " seg: " << rCh->segment() << " sub: "
293 << rCh->subMatrix() << " pos:" << rCh->position());
294 }
295
296 break;
297
298 case TgcSlbData::SLB_SL_F: // Forward Sector Logic
299 case TgcSlbData::SLB_SL_E: // Endcap Sector Logic
300
301 forward = (slb->getType() == TgcSlbData::SLB_SL_F);
302 sector = getSector(forward, subDetectorId, rodId, slb);
303
304 // SL Output
305 bool cand3plus;
306 bool hitSL[2];
307 bool muplus[2];
308 uint16_t threshold[2];
309 bool overlap[2];
310 uint16_t roi[2];
311 if (forward) {
312 TgcSlbDataHelper::getSL_F(bitArray, cand3plus, hitSL,
313 muplus, threshold, overlap, roi);
314 } else {
315 TgcSlbDataHelper::getSL_E(bitArray, cand3plus, hitSL,
316 muplus, threshold, overlap, roi);
317 }
318
319 for (size_t i = 0; i < 2; ++i) {
320 if (!hitSL[i]) {
321 continue;
322 }
323 // create TgcRawData object
324 bool veto[2] = {false};
325 rCh = new TgcRawData(
326 iBc, subDetectorId, rodId, slb->getL1Id(),
327 slb->getBcId(), cand3plus, forward, sector, i,
328 muplus[i], threshold[i], overlap[i], veto[i], roi[i]);
329 vChannel.push_back(rCh);
330 if (isFirstHit) {
332 "Tgc TgcSlbDataHelper::convertCoincidence :"
333 << " slb type =" << slb->getType());
334 isFirstHit = false;
335 }
337 "TgcRawData : SL "
338 << " BC:" << iBc << " subDetId:" << subDetectorId
339 << " rodId:" << rodId << " sswId:" << slb->getSswId()
340 << " sbLoc:" << slb->getSbLoc()
341 << " slbId:" << slb->getSlbId() << " roi:" << roi[i]
342 << " pt:" << threshold[i]);
343 } // loop candidate (i)
344
345 // SL Input = Hpt Output
346 bool hitP[N_HPT_E];
347 bool strip[N_HPT_E];
348 uint16_t chip[N_HPT_E];
349 uint16_t index[N_HPT_E];
350 bool hipt[N_HPT_E];
351 uint16_t hitId[N_HPT_E];
352 uint16_t sub[N_HPT_E];
353 int16_t deltaHPT[N_HPT_E];
354
355 size_t numberOfHit;
356 if (forward) {
357 numberOfHit = N_HPT_F;
358 TgcSlbDataHelper::getHPT_F(bitArray, hitP, strip, chip,
359 index, hipt, hitId, sub,
360 deltaHPT);
361 } else {
362 numberOfHit = N_HPT_E;
363 TgcSlbDataHelper::getHPT_E(bitArray, hitP, strip, chip,
364 index, hipt, hitId, sub,
365 deltaHPT);
366 }
367
368 for (size_t i = 0; i < numberOfHit; ++i) {
369 if (!hitP[i]) {
370 continue;
371 }
372
373 // check HighPT data
374 if (!isValid_HPT(hitP[i], strip[i], chip[i], index[i],
375 hipt[i], hitId[i], sub[i], deltaHPT[i])) {
376 std::string hpt_Type = "E";
377 if (forward) {
378 hpt_Type = "F";
379 }
380 if (strip[i]) {
381 hpt_Type += "S";
382 } else {
383 hpt_Type += "W";
384 }
385
386 if (isFirstHit) {
388 "Tgc TgcSlbDataHelper::convertCoincidence :"
389 << " slb type =" << slb->getType());
390 isFirstHit = false;
391 }
392 ATH_MSG_DEBUG("invalid HPT data "
393 << hpt_Type << " BC:" << iBc
394 << " subDetId:" << subDetectorId
395 << " rodId:" << rodId
396 << " sswId:" << slb->getSswId()
397 << " sbLoc:" << slb->getSbLoc()
398 << " slbId:" << slb->getSlbId()
399 << std::dec << " chip:" << chip[i]
400 << " index:" << index[i] << " hitId:"
401 << hitId[i] << " delta:" << deltaHPT[i]);
402 continue; // skip making TgcRawData
403 }
404
405 // create TgcRawData object
406 {
407 uint16_t inner[N_HPT_E] = {0};
408 rCh = new TgcRawData(iBc, subDetectorId, rodId,
409 slb->getL1Id(), slb->getBcId(),
410 strip[i], forward, sector, chip[i],
411 index[i], hipt[i], hitId[i],
412 sub[i], deltaHPT[i], inner[i]);
413 }
414 vChannel.push_back(rCh);
415 if (isFirstHit) {
417 "Tgc TgcSlbDataHelper::convertCoincidence :"
418 << " slb type =" << slb->getType());
419 isFirstHit = false;
420 }
421 auto hptType = [&]() {
422 std::string hptType = "E";
423 if (forward) {
424 hptType = "F";
425 }
426 if (strip[i]) {
427 hptType += "S";
428 } else {
429 hptType += "W";
430 }
431 return hptType;
432 };
434 "TgcRawData : HPT "
435 << hptType() << " BC:" << iBc
436 << " subDetId:" << subDetectorId << " rodId:" << rodId
437 << " sswId:" << slb->getSswId()
438 << " sbLoc:" << slb->getSbLoc()
439 << " slbId:" << slb->getSlbId() << std::dec
440 << " chip:" << chip[i] << " index:" << index[i]
441 << " hitId:" << hitId[i] << " delta:" << deltaHPT[i]);
442 }
443
444 break;
445
446 default:
447 break;
448
449 } // end switch
450 } // end BCtag loop
451}
452
453// set SLB Type based on sswId, moduleType
454bool Muon::TgcSlbDataHelper::setType(uint16_t, // subDetectorId
455 uint16_t, // rodId
456 TgcSlbData* slb,
457 int // moduleType
458) {
459 bool ret = true;
460 switch (slb->getSswId()) {
461 case 9: // SL
462 if ((slb->getSbLoc() == 4) || (slb->getSbLoc() == 5)) {
464 } else {
466 }
467 break;
468
469 case 8: // EI/FI
470 // October 24, 2008, Susumu Oda
471 // This is not correct.
472 // One SLB for EI/FI is shared by EI/FI wire and
473 // EI/FI strip. Wire and strip should be defined
474 // with not sbLoc but bit position. A,B-inputs
475 // are used by strip and C,D-inputs are used by wire.
476 // Since there is no immediate solution and no
477 // necessitiy, I leave the following several lines.
478 if ((slb->getSbLoc() == 0) || (slb->getSbLoc() == 2)) {
480 } else {
482 }
483 break;
484
485 case 0: // EWT/EST
486 case 1: // EWT/EST
487 case 2: // FWT/FST
488 if (slb->getSbLoc() >= 16) {
490 } else {
492 }
493 break;
494
495 case 3: // EWD/ESD
496 case 4: // EWD/ESD
497 case 5: // EWD/ESD
498 case 6: // EWD/ESD
499 case 7: // FWD/FSD
500 if (slb->getSbLoc() >= 16) {
502 } else {
504 }
505 break;
506
507 default:
509 ret = false;
510 break;
511 }
512 return ret;
513}
514
515// Adjacent or not
517 bool value = false;
518 value = value || ((ibit < 200) && (ibit > 193));
519 value = value || ((ibit < 162) && (ibit > 149));
520 value = value || ((ibit < 118) && (ibit > 109));
521 value = value || ((ibit < 78) && (ibit > 73));
522 value = value || ((ibit < 42) && (ibit > 39));
523
524 return value;
525}
526
527// set sector for HpT/SL based on slbId
529 uint16_t, // subDetectorId
530 uint16_t, // rodId
531 const TgcSlbData* slb) {
532 uint16_t sector = 0;
533
534 if (forward) {
535 sector = slb->getSbLoc() - 4;
536 } else {
537 sector = slb->getSbLoc();
538 }
539 return sector;
540}
541
542void Muon::TgcSlbDataHelper::getLPTforDoublet(const bool* bitArray, bool hit[],
543 int delta[], int pos[]) const {
544 // 2 x (10 bits of TRIG data)
545 // 0 PT0 PT1 PT2 SGN PS0 PS1 PS2 PS3 PS4
546
547 size_t ibit = 0;
548 for (int blk = 0; blk < N_LPT_D; blk++) {
549 uint32_t binary = getVal(bitArray, ibit, 9);
550 hit[blk] = false;
551 // Delta
552 delta[blk] = binary & 0x07;
553 if (delta[blk] == 0) {
554 // check sign
555 if (binary & 0x08) {
556 hit[blk] = true;
557 }
558 } else {
559 hit[blk] = true;
560 if ((binary & 0x08) == 0) {
561 delta[blk] *= -1;
562 }
563 }
564 // position
565 if (hit[blk]) {
566 pos[blk] = (binary & 0x1F0) >> 4;
567 } else {
568 pos[blk] = 0;
569 }
570 ibit += 10;
571 }
572}
573
575 bool hit[], int pos[]) const {
576 // 3 x ( 6/7 bits of TRIG Data )
577 size_t ibit = 0;
578 int blk;
579 uint32_t binary;
580
581 // TRIG0
582 // PS0 PS1 PS2 PS3 PS4 HIT
583 blk = 0;
584 binary = getVal(bitArray, ibit, 6);
585 pos[blk] = 0;
586 hit[blk] = ((binary & 0x20) != 0);
587 // position
588 if (hit[blk]) {
589 pos[blk] = (binary & 0x1F);
590 }
591 ibit += 6;
592
593 // TRIG1
594 // PS0 PS1 PS2 0 PS3 PS4 HIT
595 blk = 1;
596 binary = getVal(bitArray, ibit, 3);
597 pos[blk] = 0;
598 hit[blk] = ((binary & 0x04) != 0);
599 // position
600 if (hit[blk]) {
601 pos[blk] = (binary & 0x03) * 8;
602 }
603 ibit += 4;
604 binary = getVal(bitArray, ibit, 3);
605 if (hit[blk]) {
606 pos[blk] += (binary & 0x07);
607 }
608 ibit += 3;
609
610 // TRIG2
611 // PS0 PS1 PS2 PS3 PS4 HIT
612 blk = 2;
613 binary = getVal(bitArray, ibit, 6);
614 pos[blk] = 0;
615 hit[blk] = ((binary & 0x20) != 0);
616 // position
617 if (hit[blk]) {
618 pos[blk] = (binary & 0x1F);
619 }
620}
621
623 bool hit[],
624 int pos[]) const {
625 // 8 x (5bits of TRIG datat)
626 // PS0 PS1 PS2 PS3 HIT
627
628 size_t ibit = 0;
629 for (int blk = 0; blk < N_LPT_TS; blk++) {
630 uint32_t binary = getVal(bitArray, ibit, 5);
631 pos[blk] = 0;
632 hit[blk] = ((binary & 0x10) != 0);
633 // position
634 if (hit[blk]) {
635 pos[blk] = (binary & 0x0F);
636 }
637 ibit += 5;
638 }
639}
640
642 bool hit[]) const {
643 // 2 x (4bits of TRIG data)
644 // TRIG3 TRIG2 TRIG1 TRIG0
645 // https://twiki.cern.ch/twiki/pub/Main/TgcDocument/celladdress2_asic_rev2.pdf
646
647 size_t ibit = 0;
648 for (int blk = 0; blk < N_LPT_I; blk++) {
649 uint32_t binary = getVal(bitArray, ibit, 1);
650 hit[blk] = (binary & 0x1);
651 ibit += 1;
652 }
653}
654
655void Muon::TgcSlbDataHelper::getSL_F(const bool* bitArray, bool& cand3plus,
656 bool hit[], bool muplus[], uint16_t pt[],
657 bool overlap[], uint16_t roi[]) const {
658 // 32bits of TRIG data to MuCTPI
659
660 size_t ibit;
661 uint32_t binary;
662
663 // clear results
664 for (size_t icand = 0; icand < 2; icand++) {
665 hit[icand] = false;
666 muplus[icand] = false;
667 pt[icand] = 7;
668 overlap[icand] = false;
669 roi[icand] = 0;
670 }
671 cand3plus = false;
672
673 // Morethan2: bit 199
674 cand3plus = (*(bitArray + 199));
675
676 // 1st Candidate
677 // PT1<0:2> : bit 180 -178
678 ibit = 178;
679 binary = getVal(bitArray, ibit, 3);
680 pt[0] = binary;
681
682 // check hit or not
683 // NOHIT: pT ==7 or pT==0
684 hit[0] = (binary != 7) && (binary != 0);
685
686 if (hit[0]) {
687 // Charge1 : bit 169
688 muplus[0] = (*(bitArray + 169));
689
690 // ROI1<0:5> : bit 198 -193
691 ibit = 193;
692 binary = getVal(bitArray, ibit, 6);
693 roi[0] = binary;
694 }
695
696 // 2nd candidate
697 // PT2<0:2> : bit 177 -175
698 ibit = 175;
699 binary = getVal(bitArray, ibit, 3);
700 pt[1] = binary;
701
702 // check hit or not
703 // NOHIT: pT ==7 or pT==0
704 hit[1] = (binary != 7) && (binary != 0);
705 if (hit[1]) {
706 // Charge2 : bit 168
707 muplus[1] = (*(bitArray + 168));
708
709 // ROI2<0:5> : bit 189 -184
710 ibit = 184;
711 binary = getVal(bitArray, ibit, 6);
712 roi[1] = binary;
713 }
714}
715
716void Muon::TgcSlbDataHelper::getSL_E(const bool* bitArray, bool& cand3plus,
717 bool hit[], bool muplus[], uint16_t pt[],
718 bool overlap[], uint16_t roi[]) const {
719 // 32bits of TRIG data to MuCTPI
720
721 size_t ibit;
722 uint32_t binary;
723
724 // clear results
725 for (size_t icand = 0; icand < 2; icand++) {
726 hit[icand] = false;
727 muplus[icand] = false;
728 pt[icand] = 7;
729 overlap[icand] = false;
730 roi[icand] = 0;
731 }
732 cand3plus = false;
733
734 // Morethan2: bit 199
735 cand3plus = (*(bitArray + 199));
736
737 // 1st Candidate
738 // PT1<0:2> : bit 180 -178
739 ibit = 178;
740 binary = getVal(bitArray, ibit, 3);
741 pt[0] = binary;
742
743 // check hit or not
744 // NOHIT: pT ==7 or pT==0
745 hit[0] = (binary != 7) && (binary != 0);
746
747 if (hit[0]) {
748 // Charge1 : bit 169
749 muplus[0] = (*(bitArray + 169));
750
751 // ROI1<0:7> : bit 198 -191
752 ibit = 191;
753 binary = getVal(bitArray, ibit, 8);
754 roi[0] = binary;
755 }
756
757 // 2nd candidate
758 // PT2<0:2> : bit 177 -175
759 ibit = 175;
760 binary = getVal(bitArray, ibit, 3);
761 pt[1] = binary;
762
763 // check hit or not
764 // NOHIT: pT ==7 or pT==0
765 hit[1] = (binary != 7) && (binary != 0);
766
767 if (hit[1]) {
768 // Charge2 : bit 168
769 muplus[1] = (*(bitArray + 168));
770
771 // ROI2<0:7> : bit 189 -182
772 ibit = 182;
773 binary = getVal(bitArray, ibit, 8);
774 roi[1] = binary;
775 }
776}
777
778void Muon::TgcSlbDataHelper::getHPT_F(const bool* bitArray, bool hit[],
779 bool strip[], uint16_t chip[],
780 uint16_t index[], bool hipt[],
781 uint16_t hitId[], uint16_t pos[],
782 int16_t delta[]) const {
783 int16_t dR;
784 bool sign;
785 size_t ibit;
786 int width;
787 size_t ichip;
788
789 size_t icand = 0;
790
791 // chip 0 for wire : bit 159 ..140
792 // 1st hit :159-150, 2nd hit :149-140
793 // dR<0:3>, Sign, H/L, Pos, ID<0:2>
794 ichip = 0;
795 ibit = 160; // start position
796 for (size_t idx = 0; idx < 2; ++idx) {
797 chip[icand] = ichip;
798 strip[icand] = false;
799 index[icand] = 1 - idx;
800 // dR
801 width = 4;
802 ibit -= width;
803 dR = getVal(bitArray, ibit, width);
804 // sign
805 width = 1;
806 ibit -= width;
807 sign = *(bitArray + ibit);
808 // calculate delta with sign
809 if (sign) {
810 hit[icand] = true;
811 delta[icand] = dR;
812 } else {
813 if (dR == 0) {
814 hit[icand] = false;
815 delta[icand] = 0;
816 } else {
817 hit[icand] = true;
818 delta[icand] = -dR;
819 }
820 }
821
822 // H/L
823 width = 1;
824 ibit -= width;
825 hipt[icand] = *(bitArray + ibit);
826
827 // pos
828 width = 1;
829 ibit -= width;
830 pos[icand] = getVal(bitArray, ibit, width);
831
832 // Id
833 width = 3;
834 ibit -= width;
835 hitId[icand] = getVal(bitArray, ibit, width);
836
837 icand += 1;
838 }
839
840 // chip 1 for wire : bit 135 ..120
841 // 1st hit :135-128, 2nd hit :127-120
842 // dR<0:3>, Sign, H/L, Pos, ID<0>
843 ichip = 1;
844 ibit = 136; // start position
845 for (size_t idx = 0; idx < 2; ++idx) {
846 chip[icand] = ichip;
847 strip[icand] = false;
848 index[icand] = 1 - idx;
849 // dR
850 width = 4;
851 ibit -= width;
852 dR = getVal(bitArray, ibit, width);
853 // sign
854 width = 1;
855 ibit -= width;
856 sign = *(bitArray + ibit);
857 // calculate delta with sign
858 if (sign) {
859 hit[icand] = true;
860 delta[icand] = dR;
861 } else {
862 if (dR == 0) {
863 hit[icand] = false;
864 delta[icand] = 0;
865 } else {
866 hit[icand] = true;
867 delta[icand] = -dR;
868 }
869 }
870
871 // H/L
872 width = 1;
873 ibit -= width;
874 hipt[icand] = *(bitArray + ibit);
875
876 // pos
877 width = 1;
878 ibit -= width;
879 pos[icand] = getVal(bitArray, ibit, width);
880
881 // Id
882 width = 1;
883 ibit -= width;
884 hitId[icand] = getVal(bitArray, ibit, width);
885 if (hitId[icand] == 0 && hit[icand]) {
886 hitId[icand] = 2;
887 }
888
889 icand += 1;
890 }
891
892 // chip 0 for strip : bit 119 ..104
893 // 1st hit :119-113, 2nd hit :111-105
894 // dPhi<0:2>, Sign, H/L, Pos, ID<0>
895 int16_t dPhi;
896 ichip = 0; // chip#0 for strip
897 ibit = 120;
898 for (size_t idx = 0; idx < 2; ++idx) {
899 chip[icand] = ichip;
900 strip[icand] = true;
901 index[icand] = 1 - idx;
902
903 // dPhi
904 width = 3;
905 ibit -= width;
906 dPhi = getVal(bitArray, ibit, width);
907 // sign
908 width = 1;
909 ibit -= width;
910 sign = *(bitArray + ibit);
911 // calculate delta with sign
912 if (sign) {
913 hit[icand] = true;
914 delta[icand] = dPhi;
915 } else {
916 if (dPhi == 0) {
917 hit[icand] = false;
918 delta[icand] = 0;
919 } else {
920 hit[icand] = true;
921 delta[icand] = -dPhi;
922 }
923 }
924
925 // H/L
926 width = 1;
927 ibit -= width;
928 hipt[icand] = *(bitArray + ibit);
929
930 // pos
931 width = 1;
932 ibit -= width;
933 pos[icand] = getVal(bitArray, ibit, width);
934
935 // Id
936 // Only HitId<0> is sent
937 width = 1;
938 ibit -= width;
939 hitId[icand] = getVal(bitArray, ibit, width);
940 if (hitId[icand] == 0 && hit[icand]) {
941 hitId[icand] = 2;
942 }
943
944 // dummy bit
945 ibit -= 1;
946
947 icand += 1;
948 }
949}
950
951void Muon::TgcSlbDataHelper::getHPT_E(const bool* bitArray, bool hit[],
952 bool strip[], uint16_t chip[],
953 uint16_t index[], bool hipt[],
954 uint16_t hitId[], uint16_t pos[],
955 int16_t delta[]) const {
956 int16_t dR;
957 bool sign;
958 size_t ibit;
959 int width;
960 size_t ichip;
961
962 size_t icand = 0;
963
964 // chip 0 for wire : bit 159 ..152
965 // 1st hit :159-153
966 // dR<0:3>, Sign, H/L, Pos
967 ichip = 0;
968 ibit = 160; // start position
969
970 chip[icand] = ichip;
971 index[icand] = 0; // only 1 hit in chip 0
972 strip[icand] = false;
973
974 // dR : bit 159-156
975 width = 4;
976 ibit -= width;
977 dR = getVal(bitArray, ibit, width);
978 // sign : bit 155
979 width = 1;
980 ibit -= width;
981 sign = *(bitArray + ibit);
982 // calculate delta with sign
983 if (sign) {
984 hit[icand] = true;
985 delta[icand] = dR;
986 } else {
987 if (dR == 0) {
988 hit[icand] = false;
989 delta[icand] = 0;
990 } else {
991 hit[icand] = true;
992 delta[icand] = -dR;
993 }
994 }
995
996 // H/L : bit 154
997 width = 1;
998 ibit -= width;
999 hipt[icand] = *(bitArray + ibit);
1000
1001 // pos : bit 153
1002 width = 1;
1003 ibit -= width;
1004 pos[icand] = getVal(bitArray, ibit, width);
1005
1006 // Id
1007 // Id is set to 1
1008 if (hit[icand]) {
1009 hitId[icand] = 1;
1010 }
1011
1012 icand += 1;
1013
1014 // chip 1, 2, 3 for Wire
1015 // chip 1 : 1st hit :151-142, 2nd hit :141-132
1016 // chip 2 : 1st hit :131-122, 2nd hit :121-112
1017 // chip 3 : 1st hit :111-102, 2nd hit :101- 92
1018 // dR<0:3>, Sign, H/L, Pos, ID<0:2>
1019 ibit = 152; // start position
1020
1021 for (size_t ichip = 1; ichip <= 3; ++ichip) {
1022 for (size_t idx = 0; idx < 2; ++idx) {
1023 chip[icand] = ichip;
1024 strip[icand] = false;
1025 index[icand] = 1 - idx;
1026 // dR
1027 width = 4;
1028 ibit -= width;
1029 dR = getVal(bitArray, ibit, width);
1030 // sign
1031 width = 1;
1032 ibit -= width;
1033 sign = *(bitArray + ibit);
1034 // calculate delta with sign
1035 if (sign) {
1036 hit[icand] = true;
1037 delta[icand] = dR;
1038 } else {
1039 if (dR == 0) {
1040 hit[icand] = false;
1041 delta[icand] = 0;
1042 } else {
1043 hit[icand] = true;
1044 delta[icand] = -dR;
1045 }
1046 }
1047
1048 // H/L
1049 width = 1;
1050 ibit -= width;
1051 hipt[icand] = *(bitArray + ibit);
1052
1053 // pos
1054 width = 1;
1055 ibit -= width;
1056 pos[icand] = getVal(bitArray, ibit, width);
1057
1058 // Id
1059 width = 3;
1060 ibit -= width;
1061 hitId[icand] = getVal(bitArray, ibit, width);
1062
1063 icand += 1;
1064 }
1065 }
1066
1067 // chip 0,1 for strip
1068 // chip 0 : 1st hit : 87-79, 2nd hit :78-70
1069 // dPhi<0:2>, Sign, H/L, Pos, ID<0:2>
1070 // chip 1 : 1st hit : 63-56, 2nd hit :55-48
1071 // dPhi<0:2>, Sign, H/L, Pos, ID<0>, ID<2>
1072
1073 int16_t dPhi;
1074 ibit = 88; // chip0 start position
1075 for (size_t ichip = 0; ichip <= 1; ++ichip) {
1076 if (ichip == 1) {
1077 ibit = 64; // chip1 start position
1078 }
1079
1080 for (size_t idx = 0; idx < 2; ++idx) {
1081 chip[icand] = ichip;
1082 strip[icand] = true;
1083 index[icand] = 1 - idx;
1084
1085 // dPhi
1086 width = 3;
1087 ibit -= width;
1088 dPhi = getVal(bitArray, ibit, width);
1089 // sign
1090 width = 1;
1091 ibit -= width;
1092 sign = *(bitArray + ibit);
1093 // calculate delta with sign
1094 if (sign) {
1095 hit[icand] = true;
1096 delta[icand] = dPhi;
1097 } else {
1098 if (dPhi == 0) {
1099 hit[icand] = false;
1100 delta[icand] = 0;
1101 } else {
1102 hit[icand] = true;
1103 delta[icand] = -dPhi;
1104 }
1105 }
1106
1107 // H/L
1108 width = 1;
1109 ibit -= width;
1110 hipt[icand] = *(bitArray + ibit);
1111
1112 // pos
1113 width = 1;
1114 ibit -= width;
1115 pos[icand] = getVal(bitArray, ibit, width);
1116
1117 // Id
1118 if (ichip == 0) {
1119 // chip0
1120 width = 3;
1121 ibit -= width;
1122 hitId[icand] = getVal(bitArray, ibit, width);
1123
1124 } else {
1125 // chip 1
1126 // 2bit : hitId<1>,hitId<0>
1127 width = 2;
1128 ibit -= width;
1129 hitId[icand] = 0;
1130 if (hit[icand]) {
1131 hitId[icand] = getVal(bitArray, ibit, width);
1132
1133 // duplicate hit for T5 and T6
1134 // because of bug in strip endcap HPT
1135 chip[icand + 1] = ichip;
1136 strip[icand + 1] = true;
1137 index[icand + 1] = 1 - idx;
1138 hit[icand + 1] = true;
1139 delta[icand + 1] = delta[icand];
1140 pos[icand + 1] = pos[icand];
1141 hitId[icand + 1] = hitId[icand] + 4;
1142 hipt[icand + 1] = hipt[icand];
1143 } else {
1144 // fill no HIT
1145 chip[icand + 1] = ichip;
1146 strip[icand + 1] = true;
1147 index[icand + 1] = 1 - idx;
1148 hit[icand + 1] = false;
1149 delta[icand + 1] = 0;
1150 pos[icand + 1] = 0;
1151 hitId[icand + 1] = 0;
1152 hipt[icand + 1] = 0;
1153 }
1154 icand++;
1155 }
1156
1157 icand += 1;
1158 }
1159 }
1160}
1161
1162// check consistencies of HPT output
1164 uint16_t, // chip
1165 uint16_t, // index
1166 bool hipt, uint16_t hitId,
1167 uint16_t, // pos
1168 int16_t delta) {
1169 bool isOK = true;
1170
1171 // check hitId
1172 if (hit) {
1173 // check hitId
1174 isOK = (hitId != 0) && (hitId != 7);
1175 // check delta
1176 if (!hipt || strip) {
1177 isOK = isOK && (abs(delta) < 8);
1178 }
1179 } else {
1180 // check hitId
1181 isOK = (hitId == 0);
1182 }
1183
1184 return isOK;
1185}
1186
1187uint16_t Muon::TgcSlbDataHelper::getVal(const bool* bitArray, size_t start,
1188 size_t width) {
1189 // utility function to get a value of
1190 // bitArray[ start , start + width -1]
1191 // start : MSB
1192 // start + width -1 : LSB
1193 uint16_t binary = 0;
1194 size_t ibit = start + width - 1;
1195 for (size_t i = 0; i < width; ++i) {
1196 if (bitArray[ibit]) {
1197 binary += (1 << i);
1198 }
1199 ibit -= 1;
1200 }
1201 return binary;
1202}
#define ATH_MSG_DEBUG(x)
Athena::TPCnvVers::Old Athena::TPCnvVers::Current Athena::TPCnvVers::Old Athena::TPCnvVers::Current Athena::TPCnvVers::Old Athena::TPCnvVers::Current Athena::TPCnvVers::Current Athena::TPCnvVers::Current Athena::TPCnvVers::Current Athena::TPCnvVers::Current TgcRawData
int sign(int a)
const double width
AthMessaging(IMessageSvc *msgSvc, const std::string &name)
Constructor.
static bool isValid_HPT(bool hit, bool strip, uint16_t chip, uint16_t index, bool hipt, uint16_t hitId, uint16_t pos, int16_t delta)
Check if it is valid high-pT coincidence or not.
void getLPTforInner(const bool *bitArray, bool hit[]) const
Decode low-pT coincidence (tracklet) information for inner from bit array.
void convertToHits(uint16_t subDetectorId, uint16_t rodId, const TgcSlbData *slb, std::vector< TgcRawData * > &vChannel) const
Convert to Hits.
void getHPT_E(const bool *bitArray, bool hit[], bool strip[], uint16_t chip[], uint16_t index[], bool hipt[], uint16_t hitId[], uint16_t sub[], int16_t delta[]) const
Decode high-pT coincidence information for endcap region from bit array.
static bool isAdjacent(int ibit)
Adjacent or not.
void getLPTforTripletStrip(const bool *bitArray, bool hit[], int pos[]) const
Decode low-pT coincidence (tracklet) information for triplet strip from bit array.
void getSL_F(const bool *bitArray, bool &cand3plus, bool hit[], bool muplus[], uint16_t pt[], bool overlap[], uint16_t roi[]) const
Decode Sector Logic coincidence information for forward region from bit array.
static bool setType(uint16_t subDetectorId, uint16_t rodId, TgcSlbData *slb, int moduleType)
Set SLB Type based on sswId and moduleType.
static uint16_t getVal(const bool *bitArray, std::size_t start, std::size_t width)
Get a value in a range of a bitArray.
void getSL_E(const bool *bitArray, bool &cand3plus, bool hit[], bool muplus[], uint16_t pt[], bool overlap[], uint16_t roi[]) const
Decode Sector Logic coincidence information for endcap region from bit array.
void convertToCoincidences(uint16_t subDetectorId, uint16_t rodId, const TgcSlbData *slb, std::vector< TgcRawData * > &vChannel) const
Convert to coincidences.
void getLPTforTripletWire(const bool *bitArray, bool hit[], int pos[]) const
Decode low-pT coincidence (tracklet) information for triplet wire from bit array.
virtual ~TgcSlbDataHelper()
Destructor.
void getHPT_F(const bool *bitArray, bool hit[], bool strip[], uint16_t chip[], uint16_t index[], bool hipt[], uint16_t hitId[], uint16_t sub[], int16_t delta[]) const
Decode high-pT coincidence information for forward region from bit array.
static uint16_t getSector(bool forward, uint16_t subDetectorId, uint16_t rodId, const TgcSlbData *slb)
Set sector for HpT/SL based on slbId.
void getLPTforDoublet(const bool *bitArray, bool hit[], int delta[], int pos[]) const
Decode low-pT coincidence (tracklet) information for doublet from bit array.
This is the SLB data class which represents an SLB block.
Definition TgcSlbData.h:20
uint32_t getL1Id() const
Get l1Id.
uint16_t getBcId() const
Get bcId.
uint16_t getSswId() const
Get sswId.
void setType(int vType)
Set SLB type.
int getType() const
Get SLB type.
uint16_t getSbLoc() const
Get sbLoc.
const bool * getBitArray(const uint16_t bcTag) const
Get bitArray for a BC tag.
uint16_t getSlbId() const
Get slbId.
An unit object of TGC ROD output.
Definition TgcRawData.h:23
uint16_t sswId() const
Definition TgcRawData.h:272
@ SLB_TYPE_TRIPLET_WIRE
Definition TgcRawData.h:34
@ SLB_TYPE_INNER_WIRE
Definition TgcRawData.h:36
@ SLB_TYPE_TRIPLET_STRIP
Definition TgcRawData.h:35
@ SLB_TYPE_INNER_STRIP
Definition TgcRawData.h:37
@ SLB_TYPE_DOUBLET_STRIP
Definition TgcRawData.h:33
@ SLB_TYPE_DOUBLET_WIRE
Definition TgcRawData.h:32
@ SLB_TYPE_UNKNOWN
Definition TgcRawData.h:38
uint16_t position() const
Definition TgcRawData.h:313
uint16_t subMatrix() const
Definition TgcRawData.h:329
SlbType slbType() const
Definition TgcRawData.h:285
uint16_t segment() const
Definition TgcRawData.h:325
uint16_t bcTag() const
Definition TgcRawData.h:251
uint16_t subDetectorId() const
Definition TgcRawData.h:264
uint16_t slbId() const
Definition TgcRawData.h:276
uint16_t rodId() const
Definition TgcRawData.h:268
bool hipt
Definition globals.cxx:29
std::vector< std::string > veto
these patterns are anded
Definition listroot.cxx:191
Definition index.py:1