The Gaudi Framework  v32r2 (46d42edc)
Test::ViewTester Class Reference

#include <src/ViewTester.h>

Inheritance diagram for Test::ViewTester:
Collaboration diagram for Test::ViewTester:

Public Member Functions

bool isClonable () const override
 
StatusCode execute () override
 the execution of the algorithm More...
 
StatusCode initialize () override
 Its initialization. More...
 
StatusCode finalize () override
 the finalization of the algorithm More...
 
 ViewTester (const std::string &name, ISvcLocator *pSvc)
 
- Public Member Functions inherited from GaudiAlgorithm
StatusCode initialize () override
 standard initialization method More...
 
StatusCode execute () override
 standard execution method More...
 
StatusCode finalize () override
 standard finalization method More...
 
StatusCode sysExecute (const EventContext &ctx) override
 the generic actions for the execution. More...
 
void put (IDataProviderSvc *svc, DataObject *object, const std::string &address, const bool useRootInTES=true) const
 Register a data object or container into Gaudi Event Transient Store. More...
 
void put (IDataProviderSvc *svc, std::unique_ptr< DataObject > object, const std::string &address, const bool useRootInTES=true) const
 
const DataObjectput (DataObject *object, const std::string &address, const bool useRootInTES=true) const
 Register a data object or container into Gaudi Event Transient Store. More...
 
const DataObjectput (std::unique_ptr< DataObject > object, const std::string &address, const bool useRootInTES=true) const
 
template<class TYPE >
Gaudi::Utils::GetData< TYPE >::return_type get (IDataProviderSvc *svc, const std::string &location, const bool useRootInTES=true) const
 Templated access to the data in Gaudi Transient Store. More...
 
template<class TYPE >
Gaudi::Utils::GetData< TYPE >::return_type getIfExists (IDataProviderSvc *svc, const std::string &location, const bool useRootInTES=true) const
 Templated access to the data in Gaudi Transient Store. More...
 
template<class TYPE >
Gaudi::Utils::GetData< TYPE >::return_type get (const std::string &location, const bool useRootInTES=true) const
 Templated access to the data from Gaudi Event Transient Store. More...
 
template<class TYPE >
Gaudi::Utils::GetData< TYPE >::return_type getIfExists (const std::string &location, const bool useRootInTES=true) const
 Templated access to the data in Gaudi Transient Store. More...
 
template<class TYPE >
TYPE * getDet (IDataProviderSvc *svc, const std::string &location) const
 Templated access to the detector data from the Gaudi Detector Transient Store. More...
 
template<class TYPE >
Gaudi::Utils::GetData< TYPE >::return_type getDetIfExists (IDataProviderSvc *svc, const std::string &location) const
 Templated access to the detector data from the Gaudi Detector Transient Store. More...
 
template<class TYPE >
TYPE * getDet (const std::string &location) const
 Templated access to the detector data from the Gaudi Detector Transient Store. More...
 
template<class TYPE >
Gaudi::Utils::GetData< TYPE >::return_type getDetIfExists (const std::string &location) const
 Templated access to the detector data from the Gaudi Detector Transient Store. More...
 
template<class TYPE >
bool exist (IDataProviderSvc *svc, const std::string &location, const bool useRootInTES=true) const
 Check the existence of a data object or container in the Gaudi Transient Event Store. More...
 
template<class TYPE >
bool exist (const std::string &location, const bool useRootInTES=true) const
 Check the existence of a data object or container in the Gaudi Transient Event Store. More...
 
template<class TYPE >
bool existDet (IDataProviderSvc *svc, const std::string &location) const
 Check the existence of detector objects in the Gaudi Transient Detector Store. More...
 
template<class TYPE >
bool existDet (const std::string &location) const
 Check the existence of detector objects in the Gaudi Transient Detector Store. More...
 
template<class TYPE , class TYPE2 >
Gaudi::Utils::GetData< TYPE >::return_type getOrCreate (IDataProviderSvc *svc, const std::string &location, const bool useRootInTES=true) const
 Get the existing data object from Gaudi Event Transient store. More...
 
template<class TYPE , class TYPE2 >
Gaudi::Utils::GetData< TYPE >::return_type getOrCreate (const std::string &location, const bool useRootInTES=true) const
 Get the existing data object from Gaudi Event Transient store. More...
 
 GaudiAlgorithm (const std::string &name, ISvcLocator *pSvcLocator)
 Standard constructor. More...
 
 GaudiAlgorithm (const GaudiAlgorithm &)=delete
 
