2 #ifndef GAUDIALG_TUPLEOBJ_H 3 #define GAUDIALG_TUPLEOBJ_H 1 30 #include "Math/Point3D.h" 31 #include "Math/Vector3D.h" 32 #include "Math/Vector4D.h" 33 #include "Math/SVector.h" 34 #include "Math/SMatrix.h" 62 template <
typename T>
struct to_ {
63 template <
typename Arg>
65 {
return T(std::forward<Arg>(i)); }
69 template <
typename Iterator>
260 const CLID& clid = CLID_ColumnWiseTuple ,
369 unsigned short value );
389 unsigned short value ,
390 unsigned short minv ,
391 unsigned short maxv );
453 unsigned char value );
473 unsigned char value ,
475 unsigned char maxv );
537 unsigned int value );
623 unsigned long value );
643 unsigned long value ,
645 unsigned long maxv );
707 unsigned long long value );
727 unsigned long long value ,
728 unsigned long long minv ,
729 unsigned long long maxv );
895 template <
typename ITERATOR1,
typename ITERATOR2>
903 std::forward<ITERATOR1>(first), std::forward<ITERATOR2>(last),
949 template <
class DATA>
1018 template <
class FUNCTION,
class ITERATOR>
1020 const FUNCTION&
function ,
1030 if(
std::distance(first,last) > static_cast<std::ptrdiff_t>(maxv) ) {
1032 + name +
"'): array is overflow, skip extra entries") ;
1037 Int* len = ints( length , 0 , maxv ) ;
1044 FArray* var = fArray ( name , len ) ;
1097 {
return os << i.first; } );
1098 Warning(
"farray('" + os.str()
1099 +
"'): array overflow, skipping extra entries").ignore() ;
1104 Int* len = ints ( length , 0 , maxv ) ;
1113 [&](
const Item& item) {
return this->fArray(item.first,len); } );
1120 while( first != last ) {
1121 auto var = vars.
begin();
1122 auto item = items.
begin();
1123 while ( var != vars.
end() ) {
1124 (**var)[index] = item->second(*first);
1166 template <
class FUNC1,
class FUNC2,
class Iterator>
1168 const FUNC1& func1 ,
1170 const FUNC2& func2 ,
1178 std::forward<Iterator>(first), std::forward<Iterator>(last),
1218 template <
class FUNC1,
class FUNC2,
class FUNC3,
class Iterator>
1220 const FUNC1& func1 ,
1222 const FUNC2& func2 ,
1224 const FUNC3& func3 ,
1233 std::forward<Iterator>(first), std::forward<Iterator>(last),
1276 template <
class FUNC1,
class FUNC2,
class FUNC3,
class FUNC4,
class Iterator>
1278 const FUNC1& func1 ,
1280 const FUNC2& func2 ,
1282 const FUNC3& func3 ,
1284 const FUNC4& func4 ,
1294 std::forward<Iterator>(first), std::forward<Iterator>(last),
1350 template <
class MATRIX>
1352 const MATRIX& data ,
1354 const MIndex& cols ,
1364 Warning (
"fmatrix('"+name+
"'): matrix is overflow, skip extra items").ignore() ;
1365 rows = ( 0 < maxv ) ? ( maxv - 1 ) : 0 ;
1369 Int* len = ints( length , 0 , maxv ) ;
1376 FMatrix* var = fMatrix ( name , len , cols ) ;
1380 for (
size_t iCol = 0 ; iCol < cols ; ++iCol )
1382 for ( MIndex iRow = 0 ; iRow < rows ; ++iRow )
1383 { (*var)[ iRow ] [ iCol ] = data[ iRow ][ iCol ] ; }
1425 template <
class DATA>
1429 const MIndex& cols ,
1437 if ( first + maxv < last )
1439 Warning(
"fmatrix('"+name+
"'): matrix is overflow, skip extra items").ignore() ;
1440 last = first + maxv ;
1444 Int* len = ints( length , 0 , maxv ) ;
1448 *len = last - first ;
1451 FMatrix* var = fMatrix ( name , len , cols ) ;
1456 for ( ; first != last ; ++first )
1459 for ( MIndex iCol = 0 ; iCol < cols ; ++iCol )
1460 { (*var)[ iRow ] [ iCol ] = (float)((*first)[ iCol ]) ; }
1546 template <
class FUN,
class DATA>
1559 if (
std::distance(first,last) > static_cast<std::ptrdiff_t>(maxv) )
1561 Warning(
"fmatrix('"+name+
"'): matrix is overflow, skip extra items").ignore() ;
1566 Int* len = ints( length , 0 , maxv ) ;
1574 FMatrix* var = fMatrix ( name , len , cols ) ;
1579 for ( ; first != last ; ++first )
1582 for ( FUN
fun = funF ;
fun < funL ; ++
fun )
1583 { (*var)[ iRow ] [
fun - funF ] = (*fun) ( *first ) ; }
1615 template <
class DATA>
1628 FArray* var = fArray ( name , length ) ;
1675 template <
class ARRAY>
1678 const MIndex& length )
1684 auto first =
begin(data);
1718 template <
class ARRAY>
1776 template <
class MATRIX>
1778 const MATRIX& data ,
1779 const MIndex& rows ,
1780 const MIndex& cols )
1786 FMatrix* var = fMatrix ( name , rows , cols ) ;
1790 for (
size_t iCol = 0 ; iCol < cols ; ++iCol )
1792 for (
size_t iRow = 0 ; iRow < rows ; ++iRow )
1793 { (*var)[iRow][iCol] = data[iRow][iCol]; }
1816 template <
class TYPE>
1819 const ROOT::Math::LorentzVector<TYPE>& v )
1830 sc3.isFailure () ? sc3 :
1850 template <
class TYPE,
class TAG>
1882 template <
class TYPE,
class TAG>
1906 template <
class TYPE,
unsigned int D1,
unsigned int D2,
class REP>
1909 const ROOT::Math::SMatrix<TYPE,D1,D2,REP>& mtrx )
1915 FMatrix* var = fMatrix ( name , (MIndex)D1 , (MIndex)D2 ) ;
1919 for (
size_t iCol = 0 ; iCol < D2 ; ++iCol )
1921 for (
size_t iRow = 0 ; iRow < D1 ; ++iRow )
1922 { (*var)[iRow][iCol] = mtrx(iRow,iCol) ; }
1945 template <
class KEY,
class VALUE>
1950 const size_t maxv = 100 )
1954 fns = { { [](
const Info& i) {
return i.first; } ,
1955 [](
const Info& i) {
return i.second; } } };
1971 template <
class TYPE>
2003 unsigned long addRef () {
return ++m_refCount ; }
2018 bool columnWise()
const {
return CLID_ColumnWiseTuple == clid() ; }
2021 bool rowWise ()
const {
return CLID_RowWiseTuple == clid() ; }
2027 bool valid ()
const {
return 0 != tuple() ; }
2048 {
return m_items.end() == m_items.find ( name ) ; }
2051 const ItemMap&
items()
const {
return m_items ; }
2076 const MIndex& rows ) ;
2084 const MIndex& cols ) ;
2088 const MIndex& rows ,
2089 const MIndex& cols ) ;
2158 size_t m_refCount = 0;
2221 #endif // GAUDIALG_TUPLEOBJ_H
UShorts m_ushorts
the actual storage of all 'unsigned int' columns
FMatrices m_fmatrices
the actual storage of all 'FArray' columns
A bit modified version of 'Loki::AssocVector' associative vector from Loki library by Andrei Alexandr...
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
GaudiUtils::HashMap< std::string, std::unique_ptr< FMatrix > > FMatrices
the actual storage type for matrix columns
GAUDI_API std::string format(const char *,...)
MsgStream format utility "a la sprintf(...)".
NTuple::Item< float > Float
basic type for float items
bool goodItem(const std::string &name) const
check the uniqueness of the name
bool evtColType() const
Event collection ?
Doubles m_doubles
the actual storage of all 'Double' 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
FMatrices m_matricesf
the actual storage of all 'FMatrix' columns (fixed)
Floats m_floats
the actual storage of all 'Float' columns
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
FArrays m_farrays
the actual storage of all 'FArray' columns
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.
bool isFailure() const
Test for a status code of FAILURE.
GaudiUtils::HashMap< std::string, std::unique_ptr< LongLong > > LongLongs
the actual storage type for longlong columns
NTuple::Tuple * tuple()
provide the access to underlying Gaudi N-tuple
FArrays m_arraysf
the actual storage of all 'FArray' columns (fixed)
GaudiUtils::HashMap< std::string, std::unique_ptr< Address > > Addresses
the actual storage type for 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.
NTuple::Item< unsigned char > UChar
basic type for unsigned int items
Bools m_bools
the actual storage of all 'bool' columns
Provide serialization function (output only) for some common STL classes (vectors, lists, pairs, maps) plus GaudiUtils::Map and GaudiUtils::HashMap.
auto begin(reverse_wrapper< T > &w)
bool columnWise() const
column wise NTuple ?
PropertyMgr & operator=(const PropertyMgr &)=delete
NTuple::Item< short > Short
basic type for int items
Chars m_chars
the actual storage of all 'Int' columns
bool addItem(std::string name, std::string type)
add the item name into the list of known 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...
ULongLongs 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.
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
UInts m_uints
the actual storage of all 'unsigned int' columns
T operator()(Arg &&i) const
ItemMap m_items
all booked types:
NTuple::Item< bool > Bool
basic type for int items
auto end(reverse_wrapper< T > &w)
NTuple::Item< double > Double
basic type for double items
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.
Ints m_ints
the actual storage of all 'Int' columns
unsigned int CLID
Class ID definition.
GaudiUtils::HashMap< std::string, std::unique_ptr< UShort > > UShorts
the actual storage type for unsigned short columns
LongLongs m_longlongs
the actual storage of all 'longlong' columns
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.
unsigned long addRef()
add the reference to TupleObj
unsigned long refCount() const
return the reference counter
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.
typename std::add_const< typename std::iterator_traits< Iterator >::reference >::type const_ref_t
StatusCode column(const std::string &name, signed char value)
Set the value for the selected tuple column.
ErrorCodes
Tuple error codes.
NTuple::Item< long long > LongLong
basic type for unsigned long long items
Addresses m_addresses
the actual storage of all 'Address' columns
GaudiUtils::HashMap< std::string, std::unique_ptr< FArray > > FArrays
the actual storage type for array columns
GaudiUtils::HashMap< std::string, std::unique_ptr< Float > > Floats
the actual storage type for float columns
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
GaudiUtils::HashMap< std::string, std::unique_ptr< Double > > Doubles
the actual storage type for float columns
Tuples::Type type() const
accessor to the N-Tuple type
boost::spirit::classic::position_iterator2< ForwardIterator > Iterator
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)
double fun(const std::vector< double > &x)
NTuple::Item< char > Char
basic type for int items
Common class providing an architecture-independent hash map.
NTuple::Item< int > Int
basic type for int items
GaudiUtils::HashMap< std::string, std::unique_ptr< Char > > Chars
the actual storage type for short columns
Shorts m_shorts
the actual storage of all 'Int' columns
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
Implementation file for Tuple::TupleObj::put method.
Opaque address interface definition.
GaudiUtils::HashMap< std::string, std::unique_ptr< UInt > > UInts
the actual storage type for unsigned integer columns
Class acting as a smart pointer holding a N tuple _Item.
const CLID & clid() const
accessor to the N-Tuple CLID
GaudiUtils::HashMap< std::string, std::unique_ptr< Int > > Ints
the actual storage type for integer columns
StatusCode array(const std::string &name, const ARRAY &data, const MIndex &length)
fill N-Tuple with fixed-size array
GaudiUtils::HashMap< std::string, std::unique_ptr< Short > > Shorts
the actual storage type for short columns
Class acting as a smart pointer holding a N tuple _Item.
std::map< std::string, std::string > ItemMap
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
GaudiUtils::HashMap< std::string, std::unique_ptr< ULongLong > > ULongLongs
the actual storage type for ulonglong columns
UChars m_uchars
the actual storage of all 'unsigned int' columns
GaudiUtils::HashMap< std::string, std::unique_ptr< Bool > > Bools
the actual storage type for short columns
GaudiUtils::HashMap< std::string, std::unique_ptr< UChar > > UChars
the actual storage type for unsigned short columns
General namespace for Tuple properties.