The Gaudi Framework  v33r1 (b1225454)
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, std::string_view 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 (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, std::string_view 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, std::string_view 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, std::string_view 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, std::string_view 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, std::string_view location, const bool useRootInTES=true) const
 Register a data object or container into Gaudi Event Transient Store. More...
 
DataObjectput (IDataProviderSvc *svc, DataObject *object, std::string_view location, const bool useRootInTES=true) const
 
TOOL * tool (std::string_view type, std::string_view name, const IInterface *parent=0, bool create=true) const
 Useful method for the easy location of tools. More...
 
TOOL * tool (std::string_view type, const IInterface *parent=0, bool create=true) const
 A useful method for the easy location of tools. More...
 
SmartIF< SERVICE > svc (std::string_view 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...
 
StatusCode Error (std::string_view msg, const StatusCode st=StatusCode::FAILURE, const size_t mx=10) const
 Print the error message and return with the given StatusCode. More...
 
StatusCode Warning (std::string_view msg, const StatusCode st=StatusCode::FAILURE, const size_t mx=10) const
 Print the warning message and return with the given StatusCode. More...
 
StatusCode Info (std::string_view msg, const StatusCode st=StatusCode::SUCCESS, const size_t mx=10) const
 Print the info message and return with the given StatusCode. More...
 
StatusCode Print (std::string_view 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, std::string_view message="", const StatusCode sc=StatusCode(StatusCode::FAILURE, true)) const
 Assertion - throw exception if the given condition is not fulfilled. More...
 
void Exception (std::string_view msg, const GaudiException &exc, const StatusCode sc=StatusCode(StatusCode::FAILURE, true)) const
 Create and (re)-throw a given GaudiException. More...
 
void Exception (std::string_view msg, const std::exception &exc, const StatusCode sc=StatusCode(StatusCode::FAILURE, true)) const
 Create and (re)-throw a given exception. More...
 
void Exception (std::string_view msg="no message", const StatusCode sc=StatusCode(StatusCode::FAILURE, true)) const
 Create and throw an exception with the given message. More...
 
StatEntitycounter (std::string_view tag) const
 accessor to certain counter by name More...
 
StatEntitycounter (std::string_view 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 (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 (std::string type, std::string name, const IInterface *ancestor)
 Tool constructor - SFINAE-ed to insure this constructor is only defined if PBASE derives from AlgTool. More...
 
 GaudiCommon ()=delete
 
 GaudiCommon (const GaudiCommon &)=delete
 
StatusCode initialize () override
 standard initialization method More...
 
StatusCode finalize () override
 standard finalization method More...
 
GaudiCommonoperator= (const GaudiCommon &)=delete
 
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 (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 (std::string type, 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, std::less<> > StatisticsOwn
 the actual type of general counters More...
 
typedef std::map< std::string, std::reference_wrapper< Gaudi::Accumulators::PrintableCounter >, std::less<> > Statistics
 
typedef std::map< std::string, unsigned int, std::less<> > 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 25 of file ViewTester.h.

Constructor & Destructor Documentation

◆ ViewTester() [1/3]

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

Definition at line 26 of file ViewTester.cpp.

28  : GaudiAlgorithm( name, pSvc ) {}
GaudiAlgorithm(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 62 of file ViewTester.cpp.

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

◆ finalize()

StatusCode ViewTester::finalize ( )
override

the finalization of the algorithm

Definition at line 117 of file ViewTester.cpp.

118 {
119  return GaudiAlgorithm::finalize();
120 }
StatusCode finalize() override
standard finalization method

◆ initialize()

StatusCode ViewTester::initialize ( )
override

Its initialization.

Definition at line 30 of file ViewTester.cpp.

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

◆ isClonable()

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

Definition at line 28 of file ViewTester.h.

28 { 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 54 of file ViewTester.h.

◆ m_inpKeys

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

Definition at line 48 of file ViewTester.h.

◆ m_inputHandles

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

Definition at line 50 of file ViewTester.h.

◆ m_outKeys

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

Definition at line 49 of file ViewTester.h.

◆ m_outputHandles

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

Definition at line 51 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 57 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 56 of file ViewTester.h.


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