GaudiAlgorithmoperator= (const GaudiAlgorithm &)=delete
 
SmartIF< INTupleSvc > & evtColSvc () const
 Access the standard event collection service. More...
 
- Public Member Functions inherited from GaudiCommon< Algorithm >
Gaudi::Utils::GetData< TYPE >::return_type get (IDataProviderSvc *svc, const std::string &location, const bool useRootInTES=true) const
 Templated access to the data in Gaudi Transient Store. More...
 
Gaudi::Utils::GetData< TYPE >::return_type getIfExists (IDataProviderSvc *svc, const std::string &location, const bool useRootInTES=true) const
 Quicker version of the get function which bypasses the check on the retrieved data. More...
 
bool exist (IDataProviderSvc *svc, const std::string &location, const bool useRootInTES=true) const
 Check the existence of a data object or container in the Gaudi Transient Event Store. More...
 
Gaudi::Utils::GetData< TYPE >::return_type getOrCreate (IDataProviderSvc *svc, const std::string &location, const bool useRootInTES=true) const
 Get the existing data object from Gaudi Event Transient store. More...
 
DataObjectput (IDataProviderSvc *svc, std::unique_ptr< DataObject > object, const std::string &location, const bool useRootInTES=true) const
 Register a data object or container into Gaudi Event Transient Store. More...
 
DataObjectput (IDataProviderSvc *svc, DataObject *object, const std::string &location, const bool useRootInTES=true) const
 
TOOL * tool (const std::string &type, const std::string &name, const IInterface *parent=0, bool create=true) const
 Useful method for the easy location of tools. More...
 
TOOL * tool (const std::string &type, const IInterface *parent=0, bool create=true) const
 A useful method for the easy location of tools. More...
 
SmartIF< SERVICE > svc (const std::string &name, const bool create=true) const
 A useful method for the easy location of services. More...
 
IUpdateManagerSvcupdMgrSvc () const
 Short-cut to locate the Update Manager Service. More...
 
WARN_UNUSED StatusCode Error (const std::string &msg, const StatusCode st=StatusCode::FAILURE, const size_t mx=10) const
 Print the error message and return with the given StatusCode. More...
 
WARN_UNUSED StatusCode Warning (const std::string &msg, const StatusCode st=StatusCode::FAILURE, const size_t mx=10) const
 Print the warning message and return with the given StatusCode. More...
 
WARN_UNUSED StatusCode Info (const std::string &msg, const StatusCode st=StatusCode::SUCCESS, const size_t mx=10) const
 Print the info message and return with the given StatusCode. More...
 
WARN_UNUSED StatusCode Print (const std::string &msg, const StatusCode st=StatusCode::SUCCESS, const MSG::Level lev=MSG::INFO) const
 Print the message and return with the given StatusCode. More...
 
void Assert (const bool ok, const std::string &message="", const StatusCode sc=StatusCode(StatusCode::FAILURE, true)) const
 Assertion - throw exception if the given condition is not fulfilled. More...
 
void Assert (const bool ok, const char *message, const StatusCode sc=StatusCode(StatusCode::FAILURE, true)) const
 Assertion - throw exception if the given condition is not fulfilled. More...
 
void Exception (const std::string &msg, const GaudiException &exc, const StatusCode sc=StatusCode(StatusCode::FAILURE, true)) const
 Create and (re)-throw a given GaudiException. More...
 
void Exception (const std::string &msg, const std::exception &exc, const StatusCode sc=StatusCode(StatusCode::FAILURE, true)) const
 Create and (re)-throw a given exception. More...
 
void Exception (const std::string &msg="no message", const StatusCode sc=StatusCode(StatusCode::FAILURE, true)) const
 Create and throw an exception with the given message. More...
 
StatEntity & counter (const std::string &tag) const
 accessor to certain counter by name More...
 
StatEntity & counter (const std::string &tag)
 
bool typePrint () const
 Insert the actual C++ type of the algorithm/tool in the messages ? More...
 
bool propsPrint () const
 Print properties at initialization ? More...
 
bool statPrint () const
 Print statistical counters at finalization ? More...
 
bool errorsPrint () const
 Print error counters at finalization ? More...
 
long printStat (const MSG::Level level=MSG::ALWAYS) const
 perform the actual printout of statistical counters More...
 
long printErrors (const MSG::Level level=MSG::ALWAYS) const
 perform the actual printout of error counters More...
 
long printProps (const MSG::Level level=MSG::ALWAYS) const
 perform the actual printout of properties More...
 
void registerCondition (const std::string &condition, StatusCode(CallerClass::*mf)()=nullptr)
 register the current instance to the UpdateManagerSvc as a consumer for a condition. More...
 
void registerCondition (const std::string &condition, CondType *&condPtrDest, StatusCode(CallerClass::*mf)()=NULL)
 register the current instance to the UpdateManagerSvc as a consumer for a condition. More...
 
void registerCondition (char *condition, StatusCode(CallerClass::*mf)()=NULL)
 just to avoid conflicts with the version using a pointer to a template class. More...
 
void registerCondition (TargetClass *condition, StatusCode(CallerClass::*mf)()=NULL)
 register the current instance to the UpdateManagerSvc as a consumer for a condition. More...
 
StatusCode runUpdate ()
 asks the UpdateManagerSvc to perform an update of the instance (if needed) without waiting the next BeginEvent incident. More...
 
 GaudiCommon (const std::string &name, ISvcLocator *pSvcLocator)
 Algorithm constructor - the SFINAE constraint below ensures that this is constructor is only defined if PBASE derives from Algorithm. More...
 
 GaudiCommon (const std::string &type, const std::string &name, const IInterface *ancestor)
 Tool constructor - SFINAE-ed to insure this constructor is only defined if PBASE derives from AlgTool. More...
 
StatusCode initialize () override
 standard initialization method More...
 
StatusCode finalize () override
 standard finalization method More...
 
StatusCode release (const IInterface *interface) const
 Manual forced (and 'safe') release of the active tool or service. More...
 
const Servicesservices () const
 get the list of aquired services More...
 
const std::stringcontext () const
 Returns the "context" string. Used to identify different processing states. More...
 
- Public Member Functions inherited from FixTESPath< BASE >
template<typename U = BASE, typename = std::enable_if_t<std::is_base_of_v<Gaudi::Algorithm, BASE>, U>>
 FixTESPath (const std::string &name, ISvcLocator *pSvcLocator)
 Algorithm constructor - the SFINAE constraint below ensures that this is constructor is only defined if BASE derives from Algorithm. More...
 
template<typename U = BASE, typename = std::enable_if_t<std::is_base_of_v<AlgTool, BASE>, U>>
 FixTESPath (const std::string &type, const std::string &name, const IInterface *ancestor)
 Tool constructor - SFINAE-ed to insure this constructor is only defined if BASE derives from AlgTool. More...
 
StatusCode initialize () override
 
const std::stringrootInTES () const
 Returns the "rootInTES" string. More...
 
std::string fullTESLocation (std::string_view location, bool useRootInTES) const
 Returns the full correct event location given the rootInTes settings. More...
 

Private Member Functions

 ViewTester ()
 the default constructor is disabled More...
 
 ViewTester (const ViewTester &)
 the copy constructor is disabled More...
 
ViewTesteroperator= (const ViewTester &)
 the assignement operator is disabled More...
 

Private Attributes

Gaudi::Property< std::vector< std::string > > m_inpKeys {this, "inpKeys", {}, ""}
 
Gaudi::Property< std::vector< std::string > > m_outKeys {this, "outKeys", {}, ""}
 
std::vector< std::unique_ptr< DataObjectHandle< DataObject > > > m_inputHandles
 
std::vector< std::unique_ptr< DataObjectHandle< DataObject > > > m_outputHandles
 
Gaudi::Property< std::stringm_baseViewName
 
Gaudi::Property< unsigned int > m_viewNumber {this, "viewNumber", 0, "How many views to make"}
 
Gaudi::Property< std::stringm_viewNodeName {this, "viewNodeName", "viewNode", "Name of node to attach views to"}
 

Additional Inherited Members

- Protected Types inherited from GaudiCommon< Algorithm >
using base_class = FixTESPath< Algorithm >
 
typedef std::map< std::string, StatEntity > StatisticsOwn
 the actual type of general counters More...
 
typedef std::map< std::string, std::reference_wrapper< Gaudi::Accumulators::PrintableCounter > > Statistics
 
typedef std::map< std::string, unsigned int > Counter
 the actual type error/warning counter More...
 
typedef std::vector< IAlgTool * > AlgTools
 storage for active tools More...
 
typedef std::vector< SmartIF< IService > > Services
 storage for active services More...
 
- Protected Member Functions inherited from GaudiCommon< Algorithm >
StatusCode releaseTool (const IAlgTool *tool) const
 manual forced (and 'safe') release of the tool More...
 
StatusCode releaseSvc (const IInterface *svc) const
 manual forced (and 'safe') release of the service More...
 
- Protected Attributes inherited from GaudiCommon< Algorithm >
SmartIF< ICounterSummarySvcm_counterSummarySvc
 a pointer to the CounterSummarySvc More...
 
- Static Protected Attributes inherited from GaudiCommon< Algorithm >
static const bool IgnoreRootInTES
 Simple definition to be used with the new useRootInTES argument get<TYPE> and put methods. More...
 
static const bool UseRootInTES
 Simple definition to be used with the new useRootInTES argument get<TYPE> and put methods. More...
 

Detailed Description

Definition at line 15 of file ViewTester.h.

Constructor & Destructor Documentation

◆ ViewTester() [1/3]

ViewTester::ViewTester ( const std::string name,
ISvcLocator pSvc 
)

Definition at line 16 of file ViewTester.cpp.

18  : GaudiAlgorithm( name, pSvc ) {}
GaudiAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Standard constructor.

◆ ViewTester() [2/3]

Test::ViewTester::ViewTester ( )
private

the default constructor is disabled

◆ ViewTester() [3/3]

Test::ViewTester::ViewTester ( const ViewTester )
private

the copy constructor is disabled

Member Function Documentation

◆ execute()

StatusCode ViewTester::execute ( )
override

the execution of the algorithm

Definition at line 52 of file ViewTester.cpp.

53 {
54  SmartIF<IScheduler> scheduler( serviceLocator()->service( "AvalancheSchedulerSvc" ) );
55  if ( !scheduler ) {
56  fatal() << "Unable to load AvalancheSchedulerSvc" << endmsg;
57  return StatusCode::FAILURE;
58  }
59 
60  const auto& context = getContext();
61 
62  // Report if currently running in a view
63  if ( !context.hasExtension<std::string>() )
64  info() << "Running in whole event context" << endmsg;
65  else
66  info() << "Running in view " << context.getExtension<std::string>() << endmsg;
67 
68  // If a node name is specified (and not already in view), do view scheduling
69  if ( !m_viewNodeName.empty() && !context.hasExtension<std::string>() ) {
70  if ( m_viewNumber > 0 ) {
71  // Make views
72  for ( unsigned int viewIndex = 0; viewIndex < m_viewNumber; ++viewIndex ) {
73  // Make event context for the view
74  auto viewContext = std::make_unique<EventContext>( context.evt(), context.slot() );
75  const std::string& viewName = viewContext->setExtension( m_baseViewName + std::to_string( viewIndex ) );
76 
77  StatusCode sc = scheduler->scheduleEventView( &context, m_viewNodeName, std::move( viewContext ) );
78  if ( sc.isSuccess() )
79  info() << "Attached view " << viewName << " to node " << m_viewNodeName.toString() << " for " << context
80  << endmsg;
81  else
82  error() << "Unable to attach view " << viewName << " to node " << m_viewNodeName.toString() << " for "
83  << context << endmsg;
84  }
85  } else {
86  // Disable the view node if there are no views
87  scheduler->scheduleEventView( &context, m_viewNodeName, nullptr );
88  }
89  }
90 
91  VERBOSE_MSG << "outputs number: " << m_outputHandles.size() << endmsg;
92  for ( auto& outputHandle : m_outputHandles ) {
93  if ( !outputHandle->isValid() ) continue;
94 
95  VERBOSE_MSG << "put to TS: " << outputHandle->objKey() << endmsg;
96  outputHandle->put( std::make_unique<DataObject>() );
97  }
98 
99  setFilterPassed( true );
100 
101  return StatusCode::SUCCESS;
102 }
std::vector< std::unique_ptr< DataObjectHandle< DataObject > > > m_outputHandles
Definition: ViewTester.h:41
T to_string(T... args)
constexpr static const auto SUCCESS
Definition: StatusCode.h:85
Gaudi::Property< std::string > m_baseViewName
Definition: ViewTester.h:44
STL class.
Gaudi::Property< std::string > m_viewNodeName
Definition: ViewTester.h:47
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:50
bool isSuccess() const
Definition: StatusCode.h:267
const std::string & context() const
Returns the "context" string. Used to identify different processing states.
Definition: GaudiCommon.h:707
T move(T... args)
#define VERBOSE_MSG
Definition: ViewTester.cpp:10
T size(T... args)
constexpr static const auto FAILURE
Definition: StatusCode.h:86
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:192
Gaudi::Property< unsigned int > m_viewNumber
Definition: ViewTester.h:46

