36#pragma GCC diagnostic push
37#pragma GCC diagnostic ignored "-Wnull-dereference"
39 assert( it !=
nullptr );
41#pragma GCC diagnostic pop
51 long ndim = source->
ndim();
52 const std::string&
name = source->
name();
54 long dim[4], idxLen = 0;
55 long dim1 = 1, dim2 = 1;
57 for (
int i = 0; i < ndim; i++ ) dim[i] = source->
dim( i );
61 idxName =
index->name();
62 switch (
index->type() ) {
64 idxLen = upper<unsigned char>( index );
67 idxLen = upper<unsigned short>( index );
70 idxLen = upper<unsigned int>( index );
73 idxLen = upper<unsigned long>( index );
76 idxLen = upper<char>( index );
79 idxLen = upper<short>( index );
82 idxLen = upper<int>( index );
85 idxLen = upper<long>( index );
97 dim1 = ( hasIdx ) ? idxLen : dim[0];
101 dim1 = ( hasIdx ) ? idxLen : dim[0];
102 dim2 = ( hasIdx ) ? dim[0] : dim[1];
108 return tuple->
add( it );
157 for (
auto attrib : Parser(
m_output ) ) {
166 fun = std::move( attrib.value );
177 if ( !
m_criteria.empty() && fun.empty() ) fun =
"NTuple::Selector";
200 for (
const auto& i : nt->
items() ) {
201 switch ( i->type() ) {
203 status = createItem<unsigned char>( log, tuple, i, 0 );
206 status = createItem<unsigned short>( log, tuple, i, 0 );
209 status = createItem<unsigned int>( log, tuple, i, 0 );
212 status = createItem<unsigned long>( log, tuple, i, 0 );
215 status = createItem<char>( log, tuple, i, 0 );
218 status = createItem<short>( log, tuple, i, 0 );
221 status = createItem<int>( log, tuple, i, 0 );
224 status = createItem<long>( log, tuple, i, 0 );
227 status = createItem( log, tuple, i,
false );
230 status = createItem<float>( log, tuple, i, 0 );
233 status = createItem<double>( log, tuple, i, 0 );
236 status = createItem<IOpaqueAddress*>( log, tuple, i,
nullptr );
239 status = createItem<void*>( log, tuple, i,
nullptr );
259 if ( clone && src ) {
265 for (
auto i = clone_items.begin(); i != clone_items.end(); ++i ) {
267 const std::string& nam = itm->
name();
270 log <<
"Tuple item " << nam <<
" not present in " << src_id <<
endmsg;
273 if ( itm->
type() != src_itm->
type() ) {
274 log <<
"Tuple item " << nam <<
" are of different types in " << src_id <<
":" << src_itm->
typeName()
278 if ( itm->
ndim() != src_itm->
ndim() ) {
279 log <<
"Tuple item " << nam <<
" have different dimensions in " << src_id <<
":" << src_itm->
ndim() <<
" <-> "
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;
291 log <<
"Tuple item " << nam <<
" has different index colums " << src_id <<
":" << src_itm->
hasIndex()
297 log <<
"Tuple item " << nam <<
" has different index colums " << src_id <<
":" << src_itm->
index()
298 <<
" <-> " << clone_id <<
":" << itm->
index() <<
endmsg;
314 std::vector<GenericAddress> addrVector( clone_items.size() );
317 size_t k = 0, nentry = 0;
320 for ( k = 0; k < source_items.size(); ++k ) {
328 INTuple::ItemContainer::const_iterator i;
330 for ( k = 0, i = source_items.begin(); i != source_items.end(); ++i, ++k ) {
334 switch ( ( *i )->type() ) {
336 size =
sizeof(
unsigned char );
339 size =
sizeof(
unsigned short );
342 size =
sizeof(
unsigned int );
345 size =
sizeof(
unsigned long );
348 size =
sizeof( char );
351 size =
sizeof( short );
354 size =
sizeof( int );
357 size =
sizeof( long );
360 size =
sizeof( bool );
363 size =
sizeof( float );
366 size =
sizeof( double );
369 *(std::string*)out_itm->
buffer() = *(std::string*)src_itm->
buffer();
373 size = ::strlen( (
const char*)src_itm->
buffer() ) + 1;
376 *(
void**)out_itm->
buffer() = *(
void**)src_itm->
buffer();
391 ::memcpy(
const_cast<void*
>( out_itm->
buffer() ), src_itm->
buffer(), size * src_itm->
length() );
394 status =
m_dataSvc->writeRecord( out.ptr() );
396 log <<
MSG::ERROR <<
"Failed to write record " << nentry <<
" from " << input <<
" to " <<
m_outName
401 log <<
MSG::INFO <<
"End of reading tuple " << input <<
" after " << nentry <<
" entries." <<
endmsg;
414 for (
size_t i = 0; i <
m_inputs.size(); ++i ) {
416 if ( !( 0 == nt ) ) {
429 nt->attachSelector( stmt ).ignore( );
448 for (
const auto& input :
m_inputs ) {
void toupper(std::string &s)
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
SmartDataPtr< NTuple::Tuple > NTuplePtr
#define DECLARE_COMPONENT(type)
Small algorithm, which allows to merge N-tuples in a generic way.
StatusCode connect()
Connect input and output N-tuples.
StatusCode execute() override
Execute procedure.
StatusCode mergeEntries(const std::string &input)
Merge the entries of a single input tuple into the output.
virtual StatusCode book(const NTuple::Tuple *nt)
Book the N-tuple according to the specification.
std::string m_criteria
Selection criteria (if any)
std::string m_selectorName
Selector factory.
std::string m_rootName
Name of the root leaf (obtained at initialize)
Gaudi::Property< std::vector< std::string > > m_inputs
StatusCode initialize() override
Initialize.
Gaudi::Property< std::string > m_output
virtual StatusCode checkInput(const NTuple::Tuple *clone, const NTuple::Tuple *src)
StatusCode mergeInputTuples()
Merge all N-tuple entries.
StatusCode finalize() override
Finalize.
SmartIF< INTupleSvc > m_dataSvc
Reference to data provider service.
Gaudi::Property< std::string > m_tupleSvc
std::string m_outName
Output tuple name.
const SmartIF< IMessageSvc > & msgSvc() const
The standard message service.
IRegistry * registry() const
Get pointer to Registry.
virtual const CLID & clID() const
Retrieve reference to class definition structure.
Algorithm(std::string name, ISvcLocator *svcloc, std::string version=PACKAGE_VERSION)
Constructor.
SmartIF< ISvcLocator > & serviceLocator() const override
The standard service locator.
const std::string & name() const override
The identifying name of the algorithm object.
const std::string & type() const override
The type of the algorithm object.
SmartIF< IService > service(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")
Implementation of property with value of concrete type.
Parse attribute strings allowing iteration over the various attributes.
NTuple interface class definition.
std::vector< INTupleItem * > ItemContainer
virtual const INTupleItem * find(const std::string &name) const =0
Find an item row of the Ntuple (CONST)
virtual ItemContainer & items()=0
Access item container.
virtual StatusCode add(INTupleItem *item)=0
Add an item row to the N tuple.
virtual const std::string & title() const =0
Object title.
NTuple interface class definition.
virtual long ndim() const =0
Dimension.
virtual const void * buffer() const =0
Access data buffer (CONST)
virtual long dim(long i) const =0
Access individual dimensions.
virtual const std::string & index() const =0
Access the index _Item.
virtual std::string typeName() const =0
Proper type name of the object.
virtual long type() const =0
Type information of the item.
virtual long length() const =0
Access the buffer length.
virtual INTupleItem * indexItem()=0
Pointer to index column (if present, 0 else)
virtual const std::string & name() const =0
Access _Item name.
virtual bool hasIndex() const =0
Is the tuple have an index item?
Opaque address interface definition.
virtual const id_type & identifier() const =0
Full identifier (or key)
Definition of the MsgStream class used to transmit messages.
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.
Abstract class describing basic data in an Ntuple.
virtual const ItemRange & range() const =0
Access the range if specified.
static _Item * create(INTuple *tup, const std::string &name, const std::type_info &info, TYP min, TYP max, TYP def)
Create instance.
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.
TYP lower() const
Lower boundary of range.
TYP upper() const
Upper boundary of range.
Abstract base class which allows the user to interact with the actual N tuple implementation.
TYPE * ptr()
Automatic conversion to data type.
Small smart pointer class with automatic reference counting for IInterface.
This class is used for returning status codes from appropriate routines.
constexpr static const auto SUCCESS
constexpr static const auto FAILURE
size_t index(const Gaudi::ParticleProperty *property, const Gaudi::Interfaces::IParticlePropertySvc *service)
helper utility for mapping of Gaudi::ParticleProperty object into non-negative integral sequential id...