ATLAS Offline Software
Loading...
Searching...
No Matches
INav4MomDumper Class Reference

#include <INav4MomDumper.h>

Inheritance diagram for INav4MomDumper:
Collaboration diagram for INav4MomDumper:

Public Member Functions

 INav4MomDumper (const std::string &name, ISvcLocator *pSvcLocator)
 Constructor with parameters:
virtual ~INav4MomDumper ()
 Destructor:
virtual StatusCode initialize ()
virtual StatusCode execute ()
virtual StatusCode finalize ()
StatusCode dump (const std::string &collName)
 Prints out (on the configured output stream) the content of an INavigable4MomentumCollection object, given its StoreGate key.
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

 INav4MomDumper ()
 Default constructor:
void setupOutputStream (Gaudi::Details::PropertyBase &outputStreamName)
 Callback method to configure the output stream into which we'll dump the informations from INavigable4MomentumCollection.
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.

Protected Attributes

StringArrayProperty m_inav4momContainersName
 List of INavigable4Momentum containers one wants to dump.
StringProperty m_outputStreamName
 Name of the output stream where we'll dump informations from the INav4MomAssocs object.
std::ostream * m_outputStream
 pointer to the file descriptor in case the output stream is not a "MsgStream"

Private Types

typedef ServiceHandle< StoreGateSvcStoreGateSvc_t

Private Member Functions

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

Private Attributes

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

Definition at line 23 of file INav4MomDumper.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

◆ INav4MomDumper() [1/2]

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

Constructor with parameters:

Definition at line 46 of file INav4MomDumper.cxx.

47 :
48 AthAlgorithm( name, pSvcLocator ),
49 m_outputStream ( 0 )
50{
51 //
52 // Property declaration
53 //
54 //declareProperty( "Property", m_nProperty );
55
56 std::string descr;
57
58 descr = "List of INavigable4Momentum containers one wants to dump";
59 declareProperty( "INav4Moms",
61 descr );
62 std::vector<std::string> inav4momContainersName( 0 );
63 m_inav4momContainersName.set( inav4momContainersName );
64
65 descr = "Name of the output stream where we'll dump informations from the";
66 descr += " INavigable4MomentumCollection object(s).";
67 descr += " Valid stream names are: \n";
68 descr += " - \"MsgStream\"\n";
69 descr += " - \"stderr\"\n";
70 descr += " - \"stdout\"\n";
71 descr += " - \"/path/to/some/file\".";
72
73 declareProperty( "OutputStream",
74 m_outputStreamName = "MsgStream",
75 descr );
77 this );
78}
AthAlgorithm()
Default constructor:
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
StringArrayProperty m_inav4momContainersName
List of INavigable4Momentum containers one wants to dump.
std::ostream * m_outputStream
pointer to the file descriptor in case the output stream is not a "MsgStream"
StringProperty m_outputStreamName
Name of the output stream where we'll dump informations from the INav4MomAssocs object.
void setupOutputStream(Gaudi::Details::PropertyBase &outputStreamName)
Callback method to configure the output stream into which we'll dump the informations from INavigable...
list descr
print "%s.properties()" % self.__name__

◆ ~INav4MomDumper()

INav4MomDumper::~INav4MomDumper ( )
virtual

Destructor:

Definition at line 82 of file INav4MomDumper.cxx.

83{
84 ATH_MSG_DEBUG( "Calling destructor" );
85 // delete output stream
86 if ( m_outputStream &&
87 ( m_outputStream != &std::cout &&
88 m_outputStream != &std::cerr ) ) {
89 delete m_outputStream;
91 }
92}
#define ATH_MSG_DEBUG(x)

◆ INav4MomDumper() [2/2]

INav4MomDumper::INav4MomDumper ( )
protected

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 }

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

◆ dump()

StatusCode INav4MomDumper::dump ( const std::string & collName)

Prints out (on the configured output stream) the content of an INavigable4MomentumCollection object, given its StoreGate key.

Definition at line 150 of file INav4MomDumper.cxx.

151{
152 typedef INavigable4MomentumCollection INav4Moms_t;
153 if ( !evtStore()->contains<INav4Moms_t>( collName ) ) {
154 ATH_MSG_WARNING( "No [" << collName
155 << "] INavigable4MomentumCollection in StoreGate !" );
156 return StatusCode::RECOVERABLE;
157 }
158
159 const INav4Moms_t * coll = 0;
160 if ( !evtStore()->retrieve( coll, collName ).isSuccess() ||
161 0 == coll )
162 {
163 ATH_MSG_WARNING( "Could not retrieve any INavigable4MomentumCollection at ["
164 << collName << "] !!" );
165 return StatusCode::RECOVERABLE;
166 }
167
168 std::ostringstream out;
169
170 const std::size_t iMax = coll->size();
171 out << "Retrieved [" << collName << "] ==> size = " << iMax << "\n";
172 if ( coll->empty() ) {
173 return StatusCode::SUCCESS;
174 }
175
176 // sorting the collection by Pt
177 typedef std::set<const INavigable4Momentum*, P4Sorters::Descending::Pt> Coll_t;
178 Coll_t inav4moms( coll->begin(), coll->end() );
179
180 FourMomUtils::dump( out, inav4moms );
181
182 if ( 0 != m_outputStream ) { (*m_outputStream) << out.str() << std::flush;
183 } else { ATH_MSG_DEBUG( out.str() );
184 }
185
186 return StatusCode::SUCCESS;
187}
#define ATH_MSG_WARNING(x)
DataVector< INavigable4Momentum > INavigable4MomentumCollection
bool contains(const std::string &s, const std::string &regx)
does a string contain the substring
Definition hcg.cxx:114
std::ostream & dump(std::ostream &out, const I4MomIter iBeg, const I4MomIter iEnd)
Helper to stream out a range of I4Momentum objects.
Definition P4Dumper.h:24
retrieve(aClass, aKey=None)
Definition PyKernel.py:110