◆ finalize()

StatusCode ViewTester::finalize ( )
override

the finalization of the algorithm

Definition at line 106 of file ViewTester.cpp.

107 {
108  return GaudiAlgorithm::finalize();
109 }
StatusCode finalize() override
standard finalization method

◆ initialize()

StatusCode ViewTester::initialize ( )
override

Its initialization.

Definition at line 20 of file ViewTester.cpp.

20  {
21  auto sc = GaudiAlgorithm::initialize();
22  if ( !sc ) return sc;
23 
24  // This is a bit ugly. There is no way to declare a vector of DataObjectHandles, so
25  // we need to wait until initialize when we've read in the input and output key
26  // properties, and know their size, and then turn them
27  // into Handles and register them with the framework by calling declareProperty. We
28  // could call declareInput/declareOutput on them too.
29 
30  int i = 0;
31  for ( auto k : m_inpKeys ) {
32  DEBUG_MSG << "adding input key " << k << endmsg;
34  declareProperty( "dummy_in_" + std::to_string( i ), *( m_inputHandles.back() ) );
35  i++;
36  }
37 
38  i = 0;
39  for ( auto k : m_outKeys ) {
40  DEBUG_MSG << "adding output key " << k << endmsg;
42  std::make_unique<DataObjectHandle<DataObject>>( k, Gaudi::DataHandle::Writer, this ) );
43  declareProperty( "dummy_out_" + std::to_string( i ), *( m_outputHandles.back() ) );
44  i++;
45  }
46 
47  return sc;
48 }
std::vector< std::unique_ptr< DataObjectHandle< DataObject > > > m_outputHandles
Definition: ViewTester.h:41
StatusCode initialize() override
standard initialization method
T to_string(T... args)
#define DEBUG_MSG
Definition: ViewTester.cpp:7
Gaudi::Property< std::vector< std::string > > m_inpKeys
Definition: ViewTester.h:38
Gaudi::Property< std::vector< std::string > > m_outKeys
Definition: ViewTester.h:39
T back(T... args)
std::vector< std::unique_ptr< DataObjectHandle< DataObject > > > m_inputHandles
Definition: ViewTester.h:40
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:192
T emplace_back(T... args)

◆ isClonable()

bool Test::ViewTester::isClonable ( ) const
inlineoverride

Definition at line 18 of file ViewTester.h.

18 { return true; }

◆ operator=()

ViewTester& Test::ViewTester::operator= ( const ViewTester )
private

the assignement operator is disabled

Member Data Documentation

◆ m_baseViewName

Gaudi::Property<std::string> Test::ViewTester::m_baseViewName
private
Initial value:
{this, "baseViewName", "view",
"Views to be named this, plus a numerical index"}

Definition at line 44 of file ViewTester.h.

◆ m_inpKeys

Gaudi::Property<std::vector<std::string> > Test::ViewTester::m_inpKeys {this, "inpKeys", {}, ""}
private

Definition at line 38 of file ViewTester.h.

◆ m_inputHandles

std::vector<std::unique_ptr<DataObjectHandle<DataObject> > > Test::ViewTester::m_inputHandles
private

Definition at line 40 of file ViewTester.h.

◆ m_outKeys

Gaudi::Property<std::vector<std::string> > Test::ViewTester::m_outKeys {this, "outKeys", {}, ""}
private

Definition at line 39 of file ViewTester.h.

◆ m_outputHandles

std::vector<std::unique_ptr<DataObjectHandle<DataObject> > > Test::ViewTester::m_outputHandles
private

Definition at line 41 of file ViewTester.h.

◆ m_viewNodeName

Gaudi::Property<std::string> Test::ViewTester::m_viewNodeName {this, "viewNodeName", "viewNode", "Name of node to attach views to"}
private

Definition at line 47 of file ViewTester.h.

◆ m_viewNumber

Gaudi::Property<unsigned int> Test::ViewTester::m_viewNumber {this, "viewNumber", 0, "How many views to make"}
private

Definition at line 46 of file ViewTester.h.


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