ATLAS Offline Software
Loading...
Searching...
No Matches
GlobalSim::PU1SuppTestBenchAlg Class Reference

Athena algorithm that feeds TOB and rho data into the PU1 suppression chain. More...

#include <PU1SuppTestBench.h>

Inheritance diagram for GlobalSim::PU1SuppTestBenchAlg:
Collaboration diagram for GlobalSim::PU1SuppTestBenchAlg:

Public Member Functions

 PU1SuppTestBenchAlg (const std::string &name, ISvcLocator *pSvcLocator)
 Constructor.
virtual StatusCode initialize () override
 Athena initialize hook.
virtual StatusCode execute () override
 Athena execute hook (called once per event)
virtual StatusCode sysInitialize () override
 Override sysInitialize.
virtual const DataObjIDColl & extraOutputDeps () const override
 Return the list of extra output dependencies.
ServiceHandle< StoreGateSvc > & evtStore ()
 The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
const ServiceHandle< StoreGateSvc > & detStore () const
 The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.
virtual StatusCode sysStart () override
 Handle START transition.
virtual std::vector< Gaudi::DataHandle * > inputHandles () const override
 Return this algorithm's input handles.
virtual std::vector< Gaudi::DataHandle * > outputHandles () const override
 Return this algorithm's output handles.
Gaudi::Details::PropertyBase & declareProperty (Gaudi::Property< T, V, H > &t)
void updateVHKA (Gaudi::Details::PropertyBase &)
MsgStream & msg () const
bool msgLvl (const MSG::Level lvl) const

Protected Member Functions

void renounceArray (SG::VarHandleKeyArray &handlesArray)
 remove all handles from I/O resolution
std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > renounce (T &h)
void extraDeps_update_handler (Gaudi::Details::PropertyBase &ExtraDeps)
 Add StoreName to extra input/output deps as needed.

Private Types

typedef ServiceHandle< StoreGateSvcStoreGateSvc_t

Private Member Functions

StatusCode init_from_file ()
 Populate m_fifos from file.
std::string trim (const std::string &s)
 Strip whitespace from both ends of a string.
Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
 specialization for handling Gaudi::Property<SG::VarHandleKey>

Private Attributes

Gaudi::Property< std::string > m_testsFileName
 Path to input file containing 256-bit TOBs as 64-character hex strings.
Gaudi::Property< std::string > m_rhoFileName
 Path to input file containing rho values, one per line.
SG::WriteHandleKey< GepAlgoPU1SuppFIFOm_suppFIFO_WriteKey
 Write handle key for TOB FIFO.
SG::WriteHandleKey< PU1SuppExpectationsm_PU1SuppExpectations_WriteKey
 Write handle key for dummy expectations.
std::vector< std::unique_ptr< GepAlgoPU1SuppFIFO > > m_fifos
 Preloaded list of TOB FIFOs from file.
std::size_t m_fifo_ptr {0}
 Index of next FIFO to write during execution.
DataObjIDColl m_extendedExtraObjects
StoreGateSvc_t m_evtStore
 Pointer to StoreGate (event store by default)
StoreGateSvc_t m_detStore
 Pointer to StoreGate (detector store by default)
std::vector< SG::VarHandleKeyArray * > m_vhka
bool m_varHandleArraysDeclared

Detailed Description

Athena algorithm that feeds TOB and rho data into the PU1 suppression chain.

Reads hex-encoded 256-bit TOBs and associated rho values from file, converts them into PU1SuppPortsIn structs, and pushes them into the StoreGate FIFO.

Definition at line 34 of file PU1SuppTestBench.h.

Member Typedef Documentation

◆ StoreGateSvc_t

typedef ServiceHandle<StoreGateSvc> AthCommonDataStore< AthCommonMsg< Algorithm > >::StoreGateSvc_t
privateinherited

Definition at line 388 of file AthCommonDataStore.h.

Constructor & Destructor Documentation

◆ PU1SuppTestBenchAlg()

GlobalSim::PU1SuppTestBenchAlg::PU1SuppTestBenchAlg ( const std::string & name,
ISvcLocator * pSvcLocator )

Constructor.

Constructor implementation.

Definition at line 26 of file PU1SuppTestBench.cxx.

