ATLAS Offline Software
Loading...
Searching...
No Matches
CTPUnpackingEmulationTool.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
6
7#include "GaudiKernel/EventContext.h"
8
9#include <fstream>
10
11
13 const std::string& name,
14 const IInterface* parent )
15 : CTPUnpackingToolBase( type, name, parent ) {}
16
17
19 std::ifstream inputFile( m_inputFileName );
20 if ( not inputFile.good() ) {
21 ATH_MSG_ERROR( "Input file " << m_inputFileName << " inaccessible" );
22 return StatusCode::FAILURE;
23 }
24
25 std::string line;
26 while ( std::getline( inputFile, line ) ) {
27 if ( line[0] == '#' ) {continue;}
28 std::istringstream allChains( line );
29 HLT::IDVec ids;
30 while ( allChains ) {
31 std::string chainName;
32 allChains >> chainName;
33 if ( not chainName.empty() ) {
34 ids.push_back( HLT::Identifier( chainName ).numeric() );
35 }
36 }
37
38 if ( not ids.empty() ) {
39 m_events.push_back( std::move(ids) ); // new event
40 }
41 }
42 inputFile.close();
43
44 ATH_MSG_DEBUG( "In input file "<<m_inputFileName.value()<<" found "<<m_events.size()<<" chain sets" );
45 return StatusCode::SUCCESS;
46}
47
48
53
54
55StatusCode CTPUnpackingEmulationTool::decode( const EventContext& ctx,
56 const ROIB::RoIBResult& /*roib*/,
57 HLT::IDVec& enabledChains ) const {
58 if ( m_events.empty() ){
59 ATH_MSG_ERROR( "No chain set found. Cannot decode CTP emulation" );
60 return StatusCode::FAILURE;
61 }
62
63 size_t line = ctx.evt() % m_events.size();
64 enabledChains = m_events[line];
65
66 return StatusCode::SUCCESS;
67}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_DEBUG(x)
Gaudi::Property< std::string > m_inputFileName
std::vector< HLT::IDVec > m_events
Chain IDs (inner vector) to activate for each event (outer vector).
CTPUnpackingEmulationTool(const std::string &type, const std::string &name, const IInterface *parent)
StatusCode parseInputFile()
Fill the m_events vector with configuration from an input file.
virtual StatusCode initialize() override
virtual StatusCode decode(const EventContext &ctx, const ROIB::RoIBResult &roib, HLT::IDVec &enabledChains) const override
CTPUnpackingToolBase(const std::string &type, const std::string &name, const IInterface *parent)
virtual StatusCode initialize() override
Class holding the LVL1 RoIB result build by the RoIBuilder.
Definition RoIBResult.h:47
std::vector< HLT::Identifier > IDVec