28 return long( it->
range().upper() );
35 TYP low = source->
range().lower();
36 TYP high = source->
range().upper();
38 long ndim = source->
ndim();
41 long dim[4], idxLen = 0;
42 long dim1 = 1, dim2 = 1;
44 for (
int i = 0; i < ndim; i++ ) dim[i] = source->
dim( i );
48 idxName = index->
name();
49 switch ( index->
type() ) {
51 idxLen = upper<unsigned char>( index );
54 idxLen = upper<unsigned short>( index );
57 idxLen = upper<unsigned int>( index );
60 idxLen = upper<unsigned long>( index );
63 idxLen = upper<char>( index );
66 idxLen = upper<short>( index );
69 idxLen = upper<int>( index );
72 idxLen = upper<long>( index );
75 log <<
MSG::ERROR <<
"Column " << idxName <<
" is not a valid index column!" <<
endmsg;
84 dim1 = ( hasIdx ) ? idxLen : dim[0];
88 dim1 = ( hasIdx ) ? idxLen : dim[0];
89 dim2 = ( hasIdx ) ? dim[0] : dim[1];
95 return tuple->
add( it );
149 for (
auto attrib : Parser(
m_output ) ) {
150 switch (::
toupper( attrib.tag[0] ) ) {
164 if ( m_outName.
empty() ) {
169 if ( !m_criteria.
empty() && fun.
empty() ) fun =
"NTuple::Selector";
170 m_selectorName =
fun;
198 INTuple::ItemContainer::const_iterator i;
200 for ( i = items.
begin(); i != items.
end(); ++i ) {
201 long type = ( *i )->type();
204 status = createItem( log, tuple, *i, (
unsigned char)0 );
207 status = createItem( log, tuple, *i, (
unsigned short)0 );
210 status = createItem( log, tuple, *i, (
unsigned int)0 );
213 status = createItem( log, tuple, *i, (
unsigned long)0 );
216 status = createItem( log, tuple, *i,
char( 0 ) );
219 status = createItem( log, tuple, *i,
short( 0 ) );
222 status = createItem( log, tuple, *i,
int( 0 ) );
225 status = createItem( log, tuple, *i,
long( 0 ) );
228 status = createItem( log, tuple, *i,
false );
231 status = createItem( log, tuple, *i,
float( 0.0 ) );
234 status = createItem( log, tuple, *i,
double( 0.0 ) );
240 status = createItem( log, tuple, *i, (
void*)0 );
261 if ( 0 != clone && 0 != src ) {
266 INTuple::ItemContainer::const_iterator i;
268 for ( i = clone_items.
begin(); i != clone_items.
end(); ++i ) {
273 log <<
"Tuple item " << nam <<
" not present in " << src_id <<
endmsg;
276 if ( itm->
type() != src_itm->
type() ) {
277 log <<
"Tuple item " << nam <<
" are of different types in " << src_id <<
":" << src_itm->
typeName()
281 if ( itm->
ndim() != src_itm->
ndim() ) {
282 log <<
"Tuple item " << nam <<
" have different dimensions in " << src_id <<
":" << src_itm->
ndim() <<
" <-> " 286 for (
int j = 0; j < itm->
ndim(); ++j ) {
287 if ( src_itm->
dim( j ) != itm->
dim( j ) ) {
288 log <<
"Tuple item " << nam <<
" have different dimensions in " << src_id <<
"[" << j
289 <<
"]:" << src_itm->
dim( j ) <<
" <-> " << clone_id <<
"[" << j <<
"]:" << itm->
dim( j ) <<
endmsg;
294 log <<
"Tuple item " << nam <<
" has different index colums " << src_id <<
":" << src_itm->
hasIndex()
300 log <<
"Tuple item " << nam <<
" has different index colums " << src_id <<
":" << src_itm->
index()
301 <<
" <-> " << clone_id <<
":" << itm->
index() <<
endmsg;
321 size_t k = 0, nentry = 0;
324 for ( k = 0; k < source_items.
size(); ++k ) {
329 while ( status.isSuccess() ) {
331 if ( status.isSuccess() ) {
332 INTuple::ItemContainer::const_iterator i;
334 for ( k = 0, i = source_items.
begin(); i != source_items.
end(); ++i, ++k ) {
338 switch ( ( *i )->type() ) {
340 size =
sizeof(
unsigned char );
343 size =
sizeof(
unsigned short );
346 size =
sizeof(
unsigned int );
349 size =
sizeof(
unsigned long );
352 size =
sizeof( char );
355 size =
sizeof( short );
358 size =
sizeof( int );
361 size =
sizeof( long );
364 size =
sizeof( bool );
367 size =
sizeof( float );
370 size =
sizeof( double );
377 size = ::strlen( (
const char*)src_itm->
buffer() ) + 1;
380 *(
void**)out_itm->
buffer() = *(
void**)src_itm->
buffer();
399 if ( !status.isSuccess() ) {
400 log <<
MSG::ERROR <<
"Failed to write record " << nentry <<
" from " << input <<
" to " << m_outName
405 log <<
MSG::INFO <<
"End of reading tuple " << input <<
" after " << nentry <<
" entries." <<
endmsg;
407 if ( nentry > 0 || m_selectorName !=
"" ) {
421 for (
size_t i = 0; i <
m_inputs.size(); ++i ) {
423 if ( !( 0 == nt ) ) {
432 }
else if ( m_selectorName !=
"" ) {
436 nt->attachSelector( stmt );
456 for (
const auto& input :
m_inputs ) {
Parse attribute strings allowing iteration over the various attributes.
virtual const std::string & name() const =0
Access _Item name.
std::string m_criteria
Selection criteria (if any)
Definition of the MsgStream class used to transmit messages.
virtual const ItemRange & range() const =0
Access the range if specified.
const std::string & name() const override
The identifying name of the algorithm object.
StatusCode execute() override
Execute procedure.
Implementation of property with value of concrete type.
virtual StatusCode book(const NTuple::Tuple *nt)
Book the N-tuple according to the specification.
StatusCode initialize() override
Initialize.
bool isSuccess() const
Test for a status code of SUCCESS.
virtual StatusCode add(INTupleItem *item)=0
Add an item row to the N tuple.
~CollectionCloneAlg() override=default
Standard Destructor.
Gaudi::Property< std::vector< std::string > > m_inputs
IRegistry * registry() const
Get pointer to Registry.
static _Array * create(INTuple *tup, const std::string &name, const std::type_info &info, const std::string &index, long len, TYP min, TYP max, TYP def)
Create instance.
#define DECLARE_COMPONENT(type)
SmartIF< INTupleSvc > m_dataSvc
Reference to data provider service.
StatusCode mergeEntries(const std::string &input)
Merge the entries of a single input tuple into the output.
NTuple interface class definition.
TYPE * get() const
Get interface pointer.
virtual std::string typeName() const =0
Proper type name of the object.
virtual long ndim() const =0
Dimension.
NTuple interface class definition.
virtual const CLID & clID() const
Retrieve reference to class definition structure.
virtual const id_type & identifier() const =0
Full identifier (or key)
virtual INTupleItem * indexItem()=0
Pointer to index column (if present, 0 else)
virtual long length() const =0
Access the buffer length.
This class is used for returning status codes from appropriate routines.
virtual StatusCode writeRecord(NTuple::Tuple *tuple)=0
Write single record to N tuple.
std::string m_outName
Output tuple name.
StatusCode mergeInputTuples()
Merge all N-tuple entries.
Abstract class describing basic data in an Ntuple.
virtual StatusCode checkInput(const NTuple::Tuple *clone, const NTuple::Tuple *src)
virtual long type() const =0
Type information of the item.
Algorithm(const std::string &name, ISvcLocator *svcloc, const std::string &version=PACKAGE_VERSION)
Constructor.
SmartIF< ISvcLocator > & serviceLocator() const override
The standard service locator.
std::string m_rootName
Name of the root leaf (obtained at initialize)
Abstract base class which allows the user to interact with the actual N tuple implementation.
virtual const void * buffer() const =0
Access data buffer (CONST)
StatusCode finalize() override
Finalize.
Base class from which all concrete algorithm classes should be derived.
StatusCode connect()
Connect input and output N-tuples.
virtual const std::string & index() const =0
Access the index _Item.
double fun(const std::vector< double > &x)
Gaudi::Property< std::string > m_output
Small algorithm, which allows to merge N-tuples in a generic way.
Gaudi::Property< std::string > m_tupleSvc
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...
SmartIF< IMessageSvc > & msgSvc() const
The standard message service.
virtual long dim(long i) const =0
Access individual dimensions.
void reset(TYPE *ptr=nullptr)
Set the internal pointer to the passed one disposing of the old one.
virtual ItemContainer & items()=0
Access item container.
static _Item * create(INTuple *tup, const std::string &name, const std::type_info &info, TYP min, TYP max, TYP def)
Create instance.
virtual bool hasIndex() const =0
Is the tuple have an index item?
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.
Opaque address interface definition.
const std::string & type() const override
The type of the algorithm object.
virtual const INTupleItem * find(const std::string &name) const =0
Find an item row of the Ntuple (CONST)
std::string m_selectorName
Selector factory.
virtual void setCriteria(const std::string &crit)=0
Set the type.
virtual const std::string & title() const =0
Object title.
void toupper(std::string &s)
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
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.
static _Matrix * create(INTuple *tup, const std::string &name, const std::type_info &info, const std::string &index, long ncol, long nrow, TYP min, TYP max, TYP def)
Create instance.