ATLAS Offline Software
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 
10 #include "MuonRDO/TgcRdoIdHash.h"
11 #include "StoreGate/StoreGateSvc.h"
13 
16 namespace {
17  static uint16_t identifyFragment(const TgcRawData& rawData) {
18  return TgcRdo::identifyRawData(rawData);
19  }
20 }
21 
22 TgcDigitToTgcRDO::TgcDigitToTgcRDO(const std::string& name, ISvcLocator* pSvcLocator) :
23  AthReentrantAlgorithm(name, pSvcLocator){}
24 
25 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
26 
28  ATH_MSG_DEBUG(" in initialize()");
29  ATH_CHECK(m_idHelperSvc.retrieve());
30  ATH_CHECK(m_tgc_cabling_server.retrieve());
31 
32  ATH_MSG_DEBUG("standard digitization job: "
33  << "initialize now the TGC cabling and TGC container.");
35 
37  ATH_MSG_VERBOSE("Initialized WriteHandleKey: " << m_rdoContainerKey);
39  ATH_MSG_VERBOSE("Initialized ReadHandleKey: " << m_digitContainerKey);
40 
41  return StatusCode::SUCCESS;
42 }
43 
44 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
45 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
46 
47 StatusCode TgcDigitToTgcRDO::execute(const EventContext& ctx) const {
48  ATH_MSG_DEBUG("in execute()");
49 
51  ATH_CHECK(rdoContainer.record(std::make_unique<TgcRdoContainer>()));
52  ATH_MSG_DEBUG("Recorded TgcRdoContainer called " << rdoContainer.name() << " in store " << rdoContainer.store());
54  ATH_CHECK(container.isPresent());
55  ATH_MSG_DEBUG("Found TgcDigitContainer called " << container.name() << " in store " << container.store());
56 
57  std::map<uint16_t, std::unique_ptr<TgcRdo>> tgcRdoMap{};
58 
59  const TgcRdoIdHash hashF;
60 
61  // loop over collections
62  for (const TgcDigitCollection* tgcCollection : *container) {
63 
64  // Iterate on the digits of the collection
65  for (const TgcDigit* tgcDigit : *tgcCollection) {
66  const Identifier channelId = tgcDigit->identify();
67  const uint16_t bctag = m_isNewTgcDigit ? tgcDigit->bcTag() : 0;
68 
69  // Get the online Id of the channel
70  int subDetectorID{0}, rodID{0}, sswID{0}, slbID{0}, channelID{0};
71 
72  // repeat two times for Adjacent Channel
73  for (int iAd = 0; iAd < 2; ++iAd) {
74  bool adFlag = false;
75 
76  // check if this channel has Adjacent partner only when 2nd time
77  if (iAd != 0) {
78  bool a_found = m_cabling->hasAdjacentChannel(channelId);
79 
80  // set Adjacent flag
81  if (a_found)
82  adFlag = true;
83  else
84  continue;
85  }
86 
87  // get Online ID
88  bool status = m_cabling->getReadoutIDfromOfflineID(channelId, subDetectorID, rodID, sswID, slbID, channelID, adFlag);
89 
90  if (!status) {
91  ATH_MSG_DEBUG("ITGCcablingSvc can't return an online ID for the channel : "
92  << MSG::dec << " N_" << m_idHelperSvc->toString(channelId) );
93  continue;
94  }
95 
96  // Create the new Tgc RawData
97  bool isStrip = m_idHelperSvc->tgcIdHelper().isStrip(channelId);
98  std::string name = m_idHelperSvc->tgcIdHelper().stationNameString(m_idHelperSvc->tgcIdHelper().stationName(channelId));
100  if (name[1] == '4')
102  else if (name[1] == '1')
104  else
106 
107  auto rawData = std::make_unique<TgcRawData>(bctag, subDetectorID, rodID, sswID, slbID, 0, 0, type, adFlag, 0, channelID);
108 
109  ATH_MSG_DEBUG("Adding a new RawData");
110  ATH_MSG_DEBUG(MSG::hex << " Sub : " << subDetectorID << " ROD : " << rodID << " SSW : " << sswID << " SLB : " << slbID
111  << " Ch : " << channelID);
112 
113  // Add the RawData to the RDO
114  const uint16_t rdoId = identifyFragment(*rawData);
115  std::unique_ptr<TgcRdo>& tgcRdo = tgcRdoMap[rdoId];
116 
117  if(!tgcRdo) {
118  // create new TgcRdo
119  const IdentifierHash hashId = hashF(rdoId);
120  tgcRdo = std::make_unique<TgcRdo>(rdoId, hashId);
121  tgcRdo->setOnlineId(rawData->subDetectorId(), rawData->rodId());
122  }
123  tgcRdo->push_back(std::move(rawData));
124  }
125  }
126  }
127 
128  ATH_MSG_DEBUG("Add RDOs to the RdoContainer");
129  // Add RDOs to the RdoContainer
130  for (auto&[onlineId, rdo] : tgcRdoMap) {
131  unsigned int elementHash = hashF(onlineId);
132  ATH_CHECK(rdoContainer->addCollection(rdo.release(), elementHash));
133  }
134  ATH_MSG_DEBUG("Added RDOs to the RdoContainer XXXXXX");
135 
136  return StatusCode::SUCCESS;
137 }
138 
139 // NOTE: although this function has no clients in release 22, currently the Run2 trigger simulation is still run in
140 // release 21 on RDOs produced in release 22. Since release 21 accesses the TagInfo, it needs to be written to the
141 // RDOs produced in release 22. The fillTagInfo() function thus needs to stay in release 22 until the workflow changes
143  ServiceHandle<ITagInfoMgr> tagInfoMgr("TagInfoMgr", name());
144  if (tagInfoMgr.retrieve().isFailure()) return StatusCode::FAILURE;
145 
146  StatusCode sc = tagInfoMgr->addTag("TGC_CablingType", m_cablingType);
147 
148  if (sc.isFailure()) {
149  ATH_MSG_WARNING("TGC_CablingType " << m_cablingType << " not added to TagInfo ");
150  return sc;
151  } else {
152  ATH_MSG_DEBUG("TGC_CablingType " << m_cablingType << " is Added TagInfo ");
153  }
154 
155  return StatusCode::SUCCESS;
156 }
157 
160 
161  int maxRodId, maxSRodId, maxSswId, maxSbloc, minChannelId, maxChannelId;
162  m_cabling->getReadoutIDRanges(maxRodId, maxSRodId, maxSswId, maxSbloc, minChannelId, maxChannelId);
163  if (maxRodId == 12) {
164  ATH_MSG_INFO(m_cabling->name() << " (12-fold) is selected ");
165  m_cablingType = "TGCcabling12Svc";
166  } else {
167  ATH_MSG_INFO("TGCcablingSvc (8-fold) is selected");
168  m_cablingType = "TGCcabling8Svc";
169  }
170 
171  // Fill Tag Info
173 
174  return StatusCode::SUCCESS;
175 }
TgcRdo::identifyRawData
static uint16_t identifyRawData(const TgcRawData &rawData)
Definition: TgcRdo.cxx:45
TgcRawData::SLB_TYPE_DOUBLET_STRIP
@ SLB_TYPE_DOUBLET_STRIP
Definition: TgcRawData.h:33
ITGCcablingSvc::getReadoutIDRanges
virtual void getReadoutIDRanges(int &maxRodId, int &maxSRodId, int &maxSswId, int &maxSbloc, int &minChannelId, int &maxChannelId) const =0
TgcDigitToTgcRDO::m_digitContainerKey
SG::ReadHandleKey< TgcDigitContainer > m_digitContainerKey
Definition: TgcDigitToTgcRDO.h:44
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
IdentifiableContainerMT::addCollection
virtual StatusCode addCollection(const T *coll, IdentifierHash hashId) override final
insert collection into container with id hash if IDC should not take ownership of collection,...
Definition: IdentifiableContainerMT.h:300
TgcDigitToTgcRDO::m_rdoContainerKey
SG::WriteHandleKey< TgcRdoContainer > m_rdoContainerKey
Definition: TgcDigitToTgcRDO.h:43
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
SG::VarHandleBase::name
const std::string & name() const
Return the StoreGate ID for the referenced object.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleBase.cxx:75
ITagInfoMgr.h
TgcDigitToTgcRDO.h
TgcDigitToTgcRDO::initialize
virtual StatusCode initialize() override final
Definition: TgcDigitToTgcRDO.cxx:27
ITGCcablingSvc::hasAdjacentChannel
virtual bool hasAdjacentChannel(const Identifier &offlineID) const =0
TgcDigitToTgcRDO::m_cabling
const ITGCcablingSvc * m_cabling
Definition: TgcDigitToTgcRDO.h:41
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
TgcDigitToTgcRDO::m_cablingType
std::string m_cablingType
Definition: TgcDigitToTgcRDO.h:48
TgcRawData::SLB_TYPE_TRIPLET_WIRE
@ SLB_TYPE_TRIPLET_WIRE
Definition: TgcRawData.h:34
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
AthReentrantAlgorithm
An algorithm that can be simultaneously executed in multiple threads.
Definition: AthReentrantAlgorithm.h:83
TgcRdoIdHash
Definition: TgcRdoIdHash.h:18
xAOD::uint16_t
setWord1 uint16_t
Definition: eFexEMRoI_v1.cxx:88
TgcDigitToTgcRDO::fillTagInfo
StatusCode fillTagInfo() const
Definition: TgcDigitToTgcRDO.cxx:142
TgcRawData::SLB_TYPE_UNKNOWN
@ SLB_TYPE_UNKNOWN
Definition: TgcRawData.h:38
Identifier
Definition: DetectorDescription/Identifier/Identifier/Identifier.h:32
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
TgcDigitCollection
Definition: TgcDigitCollection.h:17
SG::VarHandleBase::store
std::string store() const
Return the name of the store holding the object we are proxying.
Definition: StoreGate/src/VarHandleBase.cxx:379
TgcDigitCollection.h
TgcDigit.h
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
SG::VarHandleKey::initialize
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:103
CaloCondBlobAlgs_fillNoiseFromASCII.channelId
channelId
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:122
TgcDigitToTgcRDO::m_tgc_cabling_server
ServiceHandle< ITGCcablingServerSvc > m_tgc_cabling_server
Definition: TgcDigitToTgcRDO.h:40
TgcDigitToTgcRDO::m_idHelperSvc
ServiceHandle< Muon::IMuonIdHelperSvc > m_idHelperSvc
Definition: TgcDigitToTgcRDO.h:46
TgcDigit
Definition: TgcDigit.h:21
TgcDigitToTgcRDO::m_isNewTgcDigit
BooleanProperty m_isNewTgcDigit
Definition: TgcDigitToTgcRDO.h:37
dumpTgcDigiThreshold.isStrip
list isStrip
Definition: dumpTgcDigiThreshold.py:33
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
DataVector::push_back
value_type push_back(value_type pElem)
Add an element to the end of the collection.
TgcRdo::setOnlineId
void setOnlineId(uint16_t subDetectorId, uint16_t rodId)
Definition: TgcRdo.cxx:35
ITGCcablingServerSvc.h
SG::WriteHandle
Definition: StoreGate/StoreGate/WriteHandle.h:76
ITGCcablingSvc::getReadoutIDfromOfflineID
virtual bool getReadoutIDfromOfflineID(const Identifier &offlineID, int &subDetectorID, int &rodID, int &sswID, int &sbLoc, int &channelID, bool adChannel=false) const =0
SG::WriteHandle::record
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
TgcRdoIdHash.h
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
TgcRawData
An unit object of TGC ROD output.
Definition: TgcRawData.h:23
TgcRawData::SLB_TYPE_INNER_STRIP
@ SLB_TYPE_INNER_STRIP
Definition: TgcRawData.h:37
TgcDigitToTgcRDO::execute
virtual StatusCode execute(const EventContext &ctx) const override final
Definition: TgcDigitToTgcRDO.cxx:47
TgcRawData::SLB_TYPE_INNER_WIRE
@ SLB_TYPE_INNER_WIRE
Definition: TgcRawData.h:36
SG::VarHandleBase::isPresent
bool isPresent() const
Is the referenced object present in SG?
Definition: StoreGate/src/VarHandleBase.cxx:397
TgcDigitToTgcRDO::getCabling
StatusCode getCabling()
Definition: TgcDigitToTgcRDO.cxx:158
merge.status
status
Definition: merge.py:17
IdentifierHash
Definition: IdentifierHash.h:38
TgcDigitToTgcRDO::TgcDigitToTgcRDO
TgcDigitToTgcRDO(const std::string &name, ISvcLocator *pSvcLocator)
Definition: TgcDigitToTgcRDO.cxx:22
TgcRawData::SLB_TYPE_TRIPLET_STRIP
@ SLB_TYPE_TRIPLET_STRIP
Definition: TgcRawData.h:35
StoreGateSvc.h
TgcRawData::SLB_TYPE_DOUBLET_WIRE
@ SLB_TYPE_DOUBLET_WIRE
Definition: TgcRawData.h:32
ServiceHandle< ITagInfoMgr >
TgcRawData::SlbType
SlbType
Definition: TgcRawData.h:31