| # Gaudi Framework, version v25r0 |

Home |  | Generated: Mon Feb 17 2014

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Public Member Functions | Private Attributes | Static Private Attributes | List of all members
CollectionCloneAlg Class Reference

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

Inheritance diagram for CollectionCloneAlg:
[legend]
Collaboration diagram for CollectionCloneAlg:
[legend]

## Public Member Functions
| CollectionCloneAlg (const std::string &name, ISvcLocator *pSvcLocator)
| Standard algorithm constructor.
virtual | ~CollectionCloneAlg ()
| Standard Destructor.
virtual StatusCode | initialize ()
| Initialize.
virtual StatusCode | finalize ()
| Finalize.
virtual StatusCode | execute ()
| Execute procedure.
virtual StatusCode | book (const NTuple::Tuple *nt)
| Book the N-tuple according to the specification.
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.
StatusCode | connect ()
| Connect input and output N-tuples.
StatusCode | mergeInputTuples ()
| Merge all N-tuple entries.
Public Member Functions inherited from Algorithm
| Algorithm (const std::string &name, ISvcLocator *svcloc, const std::string &version=PACKAGE_VERSION)
| Constructor.
virtual | ~Algorithm ()
| Destructor.
virtual StatusCode | sysStart ()
| Reinitialization method invoked by the framework.
virtual StatusCode | sysInitialize ()
| Initialization method invoked by the framework.
virtual StatusCode | sysReinitialize ()
| Reinitialization method invoked by the framework.
virtual StatusCode | sysRestart ()
| Restart method invoked by the framework.
virtual StatusCode | sysExecute ()
| The actions to be performed by the algorithm on an event.
virtual StatusCode | sysStop ()
| System stop.
virtual StatusCode | sysFinalize ()
| System finalization.
virtual StatusCode | sysBeginRun ()
| beginRun method invoked by the framework.
virtual StatusCode | sysEndRun ()
| endRun method invoked by the framework.
virtual const std::string & | name () const
| The identifying name of the algorithm object.
virtual const std::string & | version () const
virtual StatusCode | configure ()
| Dummy implementation of IStateful::configure() method.
virtual StatusCode | terminate ()
| Dummy implementation of IStateful::terminate() method.
virtual StatusCode | start ()
| the default (empty) implementation of IStateful::start() method
virtual StatusCode | stop ()
| the default (empty) implementation of IStateful::stop() method
virtual StatusCode | reinitialize ()
| the default (empty) implementation of IStateful::reinitialize() method
virtual StatusCode | restart ()
| the default (empty) implementation of IStateful::restart() method
virtual bool | isExecuted () const
| Has this algorithm been executed since the last reset?
virtual void | setExecuted (bool state)
| Set the executed flag to the specified state.
virtual void | resetExecuted ()
| Reset the executed state of the Algorithm for the duration of the current event.
virtual StatusCode | beginRun ()
| Algorithm begin run.
virtual StatusCode | endRun ()
| Algorithm end run. This method is called at the end of the event loop.
virtual Gaudi::StateMachine::State | FSMState () const
| returns the current state of the algorithm
virtual Gaudi::StateMachine::State | targetFSMState () const
| returns the state the algorithm will be in after the ongoing transition
virtual bool | isEnabled () const
| Is this algorithm enabled or disabled?
virtual bool | filterPassed () const
| Did this algorithm pass or fail its filter criterion for the last event?
virtual void | setFilterPassed (bool state)
| Set the filter passed flag to the specified state.
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.
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.
SmartIF< IService > | service (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")
void | setOutputLevel (int level)
| Set the output level for current algorithm.
SmartIF< IAuditorSvc > & | auditorSvc () const
| The standard auditor service.May not be invoked before sysInitialize() has been invoked.
SmartIF< IChronoStatSvc > & | chronoSvc () const
| The standard Chrono & Stat service, Return a pointer to the service if present.
SmartIF< IChronoStatSvc > & | chronoStatService () const
| Obsoleted name, kept due to the backwards compatibility.
SmartIF< IDataProviderSvc > & | detSvc () const
| The standard detector data service.
SmartIF< IDataProviderSvc > & | detDataService () const
| Obsoleted name, kept due to the backwards compatibility.
SmartIF< IConversionSvc > & | detCnvSvc () const
| The standard detector data persistency conversion service.
SmartIF< IConversionSvc > & | detDataCnvService () const
| Obsoleted name, kept due to the backwards compatibility.
SmartIF< IDataProviderSvc > & | eventSvc () const
| The standard event data service.
SmartIF< IDataProviderSvc > & | evtSvc () const
| shortcut for method eventSvc
SmartIF< IDataProviderSvc > & | eventDataService () const
| Obsoleted name, kept due to the backwards compatibility.
SmartIF< IConversionSvc > & | eventCnvSvc () const
| The standard event data persistency conversion service.
SmartIF< IConversionSvc > & | eventDataCnvService () const
| Obsoleted name, kept due to the backwards compatibility.
SmartIF< IHistogramSvc > & | histoSvc () const
| The standard histogram service.
SmartIF< IHistogramSvc > & | histogramDataService () const
| Obsoleted name, kept due to the backwards compatibility.
SmartIF< IMessageSvc > & | msgSvc () const
| The standard message service.
SmartIF< IMessageSvc > & | messageService () const
| Obsoleted name, kept due to the backwards compatibility.
SmartIF< INTupleSvc > & | ntupleSvc () const
| The standard N tuple service.
SmartIF< INTupleSvc > & | ntupleService () const
| Obsoleted name, kept due to the backwards compatibility.
SmartIF< IRndmGenSvc > & | randSvc () const
| AIDA-based NTuple service Returns a pointer to the AIDATuple service if present.
SmartIF< IToolSvc > & | toolSvc () const
| The standard ToolSvc service, Return a pointer to the service if present.
SmartIF< IExceptionSvc > & | exceptionSvc () const
| Get the exception Service.
SmartIF< IAlgContextSvc > & | contextSvc () const
| get Algorithm Context Service
SmartIF< ISvcLocator > & | serviceLocator () const
| The standard service locator.
SmartIF< ISvcLocator > & | svcLoc () const
| shortcut for method serviceLocator
bool | registerContext () const
| register for Algorithm Context Service?
StatusCode | createSubAlgorithm (const std::string &type, const std::string &name, Algorithm *&pSubAlg)
| Create a sub algorithm.
std::vector< Algorithm * > * | subAlgorithms () const
| List of sub-algorithms. Returns a pointer to a vector of (sub) Algorithms.
virtual StatusCode | setProperty (const Property &p)
| Implementation of IProperty::setProperty.
virtual StatusCode | setProperty (const std::string &s)
| Implementation of IProperty::setProperty.
virtual StatusCode | setProperty (const std::string &n, const std::string &v)
| Implementation of IProperty::setProperty.
virtual StatusCode | getProperty (Property *p) const
| Implementation of IProperty::getProperty.
virtual const Property & | getProperty (const std::string &name) const
| Implementation of IProperty::getProperty.
virtual StatusCode | getProperty (const std::string &n, std::string &v) const
| Implementation of IProperty::getProperty.
virtual const std::vector < Property * > & | getProperties () const
| Implementation of IProperty::getProperties.
StatusCode | setProperties ()
| Set the algorithm's properties.
template<class T >
Property * | declareProperty (const std::string &name, T &property, const std::string &doc="none") const
| Declare the named property.
Property * | declareRemoteProperty (const std::string &name, IProperty *rsvc, const std::string &rname="") const
| Declare remote named properties.
SmartIF< IMonitorSvc > & | monitorSvc () const
| Access the monitor service.
template<class T >
void | declareInfo (const std::string &name, const T &var, const std::string &desc) const
| Declare monitoring information.
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)
template<class TYPE >
StatusCode | setProperty (const std::string &name, const TYPE &value)
| set the property form the value

