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

 CollectionCloneAlg (const std::string &name, ISvcLocator *pSvcLocator)
 Standard algorithm constructor. More...
 
virtual ~CollectionCloneAlg ()
 Standard Destructor. More...
 
virtual StatusCode initialize ()
 Initialize. More...
 
virtual StatusCode finalize ()
 Finalize. More...
 
virtual StatusCode execute ()
 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...
 
 ~Algorithm () override=default
 Destructor. 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 () 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) 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 filterPassed () const override
 Did this algorithm pass or fail its filter criterion for the last event? More...
 
void setFilterPassed (bool state) override
 Set the filter passed flag to the specified state. More...
 
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
 Obsoleted name, kept due to the backwards compatibility. More...
 
SmartIF< IDataProviderSvc > & detSvc () const
 The standard detector data service. More...
 
SmartIF< IDataProviderSvc > & detDataService () const
 Obsoleted name, kept due to the backwards compatibility. More...
 
SmartIF< IConversionSvc > & detCnvSvc () const
 The standard detector data persistency conversion service. More...
 
SmartIF< IConversionSvc > & detDataCnvService () const
 Obsoleted name, kept due to the backwards compatibility. More...
 
SmartIF< IDataProviderSvc > & eventSvc () const
 The standard event data service. More...
 
SmartIF< IDataProviderSvc > & evtSvc () const
 shortcut for method eventSvc More...
 
SmartIF< IDataProviderSvc > & eventDataService () const
 Obsoleted name, kept due to the backwards compatibility. More...
 
SmartIF< IConversionSvc > & eventCnvSvc () const
 The standard event data persistency conversion service. More...
 
SmartIF< IConversionSvc > & eventDataCnvService () const
 Obsoleted name, kept due to the backwards compatibility. More...
 
SmartIF< IHistogramSvc > & histoSvc () const
 The standard histogram service. More...
 
SmartIF< IHistogramSvc > & histogramDataService () const
 Obsoleted name, kept due to the backwards compatibility. More...
 
SmartIF< INTupleSvc > & ntupleSvc () const
 The standard N tuple service. More...
 
SmartIF< INTupleSvc > & ntupleService () const
 Obsoleted name, kept due to the backwards compatibility. More...
 
SmartIF< IRndmGenSvc > & randSvc () const
 AIDA-based NTuple service Returns a pointer to the AIDATuple 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
 
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 setProperty (const Property &p) override
 Implementation of IProperty::setProperty. More...
 
StatusCode setProperty (const std::string &s) override
 Implementation of IProperty::setProperty. More...
 
StatusCode setProperty (const std::string &n, const std::string &v) override
 Implementation of IProperty::setProperty. More...
 
StatusCode getProperty (Property *p) const override
 Implementation of IProperty::getProperty. More...
 
const PropertygetProperty (const std::string &name) const override
 Implementation of IProperty::getProperty. More...
 
StatusCode getProperty (const std::string &n, std::string &v) const override
 Implementation of IProperty::getProperty. More...
 
const std::vector< Property * > & getProperties () const override
 Implementation of IProperty::getProperties. More...
 
bool hasProperty (const std::string &name) const override
 Implementation of IProperty::hasProperty. More...
 
PropertyMgrgetPropertyMgr ()
 
StatusCode setProperties ()
 Set the algorithm's properties. More...
 
template<class T >
PropertydeclareProperty (const std::string &name, T &property, const std::string &doc="none") const
 Declare the named property. More...
 
PropertydeclareRemoteProperty (const std::string &name, IProperty *rsvc, const std::string &rname="") const
 Declare remote named properties. More...
 
template<class T >
PropertydeclareProperty (const std::string &name, ToolHandle< T > &hndl, const std::string &doc="none") const
 
template<class T >
PropertydeclareProperty (const std::string &name, ToolHandleArray< T > &hndlArr, const std::string &doc="none") const
 
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...
 
template<class TYPE >
StatusCode setProperty (const std::string &name, const TYPE &value)
 set the property form the value More...
 
