2 #ifndef GAUDIALG_TUPLEOBJ_H 3 #define GAUDIALG_TUPLEOBJ_H 1 32 #include "Math/Point3D.h" 33 #include "Math/SMatrix.h" 34 #include "Math/SVector.h" 35 #include "Math/Vector3D.h" 36 #include "Math/Vector4D.h" 66 template <
typename Arg>
69 return T( std::forward<Arg>( i ) );
74 template <
typename Iterator>
75 using const_ref_t = std::add_const_t<typename std::iterator_traits<Iterator>::reference>;
690 unsigned long long maxv );
793 template <
typename Value,
typename... Args>
883 template <
typename ITERATOR1,
typename ITERATOR2>
887 return farray( name,
detail::to_float, std::forward<ITERATOR1>( first ), std::forward<ITERATOR2>( last ), length,
933 template <
class DATA>
1001 template <
class FUNCTION,
class ITERATOR>
1009 if (
std::distance( first, last ) > static_cast<std::ptrdiff_t>( maxv ) ) {
1010 Warning(
"farray('" + name +
"'): array is overflow, skip extra entries" );
1015 Int* len = ints( length, 0, maxv );
1022 FArray* var = fArray( name, len );
1059 template <
typename FunIterator,
typename DataIterator>
1067 if (
std::distance( first, last ) > static_cast<std::ptrdiff_t>( maxv ) ) {
1071 [](
std::ostream& os,
const auto& i ) -> decltype(
auto ) {
return os << i.first; } );
1072 Warning(
"farray('" + os.str() +
"'): array overflow, skipping extra entries" ).ignore();
1077 Int* len = ints( length, 0, maxv );
1087 [&](
const auto& item ) {
return this->fArray( item.first, len ); } );
1093 for (
size_t index = 0; first != last; ++first, ++index ) {
1094 auto item = first_item;
1095 for (
auto& var : vars ) {
1107 StatusCode farray(
const Container<NamedFunction>& funs, DataIterator first, DataIterator last,
1110 return farray_impl( funs.begin(), funs.end(), std::forward<DataIterator>( first ),
1111 std::forward<DataIterator>( last ), length, maxv );
1114 template <
typename NamedFunctions,
typename DataIterator,
1115 typename = std::enable_if_t<!std::is_convertible<NamedFunctions, std::string>::value>>
1119 return farray_impl( funs.begin(), funs.end(), std::forward<DataIterator>( first ),
1120 std::forward<DataIterator>( last ), length, maxv );
1154 template <
class FUNC1,
class FUNC2,
class Iterator>
1159 std::forward<Iterator>( last ), length, maxv );
1198 template <
class FUNC1,
class FUNC2,
class FUNC3,
class Iterator>
1204 std::forward<Iterator>( first ), std::forward<Iterator>( last ), length, maxv );
1246 template <
class FUNC1,
class FUNC2,
class FUNC3,
class FUNC4,
class Iterator>
1255 std::forward<Iterator>( first ), std::forward<Iterator>( last ), length, maxv );
1310 template <
class MATRIX>
1318 if ( rows >= maxv ) {
1319 Warning(
"fmatrix('" + name +
"'): matrix is overflow, skip extra items" ).ignore();
1320 rows = ( 0 < maxv ) ? ( maxv - 1 ) : 0;
1324 Int* len = ints( length, 0, maxv );
1331 FMatrix* var = fMatrix( name, len, cols );
1335 for (
size_t iCol = 0; iCol < cols; ++iCol ) {
1336 for ( MIndex iRow = 0; iRow < rows; ++iRow ) {
1337 ( *var )[iRow][iCol] = data[iRow][iCol];
1380 template <
class DATA>
1388 if ( first + maxv < last ) {
1389 Warning(
"fmatrix('" + name +
"'): matrix is overflow, skip extra items" ).ignore();
1390 last = first + maxv;
1394 Int* len = ints( length, 0, maxv );
1398 *len = last - first;
1401 FMatrix* var = fMatrix( name, len, cols );
1406 for ( ; first != last; ++first ) {
1408 for ( MIndex iCol = 0; iCol < cols; ++iCol ) {
1409 ( *var )[iRow][iCol] = ( *first )[iCol];
1496 template <
class FUN,
class DATA>
1504 if (
std::distance( first, last ) > static_cast<std::ptrdiff_t>( maxv ) ) {
1505 Warning(
"fmatrix('" + name +
"'): matrix is overflow, skip extra items" ).ignore();
1510 Int* len = ints( length, 0, maxv );
1519 FMatrix* var = fMatrix( name, len, cols );
1524 for ( ; first != last; ++first ) {
1526 for ( FUN
fun = funF;
fun < funL; ++
fun ) {
1560 template <
class DATA>
1571 FArray* var = fArray( name, length );
1618 template <
class ARRAY>
1625 auto first =
begin( data );
1659 template <
class ARRAY>
1717 template <
class MATRIX>
1724 FMatrix* var = fMatrix( name, rows, cols );
1728 for (
size_t iCol = 0; iCol < cols; ++iCol ) {
1729 for (
size_t iRow = 0; iRow < rows; ++iRow ) {
1730 ( *var )[iRow][iCol] = data[iRow][iCol];
1754 template <
class TYPE>
1757 return columns( v,
std::make_pair( name +
"E", &ROOT::Math::LorentzVector<TYPE>::E ),
1758 std::make_pair( name +
"X", &ROOT::Math::LorentzVector<TYPE>::Px ),
1759 std::make_pair( name +
"Y", &ROOT::Math::LorentzVector<TYPE>::Py ),
1760 std::make_pair( name +
"Z", &ROOT::Math::LorentzVector<TYPE>::Pz ) );
1779 template <
class TYPE,
class TAG>
1803 template <
class TYPE,
class TAG>
1819 template <
class TYPE,
unsigned int D1,
unsigned int D2,
class REP>
1826 FMatrix* var = fMatrix( name, (MIndex)D1, (MIndex)D2 );
1830 for (
size_t iCol = 0; iCol < D2; ++iCol ) {
1831 for (
size_t iRow = 0; iRow < D1; ++iRow ) {
1832 ( *var )[iRow][iCol] = mtrx( iRow, iCol );
1856 template <
class KEY,
class VALUE>
1858 const std::string& length,
const size_t maxv = 100 )
1862 {[](
const Info& i ) ->
float {
return i.first; }, [](
const Info& i ) ->
float {
return i.second; }}};
1875 template <
class TYPE>
1905 bool columnWise()
const {
return CLID_ColumnWiseTuple == clid(); }
1908 bool rowWise()
const {
return CLID_RowWiseTuple == clid(); }
1914 bool valid()
const {
return 0 != tuple(); }
1938 const ItemMap&
items()
const {
return m_items; }
1949 Int* ints(
const std::string& name,
int minv,
int maxv );
1952 FArray* fArray(
const std::string& name, Int* item );
1955 FArray* fArray(
const std::string& name,
const MIndex& rows );
1961 FMatrix* fMatrix(
const std::string& name, Int* item,
const MIndex& cols );
1964 FMatrix* fMatrix(
const std::string& name,
const MIndex& rows,
const MIndex& cols );
1985 size_t m_refCount = 0;
1988 template <
typename T>
2053 #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:
constexpr static const auto FAILURE
ColumnStorage< FArray > m_arraysf
the actual storage of all 'FArray' columns (fixed)
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
const NTuple::Tuple * tuple() const
provide the access to underlying Gaudi N-tuple
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
bool goodItem(const std::string &name) const
check the uniqueness of the name
bool evtColType() const
Event collection ?
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.
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
#define STATUSCODE_ENUM_DECL(ENUM)
Declare an enum to be used as StatusCode value.
NTuple::Item< unsigned short > UShort
basic type for unsigned int items
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 'longlong' columns
ColumnStorage< UShort > m_ushorts
the actual storage of all 'unsigned int' columns
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, lists, pairs, maps) plus GaudiUtils::Map and GaudiUtils::HashMap.
bool columnWise() const
column wise NTuple ?
ColumnStorage< UInt > m_uints
the actual storage of all 'unsigned int' columns
PropertyMgr & operator=(const PropertyMgr &)=delete
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 'ulonglong' columns
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
T operator()(Arg &&i) const
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
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.
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...
bool valid() const
valid pointer to tuple ?
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.
constexpr static const auto SUCCESS
bool rowWise() const
row wise NTuple ?
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
StatusCode farray(const NamedFunctions &funs, DataIterator first, DataIterator last, const std::string &length, size_t maxv)
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
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
Tuples::Type type() const
accessor to the N-Tuple type
boost::spirit::classic::position_iterator2< ForwardIterator > Iterator
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)
const StatusCode & ignore() const
Ignore/check StatusCode.
StatusCode farray(const Container< NamedFunction > &funs, DataIterator first, DataIterator last, const std::string &length, size_t maxv)
double fun(const std::vector< double > &x)
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
StatusCode column(const std::string &name, const ROOT::Math::LorentzVector< TYPE > &v)
Useful shortcut to put LorentzVector directly into N-Tuple:
bool invalid() const
invalid pointer to tuple ?
const ItemMap & items() const
get the full list of booked items
NTuple::Array< float > FArray
basic type for array of floats
AttribStringParser::Iterator begin(const AttribStringParser &parser)
auto invoke(F &&f, ArgTypes &&...args) noexcept(noexcept(detail2::INVOKE(std::forward< F >(f), std::forward< ArgTypes >(args)...))) -> decltype(detail2::INVOKE(std::forward< F >(f), std::forward< ArgTypes >(args)...))
Implementation file for Tuple::TupleObj::put method.
Opaque address interface definition.
Class acting as a smart pointer holding a N tuple _Item.
const CLID & clid() const
accessor to the N-Tuple CLID
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
const std::string & name() const
get 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
StatusCode columns(Value &&value, Args &&...args)
Set the values for several columns simultaneously, for the same object Non-existing columns will be a...
Out1 * put(DataObjectHandle< Out1 > &out_handle, Out2 &&out)
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: