5 #ifndef GAUDIALG_TUPLEOBJ_H
6 #define GAUDIALG_TUPLEOBJ_H 1
28 #include "Math/Point3D.h"
29 #include "Math/Vector3D.h"
30 #include "Math/Vector4D.h"
31 #include "Math/SVector.h"
32 #include "Math/SMatrix.h"
230 typedef std::map<std::string,std::string>
ItemMap ;
242 (
const std::string& name ,
244 const CLID& clid = CLID_ColumnWiseTuple ,
291 const double value );
353 const unsigned short value );
373 const unsigned short value ,
374 const unsigned short minv ,
375 const unsigned short maxv );
437 const unsigned char value );
457 const unsigned char value ,
458 const unsigned char minv ,
459 const unsigned char maxv );
521 const unsigned int value );
541 const unsigned int value ,
542 const unsigned int minv ,
543 const unsigned int maxv );
607 const unsigned long value );
627 const unsigned long value ,
628 const unsigned long minv ,
629 const unsigned long maxv );
649 const long long value );
669 const long long value ,
670 const long long minv ,
671 const long long maxv );
691 const unsigned long long value );
711 const unsigned long long value ,
712 const unsigned long long minv ,
713 const unsigned long long maxv );
733 const signed char value )
739 std::numeric_limits<signed char>::max() ) ;
879 template <
class DATA>
883 const std::string& length ,
890 if( first + maxv < last )
892 Warning(
"farray('"+name+
"'): array is overflow, skip extra items") ;
893 last = first + maxv ;
897 Int* len = ints( length , 0 , maxv ) ;
901 *len = last - first ;
904 FArray* var = fArray ( name , len ) ;
909 for( ; first != last ; ++first )
910 { (*var)[ index ] = (float)(*first) ; ++index ; }
957 template <
class DATA>
960 const std::string& length ,
962 {
return farray ( name , data.begin() , data.end() , length , maxv ) ; }
1026 template <
class FUNCTION,
class DATA>
1028 const FUNCTION&
function ,
1031 const std::string& length ,
1038 if( first + maxv < last )
1041 + name +
"'): array is overflow, skip extra entries") ;
1042 last = first + maxv ;
1046 Int* len = ints( length , 0 , maxv ) ;
1050 *len = last - first ;
1053 FArray* var = fArray ( name , len ) ;
1058 for( ; first != last ; ++first )
1059 { (*var)[ index ] =
function( *first ) ; ++index ; }
1095 template <
class FUNC1,
class FUNC2,
class DATA>
1097 const FUNC1& func1 ,
1098 const std::string& name2 ,
1099 const FUNC2& func2 ,
1102 const std::string& length ,
1109 if( first + maxv < last )
1113 + name2 +
"'): array is overflow, skip extra entries").ignore() ;
1114 Warning(
"farray('"+name1+
"'): array is overflow, skip extra items").ignore() ;
1115 last = first + maxv ;
1119 Int* len = ints ( length , 0 , maxv ) ;
1123 *len = last - first ;
1126 FArray* var1 = fArray ( name1 , len ) ;
1130 FArray* var2 = fArray ( name2 , len ) ;
1135 for( ; first != last ; ++first )
1137 ( *var1 ) [ index ] = func1 ( *first ) ;
1138 ( *var2 ) [ index ] = func2 ( *first ) ;
1181 template <
class FUNC1,
class FUNC2,
class FUNC3,
class DATA>
1183 const FUNC1& func1 ,
1184 const std::string& name2 ,
1185 const FUNC2& func2 ,
1186 const std::string& name3 ,
1187 const FUNC3& func3 ,
1190 const std::string& length ,
1197 if( first + maxv < last )
1202 + name3 +
"'): array is overflow, skip extra entries").ignore() ;
1203 last = first + maxv ;
1207 Int* len = ints ( length , 0 , maxv ) ;
1211 *len = last - first ;
1214 FArray* var1 = fArray ( name1 , len ) ;
1218 FArray* var2 = fArray ( name2 , len ) ;
1222 FArray* var3 = fArray ( name3 , len ) ;
1227 for( ; first != last ; ++first )
1229 ( *var1 ) [ index ] = (float)func1 ( *first ) ;
1230 ( *var2 ) [ index ] = (float)func2 ( *first ) ;
1231 ( *var3 ) [ index ] = (float)func3 ( *first ) ;
1276 template <
class FUNC1,
class FUNC2,
class FUNC3,
class FUNC4,
class DATA>
1278 const FUNC1& func1 ,
1279 const std::string& name2 ,
1280 const FUNC2& func2 ,
1281 const std::string& name3 ,
1282 const FUNC3& func3 ,
1283 const std::string& name4 ,
1284 const FUNC4& func4 ,
1287 const std::string& length ,
1294 if( first + maxv < last )
1300 + name4 +
"'): array is overflow, skip extra entries").ignore() ;
1301 last = first + maxv ;
1305 Int* len = ints ( length , 0 , maxv ) ;
1309 *len = last - first ;
1312 FArray* var1 = fArray ( name1 , len ) ;
1316 FArray* var2 = fArray ( name2 , len ) ;
1320 FArray* var3 = fArray ( name3 , len ) ;
1324 FArray* var4 = fArray ( name4 , len ) ;
1329 for( ; first != last ; ++first )
1331 ( *var1 ) [ index ] =
static_cast<float> ( func1 ( *first ) );
1332 ( *var2 ) [ index ] =
static_cast<float> ( func2 ( *first ) );
1333 ( *var3 ) [ index ] =
static_cast<float> ( func3 ( *first ) );
1334 ( *var4 ) [ index ] =
static_cast<float> ( func4 ( *first ) );
1393 template <
class MATRIX>
1395 const MATRIX& data ,
1398 const std::string& length ,
1407 Warning (
"fmatrix('"+name+
"'): matrix is overflow, skip extra items").ignore() ;
1408 rows = ( 0 < maxv ) ? ( maxv - 1 ) : 0 ;
1412 Int* len = ints( length , 0 , maxv ) ;
1419 FMatrix* var = fMatrix ( name , len , cols ) ;
1423 for (
size_t iCol = 0 ; iCol < cols ; ++iCol )
1425 for (
MIndex iRow = 0 ; iRow < rows ; ++iRow )
1426 { (*var)[ iRow ] [ iCol ] = (float)(data[ iRow ][ iCol ]) ; }
1468 template <
class DATA>
1473 const std::string& length ,
1480 if ( first + maxv < last )
1482 Warning(
"fmatrix('"+name+
"'): matrix is overflow, skip extra items").ignore() ;
1483 last = first + maxv ;
1487 Int* len = ints( length , 0 , maxv ) ;
1491 *len = last - first ;
1494 FMatrix* var = fMatrix ( name , len , cols ) ;
1499 for ( ; first != last ; ++first )
1502 for (
MIndex iCol = 0 ; iCol < cols ; ++iCol )
1503 { (*var)[ iRow ] [ iCol ] = (float)((*first)[ iCol ]) ; }
1589 template <
class FUN,
class DATA>
1595 const std::string& length ,
1602 if ( first + maxv < last )
1604 Warning(
"fmatrix('"+name+
"'): matrix is overflow, skip extra items").ignore() ;
1605 last = first + maxv ;
1609 Int* len = ints( length , 0 , maxv ) ;
1613 *len = last - first ;
1616 const size_t cols = funL - funF ;
1617 FMatrix* var = fMatrix ( name , len , cols ) ;
1622 for ( ; first != last ; ++first )
1625 for ( FUN
fun = funF ;
fun < funL ; ++
fun )
1626 { (*var)[ iRow ] [
fun - funF ] = (float)((*
fun) ( *first )) ; }
1658 template <
class DATA>
1668 const size_t length = last - first ;
1671 FArray* var = fArray ( name , length ) ;
1676 for ( ; first != last ; ++first )
1677 { (*var)[ iCol ] = (float)(*first) ; ++iCol ; }
1720 template <
class ARRAY>
1729 FArray* var = fArray ( name , length ) ;
1733 for (
size_t index = 0 ; index < length ; ++index )
1734 { (*var)[ index ] = (float) data[index] ; }
1768 template <
class ARRAY>
1771 {
return array ( name , data.begin() , data.end() ) ; }
1823 template <
class MATRIX>
1825 const MATRIX& data ,
1833 FMatrix* var = fMatrix ( name , rows , cols ) ;
1837 for (
size_t iCol = 0 ; iCol < cols ; ++iCol )
1839 for (
size_t iRow = 0 ; iRow < rows ; ++iRow )
1840 { (*var)[iRow][iCol] = (float)(data[iRow][iCol]) ; }
1863 template <
class TYPE>
1865 (
const std::string& name ,
1866 const ROOT::Math::LorentzVector<TYPE>& v )
1870 StatusCode sc1 =
this -> column ( name +
"E" , v.E () ) ;
1871 StatusCode sc2 =
this -> column ( name +
"X" , v.Px () ) ;
1872 StatusCode sc3 =
this -> column ( name +
"Y" , v.Py () ) ;
1873 StatusCode sc4 =
this -> column ( name +
"Z" , v.Pz () ) ;
1877 sc3.isFailure () ? sc3 :
1897 template <
class TYPE,
class TAG>
1899 (
const std::string& name ,
1904 StatusCode sc1 =
this -> column ( name +
"X" , v.X () ) ;
1905 StatusCode sc2 =
this -> column ( name +
"Y" , v.Y () ) ;
1906 StatusCode sc3 =
this -> column ( name +
"Z" , v.Z () ) ;
1929 template <
class TYPE,
class TAG>
1931 (
const std::string& name ,
1936 StatusCode sc1 =
this -> column ( name +
"X" , v.X () ) ;
1937 StatusCode sc2 =
this -> column ( name +
"Y" , v.Y () ) ;
1938 StatusCode sc3 =
this -> column ( name +
"Z" , v.Z () ) ;
1961 template <
class TYPE,
unsigned int DIM>
1963 (
const std::string& name ,
1964 const ROOT::Math::SVector<TYPE,DIM>& vect )
1966 return this->
array( name , vect.begin() , vect.end() ) ;
1977 template <
class TYPE,
unsigned int D1,
unsigned int D2,
class REP>
1979 (
const std::string& name ,
1980 const ROOT::Math::SMatrix<TYPE,D1,D2,REP>& mtrx )
1990 for (
size_t iCol = 0 ; iCol < D2 ; ++iCol )
1992 for (
size_t iRow = 0 ; iRow < D1 ; ++iRow )
1993 { (*var)[iRow][iCol] = (float) mtrx(iRow,iCol) ; }
2016 template <
class KEY,
class VALUE>
2018 (
const std::string& name ,
2020 const std::string& length ,
2021 const size_t maxv = 100 )
2031 if ( maxv < info.
size() )
2033 Warning(
"fmatrix('"+name+
"'): matrix is overflow, skip extra items") ;
2034 end = begin + maxv ;
2038 Int* len = ints( length , 0 , maxv ) ;
2042 *len = end - begin ;
2045 FMatrix* var = fMatrix ( name , len , 2 ) ;
2050 for ( ; begin !=
end ; ++begin)
2053 (*var)[iRow][0] = (float) begin->first ;
2054 (*var)[iRow][1] = (float) begin->second ;
2071 template <
class TYPE>
2073 (
const std::string& name ,
const TYPE* obj ) ;
2083 const std::string&
name()
const {
return m_name ; }
2098 unsigned long addRef () {
return ++m_refCount ; }
2113 bool columnWise()
const {
return CLID_ColumnWiseTuple == clid() ; }
2116 bool rowWise ()
const {
return CLID_RowWiseTuple == clid() ; }
2122 bool valid ()
const {
return 0 != tuple() ; }
2135 const std::string&
type )
2136 {
return m_items.insert ( std::make_pair ( name , type ) ).second ; }
2143 {
return m_items.end() == m_items.find ( name ) ; }
2151 (
const std::string&
msg ,
2155 (
const std::string&
msg ,
2161 Bool* bools (
const std::string& name ) ;
2164 Float* floats (
const std::string& name ) ;
2167 Double* doubles (
const std::string& name ) ;
2170 Char* chars (
const std::string& name ) ;
2173 Char* chars (
const std::string& name ,
2178 UChar* uchars (
const std::string& name ) ;
2181 UChar* uchars (
const std::string& name ,
2182 const unsigned char minv ,
2183 const unsigned char maxv ) ;
2186 Short* shorts (
const std::string& name ) ;
2189 Short* shorts (
const std::string& name ,
2191 const short maxv ) ;
2194 UShort* ushorts (
const std::string& name ) ;
2197 UShort* ushorts (
const std::string& name ,
2198 const unsigned short minv ,
2199 const unsigned short maxv ) ;
2202 Int* ints (
const std::string& name ) ;
2205 Int* ints (
const std::string& name ,
2210 UInt* uints (
const std::string& name ) ;
2213 UInt* uints (
const std::string& name ,
2214 const unsigned int minv ,
2215 const unsigned int maxv ) ;
2218 LongLong* longlongs (
const std::string& name );
2221 LongLong* longlongs (
const std::string& name ,
2222 const long long minv ,
2223 const long long maxv ) ;
2226 ULongLong* ulonglongs (
const std::string& name ) ;
2229 ULongLong* ulonglongs (
const std::string& name ,
2230 const unsigned long long minv ,
2231 const unsigned long long maxv ) ;
2234 FArray* fArray (
const std::string& name ,
2238 FArray* fArray (
const std::string& name ,
2239 const MIndex& rows ) ;
2242 Address* addresses (
const std::string& name ) ;
2245 FMatrix* fMatrix (
const std::string& name ,
2247 const MIndex& cols ) ;
2250 FMatrix* fMatrix (
const std::string& name ,
2251 const MIndex& rows ,
2252 const MIndex& cols ) ;
2387 #endif // GAUDIALG_TUPLEOBJ_H
GaudiUtils::HashMap< std::string, Address * > Addresses
the actual storage type for address columns
GaudiUtils::HashMap< std::string, UChar * > UChars
the actual storage type for unsigned short columns
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...
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
bool goodItem(const std::string &name) const
check the uniqueness of the name
bool evtColType() const
Event collection ?
StatusCode farray(const std::string &name1, const FUNC1 &func1, const std::string &name2, const FUNC2 &func2, const std::string &name3, const FUNC3 &func3, DATA first, DATA last, const std::string &length, const size_t maxv)
Put three functions from one data array into LoKi-style N-Tuple simultaneously (effective!) ...
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.
GaudiUtils::HashMap< std::string, Char * > Chars
the actual storage type for short columns
StatusCode fmatrix(const std::string &name, DATA first, DATA last, const MIndex &cols, const std::string &length, const size_t maxv)
Fill N-Tuple with data from variable-size matrix.
GaudiUtils::HashMap< std::string, Bool * > Bools
the actual storage type for short columns
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
GaudiUtils::HashMap< std::string, LongLong * > LongLongs
the actual storage type for longlong columns
size_t m_refCount
reference counter
bool isFailure() const
Test for a status code of FAILURE.
FArrays m_arraysf
the actual storage of all 'FArray' columns (fixed)
NTuple::Item< unsigned char > UChar
basic type for unsigned int items
Bools m_bools
the actual storage of all 'bool' 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, DATA first, DATA last, const std::string &length, const size_t maxv)
Put four functions from one data array into LoKi-style N-Tuple simultaneously (effective!) ...
bool columnWise() const
column wise NTuple ?
NTuple::Tuple * tuple() const
provide the access to underlying Gaudi N-tuple
StatusCode farray(const std::string &name, const FUNCTION &function, DATA first, DATA last, const std::string &length, const size_t maxv)
Put an indexed array into LoKi-style N-Tuple.
NTuple::Item< short > Short
basic type for int items
Chars m_chars
the actual storage of all 'Int' columns
iterator end() const
"end" iterator for sequential access (const-only version!)
ULongLongs m_ulonglongs
the actual storage of all 'ulonglong' columns
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 &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
iterator begin() const
"begin" iterator for sequential access (const-only version!)
UInts m_uints
the actual storage of all 'unsigned int' columns
GaudiUtils::HashMap< std::string, FMatrix * > FMatrices
the actual storage type for matrix 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
GaudiUtils::HashMap< std::string, FArray * > FArrays
the actual storage type for array columns
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.
LongLongs m_longlongs
the actual storage of all 'longlong' columns
bool valid() const
valid pointer to tuple ?
unsigned long addRef()
add the reference to TupleObj
unsigned long refCount() const
return the reference counter
bool rowWise() const
row wise NTuple ?
StatusCode column(const std::string &name, const signed char value)
Set the value for the selected tuple column.
Abstract base class which allows the user to interact with the actual N tuple implementation.
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
StatusCode array(const std::string &name, DATA first, DATA last)
fill N-Tuple with fixed-size array
bool addItem(const std::string &name, const std::string &type)
add the item name into the list of known items
struct GAUDI_API array
Parametrisation class for redirection array - like implementation.
NTuple::Tuple * m_tuple
tuple itself
GaudiUtils::HashMap< std::string, Short * > Shorts
the actual storage type for short columns
_vector::const_iterator const_iterator
visible const_iterator (exported)
GaudiUtils::HashMap< std::string, ULongLong * > ULongLongs
the actual storage type for ulonglong columns
Tuples::Type type() const
accessor to the N-Tuple type
GaudiUtils::HashMap< std::string, Double * > Doubles
the actual storage type for float columns
double fun(const std::vector< double > &x)
NTuple::Item< char > Char
basic type for int items
GaudiUtils::HashMap< std::string, UInt * > UInts
the actual storage type for unsigned integer columns
NTuple::Item< int > Int
basic type for int items
StatusCode farray(const std::string &name1, const FUNC1 &func1, const std::string &name2, const FUNC2 &func2, DATA first, DATA last, const std::string &length, const size_t maxv)
Put two functions from one data array into LoKi-style N-Tuple simultaneously (effective!) ...
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.
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.
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
StatusCode farray(const std::string &name, DATA first, DATA last, const std::string &length, const size_t maxv)
Add an indexed array (of type float) to N-tuple.
StatusCode fmatrix(const std::string &name, FUN funF, FUN funL, DATA first, DATA last, const std::string &length, const size_t maxv)
fill N-Tuple with matrix of "direct-product" of "data-vector" [first,last) and "function-vector" [fun...
StatusCode fmatrix(const std::string &name, const MATRIX &data, size_t rows, const MIndex &cols, const std::string &length, const size_t maxv)
Fill N-Tuple with data from variable-size matrix.
GaudiUtils::HashMap< std::string, UShort * > UShorts
the actual storage type for unsigned short columns
UChars m_uchars
the actual storage of all 'unsigned int' columns
GaudiUtils::HashMap< std::string, Int * > Ints
the actual storage type for integer columns
size_type size() const
number of elements
GaudiUtils::HashMap< std::string, Float * > Floats
the actual storage type for float columns