EventContextgetContext () const
 get the context More...
 
void setContext (EventContext *context)
 set the context More...
 
virtual std::vector< Gaudi::DataHandle * > inputHandles () const override
 
virtual std::vector< Gaudi::DataHandle * > outputHandles () const override
 
virtual const DataObjIDCollextraInputDeps () const override
 
virtual const DataObjIDCollextraOutputDeps () const override
 
virtual void acceptDHVisitor (IDataHandleVisitor *) const override
 
const DataObjIDCollinputDataObjs () const
 
const DataObjIDColloutputDataObjs () const
 
void commitHandles () override
 
void registerTool (IAlgTool *tool) const
 
void deregisterTool (IAlgTool *tool) const
 
template<class T >
StatusCode declareTool (ToolHandle< T > &handle, std::string toolTypeAndName="", bool createIf=true)
 
const std::vector< IAlgTool * > & tools () const
 
bool isClonable () const override
 Specifies the clonability of the algorithm. More...
 
unsigned int cardinality () const override
 Return the cardinality. More...
 
const std::vector< std::string > & neededResources () const override
 
- Public Member Functions inherited from CommonMessagingBase
virtual ~CommonMessagingBase ()=default
 Virtual destructor. More...
 
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...
 
MSG::Level msgLevel () const
 get the output level from the embedded MsgStream More...
 
MSG::Level outputLevel () const __attribute__((deprecated))
 Backward compatibility function for getting the output level. More...
 
bool msgLevel (MSG::Level lvl) const
 get the output level from the embedded MsgStream More...
 

Private Attributes

SmartIF< INTupleSvcm_dataSvc
 Reference to data provider service. More...
 
std::string m_tupleSvc
 Name of the data provider service. More...
 
std::string m_output
 Output specification. More...
 
std::vector< std::stringm_inputs
 input specifications 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
typedef Gaudi::PluginService::Factory< IAlgorithm *, const std::string &, ISvcLocator * > Factory
 
- Public Types inherited from CommonMessaging< implements< IAlgorithm, IDataHandleHolder, IProperty, IStateful > >
using base_class = CommonMessaging
 
- Protected Member Functions inherited from Algorithm
virtual void declareInput (Gaudi::DataHandle *im) override
 
virtual void declareOutput (Gaudi::DataHandle *im) override
 
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...
 
- Protected Member Functions inherited from CommonMessaging< implements< IAlgorithm, IDataHandleHolder, IProperty, IStateful > >
void updateMsgStreamOutputLevel (int level)
 Update the output level of the cached MsgStream. More...
 
- Protected Attributes inherited from Algorithm
EventContextm_event_context
 Event specific data for multiple event processing. More...
 
SmartIF< PropertyMgrm_propertyMgr
 For management of properties. More...
 
std::unique_ptr< IDataHandleVisitorm_updateDataHandles
 Hook for for derived classes to provide a custom visitor for data handles. More...
 

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 126 of file CollectionCloneAlg.cpp.

Constructor & Destructor Documentation

CollectionCloneAlg::CollectionCloneAlg ( const std::string name,
ISvcLocator pSvcLocator 
)
inline

Standard algorithm constructor.

Definition at line 146 of file CollectionCloneAlg.cpp.

147  : Algorithm(name, pSvcLocator)
148  {
149  declareProperty("EvtTupleSvc", m_tupleSvc="EvtTupleSvc");
150  declareProperty("Input", m_inputs);
151  declareProperty("Output", m_output);
152  }
std::string m_tupleSvc
Name of the data provider service.
Property * declareProperty(const std::string &name, T &property, const std::string &doc="none") const
Declare the named property.
Definition: Algorithm.h:426
std::string m_output
Output specification.
std::vector< std::string > m_inputs
input specifications
Algorithm(const std::string &name, ISvcLocator *svcloc, const std::string &version=PACKAGE_VERSION)
Constructor.
Definition: Algorithm.cpp:43
virtual CollectionCloneAlg::~CollectionCloneAlg ( )
inlinevirtual

Standard Destructor.

Definition at line 154 of file CollectionCloneAlg.cpp.

154  {
155  }

Member Function Documentation

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

Book the N-tuple according to the specification.

Definition at line 214 of file CollectionCloneAlg.cpp.

214  {
215  MsgStream log(msgSvc(), name());
216  const INTuple::ItemContainer& items = nt->items();
218  INTuple::ItemContainer::const_iterator i;
219  NTuple::Tuple* tuple = m_dataSvc->book(m_outName, nt->clID(), nt->title());
220  for (i = items.begin(); i != items.end(); ++i) {
221  long type = (*i)->type();
222  switch(type) {
223  case DataTypeInfo::UCHAR:
224  status = createItem(log, tuple, *i, (unsigned char)0);
225  break;
227  status = createItem(log, tuple, *i, (unsigned short)0);
228  break;
229  case DataTypeInfo::UINT:
230  status = createItem(log, tuple, *i, (unsigned int)0);
231  break;
232  case DataTypeInfo::ULONG:
233  status = createItem(log, tuple, *i, (unsigned long)0);
234  break;
235  case DataTypeInfo::CHAR:
236  status = createItem(log, tuple, *i, char(0));
237  break;
238  case DataTypeInfo::SHORT:
239  status = createItem(log, tuple, *i, short(0));
240  break;
241  case DataTypeInfo::INT:
242  status = createItem(log, tuple, *i, int(0));
243  break;
244  case DataTypeInfo::LONG:
245  status = createItem(log, tuple, *i, long(0));
246  break;
247  case DataTypeInfo::BOOL:
248  status = createItem(log, tuple, *i, false);
249  break;
250  case DataTypeInfo::FLOAT:
251  status = createItem(log, tuple, *i, float(0.0));
252  break;
254  status = createItem(log, tuple, *i, double(0.0));
255  break;
257  status = createItem(log, tuple, *i, (IOpaqueAddress*)0);
258  break;
260  status = createItem(log, tuple, *i, (void*)0);
261  break;
263 // status = createItem(log, tuple, *i, (std::string*)0);
264 // break;
266 // status = createItem(log, tuple, *i, (char*)0);
267 // break;
269  default:
270  status = StatusCode::FAILURE;
271  break;
272  }
273  }
274  return status;
275  }
Definition of the MsgStream class used to transmit messages.
Definition: MsgStream.h:24
virtual const std::string & title() const =0
Object title.
T end(T...args)
const std::string & type() const override
The type of the algorithm object.
Definition: Algorithm.h:168
SmartIF< INTupleSvc > m_dataSvc
Reference to data provider service.
const std::string & name() const override
The identifying name of the algorithm object.
Definition: Algorithm.cpp:820
virtual const CLID & clID() const
Retrieve reference to class definition structure.
Definition: DataObject.cpp:68
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
std::string m_outName
Output tuple name.
Abstract base class which allows the user to interact with the actual N tuple implementation.
Definition: NTuple.h:370
STL class.
T begin(T...args)
SmartIF< IMessageSvc > & msgSvc() const
The standard message service.
virtual ItemContainer & items()=0
Access item container.
Opaque address interface definition.
list i
Definition: ana.py:128
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 278 of file CollectionCloneAlg.cpp.

278  {
279  MsgStream log(msgSvc(), name());
280  if ( 0 != clone && 0 != src ) {
281  const INTuple::ItemContainer& clone_items = clone->items();
282  const std::string clone_id = clone->registry()->identifier();
283  const std::string src_id = src->registry()->identifier();
284 
285  INTuple::ItemContainer::const_iterator i;
286  log << MSG::ERROR;
287  for (i = clone_items.begin(); i != clone_items.end(); ++i) {
288  const INTupleItem* itm = *i;
289  const std::string& nam = itm->name();
290  const INTupleItem* src_itm = src->find(nam);
291  if ( !src_itm ) {
292  log << "Tuple item " << nam << " not present in " << src_id << endmsg;
293  return StatusCode::FAILURE;
294  }
295  if ( itm->type() != src_itm->type() ) {
296  log << "Tuple item " << nam << " are of different types in "
297  << src_id << ":" << src_itm->typeName() << " <-> "
298  << clone_id << ":" << itm->typeName() << endmsg;
299  return StatusCode::FAILURE;
300  }
301  if ( itm->ndim() != src_itm->ndim() ) {
302  log << "Tuple item " << nam << " have different dimensions in "
303  << src_id << ":" << src_itm->ndim() << " <-> "
304  << clone_id << ":" << itm->ndim() << endmsg;
305  return StatusCode::FAILURE;
306  }
307  for (int j=0; j<itm->ndim(); ++j) {
308  if ( src_itm->dim(j) != itm->dim(j) ) {
309  log << "Tuple item " << nam << " have different dimensions in "
310  << src_id << "[" << j << "]:" << src_itm->dim(j) << " <-> "
311  << clone_id << "[" << j << "]:" << itm->dim(j) << endmsg;
312  return StatusCode::FAILURE;
313  }
314  }
315  if ( itm->hasIndex() != src_itm->hasIndex() ) {
316  log << "Tuple item " << nam << " has different index colums "
317  << src_id << ":" << src_itm->hasIndex() << " <-> "
318  << clone_id << ":" << itm->hasIndex() << endmsg;
319  return StatusCode::FAILURE;
320  }
321  if ( itm->hasIndex() ) {
322  if ( itm->index() != src_itm->index() ) {
323  log << "Tuple item " << nam << " has different index colums "
324  << src_id << ":" << src_itm->index() << " <-> "
325  << clone_id << ":" << itm->index() << endmsg;
326  return StatusCode::FAILURE;
327  }
328  }
329  }
330  return StatusCode::SUCCESS;
331  }
332  return StatusCode::FAILURE;
333  }
Definition of the MsgStream class used to transmit messages.
Definition: MsgStream.h:24
virtual long type() const =0
Type information of the item.
tuple itm
Definition: ana.py:57
T end(T...args)
virtual bool hasIndex() const =0
Is the tuple have an index item?
IRegistry * registry() const
Get pointer to Registry.
Definition: DataObject.h:74
virtual const std::string & name() const =0
Access _Item name.
STL class.
const std::string & name() const override
The identifying name of the algorithm object.
Definition: Algorithm.cpp:820
NTuple interface class definition.
Definition: INTuple.h:26
virtual long dim(long i) const =0
Access individual dimensions.
STL class.
T begin(T...args)
virtual long ndim() const =0
Dimension.
SmartIF< IMessageSvc > & msgSvc() const
The standard message service.
virtual const id_type & identifier() const =0
Full identifier (or key)
virtual ItemContainer & items()=0
Access item container.
virtual std::string typeName() const =0
Proper type name of the object.
list i
Definition: ana.py:128
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
virtual const INTupleItem * find(const std::string &name) const =0
Find an item row of the Ntuple (CONST)
virtual const std::string & index() const =0
Access the index _Item.
StatusCode CollectionCloneAlg::connect ( )
inline

Connect input and output N-tuples.

Definition at line 446 of file CollectionCloneAlg.cpp.

446  {
448  for (size_t i=0; i < m_inputs.size(); ++i) {
449  NTuplePtr nt(m_dataSvc.get(), m_inputs[i]);
450  if ( !(0 == nt) ) {
452  if ( 0 == out ) {
453  status = book(nt);
454  } else {
455  status = checkInput(out, nt);
456  }
457  if ( !status.isSuccess() ) {
458  return status;
459  }
460  else if ( m_selectorName != "" ) {
461  SmartIF<ISelectStatement> stmt(ObjFactory::create(m_selectorName, serviceLocator()));
462  if ( stmt ) {
463  if ( !m_criteria.empty() ) stmt->setCriteria(m_criteria);
464  nt->attachSelector(stmt);
465  } else {
466  MsgStream log(msgSvc(), name());
467  log << MSG::ERROR << "Failed to attach tuple selector to " << m_inputs[i] << endmsg;
468  return StatusCode::FAILURE;
469  }
470  }
471  } else {
472  MsgStream log(msgSvc(), name());
473  log << MSG::ERROR << "Failed to access tuple: " << m_inputs[i] << endmsg;
474  return StatusCode::FAILURE;
475  }
476  }
477  return StatusCode::SUCCESS;
478  }
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)
virtual StatusCode book(const NTuple::Tuple *nt)
Book the N-tuple according to the specification.
bool isSuccess() const
Test for a status code of SUCCESS.
Definition: StatusCode.h:76
SmartIF< ISvcLocator > & serviceLocator() const override
The standard service locator.
Definition: Algorithm.cpp:929
SmartIF< INTupleSvc > m_dataSvc
Reference to data provider service.
const std::string & name() const override
The identifying name of the algorithm object.
Definition: Algorithm.cpp:820
TYPE * get() const
Get interface pointer.
Definition: SmartIF.h:76
std::vector< std::string > m_inputs
input specifications
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
std::string m_outName
Output tuple name.
virtual StatusCode checkInput(const NTuple::Tuple *clone, const NTuple::Tuple *src)
T size(T...args)
A small class used to access easily (and efficiently) data items residing in data stores...
Definition: SmartDataPtr.h:46
SmartIF< IMessageSvc > & msgSvc() const
The standard message service.
std::string m_selectorName
Selector factory.
list i
Definition: ana.py:128
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
virtual StatusCode CollectionCloneAlg::execute ( )
inlinevirtual

Execute procedure.

Definition at line 205 of file CollectionCloneAlg.cpp.

205  {
206  StatusCode status = connect();
207  if ( status.isSuccess() ) {
208  status = mergeInputTuples();
209  }
210  return status;
211  }
bool isSuccess() const
Test for a status code of SUCCESS.
Definition: StatusCode.h:76
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
StatusCode mergeInputTuples()
Merge all N-tuple entries.
StatusCode connect()
Connect input and output N-tuples.
virtual StatusCode CollectionCloneAlg::finalize ( )
inlinevirtual

Finalize.

Definition at line 199 of file CollectionCloneAlg.cpp.

199  {
200  m_dataSvc.reset();
201  return StatusCode::SUCCESS;
202  }
SmartIF< INTupleSvc > m_dataSvc
Reference to data provider service.
void reset(TYPE *ptr=nullptr)
Set the internal pointer to the passed one disposing of the old one.
Definition: SmartIF.h:88
virtual StatusCode CollectionCloneAlg::initialize ( )
inlinevirtual

Initialize.

Definition at line 158 of file CollectionCloneAlg.cpp.

158  {
159  MsgStream log(msgSvc(), name());
160  m_rootName = "";
161  m_outName = "";
162  m_criteria = "";
163  m_selectorName = "";
164  m_dataSvc = service(m_tupleSvc, true);
165  if ( !m_dataSvc ) {
166  log << MSG::ERROR << "Failed to access service \""
167  << m_tupleSvc << "\"." << endmsg;
168  return StatusCode::FAILURE;
169  }
171  using Parser = Gaudi::Utils::AttribStringParser;
172  for (auto attrib: Parser(m_output)) {
173  switch( ::toupper(attrib.tag[0]) ) {
174  case 'D':
175  m_outName = std::move(attrib.value);
176  break;
177  case 'S':
178  m_criteria = std::move(attrib.value);
179  break;
180  case 'F':
181  fun = std::move(attrib.value);
182  break ;
183  default:
184  break;
185  }
186  }
187  if ( m_outName.empty() ) {
188  log << MSG::ERROR << "Failed to analyze output specs:" << m_output << endmsg;
189  return StatusCode::FAILURE;
190  }
191  if ( !fun.empty() || !m_criteria.empty() ) {
192  if ( !m_criteria.empty() && fun.empty() ) fun = "NTuple::Selector";
194  }
195  return StatusCode::SUCCESS;
196  }
Parse attribute strings allowing iteration over the various attributes.
std::string m_tupleSvc
Name of the data provider service.
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)
SmartIF< INTupleSvc > m_dataSvc
Reference to data provider service.
STL class.
const std::string & name() const override
The identifying name of the algorithm object.
Definition: Algorithm.cpp:820
std::string m_output
Output specification.
std::string m_outName
Output tuple name.
T move(T...args)
std::string m_rootName
Name of the root leaf (obtained at initialize)
double fun(const std::vector< double > &x)
Definition: PFuncTest.cpp:26
SmartIF< IMessageSvc > & msgSvc() const
The standard message service.
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.
Definition: Algorithm.h:232
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:244
StatusCode CollectionCloneAlg::mergeEntries ( const std::string input)
inline

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

Definition at line 336 of file CollectionCloneAlg.cpp.

336  {
337  MsgStream log(msgSvc(), name());
339  if ( 0 != out ) {
340  const INTuple::ItemContainer& clone_items = out->items();
341  std::vector<GenericAddress> addrVector(clone_items.size());
343  NTuplePtr nt(m_dataSvc.get(), input);
344  size_t k = 0, nentry = 0;
345  if ( 0 != nt ) {
346  const INTuple::ItemContainer& source_items = nt->items();
347  for (k=0; k < source_items.size(); ++k ) {
348  if ( source_items[k]->type() == DataTypeInfo::OBJECT_ADDR ) {
349  *(IOpaqueAddress**)source_items[k]->buffer() = &addrVector[k];
350  }
351  }
352  while ( status.isSuccess() ) {
353  status = m_dataSvc->readRecord(nt.ptr());
354  if ( status.isSuccess() ) {
355  INTuple::ItemContainer::const_iterator i;
356  nentry++;
357  for (k=0,i = source_items.begin(); i != source_items.end(); ++i,++k) {
358  const INTupleItem* src_itm = *i;
359  const INTupleItem* out_itm = out->find(src_itm->name());
360  size_t size = 0;
361  switch((*i)->type()) {
362  case DataTypeInfo::UCHAR:
363  size = sizeof(unsigned char);
364  break;
366  size = sizeof(unsigned short);
367  break;
368  case DataTypeInfo::UINT:
369  size = sizeof(unsigned int);
370  break;
371  case DataTypeInfo::ULONG:
372  size = sizeof(unsigned long);
373  break;
374  case DataTypeInfo::CHAR:
375  size = sizeof(char);
376  break;
377  case DataTypeInfo::SHORT:
378  size = sizeof(short);
379  break;
380  case DataTypeInfo::INT:
381  size = sizeof(int);
382  break;
383  case DataTypeInfo::LONG:
384  size = sizeof(long);
385  break;
386  case DataTypeInfo::BOOL:
387  size = sizeof(bool);
388  break;
389  case DataTypeInfo::FLOAT:
390  size = sizeof(float);
391  break;
393  size = sizeof(double);
394  break;
396  *(std::string*)out_itm->buffer() = *(std::string*)src_itm->buffer();
397  size = 0;
398  break;
400  size = ::strlen((const char*)src_itm->buffer())+1;
401  break;
403  {
404  *(void**)out_itm->buffer() = *(void**)src_itm->buffer();
405  size = 0;
406  }
407  break;
409  {
410  IOpaqueAddress* ppA1 = &addrVector[k];
411  IOpaqueAddress** ppA2 = (IOpaqueAddress**)out_itm->buffer();
412  *ppA2 = ppA1;
413  size = 0;
414  }
415  break;
417  default:
418  size = 0;
419  break;
420  }
421  if ( size > 0 ) {
422  ::memcpy((void*)out_itm->buffer(), src_itm->buffer(), size*src_itm->length());
423  }
424  }
425  status = m_dataSvc->writeRecord(out.ptr());
426  if ( !status.isSuccess() ) {
427  log << MSG::ERROR << "Failed to write record " << nentry
428  << " from " << input << " to " << m_outName << endmsg;
429  }
430  }
431  }
432  log << MSG::INFO << "End of reading tuple " << input
433  << " after " << nentry << " entries." << endmsg;
434 
435  if ( nentry > 0 || m_selectorName != "" ) {
436  return StatusCode::SUCCESS;
437  }
438  return StatusCode::FAILURE;
439  }
440  log << MSG::ERROR << "Failed to access input: " << input << endmsg;
441  }
442  return StatusCode::FAILURE;
443  }
Definition of the MsgStream class used to transmit messages.
Definition: MsgStream.h:24
T end(T...args)
const std::string & type() const override
The type of the algorithm object.
Definition: Algorithm.h:168
virtual const std::string & name() const =0
Access _Item name.
SmartIF< INTupleSvc > m_dataSvc
Reference to data provider service.
STL class.
const std::string & name() const override
The identifying name of the algorithm object.
Definition: Algorithm.cpp:820
TYPE * get() const
Get interface pointer.
Definition: SmartIF.h:76
NTuple interface class definition.
Definition: INTuple.h:26
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
virtual StatusCode writeRecord(NTuple::Tuple *tuple)=0
Write single record to N tuple.
std::string m_outName
Output tuple name.
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:46
SmartIF< IMessageSvc > & msgSvc() const
The standard message service.
Opaque address interface definition.
std::string m_selectorName
Selector factory.
list i
Definition: ana.py:128
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
virtual long length() const =0
Access the buffer length.
virtual const void * buffer() const =0
Access data buffer (CONST)
StatusCode CollectionCloneAlg::mergeInputTuples ( )
inline

Merge all N-tuple entries.

Definition at line 481 of file CollectionCloneAlg.cpp.

481  {
482  MsgStream log(msgSvc(), name());
483  for( const auto& input : m_inputs ) {
484  StatusCode sc = mergeEntries(input);
485  if ( !sc.isSuccess() ) {
486  log << MSG::ERROR << "Failed to merge tuple:" << input << endmsg;
487  return sc;
488  }
489  }
490  return StatusCode::SUCCESS;
491  }
Definition of the MsgStream class used to transmit messages.
Definition: MsgStream.h:24
bool isSuccess() const
Test for a status code of SUCCESS.
Definition: StatusCode.h:76
StatusCode mergeEntries(const std::string &input)
Merge the entries of a single input tuple into the output.
const std::string & name() const override
The identifying name of the algorithm object.
Definition: Algorithm.cpp:820
std::vector< std::string > m_inputs
input specifications
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
SmartIF< IMessageSvc > & msgSvc() const
The standard message service.
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244

Member Data Documentation

std::string CollectionCloneAlg::m_criteria
private

Selection criteria (if any)

Definition at line 140 of file CollectionCloneAlg.cpp.

SmartIF<INTupleSvc> CollectionCloneAlg::m_dataSvc
private

Reference to data provider service.

Definition at line 128 of file CollectionCloneAlg.cpp.

std::vector<std::string> CollectionCloneAlg::m_inputs
private

input specifications

Definition at line 134 of file CollectionCloneAlg.cpp.

std::string CollectionCloneAlg::m_outName
private

Output tuple name.

Definition at line 138 of file CollectionCloneAlg.cpp.

std::string CollectionCloneAlg::m_output
private

Output specification.

Definition at line 132 of file CollectionCloneAlg.cpp.

std::string CollectionCloneAlg::m_rootName
private

Name of the root leaf (obtained at initialize)

Definition at line 136 of file CollectionCloneAlg.cpp.

std::string CollectionCloneAlg::m_selectorName
private

Selector factory.

Definition at line 142 of file CollectionCloneAlg.cpp.

std::string CollectionCloneAlg::m_tupleSvc
private

Name of the data provider service.

Definition at line 130 of file CollectionCloneAlg.cpp.


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