## Private Attributes
std::string | m_tupleSvc
| Name of the data provider service.
std::string | m_output
| Output specification.
std::vector< std::string > | m_inputs
| input specifications
std::string | m_rootName
| Name of the root leaf (obtained at initialize)
std::string | m_outName
| Output tuple name.
std::string | m_criteria
| Selection criteria (if any)
std::string | m_selectorName
| Selector factory.

## Static Private Attributes
INTupleSvc * | m_dataSvc
| Reference to data provider service.

## Additional Inherited Members
Public Types inherited from Algorithm
typedef Gaudi::PluginService::Factory2 < IAlgorithm *, const std::string &, ISvcLocator * > | Factory
Protected Member Functions inherited from Algorithm
bool | isInitialized () const
| Has the Algorithm already been initialized?
bool | isFinalized () const
| Has the Algorithm already been finalized?
int | outputLevel () const
| retrieve the Algorithm output level
IntegerProperty & | outputLevelProperty ()
| Accessor for the Message level property.
void | initOutputLevel (Property &prop)
| callback for output level property

## 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.

: Algorithm(name, pSvcLocator), m_dataSvc(0)
{
declareProperty("EvtTupleSvc", m_tupleSvc="EvtTupleSvc");
declareProperty("Input", m_inputs);
declareProperty("Output", m_output);
}

virtual CollectionCloneAlg::~CollectionCloneAlg | ( |  | ) |
| inline virtual

Standard Destructor.

Definition at line 154 of file CollectionCloneAlg.cpp.

{
}

## Member Function Documentation

virtual StatusCode CollectionCloneAlg::book | ( | const NTuple::Tuple * | nt | ) |
| inline virtual

Book the N-tuple according to the specification.

Definition at line 219 of file CollectionCloneAlg.cpp.

{
MsgStream log(msgSvc(), name());
const INTuple::ItemContainer& items = nt->items();
StatusCode status = StatusCode::SUCCESS;
INTuple::ItemContainer::const_iterator i;
NTuple::Tuple* tuple = m_dataSvc->book(m_outName, nt->clID(), nt->title());
for (i = items.begin(); i != items.end(); ++i) {
long type = (*i)->type();
switch(type) {
case DataTypeInfo::UCHAR:
status = createItem(log, tuple, *i, (unsigned char)0);
break;
case DataTypeInfo::USHORT:
status = createItem(log, tuple, *i, (unsigned short)0);
break;
case DataTypeInfo::UINT:
status = createItem(log, tuple, *i, (unsigned int)0);
break;
case DataTypeInfo::ULONG:
status = createItem(log, tuple, *i, (unsigned long)0);
break;
case DataTypeInfo::CHAR:
status = createItem(log, tuple, *i, char(0));
break;
case DataTypeInfo::SHORT:
status = createItem(log, tuple, *i, short(0));
break;
case DataTypeInfo::INT:
status = createItem(log, tuple, *i, int(0));
break;
case DataTypeInfo::LONG:
status = createItem(log, tuple, *i, long(0));
break;
case DataTypeInfo::BOOL:
status = createItem(log, tuple, *i, false);
break;
case DataTypeInfo::FLOAT:
status = createItem(log, tuple, *i, float(0.0));
break;
case DataTypeInfo::DOUBLE:
status = createItem(log, tuple, *i, double(0.0));
break;
case DataTypeInfo::OBJECT_ADDR:
status = createItem(log, tuple, *i, (IOpaqueAddress*)0);
break;
case DataTypeInfo::POINTER:
status = createItem(log, tuple, *i, (void*)0);
break;
case DataTypeInfo::STRING:
// status = createItem(log, tuple, *i, (std::string*)0);
// break;
case DataTypeInfo::NTCHAR:
// status = createItem(log, tuple, *i, (char*)0);
// break;
case DataTypeInfo::UNKNOWN:
default:
status = StatusCode::FAILURE;
break;
}
}
return status;
}

virtual StatusCode CollectionCloneAlg::checkInput | ( | const NTuple::Tuple * | clone,
|  | const NTuple::Tuple * | src
| ) |  |
| inline virtual

Definition at line 283 of file CollectionCloneAlg.cpp.

{
MsgStream log(msgSvc(), name());
if ( 0 != clone && 0 != src ) {
const INTuple::ItemContainer& clone_items = clone->items();
const std::string clone_id = clone->registry()->identifier();
const std::string src_id = src->registry()->identifier();
INTuple::ItemContainer::const_iterator i;
log << MSG::ERROR;
for (i = clone_items.begin(); i != clone_items.end(); ++i) {
const INTupleItem* itm = *i;
const std::string& nam = itm->name();
const INTupleItem* src_itm = src->find(nam);
if ( !src_itm ) {
log << "Tuple item " << nam << " not present in " << src_id << endmsg;
return StatusCode::FAILURE;
}
if ( itm->type() != src_itm->type() ) {
log << "Tuple item " << nam << " are of different types in "
<< src_id << ":" << src_itm->typeName() << " <-> "
<< clone_id << ":" << itm->typeName() << endmsg;
return StatusCode::FAILURE;
}
if ( itm->ndim() != src_itm->ndim() ) {
log << "Tuple item " << nam << " have different dimensions in "
<< src_id << ":" << src_itm->ndim() << " <-> "
<< clone_id << ":" << itm->ndim() << endmsg;
return StatusCode::FAILURE;
}
for (int j=0; j<itm->ndim(); ++j) {
if ( src_itm->dim(j) != itm->dim(j) ) {
log << "Tuple item " << nam << " have different dimensions in "
<< src_id << "[" << j << "]:" << src_itm->dim(j) << " <-> "
<< clone_id << "[" << j << "]:" << itm->dim(j) << endmsg;
return StatusCode::FAILURE;
}
}
if ( itm->hasIndex() != src_itm->hasIndex() ) {
log << "Tuple item " << nam << " has different index colums "
<< src_id << ":" << src_itm->hasIndex() << " <-> "
<< clone_id << ":" << itm->hasIndex() << endmsg;
return StatusCode::FAILURE;
}
if ( itm->hasIndex() ) {
if ( itm->index() != src_itm->index() ) {
log << "Tuple item " << nam << " has different index colums "
<< src_id << ":" << src_itm->index() << " <-> "
<< clone_id << ":" << itm->index() << endmsg;
return StatusCode::FAILURE;
}
}
}
return StatusCode::SUCCESS;
}
return StatusCode::FAILURE;
}

StatusCode CollectionCloneAlg::connect | ( |  | ) |
| inline

Connect input and output N-tuples.

Definition at line 451 of file CollectionCloneAlg.cpp.

{
StatusCode status = StatusCode::SUCCESS;
for (size_t i=0; i < m_inputs.size(); ++i) {
NTuplePtr nt(m_dataSvc, m_inputs[i]);
if ( !(0 == nt) ) {
NTuplePtr out(m_dataSvc, m_outName);
if ( 0 == out ) {
status = book(nt);
}
else {
status = checkInput(out, nt);
}
if ( !status.isSuccess() ) {
return status;
}
else if ( m_selectorName != "" ) {
SmartIF<ISelectStatement> stmt(ObjFactory::create(m_selectorName, serviceLocator()));
if ( stmt.isValid( ) ) {
if ( m_criteria.length() > 0 ) stmt->setCriteria(m_criteria);
nt->attachSelector(stmt);
}
else {
MsgStream log(msgSvc(), name());
log << MSG::ERROR << "Failed to attach tuple selector to " << m_inputs[i] << endmsg;
return StatusCode::FAILURE;
}
}
}
else {
MsgStream log(msgSvc(), name());
log << MSG::ERROR << "Failed to access tuple: " << m_inputs[i] << endmsg;
return StatusCode::FAILURE;
}
}
return StatusCode::SUCCESS;
}

virtual StatusCode CollectionCloneAlg::execute | ( |  | ) |
| inline virtual

Execute procedure.

Definition at line 210 of file CollectionCloneAlg.cpp.

{
StatusCode status = connect();
if ( status.isSuccess() ) {
status = mergeInputTuples();
}
return status;
}

virtual StatusCode CollectionCloneAlg::finalize | ( |  | ) |
| inline virtual

Finalize.

Reimplemented from Algorithm.

Definition at line 203 of file CollectionCloneAlg.cpp.

{
if ( m_dataSvc ) m_dataSvc->release();
m_dataSvc = 0;
return StatusCode::SUCCESS;
}

virtual StatusCode CollectionCloneAlg::initialize | ( |  | ) |
| inline virtual

Initialize.

Reimplemented from Algorithm.

Definition at line 158 of file CollectionCloneAlg.cpp.

{
MsgStream log(msgSvc(), name());
m_rootName = "";
m_outName = "";
m_criteria = "";
m_selectorName = "";
StatusCode sc = service(m_tupleSvc, m_dataSvc, true);
if ( sc.isSuccess() ) {
std::string fun;
Tokenizer tok(true);
tok.analyse(m_output, " ", "", "", "=", "'", "'");
for ( Tokenizer::Items::iterator i = tok.items().begin(); i != tok.items().end(); i++ ) {
const std::string& tag = (*i).tag();
const std::string& val = (*i).value();
switch( ::toupper(tag[0]) ) {
case 'D':
m_outName = val;
break;
case 'S':
m_criteria = val;
break;
case 'F':
fun = val;
break ;
default:
break;
}
}
if ( m_outName.empty() ) {
log << MSG::ERROR << "Failed to analyze output specs:" << m_output << endmsg;
return StatusCode::FAILURE;
}
if ( fun.length() > 0 || m_criteria.length() > 0 ) {
if ( m_criteria.length() > 0 && fun.length() == 0 ) fun = "NTuple::Selector";
m_selectorName = fun;
return StatusCode::SUCCESS;
}
return sc;
}
log << MSG::ERROR << "Failed to access service \""
<< m_tupleSvc << "\"." << endmsg;
return sc;
}

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.

