ATLAS Offline Software
TgcCalibRawDataProvider.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
6 #include "GaudiKernel/DataObject.h"
7 #include "GaudiKernel/IRegistry.h"
8 #include "MuCalDecode/CalibData.h"
9 #include "MuCalDecode/CalibEvent.h"
10 #include "MuCalDecode/CalibUti.h"
13 
14 #include <iostream>
15 #include <list>
16 #include <map>
17 #include <memory>
18 
19 #include "StoreGate/StoreGateSvc.h"
24 #include "GaudiKernel/ServiceHandle.h"
26 
29 #include "MuonRDO/TgcRawData.h"
30 #include "MuonRDO/TgcRdo.h"
32 
33 #include <algorithm>
34 
35 using namespace LVL2_MUON_CALIBRATION;
36 
37 
38 TgcCalibRawDataProvider::TgcCalibRawDataProvider(const std::string& name, ISvcLocator* pSvcLocator) :
39  AthReentrantAlgorithm(name, pSvcLocator) {}
40 
41 
42 //int TgcCalibRawDataProvider::getRodIdFromSectorId(int tmp_sectorId) const { return ((tmp_sectorId % 12) + 1); }
43 
45  return (bcBitMap == 4 ? 1 : (bcBitMap == 2 ? 2 : (bcBitMap == 1 ? 3 : 0)));
46 }
47 
48 
50 
51  ATH_MSG_INFO("TgcCalibRawDataProvider::initialize");
52 
53  // retrieve common tools
55  ATH_CHECK(m_muonIdHelper.retrieve());
56 
57  // retrieve the dataProviderSvc
58  ATH_CHECK(m_dataProvider.retrieve());
59 
60  // setup output Tgc container keys
62 
63 
64 
65  return StatusCode::SUCCESS;
66 }
67 
68 // --------------------------------------------------------------------
69 // Execute
70 StatusCode TgcCalibRawDataProvider::execute(const EventContext& ctx) const {
71 
72  ATH_MSG_INFO("TgcCalibRawDataProvider::execute");
73 
74  const CalibEvent *event = m_dataProvider->getEvent();
75 
76  // // setup output write handle for RpcPadContainer
78  ATH_CHECK(handle.record(std::make_unique<TgcRdoContainer>(m_muonIdHelper->tgcIdHelper().module_hash_max())));
79  ATH_MSG_DEBUG("Created TgcRodContainer " << m_rdoContainerKey.key());
80  // Pass the container from the handle
81  TgcRdoContainer *padContainer = handle.ptr();
82 
83  ATH_CHECK(decodeImpl(padContainer, event));
84  ATH_MSG_DEBUG("TGC core decode processed in MT decode (calibration stream event)");
85 
86  return StatusCode::SUCCESS;
87 }
88 
89 
90 StatusCode TgcCalibRawDataProvider::decodeImpl(TgcRdoContainer *padContainer, const CalibEvent *event) const {
91 
92  if (!event->tgc()) {
93  ATH_MSG_DEBUG("NO TGC hits!");
94  return StatusCode::SUCCESS;
95  }
96 
97  int l1Id = event->lvl1_id();
98  int bcId = 0; // DUMMY BCID
99  int subsystemId = (*(event->tgc())).subsystemId(); // 0x67 or 0x68
100  int rodId = (*(event->tgc())).rdoId(); // This returns sector number since Run 2 (1..12 for legacy ROD, 17..19 for new trigger SROD), +1 for Run 1 data
101  uint16_t rdoId = TgcRdo::calculateOnlineId(subsystemId,rodId); // 0-23 : ROD, 24-29 : SROD
102  TgcRdoIdHash rdoIdHash;
103  int idHash = rdoIdHash(rdoId);
104 
105  std::unique_ptr<TgcRdo> newrdo = std::make_unique<TgcRdo>(subsystemId,rodId,bcId,l1Id);
106 
107  for(auto const& calib_tgcRdo : (event->tgc())->data()){
108  for(auto const& roh : calib_tgcRdo.readoutHit()){
109 
111  continue;
112  } // discard EIL4 TGC hits
113 
114  uint16_t slbId = roh.sbId;
115  std::unique_ptr<TgcRawData> raw = std::make_unique<TgcRawData>(bcTagCnv(roh.bcBitmap),
116  subsystemId,
117  rodId,
118  roh.ldbId,
119  slbId,
120  l1Id,
121  bcId,
122  static_cast<TgcRawData::SlbType>(roh.sbType),
123  roh.adj,
124  roh.tracklet,
125  roh.channel+40);
126 
127  ATH_MSG_DEBUG(std::hex << "TgcRawData READOUT FORMATTED HIT " << std::endl
128  << " bcTag " << bcTagCnv(roh.bcBitmap) << " subDetectorId " << newrdo->subDetectorId() << " rodId "
129  << newrdo->rodId() << " sswId " << roh.ldbId << " sbId " << slbId << " l1Id " << newrdo->l1Id()
130  << " bcId " << newrdo->bcId() << " sbType " << static_cast<TgcRawData::SlbType>(roh.sbType) << " adjucent "
131  << roh.adj << " associate tracklet " << roh.tracklet << " bitPos "
132  << roh.channel + 40);
133 
134  newrdo->push_back(std::move(raw));
135  }
136  }
137 
138  TgcRdoContainer::IDC_WriteHandle lock = padContainer->getWriteHandle(idHash);
139  ATH_CHECK(lock.addOrDelete(std::move(newrdo)));
140 
141  return StatusCode::SUCCESS;
142 }
ReadHandleKey.h
Property holding a SG store/key/clid from which a ReadHandle is made.
MuonCalibStreamAddress.h
TgcCalibRawDataProvider::execute
virtual StatusCode execute(const EventContext &ctx) const override
Execute.
Definition: TgcCalibRawDataProvider.cxx:70
AthCheckMacros.h
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
TgcRdo::calculateOnlineId
static uint16_t calculateOnlineId(uint16_t subDetectorId, uint16_t rodId)
Definition: TgcRdo.cxx:58
AthMsgStreamMacros.h
LVL2_MUON_CALIBRATION
Definition: MuCalStreamerTool.h:37
IdentifiableContainerMT::getWriteHandle
IDC_WriteHandle getWriteHandle(IdentifierHash hash)
Definition: IdentifiableContainerMT.h:251
TgcRawData.h
TgcCalibRawDataProvider::TgcCalibRawDataProvider
TgcCalibRawDataProvider(const std::string &name, ISvcLocator *pSvcLocator)
Constructor.
Definition: TgcCalibRawDataProvider.cxx:38
TgcCalibRawDataProvider.h
TgcCalibRawDataProvider::decodeImpl
StatusCode decodeImpl(TgcRdoContainer *m_tgcRdoContainer, const CalibEvent *event) const
Definition: TgcCalibRawDataProvider.cxx:90
SG::VarHandleKey::key
const std::string & key() const
Return the StoreGate ID for the referenced object.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:141
TgcCalibRawDataProvider::m_rdoContainerKey
SG::WriteHandleKey< TgcRdoContainer > m_rdoContainerKey
Definition: TgcCalibRawDataProvider.h:68
TgcRdo::l1Id
uint16_t l1Id() const
Definition: TgcRdo.h:150
ReadCondHandle.h
AthReentrantAlgorithm
An algorithm that can be simultaneously executed in multiple threads.
Definition: AthReentrantAlgorithm.h:83
TgcCalibRawDataProvider::initialize
virtual StatusCode initialize() override
Initialize.
Definition: TgcCalibRawDataProvider.cxx:49
TgcCalibRawDataProvider::m_detectorManagerKey
SG::ReadCondHandleKey< MuonGM::MuonDetectorManager > m_detectorManagerKey
Definition: TgcCalibRawDataProvider.h:61
TgcRdoIdHash
Definition: TgcRdoIdHash.h:18
TgcRdo::subDetectorId
uint16_t subDetectorId() const
Definition: TgcRdo.h:134
xAOD::uint16_t
setWord1 uint16_t
Definition: eFexEMRoI_v1.cxx:88
event
POOL::TEvent event(POOL::TEvent::kClassAccess)
TgcRdoContainer
Definition: TgcRdoContainer.h:25
MuonPrepDataCollection.h
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
WriteCondHandle.h
TgcCalibRawDataProvider::m_dataProvider
ServiceHandle< IMuonCalibStreamDataProviderSvc > m_dataProvider
Definition: TgcCalibRawDataProvider.h:58
IdentifiableContainerMT::IDC_WriteHandle
Definition: IdentifiableContainerMT.h:34
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
TgcCalibRawDataProvider::m_muonIdHelper
ServiceHandle< Muon::IMuonIdHelperSvc > m_muonIdHelper
Definition: TgcCalibRawDataProvider.h:64
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
TgcRdoContainer.h
TgcRdo.h
TgcRdo::bcId
uint16_t bcId() const
Definition: TgcRdo.h:146
ReadCondHandleKey.h
WriteHandleKey.h
Property holding a SG store/key/clid from which a WriteHandle is made.
bcId
uint16_t bcId(uint32_t data)
Definition: TgcByteStreamData.h:326
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
DataVector::push_back
value_type push_back(value_type pElem)
Add an element to the end of the collection.
SG::CondHandleKey::initialize
StatusCode initialize(bool used=true)
IdentifiableContainerMT::IDC_WriteHandle::addOrDelete
StatusCode addOrDelete(std::unique_ptr< T > ptr)
Definition: IdentifiableContainerMT.h:56
SG::WriteHandle
Definition: StoreGate/StoreGate/WriteHandle.h:76
TgcRawData::SLB_TYPE_INNER_STRIP
@ SLB_TYPE_INNER_STRIP
Definition: TgcRawData.h:37
TgcIdHelper.h
TgcRawData::SLB_TYPE_INNER_WIRE
@ SLB_TYPE_INNER_WIRE
Definition: TgcRawData.h:36
StoreGateSvc.h
TgcRdo::rodId
uint16_t rodId() const
Definition: TgcRdo.h:138
TgcCalibRawDataProvider::bcTagCnv
uint16_t bcTagCnv(uint16_t bcBitMap) const
Definition: TgcCalibRawDataProvider.cxx:44
TgcRawData::SlbType
SlbType
Definition: TgcRawData.h:31