56 m_topoSteering->setLegacyMode(m_isLegacyTopo);
59 CHECK( m_histSvc.retrieve() );
61 if (m_emtauInputProvider.isEnabled()) {
63 CHECK( m_emtauInputProvider.retrieve() );
66 if (m_jetInputProvider.isEnabled()) {
68 CHECK( m_jetInputProvider.retrieve() );
71 if (m_energyInputProvider.isEnabled()) {
73 CHECK( m_energyInputProvider.retrieve() );
76 if (m_muonInputProvider.isEnabled()) {
78 CHECK( m_muonInputProvider.retrieve(DisableTool{m_isLegacyTopo}) );
82 CHECK( m_ControlHistSvc.retrieve());
84 CHECK(m_l1topoRawDataKey.initialize(m_fillHistogramsBasedOnHardwareDecision));
86 CHECK(m_legacyTopoCTPLocation.initialize(m_isLegacyTopo));
87 CHECK(m_legacyTopoOverflowCTPLocation.initialize(m_isLegacyTopo));
88 CHECK(m_topoCTPLocation.initialize(!m_isLegacyTopo));
89 CHECK(m_topoOverflowCTPLocation.initialize(!m_isLegacyTopo));
91 ATH_MSG_DEBUG(
"Legacy output trigger key property " << m_legacyTopoCTPLocation);
92 ATH_MSG_DEBUG(
"Legacy output overflow key property " << m_legacyTopoOverflowCTPLocation);
95 ATH_MSG_DEBUG(
"Output trigger key property " << m_topoCTPLocation);
96 ATH_MSG_DEBUG(
"Output overflow key property " << m_topoOverflowCTPLocation);
100 ATH_MSG_DEBUG(
"PrescaleDAQROBAccess factor set to " << m_prescaleForDAQROBAccess);
101 ATH_MSG_DEBUG(
"FillHistoBasedOnHardware " << m_fillHistogramsBasedOnHardwareDecision);
102 if(m_fillHistogramsBasedOnHardwareDecision and
103 (m_prescaleForDAQROBAccess % m_prescale)) {
104 ATH_MSG_FATAL(
"PrescaleDAQROBAccess must be a multiple of Prescale"
105 <<
" : current values :"
106 <<
" "<<m_prescaleForDAQROBAccess
108 return StatusCode::FAILURE;
112 ATH_CHECK( detStore()->retrieve(l1menu) );
113 ATH_MSG_INFO(
"initialize(): retrieving new-style L1 trigger menu from Detector Store" );
115 m_topoSteering->setUseBitwise(m_enableBitwise);
117 m_topoSteering->setupFromConfiguration(*l1menu);
119 catch(std::exception & e) {
120 ATH_MSG_FATAL(
"Caught exception when configuring topo steering from menu: " << e.what() );
121 return StatusCode::FAILURE;
125 m_topoSteering->setOutputAlgosFillBasedOnHardware(m_fillHistogramsBasedOnHardwareDecision);
127 if (m_doMonitoring) {
ATH_CHECK(m_ControlHistSvc->SetHistSvc(m_topoSteering, m_histBaseDir.value()));}
129 ATH_CHECK(m_legacyL1topoKey.initialize(m_isLegacyTopo));
130 ATH_CHECK(m_l1topoKey.initialize(!m_isLegacyTopo));
132 return StatusCode::SUCCESS;
146 catch(std::exception & e) {
147 ATH_MSG_FATAL(
"Caught exception when initializing topo algorithms" << e.what() );
148 return StatusCode::FAILURE;
156 return StatusCode::SUCCESS;
163 const EventContext& ctx = Gaudi::Hive::currentContext();
167 return StatusCode::SUCCESS;
184 ctx.eventID().event_number(),
185 ctx.eventID().lumi_block(),
186 ctx.eventID().bunch_crossing_id());
240 auto topoOutput2CTP = std::make_unique< LVL1::FrontPanelCTP >();
241 auto topoOverflow2CTP = std::make_unique< LVL1::FrontPanelCTP >();
249 ATH_CHECK(outputHandle.
record(std::make_unique<xAOD::L1TopoSimResultsContainer>(), std::make_unique<xAOD::L1TopoSimResultsAuxContainer>()));
254 std::string conn1 = l1menu->board(
"LegacyTopo0").connectorNames()[0];
255 std::string conn2 = l1menu->board(
"LegacyTopo1").connectorNames()[0];
256 for(
unsigned int clock=0; clock<2; ++clock) {
257 topoOutput2CTP->setCableWord0( clock, 0 );
259 topoOutput2CTP->setCableWord1( clock, globalOutput.
decision_field( conn1, clock) );
262 topoOutput2CTP->setCableWord2( clock, globalOutput.
decision_field( conn2, clock) );
274 std::string conn1 = l1menu->board(
"Topo2").connectorNames()[0];
275 std::string conn2 = l1menu->board(
"Topo3").connectorNames()[0];
276 for(
unsigned int clock=0; clock<2; ++clock) {
284 topoOverflow2CTP->setCableWord0( clock, 0 );
285 topoOverflow2CTP->setCableWord1( clock, globalOutput.
overflow_field( conn1, clock) );
287 topoOverflow2CTP->setCableWord2( clock, globalOutput.
overflow_field( conn2, clock) );
295 for(
const auto& connOpt : l1menu->board(
"Topo1").connectorNames() ) {
296 auto outputOpt = globalOutput.
count_field(connOpt);
297 std::bitset<64> outputOpt_1(outputOpt.to_string());
298 std::bitset<64> outputOpt_2((outputOpt<<64).
to_string());
299 topoOutput2CTP->setOptCableWord( connOpt, outputOpt );
300 WriteEDM(outputHandle,connOpt,1,outputOpt_1.to_ulong());
301 WriteEDM(outputHandle,connOpt,0,outputOpt_2.to_ulong());
308 return StatusCode::SUCCESS;
315 return StatusCode::SUCCESS;
321 handle->push_back(std::make_unique<xAOD::L1TopoSimResults>());
323 handle->back()->setClock(clock);
324 handle->back()->setBitWidth(32);
325 handle->back()->setTopoWord(word);
327 ATH_MSG_DEBUG(
"L1Topo EDM:: Connection Id: " << handle->back()->connectionId() <<
" Clock: " << handle->back()->clock() <<
" Decision: " << handle->back()->topoWord() );
333 handle->push_back(std::make_unique<xAOD::L1TopoSimResults>());
335 handle->back()->setClock(clock);
336 handle->back()->setBitWidth(32);
337 handle->back()->setTopoWordOverflow(word);
339 ATH_MSG_DEBUG(
"L1Topo EDM:: Connection Id: " << handle->back()->connectionId() <<
" Clock: " << handle->back()->clock() <<
" Decision: " << handle->back()->topoWord() );
345 handle->push_back(std::make_unique<xAOD::L1TopoSimResults>());
347 handle->back()->setClock(clock);
348 handle->back()->setBitWidth(64);
349 handle->back()->setTopoWord64(word);
351 ATH_MSG_DEBUG(
"L1Topo EDM:: Connection Id: " << handle->back()->connectionId() <<
" Clock: " << handle->back()->clock() <<
" Decision: " << handle->back()->topoWord() );
357 handle->push_back(std::make_unique<xAOD::L1TopoSimResults>());
359 handle->back()->setClock(clock);
360 handle->back()->setBitWidth(64);
361 handle->back()->setTopoWord64Overflow(word);
363 ATH_MSG_DEBUG(
"L1Topo EDM:: Connection Id: " << handle->back()->connectionId() <<
" Clock: " << handle->back()->clock() <<
" Decision: " << handle->back()->topoWord() );
378 StatusCode
sc = StatusCode::SUCCESS;
379 std::bitset<TCS::TopoSteering::numberOfL1TopoBits> hardwareDaqRobTriggerBits;
380 std::bitset<TCS::TopoSteering::numberOfL1TopoBits> hardwareDaqRobOvrflowBits;
381 bool prescalForDAQROBAccess =
true;
382 if (prescalForDAQROBAccess){
383 std::vector<L1Topo::L1TopoTOB> daqTobsBC0;
384 std::vector<uint32_t> tobsbc0SourceIds;
387 if (
sc.isFailure() or 0 == rdos) {
388 ATH_MSG_INFO (
"Could not retrieve L1Topo DAQ RDO collection from StoreGate" );
389 }
else if (rdos->
empty()) {
393 const std::vector<uint32_t> cDataWords = rdo->getDataWords();
396 for (
const uint32_t word : cDataWords){
404 if (
header.bcn_offset()==0){
405 daqTobsBC0.push_back(tob);
406 tobsbc0SourceIds.push_back(rdo->getSourceID());
415 for(uint32_t iTob=0; iTob<daqTobsBC0.size(); ++iTob){
417 const uint32_t &sourceId = tobsbc0SourceIds[iTob];
418 for(
unsigned int i=0; i<8; ++i){
425 hardwareDaqRobOvrflowBits);
436 StatusCode
sc = StatusCode::SUCCESS;
438 std::bitset<TCS::TopoSteering::numberOfL1TopoBits> hardwareDaqRobTriggerBits;
439 std::bitset<TCS::TopoSteering::numberOfL1TopoBits> hardwareDaqRobOvrflowBits;
443 ATH_MSG_FATAL(
"Could not retrieve L1Topo RAW Data Container from the BS data.");
444 return StatusCode::FAILURE;
447 std::unique_ptr<L1Topo::L1TopoResult> l1topoResult = std::make_unique<L1Topo::L1TopoResult>(*cont);
448 if (!l1topoResult->getStatus()) {
450 return StatusCode::FAILURE;
452 hardwareDaqRobTriggerBits = l1topoResult->getDecisions();
453 hardwareDaqRobOvrflowBits = l1topoResult->getOverflows();
458 hardwareDaqRobOvrflowBits);
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_WARNING(x)
#define CHECK(...)
Evaluate an expression and check for errors.
#define ATLAS_NOT_THREAD_SAFE
getNoisyStrip() Find noisy strips from hitmaps and write out into xml/db formats
AthAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor with parameters:
ServiceHandle< StoreGateSvc > & evtStore()
const ServiceHandle< StoreGateSvc > & detStore() const
bool empty() const noexcept
Returns true if the collection is empty.
Container of L1TopoRDOs (standard Athena boilerplate)
The class that represents the raw data received from an L1Topo board.
Represents the L1Topo TOB word of the L1Topo ROI data, with decode and encoder.
uint32_t overflow_bits() const
accessor method for overflow bits
uint32_t trigger_bits() const
accessor method for trigger bits
Gaudi::Property< unsigned int > m_prescale
virtual StatusCode start() override
StatusCode hardwareDecisionPhase1(const EventContext &ctx)
Gaudi::Property< bool > m_enableInputDump
SG::WriteHandleKey< xAOD::L1TopoSimResultsContainer > m_l1topoKey
SG::WriteHandleKey< LVL1::FrontPanelCTP > m_legacyTopoOverflowCTPLocation
SG key of overflow bits for CTP.
StatusCode hardwareDecisionLegacy()
StatusCode retrieveHardwareDecision(bool isLegacy, const EventContext &ctx)
Retrieve the L1Topo hardware bits from the DAQ RODs.
std::unique_ptr< TCS::TopoSteering > m_topoSteering
the topo steering
ToolHandle< IInputTOBConverter > m_energyInputProvider
SG::WriteHandleKey< xAOD::L1TopoSimResultsContainer > m_legacyL1topoKey
Gaudi::Property< bool > m_isLegacyTopo
SG::ReadHandleKey< xAOD::L1TopoRawDataContainer > m_l1topoRawDataKey
virtual StatusCode finalize() override
void WriteEDM(SG::WriteHandle< xAOD::L1TopoSimResultsContainer > &handle, const std::string &name, unsigned int clock, uint32_t word)
SG::WriteHandleKey< LVL1::FrontPanelCTP > m_topoOverflowCTPLocation
SG key of overflow bits for CTP.
virtual StatusCode execute() override
Gaudi::Property< unsigned int > m_prescaleForDAQROBAccess
void WriteEDM_Overflow(SG::WriteHandle< xAOD::L1TopoSimResultsContainer > &handle, const std::string &name, unsigned int clock, uint32_t word)
L1TopoSimulation(const std::string &name, ISvcLocator *pSvcLocator)
virtual bool isClonable() const override
SG::WriteHandleKey< LVL1::FrontPanelCTP > m_topoCTPLocation
SG key of decision bits for CTP.
ToolHandle< IInputTOBConverter > m_muonInputProvider
Gaudi::Property< std::string > m_inputDumpFile
ToolHandle< IInputTOBConverter > m_emtauInputProvider
Gaudi::Property< bool > m_fillHistogramsBasedOnHardwareDecision
SG::WriteHandleKey< LVL1::FrontPanelCTP > m_legacyTopoCTPLocation
SG key of decision bits for CTP.
std::unique_ptr< LVL1::PeriodicScaler > m_scaler
ToolHandle< IInputTOBConverter > m_jetInputProvider
Utility class to determine if a chain should be prescaled/passed-through using its PS/PT factor,...
virtual bool isValid() override final
Can the handle be successfully dereferenced?
virtual const std::string & key() const override final
Return the StoreGate ID for the referenced object.
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
std::bitset< 128 > count_field(const std::string &l1connName) const
uint64_t decision_field(const std::string &l1connName) const
uint64_t ambiguity_field(const std::string &l1connName) const
uint64_t overflow_field(const std::string &l1connName) const
::StatusCode StatusCode
StatusCode definition for legacy code.
L1Topo::BlockTypes blockType(const uint32_t word, uint32_t offset=28, uint32_t size=0x0f)
Function to return the block type of a data word from L1Topo.
unsigned int triggerBitIndexNew(uint32_t moduleId, const L1Topo::L1TopoTOB &, unsigned int bitIdx)
Helper to calculate the index needed to pack trigger bits into the full 128-bit decision....
eFexTowerBuilder creates xAOD::eFexTowerContainer from supercells (LATOME) and triggerTowers (TREX) i...
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
outputTopoType_t outputType(const std::string &output)