ATLAS Offline Software
CTPUnpackingEmulationTool.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2021 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 )
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 );
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( 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 
52  return parseInputFile();
53 }
54 
55 
56 StatusCode CTPUnpackingEmulationTool::decode( const ROIB::RoIBResult& /*roib*/, HLT::IDVec& enabledChains ) const {
57  if ( m_events.empty() ){
58  ATH_MSG_ERROR( "No chain set found. Cannot decode CTP emulation" );
59  return StatusCode::FAILURE;
60  }
61 
62  const EventContext& context = Gaudi::Hive::currentContext();
63  size_t line = context.evt() % m_events.size();
64  enabledChains = m_events[line];
65 
66  return StatusCode::SUCCESS;
67 }
CTPUnpackingEmulationTool::decode
virtual StatusCode decode(const ROIB::RoIBResult &roib, HLT::IDVec &enabledChains) const override
Definition: CTPUnpackingEmulationTool.cxx:56
checkFileSG.line
line
Definition: checkFileSG.py:75
ROIB::RoIBResult
Class holding the LVL1 RoIB result build by the RoIBuilder.
Definition: RoIBResult.h:47
CTPUnpackingToolBase
Base class for CTP unpacking tools.
Definition: CTPUnpackingToolBase.h:24
CTPUnpackingEmulationTool::m_events
std::vector< HLT::IDVec > m_events
Chain IDs (inner vector) to activate for each event (outer vector)
Definition: CTPUnpackingEmulationTool.h:32
CTPUnpackingEmulationTool::parseInputFile
StatusCode parseInputFile()
Fill the m_events vector with configuration from an input file.
Definition: CTPUnpackingEmulationTool.cxx:19
HLT::IDVec
std::vector< HLT::Identifier > IDVec
Definition: TrigCompositeUtils/TrigCompositeUtils/HLTIdentifier.h:62
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
CaloCondBlobAlgs_fillNoiseFromASCII.inputFile
string inputFile
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:17
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
CTPUnpackingEmulationTool.h
test_pyathena.parent
parent
Definition: test_pyathena.py:15
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
HLT::Identifier
Definition: TrigCompositeUtils/TrigCompositeUtils/HLTIdentifier.h:20
CTPUnpackingEmulationTool::initialize
virtual StatusCode initialize() override
Definition: CTPUnpackingEmulationTool.cxx:50
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
python.subdetectors.mmg.ids
ids
Definition: mmg.py:8
CTPUnpackingEmulationTool::m_inputFileName
Gaudi::Property< std::string > m_inputFileName
Definition: CTPUnpackingEmulationTool.h:28
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
python.TriggerAPI.TriggerAPISession.chainName
chainName
Definition: TriggerAPISession.py:426
HLTIdentifier.h
CTPUnpackingToolBase::initialize
virtual StatusCode initialize() override
Definition: CTPUnpackingToolBase.cxx:14
CTPUnpackingEmulationTool::CTPUnpackingEmulationTool
CTPUnpackingEmulationTool(const std::string &type, const std::string &name, const IInterface *parent)
Definition: CTPUnpackingEmulationTool.cxx:13