2 #ifndef GAUDIALG_TUPLEOBJ_H 3 #define GAUDIALG_TUPLEOBJ_H 1 31 #include "Math/Point3D.h" 32 #include "Math/SMatrix.h" 33 #include "Math/SVector.h" 34 #include "Math/Vector3D.h" 35 #include "Math/Vector4D.h" 63 template <
typename Arg>
65 return T( std::forward<Arg>( i ) );
70 template <
typename Iterator>
71 using const_ref_t = std::add_const_t<typename std::iterator_traits<Iterator>::reference>;
684 unsigned long long maxv );
786 template <
typename Value,
typename... Args>
790 this->
column( std::get<0>(
args ), std::invoke( std::get<1>(
args ), value ) )...};
875 template <
typename ITERATOR1,
typename ITERATOR2>
878 return farray(
name,
detail::to_float, std::forward<ITERATOR1>( first ), std::forward<ITERATOR2>( last ), length,
924 template <
class DATA>
991 template <
class FUNCTION,
class ITERATOR>
998 if (
std::distance( first, last ) > static_cast<std::ptrdiff_t>( maxv ) ) {
999 Warning(
"farray('" +
name +
"'): array is overflow, skip extra entries" );
1004 Int* len = ints( length, 0, maxv );
1016 [&](
auto&& i ) {
return std::invoke(
function,
std::forward<decltype( i )>( i ) ); } );
1048 template <
typename FunIterator,
typename DataIterator>
1055 if (
std::distance( first, last ) > static_cast<std::ptrdiff_t>( maxv ) ) {
1059 [](
std::ostream& os,
const auto& i ) -> decltype(
auto ) {
return os << i.first; } );
1060 Warning(
"farray('" + os.str() +
"'): array overflow, skipping extra entries" ).ignore();
1065 Int* len = ints( length, 0, maxv );
1075 [&](
const auto& item ) {
return this->fArray( item.first, len ); } );
1081 for (
size_t index = 0; first != last; ++first, ++index ) {
1082 auto item = first_item;
1083 for (
auto& var : vars ) { ( *var )[index] = std::invoke( ( item++ )->
second, *first ); }
1092 typename = std::enable_if_t<!std::is_convertible_v<Container<NamedFunction>,
std::string>>>
1093 StatusCode farray(
const Container<NamedFunction>& funs, DataIterator first, DataIterator last,
1095 return farray_impl( funs.begin(), funs.end(), std::forward<DataIterator>( first ),
1096 std::forward<DataIterator>( last ), length, maxv );
1099 template <
typename NamedFunctions,
typename DataIterator,
1100 typename = std::enable_if_t<!std::is_convertible_v<NamedFunctions, std::string>>>
1103 return farray_impl( funs.begin(), funs.end(), std::forward<DataIterator>( first ),
1104 std::forward<DataIterator>( last ), length, maxv );
1138 template <
class FUNC1,
class FUNC2,
class Iterator>
1141 return farray( {{name1,
std::cref( func1 )}, {name2,
std::cref( func2 )}}, std::forward<Iterator>( first ),
1142 std::forward<Iterator>( last ), length, maxv );
1181 template <
class FUNC1,
class FUNC2,
class FUNC3,
class Iterator>
1186 std::forward<Iterator>( first ), std::forward<Iterator>( last ), length, maxv );
1228 template <
class FUNC1,
class FUNC2,
class FUNC3,
class FUNC4,
class Iterator>
1232 return farray( {{name1,
std::cref( func1 )},
1236 std::forward<Iterator>( first ), std::forward<Iterator>( last ), length, maxv );
1291 template <
class MATRIX>
1298 if ( rows >= maxv ) {
1299 Warning(
"fmatrix('" +
name +
"'): matrix is overflow, skip extra items" ).ignore();
1300 rows = ( 0 < maxv ) ? ( maxv - 1 ) : 0;
1304 Int* len = ints( length, 0, maxv );
1315 for (
size_t iCol = 0; iCol < cols; ++iCol ) {
1316 for (
MIndex iRow = 0; iRow < rows; ++iRow ) { ( *var )[iRow][iCol] = data[iRow][iCol]; }
1358 template <
class DATA>
1365 if ( first + maxv < last ) {
1366 Warning(
"fmatrix('" +
name +
"'): matrix is overflow, skip extra items" ).ignore();
1367 last = first + maxv;
1371 Int* len = ints( length, 0, maxv );
1375 *len = last - first;
1383 for ( ; first != last; ++first ) {
1385 for (
MIndex iCol = 0; iCol < cols; ++iCol ) { ( *var )[iRow][iCol] = ( *first )[iCol]; }
1471 template <
class FUN,
class DATA>
1478 if (
std::distance( first, last ) > static_cast<std::ptrdiff_t>( maxv ) ) {
1479 Warning(
"fmatrix('" +
name +
"'): matrix is overflow, skip extra items" ).ignore();
1484 Int* len = ints( length, 0, maxv );
1498 for ( ; first != last; ++first ) {
1500 for ( FUN fun = funF; fun < funL; ++fun ) { ( *var )[iRow][fun - funF] = std::invoke( *fun, *first ); }
1532 template <
class DATA>
1590 template <
class ARRAY>
1596 auto first =
begin( data );
1630 template <
class ARRAY>
1687 template <
class MATRIX>
1697 for (
size_t iCol = 0; iCol < cols; ++iCol ) {
1698 for (
size_t iRow = 0; iRow < rows; ++iRow ) { ( *var )[iRow][iCol] = data[iRow][iCol]; }
1721 template <
class TYPE>
1723 return columns( v,
std::make_pair(
name +
"E", &ROOT::Math::LorentzVector<TYPE>::E ),
1745 template <
class TYPE,
class TAG>
1768 template <
class TYPE,
class TAG>
1783 template <
class TYPE,
unsigned int D1,
unsigned int D2,
class REP>
1793 for (
size_t iCol = 0; iCol < D2; ++iCol ) {
1794 for (
size_t iRow = 0; iRow < D1; ++iRow ) { ( *var )[iRow][iCol] = mtrx( iRow, iCol ); }
1817 template <
class KEY,
class VALUE>
1819 const std::string& length,
const size_t maxv = 100 ) {
1821 static const std::array<float ( * )(
const Info& ), 2> fns = {
1822 {[](
const Info& i ) ->
float {
return i.first; }, [](
const Info& i ) ->
float {
return i.second; }}};
1835 template <
class TYPE>
1865 bool columnWise()
const {
return CLID_ColumnWiseTuple == clid(); }
1868 bool rowWise()
const {
return CLID_RowWiseTuple == clid(); }
1874 bool valid()
const {
return 0 != tuple(); }
1920 FMatrix* fMatrix(
const std::string&
name, Int* item,
const MIndex& cols );
1923 FMatrix* fMatrix(
const std::string&
name,
const MIndex& rows,
const MIndex& cols );
1944 size_t m_refCount = 0;
1947 template <
typename T>
2012 #endif // GAUDIALG_TUPLEOBJ_H StatusCode column(const std::string &name, const ROOT::Math::DisplacementVector3D< TYPE, TAG > &v)
Useful shortcut to put 3D-Vector directly into N-Tuple:
ColumnStorage< FArray > m_arraysf
the actual storage of all 'FArray' columns (fixed)
Out1 * put(const DataObjectHandle< Out1 > &out_handle, Out2 &&out)
A bit modified version of 'Loki::AssocVector' associative vector from Loki library by Andrei Alexandr...
ColumnStorage< Float > m_floats
the actual storage of all 'Float' columns
ColumnStorage< Address > m_addresses
the actual storage of all 'Address' columns
std::map< std::string, std::string > ItemMap
StatusCode matrix(const std::string &name, const MATRIX &data, const MIndex &rows, const MIndex &cols)
fill N-Tuple with fixed-size matrix
GAUDI_API std::string format(const char *,...)
MsgStream format utility "a la sprintf(...)".
NTuple::Item< float > Float
basic type for float items
ColumnStorage< Bool > m_bools
the actual storage of all 'bool' columns
Tuples::Type m_type
tuple 'type'
Class acting as a smart pointer holding a N tuple _Item.
NTuple::Item< IOpaqueAddress * > Address
basic type for address items
ErrorCodes
Tuple error codes.
constexpr static const auto SUCCESS
const CLID & clid() const
accessor to the N-Tuple CLID
GAUDI_API void fill(AIDA::IHistogram1D *histo, const double value, const double weight=1.0)
simple function to fill AIDA::IHistogram1D objects
NTuple::Item< unsigned long long > ULongLong
basic type for unsigned long long items
NTuple::Item< unsigned short > UShort
basic type for unsigned int items
bool invalid() const
invalid pointer to tuple ?
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< LongLong > m_longlongs
the actual storage of all 'long long' columns
ColumnStorage< UShort > m_ushorts
the actual storage of all 'unsigned int' columns
Tuples::Type type() const
accessor to the N-Tuple type
bool evtColType() const
Event collection ?
NTuple::Tuple * tuple()
provide the access to underlying Gaudi N-tuple
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.
NTuple::Item< unsigned char > UChar
basic type for unsigned int items
Provide serialization function (output only) for some common STL classes (vectors,...
ColumnStorage< UInt > m_uints
the actual storage of all 'unsigned int' columns
NTuple::Item< short > Short
basic type for int items
bool addItem(std::string name, std::string type)
add the item name into the list of known items
ColumnStorage< Double > m_doubles
the actual storage of all 'Double' columns
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< FMatrix > m_fmatrices
the actual storage of all 'FArray' columns
constexpr to_< float > to_float
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.
TupleObj.h GaudiAlg/TupleObj.h namespace with few technical implementations.
A simple wrapper class over standard Gaudi NTuple::Tuple facility.
StatusCode array(const std::string &name, const ARRAY &data)
fill N-Tuple with fixed-size array
This class is used for returning status codes from appropriate routines.
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!...
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
StatusCode matrix(const std::string &name, const ROOT::Math::SMatrix< TYPE, D1, D2, REP > &mtrx)
shortcut to put Smatrix into N-tuple:
ColumnStorage< Short > m_shorts
the actual storage of all 'Int' columns
ItemMap m_items
all booked types:
NTuple::Item< bool > Bool
basic type for int items
NTuple::Item< double > Double
basic type for double items
ColumnStorage< Int > m_ints
the actual storage of all 'Int' columns
const NTuple::Tuple * tuple() const
provide the access to underlying Gaudi N-tuple
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!...
Specialization acting as a smart pointer holding a N tuple _Item.
unsigned int CLID
Class ID definition.
bool columnWise() const
column wise NTuple ?
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 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.
Stream & ostream_joiner(Stream &os, Iterator first, Iterator last, Separator sep, OutputElement output=OutputElement{})
Abstract base class which allows the user to interact with the actual N tuple implementation.
StatusCode column(const std::string &name, signed char value)
Set the value for the selected tuple column.
NTuple::Item< long long > LongLong
basic type for unsigned long long items
const std::string & name() const
get the name
StatusCode farray(const NamedFunctions &funs, DataIterator first, DataIterator last, const std::string &length, size_t maxv)
const StatusCode & ignore() const
Ignore/check StatusCode.
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, DATA first, DATA last)
fill N-Tuple with fixed-size array
struct GAUDI_API array
Parametrisation class for redirection array - like implementation.
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
boost::spirit::classic::position_iterator2< ForwardIterator > Iterator
bool rowWise() const
row wise NTuple ?
ColumnStorage< FMatrix > m_matricesf
the actual storage of all 'FMatrix' columns (fixed)
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.
T back_inserter(T... args)
StatusCode farray(const Container< NamedFunction > &funs, DataIterator first, DataIterator last, const std::string &length, size_t maxv)
NTuple::Item< char > Char
basic type for int items
std::add_const_t< typename std::iterator_traits< Iterator >::reference > const_ref_t
Common class providing an architecture-independent hash map.
NTuple::Item< int > Int
basic type for int items
constexpr static const auto FAILURE
StatusCode column(const std::string &name, const ROOT::Math::LorentzVector< TYPE > &v)
Useful shortcut to put LorentzVector directly 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...
bool valid() const
valid pointer to tuple ?
NTuple::Array< float > FArray
basic type for array of floats
AttribStringParser::Iterator begin(const AttribStringParser &parser)
Implementation file for Tuple::TupleObj::put method.
Opaque address interface definition.
Class acting as a smart pointer holding a N tuple _Item.
StatusCode array(const std::string &name, const ARRAY &data, const MIndex &length)
fill N-Tuple with fixed-size array
Class acting as a smart pointer holding a N tuple _Item.
Type
the list of available types for ntuples
bool goodItem(const std::string &name) const
check the uniqueness of the name
NTuple::Item< unsigned int > UInt
basic type for unsigned int items
ColumnStorage< UChar > m_uchars
the actual storage of all 'unsigned int' columns
T operator()(Arg &&i) const
unsigned long code_t
type of StatusCode value
ColumnStorage< FArray > m_farrays
the actual storage of all 'FArray' columns
General namespace for Tuple properties.
StatusCode column(const std::string &name, const ROOT::Math::PositionVector3D< TYPE, TAG > &v)
Useful shortcut to put 3D-Vector directly into N-Tuple: