Go to the documentation of this file.
12 #ifndef GAUDIALG_TUPLEOBJ_H
13 #define GAUDIALG_TUPLEOBJ_H 1
41 #include "Math/Point3D.h"
42 #include "Math/SMatrix.h"
43 #include "Math/SVector.h"
44 #include "Math/Vector3D.h"
45 #include "Math/Vector4D.h"
73 template <
typename Arg>
75 return T( std::forward<Arg>( i ) );
80 template <
typename Iterator>
81 using const_ref_t = std::add_const_t<typename std::iterator_traits<Iterator>::reference>;
694 unsigned long long maxv );
796 template <
typename Value,
typename... Args>
800 this->
column( std::get<0>(
args ), std::invoke( std::get<1>(
args ), value ) )...};
885 template <
typename ITERATOR1,
typename ITERATOR2>
888 return farray(
name,
detail::to_float, std::forward<ITERATOR1>( first ), std::forward<ITERATOR2>( last ), length,
934 template <
class DATA>
1001 template <
class FUNCTION,
class ITERATOR>
1009 Warning(
"farray('" +
name +
"'): array is overflow, skip extra entries" )
1015 Int* len =
ints( length, 0, maxv );
1027 [&](
auto&& i ) {
return std::invoke(
function,
std::forward<decltype( i )>( i ) ); } );
1059 template <
typename FunIterator,
typename DataIterator>
1070 [](
std::ostream& os,
const auto& i ) -> decltype(
auto ) {
return os << i.first; } );
1071 Warning(
"farray('" + os.str() +
"'): array overflow, skipping extra entries" ).ignore();
1076 Int* len =
ints( length, 0, maxv );
1086 [&](
const auto& item ) {
return this->fArray( item.first, len ); } );
1092 for (
size_t index = 0; first != last; ++first, ++index ) {
1093 auto item = first_item;
1094 for (
auto& var : vars ) { ( *var )[index] = std::invoke( ( item++ )->
second, *first ); }
1103 typename = std::enable_if_t<!std::is_convertible_v<Container<NamedFunction>,
std::string>>>
1104 StatusCode farray(
const Container<NamedFunction>& funs, DataIterator first, DataIterator last,
1106 return farray_impl( funs.begin(), funs.end(), std::forward<DataIterator>( first ),
1107 std::forward<DataIterator>( last ), length, maxv );
1110 template <
typename NamedFunctions,
typename DataIterator,
1111 typename = std::enable_if_t<!std::is_convertible_v<NamedFunctions, std::string>>>
1114 return farray_impl( funs.begin(), funs.end(), std::forward<DataIterator>( first ),
1115 std::forward<DataIterator>( last ), length, maxv );
1149 template <
class FUNC1,
class FUNC2,
class Iterator>
1152 return farray( {{name1,
std::cref( func1 )}, {name2,
std::cref( func2 )}}, std::forward<Iterator>( first ),
1153 std::forward<Iterator>( last ), length, maxv );
1192 template <
class FUNC1,
class FUNC2,
class FUNC3,
class Iterator>
1197 std::forward<Iterator>( first ), std::forward<Iterator>( last ), length, maxv );
1239 template <
class FUNC1,
class FUNC2,
class FUNC3,
class FUNC4,
class Iterator>
1243 return farray( {{name1,
std::cref( func1 )},
1247 std::forward<Iterator>( first ), std::forward<Iterator>( last ), length, maxv );
1302 template <
class MATRIX>
1309 if ( rows >= maxv ) {
1310 Warning(
"fmatrix('" +
name +
"'): matrix is overflow, skip extra items" ).ignore();
1311 rows = ( 0 < maxv ) ? ( maxv - 1 ) : 0;
1315 Int* len =
ints( length, 0, maxv );
1326 for (
size_t iCol = 0; iCol < cols; ++iCol ) {
1327 for (
MIndex iRow = 0; iRow < rows; ++iRow ) { ( *var )[iRow][iCol] = data[iRow][iCol]; }
1369 template <
class DATA>
1376 if ( first + maxv < last ) {
1377 Warning(
"fmatrix('" +
name +
"'): matrix is overflow, skip extra items" ).ignore();
1378 last = first + maxv;
1382 Int* len =
ints( length, 0, maxv );
1386 *len = last - first;
1394 for ( ; first != last; ++first ) {
1396 for (
MIndex iCol = 0; iCol < cols; ++iCol ) { ( *var )[iRow][iCol] = ( *first )[iCol]; }
1482 template <
class FUN,
class DATA>
1490 Warning(
"fmatrix('" +
name +
"'): matrix is overflow, skip extra items" ).ignore();
1495 Int* len =
ints( length, 0, maxv );
1509 for ( ; first != last; ++first ) {
1511 for ( FUN fun = funF; fun < funL; ++fun ) { ( *var )[iRow][fun - funF] = std::invoke( *fun, *first ); }
1543 template <
class DATA>
1601 template <
class ARRAY>
1607 auto first =
begin( data );
1641 template <
class ARRAY>
1698 template <
class MATRIX>
1708 for (
size_t iCol = 0; iCol < cols; ++iCol ) {
1709 for (
size_t iRow = 0; iRow < rows; ++iRow ) { ( *var )[iRow][iCol] = data[iRow][iCol]; }
1732 template <
class TYPE>
1756 template <
class TYPE,
class TAG>
1779 template <
class TYPE,
class TAG>
1794 template <
class TYPE,
unsigned int D1,
unsigned int D2,
class REP>
1804 for (
size_t iCol = 0; iCol < D2; ++iCol ) {
1805 for (
size_t iRow = 0; iRow < D1; ++iRow ) { ( *var )[iRow][iCol] = mtrx( iRow, iCol ); }
1828 template <
class KEY,
class VALUE>
1830 const std::string& length,
const size_t maxv = 100 ) {
1832 static const std::array<float ( * )(
const Info& ), 2> fns = {
1833 {[](
const Info& i ) ->
float {
return i.first; }, [](
const Info& i ) ->
float {
return i.second; }}};
1846 template <
class TYPE>
1876 bool columnWise()
const {
return CLID_ColumnWiseTuple == clid(); }
1879 bool rowWise()
const {
return CLID_RowWiseTuple == clid(); }
1885 bool valid()
const {
return 0 != tuple(); }
1955 size_t m_refCount = 0;
1958 template <
typename T>
2023 #endif // GAUDIALG_TUPLEOBJ_H
Tuples::Type m_type
tuple 'type'
NTuple::Item< IOpaqueAddress * > Address
basic type for address items
Address * addresses(const std::string &name)
get the column
StatusCode column(const std::string &name, const ROOT::Math::LorentzVector< TYPE > &v)
Useful shortcut to put LorentzVector directly into N-Tuple:
Tuples::Type type() const
accessor to the N-Tuple type
StatusCode matrix(const std::string &name, const ROOT::Math::SMatrix< TYPE, D1, D2, REP > &mtrx)
shortcut to put Smatrix into N-tuple:
StatusCode columns(Value &&value, Args &&... args)
Set the values for several columns simultaneously, for the same object Non-existing columns will be a...
ColumnStorage< Short > m_shorts
the actual storage of all 'Int' columns
ColumnStorage< FMatrix > m_fmatrices
the actual storage of all 'FArray' columns
NTuple::Item< unsigned long long > ULongLong
basic type for unsigned long long items
const NTuple::Tuple * tuple() const
provide the access to underlying Gaudi N-tuple
NTuple::Item< short > Short
basic type for int items
virtual StatusCode Error(const std::string &msg, const StatusCode sc=StatusCode::FAILURE) const =0
ColumnStorage< FArray > m_arraysf
the actual storage of all 'FArray' columns (fixed)
NTuple::Array< float > FArray
basic type for array of floats
T back_inserter(T... args)
bool evtColType() const
Event collection ?
NTuple::Item< float > Float
basic type for float items
bool goodItem(const std::string &name) const
check the uniqueness of the name
StatusCode column(const std::string &name, const ROOT::Math::PositionVector3D< TYPE, TAG > &v)
Useful shortcut to put 3D-Vector directly into N-Tuple:
T operator()(Arg &&i) const
unsigned long code_t
type of StatusCode value
ColumnStorage< Float > m_floats
the actual storage of all 'Float' columns
NTuple::Item< char > Char
basic type for int items
std::map< std::string, std::string > ItemMap
NTuple::Item< double > Double
basic type for double items
StatusCode fmatrix(const std::string &name, FUN funF, FUN funL, DATA first, DATA last, const std::string &length, size_t maxv)
fill N-Tuple with matrix of "direct-product" of "data-vector" [first,last) and "function-vector" [fun...
ColumnStorage< Bool > m_bools
the actual storage of all 'bool' columns
StatusCode farray(const NamedFunctions &funs, DataIterator first, DataIterator last, const std::string &length, size_t maxv)
ColumnStorage< FMatrix > m_matricesf
the actual storage of all 'FMatrix' columns (fixed)
A simple wrapper class over standard Gaudi NTuple::Tuple facility.
TupleObj(const TupleObj &)=delete
delete the copy constructor and assignment
StatusCode farray(const std::string &name1, const FUNC1 &func1, const std::string &name2, const FUNC2 &func2, const std::string &name3, const FUNC3 &func3, const std::string &name4, const FUNC4 &func4, Iterator &&first, Iterator &&last, const std::string &length, size_t maxv)
Put four functions from one data array into LoKi-style N-Tuple simultaneously (effective!...
StatusCode array(const std::string &name, const ARRAY &data, const MIndex &length)
fill N-Tuple with fixed-size array
ItemMap m_items
all booked types:
NTuple::Tuple * tuple()
provide the access to underlying Gaudi N-tuple
NTuple::Item< unsigned int > UInt
basic type for unsigned int items
double * begin(CLHEP::HepVector &v)
StatusCode farray(const Container< NamedFunction > &funs, DataIterator first, DataIterator last, const std::string &length, size_t maxv)
StatusCode farray_impl(FunIterator first_item, FunIterator last_item, DataIterator first, DataIterator last, const std::string &length, size_t maxv)
Put arbitrary number of functions from one data array into LoKi-style N-Tuple simultaneously (effecti...
StatusCode column(const std::string &name, signed char value)
Set the value for the selected tuple column.
bool valid() const
valid pointer to tuple ?
unsigned int CLID
Class ID definition.
GAUDI_API std::string format(const char *,...)
MsgStream format utility "a la sprintf(...)".
StatusCode fmatrix(const std::string &name, const MATRIX &data, size_t rows, const MIndex &cols, const std::string &length, size_t maxv)
Fill N-Tuple with data from variable-size matrix.
ColumnStorage< Address > m_addresses
the actual storage of all 'Address' columns
StatusCode farray(const std::string &name, ITERATOR1 &&first, ITERATOR2 &&last, const std::string &length, size_t maxv)
Add an indexed array (of type float) to N-tuple.
StatusCode farray(const std::string &name, const FUNCTION &function, ITERATOR first, ITERATOR last, const std::string &length, size_t maxv)
Put an indexed array into LoKi-style N-Tuple.
constexpr to_< float > to_float
StatusCode matrix(const std::string &name, const MATRIX &data, const MIndex &rows, const MIndex &cols)
fill N-Tuple with fixed-size matrix
StatusCode farray(const std::string &name, const DATA &data, const std::string &length, const size_t maxv)
Add an indexed array (of type float) to N-tuple.
NTuple::Matrix< float > FMatrix
basic type for matrix of floats
ColumnStorage< LongLong > m_longlongs
the actual storage of all 'long long' columns
ColumnStorage< UShort > m_ushorts
the actual storage of all 'unsigned int' columns
const StatusCode & ignore() const
Allow discarding a StatusCode without warning.
Class acting as a smart pointer holding a N tuple _Item.
ColumnStorage< FArray > m_farrays
the actual storage of all 'FArray' columns
bool addItem(std::string name, std::string type)
add the item name into the list of known items
NTuple::Item< bool > Bool
basic type for int items
const CLID & clid() const
accessor to the N-Tuple CLID
ColumnStorage< Double > m_doubles
the actual storage of all 'Double' columns
virtual StatusCode Warning(const std::string &msg, const StatusCode sc=StatusCode::FAILURE) const =0
ColumnStorage< Int > m_ints
the actual storage of all 'Int' columns
StatusCode farray(const std::string &name1, const FUNC1 &func1, const std::string &name2, const FUNC2 &func2, Iterator &&first, Iterator &&last, const std::string &length, size_t maxv)
Put two functions from one data array into LoKi-style N-Tuple simultaneously (effective!...
ColumnStorage< ULongLong > m_ulonglongs
the actual storage of all 'unsigned long long' columns
#define STATUSCODE_ENUM_DECL(ENUM)
Declare an enum to be used as StatusCode value.
constexpr static const auto SUCCESS
bool invalid() const
invalid pointer to tuple ?
struct GAUDI_API array
Parametrisation class for redirection array - like implementation.
Abstract base class which allows the user to interact with the actual N tuple implementation.
StatusCode array(const std::string &name, const ARRAY &data)
fill N-Tuple with fixed-size array
std::add_const_t< typename std::iterator_traits< Iterator >::reference > const_ref_t
StatusCode column(const std::string &name, const ROOT::Math::DisplacementVector3D< TYPE, TAG > &v)
Useful shortcut to put 3D-Vector directly into N-Tuple:
ColumnStorage< UChar > m_uchars
the actual storage of all 'unsigned int' columns
StatusCode array(const std::string &name, DATA first, DATA last)
fill N-Tuple with fixed-size array
NTuple::Tuple * m_tuple
tuple itself
const ItemMap & items() const
get the full list of booked items
StatusCode fmatrix(const std::string &name, const GaudiUtils::VectorMap< KEY, VALUE > &info, const std::string &length, const size_t maxv=100)
shortcut to put "ExtraInfo" fields of major into N-Tuple
ColumnStorage< UInt > m_uints
the actual storage of all 'unsigned int' columns
bool rowWise() const
row wise NTuple ?
TupleObj & operator=(const TupleObj &)=delete
GAUDI_API void fill(AIDA::IHistogram1D *histo, const double value, const double weight=1.0)
simple function to fill AIDA::IHistogram1D objects
Specialization acting as a smart pointer holding a N tuple _Item.
constexpr static const auto FAILURE
NTuple::Item< int > Int
basic type for int items
NTuple::Item< unsigned char > UChar
basic type for unsigned int items
bool columnWise() const
column wise NTuple ?
StatusCode fmatrix(const std::string &name, DATA first, DATA last, const MIndex &cols, const std::string &length, size_t maxv)
Fill N-Tuple with data from variable-size matrix.
NTuple::Item< unsigned short > UShort
basic type for unsigned int items
ColumnStorage< Char > m_chars
the actual storage of all 'Int' columns
StatusCode farray(const std::string &name1, const FUNC1 &func1, const std::string &name2, const FUNC2 &func2, const std::string &name3, const FUNC3 &func3, Iterator &&first, Iterator &&last, const std::string &length, size_t maxv)
Put three functions from one data array into LoKi-style N-Tuple simultaneously (effective!...
NTuple::Item< long long > LongLong
basic type for unsigned long long items
const std::string & name() const
get the name
auto put(const DataObjectHandle< Out1 > &out_handle, Out2 &&out)
Stream & ostream_joiner(Stream &os, Iterator first, Iterator last, Separator sep, OutputElement output=OutputElement{})
Class acting as a smart pointer holding a N tuple _Item.
boost::spirit::classic::position_iterator2< ForwardIterator > Iterator