All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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...
 
virtual ~Algorithm ()
 Destructor. More...
 
virtual StatusCode sysStart ()
 Reinitialization method invoked by the framework. More...
 
virtual StatusCode sysInitialize ()
 Initialization method invoked by the framework. More...
 
virtual StatusCode sysReinitialize ()
 Reinitialization method invoked by the framework. More...
 
virtual StatusCode sysRestart ()
 Restart method invoked by the framework. More...
 
virtual StatusCode sysExecute ()
 The actions to be performed by the algorithm on an event. More...
 
virtual StatusCode sysStop ()
 System stop. More...
 
virtual StatusCode sysFinalize ()
 System finalization. More...
 
virtual StatusCode sysBeginRun ()
 beginRun method invoked by the framework. More...
 
virtual StatusCode sysEndRun ()
 endRun method invoked by the framework. More...
 
virtual const std::string & name () const
 The identifying name of the algorithm object. More...
 
virtual const std::string & version () const
 The version of the algorithm. More...
 
virtual StatusCode configure ()
 Dummy implementation of IStateful::configure() method. More...
 
virtual StatusCode terminate ()
 Dummy implementation of IStateful::terminate() method. More...
 
virtual StatusCode start ()
 the default (empty) implementation of IStateful::start() method More...
 
virtual StatusCode stop ()
 the default (empty) implementation of IStateful::stop() method More...
 
virtual StatusCode reinitialize ()
 the default (empty) implementation of IStateful::reinitialize() method More...
 
virtual StatusCode restart ()
 the default (empty) implementation of IStateful::restart() method More...
 
virtual bool isExecuted () const
 Has this algorithm been executed since the last reset? More...
 
virtual void setExecuted (bool state)
 Set the executed flag to the specified state. More...
 
virtual void resetExecuted ()
 Reset the executed state of the Algorithm for the duration of the current event. More...
 
virtual StatusCode beginRun ()
 Algorithm begin run. More...
 
virtual StatusCode endRun ()
 Algorithm end run. This method is called at the end of the event loop. More...
 
virtual Gaudi::StateMachine::State FSMState () const
 returns the current state of the algorithm More...
 
virtual Gaudi::StateMachine::State targetFSMState () const
 returns the state the algorithm will be in after the ongoing transition More...
 
virtual bool isEnabled () const
 Is this algorithm enabled or disabled? More...
 
virtual bool filterPassed () const
 Did this algorithm pass or fail its filter criterion for the last event? More...
 
virtual void setFilterPassed (bool state)
 Set the filter passed flag to the specified state. 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...
 
void setOutputLevel (int level)
 Set the output level for current algorithm. More...
 
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< IMessageSvc > & msgSvc () const
 The standard message service. More...
 
SmartIF< IMessageSvc > & messageService () 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< ISvcLocator > & serviceLocator () const
 The standard service locator. More...
 
SmartIF< ISvcLocator > & svcLoc () const
 shortcut for method serviceLocator More...
 
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...
 
std::vector< Algorithm * > * subAlgorithms () const
 List of sub-algorithms. Returns a pointer to a vector of (sub) Algorithms. More...
 
virtual StatusCode setProperty (const Property &p)
 Implementation of IProperty::setProperty. More...
 
virtual StatusCode setProperty (const std::string &s)
 Implementation of IProperty::setProperty. More...
 
virtual StatusCode setProperty (const std::string &n, const std::string &v)
 Implementation of IProperty::setProperty. More...
 
virtual StatusCode getProperty (Property *p) const
 Implementation of IProperty::getProperty. More...
 
virtual const PropertygetProperty (const std::string &name) const
 Implementation of IProperty::getProperty. More...
 
virtual StatusCode getProperty (const std::string &n, std::string &v) const
 Implementation of IProperty::getProperty. More...
 
virtual const std::vector
< Property * > & 
getProperties () const
 Implementation of IProperty::getProperties. More...
 
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...
 
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...
 
- Public Member Functions inherited from extend_interfaces3< IAlgorithm, IProperty, IStateful >
virtual ~extend_interfaces3 ()
 Virtual destructor. More...
 
- Public Member Functions inherited from IAlgorithm
 DeclareInterfaceID (IAlgorithm, 4, 0)
 InterfaceID. More...
 
- Public Member Functions inherited from INamedInterface
 DeclareInterfaceID (INamedInterface, 1, 0)
 InterfaceID. More...
 
virtual ~INamedInterface ()
 Virtual destructor (always needed for abstract classes). More...
 
- Public Member Functions inherited from IInterface
virtual void * i_cast (const InterfaceID &) const =0
 main cast function More...
 
virtual std::vector< std::string > getInterfaceNames () const =0
 Returns a vector of strings containing the names of all the implemented interfaces. More...
 
virtual unsigned long addRef ()=0
 Increment the reference count of Interface instance. More...
 
virtual unsigned long release ()=0
 Release Interface instance. More...
 
virtual unsigned long refCount () const =0
 Current reference count. More...
 
virtual StatusCode queryInterface (const InterfaceID &ti, void **pp)=0
 Set the void** to the pointer to the requested interface of the instance. More...
 
virtual ~IInterface ()
 Virtual destructor. More...
 
- Public Member Functions inherited from IProperty
 DeclareInterfaceID (IProperty, 2, 0)
 InterfaceID. More...
 
- Public Member Functions inherited from IStateful
 DeclareInterfaceID (IStateful, 1, 0)
 InterfaceID. More...
 
virtual ~IStateful ()
 

Private Attributes

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::string > m_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 implements3< IAlgorithm, IProperty, IStateful >
typedef implements3 base_class
 Typedef to this class. More...
 
typedef extend_interfaces3
< IAlgorithm, IProperty,
IStateful
extend_interfaces_base
 Typedef to the base of this class. More...
 
typedef
extend_interfaces_base::ext_iids 
interfaces
 MPL set of all the implemented interfaces. More...
 
- Public Types inherited from extend_interfaces3< IAlgorithm, IProperty, IStateful >
typedef mpl::fold< typename
IAlgorithm::iid::iids::type,
typename mpl::fold< typename
IProperty::iid::iids::type,
typename
IStateful::iid::iids::type,
mpl::insert< mpl::_1, mpl::_2 >
>::type, mpl::insert< mpl::_1,
mpl::_2 > >::type 
ext_iids
 MPL set of interfaces extended by this one. More...
 
- Public Types inherited from IInterface
enum  Status { SUCCESS = 1, NO_INTERFACE, VERSMISMATCH, LAST_ERROR }
 Return status. More...
 
typedef Gaudi::InterfaceId
< IInterface, 0, 0 > 
iid
 Interface ID. More...
 
typedef mpl::set1< iidext_iids
 Extra interfaces. More...
 
- Static Public Member Functions inherited from IInterface
static const InterfaceIDinterfaceID ()
 Return an instance of InterfaceID identifying the interface. More...
 
- Protected Member Functions inherited from Algorithm
bool isInitialized () const
 Has the Algorithm already been initialized? More...
 
bool isFinalized () const
 Has the Algorithm already been finalized? More...
 
int outputLevel () const
 retrieve the Algorithm output level More...
 
IntegerPropertyoutputLevelProperty ()
 Accessor for the Message level property. More...
 
void initOutputLevel (Property &prop)
 callback for output level property 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), m_dataSvc(0)
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:397
std::string m_output
Output specification.
std::vector< std::string > m_inputs
input specifications
virtual const std::string & name() const
The identifying name of the algorithm object.
Definition: Algorithm.cpp:837
INTupleSvc * m_dataSvc
Reference to data provider service.
Algorithm(const std::string &name, ISvcLocator *svcloc, const std::string &version=PACKAGE_VERSION)
Constructor.
Definition: Algorithm.cpp:28
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 219 of file CollectionCloneAlg.cpp.

219  {
220  MsgStream log(msgSvc(), name());
221  const INTuple::ItemContainer& items = nt->items();
223  INTuple::ItemContainer::const_iterator i;
224  NTuple::Tuple* tuple = m_dataSvc->book(m_outName, nt->clID(), nt->title());
225  for (i = items.begin(); i != items.end(); ++i) {
226  long type = (*i)->type();
227  switch(type) {
228  case DataTypeInfo::UCHAR:
229  status = createItem(log, tuple, *i, (unsigned char)0);
230  break;
232  status = createItem(log, tuple, *i, (unsigned short)0);
233  break;
234  case DataTypeInfo::UINT:
235  status = createItem(log, tuple, *i, (unsigned int)0);
236  break;
237  case DataTypeInfo::ULONG:
238  status = createItem(log, tuple, *i, (unsigned long)0);
239  break;
240  case DataTypeInfo::CHAR:
241  status = createItem(log, tuple, *i, char(0));
242  break;
243  case DataTypeInfo::SHORT:
244  status = createItem(log, tuple, *i, short(0));
245  break;
246  case DataTypeInfo::INT:
247  status = createItem(log, tuple, *i, int(0));
248  break;
249  case DataTypeInfo::LONG:
250  status = createItem(log, tuple, *i, long(0));
251  break;
252  case DataTypeInfo::BOOL:
253  status = createItem(log, tuple, *i, false);
254  break;
255  case DataTypeInfo::FLOAT:
256  status = createItem(log, tuple, *i, float(0.0));
257  break;
259  status = createItem(log, tuple, *i, double(0.0));
260  break;
262  status = createItem(log, tuple, *i, (IOpaqueAddress*)0);
263  break;
265  status = createItem(log, tuple, *i, (void*)0);
266  break;
268 // status = createItem(log, tuple, *i, (std::string*)0);
269 // break;
271 // status = createItem(log, tuple, *i, (char*)0);
272 // break;
274  default:
275  status = StatusCode::FAILURE;
276  break;
277  }
278  }
279  return status;
280  }
Definition of the MsgStream class used to transmit messages.
Definition: MsgStream.h:24
std::vector< INTupleItem * > ItemContainer
Definition: INTuple.h:86
virtual const std::string & title() const =0
Object title.
string type
Definition: gaudirun.py:126
virtual const CLID & clID() const
Retrieve reference to class definition structure.
Definition: DataObject.cpp:58
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:30
std::string m_outName
Output tuple name.
virtual const std::string & name() const
The identifying name of the algorithm object.
Definition: Algorithm.cpp:837
INTupleSvc * m_dataSvc
Reference to data provider service.
SmartIF< IMessageSvc > & msgSvc() const
The standard message service.
Definition: Algorithm.cpp:896
Abstract base class which allows the user to interact with the actual N tuple implementation.
Definition: NTuple.h:367
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 283 of file CollectionCloneAlg.cpp.

283  {
284  MsgStream log(msgSvc(), name());
285  if ( 0 != clone && 0 != src ) {
286  const INTuple::ItemContainer& clone_items = clone->items();
287  const std::string clone_id = clone->registry()->identifier();
288  const std::string src_id = src->registry()->identifier();
289 
290  INTuple::ItemContainer::const_iterator i;
291  log << MSG::ERROR;
292  for (i = clone_items.begin(); i != clone_items.end(); ++i) {
293  const INTupleItem* itm = *i;
294  const std::string& nam = itm->name();
295  const INTupleItem* src_itm = src->find(nam);
296  if ( !src_itm ) {
297  log << "Tuple item " << nam << " not present in " << src_id << endmsg;
298  return StatusCode::FAILURE;
299  }
300  if ( itm->type() != src_itm->type() ) {
301  log << "Tuple item " << nam << " are of different types in "
302  << src_id << ":" << src_itm->typeName() << " <-> "
303  << clone_id << ":" << itm->typeName() << endmsg;
304  return StatusCode::FAILURE;
305  }
306  if ( itm->ndim() != src_itm->ndim() ) {
307  log << "Tuple item " << nam << " have different dimensions in "
308  << src_id << ":" << src_itm->ndim() << " <-> "
309  << clone_id << ":" << itm->ndim() << endmsg;
310  return StatusCode::FAILURE;
311  }
312  for (int j=0; j<itm->ndim(); ++j) {
313  if ( src_itm->dim(j) != itm->dim(j) ) {
314  log << "Tuple item " << nam << " have different dimensions in "
315  << src_id << "[" << j << "]:" << src_itm->dim(j) << " <-> "
316  << clone_id << "[" << j << "]:" << itm->dim(j) << endmsg;
317  return StatusCode::FAILURE;
318  }
319  }
320  if ( itm->hasIndex() != src_itm->hasIndex() ) {
321  log << "Tuple item " << nam << " has different index colums "
322  << src_id << ":" << src_itm->hasIndex() << " <-> "
323  << clone_id << ":" << itm->hasIndex() << endmsg;
324  return StatusCode::FAILURE;
325  }
326  if ( itm->hasIndex() ) {
327  if ( itm->index() != src_itm->index() ) {
328  log << "Tuple item " << nam << " has different index colums "
329  << src_id << ":" << src_itm->index() << " <-> "
330  << clone_id << ":" << itm->index() << endmsg;
331  return StatusCode::FAILURE;
332  }
333  }
334  }
335  return StatusCode::SUCCESS;
336  }
337  return StatusCode::FAILURE;
338  }
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
std::vector< INTupleItem * > ItemContainer
Definition: INTuple.h:86
virtual bool hasIndex() const =0
Is the tuple have an index item?
IRegistry * registry() const
Get pointer to Registry.
Definition: DataObject.h:69
virtual const std::string & name() const =0
Access _Item name.
NTuple interface class definition.
Definition: INTuple.h:27
virtual const std::string & name() const
The identifying name of the algorithm object.
Definition: Algorithm.cpp:837
virtual long dim(long i) const =0
Access individual dimensions.
SmartIF< IMessageSvc > & msgSvc() const
The standard message service.
Definition: Algorithm.cpp:896
virtual long ndim() const =0
Dimension.
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 451 of file CollectionCloneAlg.cpp.

451  {
453  for (size_t i=0; i < m_inputs.size(); ++i) {
455  if ( !(0 == nt) ) {
457  if ( 0 == out ) {
458  status = book(nt);
459  }
460  else {
461  status = checkInput(out, nt);
462  }
463  if ( !status.isSuccess() ) {
464  return status;
465  }
466  else if ( m_selectorName != "" ) {
467  SmartIF<ISelectStatement> stmt(ObjFactory::create(m_selectorName, serviceLocator()));
468  if ( stmt.isValid( ) ) {
469  if ( m_criteria.length() > 0 ) stmt->setCriteria(m_criteria);
470  nt->attachSelector(stmt);
471  }
472  else {
473  MsgStream log(msgSvc(), name());
474  log << MSG::ERROR << "Failed to attach tuple selector to " << m_inputs[i] << endmsg;
475  return StatusCode::FAILURE;
476  }
477  }
478  }
479  else {
480  MsgStream log(msgSvc(), name());
481  log << MSG::ERROR << "Failed to access tuple: " << m_inputs[i] << endmsg;
482  return StatusCode::FAILURE;
483  }
484  }
485  return StatusCode::SUCCESS;
486  }
std::string m_criteria
Selection criteria (if any)
Definition of the MsgStream class used to transmit messages.
Definition: MsgStream.h:24
Small smart pointer class with automatic reference counting for IInterface.
Definition: IConverter.h:14
SmartIF< ISvcLocator > & serviceLocator() const
The standard service locator.
Definition: Algorithm.cpp:1091
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:62
std::vector< std::string > m_inputs
input specifications
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:30
std::string m_outName
Output tuple name.
virtual const std::string & name() const
The identifying name of the algorithm object.
Definition: Algorithm.cpp:837
INTupleSvc * m_dataSvc
Reference to data provider service.
SmartIF< IMessageSvc > & msgSvc() const
The standard message service.
Definition: Algorithm.cpp:896
virtual StatusCode checkInput(const NTuple::Tuple *clone, const NTuple::Tuple *src)
A small class used to access easily (and efficiently) data items residing in data stores...
Definition: SmartDataPtr.h:46
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.

Implements IAlgorithm.

Definition at line 210 of file CollectionCloneAlg.cpp.

