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
21
22// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
23
25 ATH_MSG_DEBUG(" in initialize()");
26 ATH_CHECK(m_idHelperSvc.retrieve());
27
28 ATH_MSG_DEBUG("standard digitization job: "
29 << "initialize now the TGC cabling and TGC container.");
30
31 ATH_CHECK(m_rdoContainerKey.initialize());
32 ATH_CHECK(m_digitContainerKey.initialize());
33 ATH_CHECK(m_cablingKey.initialize());
34 // NOTE: although this function has no clients in release 22, currently the Run2 trigger simulation is still run in
35 // release 21 on RDOs produced in release 22. Since release 21 accesses the TagInfo, it needs to be written to the
36 // RDOs produced in release 22. The fillTagInfo() function thus needs to stay in release 22 until the workflow changes
37
38 ServiceHandle<ITagInfoMgr> tagInfoMgr("TagInfoMgr", name());
39
40 ATH_CHECK(tagInfoMgr.retrieve());
41 ATH_CHECK(tagInfoMgr->addTag("TGC_CablingType", "TGCcabling12Svc"));
42
43 return StatusCode::SUCCESS;
44}
45// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
46// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
47
48StatusCode TgcDigitToTgcRDO::execute(const EventContext& ctx) const {
49 ATH_MSG_DEBUG("in execute()");
50
51 SG::WriteHandle rdoContainer(m_rdoContainerKey, ctx);
52 ATH_CHECK(rdoContainer.record(std::make_unique<TgcRdoContainer>()));
53 ATH_MSG_DEBUG("Recorded TgcRdoContainer called " << rdoContainer.name() << " in store " << rdoContainer.store());
56
57 const Muon::TgcCablingMap* cabling{nullptr};
58 ATH_CHECK(SG::get(cabling, m_cablingKey, ctx));
59 std::map<uint16_t, std::unique_ptr<TgcRdo>> tgcRdoMap{};
60
61 const TgcRdoIdHash hashF;
62
63 // loop over collections
64 for (const TgcDigitCollection* tgcCollection : *container) {
65
66 // Iterate on the digits of the collection
67 for (const TgcDigit* tgcDigit : *tgcCollection) {
68 const Identifier channelId = tgcDigit->identify();
69 const uint16_t bctag = m_isNewTgcDigit ? tgcDigit->bcTag() : 0;
70
71 // Get the online Id of the channel
72 int subDetectorID{0}, rodID{0}, sswID{0}, slbID{0}, channelID{0};
73
74 // repeat two times for Adjacent Channel
75 for (int iAd = 0; iAd < 2; ++iAd) {
76 bool adFlag = false;
77
78 // check if this channel has Adjacent partner only when 2nd time
79 if (iAd != 0) {
80 bool a_found = cabling->hasAdjacentChannel(channelId);
81
82 // set Adjacent flag
83 if (a_found) {
84 adFlag = true;
85 } else {
86 continue;
87 }
88 }
89
90 // get Online ID
91 bool status = cabling->getReadoutIDfromOfflineID(channelId, subDetectorID,
92 rodID, sswID, slbID, channelID, adFlag);
93
94 if (!status) {
95 ATH_MSG_DEBUG("MuonTGC_CablingSvc can't return an online ID for the channel : "
96 << MSG::dec << " N_" << m_idHelperSvc->toString(channelId) );
97 continue;
98 }
99
100 // Create the new Tgc RawData
101 bool isStrip = m_idHelperSvc->tgcIdHelper().isStrip(channelId);
102 std::string name = m_idHelperSvc->tgcIdHelper().stationNameString(m_idHelperSvc->tgcIdHelper().stationName(channelId));
104 if (name[1] == '4')
106 else if (name[1] == '1')
108 else
110
111 auto rawData = std::make_unique<TgcRawData>(bctag, subDetectorID, rodID, sswID, slbID, 0, 0, type, adFlag, 0, channelID);
112
113 ATH_MSG_DEBUG("Adding a new RawData");
114 ATH_MSG_DEBUG(MSG::hex << " Sub : " << subDetectorID << " ROD : " << rodID << " SSW : " << sswID << " SLB : " << slbID
115 << " Ch : " << channelID);
116
117 // Add the RawData to the RDO
118 const uint16_t rdoId = identifyFragment(*rawData);
119 std::unique_ptr<TgcRdo>& tgcRdo = tgcRdoMap[rdoId];
120
121 if(!tgcRdo) {
122 // create new TgcRdo
123 const IdentifierHash hashId = hashF(rdoId);
124 tgcRdo = std::make_unique<TgcRdo>(rdoId, hashId);
125 tgcRdo->setOnlineId(rawData->subDetectorId(), rawData->rodId());
126 }
127 tgcRdo->push_back(std::move(rawData));
128 }
129 }
130 }
131
132 ATH_MSG_DEBUG("Add RDOs to the RdoContainer");
133 // Add RDOs to the RdoContainer
134 for (auto&[onlineId, rdo] : tgcRdoMap) {
135 unsigned int elementHash = hashF(onlineId);
136 ATH_CHECK(rdoContainer->addCollection(rdo.release(), elementHash));
137 }
138 ATH_MSG_DEBUG("Added RDOs to the RdoContainer XXXXXX");
139
140 return StatusCode::SUCCESS;
141}
142
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_DEBUG(x)
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.
Use IdentifiableContainer with TgcDigitCollection.
virtual StatusCode initialize() override final
BooleanProperty m_isNewTgcDigit
SG::WriteHandleKey< TgcRdoContainer > m_rdoContainerKey
SG::ReadHandleKey< TgcDigitContainer > m_digitContainerKey
SG::ReadCondHandleKey< Muon::TgcCablingMap > m_cablingKey
ServiceHandle< Muon::IMuonIdHelperSvc > m_idHelperSvc
virtual StatusCode execute(const EventContext &ctx) const override final
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
const T * get(const ReadCondHandleKey< T > &key, const EventContext &ctx)
Convenience function to retrieve an object given a ReadCondHandleKey.
setWord1 uint16_t