ATLAS Offline Software
Loading...
Searching...
No Matches
TgcDigitToTgcRDO.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3*/
4
5#include "TgcDigitToTgcRDO.h"
6
12
15namespace {
16 static uint16_t identifyFragment(const TgcRawData& rawData) {
17 return TgcRdo::identifyRawData(rawData);
18 }
19}
20
21TgcDigitToTgcRDO::TgcDigitToTgcRDO(const std::string& name, ISvcLocator* pSvcLocator) :
22 AthReentrantAlgorithm(name, pSvcLocator){}
23
24// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
25
27 ATH_MSG_DEBUG(" in initialize()");
28 ATH_CHECK(m_idHelperSvc.retrieve());
29
30 ATH_MSG_DEBUG("standard digitization job: "
31 << "initialize now the TGC cabling and TGC container.");
33
34 ATH_CHECK(m_rdoContainerKey.initialize());
35 ATH_MSG_VERBOSE("Initialized WriteHandleKey: " << m_rdoContainerKey);
36 ATH_CHECK(m_digitContainerKey.initialize());
37 ATH_MSG_VERBOSE("Initialized ReadHandleKey: " << m_digitContainerKey);
38
39 return StatusCode::SUCCESS;
40}
41
42// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
43// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
44
45StatusCode TgcDigitToTgcRDO::execute(const EventContext& ctx) const {
46 ATH_MSG_DEBUG("in execute()");
47
49 ATH_CHECK(rdoContainer.record(std::make_unique<TgcRdoContainer>()));
50 ATH_MSG_DEBUG("Recorded TgcRdoContainer called " << rdoContainer.name() << " in store " << rdoContainer.store());
52 ATH_CHECK(container.isPresent());
53 ATH_MSG_DEBUG("Found TgcDigitContainer called " << container.name() << " in store " << container.store());
54
55 std::map<uint16_t, std::unique_ptr<TgcRdo>> tgcRdoMap{};
56
57 const TgcRdoIdHash hashF;
58
59 // loop over collections
60 for (const TgcDigitCollection* tgcCollection : *container) {
61
62 // Iterate on the digits of the collection
63 for (const TgcDigit* tgcDigit : *tgcCollection) {
64 const Identifier channelId = tgcDigit->identify();
65 const uint16_t bctag = m_isNewTgcDigit ? tgcDigit->bcTag() : 0;
66
67 // Get the online Id of the channel
68 int subDetectorID{0}, rodID{0}, sswID{0}, slbID{0}, channelID{0};
69
70 // repeat two times for Adjacent Channel
71 for (int iAd = 0; iAd < 2; ++iAd) {
72 bool adFlag = false;
73
74 // check if this channel has Adjacent partner only when 2nd time
75 if (iAd != 0) {
76 bool a_found = m_cabling->hasAdjacentChannel(channelId);
77
78 // set Adjacent flag
79 if (a_found)
80 adFlag = true;
81 else
82 continue;
83 }
84
85 // get Online ID
86 bool status = m_cabling->getReadoutIDfromOfflineID(channelId, subDetectorID, rodID, sswID, slbID, channelID, adFlag);
87
88 if (!status) {
89 ATH_MSG_DEBUG("MuonTGC_CablingSvc can't return an online ID for the channel : "
90 << MSG::dec << " N_" << m_idHelperSvc->toString(channelId) );
91 continue;
92 }
93
94 // Create the new Tgc RawData
95 bool isStrip = m_idHelperSvc->tgcIdHelper().isStrip(channelId);
96 std::string name = m_idHelperSvc->tgcIdHelper().stationNameString(m_idHelperSvc->tgcIdHelper().stationName(channelId));
98 if (name[1] == '4')
100 else if (name[1] == '1')
102 else
104
105 auto rawData = std::make_unique<TgcRawData>(bctag, subDetectorID, rodID, sswID, slbID, 0, 0, type, adFlag, 0, channelID);
106
107 ATH_MSG_DEBUG("Adding a new RawData");
108 ATH_MSG_DEBUG(MSG::hex << " Sub : " << subDetectorID << " ROD : " << rodID << " SSW : " << sswID << " SLB : " << slbID
109 << " Ch : " << channelID);
110
111 // Add the RawData to the RDO
112 const uint16_t rdoId = identifyFragment(*rawData);
113 std::unique_ptr<TgcRdo>& tgcRdo = tgcRdoMap[rdoId];
114
115 if(!tgcRdo) {
116 // create new TgcRdo
117 const IdentifierHash hashId = hashF(rdoId);
118 tgcRdo = std::make_unique<TgcRdo>(rdoId, hashId);
119 tgcRdo->setOnlineId(rawData->subDetectorId(), rawData->rodId());
120 }
121 tgcRdo->push_back(std::move(rawData));
122 }
123 }
124 }
125
126 ATH_MSG_DEBUG("Add RDOs to the RdoContainer");
127 // Add RDOs to the RdoContainer
128 for (auto&[onlineId, rdo] : tgcRdoMap) {
129 unsigned int elementHash = hashF(onlineId);
130 ATH_CHECK(rdoContainer->addCollection(rdo.release(), elementHash));
131 }
132 ATH_MSG_DEBUG("Added RDOs to the RdoContainer XXXXXX");
133
134 return StatusCode::SUCCESS;
135}
136
137// NOTE: although this function has no clients in release 22, currently the Run2 trigger simulation is still run in
138// release 21 on RDOs produced in release 22. Since release 21 accesses the TagInfo, it needs to be written to the
139// RDOs produced in release 22. The fillTagInfo() function thus needs to stay in release 22 until the workflow changes
141 ServiceHandle<ITagInfoMgr> tagInfoMgr("TagInfoMgr", name());
142 if (tagInfoMgr.retrieve().isFailure()) return StatusCode::FAILURE;
143
144 StatusCode sc = tagInfoMgr->addTag("TGC_CablingType", m_cablingType);
145
146 if (sc.isFailure()) {
147 ATH_MSG_WARNING("TGC_CablingType " << m_cablingType << " not added to TagInfo ");
148 return sc;
149 } else {
150 ATH_MSG_DEBUG("TGC_CablingType " << m_cablingType << " is Added TagInfo ");
151 }
152
153 return StatusCode::SUCCESS;
154}
155
157 ATH_CHECK(m_cabling.retrieve());
158
159 int maxRodId = m_cabling->getMaxRodId();
160 if (maxRodId == 12) {
161 ATH_MSG_INFO(m_cabling->name() << " (12-fold) is selected ");
162 m_cablingType = "TGCcabling12Svc";
163 } else {
164 ATH_MSG_INFO("Other TGC cabling scheme is (e.g. 8-fold) is selected");
165 m_cablingType = "TGCcabling8Svc";
166 }
167
168 // Fill Tag Info
170
171 return StatusCode::SUCCESS;
172}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_INFO(x)
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
An algorithm that can be simultaneously executed in multiple threads.
This is a "hash" representation of an Identifier.
std::string store() const
Return the name of the store holding the object we are proxying.
const std::string & name() const
Return the StoreGate ID for the referenced object.
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
ServiceHandle< MuonTGC_CablingSvc > m_cabling
virtual StatusCode initialize() override final
BooleanProperty m_isNewTgcDigit
SG::WriteHandleKey< TgcRdoContainer > m_rdoContainerKey
SG::ReadHandleKey< TgcDigitContainer > m_digitContainerKey
std::string m_cablingType
ServiceHandle< Muon::IMuonIdHelperSvc > m_idHelperSvc
virtual StatusCode execute(const EventContext &ctx) const override final
StatusCode fillTagInfo() const
TgcDigitToTgcRDO(const std::string &name, ISvcLocator *pSvcLocator)
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
@ SLB_TYPE_UNKNOWN
Definition TgcRawData.h:38
static uint16_t identifyRawData(const TgcRawData &rawData)
Definition TgcRdo.cxx:47
setWord1 uint16_t