ATLAS Offline Software
Loading...
Searching...
No Matches
TGC_RawDataProviderToolCore.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3*/
4
6
9
10//================ Constructor =================================================
11
13 const std::string& t,
14 const std::string& n,
15 const IInterface* p) :
16 AthAlgTool(t, n, p),
17 m_robDataProvider("ROBDataProviderSvc",n)
18{
19}
20
21//================ Initialisation =================================================
22
24{
25 ATH_CHECK(AthAlgTool::initialize());
26 ATH_CHECK(m_idHelperSvc.retrieve());
27
28 ATH_CHECK(m_decoder.retrieve());
29 ATH_MSG_DEBUG( "Retrieved tool " << m_decoder );
30
31 // Get ROBDataProviderSvc
32 ATH_CHECK(m_robDataProvider.retrieve());
33 ATH_MSG_DEBUG( "Retrieved service " << m_robDataProvider );
34
35 m_maxhashtoUse = m_idHelperSvc->tgcIdHelper().module_hash_max();
36
37 ATH_CHECK(m_rdoContainerKey.initialize());
38
39 //try to configure the cabling service
40 if (!getCabling()) {
41 // ??? Is deferred initialization still needed here?
42 ATH_MSG_INFO( "TGCCablingServerSvc not yet configured; postpone TGCcabling initialization at first event. " );
43 }
44
45 m_hid2re.fillAllRobIds();
46
47 return StatusCode::SUCCESS;
48}
49
50//============================================================================================
51
52StatusCode Muon::TGC_RawDataProviderToolCore::convertIntoContainer(const std::vector<const OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment*>& vecRobs, TgcRdoContainer& tgcRdoContainer) const
53{
54
56 static thread_local int DecodeErrCount = 0;
57
58 // Update to range based loop
59 for(const OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment* fragment : vecRobs){
60 if(m_decoder->fillCollection(*fragment, tgcRdoContainer).isFailure()) {
61 if(DecodeErrCount < 100) {
62 ATH_MSG_INFO( "Problem with TGC ByteStream Decoding!" );
63 DecodeErrCount++;
64 }
65 else if(100 == DecodeErrCount) {
66 ATH_MSG_INFO( "Too many Problems with TGC Decoding messages. Turning message off." );
67 DecodeErrCount++;
68 }
69 }
70 }
71 ATH_MSG_DEBUG("Size of TgcRdoContainer is " << tgcRdoContainer.size());
72 return StatusCode::SUCCESS;
73}
74
76{
77 const MuonTGC_CablingSvc* cabling = m_cabling.get();
78 if (cabling) {
79 return cabling;
80 }
81
82 ServiceHandle<MuonTGC_CablingSvc> TgcCabGet("MuonTGC_CablingSvc", name());
83 if (TgcCabGet.retrieve().isFailure()) {
84 ATH_MSG_FATAL( "Could not get MuonTGC_CablingSvc !" );
85 return nullptr;
86 }
87
88 m_cabling.set(TgcCabGet.get());
89
90 return m_cabling.get();
91}
92
93
94std::vector<const OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment*> Muon::TGC_RawDataProviderToolCore::getROBData(const std::vector<IdentifierHash>& rdoIdhVect, const EventContext& ctx) const
95{
96 std::vector<const OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment*> vecOfRobf;
97 const MuonTGC_CablingSvc* cabling = getCabling();
98 if(!cabling) {
99 ATH_MSG_ERROR("Could not get cabling, return empty vector of ROB fragments");
100 return vecOfRobf;
101 }
102
103 IdContext tgcContext = m_idHelperSvc->tgcIdHelper().module_context();
104
105 std::vector<uint32_t> robIds;
106
107 unsigned int size = rdoIdhVect.size();
108 for(unsigned int i=0; i<size; ++i) {
109 Identifier Id;
110 if(m_idHelperSvc->tgcIdHelper().get_id(rdoIdhVect[i], Id, &tgcContext)) {
111 ATH_MSG_WARNING( "Unable to get TGC Identifier from collection hash id " );
112 continue;
113 }
114 const Identifier tgcId = Id;
115 uint32_t rodId = m_hid2re.getRodID(tgcId, cabling);
116 uint32_t robId = m_hid2re.getRobID(rodId);
117 std::vector<uint32_t>::iterator it_robId = std::find(robIds.begin(), robIds.end(), robId);
118 if(it_robId==robIds.end()) {
119 robIds.push_back(robId);
120 }
121 }
122 m_robDataProvider->getROBData(ctx, robIds, vecOfRobf);
123 ATH_MSG_VERBOSE( "Number of ROB fragments " << vecOfRobf.size() );
124 return vecOfRobf;
125}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_FATAL(x)
#define ATH_MSG_INFO(x)
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
AthAlgTool(const std::string &type, const std::string &name, const IInterface *parent)
Constructor with parameters:
This class saves the "context" of an expanded identifier (ExpandedIdentifier) for compact or hash ver...
Definition IdContext.h:26
size_t size() const
Duplicate of fullSize for backwards compatability.
CxxUtils::CachedPointer< const MuonTGC_CablingSvc > m_cabling
TGC cabling Svc.
std::vector< const OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment * > getROBData(const std::vector< IdentifierHash > &rdoIdhVect, const EventContext &ctx) const
Function to get the ROB data from a vector of IdentifierHash.
const MuonTGC_CablingSvc * getCabling() const
ToolHandle< ITGC_RodDecoder > m_decoder
Decoder for ROB fragment RDO conversion.
TGC_RawDataProviderToolCore(const std::string &t, const std::string &n, const IInterface *p)
Default constructor.
SG::WriteHandleKey< TgcRdoContainer > m_rdoContainerKey
RDO container key.
ServiceHandle< IROBDataProviderSvc > m_robDataProvider
Rob Data Provider handle.
ServiceHandle< Muon::IMuonIdHelperSvc > m_idHelperSvc
virtual StatusCode convertIntoContainer(const std::vector< const OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment * > &vecRobs, TgcRdoContainer &tgcRdoContainer) const
Method that converts the ROBFragments into the passed container.
virtual StatusCode initialize()
Standard AlgTool method.
eformat::ROBFragment< PointerType > ROBFragment
Definition RawEvent.h:27