template<class ITEM>
class Tuples::TupleColumn< ITEM >
Helper class which allows to extend the functionality of Tuple with possibility to use your own representation of complex objects.
It allows to extend the functionality of Tuples::Tuple and Tuples::TupleObj classes for your own needs, according to your own taste and without touching the classes at all. Neither the extension or the functionality through inheritance nor the extension through aggregation is used. One use the trick with template specialization of streamer operators.
Assuming one need to add into private code the N-Tuple representation of e.g. MyClass class
class MyClass
{
...
double field1() const ;
double field2() const ;
long field3() const ;
bool field4() const ;
};
template <>
{
if( !tuple.valid() ) { return tuple ;}
tuple->
column( item.name() +
"field1" , item.value().field1() );
tuple->column( item.name() + "field2" , item.value().field2() );
tuple->column( item.name() + "field3" , item.value().field3() );
tuple->column( item.name() + "field4" , item.value().field4() );
return tuple ;
}
MyClass a = ... ;
Alternatively one can use function Tuples::Column
MyClass a1 = ... ;
MyClass a2 = ... ;
MyClass a3 = ... ;
Using this technique one can put 'any' object into NTuple and create the own representation. E.g. if the 'standard' representation of HepLorentzVector is not suitable one can create the alternative representation.
Also one can create own representations of complex classes, e.g. class MCParticle :
template <>
{
if( !tuple.valid() ) { return tuple ;}
const MCParticle* mcp = item.value() ;
tuple->
column( item.name() +
"Mom" , mcp->momentum() ) ;
tuple->column( item.name() + "PID" , mcp->particleID().pid() ) ;
tuple->column( item.name() + "hasVX" , 0 != mcp->originVertex() ) ;
};
const MCParticle* mcp = ... ;
- Author
- Vanya BELYAEV Ivan..nosp@m.Bely.nosp@m.aev@i.nosp@m.tep..nosp@m.ru
Definition at line 257 of file Tuple.h.