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