The Gaudi Framework  v30r3 (a5ef0a68)
CollectionCloneAlg Class Reference

Small algorithm, which allows to merge N-tuples in a generic way. More...

Inheritance diagram for CollectionCloneAlg:
Collaboration diagram for CollectionCloneAlg:

Public Member Functions

StatusCode initialize () override
 Initialize. More...
 
StatusCode finalize () override
 Finalize. More...
 
StatusCode execute () override
 Execute procedure. More...
 
virtual StatusCode book (const NTuple::Tuple *nt)
 Book the N-tuple according to the specification. More...
 
virtual StatusCode checkInput (const NTuple::Tuple *clone, const NTuple::Tuple *src)
 
StatusCode mergeEntries (const std::string &input)
 Merge the entries of a single input tuple into the output. More...
 
StatusCode connect ()
 Connect input and output N-tuples. More...
 
StatusCode mergeInputTuples ()
 Merge all N-tuple entries. More...
 
- Public Member Functions inherited from Algorithm
 Algorithm (const std::string &name, ISvcLocator *svcloc, const std::string &version=PACKAGE_VERSION)
 Constructor. More...
 
StatusCode sysStart () override
 Reinitialization method invoked by the framework. More...
 
StatusCode sysInitialize () override
 Initialization method invoked by the framework. More...
 
StatusCode sysReinitialize () override
 Reinitialization method invoked by the framework. More...
 
StatusCode sysRestart () override
 Restart method invoked by the framework. More...
 
StatusCode sysExecute (const EventContext &ctx) override
 The actions to be performed by the algorithm on an event. More...
 
StatusCode sysStop () override
 System stop. More...
 
StatusCode sysFinalize () override
 System finalization. More...
 
StatusCode sysBeginRun () override
 beginRun method invoked by the framework. More...
 
StatusCode sysEndRun () override
 endRun method invoked by the framework. More...
 
const std::stringname () const override
 The identifying name of the algorithm object. More...
 
const Gaudi::StringKeynameKey () const override
 
const std::stringtype () const override
 The type of the algorithm object. More...
 
void setType (const std::string &type) override
 
const std::stringversion () const override
 
unsigned int index () const override
 
StatusCode configure () override
 Dummy implementation of IStateful::configure() method. More...
 
StatusCode terminate () override
 Dummy implementation of IStateful::terminate() method. More...
 
StatusCode initialize () override
 the default (empty) implementation of IStateful::initialize() method More...
 
StatusCode start () override
 the default (empty) implementation of IStateful::start() method More...
 
StatusCode stop () override
 the default (empty) implementation of IStateful::stop() method More...
 
StatusCode finalize () override
 the default (empty) implementation of IStateful::finalize() method More...
 
StatusCode reinitialize () override
 the default (empty) implementation of IStateful::reinitialize() method More...
 
StatusCode restart () override
 the default (empty) implementation of IStateful::restart() method More...
 
Gaudi::StateMachine::State FSMState () const override
 returns the current state of the algorithm More...
 
Gaudi::StateMachine::State targetFSMState () const override
 returns the state the algorithm will be in after the ongoing transition More...
 
bool isExecuted () const override
 Has this algorithm been executed since the last reset? More...
 
void setExecuted (bool state) const override
 Set the executed flag to the specified state. More...
 
void resetExecuted () override
 Reset the executed state of the Algorithm for the duration of the current event. More...
 
StatusCode beginRun () override
 Algorithm begin run. More...
 
StatusCode endRun () override
 Algorithm end run. This method is called at the end of the event loop. More...
 
bool isEnabled () const override
 Is this algorithm enabled or disabled? More...
 
bool isSequence () const override
 Are we a Sequence? More...
 
bool filterPassed () const override
 Did this algorithm pass or fail its filter criterion for the last event? More...
 
void setFilterPassed (bool state) const override
 Set the filter passed flag to the specified state. More...
 
unsigned int errorCount () const
 Get the number of failures of the algorithm. More...
 
template<class T >
StatusCode service (const std::string &name, T *&psvc, bool createIf=true) const
 Access a service by name, creating it if it doesn't already exist. More...
 
template<class T >
StatusCode service (const std::string &svcType, const std::string &svcName, T *&psvc) const
 Access a service by name and type, creating it if it doesn't already exist. More...
 
SmartIF< IServiceservice (const std::string &name, const bool createIf=true, const bool quiet=false) const
 Return a pointer to the service identified by name (or "type/name") More...
 
template<class T >
SmartIF< T > service (const std::string &name, bool createIf=true, bool quiet=false) const
 
SmartIF< IAuditorSvc > & auditorSvc () const
 The standard auditor service.May not be invoked before sysInitialize() has been invoked. More...
 
SmartIF< IChronoStatSvc > & chronoSvc () const
 The standard Chrono & Stat service, Return a pointer to the service if present. More...
 
SmartIF< IChronoStatSvc > & chronoStatService () const
 
SmartIF< IDataProviderSvc > & detSvc () const
 The standard detector data service. More...
 
