ATLAS Offline Software
Loading...
Searching...
No Matches
HLTTest::TestRecoAlg Class Reference

Pseudo reco alg, reads input file formatted as follows: prop1:value, prop2:value; prop1:value, prop2:value; ... and created TrigComposites with prop1 & prop2 details set to corresponding values. More...

#include <TestRecoAlg.h>

Inheritance diagram for HLTTest::TestRecoAlg:
Collaboration diagram for HLTTest::TestRecoAlg:

Public Member Functions

 TestRecoAlg (const std::string &name, ISvcLocator *pSvcLocator)
virtual ~TestRecoAlg ()
StatusCode initialize () override
StatusCode execute () override
StatusCode finalize () override
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 std::pair< std::string, float > Prop_t
typedef std::vector< Prop_tObj_t
typedef std::vector< Obj_tEvent_t
typedef ServiceHandle< StoreGateSvcStoreGateSvc_t

Private Member Functions

 TestRecoAlg ()
Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
 specialization for handling Gaudi::Property<SG::VarHandleKey>

Private Attributes

std::vector< Event_tm_data
StringProperty m_fileName { this, "FileName", "Input file with fake objects"}
SG::WriteHandleKey< xAOD::TrigCompositeContainerm_output { this, "Output", "Output collection name" }
SG::ReadHandleKey< xAOD::TrigCompositeContainerm_input { this, "Input", "Input collection name" }
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

Pseudo reco alg, reads input file formatted as follows: prop1:value, prop2:value; prop1:value, prop2:value; ... and created TrigComposites with prop1 & prop2 details set to corresponding values.

one line is one event

Definition at line 26 of file TestRecoAlg.h.

Member Typedef Documentation

◆ Event_t

typedef std::vector< Obj_t > HLTTest::TestRecoAlg::Event_t
private

Definition at line 42 of file TestRecoAlg.h.

◆ Obj_t

typedef std::vector< Prop_t > HLTTest::TestRecoAlg::Obj_t
private

Definition at line 41 of file TestRecoAlg.h.

◆ Prop_t

typedef std::pair< std::string, float > HLTTest::TestRecoAlg::Prop_t
private

Definition at line 40 of file TestRecoAlg.h.

◆ StoreGateSvc_t

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

Definition at line 388 of file AthCommonDataStore.h.

Constructor & Destructor Documentation

◆ TestRecoAlg() [1/2]

HLTTest::TestRecoAlg::TestRecoAlg ( const std::string & name,
ISvcLocator * pSvcLocator )

Definition at line 15 of file TestRecoAlg.cxx.

16 :
17 ::AthAlgorithm( name, pSvcLocator )
18 {}
AthAlgorithm()
Default constructor:

◆ ~TestRecoAlg()

HLTTest::TestRecoAlg::~TestRecoAlg ( )
virtual

Definition at line 21 of file TestRecoAlg.cxx.

21{}

◆ TestRecoAlg() [2/2]

HLTTest::TestRecoAlg::TestRecoAlg ( )
private

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 HLTTest::TestRecoAlg::execute ( )
override

Definition at line 82 of file TestRecoAlg.cxx.

82 {
83 using namespace TrigCompositeUtils;
84 ATH_MSG_DEBUG ("Executing " << name() << "...");
85
86 const EventContext& context = Gaudi::Hive::currentContext();
87 const size_t eventNo = context.evt() % m_data.size();
88 auto objects= m_data[eventNo];
89
90 auto output = std::make_unique<xAOD::TrigCompositeContainer>();
91 auto aux = std::make_unique<xAOD::TrigCompositeAuxContainer>();
92 output->setStore( aux.get() );
93
94
95 auto inputHandle = SG::makeHandle(m_input);
96 ATH_MSG_DEBUG("Input " << m_input.key() << " has "<<inputHandle->size() <<" elements, scanning it");
97 for ( auto i: *inputHandle.cptr() ) {
98 auto featureInfo = TrigCompositeUtils::findLink<TrigRoiDescriptorCollection>( i, "initialRoI" );
99 auto roiLink = featureInfo.link;
100 CHECK( roiLink.isValid() );
101 if ( roiLink.isValid() ) {
102 auto roiPtr(roiLink.cptr());
103 ATH_MSG_DEBUG("RoI" << **roiPtr );
104 bool foundObject = false;
105 // create new outpu objects and add the properties
106 if (objects.size() > output->size()) {
107 // attaching the correct object form input data:
108 for (const auto & object: objects){
109 auto eta = object[0].second;
110 auto phi = object[1].second;
111 // check eta and phi
112 if (std::abs( eta - (*roiPtr)->eta()) <0.01 && std::abs(phi - (*roiPtr)->phi())< 0.01){
113 foundObject = true;
114 ATH_MSG_DEBUG( "Found object: " << object[0].first << " : " << object[0].second <<" , " << object[1].first << " : " << object[1].second );
115 auto xobj = new xAOD::TrigComposite;
116 output->push_back( xobj );
117 // maintain link to previous collections
118 xobj->setObjectLink( "initialRoI", roiLink );// this is used by the HypoAlg
119 for ( const auto& prop : object ) {
120 xobj->setDetail( prop.first, prop.second );
121 ATH_MSG_DEBUG( " " << prop.first << " : " << prop.second );
122 }
123 }
124 }
125 if (!foundObject) {
126 ATH_MSG_ERROR("No reco object found in eta and phi range: this might be an error");
127 }
128 }
129 else {
130 ATH_MSG_DEBUG( "No reco object created for this RoI because it's not found in the event");
131 }
132 } else {
133 ATH_MSG_DEBUG("RoI information missing");
134 }
135 }
136
137
138 ATH_MSG_DEBUG("Reconstructed "<<output->size() <<" objects");
139
140 auto handle = SG::makeHandle(m_output);
141 CHECK( handle.record( std::move(output), std::move(aux) ) );
142
143 return StatusCode::SUCCESS;
144 }
Scalar eta() const
pseudorapidity method
Scalar phi() const
phi method
#define ATH_MSG_ERROR(x)
#define ATH_MSG_DEBUG(x)
#define CHECK(...)
Evaluate an expression and check for errors.
std::vector< Event_t > m_data
Definition TestRecoAlg.h:43
SG::WriteHandleKey< xAOD::TrigCompositeContainer > m_output
Definition TestRecoAlg.h:46
SG::ReadHandleKey< xAOD::TrigCompositeContainer > m_input
Definition TestRecoAlg.h:47
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
LinkInfo< T > findLink(const Decision *start, const std::string &linkName, const bool suppressMultipleLinksWarning=false)
Perform a recursive search for ElementLinks of type T and name 'linkName', starting from Decision obj...
output
Definition merge.py:16
TrigComposite_v1 TrigComposite
Declare the latest version of the class.

