26 #pragma GCC diagnostic push 27 #pragma GCC diagnostic ignored "-Wnull-dereference" 29 assert( it !=
nullptr );
30 return it->
range().upper();
31 #pragma GCC diagnostic pop 38 TYP low = source->
range().lower();
39 TYP high = source->
range().upper();
41 long ndim = source->
ndim();
44 long dim[4], idxLen = 0;
45 long dim1 = 1, dim2 = 1;
47 for (
int i = 0; i < ndim; i++ ) dim[i] = source->
dim( i );
51 idxName = index->
name();
52 switch ( index->
type() ) {
54 idxLen = upper<unsigned char>( index );
57 idxLen = upper<unsigned short>( index );
60 idxLen = upper<unsigned int>( index );
63 idxLen = upper<unsigned long>( index );
66 idxLen = upper<char>( index );
69 idxLen = upper<short>( index );
72 idxLen = upper<int>( index );
75 idxLen = upper<long>( index );
78 log <<
MSG::ERROR <<
"Column " << idxName <<
" is not a valid index column!" <<
endmsg;
87 dim1 = ( hasIdx ) ? idxLen : dim[0];
91 dim1 = ( hasIdx ) ? idxLen : dim[0];
92 dim2 = ( hasIdx ) ? dim[0] : dim[1];
98 return tuple->
add( it );
147 for (
auto attrib : Parser(
m_output ) ) {
148 switch ( ::
toupper( attrib.tag[0] ) ) {
162 if ( m_outName.
empty() ) {
167 if ( !m_criteria.
empty() && fun.
empty() ) fun =
"NTuple::Selector";
168 m_selectorName =
fun;
190 for (
const auto& i : nt->
items() ) {
191 switch ( i->type() ) {
193 status = createItem<unsigned char>(
log, tuple, i, 0 );
196 status = createItem<unsigned short>(
log, tuple, i, 0 );
199 status = createItem<unsigned int>(
log, tuple, i, 0 );
202 status = createItem<unsigned long>(
log, tuple, i, 0 );
205 status = createItem<char>(
log, tuple, i, 0 );
208 status = createItem<short>(
log, tuple, i, 0 );
211 status = createItem<int>(
log, tuple, i, 0 );
214 status = createItem<long>(
log, tuple, i, 0 );
217 status = createItem( log, tuple, i,
false );
220 status = createItem<float>(
log, tuple, i, 0 );
223 status = createItem<double>(
log, tuple, i, 0 );
226 status = createItem<IOpaqueAddress*>(
log, tuple, i, nullptr );
229 status = createItem<void*>(
log, tuple, i, nullptr );
249 if ( clone && src ) {
255 for (
auto i = clone_items.
begin(); i != clone_items.
end(); ++i ) {
260 log <<
"Tuple item " << nam <<
" not present in " << src_id <<
endmsg;
263 if ( itm->
type() != src_itm->
type() ) {
264 log <<
"Tuple item " << nam <<
" are of different types in " << src_id <<
":" << src_itm->
typeName()
268 if ( itm->
ndim() != src_itm->
ndim() ) {
269 log <<
"Tuple item " << nam <<
" have different dimensions in " << src_id <<
":" << src_itm->
ndim() <<
" <-> " 273 for (
int j = 0; j < itm->
ndim(); ++j ) {
274 if ( src_itm->
dim( j ) != itm->
dim( j ) ) {
275 log <<
"Tuple item " << nam <<
" have different dimensions in " << src_id <<
"[" << j
276 <<
"]:" << src_itm->
dim( j ) <<
" <-> " << clone_id <<
"[" << j <<
"]:" << itm->
dim( j ) <<
endmsg;
281 log <<
"Tuple item " << nam <<
" has different index colums " << src_id <<
":" << src_itm->
hasIndex()
287 log <<
"Tuple item " << nam <<
" has different index colums " << src_id <<
":" << src_itm->
index()
288 <<
" <-> " << clone_id <<
":" << itm->
index() <<
endmsg;
307 size_t k = 0, nentry = 0;
310 for ( k = 0; k < source_items.
size(); ++k ) {
315 while ( status.isSuccess() ) {
317 if ( status.isSuccess() ) {
318 INTuple::ItemContainer::const_iterator i;
320 for ( k = 0, i = source_items.
begin(); i != source_items.
end(); ++i, ++k ) {
324 switch ( ( *i )->type() ) {
326 size =
sizeof(
unsigned char );
329 size =
sizeof(
unsigned short );
332 size =
sizeof(
unsigned int );
335 size =
sizeof(
unsigned long );
338 size =
sizeof( char );
341 size =
sizeof( short );
344 size =
sizeof( int );
347 size =
sizeof( long );
350 size =
sizeof( bool );
353 size =
sizeof( float );
356 size =
sizeof( double );
363 size = ::strlen( (
const char*)src_itm->
buffer() ) + 1;
366 *(
void**)out_itm->
buffer() = *(
void**)src_itm->
buffer();
381 ::memcpy( const_cast<void*>( out_itm->
buffer() ), src_itm->
buffer(), size * src_itm->
length() );
385 if ( !status.isSuccess() ) {
386 log <<
MSG::ERROR <<
"Failed to write record " << nentry <<
" from " << input <<
" to " << m_outName
391 log <<
MSG::INFO <<
"End of reading tuple " << input <<
" after " << nentry <<
" entries." <<
endmsg;
404 for (
size_t i = 0; i <
m_inputs.size(); ++i ) {
406 if ( !( 0 == nt ) ) {
415 }
else if ( m_selectorName !=
"" ) {
419 nt->attachSelector( stmt );
438 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.
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.
const std::string & name() const override
The identifying name of the algorithm object.
StatusCode initialize() override
Initialize.
Algorithm(const std::string &name, ISvcLocator *svcloc, const std::string &version=PACKAGE_VERSION)
Constructor.
virtual StatusCode add(INTupleItem *item)=0
Add an item row to the N tuple.
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.
constexpr static const auto SUCCESS
Gaudi::Property< std::vector< std::string > > m_inputs
IRegistry * registry() const
Get pointer to Registry.
constexpr auto size(const C &c) noexcept(noexcept(c.size())) -> decltype(c.size())
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.
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.
#define DECLARE_COMPONENT(type)
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.
const SmartIF< IMessageSvc > & msgSvc() const
The standard message service.
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.
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.
const std::string & type() const override
The type of the algorithm object.
virtual const void * buffer() const =0
Access data buffer (CONST)
StatusCode finalize() override
Finalize.
Alias for backward compatibility.
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...
constexpr static const auto FAILURE
SmartIF< ISvcLocator > & serviceLocator() const override
The standard service locator.
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?
Opaque address interface definition.
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.