SmartIF< IDataProviderSvc > & detDataService () const
 
SmartIF< IConversionSvc > & detCnvSvc () const
 The standard detector data persistency conversion service. More...
 
SmartIF< IConversionSvc > & detDataCnvService () const
 
SmartIF< IDataProviderSvc > & eventSvc () const
 The standard event data service. More...
 
SmartIF< IDataProviderSvc > & evtSvc () const
 shortcut for method eventSvc More...
 
SmartIF< IDataProviderSvc > & eventDataService () const
 
SmartIF< IConversionSvc > & eventCnvSvc () const
 The standard event data persistency conversion service. More...
 
SmartIF< IConversionSvc > & eventDataCnvService () const
 
SmartIF< IHistogramSvc > & histoSvc () const
 The standard histogram service. More...
 
SmartIF< IHistogramSvc > & histogramDataService () const
 
SmartIF< INTupleSvc > & ntupleSvc () const
 The standard N tuple service. More...
 
SmartIF< INTupleSvc > & ntupleService () const
 
SmartIF< IRndmGenSvc > & randSvc () const
 The standard RandomGen service, Return a pointer to the service if present. More...
 
SmartIF< IToolSvc > & toolSvc () const
 The standard ToolSvc service, Return a pointer to the service if present. More...
 
SmartIF< IExceptionSvc > & exceptionSvc () const
 Get the exception Service. More...
 
SmartIF< IAlgContextSvc > & contextSvc () const
 get Algorithm Context Service More...
 
SmartIF< ITimelineSvc > & timelineSvc () const
 
SmartIF< ISvcLocator > & serviceLocator () const override
 The standard service locator. More...
 
SmartIF< ISvcLocator > & svcLoc () const
 shortcut for method serviceLocator More...
 
SmartIF< IHiveWhiteBoard > & whiteboard () const
 
SmartIF< IAlgExecStateSvc > & algExecStateSvc () const
 
bool registerContext () const
 register for Algorithm Context Service? More...
 
StatusCode createSubAlgorithm (const std::string &type, const std::string &name, Algorithm *&pSubAlg)
 Create a sub algorithm. More...
 
const std::vector< Algorithm * > * subAlgorithms () const
 List of sub-algorithms. Returns a pointer to a vector of (sub) Algorithms. More...
 
std::vector< Algorithm * > * subAlgorithms ()
 List of sub-algorithms. Returns a pointer to a vector of (sub) Algorithms. More...
 
StatusCode setProperties ()
 Set the algorithm's properties. More...
 
template<class T >
Gaudi::Details::PropertyBasedeclareProperty (const std::string &name, ToolHandle< T > &hndl, const std::string &doc="none")
 
template<class T >
Gaudi::Details::PropertyBasedeclareProperty (const std::string &name, ToolHandleArray< T > &hndlArr, const std::string &doc="none")
 
SmartIF< IMonitorSvc > & monitorSvc () const
 Access the monitor service. More...
 
template<class T >
void declareInfo (const std::string &name, const T &var, const std::string &desc) const
 Declare monitoring information. More...
 
void declareInfo (const std::string &name, const std::string &format, const void *var, int size, const std::string &desc) const
 Declare monitoring information (special case) More...
 
const EventContextgetContext () const override
 get the context More...
 
void acceptDHVisitor (IDataHandleVisitor *) const override
 
void registerTool (IAlgTool *tool) const
 
void deregisterTool (IAlgTool *tool) const
 
template<class T >
StatusCode declareTool (ToolHandle< T > &handle, bool createIf=true)
 
template<class T >
StatusCode declareTool (ToolHandle< T > &handle, std::string toolTypeAndName, bool createIf=true)
 
template<class T >
void addToolsArray (ToolHandleArray< T > &hndlArr)
 
const std::vector< IAlgTool * > & tools () const
 
bool isIOBound () const
 
void setIOBound (bool value)
 
unsigned int cardinality () const override
 Return the cardinality. More...
 
const std::vector< std::string > & neededResources () const override
 
std::ostreamtoControlFlowExpression (std::ostream &os) const override
 Produce string represention of the control flow expression. More...
 
- Public Member Functions inherited from DataHandleHolderBase< PropertyHolder< CommonMessaging< implements< IAlgorithm, IDataHandleHolder, IProperty, IStateful > > > >
std::vector< Gaudi::DataHandle * > inputHandles () const override
 
std::vector< Gaudi::DataHandle * > outputHandles () const override
 
virtual const DataObjIDCollextraInputDeps () const override
 
virtual const DataObjIDCollextraOutputDeps () const override
 
void declare (Gaudi::DataHandle &handle) override
 
void renounce (Gaudi::DataHandle &handle) override
 
const DataObjIDCollinputDataObjs () const override
 
const DataObjIDColloutputDataObjs () const override
 
void addDependency (const DataObjID &id, const Gaudi::DataHandle::Mode &mode) override
 
