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#include "GaudiKernel/ThreadLocalContext.h"
9
10#include <fstream>
11
12
14 const std::string& name,
15 const IInterface* parent )
16 : CTPUnpackingToolBase( type, name, parent ) {}
17
18
20 std::ifstream inputFile( m_inputFileName );
21 if ( not inputFile.good() ) {
22 ATH_MSG_ERROR( "Input file " << m_inputFileName << " inaccessible" );
23 return StatusCode::FAILURE;
24 }
25
26 std::string line;
27 while ( std::getline( inputFile, line ) ) {
28 if ( line[0] == '#' ) {continue;}
29 std::istringstream allChains( line );
30 HLT::IDVec ids;
31 while ( allChains ) {
32 std::string chainName;
33 allChains >> chainName;
34 if ( not chainName.empty() ) {
35 ids.push_back( HLT::Identifier( chainName ).numeric() );
36 }
37 }
38
39 if ( not ids.empty() ) {
40 m_events.push_back( std::move(ids) ); // new event
41 }
42 }
43 inputFile.close();
44
45 ATH_MSG_DEBUG( "In input file "<<m_inputFileName.value()<<" found "<<m_events.size()<<" chain sets" );
46 return StatusCode::SUCCESS;
47}
48
49
54
55
56StatusCode CTPUnpackingEmulationTool::decode( const EventContext& ctx,
57 const ROIB::RoIBResult& /*roib*/,
58 HLT::IDVec& enabledChains ) const {
59 if ( m_events.empty() ){
60 ATH_MSG_ERROR( "No chain set found. Cannot decode CTP emulation" );
61 return StatusCode::FAILURE;
62 }
63
64 size_t line = ctx.evt() % m_events.size();
65 enabledChains = m_events[line];
66
67 return StatusCode::SUCCESS;
68}
#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