{
MsgStream log(msgSvc(), name());
NTuplePtr out(m_dataSvc, m_outName);
if ( 0 != out ) {
const INTuple::ItemContainer& clone_items = out->items();
std::vector<GenericAddress> addrVector(clone_items.size());
StatusCode status = StatusCode::SUCCESS;
NTuplePtr nt(m_dataSvc, input);
size_t k = 0, nentry = 0;
if ( 0 != nt ) {
const INTuple::ItemContainer& source_items = nt->items();
for (k=0; k < source_items.size(); ++k ) {
if ( source_items[k]->type() == DataTypeInfo::OBJECT_ADDR ) {
*(IOpaqueAddress**)source_items[k]->buffer() = &addrVector[k];
}
}
while ( status.isSuccess() ) {
status = m_dataSvc->readRecord(nt.ptr());
if ( status.isSuccess() ) {
INTuple::ItemContainer::const_iterator i;
nentry++;
for (k=0,i = source_items.begin(); i != source_items.end(); ++i,++k) {
const INTupleItem* src_itm = *i;
const INTupleItem* out_itm = out->find(src_itm->name());
size_t size = 0;
switch((*i)->type()) {
case DataTypeInfo::UCHAR:
size = sizeof(unsigned char);
break;
case DataTypeInfo::USHORT:
size = sizeof(unsigned short);
break;
case DataTypeInfo::UINT:
size = sizeof(unsigned int);
break;
case DataTypeInfo::ULONG:
size = sizeof(unsigned long);
break;
case DataTypeInfo::CHAR:
size = sizeof(char);
break;
case DataTypeInfo::SHORT:
size = sizeof(short);
break;
case DataTypeInfo::INT:
size = sizeof(int);
break;
case DataTypeInfo::LONG:
size = sizeof(long);
break;
case DataTypeInfo::BOOL:
size = sizeof(bool);
break;
case DataTypeInfo::FLOAT:
size = sizeof(float);
break;
case DataTypeInfo::DOUBLE:
size = sizeof(double);
break;
case DataTypeInfo::STRING:
*(std::string*)out_itm->buffer() = *(std::string*)src_itm->buffer();
size = 0;
break;
case DataTypeInfo::NTCHAR:
size = ::strlen((const char*)src_itm->buffer())+1;
break;
case DataTypeInfo::POINTER:
{
*(void**)out_itm->buffer() = *(void**)src_itm->buffer();
size = 0;
}
break;
case DataTypeInfo::OBJECT_ADDR:
{
IOpaqueAddress* ppA1 = &addrVector[k];
IOpaqueAddress** ppA2 = (IOpaqueAddress**)out_itm->buffer();
*ppA2 = ppA1;
size = 0;
}
break;
case DataTypeInfo::UNKNOWN:
default:
size = 0;
break;
}
if ( size > 0 ) {
::memcpy((void*)out_itm->buffer(), src_itm->buffer(), size*src_itm->length());
}
}
status = m_dataSvc->writeRecord(out.ptr());
if ( !status.isSuccess() ) {
log << MSG::ERROR << "Failed to write record " << nentry
<< " from " << input << " to " << m_outName << endmsg;
}
}
}
log << MSG::INFO << "End of reading tuple " << input
<< " after " << nentry << " entries." << endmsg;
if ( nentry > 0 || m_selectorName != "" ) {
return StatusCode::SUCCESS;
}
return StatusCode::FAILURE;
}
log << MSG::ERROR << "Failed to access input: " << input << endmsg;
}
return StatusCode::FAILURE;
}

StatusCode CollectionCloneAlg::mergeInputTuples | ( |  | ) |
| inline

Merge all N-tuple entries.

Definition at line 489 of file CollectionCloneAlg.cpp.

{
MsgStream log(msgSvc(), name());
for (size_t inp=0; inp < m_inputs.size(); ++inp) {
StatusCode sc = mergeEntries(m_inputs[inp]);
if ( !sc.isSuccess() ) {
log << MSG::ERROR << "Failed to merge tuple:" << m_inputs[inp] << endmsg;
return sc;
}
}
return StatusCode::SUCCESS;
}

## 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
| static 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:

- /afs/cern.ch/sw/Gaudi/releases/GAUDI/GAUDI_v25r0/GaudiSvc/src/NTupleSvc/CollectionCloneAlg.cpp