- Public Member Functions inherited from extends< PropertyHolder< CommonMessaging< implements< IAlgorithm, IDataHandleHolder, IProperty, IStateful > > >, IDataHandleHolder >
void * i_cast (const InterfaceID &tid) const override
 Implementation of IInterface::i_cast. More...
 
StatusCode queryInterface (const InterfaceID &ti, void **pp) override
 Implementation of IInterface::queryInterface. More...
 
std::vector< std::stringgetInterfaceNames () const override
 Implementation of IInterface::getInterfaceNames. More...
 
- Public Member Functions inherited from PropertyHolder< CommonMessaging< implements< IAlgorithm, IDataHandleHolder, IProperty, IStateful > > >
 PropertyHolder ()=default
 
Gaudi::Details::PropertyBasedeclareProperty (Gaudi::Details::PropertyBase &prop)
 Declare a property. More...
 
Gaudi::Details::PropertyBasedeclareProperty (const std::string &name, TYPE &value, const std::string &doc="none")
 Helper to wrap a regular data member and use it as a regular property. More...
 
Gaudi::Details::PropertyBasedeclareProperty (const std::string &name, Gaudi::Property< TYPE, VERIFIER, HANDLERS > &prop, const std::string &doc="none")
 Declare a PropertyBase instance setting name and documentation. More...
 
Gaudi::Details::PropertyBasedeclareRemoteProperty (const std::string &name, IProperty *rsvc, const std::string &rname="")
 Declare a remote property. More...
 
StatusCode setProperty (const Gaudi::Details::PropertyBase &p) override
 set the property form another property More...
 
StatusCode setProperty (const std::string &s) override
 set the property from the formatted string More...
 
StatusCode setProperty (const std::string &n, const std::string &v) override
 set the property from name and the value More...
 
StatusCode setProperty (const std::string &name, const TYPE &value)
 set the property form the value More...
 
StatusCode getProperty (Gaudi::Details::PropertyBase *p) const override
 get the property More...
 
const Gaudi::Details::PropertyBasegetProperty (const std::string &name) const override
 get the property by name More...
 
StatusCode getProperty (const std::string &n, std::string &v) const override
 convert the property to the string More...
 
const std::vector< Gaudi::Details::PropertyBase * > & getProperties () const override
 get all properties More...
 
bool hasProperty (const std::string &name) const override
 Return true if we have a property with the given name. More...
 
 PropertyHolder (const PropertyHolder &)=delete
 
PropertyHolderoperator= (const PropertyHolder &)=delete
 
- Public Member Functions inherited from CommonMessaging< implements< IAlgorithm, IDataHandleHolder, IProperty, IStateful > >
MSG::Level msgLevel () const
 get the cached level (originally extracted from the embedded MsgStream) More...
 
bool msgLevel (MSG::Level lvl) const
 get the output level from the embedded MsgStream More...
 
MSG::Level outputLevel () const
 Backward compatibility function for getting the output level. More...
 
- Public Member Functions inherited from CommonMessagingBase
virtual ~CommonMessagingBase ()=default
 Virtual destructor. More...
 
const SmartIF< IMessageSvc > & msgSvc () const
 The standard message service. More...
 
MsgStreammsgStream () const
 Return an uninitialized MsgStream. More...
 
MsgStreammsgStream (const MSG::Level level) const
 Predefined configurable message stream for the efficient printouts. More...
 
MsgStreamalways () const
 shortcut for the method msgStream(MSG::ALWAYS) More...
 
MsgStreamfatal () const
 shortcut for the method msgStream(MSG::FATAL) More...
 
MsgStreamerr () const
 shortcut for the method msgStream(MSG::ERROR) More...
 
MsgStreamerror () const
 shortcut for the method msgStream(MSG::ERROR) More...
 
MsgStreamwarning () const
 shortcut for the method msgStream(MSG::WARNING) More...
 
MsgStreaminfo () const
 shortcut for the method msgStream(MSG::INFO) More...
 
MsgStreamdebug () const
 shortcut for the method msgStream(MSG::DEBUG) More...
 
MsgStreamverbose () const
 shortcut for the method msgStream(MSG::VERBOSE) More...
 
MsgStreammsg () const
 shortcut for the method msgStream(MSG::INFO) More...
 

Private Attributes

Gaudi::Property< std::stringm_tupleSvc {this, "EvtTupleSvc", "EvtTupleSvc", "name of the data provider service"}
 
Gaudi::Property< std::vector< std::string > > m_inputs {this, "Input", {}, "input specifications"}
 
Gaudi::Property< std::stringm_output {this, "Output", {}, "output specification"}
 
SmartIF< INTupleSvcm_dataSvc
 Reference to data provider service. More...
 
std::string m_rootName
 Name of the root leaf (obtained at initialize) More...
 
std::string m_outName
 Output tuple name. More...
 
std::string m_criteria
 Selection criteria (if any) More...
 
std::string m_selectorName
 Selector factory. More...
 

Additional Inherited Members

- Public Types inherited from Algorithm
using Factory = Gaudi::PluginService::Factory< IAlgorithm *(const std::string &, ISvcLocator *)>
 
