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"
12 
15 namespace {
16  static uint16_t identifyFragment(const TgcRawData& rawData) {
17  return TgcRdo::identifyRawData(rawData);
18  }
19 }
20 
21 TgcDigitToTgcRDO::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 
35  ATH_MSG_VERBOSE("Initialized WriteHandleKey: " << m_rdoContainerKey);
37  ATH_MSG_VERBOSE("Initialized ReadHandleKey: " << m_digitContainerKey);
38 
39  return StatusCode::SUCCESS;
40 }
41 
42 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
43 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
44 
45 StatusCode 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 }
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
TgcDigitToTgcRDO::m_cabling
ServiceHandle< MuonTGC_CablingSvc > m_cabling
Definition: TgcDigitToTgcRDO.h:39
TgcDigitToTgcRDO::m_digitContainerKey
SG::ReadHandleKey< TgcDigitContainer > m_digitContainerKey
Definition: TgcDigitToTgcRDO.h:42
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:297
TgcDigitToTgcRDO::m_rdoContainerKey
SG::WriteHandleKey< TgcRdoContainer > m_rdoContainerKey
Definition: TgcDigitToTgcRDO.h:41
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:26
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
TgcDigitToTgcRDO::m_cablingType
std::string m_cablingType
Definition: TgcDigitToTgcRDO.h:46
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:93
TgcDigitToTgcRDO::fillTagInfo
StatusCode fillTagInfo() const
Definition: TgcDigitToTgcRDO.cxx:140
TgcRawData::SLB_TYPE_UNKNOWN
@ SLB_TYPE_UNKNOWN
Definition: TgcRawData.h:38
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:376
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_idHelperSvc
ServiceHandle< Muon::IMuonIdHelperSvc > m_idHelperSvc
Definition: TgcDigitToTgcRDO.h:44
TgcDigit
Definition: TgcDigit.h:21
TgcDigitToTgcRDO::m_isNewTgcDigit
BooleanProperty m_isNewTgcDigit
Definition: TgcDigitToTgcRDO.h:36
dumpTgcDigiThreshold.isStrip
list isStrip
Definition: dumpTgcDigiThreshold.py:33
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
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
SG::WriteHandle
Definition: StoreGate/StoreGate/WriteHandle.h:76
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:45
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:394
TgcDigitToTgcRDO::getCabling
StatusCode getCabling()
Definition: TgcDigitToTgcRDO.cxx:156
merge.status
status
Definition: merge.py:17
IdentifierHash
This is a "hash" representation of an Identifier. This encodes a 32 bit index which can be used to lo...
Definition: IdentifierHash.h:25
TgcDigitToTgcRDO::TgcDigitToTgcRDO
TgcDigitToTgcRDO(const std::string &name, ISvcLocator *pSvcLocator)
Definition: TgcDigitToTgcRDO.cxx:21
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
Identifier
Definition: IdentifierFieldParser.cxx:14