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