210  {
211  StatusCode status = connect();
212  if ( status.isSuccess() ) {
213  status = mergeInputTuples();
214  }
215  return status;
216  }
bool isSuccess() const
Test for a status code of SUCCESS.
Definition: StatusCode.h:62
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:30
StatusCode mergeInputTuples()
Merge all N-tuple entries.
StatusCode connect()
Connect input and output N-tuples.
virtual StatusCode CollectionCloneAlg::finalize ( )
inlinevirtual

Finalize.

Reimplemented from Algorithm.

Definition at line 203 of file CollectionCloneAlg.cpp.

203  {
204  if ( m_dataSvc ) m_dataSvc->release();
205  m_dataSvc = 0;
206  return StatusCode::SUCCESS;
207  }
INTupleSvc * m_dataSvc
Reference to data provider service.
virtual unsigned long release()=0
Release Interface instance.
virtual StatusCode CollectionCloneAlg::initialize ( )
inlinevirtual

Initialize.

Reimplemented from Algorithm.

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 = "";
165  if ( sc.isSuccess() ) {
166  std::string fun;
167  Tokenizer tok(true);
168  tok.analyse(m_output, " ", "", "", "=", "'", "'");
169  for ( Tokenizer::Items::iterator i = tok.items().begin(); i != tok.items().end(); i++ ) {
170  const std::string& tag = (*i).tag();
171  const std::string& val = (*i).value();
172  switch( ::toupper(tag[0]) ) {
173  case 'D':
174  m_outName = val;
175  break;
176  case 'S':
177  m_criteria = val;
178  break;
179  case 'F':
180  fun = val;
181  break ;
182  default:
183  break;
184  }
185  }
186  if ( m_outName.empty() ) {
187  log << MSG::ERROR << "Failed to analyze output specs:" << m_output << endmsg;
188  return StatusCode::FAILURE;
189  }
190  if ( fun.length() > 0 || m_criteria.length() > 0 ) {
191  if ( m_criteria.length() > 0 && fun.length() == 0 ) fun = "NTuple::Selector";
193  return StatusCode::SUCCESS;
194  }
195  return sc;
196  }
197  log << MSG::ERROR << "Failed to access service \""
198  << m_tupleSvc << "\"." << endmsg;
199  return sc;
200  }
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
bool isSuccess() const
Test for a status code of SUCCESS.
Definition: StatusCode.h:62
std::string m_output
Output specification.
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:30
STL Include files.
Definition: Tokenizer.h:24
std::string m_outName
Output tuple name.
virtual const std::string & name() const
The identifying name of the algorithm object.
Definition: Algorithm.cpp:837
INTupleSvc * m_dataSvc
Reference to data provider service.
SmartIF< IMessageSvc > & msgSvc() const
The standard message service.
Definition: Algorithm.cpp:896
std::string m_rootName
Name of the root leaf (obtained at initialize)
double fun(const std::vector< double > &x)
Definition: PFuncTest.cpp:27
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:207
std::string m_selectorName
Selector factory.
list i
Definition: ana.py:128
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 341 of file CollectionCloneAlg.cpp.

341  {
342  MsgStream log(msgSvc(), name());
344  if ( 0 != out ) {
345  const INTuple::ItemContainer& clone_items = out->items();
346  std::vector<GenericAddress> addrVector(clone_items.size());
348  NTuplePtr nt(m_dataSvc, input);
349  size_t k = 0, nentry = 0;
350  if ( 0 != nt ) {
351  const INTuple::ItemContainer& source_items = nt->items();
352  for (k=0; k < source_items.size(); ++k ) {
353  if ( source_items[k]->type() == DataTypeInfo::OBJECT_ADDR ) {
354  *(IOpaqueAddress**)source_items[k]->buffer() = &addrVector[k];
355  }
356  }
357  while ( status.isSuccess() ) {
358  status = m_dataSvc->readRecord(nt.ptr());
359  if ( status.isSuccess() ) {
360  INTuple::ItemContainer::const_iterator i;
361  nentry++;
362  for (k=0,i = source_items.begin(); i != source_items.end(); ++i,++k) {
363  const INTupleItem* src_itm = *i;
364  const INTupleItem* out_itm = out->find(src_itm->name());
365  size_t size = 0;
366  switch((*i)->type()) {
367  case DataTypeInfo::UCHAR:
368  size = sizeof(unsigned char);
369  break;
371  size = sizeof(unsigned short);
372  break;
373  case DataTypeInfo::UINT:
374  size = sizeof(unsigned int);
375  break;
376  case DataTypeInfo::ULONG:
377  size = sizeof(unsigned long);
378  break;
379  case DataTypeInfo::CHAR:
380  size = sizeof(char);
381  break;
382  case DataTypeInfo::SHORT:
383  size = sizeof(short);
384  break;
385  case DataTypeInfo::INT:
386  size = sizeof(int);
387  break;
388  case DataTypeInfo::LONG:
389  size = sizeof(long);
390  break;
391  case DataTypeInfo::BOOL:
392  size = sizeof(bool);
393  break;
394  case DataTypeInfo::FLOAT:
395  size = sizeof(float);
396  break;
398  size = sizeof(double);
399  break;
401  *(std::string*)out_itm->buffer() = *(std::string*)src_itm->buffer();
402  size = 0;
403  break;
405  size = ::strlen((const char*)src_itm->buffer())+1;
406  break;
408  {
409  *(void**)out_itm->buffer() = *(void**)src_itm->buffer();
410  size = 0;
411  }
412  break;
414  {
415  IOpaqueAddress* ppA1 = &addrVector[k];
416  IOpaqueAddress** ppA2 = (IOpaqueAddress**)out_itm->buffer();
417  *ppA2 = ppA1;
418  size = 0;
419  }
420  break;
422  default:
423  size = 0;
424  break;
425  }
426  if ( size > 0 ) {
427  ::memcpy((void*)out_itm->buffer(), src_itm->buffer(), size*src_itm->length());
428  }
429  }
430  status = m_dataSvc->writeRecord(out.ptr());
431  if ( !status.isSuccess() ) {
432  log << MSG::ERROR << "Failed to write record " << nentry
433  << " from " << input << " to " << m_outName << endmsg;
434  }
435  }
436  }
437  log << MSG::INFO << "End of reading tuple " << input
438  << " after " << nentry << " entries." << endmsg;
439 
440  if ( nentry > 0 || m_selectorName != "" ) {
441  return StatusCode::SUCCESS;
442  }
443  return StatusCode::FAILURE;
444  }
445  log << MSG::ERROR << "Failed to access input: " << input << endmsg;
446  }
447  return StatusCode::FAILURE;
448  }
Definition of the MsgStream class used to transmit messages.
Definition: MsgStream.h:24
std::vector< INTupleItem * > ItemContainer
Definition: INTuple.h:86
virtual const std::string & name() const =0
Access _Item name.
NTuple interface class definition.
Definition: INTuple.h:27
string type
Definition: gaudirun.py:126
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:30
virtual StatusCode writeRecord(NTuple::Tuple *tuple)=0
Write single record to N tuple.
std::string m_outName
Output tuple name.
virtual const std::string & name() const
The identifying name of the algorithm object.
Definition: Algorithm.cpp:837
INTupleSvc * m_dataSvc
Reference to data provider service.
SmartIF< IMessageSvc > & msgSvc() const
The standard message service.
Definition: Algorithm.cpp:896
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
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 489 of file CollectionCloneAlg.cpp.

489  {
490  MsgStream log(msgSvc(), name());
491  for (size_t inp=0; inp < m_inputs.size(); ++inp) {
493  if ( !sc.isSuccess() ) {
494  log << MSG::ERROR << "Failed to merge tuple:" << m_inputs[inp] << endmsg;
495  return sc;
496  }
497  }
498  return StatusCode::SUCCESS;
499  }
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:62
StatusCode mergeEntries(const std::string &input)
Merge the entries of a single input tuple into the output.
std::vector< std::string > m_inputs
input specifications
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:30
virtual const std::string & name() const
The identifying name of the algorithm object.
Definition: Algorithm.cpp:837
SmartIF< IMessageSvc > & msgSvc() const
The standard message service.
Definition: Algorithm.cpp:896
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.

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: