The Gaudi Framework  master (37c0b60a)
CollectionCloneAlg Class Reference
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 Gaudi::details::LegacyAlgorithmAdapter
 LegacyAlgorithmAdapter (std::string name, ISvcLocator *svcloc, std::string version=PACKAGE_VERSION)
 
const EventContextgetContext () const
 
bool isExecuted () const
 Has this algorithm been executed since the last reset? More...
 
void setExecuted (bool state) const
 Set the executed flag to the specified state. More...
 
bool filterPassed () const
 Did this algorithm pass or fail its filter criterion for the last event? More...
 
void setFilterPassed (bool state) const
 Set the filter passed flag to the specified state. More...
 
- Public Member Functions inherited from Gaudi::Algorithm
 Algorithm (std::string name, ISvcLocator *svcloc, 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...
 
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 (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 isEnabled () const override
 Is this algorithm enabled or disabled? More...
 
bool isSequence () const override
 Are we a Sequence? More...
 
unsigned int errorCount () const
 Get the number of failures of the algorithm. More...
 
template<class T >
StatusCode service (std::string_view 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 (std::string_view svcType, std::string_view svcName, T *&psvc) const
 Access a service by name and type, creating it if it doesn't already exist. More...
 
SmartIF< IServiceservice (std::string_view 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 (std::string_view 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< IDataProviderSvc > & detSvc () const
 The standard detector data service. More...
 
SmartIF< IConversionSvc > & detCnvSvc () const
 The standard detector data persistency conversion service. More...
 
SmartIF< IDataProviderSvc > & eventSvc () const
 The standard event data service. More...
 
SmartIF< IDataProviderSvc > & evtSvc () const
 shortcut for method eventSvc More...
 
SmartIF< IConversionSvc > & eventCnvSvc () const
 The standard event data persistency conversion service. More...
 
SmartIF< IHistogramSvc > & histoSvc () const
 The standard histogram service. More...
 
SmartIF< INTupleSvc > & ntupleSvc () const
 The standard N tuple service. More...
 
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...
 
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...
 
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, const std::string &toolTypeAndName, bool createIf=true)
 
template<class T >
void addToolsArray (ToolHandleArray< T > &hndlArr)
 
const std::vector< IAlgTool * > & tools () const
 
bool isAsynchronous () const
 
void setAsynchronous (bool value)
 
unsigned int cardinality () const override
 Return the cardinality. More...
 
const std::vector< std::string > & neededResources () const override
 
AlgExecStateexecState (const EventContext &ctx) const override
 reference to AlgExecState of Alg More...
 
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
 
bool renounceInput (const DataObjID &id) 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 std::string &name, const Gaudi::Details::PropertyBase &p) override
 set the property from another property with a different name More...
 
StatusCode setProperty (const std::string &s) override
 set the property from the formatted string More...
 
StatusCode setProperty (const Gaudi::Details::PropertyBase &p)
 Set the property from a property. More...
 
virtual StatusCode setProperty (const std::string &name, const Gaudi::Details::PropertyBase &p)=0
 Set the property from a property with a different name. More...
 
virtual StatusCode setProperty (const std::string &s)=0
 Set the property by string. More...
 
StatusCode setProperty (const std::string &name, const char *v)
 Special case for string literals. More...
 
StatusCode setProperty (const std::string &name, const std::string &v)
 Special case for std::string. More...
 
StatusCode setProperty (const std::string &name, const TYPE &value)
 set the property form the value More...
 
StatusCode setPropertyRepr (const std::string &n, const std::string &r) override
 set the property from name and value string representation More...
 
StatusCode getProperty (Gaudi::Details::PropertyBase *p) const override
 get the property More...
 
const Gaudi::Details::PropertyBasegetProperty (std::string_view name) const override
 get the property by name More...
 
StatusCode getProperty (std::string_view 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 (std::string_view name) const override
 Return true if we have a property with the given name. More...
 
Gaudi::Details::PropertyBaseproperty (std::string_view name) const
 \fixme property and bindPropertiesTo should be protected More...
 
void bindPropertiesTo (Gaudi::Interfaces::IOptionsSvc &optsSvc)
 
 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...
 

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 Gaudi::Algorithm
typedef Gaudi::PluginService::Factory< IAlgorithm *(const std::string &, ISvcLocator *)> Factory
 
- 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 Gaudi::Algorithm
friend AlgorithmManager
 
- Protected Member Functions inherited from Gaudi::details::LegacyAlgorithmAdapter
bool isReEntrant () const override
 
- Protected Member Functions inherited from Gaudi::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...
 
bool isReEntrant () const override
 
- 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 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 Gaudi::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 122 of file CollectionCloneAlg.cpp.

Member Function Documentation

◆ book()

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

Book the N-tuple according to the specification.

Definition at line 196 of file CollectionCloneAlg.cpp.

196  {
197  MsgStream log( msgSvc(), name() );
199  NTuple::Tuple* tuple = m_dataSvc->book( m_outName, nt->clID(), nt->title() );
200  for ( const auto& i : nt->items() ) {
201  switch ( i->type() ) {
202  case DataTypeInfo::UCHAR:
203  status = createItem<unsigned char>( log, tuple, i, 0 );
204  break;
206  status = createItem<unsigned short>( log, tuple, i, 0 );
207  break;
208  case DataTypeInfo::UINT:
209  status = createItem<unsigned int>( log, tuple, i, 0 );
210  break;
211  case DataTypeInfo::ULONG:
212  status = createItem<unsigned long>( log, tuple, i, 0 );
213  break;
214  case DataTypeInfo::CHAR:
215  status = createItem<char>( log, tuple, i, 0 );
216  break;
217  case DataTypeInfo::SHORT:
218  status = createItem<short>( log, tuple, i, 0 );
219  break;
220  case DataTypeInfo::INT:
221  status = createItem<int>( log, tuple, i, 0 );
222  break;
223  case DataTypeInfo::LONG:
224  status = createItem<long>( log, tuple, i, 0 );
225  break;
226  case DataTypeInfo::BOOL:
227  status = createItem( log, tuple, i, false );
228  break;
229  case DataTypeInfo::FLOAT:
230  status = createItem<float>( log, tuple, i, 0 );
231  break;
233  status = createItem<double>( log, tuple, i, 0 );
234  break;
236  status = createItem<IOpaqueAddress*>( log, tuple, i, nullptr );
237  break;
239  status = createItem<void*>( log, tuple, i, nullptr );
240  break;
242  // status = createItem(log, tuple, i, (std::string*)0);
243  // break;
245  // status = createItem(log, tuple, i, (char*)0);
246  // break;
248  default:
249  status = StatusCode::FAILURE;
250  break;
251  }
252  }
253  return status;
254  }

◆ checkInput()

virtual StatusCode CollectionCloneAlg::checkInput ( const NTuple::Tuple clone,
const NTuple::Tuple src 
)
inlinevirtual

Definition at line 257 of file CollectionCloneAlg.cpp.

257  {
258  MsgStream log( msgSvc(), name() );
259  if ( clone && src ) {
260  const INTuple::ItemContainer& clone_items = clone->items();
261  const std::string clone_id = clone->registry()->identifier();
262  const std::string src_id = src->registry()->identifier();
263 
264  log << MSG::ERROR;
265  for ( auto i = clone_items.begin(); i != clone_items.end(); ++i ) {
266  const INTupleItem* itm = *i;
267  const std::string& nam = itm->name();
268  const INTupleItem* src_itm = src->find( nam );
269  if ( !src_itm ) {
270  log << "Tuple item " << nam << " not present in " << src_id << endmsg;
271  return StatusCode::FAILURE;
272  }
273  if ( itm->type() != src_itm->type() ) {
274  log << "Tuple item " << nam << " are of different types in " << src_id << ":" << src_itm->typeName()
275  << " <-> " << clone_id << ":" << itm->typeName() << endmsg;
276  return StatusCode::FAILURE;
277  }
278  if ( itm->ndim() != src_itm->ndim() ) {
279  log << "Tuple item " << nam << " have different dimensions in " << src_id << ":" << src_itm->ndim() << " <-> "
280  << clone_id << ":" << itm->ndim() << endmsg;
281  return StatusCode::FAILURE;
282  }
283  for ( int j = 0; j < itm->ndim(); ++j ) {
284  if ( src_itm->dim( j ) != itm->dim( j ) ) {
285  log << "Tuple item " << nam << " have different dimensions in " << src_id << "[" << j
286  << "]:" << src_itm->dim( j ) << " <-> " << clone_id << "[" << j << "]:" << itm->dim( j ) << endmsg;
287  return StatusCode::FAILURE;
288  }
289  }
290  if ( itm->hasIndex() != src_itm->hasIndex() ) {
291  log << "Tuple item " << nam << " has different index colums " << src_id << ":" << src_itm->hasIndex()
292  << " <-> " << clone_id << ":" << itm->hasIndex() << endmsg;
293  return StatusCode::FAILURE;
294  }
295  if ( itm->hasIndex() ) {
296  if ( itm->index() != src_itm->index() ) {
297  log << "Tuple item " << nam << " has different index colums " << src_id << ":" << src_itm->index()
298  << " <-> " << clone_id << ":" << itm->index() << endmsg;
299  return StatusCode::FAILURE;
300  }
301  }
302  }
303  return StatusCode::SUCCESS;
304  }
305  return StatusCode::FAILURE;
306  }

◆ connect()

StatusCode CollectionCloneAlg::connect ( )
inline

Connect input and output N-tuples.

Definition at line 412 of file CollectionCloneAlg.cpp.

412  {
414  for ( size_t i = 0; i < m_inputs.size(); ++i ) {
415  NTuplePtr nt( m_dataSvc.get(), m_inputs[i] );
416  if ( !( 0 == nt ) ) {
418  if ( 0 == out ) {
419  status = book( nt );
420  } else {
421  status = checkInput( out, nt );
422  }
423  if ( !status.isSuccess() ) {
424  return status;
425  } else if ( m_selectorName != "" ) {
426  SmartIF<ISelectStatement> stmt( ObjFactory::create( m_selectorName, serviceLocator() ).release() );
427  if ( stmt ) {
428  if ( !m_criteria.empty() ) stmt->setCriteria( m_criteria );
429  nt->attachSelector( stmt ).ignore( /* AUTOMATICALLY ADDED FOR gaudi/Gaudi!763 */ );
430  } else {
431  MsgStream log( msgSvc(), name() );
432  log << MSG::ERROR << "Failed to attach tuple selector to " << m_inputs[i] << endmsg;
433  return StatusCode::FAILURE;
434  }
435  }
436  } else {
437  MsgStream log( msgSvc(), name() );
438  log << MSG::ERROR << "Failed to access tuple: " << m_inputs[i] << endmsg;
439  return StatusCode::FAILURE;
440  }
441  }
442  return StatusCode::SUCCESS;
443  }

◆ execute()

StatusCode CollectionCloneAlg::execute ( )
inlineoverridevirtual

Execute procedure.

Implements Algorithm.

Definition at line 190 of file CollectionCloneAlg.cpp.

190  {
191  StatusCode status = connect();
192  return status.isSuccess() ? mergeInputTuples() : status;
193  }

◆ finalize()

StatusCode CollectionCloneAlg::finalize ( )
inlineoverride

Finalize.

Definition at line 184 of file CollectionCloneAlg.cpp.

184  {
185  m_dataSvc.reset();
186  return StatusCode::SUCCESS;
187  }

◆ initialize()

StatusCode CollectionCloneAlg::initialize ( )
inlineoverride

Initialize.

Definition at line 144 of file CollectionCloneAlg.cpp.

144  {
145  MsgStream log( msgSvc(), name() );
146  m_rootName = "";
147  m_outName = "";
148  m_criteria = "";
149  m_selectorName = "";
150  m_dataSvc = service( m_tupleSvc, true );
151  if ( !m_dataSvc ) {
152  log << MSG::ERROR << "Failed to access service \"" << m_tupleSvc << "\"." << endmsg;
153  return StatusCode::FAILURE;
154  }
155  std::string fun;
156  using Parser = Gaudi::Utils::AttribStringParser;
157  for ( auto attrib : Parser( m_output ) ) {
158  switch ( ::toupper( attrib.tag[0] ) ) {
159  case 'D':
160  m_outName = std::move( attrib.value );
161  break;
162  case 'S':
163  m_criteria = std::move( attrib.value );
164  break;
165  case 'F':
166  fun = std::move( attrib.value );
167  break;
168  default:
169  break;
170  }
171  }
172  if ( m_outName.empty() ) {
173  log << MSG::ERROR << "Failed to analyze output specs:" << m_output << endmsg;
174  return StatusCode::FAILURE;
175  }
176  if ( !fun.empty() || !m_criteria.empty() ) {
177  if ( !m_criteria.empty() && fun.empty() ) fun = "NTuple::Selector";
178  m_selectorName = fun;
179  }
180  return StatusCode::SUCCESS;
181  }

◆ mergeEntries()

StatusCode CollectionCloneAlg::mergeEntries ( const std::string input)
inline

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

Definition at line 309 of file CollectionCloneAlg.cpp.

309  {
310  MsgStream log( msgSvc(), name() );
312  if ( 0 != out ) {
313  const INTuple::ItemContainer& clone_items = out->items();
314  std::vector<GenericAddress> addrVector( clone_items.size() );
316  NTuplePtr nt( m_dataSvc.get(), input );
317  size_t k = 0, nentry = 0;
318  if ( 0 != nt ) {
319  const INTuple::ItemContainer& source_items = nt->items();
320  for ( k = 0; k < source_items.size(); ++k ) {
321  if ( source_items[k]->type() == DataTypeInfo::OBJECT_ADDR ) {
322  *(IOpaqueAddress**)source_items[k]->buffer() = &addrVector[k];
323  }
324  }
325  while ( status.isSuccess() ) {
326  status = m_dataSvc->readRecord( nt.ptr() );
327  if ( status.isSuccess() ) {
328  INTuple::ItemContainer::const_iterator i;
329  nentry++;
330  for ( k = 0, i = source_items.begin(); i != source_items.end(); ++i, ++k ) {
331  const INTupleItem* src_itm = *i;
332  const INTupleItem* out_itm = out->find( src_itm->name() );
333  size_t size = 0;
334  switch ( ( *i )->type() ) {
335  case DataTypeInfo::UCHAR:
336  size = sizeof( unsigned char );
337  break;
339  size = sizeof( unsigned short );
340  break;
341  case DataTypeInfo::UINT:
342  size = sizeof( unsigned int );
343  break;
344  case DataTypeInfo::ULONG:
345  size = sizeof( unsigned long );
346  break;
347  case DataTypeInfo::CHAR:
348  size = sizeof( char );
349  break;
350  case DataTypeInfo::SHORT:
351  size = sizeof( short );
352  break;
353  case DataTypeInfo::INT:
354  size = sizeof( int );
355  break;
356  case DataTypeInfo::LONG:
357  size = sizeof( long );
358  break;
359  case DataTypeInfo::BOOL:
360  size = sizeof( bool );
361  break;
362  case DataTypeInfo::FLOAT:
363  size = sizeof( float );
364  break;
366  size = sizeof( double );
367  break;
369  *(std::string*)out_itm->buffer() = *(std::string*)src_itm->buffer();
370  size = 0;
371  break;
373  size = ::strlen( (const char*)src_itm->buffer() ) + 1;
374  break;
375  case DataTypeInfo::POINTER: {
376  *(void**)out_itm->buffer() = *(void**)src_itm->buffer();
377  size = 0;
378  } break;
380  IOpaqueAddress* ppA1 = &addrVector[k];
381  IOpaqueAddress** ppA2 = (IOpaqueAddress**)( out_itm->buffer() );
382  *ppA2 = ppA1;
383  size = 0;
384  } break;
386  default:
387  size = 0;
388  break;
389  }
390  if ( size > 0 ) {
391  ::memcpy( const_cast<void*>( out_itm->buffer() ), src_itm->buffer(), size * src_itm->length() );
392  }
393  }
394  status = m_dataSvc->writeRecord( out.ptr() );
395  if ( !status.isSuccess() ) {
396  log << MSG::ERROR << "Failed to write record " << nentry << " from " << input << " to " << m_outName
397  << endmsg;
398  }
399  }
400  }
401  log << MSG::INFO << "End of reading tuple " << input << " after " << nentry << " entries." << endmsg;
402 
403  if ( nentry > 0 || m_selectorName != "" ) { return StatusCode::SUCCESS; }
404  return StatusCode::FAILURE;
405  }
406  log << MSG::ERROR << "Failed to access input: " << input << endmsg;
407  }
408  return StatusCode::FAILURE;
409  }

◆ mergeInputTuples()

StatusCode CollectionCloneAlg::mergeInputTuples ( )
inline

Merge all N-tuple entries.

Definition at line 446 of file CollectionCloneAlg.cpp.

446  {
447  MsgStream log( msgSvc(), name() );
448  for ( const auto& input : m_inputs ) {
449  StatusCode sc = mergeEntries( input );
450  if ( !sc.isSuccess() ) {
451  log << MSG::ERROR << "Failed to merge tuple:" << input << endmsg;
452  return sc;
453  }
454  }
455  return StatusCode::SUCCESS;
456  }

Member Data Documentation

◆ m_criteria

std::string CollectionCloneAlg::m_criteria
private

Selection criteria (if any)

Definition at line 135 of file CollectionCloneAlg.cpp.

◆ m_dataSvc

SmartIF<INTupleSvc> CollectionCloneAlg::m_dataSvc
private

Reference to data provider service.

Definition at line 129 of file CollectionCloneAlg.cpp.

◆ m_inputs

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

Definition at line 125 of file CollectionCloneAlg.cpp.

◆ m_outName

std::string CollectionCloneAlg::m_outName
private

Output tuple name.

Definition at line 133 of file CollectionCloneAlg.cpp.

◆ m_output

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

Definition at line 126 of file CollectionCloneAlg.cpp.

◆ m_rootName

std::string CollectionCloneAlg::m_rootName
private

Name of the root leaf (obtained at initialize)

Definition at line 131 of file CollectionCloneAlg.cpp.

◆ m_selectorName

std::string CollectionCloneAlg::m_selectorName
private

Selector factory.

Definition at line 137 of file CollectionCloneAlg.cpp.

◆ m_tupleSvc

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

Definition at line 124 of file CollectionCloneAlg.cpp.


The documentation for this class was generated from the following file:
CollectionCloneAlg::book
virtual StatusCode book(const NTuple::Tuple *nt)
Book the N-tuple according to the specification.
Definition: CollectionCloneAlg.cpp:196
INTupleItem::type
virtual long type() const =0
Type information of the item.
toupper
void toupper(std::string &s)
Definition: ExceptionSvc.cpp:36
CollectionCloneAlg::m_output
Gaudi::Property< std::string > m_output
Definition: CollectionCloneAlg.cpp:126
std::string
STL class.
INTupleItem::index
virtual const std::string & index() const =0
Access the index _Item.
details::size
constexpr auto size(const T &, Args &&...) noexcept
Definition: AnyDataWrapper.h:23
DataTypeInfo::STRING
@ STRING
Definition: DataTypeInfo.h:46
Gaudi.Configuration.log
log
Definition: Configuration.py:28
INTupleItem::length
virtual long length() const =0
Access the buffer length.
CollectionCloneAlg::m_criteria
std::string m_criteria
Selection criteria (if any)
Definition: CollectionCloneAlg.cpp:135
std::move
T move(T... args)
Gaudi::Algorithm::name
const std::string & name() const override
The identifying name of the algorithm object.
Definition: Algorithm.cpp:526
StatusCode::isSuccess
bool isSuccess() const
Definition: StatusCode.h:314
MSG::INFO
@ INFO
Definition: IMessageSvc.h:25
Gaudi::Algorithm::type
const std::string & type() const override
The type of the algorithm object.
Definition: Algorithm.h:165
IOpaqueAddress
Definition: IOpaqueAddress.h:33
CollectionCloneAlg::m_outName
std::string m_outName
Output tuple name.
Definition: CollectionCloneAlg.cpp:133
std::vector
STL class.
SmartIF::reset
void reset(TYPE *ptr=nullptr)
Set the internal pointer to the passed one disposing of the old one.
Definition: SmartIF.h:96
std::vector::size
T size(T... args)
DataTypeInfo::NTCHAR
@ NTCHAR
Definition: DataTypeInfo.h:47
Gaudi::Algorithm::serviceLocator
SmartIF< ISvcLocator > & serviceLocator() const override
The standard service locator.
Definition: Algorithm.cpp:570
DataTypeInfo::POINTER
@ POINTER
Definition: DataTypeInfo.h:50
INTupleItem::ndim
virtual long ndim() const =0
Dimension.
conf.release
string release
Definition: conf.py:27
CollectionCloneAlg::m_inputs
Gaudi::Property< std::vector< std::string > > m_inputs
Definition: CollectionCloneAlg.cpp:125
DataTypeInfo::USHORT
@ USHORT
Definition: DataTypeInfo.h:36
INTuple::find
virtual const INTupleItem * find(const std::string &name) const =0
Find an item row of the Ntuple (CONST)
CollectionCloneAlg::m_dataSvc
SmartIF< INTupleSvc > m_dataSvc
Reference to data provider service.
Definition: CollectionCloneAlg.cpp:129
CollectionCloneAlg::m_selectorName
std::string m_selectorName
Selector factory.
Definition: CollectionCloneAlg.cpp:137
AvalancheSchedulerErrorTest.msgSvc
msgSvc
Definition: AvalancheSchedulerErrorTest.py:80
DataTypeInfo::ULONG
@ ULONG
Definition: DataTypeInfo.h:38
DataTypeInfo::LONG
@ LONG
Definition: DataTypeInfo.h:42
DataTypeInfo::DOUBLE
@ DOUBLE
Definition: DataTypeInfo.h:45
INTuple::items
virtual ItemContainer & items()=0
Access item container.
INTupleItem::hasIndex
virtual bool hasIndex() const =0
Is the tuple have an index item?
StatusCode
Definition: StatusCode.h:65
DataTypeInfo::SHORT
@ SHORT
Definition: DataTypeInfo.h:40
DataTypeInfo::UNKNOWN
@ UNKNOWN
Definition: DataTypeInfo.h:34
CollectionCloneAlg::mergeInputTuples
StatusCode mergeInputTuples()
Merge all N-tuple entries.
Definition: CollectionCloneAlg.cpp:446
ProduceConsume.j
j
Definition: ProduceConsume.py:104
INTupleItem::buffer
virtual const void * buffer() const =0
Access data buffer (CONST)
CollectionCloneAlg::m_rootName
std::string m_rootName
Name of the root leaf (obtained at initialize)
Definition: CollectionCloneAlg.cpp:131
INTupleItem::typeName
virtual std::string typeName() const =0
Proper type name of the object.
SmartIF< ISelectStatement >
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:202
INTupleItem
Definition: INTuple.h:37
MsgStream
Definition: MsgStream.h:33
INTupleItem::dim
virtual long dim(long i) const =0
Access individual dimensions.
DataTypeInfo::FLOAT
@ FLOAT
Definition: DataTypeInfo.h:44
CollectionCloneAlg::checkInput
virtual StatusCode checkInput(const NTuple::Tuple *clone, const NTuple::Tuple *src)
Definition: CollectionCloneAlg.cpp:257
DataTypeInfo::UCHAR
@ UCHAR
Definition: DataTypeInfo.h:35
DataTypeInfo::UINT
@ UINT
Definition: DataTypeInfo.h:37
StatusCode::SUCCESS
constexpr static const auto SUCCESS
Definition: StatusCode.h:100
SmartIF::get
TYPE * get() const
Get interface pointer.
Definition: SmartIF.h:86
DataTypeInfo::BOOL
@ BOOL
Definition: DataTypeInfo.h:43
SmartDataPtr
A small class used to access easily (and efficiently) data items residing in data stores.
Definition: SmartDataPtr.h:57
NTuple::Tuple
Abstract base class which allows the user to interact with the actual N tuple implementation.
Definition: NTuple.h:388
std::vector::begin
T begin(T... args)
Gaudi::Algorithm::service
StatusCode service(std::string_view name, T *&psvc, bool createIf=true) const
Access a service by name, creating it if it doesn't already exist.
Definition: Algorithm.h:206
MSG::ERROR
@ ERROR
Definition: IMessageSvc.h:25
INTuple::title
virtual const std::string & title() const =0
Object title.
IRegistry::identifier
virtual const id_type & identifier() const =0
Full identifier (or key)
std::string::empty
T empty(T... args)
DataTypeInfo::OBJECT_ADDR
@ OBJECT_ADDR
Definition: DataTypeInfo.h:51
std::vector::end
T end(T... args)
CollectionCloneAlg::m_tupleSvc
Gaudi::Property< std::string > m_tupleSvc
Definition: CollectionCloneAlg.cpp:124
INTupleItem::name
virtual const std::string & name() const =0
Access _Item name.
StatusCode::FAILURE
constexpr static const auto FAILURE
Definition: StatusCode.h:101
CollectionCloneAlg::mergeEntries
StatusCode mergeEntries(const std::string &input)
Merge the entries of a single input tuple into the output.
Definition: CollectionCloneAlg.cpp:309
DataObject::clID
virtual const CLID & clID() const
Retrieve reference to class definition structure.
Definition: DataObject.cpp:66
Gaudi::Utils::AttribStringParser
Parse attribute strings allowing iteration over the various attributes.
Definition: AttribStringParser.h:40
DataObject::registry
IRegistry * registry() const
Get pointer to Registry.
Definition: DataObject.h:78
DataTypeInfo::INT
@ INT
Definition: DataTypeInfo.h:41
DataTypeInfo::CHAR
@ CHAR
Definition: DataTypeInfo.h:39
PrepareBase.out
out
Definition: PrepareBase.py:20
CollectionCloneAlg::connect
StatusCode connect()
Connect input and output N-tuples.
Definition: CollectionCloneAlg.cpp:412