60 m_topoSteering->setLegacyMode(m_isLegacyTopo);
63 CHECK( m_histSvc.retrieve() );
65 if (m_emtauInputProvider.isEnabled()) {
67 CHECK( m_emtauInputProvider.retrieve() );
70 if (m_jetInputProvider.isEnabled()) {
72 CHECK( m_jetInputProvider.retrieve() );
75 if (m_energyInputProvider.isEnabled()) {
77 CHECK( m_energyInputProvider.retrieve() );
80 if (m_muonInputProvider.isEnabled()) {
82 CHECK( m_muonInputProvider.retrieve(DisableTool{m_isLegacyTopo}) );
86 CHECK( m_ControlHistSvc.retrieve());
88 CHECK(m_l1topoRawDataKey.initialize(m_fillHistogramsBasedOnHardwareDecision));
90 CHECK(m_legacyTopoCTPLocation.initialize(m_isLegacyTopo));
91 CHECK(m_legacyTopoOverflowCTPLocation.initialize(m_isLegacyTopo));
92 CHECK(m_topoCTPLocation.initialize(!m_isLegacyTopo));
93 CHECK(m_topoOverflowCTPLocation.initialize(!m_isLegacyTopo));
95 ATH_MSG_DEBUG(
"Legacy output trigger key property " << m_legacyTopoCTPLocation);
96 ATH_MSG_DEBUG(
"Legacy output overflow key property " << m_legacyTopoOverflowCTPLocation);
99 ATH_MSG_DEBUG(
"Output trigger key property " << m_topoCTPLocation);
100 ATH_MSG_DEBUG(
"Output overflow key property " << m_topoOverflowCTPLocation);
104 ATH_MSG_DEBUG(
"PrescaleDAQROBAccess factor set to " << m_prescaleForDAQROBAccess);
105 ATH_MSG_DEBUG(
"FillHistoBasedOnHardware " << m_fillHistogramsBasedOnHardwareDecision);
106 if(m_fillHistogramsBasedOnHardwareDecision and
107 (m_prescaleForDAQROBAccess % m_prescale)) {
108 ATH_MSG_FATAL(
"PrescaleDAQROBAccess must be a multiple of Prescale"
109 <<
" : current values :"
110 <<
" "<<m_prescaleForDAQROBAccess
112 return StatusCode::FAILURE;
116 ATH_CHECK( detStore()->retrieve(l1menu) );
117 ATH_MSG_INFO(
"initialize(): retrieving new-style L1 trigger menu from Detector Store" );
124 if ( jetProviderAsAlgTool && l1menu->thrExtraInfo().hasInfo(
"cXE") ) {
126 if ( jetProviderAsAlgTool->hasProperty(
"cXEweight_jFEX") ) {
127 float jXEweight = cXeExtraInfo.
jXeWeight();
128 jetProviderAsAlgTool->setProperty(
"cXEweight_jFEX", jXEweight).ignore();
130 if ( jetProviderAsAlgTool->hasProperty(
"cXEweight_gFEX") ) {
131 float gXEweight = cXeExtraInfo.
gXeWeight();
132 jetProviderAsAlgTool->setProperty(
"cXEweight_gFEX", gXEweight).ignore();
136 m_topoSteering->setUseBitwise(m_enableBitwise);
138 m_topoSteering->setupFromConfiguration(*l1menu);
140 catch(std::exception & e) {
141 ATH_MSG_FATAL(
"Caught exception when configuring topo steering from menu: " << e.what() );
142 return StatusCode::FAILURE;
146 m_topoSteering->setOutputAlgosFillBasedOnHardware(m_fillHistogramsBasedOnHardwareDecision);
148 if (m_doMonitoring) {
ATH_CHECK(m_ControlHistSvc->SetHistSvc(m_topoSteering, m_histBaseDir.value()));}
150 ATH_CHECK(m_legacyL1topoKey.initialize(m_isLegacyTopo));
151 ATH_CHECK(m_l1topoKey.initialize(!m_isLegacyTopo));
153 return StatusCode::SUCCESS;
167 catch(std::exception & e) {
168 ATH_MSG_FATAL(
"Caught exception when initializing topo algorithms" << e.what() );
169 return StatusCode::FAILURE;
177 return StatusCode::SUCCESS;
187 return StatusCode::SUCCESS;
204 ctx.eventID().event_number(),
205 ctx.eventID().lumi_block(),
206 ctx.eventID().bunch_crossing_id());
260 auto topoOutput2CTP = std::make_unique< LVL1::FrontPanelCTP >();
261 auto topoOverflow2CTP = std::make_unique< LVL1::FrontPanelCTP >();
269 ATH_CHECK(outputHandle.
record(std::make_unique<xAOD::L1TopoSimResultsContainer>(), std::make_unique<xAOD::L1TopoSimResultsAuxContainer>()));
274 std::string conn1 = l1menu->board(
"LegacyTopo0").connectorNames()[0];
275 std::string conn2 = l1menu->board(
"LegacyTopo1").connectorNames()[0];
276 for(
unsigned int clock=0; clock<2; ++clock) {
277 topoOutput2CTP->setCableWord0( clock, 0 );
279 topoOutput2CTP->setCableWord1( clock, globalOutput.
decision_field( conn1, clock) );
282 topoOutput2CTP->setCableWord2( clock, globalOutput.
decision_field( conn2, clock) );
294 std::string conn1 = l1menu->board(
"Topo2").connectorNames()[0];
295 std::string conn2 = l1menu->board(
"Topo3").connectorNames()[0];
296 for(
unsigned int clock=0; clock<2; ++clock) {
304 topoOverflow2CTP->setCableWord0( clock, 0 );
305 topoOverflow2CTP->setCableWord1( clock, globalOutput.
overflow_field( conn1, clock) );
307 topoOverflow2CTP->setCableWord2( clock, globalOutput.
overflow_field( conn2, clock) );
315 for(
const auto& connOpt : l1menu->board(
"Topo1").connectorNames() ) {
316 auto outputOpt = globalOutput.
count_field(connOpt);
317 std::bitset<64> outputOpt_1(outputOpt.to_string());
318 std::bitset<64> outputOpt_2((outputOpt<<64).
to_string());
319 topoOutput2CTP->setOptCableWord( connOpt, outputOpt );
320 WriteEDM(outputHandle,connOpt,1,outputOpt_1.to_ulong());
321 WriteEDM(outputHandle,connOpt,0,outputOpt_2.to_ulong());
328 return StatusCode::SUCCESS;
335 return StatusCode::SUCCESS;
341 handle->push_back(std::make_unique<xAOD::L1TopoSimResults>());
343 handle->back()->setClock(clock);
344 handle->back()->setBitWidth(32);
345 handle->back()->setTopoWord(word);
347 ATH_MSG_DEBUG(
"L1Topo EDM:: Connection Id: " << handle->back()->connectionId() <<
" Clock: " << handle->back()->clock() <<
" Decision: " << handle->back()->topoWord() );
353 handle->push_back(std::make_unique<xAOD::L1TopoSimResults>());
355 handle->back()->setClock(clock);
356 handle->back()->setBitWidth(32);
357 handle->back()->setTopoWordOverflow(word);
359 ATH_MSG_DEBUG(
"L1Topo EDM:: Connection Id: " << handle->back()->connectionId() <<
" Clock: " << handle->back()->clock() <<
" Decision: " << handle->back()->topoWord() );
365 handle->push_back(std::make_unique<xAOD::L1TopoSimResults>());
367 handle->back()->setClock(clock);
368 handle->back()->setBitWidth(64);
369 handle->back()->setTopoWord64(word);
371 ATH_MSG_DEBUG(
"L1Topo EDM:: Connection Id: " << handle->back()->connectionId() <<
" Clock: " << handle->back()->clock() <<
" Decision: " << handle->back()->topoWord() );
377 handle->push_back(std::make_unique<xAOD::L1TopoSimResults>());
379 handle->back()->setClock(clock);
380 handle->back()->setBitWidth(64);
381 handle->back()->setTopoWord64Overflow(word);
383 ATH_MSG_DEBUG(
"L1Topo EDM:: Connection Id: " << handle->back()->connectionId() <<
" Clock: " << handle->back()->clock() <<
" Decision: " << handle->back()->topoWord() );
398 StatusCode
sc = StatusCode::SUCCESS;
399 std::bitset<TCS::TopoSteering::numberOfL1TopoBits> hardwareDaqRobTriggerBits;
400 std::bitset<TCS::TopoSteering::numberOfL1TopoBits> hardwareDaqRobOvrflowBits;
401 bool prescalForDAQROBAccess =
true;
402 if (prescalForDAQROBAccess){
403 std::vector<L1Topo::L1TopoTOB> daqTobsBC0;
404 std::vector<uint32_t> tobsbc0SourceIds;
407 if (
sc.isFailure() or 0 == rdos) {
408 ATH_MSG_INFO (
"Could not retrieve L1Topo DAQ RDO collection from StoreGate" );
409 }
else if (rdos->
empty()) {
413 const std::vector<uint32_t> cDataWords = rdo->getDataWords();
416 for (
const uint32_t word : cDataWords){
424 if (
header.bcn_offset()==0){
425 daqTobsBC0.push_back(tob);
426 tobsbc0SourceIds.push_back(rdo->getSourceID());
435 for(uint32_t iTob=0; iTob<daqTobsBC0.size(); ++iTob){
437 const uint32_t &sourceId = tobsbc0SourceIds[iTob];
438 for(
unsigned int i=0; i<8; ++i){
445 hardwareDaqRobOvrflowBits);
456 StatusCode
sc = StatusCode::SUCCESS;
458 std::bitset<TCS::TopoSteering::numberOfL1TopoBits> hardwareDaqRobTriggerBits;
459 std::bitset<TCS::TopoSteering::numberOfL1TopoBits> hardwareDaqRobOvrflowBits;
463 ATH_MSG_FATAL(
"Could not retrieve L1Topo RAW Data Container from the BS data.");
464 return StatusCode::FAILURE;
467 std::unique_ptr<L1Topo::L1TopoResult> l1topoResult = std::make_unique<L1Topo::L1TopoResult>(*cont);
468 if (!l1topoResult->getStatus()) {
470 return StatusCode::FAILURE;
472 hardwareDaqRobTriggerBits = l1topoResult->getDecisions();
473 hardwareDaqRobOvrflowBits = l1topoResult->getOverflows();
478 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.
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 StatusCode execute(const EventContext &ctx) override
Execute method.
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)