28 : AthAlgorithm(name, pSvcLocator) {}
AthAlgorithm()
Default constructor:

Member Function Documentation

◆ declareGaudiProperty()

Gaudi::Details::PropertyBase & AthCommonDataStore< AthCommonMsg< Algorithm > >::declareGaudiProperty ( Gaudi::Property< T, V, H > & hndl,
const SG::VarHandleKeyType &  )
inlineprivateinherited

specialization for handling Gaudi::Property<SG::VarHandleKey>

Definition at line 156 of file AthCommonDataStore.h.

158 {
160 hndl.value(),
161 hndl.documentation());
162
163 }
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)

◆ declareProperty()

Gaudi::Details::PropertyBase & AthCommonDataStore< AthCommonMsg< Algorithm > >::declareProperty ( Gaudi::Property< T, V, H > & t)
inlineinherited

Definition at line 145 of file AthCommonDataStore.h.

145 {
146 typedef typename SG::HandleClassifier<T>::type htype;
148 }
Gaudi::Details::PropertyBase & declareGaudiProperty(Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
specialization for handling Gaudi::Property<SG::VarHandleKey>

◆ detStore()

const ServiceHandle< StoreGateSvc > & AthCommonDataStore< AthCommonMsg< Algorithm > >::detStore ( ) const
inlineinherited

The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 95 of file AthCommonDataStore.h.

◆ evtStore()

ServiceHandle< StoreGateSvc > & AthCommonDataStore< AthCommonMsg< Algorithm > >::evtStore ( )
inlineinherited

The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 85 of file AthCommonDataStore.h.

◆ execute()

StatusCode GlobalSim::PU1SuppTestBenchAlg::execute ( )
overridevirtual

Athena execute hook (called once per event)

Athena execute method (runs once per event)

Definition at line 49 of file PU1SuppTestBench.cxx.

49 {
50 if (m_fifo_ptr >= m_fifos.size()) {
51 ATH_MSG_ERROR("No more FIFO data to write");
52 return StatusCode::FAILURE;
53 }
54
55 // Write TOB FIFO to event store
56 SG::WriteHandle<GepAlgoPU1SuppFIFO> h_write(m_suppFIFO_WriteKey);
57 CHECK(h_write.record(std::move(m_fifos[m_fifo_ptr])));
58
59 // Write dummy expectation to event store (placeholder)
60 auto expectations = std::make_unique<PU1SuppExpectations>("0000", "0000");
61 SG::WriteHandle<PU1SuppExpectations> h_write_exp(
63 CHECK(h_write_exp.record(std::move(expectations)));
64
65 ++m_fifo_ptr;
66 return StatusCode::SUCCESS;
67}
#define ATH_MSG_ERROR(x)
#define CHECK(...)
Evaluate an expression and check for errors.
std::vector< std::unique_ptr< GepAlgoPU1SuppFIFO > > m_fifos
Preloaded list of TOB FIFOs from file.
SG::WriteHandleKey< GepAlgoPU1SuppFIFO > m_suppFIFO_WriteKey
Write handle key for TOB FIFO.
SG::WriteHandleKey< PU1SuppExpectations > m_PU1SuppExpectations_WriteKey
Write handle key for dummy expectations.
std::size_t m_fifo_ptr
Index of next FIFO to write during execution.

◆ extraDeps_update_handler()

void AthCommonDataStore< AthCommonMsg< Algorithm > >::extraDeps_update_handler ( Gaudi::Details::PropertyBase & ExtraDeps)
protectedinherited

Add StoreName to extra input/output deps as needed.

use the logic of the VarHandleKey to parse the DataObjID keys supplied via the ExtraInputs and ExtraOuputs Properties to add the StoreName if it's not explicitly given

◆ extraOutputDeps()

const DataObjIDColl & AthAlgorithm::extraOutputDeps ( ) const
overridevirtualinherited

Return the list of extra output dependencies.

This list is extended to include symlinks implied by inheritance relations.

Definition at line 50 of file AthAlgorithm.cxx.

51{
52 // If we didn't find any symlinks to add, just return the collection
53 // from the base class. Otherwise, return the extended collection.
54 if (!m_extendedExtraObjects.empty()) {
56 }
57 return Algorithm::extraOutputDeps();
58}
DataObjIDColl m_extendedExtraObjects

◆ init_from_file()

StatusCode GlobalSim::PU1SuppTestBenchAlg::init_from_file ( )
private

Populate m_fifos from file.

Read TOB and rho test vectors from input files and populate FIFO buffer.

Definition at line 70 of file PU1SuppTestBench.cxx.

70 {
71 std::ifstream tobFile(m_testsFileName);
72 std::ifstream rhoFile(m_rhoFileName);
73
74 if (!tobFile) {
75 ATH_MSG_FATAL("Failed to open TOB input file: " << m_testsFileName);
76 return StatusCode::FAILURE;
77 }
78 if (!rhoFile) {
79 ATH_MSG_FATAL("Failed to open rho input file: " << m_rhoFileName);
80 return StatusCode::FAILURE;
81 }
82
83 std::string tobLine, rhoLine;
84 int lineNum = 0;
85
86 while (std::getline(tobFile, tobLine) && std::getline(rhoFile, rhoLine)) {
87 ++lineNum;
88
89 std::string tobStr = trim(tobLine);
90 std::string rhoStr = trim(rhoLine);
91
92 const bool isHex = (tobStr.length() == 64 &&
93 std::all_of(tobStr.begin(), tobStr.end(), ::isxdigit));
94
95 const bool isBinary =
96 (tobStr.length() == 256 &&
97 std::all_of(tobStr.begin(), tobStr.end(),
98 [](char c) { return c == '0' || c == '1'; }));
99
100 if (!isHex && !isBinary) {
101 ATH_MSG_WARNING("Skipping bad TOB line "
102 << lineNum
103 << ": expected 64 length hex or 256 length bit");
104 continue;
105 }
106
107 auto fifo = std::make_unique<GepAlgoPU1SuppFIFO>();
108 PU1SuppPortsIn ports_in;
109
110 const int chunkSize = isHex ? 16 : 64;
111 std::string_view tobView = tobStr;
112 bool parseError = false;
113
114 for (int i=0; i < 4; ++i) {
115 auto tobWord = tobView.substr(i * chunkSize, chunkSize);
116 uint64_t value = 0;
117 auto [ptr, ec] = std::from_chars(
118 tobWord.data(),
119 tobWord.data() + tobWord.size(),
120 value,
121 isHex ? 16 : 2
122 );
123 if (ec != std::errc{}) {
124 ATH_MSG_WARNING("Skipping bad TOB line " << lineNum
125 << ": failed to parse section " << i);
126 parseError = true;
127 break;
128 }
129 ports_in.m_I_PU1TobData[i] = value;
130 }
131
132 if (parseError) continue;
133
134 ports_in.m_rho = static_cast<uint16_t>(std::stoul(rhoStr, nullptr, 2));
135
136 fifo->push_back(ports_in);
137 m_fifos.push_back(std::move(fifo));
138 }
139
140 return StatusCode::SUCCESS;
141}
#define ATH_MSG_FATAL(x)
#define ATH_MSG_WARNING(x)
Gaudi::Property< std::string > m_testsFileName
Path to input file containing 256-bit TOBs as 64-character hex strings.
Gaudi::Property< std::string > m_rhoFileName
Path to input file containing rho values, one per line.
std::string trim(const std::string &s)
Strip whitespace from both ends of a string.
void * ptr(T *p)
Definition SGImplSvc.cxx:74
setWord1 uint16_t

◆ initialize()

StatusCode GlobalSim::PU1SuppTestBenchAlg::initialize ( )
overridevirtual

Athena initialize hook.

Athena initialize method.

Definition at line 31 of file PU1SuppTestBench.cxx.

31 {
32 ATH_MSG_INFO("Initializing PU1SuppTestBench");
33
34 CHECK(m_suppFIFO_WriteKey.initialize());
36
37 if (m_testsFileName.empty()) {
38 ATH_MSG_FATAL("testsFileName is empty");
39 return StatusCode::FAILURE;
40 }
41
43
44 ATH_MSG_INFO("Loaded " << m_fifos.size() << " FIFOs for input");
45 return StatusCode::SUCCESS;
46}
#define ATH_MSG_INFO(x)
StatusCode init_from_file()
Populate m_fifos from file.

◆ inputHandles()

virtual std::vector< Gaudi::DataHandle * > AthCommonDataStore< AthCommonMsg< Algorithm > >::inputHandles ( ) const
overridevirtualinherited

Return this algorithm's input handles.

We override this to include handle instances from key arrays if they have not yet been declared. See comments on updateVHKA.

◆ msg()

MsgStream & AthCommonMsg< Algorithm >::msg ( ) const
inlineinherited

Definition at line 24 of file AthCommonMsg.h.

24 {
25 return this->msgStream();
26 }

◆ msgLvl()

bool AthCommonMsg< Algorithm >::msgLvl ( const MSG::Level lvl) const
inlineinherited

Definition at line 30 of file AthCommonMsg.h.

30 {
31 return this->msgLevel(lvl);
32 }

◆ outputHandles()

virtual std::vector< Gaudi::DataHandle * > AthCommonDataStore< AthCommonMsg< Algorithm > >::outputHandles ( ) const
overridevirtualinherited

Return this algorithm's output handles.

We override this to include handle instances from key arrays if they have not yet been declared. See comments on updateVHKA.

◆ renounce()

std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > AthCommonDataStore< AthCommonMsg< Algorithm > >::renounce ( T & h)
inlineprotectedinherited

Definition at line 380 of file AthCommonDataStore.h.

381 {
382 h.renounce();
384 }
std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > renounce(T &h)

◆ renounceArray()

void AthCommonDataStore< AthCommonMsg< Algorithm > >::renounceArray ( SG::VarHandleKeyArray & handlesArray)
inlineprotectedinherited

remove all handles from I/O resolution

Definition at line 364 of file AthCommonDataStore.h.

364 {
366 }

◆ sysInitialize()

StatusCode AthAlgorithm::sysInitialize ( )
overridevirtualinherited

Override sysInitialize.

Override sysInitialize from the base class.

Loop through all output handles, and if they're WriteCondHandles, automatically register them and this Algorithm with the CondSvc

Scan through all outputHandles, and if they're WriteCondHandles, register them with the CondSvc

Reimplemented from AthCommonDataStore< AthCommonMsg< Algorithm > >.

Reimplemented in AthAnalysisAlgorithm, AthFilterAlgorithm, AthHistogramAlgorithm, and PyAthena::Alg.

Definition at line 66 of file AthAlgorithm.cxx.

66 {
68
69 if (sc.isFailure()) {
70 return sc;
71 }
72 ServiceHandle<ICondSvc> cs("CondSvc",name());
73 for (auto h : outputHandles()) {
74 if (h->isCondition() && h->mode() == Gaudi::DataHandle::Writer) {
75 // do this inside the loop so we don't create the CondSvc until needed
76 if ( cs.retrieve().isFailure() ) {
77 ATH_MSG_WARNING("no CondSvc found: won't autoreg WriteCondHandles");
78 return StatusCode::SUCCESS;
79 }
80 if (cs->regHandle(this,*h).isFailure()) {
81 sc = StatusCode::FAILURE;
82 ATH_MSG_ERROR("unable to register WriteCondHandle " << h->fullKey()
83 << " with CondSvc");
84 }
85 }
86 }
87 return sc;
88}
static Double_t sc
virtual StatusCode sysInitialize() override
Override sysInitialize.
AthCommonDataStore(const std::string &name, T... args)
virtual std::vector< Gaudi::DataHandle * > outputHandles() const override
::StatusCode StatusCode
StatusCode definition for legacy code.

◆ sysStart()

virtual StatusCode AthCommonDataStore< AthCommonMsg< Algorithm > >::sysStart ( )
overridevirtualinherited

Handle START transition.

We override this in order to make sure that conditions handle keys can cache a pointer to the conditions container.

◆ trim()

std::string GlobalSim::PU1SuppTestBenchAlg::trim ( const std::string & s)
private

Strip whitespace from both ends of a string.

Helper to trim leading and trailing whitespace from a string.

Definition at line 144 of file PU1SuppTestBench.cxx.

144 {
145 std::string result = s;
146 boost::algorithm::trim(result);
147 return result;
148}

◆ updateVHKA()

void AthCommonDataStore< AthCommonMsg< Algorithm > >::updateVHKA ( Gaudi::Details::PropertyBase & )
inlineinherited

Definition at line 308 of file AthCommonDataStore.h.

308 {
309 // debug() << "updateVHKA for property " << p.name() << " " << p.toString()
310 // << " size: " << m_vhka.size() << endmsg;
311 for (auto &a : m_vhka) {
313 for (auto k : keys) {
314 k->setOwner(this);
315 }
316 }
317 }
std::vector< SG::VarHandleKeyArray * > m_vhka

Member Data Documentation

◆ m_detStore

StoreGateSvc_t AthCommonDataStore< AthCommonMsg< Algorithm > >::m_detStore
privateinherited

Pointer to StoreGate (detector store by default)

Definition at line 393 of file AthCommonDataStore.h.

◆ m_evtStore

StoreGateSvc_t AthCommonDataStore< AthCommonMsg< Algorithm > >::m_evtStore
privateinherited

Pointer to StoreGate (event store by default)

Definition at line 390 of file AthCommonDataStore.h.

◆ m_extendedExtraObjects

DataObjIDColl AthAlgorithm::m_extendedExtraObjects
privateinherited

Definition at line 79 of file AthAlgorithm.h.

◆ m_fifo_ptr

std::size_t GlobalSim::PU1SuppTestBenchAlg::m_fifo_ptr {0}
private

Index of next FIFO to write during execution.

Definition at line 70 of file PU1SuppTestBench.h.

70{0};

◆ m_fifos

std::vector<std::unique_ptr<GepAlgoPU1SuppFIFO> > GlobalSim::PU1SuppTestBenchAlg::m_fifos
private

Preloaded list of TOB FIFOs from file.

Definition at line 67 of file PU1SuppTestBench.h.

◆ m_PU1SuppExpectations_WriteKey

SG::WriteHandleKey<PU1SuppExpectations> GlobalSim::PU1SuppTestBenchAlg::m_PU1SuppExpectations_WriteKey
private
Initial value:
{
this, "ExpectationsKey", "ExpectedTOBs", "Key to write dummy expectations (optional)"
}

Write handle key for dummy expectations.

Definition at line 62 of file PU1SuppTestBench.h.

62 {
63 this, "ExpectationsKey", "ExpectedTOBs", "Key to write dummy expectations (optional)"
64 };

◆ m_rhoFileName

Gaudi::Property<std::string> GlobalSim::PU1SuppTestBenchAlg::m_rhoFileName
private
Initial value:
{
this, "RhoFileName", "", "Path to file containing rho values"
}

Path to input file containing rho values, one per line.

Definition at line 52 of file PU1SuppTestBench.h.

52 {
53 this, "RhoFileName", "", "Path to file containing rho values"
54 };

◆ m_suppFIFO_WriteKey

SG::WriteHandleKey<GepAlgoPU1SuppFIFO> GlobalSim::PU1SuppTestBenchAlg::m_suppFIFO_WriteKey
private
Initial value:
{
this, "SuppFIFOKey", "SuppFIFO", "Key to write FIFO of TOBs to SG"
}

Write handle key for TOB FIFO.

Definition at line 57 of file PU1SuppTestBench.h.

57 {
58 this, "SuppFIFOKey", "SuppFIFO", "Key to write FIFO of TOBs to SG"
59 };

◆ m_testsFileName

Gaudi::Property<std::string> GlobalSim::PU1SuppTestBenchAlg::m_testsFileName
private
Initial value:
{
this, "TestsFileName", "", "Path to file containing 256-bit TOB hex strings"
}

Path to input file containing 256-bit TOBs as 64-character hex strings.

Definition at line 47 of file PU1SuppTestBench.h.

47 {
48 this, "TestsFileName", "", "Path to file containing 256-bit TOB hex strings"
49 };

◆ m_varHandleArraysDeclared

bool AthCommonDataStore< AthCommonMsg< Algorithm > >::m_varHandleArraysDeclared
privateinherited

Definition at line 399 of file AthCommonDataStore.h.

◆ m_vhka

std::vector<SG::VarHandleKeyArray*> AthCommonDataStore< AthCommonMsg< Algorithm > >::m_vhka
privateinherited

Definition at line 398 of file AthCommonDataStore.h.


The documentation for this class was generated from the following files: