ATLAS Offline Software
Loading...
Searching...
No Matches
LVL1TGCTrigger.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4
5// STL
6#include <sstream>
7#include <fstream>
8#include <vector>
9
10// TGC
12#include "TrigT1TGC/TGCASDOut.h"
13#include "TrigT1TGC/TGCEvent.h"
19#include "TrigT1TGC/TGCSector.h"
23#include "TrigT1TGC/TGCNSW.h"
25#include "TrigT1TGC/TGCBIS78.h"
27
28// Other stuff
34
35// MuonSpectrometer
39
42
43// DetMask stuff
44#include "eformat/DetectorMask.h"
45#include "eformat/SourceIdentifier.h"
46
47namespace LVL1TGCTrigger {
48
49LVL1TGCTrigger::LVL1TGCTrigger(const std::string& name, ISvcLocator* pSvcLocator)
50: AthAlgorithm(name,pSvcLocator),
51 m_db(0),
54 m_debuglevel(false)
55{}
56
59{
60 ATH_MSG_DEBUG("LVL1TGCTrigger destructor called");
61 if (m_db) {
62 delete m_db;
63 m_db =0;
64 }
65}
66
69{
70 ATH_MSG_DEBUG("LVL1TGCTrigger::initialize()");
71
72 m_debuglevel = (msgLevel() <= MSG::DEBUG); // save if threshold for debug
73
74 m_tgcArgs.set_MSGLEVEL(msgLevel());
75 m_tgcArgs.set_SHPT_ORED( m_SHPTORED.value() );
76 m_tgcArgs.set_USE_INNER( m_USEINNER.value() );
77 m_tgcArgs.set_INNER_VETO( m_INNERVETO.value() );
78 m_tgcArgs.set_TILE_MU( m_TILEMU.value() );
79 m_tgcArgs.set_USE_NSW( m_USENSW.value() );
80 m_tgcArgs.set_USE_BIS78( m_USEBIS78.value() );
81 m_tgcArgs.set_FORCE_NSW_COIN( m_FORCENSWCOIN.value() );
82
83 m_tgcArgs.set_USE_CONDDB( m_USE_CONDDB.value() );
84 m_tgcArgs.set_useRun3Config( m_useRun3Config.value() );
85
86 m_tgcArgs.set_NSWSideInfo( m_NSWSideInfo.value() );
87
88 ATH_CHECK( m_readCondKey.initialize(!m_useRun3Config.value()) );
89 ATH_CHECK( m_readLUTs_CondKey.initialize(m_useRun3Config.value()) );
90
91 // CondDB is not available for Run3 config. set USE_CONDDB to false to avoid errors.
92 // will be removed the below part.
93 if(m_useRun3Config.value()){
94 m_tgcArgs.set_USE_CONDDB(false);
95 }
96
97 // initialize TGCDataBase
99
100 // initialize the TGCcabling
102
103 // create TGCElectronicsSystem
104 m_system = std::make_unique<TGCElectronicsSystem>(&m_tgcArgs,m_db);
105
106 m_TimingManager = std::make_unique<TGCTimingManager>(m_readCondKey);
107 m_TimingManager->setBunchCounter(0);
108
110
111 // read and write handle key
112 ATH_CHECK(m_keyTgcRdoIn.initialize());
113 ATH_CHECK(m_keyTgcDigit.initialize());
114 ATH_CHECK(m_keyTileMu.initialize());
115 ATH_CHECK(m_keyNSWTrigOut.initialize(tgcArgs()->USE_NSW())); // to be updated once the Run 3 CondDb becomes available (should be automatically configured by db info)
116 ATH_CHECK(m_keyBIS78TrigOut.initialize(tgcArgs()->USE_BIS78())); // to be updated as well
117 ATH_CHECK(m_muctpiPhase1Key.initialize(tgcArgs()->useRun3Config()));
118 ATH_CHECK(m_keyTgcRdo.initialize(tgcArgs()->useRun3Config()));
120
121 // clear mask channel map
122 m_MaskedChannel.clear();
123
124 return StatusCode::SUCCESS;
125}
126
129{
130 ATH_MSG_DEBUG("LVL1TGCTrigger::finalize() called" << " m_nEventInSector = " << m_nEventInSector);
131
132 if (m_db) delete m_db;
133 m_db = 0 ;
134
135 return StatusCode::SUCCESS;
136}
137
140{
141 ATH_MSG_DEBUG("execute() called");
142 const EventContext& ctx = getContext();
143
144 if(!m_cabling) {
145 // get cabling svc
146 if(getCabling().isFailure()) return StatusCode::FAILURE;
147 }
148
149 // doMaskOperation is performed at the first event
150 // It is better to implement callback against
151 // MuonTGC_CablingSvc::updateCableASDToPP (Susumu Oda, 2010/10/27)
152 if(m_firstTime) {
153 // do mask operation
154 if(getMaskedChannel().isFailure()) return StatusCode::FAILURE;
155 m_firstTime = false;
156 }
157
158 // Tile-Muon data
159 bool doTileMu = m_tgcArgs.TILE_MU();
160
161 if (doTileMu && !m_tgcArgs.useRun3Config()) { // for Run-2
163 const TGCTriggerData* readCdo{*readHandle};
164 doTileMu = readCdo->isActive(TGCTriggerData::CW_TILE);
165 }
166
167 // NSW data
168 bool doNSW = m_tgcArgs.USE_NSW();
169
170 // BIS78 data
171 bool doBIS78 = m_tgcArgs.USE_BIS78();
172
173 // TgcRdo
174 std::map<std::pair<int, int>, std::unique_ptr<TgcRdo>> tgcrdo;
175
176
177
178 SG::ReadHandle<TgcDigitContainer> readTgcDigitContainer(m_keyTgcDigit, ctx);
179 if(!readTgcDigitContainer.isValid()){
180 ATH_MSG_ERROR("Cannot retrieve TgcDigitContainer");
181 return StatusCode::FAILURE;
182 }
183 const TgcDigitContainer* tgc_container = readTgcDigitContainer.cptr();
184
186 ATH_CHECK(wh_muctpiTgc.record(std::make_unique<LVL1MUONIF::Lvl1MuCTPIInputPhase1>()));
187 LVL1MUONIF::Lvl1MuCTPIInputPhase1* muctpiinputPhase1 = wh_muctpiTgc.ptr();
188
189 // process one by one
190 StatusCode sc = StatusCode::SUCCESS;
191 for (int bc=TgcDigit::BC_PREVIOUS; bc<=TgcDigit::BC_NEXTNEXT; bc++){
192 sc = StatusCode::SUCCESS;
193
194 // Use TileMu only if BC_CURRENT
195 if (doTileMu && bc == m_CurrentBunchTag) {
196 ATH_CHECK(m_system->getTMDB()->retrieve(m_keyTileMu, ctx));
197 }
198
199 // Use NSW trigger output
200 if(doNSW && bc==m_CurrentBunchTag){ // To implement BC-calculation
201 ATH_CHECK(m_system->getNSW()->retrieve(m_keyNSWTrigOut, ctx));
202 }
203
204 // Use RPC BIS78 trigger output
205 if(doBIS78 && bc == m_CurrentBunchTag){ // Todo: implement BC-calculation
206 ATH_CHECK(m_system->getBIS78()->retrieve(m_keyBIS78TrigOut, ctx));
207 }
208
210 m_bctagInProcess = bc;
211 sc = processOneBunch(tgc_container, muctpiinputPhase1, tgcrdo);
212 }
213 if (sc.isFailure()) {
214 ATH_MSG_FATAL("Fail to process the bunch " << m_bctagInProcess);
215 return sc;
216 }
217 }
218
219
220 // before writing the output TgcRdo container,
221 // read input TgcRdo and copy the tracklet etc.
223 if(!rdoContIn.isValid()){
224 ATH_MSG_WARNING("Cannot retrieve TgcRdoContainer with key=" << m_keyTgcRdoIn.key());
225 return sc;
226 }else if(rdoContIn->size()>0) {
227 TgcRdoContainer::const_iterator itR = rdoContIn->begin();
228 for(; itR!=rdoContIn->end(); ++itR){
229 const TgcRdo* rdoIn = (*itR);
230 std::pair<int, int> subDetectorRod(rdoIn->subDetectorId(), rdoIn->rodId());
231 std::map<std::pair<int, int>, std::unique_ptr<TgcRdo>>::iterator itRdo = tgcrdo.find(subDetectorRod);
232 if (itRdo!=tgcrdo.end()) {
233 // if subDetectorId and rodId for input and output RDOs are the same,
234 // copy the tracklet info etc. from input to the output TgcRdo
235 for ( const TgcRawData* rd : *rdoIn ) {
236 itRdo->second->push_back(std::make_unique<TgcRawData>(*rd));
237 }
238 }
239 }
240 }
241
242 // write tgcL1rdo container
243 SG::WriteHandle<TgcRdoContainer> tgcL1rdoHandle (m_keyTgcRdo, ctx);
244 auto trgContainer=std::make_unique<TgcRdoContainer>();
245 for(const auto& tgcRdoMap : tgcrdo){
246 for(const auto rawData : *tgcRdoMap.second){
247 trgContainer->push_back(rawData);
248 }
249 }
250 ATH_CHECK(tgcL1rdoHandle.record(std::move(trgContainer)));
251
252 return sc;
253}
254
256 LVL1MUONIF::Lvl1MuCTPIInputPhase1* muctpiinputPhase1,
257 std::map<std::pair<int, int>, std::unique_ptr<TgcRdo>>& tgcrdo)
258{
259 ATH_MSG_DEBUG("start processOneBunch: for BC=" << m_bctagInProcess);
260
261 std::map<Identifier, int> tgcDigitIDs;
262 std::map<Identifier, int>::iterator itCh;
263
264 // doMaskOperation (masked & fired)
265 doMaskOperation(tgc_container, tgcDigitIDs);
266
267 // fill ASDOut to this event
268 TGCEvent event;
269 fillTGCEvent(tgcDigitIDs, event);
270 tgcDigitIDs.clear();
271
272 // process trigger electronics emulation...
273 m_TimingManager->increaseBunchCounter();
274 m_system->distributeSignal(&event);
275
276 // EIFI trigger bits for SL are cleared.
277 m_innerTrackletSlotHolder.clearTriggerBits();
278
279 // PatchPanel, SlaveBoard
281 for( int j=0; j<m_system->getNumberOfOctant(); j+=1){
282 for( int k=0; k<m_system->getNumberOfModule(); k+=1){
283 TGCSector* sector = m_system->getSector(i,j,k);
284 if((sector!=0)&&(sector->hasHit())){
286 m_TimingManager->startPatchPanel(sector, m_db);
287 m_TimingManager->startSlaveBoard(sector);
288 if (m_OutputTgcRDO.value()) recordRdoSLB(sector, tgcrdo);
289 // EIFI trigger bits for SL are filled in this method.
290 }
291 }
292 }
293 }
294
295 // HighPtBoard, SectorLogic
296 const int muctpiBcId_offset = TgcDigit::BC_CURRENT;
297 int muctpiBcId = m_bctagInProcess - muctpiBcId_offset;
298 for(int i=0; i< LVL1TGC::kNSide; i++) {
299 int sectoraddr_endcap = 0;
300 int sectoraddr_forward = 0;
301 for(int j=0; j<m_system->getNumberOfOctant(); j+=1){
302 for(int k=0; k<m_system->getNumberOfModule(); k+=1){
303 if(k>=9) continue;// skip Inner TGC
304 TGCSector* sector = m_system->getSector(i,j,k);
305 if(sector==0) continue;
306
307 m_TimingManager->startHighPtBoard(sector);
308 if (m_OutputTgcRDO.value()) recordRdoHPT(sector, tgcrdo);
309
310 // EIFI trigger bits are checked if Endcap
311 if(sector->getRegionType() == TGCRegionType::ENDCAP && sector->getSL()) {
312 if((sector->hasHit())){
313 // Pointers to store EIFI trigger bits for Endcap SL
315 = {0, 0, 0, 0};
316 m_innerTrackletSlotHolder.getInnerTrackletSlots(i, j, k, innerTrackletSlots);
317 sector->getSL()->setInnerTrackletSlots(innerTrackletSlots);
318 }
319 }
320 m_TimingManager->startSectorLogic(sector);
321 if(sector->hasHit()) sector->clearNumberOfHit();
322
323 // Fill inner (EIFI/Tile) words
324 if (m_OutputTgcRDO.value() && m_tgcArgs.USE_INNER()) recordRdoInner(sector, tgcrdo);
325
326 // Fill Lvl1MuCTPInput
327 if (m_OutputTgcRDO.value()) recordRdoSL(sector, tgcrdo);
328
329 size_t tgcsystem=0,subsystem=0;
330 if(i==0) subsystem = LVL1MUONIF::Lvl1MuCTPIInput::idSideA();
331 if(i==1) subsystem = LVL1MUONIF::Lvl1MuCTPIInput::idSideC();
332
333 std::shared_ptr<TGCTrackSelectorOut> trackSelectorOut;
334 sector->getSL()->getTrackSelectorOutput(trackSelectorOut);
335
336 std::shared_ptr<LVL1TGC::TGCNSW> nsw = m_system->getNSW();
337 int module = sector->getModuleId();
338 int sectorId;
339 if(sector->getRegionType() == TGCRegionType::ENDCAP) {
342 if(trackSelectorOut != 0) FillSectorLogicData(&sldata,trackSelectorOut.get());
343
344 if ( m_tgcArgs.USE_NSW() ){
345 sectorId = ((module/3)*2+module%3) + sector->getOctantId()*6;
346 std::shared_ptr<const LVL1TGC::NSWTrigOut> pNSWOut = nsw->getOutput(sector->getRegionType(),
347 sector->getSideId(),
348 sectorId);
349 if ( pNSWOut ){
350 // set monitoring flag
351 for(bool NSWmonitor : pNSWOut->getNSWmonitor() ){
352 if ( NSWmonitor ) {
353 sldata.nsw(true);
354 break;
355 }
356 }
357 }
358 }
359 muctpiinputPhase1->setSectorLogicData(sldata,tgcsystem,subsystem,sectoraddr_endcap++,muctpiBcId);
360 } else if(sector->getRegionType() == TGCRegionType::FORWARD) {
361 LVL1MUONIF::Lvl1MuForwardSectorLogicDataPhase1 sldata;
362 tgcsystem = LVL1MUONIF::Lvl1MuCTPIInputPhase1::idForwardSystem();
363 if(trackSelectorOut != 0) FillSectorLogicData(&sldata,trackSelectorOut.get());
364
365 if ( m_tgcArgs.USE_NSW() ) {
366 sectorId = (module/3) + sector->getOctantId()*3;
367 std::shared_ptr<const LVL1TGC::NSWTrigOut> pNSWOut = nsw->getOutput(sector->getRegionType(),
368 sector->getSideId(),
369 sectorId);
370 if ( pNSWOut ){
371 // set monitoring flag
372 for(bool NSWmonitor : pNSWOut->getNSWmonitor() ){
373 if ( NSWmonitor ) {
374 sldata.nsw(true);
375 break;
376 }
377 }
378 }
379 }
380 muctpiinputPhase1->setSectorLogicData(sldata,tgcsystem,subsystem,sectoraddr_forward++,muctpiBcId);
381 }
382
383 trackSelectorOut.get()->reset();
384
385
386 } // k Module
387 } // j Octant
388 } // i Side
389
390 event.Clear();
391
392 return StatusCode::SUCCESS;
393}
394
395
398 std::map<Identifier, int>& TgcDigitIDs)
399{
400 // (1) skip masked channels
401 for (const TgcDigitCollection* c : *tgc_container) {
402 for (const TgcDigit* h : *c) {
403
404 // check BCID
405 if (h->bcTag()!=m_bctagInProcess) continue;
406
407 Identifier channelId = h->identify();
408 const auto itCh = m_MaskedChannel.find(channelId);
409 if (itCh!=m_MaskedChannel.end() && itCh->second==0) {
410 ATH_MSG_DEBUG("This channel is masked! offlineID=" << channelId);
411 continue;
412 }
413 TgcDigitIDs.emplace(channelId, 1);
414 }
415 }
416
417 // (2) add fired channels by force
418 for(const auto& [Id, OnOff] : m_MaskedChannel) {
419 if (OnOff==1) {
420 ATH_MSG_VERBOSE("This channel is fired by force! offlineID=" << Id);
421 TgcDigitIDs.emplace(Id, 1);
422 }
423 }
424
425 ATH_MSG_DEBUG("# of total hits " << TgcDigitIDs.size());
426
427 return;
428}
429
431void LVL1TGCTrigger::fillTGCEvent(const std::map<Identifier, int>& tgcDigitIDs, TGCEvent& event)
432{
433 // Loop on TGC detectors (collections)
434 for(const auto& itCh : tgcDigitIDs) {
435 const Identifier channelId = itCh.first;
436 int subsystemNumber;
437 int octantNumber;
438 int moduleNumber;
439 int layerNumber;
440 int rNumber;
441 int wireOrStrip;
442 int channelNumber;
443 bool status = m_cabling->getOnlineIDfromOfflineID(channelId,
444 subsystemNumber,
445 octantNumber,
446 moduleNumber,
447 layerNumber,
448 rNumber,
449 wireOrStrip,
450 channelNumber);
451
452 if(!status) {
453 ATH_MSG_INFO("Fail to getOnlineIDfromOfflineID for " << channelId);
454 } else {
455 bool fstatus;
456 int subDetectorID, srodID, sswID, sbLoc, channelID;
457 int phi=0;
458 int moduleType=0;
459 int slbID=0;
460 bool isAside=true;
461 bool isEndcap=true;
462
463 fstatus = m_cabling->getReadoutIDfromOfflineID(channelId,
464 subDetectorID,
465 srodID,sswID,
466 sbLoc,channelID);
467
468 if (fstatus) {
469 fstatus = m_cabling->getSLBIDfromReadoutID(phi, isAside, isEndcap,
470 moduleType, slbID,
471 subDetectorID,
472 srodID, sswID,sbLoc);
473 }
474 if (fstatus) {
475 ATH_MSG_VERBOSE("hit : subsys#=" << subsystemNumber
476 << " octant#=" << octantNumber
477 << " mod#=" << moduleNumber
478 << " layer#=" << layerNumber << " r#=" << rNumber
479 << " isStrip=" << wireOrStrip
480 << " ch#=" << channelNumber << endmsg
481 << " --> readoutID: sudetID=" << subDetectorID
482 << " srodID=" << srodID << " sswID=" << sswID
483 << " slbID=" << slbID << " chID=" << channelID);
484
485 TGCZDirection zdire = (subsystemNumber==1)? kZ_FORWARD : kZ_BACKWARD;
486 TGCReadoutIndex index(zdire,octantNumber,moduleNumber,rNumber,layerNumber);
487 TGCSignalType signal = (wireOrStrip==1)? STRIP : WIRE;
488 event.NewASDOut(index,
489 signal,
490 channelNumber,
491 0);
492 } else {
493 ATH_MSG_INFO("Fail to getSLBIDfromOfflineID for " << channelId);
494 }
495 }
496 } // End Loop on TGC detectors (collections)
497 if (m_debuglevel) {
498 ATH_MSG_DEBUG("Could make TGCEvent with TgcDigitContainer."
499 << " vector size : " << event.GetNASDOut() );
500 for(int iout=1; iout<= event.GetNASDOut(); iout++){
501 TGCASDOut* asdout = (event.GetASDOutVector()[iout-1]);
502 ATH_MSG_DEBUG( " Z:" << asdout->GetTGCReadoutIndex().GetZDirection() <<
503 " O:" << asdout->GetTGCReadoutIndex().GetOctantNumber() <<
504 " M:" << asdout->GetTGCReadoutIndex().GetModuleNumber() <<
505 " R:" << asdout->GetTGCReadoutIndex().GetRNumber() <<
506 " L:" << asdout->GetTGCReadoutIndex().GetLayerNumber() <<
507 " S:" << asdout->GetSignalType() <<
508 " I:" << asdout->GetHitID() <<
509 " T:" << asdout->GetHitToF() );
510 }
511 }
512}
513
514
517 const TGCTrackSelectorOut *trackSelectorOut)
518{
519 // M.Aoki (26/10/2019)
520 // this function will be updated for Run3-specific configuration such as quality flags, 15 thresholds
521 if(trackSelectorOut ==0) return;
522
523 sldata->clear2candidatesInSector();// for temporary
524
525 const int muctpiBcId_offset = TgcDigit::BC_CURRENT;
526 sldata->bcid(m_bctagInProcess - muctpiBcId_offset);
527
528 for(int trackNumber=0;trackNumber!=trackSelectorOut->getNCandidate();trackNumber++){
529
530 sldata->roi(trackNumber,((trackSelectorOut->getR(trackNumber))<<2)+(trackSelectorOut->getPhi(trackNumber)));
531 sldata->pt(trackNumber,trackSelectorOut->getPtLevel(trackNumber));
532 if (trackSelectorOut->getInnerVeto(trackNumber)) sldata->ovl(trackNumber,1);
533 else sldata->ovl(trackNumber,0);
534 sldata->charge(trackNumber, trackSelectorOut->getCharge(trackNumber));
535 sldata->bw2or3(trackNumber, trackSelectorOut->getCoincidenceType(trackNumber));
536 sldata->goodmf(trackNumber, trackSelectorOut->getGoodMFFlag(trackNumber));
537 sldata->innercoin(trackNumber, trackSelectorOut->getInnerCoincidenceFlag(trackNumber));
538 }
539 for(int trackNumber=0;trackNumber!=TGCTrackSelectorOut::NCandidateInTrackSelector;trackNumber++){
540 sldata->set2candidates(trackNumber);// not used for TGC
541 sldata->clear2candidates(trackNumber);// not used for TGC
542 }
543}
544
547 std::map<std::pair<int, int>, std::unique_ptr<TgcRdo>>& tgcrdo)
548{
549 uint16_t bcTag=m_CurrentBunchTag, l1Id=0, bcId=0;
550 // readoutID
551 int subDetectorId, rodId, sswId, sbLoc, secId, secIdEIFI;
552 // SLBID
553 bool isAside, isEndcap; int phi, moduleType, id, phiEIFI;
554 isAside = (sector->getSideId()==0 ? 1 : 0);
555 isEndcap = (sector->getRegionType() == TGCRegionType::ENDCAP ? 1 : 0);
556 int module = sector->getModuleId();
557 // OnlineID moduleNumber
558 // <---- phi ----
559 // EC: 7 6 4 3 1 0 11 10 9
560 // FWD: 8 5 2 14 13 12
561 // [M1, M2, M3] [EI/FI]
562 // secId=0-5(EC), 0-2(FWD) for TgcRawData
563 secId = (isEndcap ? (module/3)*2+module%3 : module/3);
564 // phi=1-48(EC), 1-24(FWD) in detector ID scheme
565 phi = (isEndcap ? (secId+46+sector->getOctantId()*6)%48+1 : (secId+23+sector->getOctantId()*3)%24+1);
566 // secIdEIFI=0-2
567 secIdEIFI = module%3;
568 // phiEIFI=1-24
569 phiEIFI = (secIdEIFI+23+sector->getOctantId()*3)%24+1;
570
571 // SLB
572 const int NumberOfSLBType = 6;
573 // 0: WT, 1: WD, 2: ST, 3: SD, 4: WI 5:SI
574 for(int itype=0; itype<NumberOfSLBType; itype++) {
575 moduleType = getLPTTypeInRawData(itype);
576
577 // loop over all SB of each type
578 for(unsigned int index=0; index<sector->getNumberOfSB(itype); index++) {
579 TGCSlaveBoard * slb = sector->getSB(itype, index);
580 if (0==slb) continue;
581 id = slb->getId();
582 const TGCSlaveBoardOut * out = slb->getOutput();
583 if (0==out) continue;
584
585 bool isEIFI = (moduleType==TgcRawData::SLB_TYPE_INNER_WIRE ||
586 moduleType==TgcRawData::SLB_TYPE_INNER_STRIP);
587
588 // get ReadoutID
589 bool status =
590 m_cabling->getReadoutIDfromSLBID((isEIFI ? phiEIFI : phi),
591 isAside, isEndcap,
592 moduleType, id,
593 subDetectorId, rodId,
594 sswId, sbLoc);
595 if (!status) {
596 ATH_MSG_DEBUG("TGCcablignSvc::getReadoutIDfromSLBID fails");
597 ATH_MSG_DEBUG( "phi=" << phi
598 << " side=" << ((isAside) ? "A": "C")
599 << " region=" << ((isEndcap) ? "Endcap" : "Forward")
600 << " type=" << moduleType
601 << " id=" << id
602 << " subDetectorId=" << subDetectorId
603 << " rodId=" << rodId
604 << " sswId=" << sswId
605 << " sbLoc=" << sbLoc);
606 continue;
607 }
608
609 // fill TgcRawData
610 for(int iData=0; iData<out->getNumberOfData(); iData++) { // max 8
611 if (!out->getHit(iData)) continue;
612
613 // see TGCcabling/TGCId.h (WD=0,SD,WT,ST,SI,WI). Same as TgcRawData
614 TgcRawData::SlbType type = (TgcRawData::SlbType)moduleType;
615 int subMat = iData % 4;
616 int seg = 0;
617 if (type==TgcRawData::SLB_TYPE_TRIPLET_STRIP ) {
618 if (iData<4) seg= 1;
619 // 13.Jan.2011 reversed by Hisaya
620 // because Layer swap in TGCStripTripletSB::doCoincidence()
621 } else if ( (type==TgcRawData::SLB_TYPE_INNER_WIRE ) ||
622 (type==TgcRawData::SLB_TYPE_INNER_STRIP) ) {
623 seg= iData/4;
624 }
625 std::unique_ptr<TgcRawData> rawdata(new TgcRawData(bcTag,
626 static_cast<uint16_t>(subDetectorId),
627 static_cast<uint16_t>(rodId),
628 static_cast<uint16_t>(sswId),
629 static_cast<uint16_t>(sbLoc),
630 l1Id, bcId,
631 type, out->getDev(iData), seg, subMat,
632 out->getPos(iData)));
633 addRawData(std::move(rawdata), tgcrdo);
634
635 // EIFI trigger bits for SL are filled.
636 if(isEIFI) {
637 bool setEIFITriggerBit =
638 m_innerTrackletSlotHolder.setTriggerBit(sector->getSideId(),
639 phiEIFI,
640 (isEndcap ?
641 TGCInnerTrackletSlot::EI : TGCInnerTrackletSlot::FI),
642 (type==TgcRawData::SLB_TYPE_INNER_WIRE ?
643 TGCInnerTrackletSlot::WIRE : TGCInnerTrackletSlot::STRIP),
644 static_cast<unsigned int>(subMat),
645 true);
646
647 if(!setEIFITriggerBit) {
648 ATH_MSG_INFO("Fail to set Inner trigger bit of"
649 << " sideId= " << sector->getSideId()
650 << " slotId= " << phiEIFI
651 << " region= " << (isEndcap ? "EI" : "FI")
652 << " readout= " << (type==TgcRawData::SLB_TYPE_INNER_WIRE ? "WIRE" : "STRIP")
653 << " subMat(iBit)= " << static_cast<unsigned int>(subMat) );
654 }
655 }
656
657 ATH_MSG_DEBUG(" recordRdoSLB : reg=" << (isEndcap ? "EC" : "FWD")
658 << " srod=" << rodId << " sswId=" << sswId
659 << " SBLoc=" << sbLoc << " type=" << itype
660 << " iData(subMat:seg)=" << iData << " pos="
661 << out->getPos(iData) << " dev=" << out->getDev(iData) );
662 }
663 // end of filling TgcRawData
664
665 } // end of loop over SB
666 } // end loop for SLB type
667}
668
671 std::map<std::pair<int, int>, std::unique_ptr<TgcRdo>>& tgcrdo)
672{
673 if(sector->hasHit() == false) return;
674
675 // readoutID
676 int subDetectorId, rodId, sswId, sbLoc, secId;
677
678 // get numbering scheme info from cabling svc
679 int startEndcapSector, coverageOfEndcapSector;
680 int startForwardSector, coverageOfForwardSector;
681 rodId = 1;
682 m_cabling->getCoveragefromSRodID(rodId,
683 startEndcapSector,
684 coverageOfEndcapSector,
685 startForwardSector,
686 coverageOfForwardSector
687 ) ;
688
689 uint16_t bcTag=m_CurrentBunchTag, l1Id=0, bcId=0;
690
691 // HPTID
692 bool isAside, isEndcap, isStrip; int phi;
693 isAside = (sector->getSideId()==0);
694 isEndcap = (sector->getRegionType() == TGCRegionType::ENDCAP);
695 int module = sector->getModuleId();
696 // sector Id = 0..47 (Endcap) 0..23 (forward)
697 int sectorId;
698 if (isEndcap){
699 sectorId = ((module/3)*2+module%3) + sector->getOctantId()*6;
700 } else {
701 sectorId = (module/3) + sector->getOctantId()*3;
702 }
703 // secId for TgcRawData
704 // 0-3(EC), 0-1(FWD) for new TGCcabling (1/12sector)
705 // 0-5(EC), 0-2(FWD) for new TGCcabling (octant)
706 if (isEndcap){
707 secId = sectorId % coverageOfEndcapSector;
708 } else {
709 secId = sectorId % coverageOfForwardSector;
710 }
711 // phi=1-48(EC), 1-24(FWD) in detector ID scheme
712 phi = (isEndcap ? (sectorId+46)%48+1 : (sectorId+23)%24+1);
713
714 for(int itype=0; itype<2; itype++) { // loop over HPB type(wire/strip)
715 isStrip = (itype==0 ? 0 : 1); // 0=wire 1=strip
716 for(unsigned int ihpb=0; ihpb<sector->getNumberOfHPB(itype); ihpb++) { // loop over # of HPB per sector
717 TGCHighPtBoard * hpb = sector->getHPB(itype, ihpb);
718 if (0==hpb) continue;
719 TGCHighPtChipOut * out = hpb->getOutput();
720 if (0==out) continue;
721
722 // get ReadoutID
723 bool status = m_cabling->getReadoutIDfromHPTID(phi, isAside, isEndcap, isStrip, hpb->getId(),
724 subDetectorId, rodId, sswId, sbLoc);
725 if (!status) {
726 ATH_MSG_WARNING("TGCcablignSvc::getReadoutIDfromHPTID fails");
727 continue;
728 }
729
730 // loop over chip and candidate
731 for(int ichip=0; ichip<NumberOfChip; ichip++) { // NumberOfChip=2
732 for(int icand=0; icand<TGCHighPtChipOut::s_NHitInTrackSelector; icand++) {
733 if (!out->getSel(ichip, icand)) continue; // should be 1 or 2
734 int chip = ichip;
735 int index = ihpb;
736 int hitId = out->getHitID(ichip, icand);
737 m_cabling->getRDOHighPtIDfromSimHighPtID(!isEndcap, isStrip,
738 index, chip, hitId);
739 bool isHPT = out->getPt(ichip,icand)==PtHigh ? 1 : 0;
740 std::unique_ptr<TgcRawData> rawdata(new TgcRawData(bcTag,
741 static_cast<uint16_t>(subDetectorId),
742 static_cast<uint16_t>(rodId),
743 l1Id,
744 bcId,
745 isStrip, (!isEndcap), secId, chip, icand,
746 isHPT, hitId,
747 out->getPos(ichip, icand),
748 out->getDev(ichip, icand),
749 0));
750 addRawData(std::move(rawdata), tgcrdo);
751
752 // Print
753 ATH_MSG_DEBUG( "recordRdoHPT : bdTag =" << bcTag
754 << " side=" << ( (isAside)? "A" : "C")
755 << (isEndcap ? "EC" : "FWD")
756 << " w/s=" << ( (isStrip)? "s" : "w")
757 << " id=" << hpb->getId()
758 << " ecId=" << secId
759 << " chip=" << ichip
760 << " cand=" << icand
761 << " block=" << out->getHitID(ichip, icand)
762 << " subMatrix=" << out->getPos(ichip, icand)
763 << " dev=" << out->getDev(ichip, icand)
764 << " srod=" << rodId << " sswId=" << sswId << " SBLoc=" << sbLoc );
765
766 // Strip HPT hit may be duplicated
767 if ( m_tgcArgs.SHPT_ORED() &&
768 isEndcap && isStrip &&
769 (chip==1) ) {
770 int oredId = -1;
771 if (hitId == 1) oredId = 5;
772 else if (hitId == 2) oredId = 6;
773 else if (hitId == 5) oredId = 1;
774 else if (hitId == 6) oredId = 2;
775 if (oredId >=0) {
776 std::unique_ptr<TgcRawData> rawdata2(
777 new TgcRawData(bcTag,
778 static_cast<uint16_t>(subDetectorId),
779 static_cast<uint16_t>(rodId),
780 l1Id,
781 bcId,
782 isStrip, (!isEndcap), secId, chip, icand,
783 isHPT, oredId,
784 out->getPos(ichip, icand),
785 out->getDev(ichip, icand),
786 0));
787 addRawData(std::move(rawdata2), tgcrdo);
788 }
790
791 }
792
793 }
794 }
795 // end loop of candidate and chip
796
797 } // end loop for # of HPB per sector
798 } // end loop for HPB type
799}
800
801
804 std::map<std::pair<int, int>, std::unique_ptr<TgcRdo>>& tgcrdo)
805{
806 const bool isAside = sector->getSideId()==0;
807 const bool isEndcap = (sector->getRegionType() == TGCRegionType::ENDCAP);
808 if (!isEndcap) return;
809
810 //*** isEndcap must be true for the rest of this function. ***
811
812 // sector Id = 0..47, phi = 1..48
813 int module = sector->getModuleId();
814 int octant = sector->getOctantId();
815 int sectorId = ((module/3)*2+module%3) + octant*6;
816 int phi = (sectorId+46)%48+1;
817
818 // get readout ID
819 int subDetectorId=0, rodId=0, sswId=0, sbLoc=0;
820
821 bool status = m_cabling->getSReadoutIDfromSLID(phi, isAside, isEndcap,
822 subDetectorId, rodId, sswId, sbLoc);
823 if (!status) {
824 ATH_MSG_WARNING("TGCcablingSvc::ReadoutIDfromSLID fails in recordRdoInner()" );
825 return;
826 }
827
828 // secID for TGCRawData
829 // 0-3(EC), 0-1(FWD) for 1/12 sector
830 // 0-15(EC), 0-7(FWD) for 1/3 sector covered by SROD in RUn3
831 int startEndcapSector, coverageOfEndcapSector;
832 int startForwardSector, coverageOfForwardSector;
833 if (!m_cabling->getCoveragefromSRodID(rodId,
834 startEndcapSector,
835 coverageOfEndcapSector,
836 startForwardSector,
837 coverageOfForwardSector
838 ) )
839 {
840 ATH_MSG_WARNING("LVL1TGCTrigger::recordRdoInner --- bad rodId " << rodId );
841 return;
842 }
843
844 int secId = 0;
845 secId = sectorId % coverageOfEndcapSector;
846
847 uint16_t bcTag = m_CurrentBunchTag, l1Id = 0, bcId = 0;
848
849 // EIFI
851
852 const TGCInnerTrackletSlot* innerTrackletSlots[n_slots] = {0, 0, 0, 0};
853 m_innerTrackletSlotHolder.getInnerTrackletSlots(sector->getSideId(),
854 octant, module, innerTrackletSlots);
855
856 std::array<int, n_slots>inner_eifi;
857 m_innerTrackletSlotHolder.getInnerTrackletBits(innerTrackletSlots, inner_eifi);
858
859 for (int i_slot = 0; i_slot < n_slots; i_slot++) {
860 if (inner_eifi[i_slot] > 0) {
861 std::unique_ptr<TgcRawData> rawdata_eifi(new TgcRawData(bcTag,
862 static_cast<uint16_t>(subDetectorId),
863 static_cast<uint16_t>(rodId),
864 l1Id,
865 bcId,
866 (!isEndcap),
867 secId, /*to be checked*/
868 static_cast<uint16_t>(inner_eifi[i_slot]),
869 0, /*fi*/
870 static_cast<uint16_t>(i_slot) /*chamber Id*/));
871 addRawData(std::move(rawdata_eifi), tgcrdo);
872 }
873 }
874
875 // Tile
876 int inner_tile = m_system->getTMDB()->getInnerTileBits(sector->getSideId(), sectorId);
877
878 if (inner_tile > 0) {
879 //TgcRawData * rawdata_tile = new TgcRawData(bcTag,
880 //std::shared_ptr<TgcRawData> rawdata_tile (
881 std::unique_ptr<TgcRawData> rawdata_tile (new TgcRawData(bcTag,
882 static_cast<uint16_t>(subDetectorId),
883 static_cast<uint16_t>(rodId),
884 l1Id,
885 bcId,
886 (!isEndcap),
887 secId,
888 inner_tile,
889 0 /*bcid*/ ));
890 addRawData(std::move(rawdata_tile), tgcrdo);
891 }
892
893 // NSW
894 TGCRegionType region = sector->getRegionType();
895 if ( m_USENSW ) {
896 std::shared_ptr<const LVL1TGC::NSWTrigOut> nsw_trigout = m_system->getNSW()->getOutput(region, !isAside, sectorId);
897 for ( int icand=0; icand<(int)nsw_trigout->getNSWeta().size(); icand++ ){
898 std::unique_ptr<TgcRawData> rawdata_nsw (new TgcRawData(bcTag,
899 static_cast<uint16_t>(subDetectorId),
900 static_cast<uint16_t>(rodId),
901 l1Id,
902 bcId,
903 (!isEndcap),
904 static_cast<uint16_t>(secId), /*?*/
905 static_cast<uint16_t>(nsw_trigout->getNSWeta().at(icand)),
906 static_cast<uint16_t>(nsw_trigout->getNSWphi().at(icand)),
907 static_cast<uint16_t>(icand), //nswcand
908 static_cast<uint16_t>(nsw_trigout->getNSWDtheta().at(icand)),
909 0, //nswphires
910 0, //nswlowres
911 static_cast<uint16_t>(nsw_trigout->getNSWTriggerProcessor().at(icand))));
912 addRawData(std::move(rawdata_nsw), tgcrdo);
913 }
914 }
915
916 // RPC BIS78
917 if ( m_USEBIS78 ) {
918 std::shared_ptr<const LVL1TGC::BIS78TrigOut> bis78_trigout = m_system->getBIS78()->getOutput(sectorId);
919 for ( int icand=0; icand<(int)bis78_trigout->getBIS78eta().size(); icand++ ){
920 std::unique_ptr<TgcRawData> rawdata_bis78 (new TgcRawData(bcTag,
921 static_cast<uint16_t>(subDetectorId),
922 static_cast<uint16_t>(rodId),
923 l1Id,
924 bcId,
925 (!isEndcap),
926 static_cast<uint16_t>(secId), /*?*/
927 static_cast<uint16_t>(bis78_trigout->getBIS78eta().at(icand)),
928 static_cast<uint16_t>(bis78_trigout->getBIS78phi().at(icand)),
929 static_cast<uint16_t>(icand),
930 static_cast<uint16_t>(bis78_trigout->getBIS78Deta().at(icand)),
931 static_cast<uint16_t>(bis78_trigout->getBIS78Dphi().at(icand))));
932 addRawData(std::move(rawdata_bis78), tgcrdo);
933 }
934 }
935}
936
939 std::map<std::pair<int, int>, std::unique_ptr<TgcRdo>>& tgcrdo)
940{
941 // check if whether trigger output exists or not
942 std::shared_ptr<TGCTrackSelectorOut> selectorOut;
943 sector->getSL()->getTrackSelectorOutput(selectorOut);
944
945 if (selectorOut == nullptr) return;
946 if (selectorOut->getNCandidate() == 0) return;
947
948 // trigger info
949 // bool cand3plus = 0;
950 bool isEndcap = (sector->getRegionType() == TGCRegionType::ENDCAP);
951 bool isAside = (sector->getSideId()==0);
952 bool veto=0;
953 int phi=0, index=0, threshold=0, roi=0;
954 int Zdir= (isAside) ? 1 : -1;
955
956 // sector Id = 0..47 (Endcap) 0..23 (forward)
957 int module = sector->getModuleId();
958 int sectorId;
959 if (isEndcap){
960 sectorId = ((module/3)*2+module%3) + sector->getOctantId()*6;
961 } else {
962 sectorId = (module/3) + sector->getOctantId()*3;
963 }
964
965 // secID for TGCRawData
966 // 0-3(EC), 0-1(FWD) for new TGCcabling (1/12sector)
967 // 0-5(EC), 0-2(FWD) for new TGCcabling (octant)
968 int startEndcapSector, coverageOfEndcapSector;
969 int startForwardSector, coverageOfForwardSector;
970 int rodId = 1;
971 m_cabling->getCoveragefromSRodID(rodId,
972 startEndcapSector,
973 coverageOfEndcapSector,
974 startForwardSector,
975 coverageOfForwardSector
976 ) ;
977 int secId = 0;
978 if (isEndcap){
979 secId = sectorId % coverageOfEndcapSector;
980 } else {
981 secId = sectorId % coverageOfForwardSector;
982 }
983
984 // phi=1-48(EC), 1-24(FWD) in detector ID scheme
985 phi = (isEndcap ? (sectorId+46)%48+1 : (sectorId+23)%24+1);
986
987 // get readout ID
988 int subDetectorId = 0, sswId = 0, sbLoc = 0;
989 bool status = m_cabling->getSReadoutIDfromSLID(phi, isAside, isEndcap,
990 subDetectorId, rodId, sswId, sbLoc);
991 if (!status) {
992 ATH_MSG_WARNING("TGCcablignSvc::ReadoutIDfromSLID fails"
993 << (isEndcap ? " Endcap-" : " Forward-")
994 << (isAside ? "A " : "C ")
995 << " phi=" << phi );
996 return;
997 }
998
999 // bool overlap = 0;
1000 int inner=0, coinFlag=0;
1001 uint16_t bcTag=m_CurrentBunchTag, l1Id=0, bcId=0;
1002 for (unsigned int icand=0; icand < (unsigned int)selectorOut->getNCandidate(); ++icand) {
1003 index=icand;
1004 bool muplus = getCharge(selectorOut->getDR(icand), Zdir)==1 ? 1 : 0;
1005 threshold = selectorOut->getPtLevel(icand);
1006 roi = ((selectorOut->getR(icand))<<2)+(selectorOut->getPhi(icand));
1007 if (selectorOut->getInnerVeto(icand)) veto = 1;
1008 else veto = 0;
1009
1010 inner = selectorOut->getInnerCoincidenceFlag(icand);
1011 coinFlag = selectorOut->getCoincidenceType(icand);
1012
1013 // create TgcRawData
1014 std::unique_ptr<TgcRawData> rawdata(new TgcRawData(bcTag,
1015 static_cast<uint16_t>(subDetectorId),
1016 static_cast<uint16_t>(rodId),
1017 l1Id,
1018 bcId,
1019 (!isEndcap), secId,
1020 inner,
1021 coinFlag,
1022 muplus, threshold, roi));
1023 addRawData(std::move(rawdata), tgcrdo);
1024
1025 ATH_MSG_DEBUG("recordRdoSL : bcTag =" << bcTag
1026 << " side=" << (isAside ? "A " : "C ")
1027 << " reg=" << (isEndcap ? "EC" : "FWD")
1028 << " phi=" << phi
1029 << " cand=" << index
1030 << " charge=" << (muplus ? "mu+" : "mu-")
1031 << " thre=" << threshold
1032 << " veto=" << veto
1033 << " roi=" << roi
1034 << " srod=" << rodId << " sswId=" << sswId << " SBLoc=" << sbLoc
1035 << " inner=" << inner << " coinFlag=" << coinFlag );
1036 }
1037 }
1038
1040// Mask=0/Fire=1
1042{
1043 std::string fname=m_MaskFileName12.value();
1044 if (fname.empty()) return StatusCode::SUCCESS;
1045
1046 std::string fullName = PathResolver::find_file (fname, "PWD");
1047 if( fullName.empty())
1048 fullName = PathResolver::find_file (fname, "DATAPATH");
1049
1050 std::ifstream fin(fullName.c_str());
1051 if (!fin) {
1052 ATH_MSG_FATAL("Cannot open file " << (fullName.empty() ? fname : fullName));
1053 return StatusCode::FAILURE;
1054 } else {
1055 ATH_MSG_INFO("Use mask file : " << fullName);
1056 }
1057 // read database ------------------------------------------------------------------------------
1058 std::vector<std::string> mask;
1059 std::string aLine;
1060 while(getline(fin,aLine)) {
1061 if (aLine.compare(0,3,"///")!=0) break;
1062 }
1063 int id_type = atoi(aLine.c_str());
1064 while(getline(fin,aLine)) {
1065 if (!aLine.empty()) mask.push_back(aLine);
1066 }
1067 fin.close();
1068
1069 //
1070 std::vector<int> ids;
1071 Identifier ID;
1072 int nmasked=0, nfired=0;
1073 for(int ich=0; ich<(int)mask.size(); ich++) {
1074 std::string ch = mask[ich];
1075 extractFromString(ch, ids);
1076 int OnOff=ids[0]; // 0=off(masked) 1=on(fired)
1077 //
1078 if (id_type==1 && ids.size()==8) { // online
1079 int sysno1 = (ids[1]==-99 ? -1 : ids[1]); int sysno2=(ids[1]==-99 ? 1 : ids[1]);// -1(B) 1(F)
1080 int octno1 = (ids[2]==-99 ? 0 : ids[2]); int octno2=(ids[2]==-99 ? 7 : ids[2]);
1081 for(int sysno=sysno1; sysno<=sysno2; sysno+=2) {
1082 for(int octno=octno1; octno<=octno2; octno++) {
1083 bool status = m_cabling->getOfflineIDfromOnlineID(ID,sysno,octno,
1084 ids[3],ids[4],ids[5],ids[6],ids[7]);
1085 ATH_MSG_VERBOSE( (OnOff==0 ? "Mask" : "Fire") << " : offlineID=" << ID
1086 << " sys=" << sysno << " oct=" << octno << " modno=" << ids[3]
1087 << " layerno=" << ids[4] << " rNumber=" << ids[5]
1088 << " strip=" << ids[6] << " chno=" << ids[7] );
1089
1090 if (!status) {
1091 ATH_MSG_WARNING("This onlineID is not valid and cannot be converted to offline ID." );
1092 ATH_MSG_WARNING("sys=" << sysno << " oct=" << octno << " modno=" << ids[3]
1093 << " layerno=" << ids[4] << " rNumber=" << ids[5]
1094 << " strip=" << ids[6] << " chno=" << ids[7] );
1095 } else {
1096 m_MaskedChannel.insert(std::map<Identifier, int>::value_type(ID, OnOff));
1097 if (OnOff==0) nmasked+=1;
1098 else if (OnOff==1) nfired+=1;
1099 }
1100 }
1101 }
1102
1103 } else if (id_type==2 && ids.size()==6) { // readout id
1104 int sysno1 = (ids[1]==-99 ? 103 : ids[1]); int sysno2=(ids[1]==-99 ? 104 : ids[1]);// 103(F), 104(B)
1105 int octno1 = (ids[2]==-99 ? 0 : ids[2]); int octno2=(ids[2]==-99 ? 7 : ids[2]);
1106 for(int sysno=sysno1; sysno<=sysno2; sysno+=1) {
1107 for(int octno=octno1; octno<=octno2; octno++) {
1108 bool status = m_cabling->getOfflineIDfromReadoutID(ID, sysno,octno,ids[3],ids[4],ids[5]);
1109 ATH_MSG_VERBOSE( (OnOff==0 ? "Mask" : "Fire") << " : offlineID=" << ID
1110 << " subdetectorID=" << sysno << " rodId=" << octno << " sswID=" << ids[3]
1111 << " SBLoc=" << ids[4] << " channelId=" << ids[5] );
1112 if (!status) {
1113 ATH_MSG_WARNING("This readoutID is not valid and cannot be converted to offline ID " );
1114 ATH_MSG_WARNING("subdetectorID=" << sysno << " rodId=" << octno << " sswID=" << ids[3]
1115 << " SBLoc=" << ids[4] << " channelId=" << ids[5] );
1116 } else {
1117 m_MaskedChannel.insert(std::map<Identifier, int>::value_type(ID, OnOff));
1118 if (OnOff==0) nmasked+=1;
1119 else if (OnOff==1) nfired+=1;
1120 }
1121 }
1122 }
1123
1124 } else if (id_type==3 && ids.size()==2) { // offline id
1125 ID = Identifier((unsigned int)ids[1]);
1126 ATH_MSG_DEBUG((OnOff==0 ? "Mask" : "Fire") << " : offlineID=" << ID);
1127 m_MaskedChannel.insert(std::map<Identifier, int>::value_type(ID, OnOff));
1128 if (OnOff==0) nmasked+=1;
1129 else if (OnOff==1) nfired+=1;
1130
1131 } else {
1132 ATH_MSG_INFO("Invalid input. Idtype or number of parameters are invalid: idtype=" << id_type
1133 << " number of elements = " << ids.size() );
1134 return StatusCode::FAILURE;
1135 }
1136 }
1137 //
1138 ATH_MSG_INFO("Total number of masked channels ... " << nmasked);
1139 ATH_MSG_INFO("Total number of fired channels ... " << nfired);
1140 //
1141 return StatusCode::SUCCESS;
1142}
1143
1146 if (m_bsMetaDataContRHKey.key().empty()) return StatusCode::SUCCESS;
1147
1148 ATH_MSG_DEBUG("Retrieving Detector Mask from ByteStream metadata container");
1150 if (bsmdc.isValid() && !bsmdc->empty()) {
1151 const ByteStreamMetadata* metadata = bsmdc->front();
1152 uint64_t detMaskLeast = metadata->getDetectorMask();
1153 uint64_t detMaskMost = metadata->getDetectorMask2();
1154
1155 std::vector<eformat::SubDetector> subDetOff;
1156 eformat::helper::DetectorMask(~detMaskLeast, ~detMaskMost).sub_detectors(subDetOff);
1157 auto sideA = std::find_if(subDetOff.begin(), subDetOff.end(), [](const eformat::SubDetector &s) {
1158 return (s == eformat::MUON_MMEGA_ENDCAP_A_SIDE || s == eformat::MUON_STGC_ENDCAP_A_SIDE); });
1159 auto sideC = std::find_if(subDetOff.begin(), subDetOff.end(), [](const eformat::SubDetector &s) {
1160 return (s == eformat::MUON_MMEGA_ENDCAP_C_SIDE || s == eformat::MUON_STGC_ENDCAP_C_SIDE); });
1161
1162 if (sideA != std::end(subDetOff)) tgcArgs()->set_NSWSideInfo(m_NSWSideInfo.value().erase(0,1));
1163 else if (sideC != std::end(subDetOff)) tgcArgs()->set_NSWSideInfo(m_NSWSideInfo.value().erase(1,1));
1164 else if (sideA != std::end(subDetOff) && sideC != std::end(subDetOff)) tgcArgs()->set_NSWSideInfo("");
1165 }
1166 return StatusCode::SUCCESS;
1167}
1168
1170void LVL1TGCTrigger::extractFromString(const std::string& str, std::vector<int> & v) {
1171 v.clear();
1172 if (str.empty()) return;
1173 std::string line=str;
1174 while(1) {
1175 if (line.empty()) break;
1176 int i = line.find(' ');
1177 if (i==(int)std::string::npos && !line.empty()) {
1178 v.push_back(atoi(line.c_str()));
1179 break;
1180 }
1181 std::string temp = line;
1182 temp.erase(i,line.size());
1183 v.push_back(atoi(temp.c_str()));
1184 line.erase(0,i+1);
1185 }
1186}
1187
1189int LVL1TGCTrigger::getCharge(int dR, int /*Zdir*/) {
1190 // old scheme
1191 // if (dR==0) return (Zdir>0 ? -1 : 1);
1192 // return (dR*Zdir>0 ? 1 : -1);
1193 return (dR >=0 ? 1 : -1 );
1194}
1195
1197// see TGCNumbering.h
1199{
1200 switch(type) {
1201 case WTSB :
1203 case WDSB :
1205 case STSB :
1207 case SDSB :
1209 case WISB :
1211 case SISB :
1213 default :
1214 return -1;
1215 }
1216}
1217
1219 bool LVL1TGCTrigger::addRawData(std::unique_ptr<TgcRawData> rawdata,
1220 std::map<std::pair<int, int>, std::unique_ptr<TgcRdo>>& tgcrdo)
1221{
1222 ATH_MSG_DEBUG("addRawData() is called.");
1223 std::pair<int, int> subDetectorRod(rawdata->subDetectorId(), rawdata->rodId());
1224 std::map<std::pair<int, int>, std::unique_ptr<TgcRdo>>::iterator itRdo = tgcrdo.find(subDetectorRod);
1225
1226 if (itRdo==tgcrdo.end()) {
1227 // in case TgcRdo with the given subDetectorId and rodId is
1228 // not registered yet, create new TgcRdo and add rawdata to it
1229 std::unique_ptr<TgcRdo> thisRdo(new TgcRdo(rawdata->subDetectorId(), rawdata->rodId(), rawdata->bcId(), rawdata->l1Id()));
1230 thisRdo->push_back(std::move(rawdata));
1231 tgcrdo.insert(std::map<std::pair<int, int>, std::unique_ptr<TgcRdo>>::value_type(subDetectorRod, std::move(thisRdo)));
1232 } else {
1233 itRdo->second->push_back(std::move(rawdata));
1234 }
1235 return true;
1236}
1237
1240{
1241 ATH_MSG_DEBUG("LVL1TGCTrigger::getCabling()");
1242
1243 // get Cabling service
1244 ATH_CHECK(m_cabling.retrieve());
1245
1246 int maxRodId, maxSRodId, maxSswId, maxSbloc,minChannelId, maxChannelId;
1247 m_cabling->getReadoutIDRanges( maxRodId, maxSRodId, maxSswId, maxSbloc,minChannelId, maxChannelId);
1248 if (maxRodId ==12) {
1249 ATH_MSG_INFO(m_cabling->name() << " is OK");
1250 } else {
1251 ATH_MSG_FATAL("Old TGCcablingSvc(octant segmentation) can not be used !");
1252 return StatusCode::FAILURE;
1253 }
1254
1255 ATH_MSG_DEBUG("finished LVL1TGCTrigger::getCabling()");
1256
1257 return StatusCode::SUCCESS;
1258}
1259
1260
1261} // end of namespace
1262
Scalar phi() const
phi method
#define endmsg
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_FATAL(x)
#define ATH_MSG_INFO(x)
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
std::vector< Identifier > ID
This file defines the class for a collection of AttributeLists where each one is associated with a ch...
static Double_t sc
if(febId1==febId2)
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
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 Athena::TPCnvVers::Old Athena::TPCnvVers::Old TgcRdo
uint16_t bcId(uint32_t data)
unsigned bcTag(unsigned bcBitMap)
AthAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor with parameters:
Header file for AthHistogramAlgorithm.
This class is the StoreGate data object for bytestream metadata.
Class representing (part of) the input data to the MuCTPI for Phase 1.
void setSectorLogicData(const Lvl1MuSectorLogicDataPhase1 &data, size_t systemAddress, size_t subSystemAddress, size_t sectorAddress, int bcid=0)
Class representing data from an endcap SL board.
Base class for the data coming from one SL board.
std::map< Identifier, int > m_MaskedChannel
mask channel map
StatusCode processOneBunch(const TgcDigitContainer *, LVL1MUONIF::Lvl1MuCTPIInputPhase1 *, std::map< std::pair< int, int >, std::unique_ptr< TgcRdo > > &)
TGCInnerTrackletSlotHolder m_innerTrackletSlotHolder
void recordRdoHPT(TGCSector *, std::map< std::pair< int, int >, std::unique_ptr< TgcRdo > > &)
SG::ReadHandleKey< Muon::NSW_TrigRawDataContainer > m_keyNSWTrigOut
virtual StatusCode execute() override
virtual StatusCode start() override
SG::ReadHandleKey< Muon::RpcBis78_TrigRawDataContainer > m_keyBIS78TrigOut
SG::ReadHandleKey< TgcDigitContainer > m_keyTgcDigit
SG::ReadCondHandleKey< TGCTriggerLUTs > m_readLUTs_CondKey
void recordRdoInner(TGCSector *, std::map< std::pair< int, int >, std::unique_ptr< TgcRdo > > &)
void recordRdoSL(TGCSector *, std::map< std::pair< int, int >, std::unique_ptr< TgcRdo > > &)
SG::ReadHandleKey< TgcRdoContainer > m_keyTgcRdoIn
SG::ReadHandleKey< TileMuonReceiverContainer > m_keyTileMu
ShortProperty m_CurrentBunchTag
property, see LVL1TGCTrigger::LVL1TGCTrigger
virtual StatusCode finalize() override
virtual StatusCode initialize() override
SG::ReadCondHandleKey< TGCTriggerData > m_readCondKey
void extractFromString(const std::string &, std::vector< int > &)
SG::WriteHandleKey< TgcRdoContainer > m_keyTgcRdo
LVL1TGCTrigger(const std::string &name, ISvcLocator *pSvcLocator)
standard constructor and destructor for algorithms
SG::WriteHandleKey< LVL1MUONIF::Lvl1MuCTPIInputPhase1 > m_muctpiPhase1Key
ServiceHandle< MuonTGC_CablingSvc > m_cabling
void fillTGCEvent(const std::map< Identifier, int > &, TGCEvent &)
SG::ReadHandleKey< ByteStreamMetadataContainer > m_bsMetaDataContRHKey
void recordRdoSLB(TGCSector *, std::map< std::pair< int, int >, std::unique_ptr< TgcRdo > > &)
bool addRawData(std::unique_ptr< TgcRawData > rawdata, std::map< std::pair< int, int >, std::unique_ptr< TgcRdo > > &tgcrdo)
std::unique_ptr< TGCElectronicsSystem > m_system
StringProperty m_MaskFileName12
property, see LVL1TGCTrigger::LVL1TGCTrigger
BooleanProperty m_OutputTgcRDO
property, see LVL1TGCTrigger::LVL1TGCTrigger
void FillSectorLogicData(LVL1MUONIF::Lvl1MuSectorLogicDataPhase1 *sldata, const TGCTrackSelectorOut *trackSelectorOut)
void doMaskOperation(const TgcDigitContainer *, std::map< Identifier, int > &)
std::unique_ptr< TGCTimingManager > m_TimingManager
const TGCReadoutIndex & GetTGCReadoutIndex() const
Definition TGCASDOut.h:33
TGCSignalType GetSignalType() const
Definition TGCASDOut.h:34
double GetHitToF() const
Definition TGCASDOut.h:37
static constexpr int s_NHitInTrackSelector
TGCZDirection GetZDirection() const
void setInnerTrackletSlots(const TGCInnerTrackletSlot *innerTrackletSlots[])
void getTrackSelectorOutput(std::shared_ptr< TGCTrackSelectorOut > &trackSelectorOut) const
TGCHighPtBoard * getHPB(int type, int index) const
Definition TGCSector.h:147
TGCRegionType getRegionType() const
Definition TGCSector.h:169
TGCSectorLogic * getSL()
Definition TGCSector.h:65
unsigned int getNumberOfHPB(int type) const
Definition TGCSector.h:164
LVL1TGC::TGCSide getSideId() const
Definition TGCSector.h:75
static std::string find_file(const std::string &logical_file_name, const std::string &search_path)
virtual bool isValid() override final
Can the handle be successfully dereferenced?
const_pointer_type cptr()
Dereference the pointer.
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
pointer_type ptr()
Dereference the pointer.
bool isActive(int cwtype) const
Use IdentifiableContainer with TgcDigitCollection.
@ BC_CURRENT
Definition TgcDigit.h:37
@ BC_PREVIOUS
Definition TgcDigit.h:37
@ BC_NEXTNEXT
Definition TgcDigit.h:37
An unit object of TGC ROD output.
Definition TgcRawData.h:23
@ 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
uint16_t rodId() const
Definition TgcRdo.h:138
uint16_t subDetectorId() const
Definition TgcRdo.h:134
std::vector< std::string > veto
these patterns are anded
Definition listroot.cxx:191
const int NumberOfChip
TGCSide
The sides of TGC (A- or C-side)
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
Definition index.py:1