◆ 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

◆ finalize()

StatusCode HLTTest::TestRecoAlg::finalize ( )
override

Definition at line 77 of file TestRecoAlg.cxx.

77 {
78 ATH_MSG_INFO ("Finalizing " << name() << "...");
79 return StatusCode::SUCCESS;
80 }
#define ATH_MSG_INFO(x)

◆ initialize()

StatusCode HLTTest::TestRecoAlg::initialize ( )
override

Definition at line 36 of file TestRecoAlg.cxx.

36 {
37 ATH_MSG_INFO ("Initializing " << name() << " reading input file " << m_fileName);
38
39
40 CHECK( m_output.initialize() );
41 CHECK( m_input.initialize( not m_input.key().empty() ) );
42 std::ifstream inputFile( m_fileName );
43 std::string line;
44 typedef std::vector<std::string> Split_t;
45
46 while ( getline(inputFile, line) ) {
47 if ( line[0] == '#' ) continue;
48 Split_t objects;
50 split( line, ';', objects );
51 for ( const auto& obj: objects ) {
53 Split_t properties;
54 split( obj, ',', properties );
55 for ( const auto& prop: properties ) {
56 Split_t keyval;
57 split( prop, ':', keyval );
58 if ( keyval.size() != 2 ) {
59 ATH_MSG_ERROR("Pnput format error, property specification invalid, should be a:b " << prop );
60 return StatusCode::FAILURE;
61 }
62 object.push_back( std::make_pair( trim ( keyval[0] ), std::stof(keyval[1]) ) );
63 }
64 if ( object.size() != 0 )
65 event.push_back(std::move(object));
66 }
67 m_data.push_back(std::move(event));
68 }
69 ATH_MSG_DEBUG( "Loaded " << m_data.size() << " pseudo events" );
70 if ( m_data.size() == 0 ) {
71 ATH_MSG_ERROR( "Can not run with zero pseudo events" );
72 return StatusCode::FAILURE;
73 }
74 return StatusCode::SUCCESS;
75 }
StringProperty m_fileName
Definition TestRecoAlg.h:44
std::vector< Prop_t > Obj_t
Definition TestRecoAlg.h:41
std::vector< Obj_t > Event_t
Definition TestRecoAlg.h:42
void split(const std::string &src, char delim, std::vector< std::string > &result)
std::string trim(const std::string &str)

◆ 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}
#define ATH_MSG_WARNING(x)
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.

◆ 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_data

std::vector< Event_t > HLTTest::TestRecoAlg::m_data
private

Definition at line 43 of file TestRecoAlg.h.

◆ 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_fileName

StringProperty HLTTest::TestRecoAlg::m_fileName { this, "FileName", "Input file with fake objects"}
private

Definition at line 44 of file TestRecoAlg.h.

44{ this, "FileName", "Input file with fake objects"};

◆ m_input

SG::ReadHandleKey<xAOD::TrigCompositeContainer> HLTTest::TestRecoAlg::m_input { this, "Input", "Input collection name" }
private

Definition at line 47 of file TestRecoAlg.h.

47{ this, "Input", "Input collection name" };

◆ m_output

SG::WriteHandleKey<xAOD::TrigCompositeContainer> HLTTest::TestRecoAlg::m_output { this, "Output", "Output collection name" }
private

Definition at line 46 of file TestRecoAlg.h.

46{ this, "Output", "Output collection name" };

◆ 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: