ATLAS Offline Software
Loading...
Searching...
No Matches
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
24#include "GaudiKernel/ServiceHandle.h"
26
29#include "MuonRDO/TgcRawData.h"
30#include "MuonRDO/TgcRdo.h"
32
33#include <algorithm>
34
35using namespace LVL2_MUON_CALIBRATION;
36
37
38TgcCalibRawDataProvider::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
44uint16_t TgcCalibRawDataProvider::bcTagCnv(uint16_t bcBitMap) const {
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
54 ATH_CHECK(m_detectorManagerKey.initialize());
55 ATH_CHECK(m_muonIdHelper.retrieve());
56
57 // retrieve the dataProviderSvc
58 ATH_CHECK(m_dataProvider.retrieve());
59
60 // setup output Tgc container keys
61 ATH_CHECK(m_rdoContainerKey.initialize());
62
63
64
65 return StatusCode::SUCCESS;
66}
67
68// --------------------------------------------------------------------
69// Execute
70StatusCode 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
90StatusCode 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}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_INFO(x)
#define ATH_MSG_DEBUG(x)
Property holding a SG store/key/clid from which a ReadHandle is made.
Property holding a SG store/key/clid from which a WriteHandle is made.
uint16_t bcId(uint32_t data)
An algorithm that can be simultaneously executed in multiple threads.
StatusCode addOrDelete(std::unique_ptr< T > ptr)
IDC_WriteHandle getWriteHandle(IdentifierHash hash)
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
pointer_type ptr()
Dereference the pointer.
TgcCalibRawDataProvider(const std::string &name, ISvcLocator *pSvcLocator)
Constructor.
uint16_t bcTagCnv(uint16_t bcBitMap) const
virtual StatusCode initialize() override
Initialize.
virtual StatusCode execute(const EventContext &ctx) const override
Execute.
SG::ReadCondHandleKey< MuonGM::MuonDetectorManager > m_detectorManagerKey
MuonDetectorManager from the conditions store.
ServiceHandle< Muon::IMuonIdHelperSvc > m_muonIdHelper
StatusCode decodeImpl(TgcRdoContainer *m_tgcRdoContainer, const LVL2_MUON_CALIBRATION::CalibEvent *event) const
ServiceHandle< IMuonCalibStreamDataProviderSvc > m_dataProvider
SG::WriteHandleKey< TgcRdoContainer > m_rdoContainerKey
@ SLB_TYPE_INNER_WIRE
Definition TgcRawData.h:36
@ SLB_TYPE_INNER_STRIP
Definition TgcRawData.h:37
static uint16_t calculateOnlineId(uint16_t subDetectorId, uint16_t rodId)
Definition TgcRdo.cxx:60