- Public Types inherited from extends< PropertyHolder< CommonMessaging< implements< IAlgorithm, IDataHandleHolder, IProperty, IStateful > > >, IDataHandleHolder >
using base_class = extends
 Typedef to this class. More...
 
using extend_interfaces_base = extend_interfaces< Interfaces... >
 Typedef to the base of this class. More...
 
- Public Types inherited from PropertyHolder< CommonMessaging< implements< IAlgorithm, IDataHandleHolder, IProperty, IStateful > > >
using PropertyHolderImpl = PropertyHolder< CommonMessaging< implements< IAlgorithm, IDataHandleHolder, IProperty, IStateful > > >
 Typedef used to refer to this class from derived classes, as in. More...
 
- Public Types inherited from CommonMessaging< implements< IAlgorithm, IDataHandleHolder, IProperty, IStateful > >
using base_class = CommonMessaging
 
- Public Types inherited from extend_interfaces< Interfaces... >
using ext_iids = typename Gaudi::interface_list_cat< typename Interfaces::ext_iids... >::type
 take union of the ext_iids of all Interfaces... More...
 
- Public Attributes inherited from Algorithm
friend AlgorithmManager
 
- Protected Member Functions inherited from Algorithm
std::vector< IAlgTool * > & tools ()
 
bool isInitialized () const override
 Has the Algorithm already been initialized? More...
 
bool isFinalized () const override
 Has the Algorithm already been finalized? More...
 
void setIndex (const unsigned int &idx) override
 set instantiation index of Alg More...
 
AlgExecStateexecState (const EventContext &ctx) const
 reference to AlgExecState of Alg More...
 
- Protected Member Functions inherited from DataHandleHolderBase< PropertyHolder< CommonMessaging< implements< IAlgorithm, IDataHandleHolder, IProperty, IStateful > > > >
void initDataHandleHolder ()
 initializes all handles - called by the sysInitialize method of any descendant of this More...
 
- Protected Member Functions inherited from PropertyHolder< CommonMessaging< implements< IAlgorithm, IDataHandleHolder, IProperty, IStateful > > >
Gaudi::Details::PropertyBaseproperty (const std::string &name) const
 
- Protected Member Functions inherited from CommonMessaging< implements< IAlgorithm, IDataHandleHolder, IProperty, IStateful > >
MSG::Level setUpMessaging () const
 Set up local caches. More...
 
MSG::Level resetMessaging ()
 Reinitialize internal states. More...
 
void updateMsgStreamOutputLevel (int level)
 Update the output level of the cached MsgStream. More...
 
- Protected Attributes inherited from Algorithm
std::unique_ptr< IDataHandleVisitorm_updateDataHandles
 Hook for for derived classes to provide a custom visitor for data handles. More...
 
- Protected Attributes inherited from DataHandleHolderBase< PropertyHolder< CommonMessaging< implements< IAlgorithm, IDataHandleHolder, IProperty, IStateful > > > >
DataObjIDColl m_inputDataObjs
 
DataObjIDColl m_outputDataObjs
 

Detailed Description

Small algorithm, which allows to merge N-tuples in a generic way.

In the options directory an python interface is presented, which shows how to steer this algorithm in a standaqlone program.

Author
: M.Frank
Version
: 1.0

Definition at line 109 of file CollectionCloneAlg.cpp.

Member Function Documentation

virtual StatusCode CollectionCloneAlg::book ( const NTuple::Tuple nt)
inlinevirtual

Book the N-tuple according to the specification.

Definition at line 187 of file CollectionCloneAlg.cpp.

