ATLAS Offline Software
Loading...
Searching...
No Matches
TileHid2RESrcIDCondAlg.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// Tile includes
8
9// Athena includes
10
14
16
17 ATH_MSG_DEBUG( "In initialize()" );
18
19 // Retrieve TileHWID helper from det store
20 ATH_CHECK( detStore()->retrieve(m_tileHWID) );
21 ATH_CHECK( m_hid2ReSrcIdKey.initialize() );
22
24 ATH_CHECK( m_rodStatusProxy.retrieve(EnableTool{m_initFromDB}) );
25
26 // Initilize from event if length of ROD2ROBmap is and odd value
27 m_initFromEvent = (!m_initFromDB && (m_ROD2ROBmap.value().size() % 2 == 1));
28 if (m_initFromEvent) {
29 ATH_CHECK(m_robSvc.retrieve());
30 }
31
32 return StatusCode::SUCCESS;
33}
34
35
36StatusCode TileHid2RESrcIDCondAlg::execute(const EventContext& ctx) const {
37
39
40 if (hid2ReSrcId.isValid()) {
41 ATH_MSG_DEBUG("Found valid TileHid2RESrcID: " << hid2ReSrcId.key());
42 return StatusCode::SUCCESS;
43 }
44
45 const uint32_t run = ctx.eventID().run_number();
46
47 EventIDRange eventRange;
48 std::unique_ptr<TileHid2RESrcID> hid2re;
49
50 if (m_initFromDB) {
51 hid2re = std::make_unique<TileHid2RESrcID>(m_tileHWID, run);
52
53 auto calibData = std::make_unique<TileCalibData<TileCalibDrawerInt>>();
54 ATH_CHECK( m_rodStatusProxy->fillCalibData(*calibData, eventRange) );
55
56 std::vector<std::vector<uint32_t>> allMap;
58
59 for (unsigned int drawerIdx = 0; drawerIdx < TileCalibUtils::MAX_DRAWERIDX; ++drawerIdx) {
60 const TileCalibDrawerInt* calibDrawer = calibData->getCalibDrawer(drawerIdx);
61 unsigned int nGains = calibDrawer->getNGains();
62 unsigned int nChannels = calibDrawer->getNChans();
63 unsigned int nValues = calibDrawer->getObjSizeUint32();
64 for (unsigned int channel = 0; channel < nChannels; ++channel) {
65 for (unsigned int adc = 0; adc < nGains; ++adc) {
66 std::vector<uint32_t> fragMap;
67 fragMap.reserve(nValues);
68 for (unsigned int i = 0; i < nValues; ++i) {
69 fragMap.push_back( calibDrawer->getData(channel, adc, i) );
70 }
71 allMap.emplace_back(std::move(fragMap));
72 }
73 }
74 }
75
76 hid2re->initialize(allMap);
77
78 } else if (m_forHLT) {
79 hid2re = std::make_unique<TileHid2RESrcID>(m_tileHWID, run);
80 } else {
81
82 unsigned int fullMode = (m_fullTileRODs > 0) ? m_fullTileRODs.value() : run;
83 hid2re = std::make_unique<TileHid2RESrcID>(m_tileHWID, fullMode);
84
85 // Check whether we want to overwrite default ROB IDs
86 if (m_initFromEvent) {
87 ATH_MSG_DEBUG( "Length of ROD2ROBmap is and odd value, "
88 << " means that we'll scan event for all fragments to create proper map" );
89
90 bool of2Default{true};
91 const eformat::FullEventFragment<const uint32_t*> * event = m_robSvc->getEvent(ctx);
92 try {
93 event->check_tree();
94 hid2re->setROD2ROBmap(event, of2Default, msg());
95 } catch (...) {
96 ATH_MSG_DEBUG( "Bad event, mapping might be incomplete! " );
97 // Bad event, but process anyhow (well, till next bug report )
98 hid2re->setROD2ROBmap(event, of2Default, msg());
99 }
100 } else if (m_ROD2ROBmap.empty()) {
101 ATH_MSG_DEBUG( "Length of ROD2ROBmap vector is zero, "
102 << " means that predefined mapping for run " << fullMode << " will be used " );
103 } else {
104 ATH_MSG_DEBUG( "Apply additional remapping for " << m_ROD2ROBmap.value().size()/2 << " fragments from jobOptions ");
105 hid2re->setROD2ROBmap(m_ROD2ROBmap.value(), msg());
106 }
107
108 }
109
110 if (!m_initFromDB) {
111 // Set validity of TileHid2RESrcID for current run
112 eventRange = EventIDRange(EventIDBase{run, EventIDBase::UNDEFEVT, EventIDBase::UNDEFNUM, EventIDBase::UNDEFNUM, 0},
113 EventIDBase{run + 1, EventIDBase::UNDEFEVT, EventIDBase::UNDEFNUM, EventIDBase::UNDEFNUM, 0});
114 }
115
116 hid2re->printSpecial(msg());
117
118 ATH_CHECK( hid2ReSrcId.record(eventRange, std::move(hid2re)) );
119
120 ATH_MSG_VERBOSE("Recorded TileHid2RESrcID object with "
121 << hid2ReSrcId.key()
122 << " with EventRange " << eventRange
123 << " into Conditions Store");
124
125 return StatusCode::SUCCESS;
126}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_DEBUG(x)
Handle class for reading from StoreGate.
const ServiceHandle< StoreGateSvc > & detStore() const
const std::string & key() const
StatusCode record(const EventIDRange &range, T *t)
record handle, with explicit range DEPRECATED
Class for storing a 32 bit array of words for each ADC.
static const unsigned int MAX_DRAWERIDX
Maximal drawer index.
static const unsigned int MAX_DRAWR0
Number of drawers in ROS 0.
ToolHandle< ITileCondProxy< TileCalibDrawerInt > > m_rodStatusProxy
Tool to get Tile ROD status (e.g.: mapping from BS frag ID to drawer ID)
Gaudi::Property< std::vector< std::string > > m_ROD2ROBmap
ServiceHandle< IROBDataProviderSvc > m_robSvc
Name of ROB data provider service.
virtual StatusCode initialize() override
Gaudi::Property< unsigned int > m_fullTileRODs
SG::WriteCondHandleKey< TileHid2RESrcID > m_hid2ReSrcIdKey
Name of output TileHid2RESrcID.
Gaudi::Property< bool > m_forHLT
virtual StatusCode execute(const EventContext &ctx) const override
Definition run.py:1