◆ 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 INav4MomDumper::execute ( )
virtual

Definition at line 121 of file INav4MomDumper.cxx.

122{
123 ATH_MSG_DEBUG( "Executing " << name() << "..." );
124
125 typedef std::vector<std::string>::const_iterator ContNameIterator;
126
127 for ( ContNameIterator
128 itr = m_inav4momContainersName.value().begin(),
129 iEnd = m_inav4momContainersName.value().end();
130 itr != iEnd;
131 ++itr )
132 {
133 ATH_MSG_DEBUG( "dumping: [" << *itr << "]..." );
134
135 if ( !dump( *itr ).isSuccess() ) {
136 ATH_MSG_WARNING( "Problem while dumping [" << *itr << "] !!" );
137 continue;
138 }
139 ATH_MSG_DEBUG( "dumping: [" << *itr << "]... [OK]" );
140 }
141
142 return StatusCode::SUCCESS;
143}
StatusCode dump(const std::string &collName)
Prints out (on the configured output stream) the content of an INavigable4MomentumCollection object,...

◆ 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 INav4MomDumper::finalize ( )
virtual

Definition at line 115 of file INav4MomDumper.cxx.

116{
117 ATH_MSG_INFO( "Finalizing " << name() << "..." );
118 return StatusCode::SUCCESS;
119}
#define ATH_MSG_INFO(x)

◆ initialize()

StatusCode INav4MomDumper::initialize ( )
virtual

Definition at line 96 of file INav4MomDumper.cxx.

97{
98 ATH_MSG_INFO( "Initializing " << name() << "..." );
99
100 ATH_MSG_INFO( "Configured to dump [" << m_inav4momContainersName.value().size()
101 << "] containers:" );
102 for ( std::vector<std::string>::const_iterator
103 itr = m_inav4momContainersName.value().begin(),
104 iEnd= m_inav4momContainersName.value().end();
105 itr != iEnd;
106 ++itr )
107 {
108 ATH_MSG_INFO( " - " << *itr );
109 }
110 ATH_MSG_INFO( "OutputStream : " << m_outputStreamName.value() );
111
112 return StatusCode::SUCCESS;
113}

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

◆ setupOutputStream()

void INav4MomDumper::setupOutputStream ( Gaudi::Details::PropertyBase & outputStreamName)
protected

Callback method to configure the output stream into which we'll dump the informations from INavigable4MomentumCollection.

Definition at line 193 of file INav4MomDumper.cxx.

194{
195 // reset internal state
196 if ( m_outputStream &&
197 ( m_outputStream != &std::cout && m_outputStream != &std::cerr ) ) {
198 delete m_outputStream;
199 m_outputStream = 0;
200 }
201
202 std::string streamName = m_outputStreamName.value();
203
204 // get the stream in lower case
205 std::transform( streamName.begin(), streamName.end(),
206 streamName.begin(),
207 ToLower() );
208
209 const std::string stdout = "stdout";
210 const std::string stderr = "stderr";
211 const std::string msgstream = "msgstream";
212
213 if ( streamName == msgstream ) {
214 m_outputStream = 0;
215 } else if ( streamName == stdout ) {
216 m_outputStream = &std::cout;
217 } else if ( streamName == stderr ) {
218 m_outputStream = &std::cerr;
219 } else {
220 m_outputStream = new std::ofstream( m_outputStreamName.value().c_str(),
221 std::ios::out | std::ios::trunc );
222 }
223
224 return;
225}

◆ 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_ERROR(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_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_inav4momContainersName

StringArrayProperty INav4MomDumper::m_inav4momContainersName
protected

List of INavigable4Momentum containers one wants to dump.

Definition at line 80 of file INav4MomDumper.h.

◆ m_outputStream

std::ostream* INav4MomDumper::m_outputStream
protected

pointer to the file descriptor in case the output stream is not a "MsgStream"

Definition at line 90 of file INav4MomDumper.h.

◆ m_outputStreamName

StringProperty INav4MomDumper::m_outputStreamName
protected

Name of the output stream where we'll dump informations from the INav4MomAssocs object.

Default: "MsgStream" Available streams: ["MsgStream", "stdout", "stderr", "anyfile"]

Definition at line 86 of file INav4MomDumper.h.

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