188  {
189  MsgStream log( msgSvc(), name() );
191  NTuple::Tuple* tuple = m_dataSvc->book( m_outName, nt->clID(), nt->title() );
192  for ( const auto& i : nt->items() ) {
193  switch ( i->type() ) {
194  case DataTypeInfo::UCHAR:
195  status = createItem<unsigned char>( log, tuple, i, 0 );
196  break;
198  status = createItem<unsigned short>( log, tuple, i, 0 );
199  break;
200  case DataTypeInfo::UINT:
201  status = createItem<unsigned int>( log, tuple, i, 0 );
202  break;
203  case DataTypeInfo::ULONG:
204  status = createItem<unsigned long>( log, tuple, i, 0 );
205  break;
206  case DataTypeInfo::CHAR:
207  status = createItem<char>( log, tuple, i, 0 );
208  break;
209  case DataTypeInfo::SHORT:
210  status = createItem<short>( log, tuple, i, 0 );
211  break;
212  case DataTypeInfo::INT:
213  status = createItem<int>( log, tuple, i, 0 );
214  break;
215  case DataTypeInfo::LONG:
216  status = createItem<long>( log, tuple, i, 0 );
217  break;
218  case DataTypeInfo::BOOL:
219  status = createItem( log, tuple, i, false );
220  break;
221  case DataTypeInfo::FLOAT:
222  status = createItem<float>( log, tuple, i, 0 );
223  break;
225  status = createItem<double>( log, tuple, i, 0 );
226  break;
228  status = createItem<IOpaqueAddress*>( log, tuple, i, nullptr );
229  break;
231  status = createItem<void*>( log, tuple, i, nullptr );
232  break;
234  // status = createItem(log, tuple, i, (std::string*)0);
235  // break;
237  // status = createItem(log, tuple, i, (char*)0);
238  // break;
240  default:
241  status = StatusCode::FAILURE;
242  break;
243  }
244  }
245  return status;
246  }
constexpr static const auto FAILURE
Definition: StatusCode.h:88
Definition of the MsgStream class used to transmit messages.
Definition: MsgStream.h:24
const std::string & name() const override
The identifying name of the algorithm object.
Definition: Algorithm.cpp:765
SmartIF< INTupleSvc > m_dataSvc
Reference to data provider service.
virtual const CLID & clID() const
Retrieve reference to class definition structure.
Definition: DataObject.cpp:62
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:51
std::string m_outName
Output tuple name.
const SmartIF< IMessageSvc > & msgSvc() const
The standard message service.
constexpr static const auto SUCCESS
Definition: StatusCode.h:87
Abstract base class which allows the user to interact with the actual N tuple implementation.
Definition: NTuple.h:407
virtual ItemContainer & items()=0
Access item container.
virtual const std::string & title() const =0
Object title.
virtual NTuple::Tuple * book(const std::string &fullPath, const CLID &type, const std::string &title)=0
Book Ntuple and register it with the data store.
virtual StatusCode CollectionCloneAlg::checkInput ( const NTuple::Tuple clone,
const NTuple::Tuple src 
)
inlinevirtual

Definition at line 249 of file CollectionCloneAlg.cpp.

250  {
251  MsgStream log( msgSvc(), name() );
252  if ( clone && src ) {
253  const INTuple::ItemContainer& clone_items = clone->items();
254  const std::string clone_id = clone->registry()->identifier();
255  const std::string src_id = src->registry()->identifier();
256 
257  log << MSG::ERROR;
258  for ( auto i = clone_items.begin(); i != clone_items.end(); ++i ) {
259  const INTupleItem* itm = *i;
260  const std::string& nam = itm->name();
261  const INTupleItem* src_itm = src->find( nam );
262  if ( !src_itm ) {
263  log << "Tuple item " << nam << " not present in " << src_id << endmsg;
264  return StatusCode::FAILURE;
265  }
266  if ( itm->type() != src_itm->type() ) {
267  log << "Tuple item " << nam << " are of different types in " << src_id << ":" << src_itm->typeName()
268  << " <-> " << clone_id << ":" << itm->typeName() << endmsg;
269  return StatusCode::FAILURE;
270  }
271  if ( itm->ndim() != src_itm->ndim() ) {
272  log << "Tuple item " << nam << " have different dimensions in " << src_id << ":" << src_itm->ndim() << " <-> "
273  << clone_id << ":" << itm->ndim() << endmsg;
274  return StatusCode::FAILURE;
275  }
276  for ( int j = 0; j < itm->ndim(); ++j ) {
277  if ( src_itm->dim( j ) != itm->dim( j ) ) {
278  log << "Tuple item " << nam << " have different dimensions in " << src_id << "[" << j
279  << "]:" << src_itm->dim( j ) << " <-> " << clone_id << "[" << j << "]:" << itm->dim( j ) << endmsg;
280  return StatusCode::FAILURE;
281  }
282  }
283  if ( itm->hasIndex() != src_itm->hasIndex() ) {
284  log << "Tuple item " << nam << " has different index colums " << src_id << ":" << src_itm->hasIndex()
285  << " <-> " << clone_id << ":" << itm->hasIndex() << endmsg;
286  return StatusCode::FAILURE;
287  }
288  if ( itm->hasIndex() ) {
289  if ( itm->index() != src_itm->index() ) {
290  log << "Tuple item " << nam << " has different index colums " << src_id << ":" << src_itm->index()
291  << " <-> " << clone_id << ":" << itm->index() << endmsg;
292  return StatusCode::FAILURE;
293  }
294  }
295  }
296  return StatusCode::SUCCESS;
297  }
298  return StatusCode::FAILURE;
299  }
virtual const std::string & name() const =0
Access _Item name.
constexpr static const auto FAILURE
Definition: StatusCode.h:88
Definition of the MsgStream class used to transmit messages.
Definition: MsgStream.h:24
const std::string & name() const override
The identifying name of the algorithm object.
Definition: Algorithm.cpp:765
T end(T...args)
IRegistry * registry() const
Get pointer to Registry.
Definition: DataObject.h:73
STL class.
virtual std::string typeName() const =0
Proper type name of the object.
virtual long ndim() const =0
Dimension.
NTuple interface class definition.
Definition: INTuple.h:27
virtual const id_type & identifier() const =0
Full identifier (or key)
const SmartIF< IMessageSvc > & msgSvc() const
The standard message service.
virtual long type() const =0
Type information of the item.
constexpr static const auto SUCCESS
Definition: StatusCode.h:87
STL class.
T begin(T...args)
virtual const std::string & index() const =0
Access the index _Item.
virtual long dim(long i) const =0
Access individual dimensions.
virtual ItemContainer & items()=0
Access item container.
virtual bool hasIndex() const =0
Is the tuple have an index item?
virtual const INTupleItem * find(const std::string &name) const =0
Find an item row of the Ntuple (CONST)
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:209
StatusCode CollectionCloneAlg::connect ( )
inline

Connect input and output N-tuples.

Definition at line 408 of file CollectionCloneAlg.cpp.

409  {
411  for ( size_t i = 0; i < m_inputs.size(); ++i ) {
412  NTuplePtr nt( m_dataSvc.get(), m_inputs[i] );
413  if ( !( 0 == nt ) ) {
414  NTuplePtr out( m_dataSvc.get(), m_outName );
415  if ( 0 == out ) {
416  status = book( nt );
417  } else {
418  status = checkInput( out, nt );
419  }
420  if ( !status.isSuccess() ) {
421  return status;
422  } else if ( m_selectorName != "" ) {
423  SmartIF<ISelectStatement> stmt( ObjFactory::create( m_selectorName, serviceLocator() ).release() );
424  if ( stmt ) {
425  if ( !m_criteria.empty() ) stmt->setCriteria( m_criteria );
426  nt->attachSelector( stmt );
427  } else {
428  MsgStream log( msgSvc(), name() );
429  log << MSG::ERROR << "Failed to attach tuple selector to " << m_inputs[i] << endmsg;
430  return StatusCode::FAILURE;
431  }
432  }
433  } else {
434  MsgStream log( msgSvc(), name() );
435  log << MSG::ERROR << "Failed to access tuple: " << m_inputs[i] << endmsg;
436  return StatusCode::FAILURE;
437  }
438  }
439  return StatusCode::SUCCESS;
440  }
constexpr static const auto FAILURE
Definition: StatusCode.h:88
std::string m_criteria
Selection criteria (if any)
Definition of the MsgStream class used to transmit messages.
Definition: MsgStream.h:24
T empty(T...args)
const std::string & name() const override
The identifying name of the algorithm object.
Definition: Algorithm.cpp:765
virtual StatusCode book(const NTuple::Tuple *nt)
Book the N-tuple according to the specification.
bool isSuccess() const
Definition: StatusCode.h:287
Gaudi::Property< std::vector< std::string > > m_inputs
SmartIF< INTupleSvc > m_dataSvc
Reference to data provider service.
TYPE * get() const
Get interface pointer.
Definition: SmartIF.h:82
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:51
std::string m_outName
Output tuple name.
const SmartIF< IMessageSvc > & msgSvc() const
The standard message service.
virtual StatusCode checkInput(const NTuple::Tuple *clone, const NTuple::Tuple *src)
SmartIF< ISvcLocator > & serviceLocator() const override
The standard service locator.
Definition: Algorithm.cpp:834
constexpr static const auto SUCCESS
Definition: StatusCode.h:87
A small class used to access easily (and efficiently) data items residing in data stores...
Definition: SmartDataPtr.h:47
std::string m_selectorName
Selector factory.
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:209
StatusCode CollectionCloneAlg::execute ( )
inlineoverride

Execute procedure.

Definition at line 180 of file CollectionCloneAlg.cpp.

181  {
182  StatusCode status = connect();
183  return status.isSuccess() ? mergeInputTuples() : status;
184  }
bool isSuccess() const
Definition: StatusCode.h:287
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:51
StatusCode mergeInputTuples()
Merge all N-tuple entries.
StatusCode connect()
Connect input and output N-tuples.
StatusCode CollectionCloneAlg::finalize ( )
inlineoverride

Finalize.

Definition at line 173 of file CollectionCloneAlg.cpp.

174  {
175  m_dataSvc.reset();
176  return StatusCode::SUCCESS;
177  }
SmartIF< INTupleSvc > m_dataSvc
Reference to data provider service.
constexpr static const auto SUCCESS
Definition: StatusCode.h:87
void reset(TYPE *ptr=nullptr)
Set the internal pointer to the passed one disposing of the old one.
Definition: SmartIF.h:92
StatusCode CollectionCloneAlg::initialize ( )
inlineoverride

Initialize.

Definition at line 132 of file CollectionCloneAlg.cpp.

133  {
134  MsgStream log( msgSvc(), name() );
135  m_rootName = "";
136  m_outName = "";
137  m_criteria = "";
138  m_selectorName = "";
139  m_dataSvc = service( m_tupleSvc, true );
140  if ( !m_dataSvc ) {
141  log << MSG::ERROR << "Failed to access service \"" << m_tupleSvc << "\"." << endmsg;
142  return StatusCode::FAILURE;
143  }
145  using Parser = Gaudi::Utils::AttribStringParser;
146  for ( auto attrib : Parser( m_output ) ) {
147  switch (::toupper( attrib.tag[0] ) ) {
148  case 'D':
149  m_outName = std::move( attrib.value );
150  break;
151  case 'S':
152  m_criteria = std::move( attrib.value );
153  break;
154  case 'F':
155  fun = std::move( attrib.value );
156  break;
157  default:
158  break;
159  }
160  }
161  if ( m_outName.empty() ) {
162  log << MSG::ERROR << "Failed to analyze output specs:" << m_output << endmsg;
163  return StatusCode::FAILURE;
164  }
165  if ( !fun.empty() || !m_criteria.empty() ) {
166  if ( !m_criteria.empty() && fun.empty() ) fun = "NTuple::Selector";
168  }
169  return StatusCode::SUCCESS;
170  }
Parse attribute strings allowing iteration over the various attributes.
constexpr static const auto FAILURE
Definition: StatusCode.h:88
std::string m_criteria
Selection criteria (if any)
Definition of the MsgStream class used to transmit messages.
Definition: MsgStream.h:24
T empty(T...args)
const std::string & name() const override
The identifying name of the algorithm object.
Definition: Algorithm.cpp:765
SmartIF< INTupleSvc > m_dataSvc
Reference to data provider service.
STL class.
std::string m_outName
Output tuple name.
const SmartIF< IMessageSvc > & msgSvc() const
The standard message service.
T move(T...args)
std::string m_rootName
Name of the root leaf (obtained at initialize)
constexpr static const auto SUCCESS
Definition: StatusCode.h:87
double fun(const std::vector< double > &x)
Definition: PFuncTest.cpp:26
Gaudi::Property< std::string > m_output
Gaudi::Property< std::string > m_tupleSvc
StatusCode service(const std::string &name, T *&psvc, bool createIf=true) const
Access a service by name, creating it if it doesn&#39;t already exist.
Definition: Algorithm.h:231
std::string m_selectorName
Selector factory.
void toupper(std::string &s)
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:209
StatusCode CollectionCloneAlg::mergeEntries ( const std::string input)
inline

Merge the entries of a single input tuple into the output.

Definition at line 302 of file CollectionCloneAlg.cpp.

303  {
304  MsgStream log( msgSvc(), name() );
305  NTuplePtr out( m_dataSvc.get(), m_outName );
306  if ( 0 != out ) {
307  const INTuple::ItemContainer& clone_items = out->items();
308  std::vector<GenericAddress> addrVector( clone_items.size() );
310  NTuplePtr nt( m_dataSvc.get(), input );
311  size_t k = 0, nentry = 0;
312  if ( 0 != nt ) {
313  const INTuple::ItemContainer& source_items = nt->items();
314  for ( k = 0; k < source_items.size(); ++k ) {
315  if ( source_items[k]->type() == DataTypeInfo::OBJECT_ADDR ) {
316  *(IOpaqueAddress**)source_items[k]->buffer() = &addrVector[k];
317  }
318  }
319  while ( status.isSuccess() ) {
320  status = m_dataSvc->readRecord( nt.ptr() );
321  if ( status.isSuccess() ) {
322  INTuple::ItemContainer::const_iterator i;
323  nentry++;
324  for ( k = 0, i = source_items.begin(); i != source_items.end(); ++i, ++k ) {
325  const INTupleItem* src_itm = *i;
326  const INTupleItem* out_itm = out->find( src_itm->name() );
327  size_t size = 0;
328  switch ( ( *i )->type() ) {
329  case DataTypeInfo::UCHAR:
330  size = sizeof( unsigned char );
331  break;
333  size = sizeof( unsigned short );
334  break;
335  case DataTypeInfo::UINT:
336  size = sizeof( unsigned int );
337  break;
338  case DataTypeInfo::ULONG:
339  size = sizeof( unsigned long );
340  break;
341  case DataTypeInfo::CHAR:
342  size = sizeof( char );
343  break;
344  case DataTypeInfo::SHORT:
345  size = sizeof( short );
346  break;
347  case DataTypeInfo::INT:
348  size = sizeof( int );
349  break;
350  case DataTypeInfo::LONG:
351  size = sizeof( long );
352  break;
353  case DataTypeInfo::BOOL:
354  size = sizeof( bool );
355  break;
356  case DataTypeInfo::FLOAT:
357  size = sizeof( float );
358  break;
360  size = sizeof( double );
361  break;
363  *(std::string*)out_itm->buffer() = *(std::string*)src_itm->buffer();
364  size = 0;
365  break;
367  size = ::strlen( (const char*)src_itm->buffer() ) + 1;
368  break;
369  case DataTypeInfo::POINTER: {
370  *(void**)out_itm->buffer() = *(void**)src_itm->buffer();
371  size = 0;
372  } break;
374  IOpaqueAddress* ppA1 = &addrVector[k];
375  IOpaqueAddress** ppA2 = (IOpaqueAddress**)( out_itm->buffer() );
376  *ppA2 = ppA1;
377  size = 0;
378  } break;
380  default:
381  size = 0;
382  break;
383  }
384  if ( size > 0 ) {
385  ::memcpy( const_cast<void*>( out_itm->buffer() ), src_itm->buffer(), size * src_itm->length() );
386  }
387  }
388  status = m_dataSvc->writeRecord( out.ptr() );
389  if ( !status.isSuccess() ) {
390  log << MSG::ERROR << "Failed to write record " << nentry << " from " << input << " to " << m_outName
391  << endmsg;
392  }
393  }
394  }
395  log << MSG::INFO << "End of reading tuple " << input << " after " << nentry << " entries." << endmsg;
396 
397  if ( nentry > 0 || m_selectorName != "" ) {
398  return StatusCode::SUCCESS;
399  }
400  return StatusCode::FAILURE;
401  }
402  log << MSG::ERROR << "Failed to access input: " << input << endmsg;
403  }
404  return StatusCode::FAILURE;
405  }
virtual const std::string & name() const =0
Access _Item name.
constexpr static const auto FAILURE
Definition: StatusCode.h:88
Definition of the MsgStream class used to transmit messages.
Definition: MsgStream.h:24
const std::string & name() const override
The identifying name of the algorithm object.
Definition: Algorithm.cpp:765
T end(T...args)
constexpr auto size(const C &c) noexcept(noexcept(c.size())) -> decltype(c.size())
SmartIF< INTupleSvc > m_dataSvc
Reference to data provider service.
STL class.
TYPE * get() const
Get interface pointer.
Definition: SmartIF.h:82
NTuple interface class definition.
Definition: INTuple.h:27
virtual long length() const =0
Access the buffer length.
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:51
virtual StatusCode writeRecord(NTuple::Tuple *tuple)=0
Write single record to N tuple.
std::string m_outName
Output tuple name.
const SmartIF< IMessageSvc > & msgSvc() const
The standard message service.
constexpr static const auto SUCCESS
Definition: StatusCode.h:87
virtual const void * buffer() const =0
Access data buffer (CONST)
T size(T...args)
STL class.
T begin(T...args)
virtual StatusCode readRecord(NTuple::Tuple *tuple)=0
Read single record from N tuple.
A small class used to access easily (and efficiently) data items residing in data stores...
Definition: SmartDataPtr.h:47
Opaque address interface definition.
const std::string & type() const override
The type of the algorithm object.
Definition: Algorithm.h:166
std::string m_selectorName
Selector factory.
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:209
StatusCode CollectionCloneAlg::mergeInputTuples ( )
inline

Merge all N-tuple entries.

Definition at line 443 of file CollectionCloneAlg.cpp.

444  {
445  MsgStream log( msgSvc(), name() );
446  for ( const auto& input : m_inputs ) {
447  StatusCode sc = mergeEntries( input );
448  if ( !sc.isSuccess() ) {
449  log << MSG::ERROR << "Failed to merge tuple:" << input << endmsg;
450  return sc;
451  }
452  }
453  return StatusCode::SUCCESS;
454  }
Definition of the MsgStream class used to transmit messages.
Definition: MsgStream.h:24
const std::string & name() const override
The identifying name of the algorithm object.
Definition: Algorithm.cpp:765
bool isSuccess() const
Definition: StatusCode.h:287
Gaudi::Property< std::vector< std::string > > m_inputs
StatusCode mergeEntries(const std::string &input)
Merge the entries of a single input tuple into the output.
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:51
const SmartIF< IMessageSvc > & msgSvc() const
The standard message service.
constexpr static const auto SUCCESS
Definition: StatusCode.h:87
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:209

Member Data Documentation

std::string CollectionCloneAlg::m_criteria
private

Selection criteria (if any)

Definition at line 123 of file CollectionCloneAlg.cpp.

SmartIF<INTupleSvc> CollectionCloneAlg::m_dataSvc
private

Reference to data provider service.

Definition at line 117 of file CollectionCloneAlg.cpp.

Gaudi::Property<std::vector<std::string> > CollectionCloneAlg::m_inputs {this, "Input", {}, "input specifications"}
private

Definition at line 113 of file CollectionCloneAlg.cpp.

std::string CollectionCloneAlg::m_outName
private

Output tuple name.

Definition at line 121 of file CollectionCloneAlg.cpp.

Gaudi::Property<std::string> CollectionCloneAlg::m_output {this, "Output", {}, "output specification"}
private

Definition at line 114 of file CollectionCloneAlg.cpp.

std::string CollectionCloneAlg::m_rootName
private

Name of the root leaf (obtained at initialize)

Definition at line 119 of file CollectionCloneAlg.cpp.

std::string CollectionCloneAlg::m_selectorName
private

Selector factory.

Definition at line 125 of file CollectionCloneAlg.cpp.

Gaudi::Property<std::string> CollectionCloneAlg::m_tupleSvc {this, "EvtTupleSvc", "EvtTupleSvc", "name of the data provider service"}
private

Definition at line 112 of file CollectionCloneAlg.cpp.


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