The Gaudi Framework  v29r0 (ff2e7097)
TupleObj.h
Go to the documentation of this file.
1 // ============================================================================
2 #ifndef GAUDIALG_TUPLEOBJ_H
3 #define GAUDIALG_TUPLEOBJ_H 1
4 // ============================================================================
5 // Include files
6 // ============================================================================
7 // STD&STL
8 // ============================================================================
9 #include <array>
10 #include <cstddef>
11 #include <functional>
12 #include <limits>
13 #include <numeric>
14 #include <set>
15 #include <sstream>
16 #include <string>
17 // ============================================================================
18 // GaudiKernel
19 // ============================================================================
20 #include "GaudiKernel/NTuple.h"
22 #include "GaudiKernel/VectorMap.h"
23 #include "GaudiKernel/invoke.h"
24 // ============================================================================
25 // GaudiAlg
26 // ============================================================================
27 #include "GaudiAlg/Maps.h"
28 #include "GaudiAlg/Tuples.h"
29 // ============================================================================
30 // ROOT
31 // ============================================================================
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"
37 // ============================================================================
38 // forward declaration
39 // ============================================================================
40 // GaudiKernel
41 // ============================================================================
42 class IOpaqueAddress;
43 // ============================================================================
52 // ============================================================================
60 namespace Tuples
61 {
62  namespace detail
63  {
64  template <typename T>
65  struct to_ {
66  template <typename Arg>
67  T operator()( Arg&& i ) const
68  {
69  return T( std::forward<Arg>( i ) );
70  }
71  };
72  constexpr struct to_<float> to_float {
73  };
74 
75  template <typename Iterator>
77  }
78  // ==========================================================================
84  enum Type {
85  NTUPLE, // Analysis nTuple
86  EVTCOL // Event Collection
87  };
88  // ==========================================================================
96  enum ErrorCodes {
97  InvalidTuple = 100,
103  };
104  // ==========================================================================
200  {
201  public:
202  // ========================================================================
205  // ========================================================================
208  // ========================================================================
211  // ========================================================================
214  // ========================================================================
217  // ========================================================================
220  // ========================================================================
223  // ========================================================================
226  // ========================================================================
229  // ========================================================================
232  // ========================================================================
235  // ========================================================================
238  // ========================================================================
241  // ========================================================================
244  // ========================================================================
245  // the actual type for variable size matrix indices
246  typedef unsigned short MIndex;
247  // ========================================================================
248  // the map of all items
250  // ========================================================================
251  protected:
252  // ========================================================================
260  TupleObj( std::string name, NTuple::Tuple* tuple, const CLID& clid = CLID_ColumnWiseTuple,
261  const Tuples::Type type = Tuples::NTUPLE );
262  // ========================================================================
263  protected:
264  // ========================================================================
266  virtual ~TupleObj();
267  // ========================================================================
268  public:
269  // ========================================================================
285  StatusCode column( const std::string& name, float value );
286  // ========================================================================
287  public:
288  // ========================================================================
305  StatusCode column( const std::string& name, double value );
306  // ========================================================================
307  public:
308  // ========================================================================
324  StatusCode column( const std::string& name, short value );
325  // ========================================================================
343  StatusCode column( const std::string& name, short value, short minv, short maxv );
344  // ========================================================================
345  public:
346  // ========================================================================
362  StatusCode column( const std::string& name, unsigned short value );
363  // ========================================================================
381  StatusCode column( const std::string& name, unsigned short value, unsigned short minv, unsigned short maxv );
382  // ========================================================================
383  public:
384  // ========================================================================
400  StatusCode column( const std::string& name, char value );
401  // ========================================================================
419  StatusCode column( const std::string& name, char value, char minv, char maxv );
420  // ========================================================================
421  public:
422  // ========================================================================
438  StatusCode column( const std::string& name, unsigned char value );
439  // ========================================================================
457  StatusCode column( const std::string& name, unsigned char value, unsigned char minv, unsigned char maxv );
458  // ========================================================================
459  public:
460  // ========================================================================
476  StatusCode column( const std::string& name, int value );
477  // ========================================================================
495  StatusCode column( const std::string& name, int value, int minv, int maxv );
496  // ========================================================================
497  public:
498  // ========================================================================
514  StatusCode column( const std::string& name, unsigned int value );
515  // ========================================================================
533  StatusCode column( const std::string& name, unsigned int value, unsigned int minv, unsigned int maxv );
534  // ========================================================================
535  public:
536  // ========================================================================
553  StatusCode column( const std::string& name, long value );
554  // ========================================================================
572  StatusCode column( const std::string& name, long value, long minv, long maxv );
573  // ========================================================================
574  public:
575  // ========================================================================
592  StatusCode column( const std::string& name, unsigned long value );
593  // ========================================================================
611  StatusCode column( const std::string& name, unsigned long value, unsigned long minv, unsigned long maxv );
612  // ========================================================================
613  public:
614  // ========================================================================
630  StatusCode column( const std::string& name, long long value );
631  // ========================================================================
649  StatusCode column( const std::string& name, long long value, long long minv, long long maxv );
650  // ========================================================================
651  public:
652  // ========================================================================
668  StatusCode column( const std::string& name, unsigned long long value );
669  // ========================================================================
687  StatusCode column( const std::string& name, unsigned long long value, unsigned long long minv,
688  unsigned long long maxv );
689  // ========================================================================
690  public:
691  // ========================================================================
707  StatusCode column( const std::string& name, signed char value )
708  {
710  }
711  // ========================================================================
712  public:
713  // ========================================================================
728  StatusCode column( const std::string& name, bool value );
729  // ========================================================================
730  public:
731  // ========================================================================
750  StatusCode column( const std::string& name, IOpaqueAddress* address );
751  // ========================================================================
768  StatusCode column( IOpaqueAddress* address );
769  // ========================================================================
770  public:
771  // ========================================================================
790  private:
791  template <typename Tuple, typename Value, std::size_t... I>
792  StatusCode columns_helper( const Value& value, const Tuple& tup, std::index_sequence<I...> )
793  {
795  this->column( std::get<I>( tup ).first, Gaudi::invoke( std::get<I>( tup ).second, value ) )...};
796  auto is_ok = []( const StatusCode& sc ) -> bool { return sc; };
797  auto i = std::find_if_not( begin( scs ), end( scs ), is_ok );
798  if ( i != end( scs ) ) {
799  // avoid unchecked StatusCodes...
800  std::for_each( std::next( i ), end( scs ), is_ok );
801  return *i;
802  }
803  return StatusCode::SUCCESS;
804  }
805 
806  public:
807  template <typename Value, typename... Args>
808  StatusCode columns( Value&& value, Args&&... args )
809  {
810  return columns_helper( std::forward<Value>( value ), std::forward_as_tuple( std::forward<Args>( args )... ),
811  std::index_sequence_for<Args...>{} );
812  }
813  // ========================================================================
814  public:
815  // ========================================================================
839  StatusCode fill( const char* format... );
840  // =======================================================================
841  public:
842  // =======================================================================
891  template <typename ITERATOR1, typename ITERATOR2>
892  StatusCode farray( const std::string& name, ITERATOR1&& first, ITERATOR2&& last, const std::string& length,
893  size_t maxv )
894  {
895  return farray( name, detail::to_float, std::forward<ITERATOR1>( first ), std::forward<ITERATOR2>( last ), length,
896  maxv );
897  }
898  // =======================================================================
941  template <class DATA>
942  StatusCode farray( const std::string& name, const DATA& data, const std::string& length, const size_t maxv )
943  {
944  return farray( name, std::begin( data ), std::end( data ), length, maxv );
945  }
946  // =======================================================================
1009  template <class FUNCTION, class ITERATOR>
1010  StatusCode farray( const std::string& name, const FUNCTION& function, ITERATOR first, ITERATOR last,
1011  const std::string& length, size_t maxv )
1012  {
1013  if ( invalid() ) {
1014  return InvalidTuple;
1015  }
1016  if ( rowWise() ) {
1017  return InvalidOperation;
1018  }
1019 
1020  // adjust the length
1021  if ( std::distance( first, last ) > static_cast<std::ptrdiff_t>( maxv ) ) {
1022  Warning( "farray('" + name + "'): array is overflow, skip extra entries" );
1023  last = std::next( first, maxv );
1024  }
1025 
1026  // get the length item
1027  Int* len = ints( length, 0, maxv );
1028  if ( !len ) {
1029  return InvalidColumn;
1030  }
1031 
1032  // adjust the length
1033  *len = std::distance( first, last );
1034 
1035  // get the array itself
1036  FArray* var = fArray( name, len );
1037  if ( !var ) {
1038  return InvalidColumn;
1039  }
1040 
1041  // fill the array
1042  std::transform( first, last, std::begin( *var ), std::cref( function ) );
1043 
1044  return StatusCode::SUCCESS;
1045  }
1046  // =======================================================================
1073  template <typename Iterator, template <typename, typename...> class Container = std::initializer_list,
1075  typename Item = std::pair<std::string, Fun>,
1076  typename = std::enable_if_t<!std::is_same<std::string, Container<Item>>::value>>
1077  StatusCode farray( const Container<Item>& items, Iterator first, Iterator last, const std::string& length,
1078  size_t maxv )
1079  {
1080  if ( invalid() ) {
1081  return InvalidTuple;
1082  }
1083  if ( rowWise() ) {
1084  return InvalidOperation;
1085  }
1086 
1087  // adjust the lenfth
1088  if ( std::distance( first, last ) > static_cast<std::ptrdiff_t>( maxv ) ) {
1090  std::ostringstream os;
1091  ostream_joiner( os, items, ",",
1092  []( std::ostream& os, const auto& i ) -> std::ostream& { return os << i.first; } );
1093  Warning( "farray('" + os.str() + "'): array overflow, skipping extra entries" ).ignore();
1094  last = std::next( first, maxv );
1095  }
1096 
1097  // get the length item
1098  Int* len = ints( length, 0, maxv );
1099  if ( !len ) {
1100  return InvalidColumn;
1101  }
1102 
1103  // adjust the length
1104  *len = std::distance( first, last );
1105 
1106  // get the arrays themselves
1107  std::vector<FArray*> vars;
1108  vars.reserve( items.size() );
1109  std::transform( items.begin(), items.end(), std::back_inserter( vars ),
1110  [&]( const auto& item ) { return this->fArray( item.first, len ); } );
1111  if ( std::any_of( vars.begin(), vars.end(), []( const FArray* f ) { return !f; } ) ) {
1112  return InvalidColumn;
1113  }
1114 
1115  // fill the array
1116  for ( size_t index = 0; first != last; ++first, ++index ) {
1117  auto item = items.begin();
1118  for ( auto& var : vars ) {
1119  ( *var )[index] = ( item++ )->second( *first );
1120  }
1121  }
1122 
1123  return StatusCode::SUCCESS;
1124  }
1125  // =======================================================================
1157  template <class FUNC1, class FUNC2, class Iterator>
1158  StatusCode farray( const std::string& name1, const FUNC1& func1, const std::string& name2, const FUNC2& func2,
1159  Iterator&& first, Iterator&& last, const std::string& length, size_t maxv )
1160  {
1161  return farray( {{name1, std::cref( func1 )}, {name2, std::cref( func2 )}}, std::forward<Iterator>( first ),
1162  std::forward<Iterator>( last ), length, maxv );
1163  }
1164  // =======================================================================
1201  template <class FUNC1, class FUNC2, class FUNC3, class Iterator>
1202  StatusCode farray( const std::string& name1, const FUNC1& func1, const std::string& name2, const FUNC2& func2,
1203  const std::string& name3, const FUNC3& func3, Iterator&& first, Iterator&& last,
1204  const std::string& length, size_t maxv )
1205  {
1206  return farray( {{name1, std::cref( func1 )}, {name2, std::cref( func2 )}, {name3, std::cref( func3 )}},
1207  std::forward<Iterator>( first ), std::forward<Iterator>( last ), length, maxv );
1208  }
1209  // =======================================================================
1249  template <class FUNC1, class FUNC2, class FUNC3, class FUNC4, class Iterator>
1250  StatusCode farray( const std::string& name1, const FUNC1& func1, const std::string& name2, const FUNC2& func2,
1251  const std::string& name3, const FUNC3& func3, const std::string& name4, const FUNC4& func4,
1252  Iterator&& first, Iterator&& last, const std::string& length, size_t maxv )
1253  {
1254  return farray( {{name1, std::cref( func1 )},
1255  {name2, std::cref( func2 )},
1256  {name3, std::cref( func3 )},
1257  {name4, std::cref( func4 )}},
1258  std::forward<Iterator>( first ), std::forward<Iterator>( last ), length, maxv );
1259  }
1260  // =======================================================================
1261  public:
1262  // =======================================================================
1313  template <class MATRIX>
1314  StatusCode fmatrix( const std::string& name, const MATRIX& data, size_t rows, const MIndex& cols,
1315  const std::string& length, size_t maxv )
1316  {
1317  if ( invalid() ) {
1318  return InvalidTuple;
1319  }
1320  if ( rowWise() ) {
1321  return InvalidOperation;
1322  }
1323 
1324  // adjust the length
1325  if ( rows >= maxv ) {
1326  Warning( "fmatrix('" + name + "'): matrix is overflow, skip extra items" ).ignore();
1327  rows = ( 0 < maxv ) ? ( maxv - 1 ) : 0;
1328  }
1329 
1330  // get the length item
1331  Int* len = ints( length, 0, maxv );
1332  if ( !len ) {
1333  return InvalidColumn;
1334  }
1335 
1336  // adjust the length item
1337  *len = rows;
1338 
1339  // get the array itself
1340  FMatrix* var = fMatrix( name, len, cols );
1341  if ( !var ) {
1342  return InvalidColumn;
1343  }
1344 
1346  for ( size_t iCol = 0; iCol < cols; ++iCol ) {
1347  for ( MIndex iRow = 0; iRow < rows; ++iRow ) {
1348  ( *var )[iRow][iCol] = data[iRow][iCol];
1349  }
1350  }
1351 
1352  return StatusCode::SUCCESS;
1353  }
1354  // =======================================================================
1391  template <class DATA>
1392  StatusCode fmatrix( const std::string& name, DATA first, DATA last, const MIndex& cols, const std::string& length,
1393  size_t maxv )
1394  {
1395  if ( invalid() ) {
1396  return InvalidTuple;
1397  }
1398  if ( rowWise() ) {
1399  return InvalidOperation;
1400  }
1401 
1402  // adjust the length
1403  if ( first + maxv < last ) {
1404  Warning( "fmatrix('" + name + "'): matrix is overflow, skip extra items" ).ignore();
1405  last = first + maxv;
1406  }
1407 
1408  // get the length item
1409  Int* len = ints( length, 0, maxv );
1410  if ( !len ) {
1411  return InvalidColumn;
1412  }
1413 
1414  // adjust the length item
1415  *len = last - first;
1416 
1417  // get the array itself
1418  FMatrix* var = fMatrix( name, len, cols );
1419  if ( !var ) {
1420  return InvalidColumn;
1421  }
1422 
1424  size_t iRow = 0;
1425  for ( ; first != last; ++first ) {
1426  //
1427  for ( MIndex iCol = 0; iCol < cols; ++iCol ) {
1428  ( *var )[iRow][iCol] = (float)( ( *first )[iCol] );
1429  }
1430  //
1431  ++iRow;
1432  }
1433 
1434  return StatusCode::SUCCESS;
1435  }
1436  // =======================================================================
1515  template <class FUN, class DATA>
1516  StatusCode fmatrix( const std::string& name, FUN funF, FUN funL, DATA first, DATA last, const std::string& length,
1517  size_t maxv )
1518  {
1519  if ( invalid() ) {
1520  return InvalidTuple;
1521  }
1522  if ( rowWise() ) {
1523  return InvalidOperation;
1524  }
1525 
1526  // adjust the length
1527  if ( std::distance( first, last ) > static_cast<std::ptrdiff_t>( maxv ) ) {
1528  Warning( "fmatrix('" + name + "'): matrix is overflow, skip extra items" ).ignore();
1529  last = std::next( first, maxv );
1530  }
1531 
1532  // get the length item
1533  Int* len = ints( length, 0, maxv );
1534  if ( !len ) {
1535  return InvalidColumn;
1536  }
1537 
1538  // adjust the length item
1539  *len = std::distance( first, last );
1540 
1541  // get the array itself
1542  auto cols = std::distance( funF, funL );
1543  FMatrix* var = fMatrix( name, len, cols );
1544  if ( !var ) {
1545  return InvalidColumn;
1546  }
1547 
1549  size_t iRow = 0;
1550  for ( ; first != last; ++first ) {
1551  //
1552  for ( FUN fun = funF; fun < funL; ++fun ) {
1553  ( *var )[iRow][fun - funF] = ( *fun )( *first );
1554  }
1555  //
1556  ++iRow;
1557  }
1558 
1559  return StatusCode::SUCCESS;
1560  }
1561  // =======================================================================
1562  public:
1563  // =======================================================================
1586  template <class DATA>
1587  StatusCode array( const std::string& name, DATA first, DATA last )
1588 
1589  {
1590  if ( invalid() ) {
1591  return InvalidTuple;
1592  }
1593  if ( rowWise() ) {
1594  return InvalidOperation;
1595  }
1596 
1597  // get the length (fixed!)
1598  auto length = std::distance( first, last );
1599 
1600  // get the array itself
1601  FArray* var = fArray( name, length );
1602  if ( !var ) {
1603  return InvalidColumn;
1604  }
1605 
1607  std::copy( first, last, std::begin( *var ) );
1608 
1609  return StatusCode::SUCCESS;
1610  }
1611  // =======================================================================
1650  template <class ARRAY>
1651  StatusCode array( const std::string& name, const ARRAY& data, const MIndex& length )
1652  {
1653  using std::begin; // allow data to be eg. CLHEP::HepVector (which does not define HepVector::begin()!,
1654  // in which case ADL prefers CLHEP::begin (yah! at least they (now) use a namespace)
1655  // so one just to insure double* CLHEP::begin(CLHEP::HepVector& v) { return &v[0]; }
1656  // is visible when this function gets instantiated for CLHEP::HepVector...
1657  auto first = begin( data );
1658  return array( name, first, std::next( first, length ) );
1659  }
1660  // =======================================================================
1691  template <class ARRAY>
1692  StatusCode array( const std::string& name, const ARRAY& data )
1693  {
1694  using std::begin;
1695  using std::end;
1696  return array( name, begin( data ), end( data ) );
1697  }
1698  // =======================================================================
1699  public:
1700  // =======================================================================
1749  template <class MATRIX>
1750  StatusCode matrix( const std::string& name, const MATRIX& data, const MIndex& rows, const MIndex& cols )
1751  {
1752  if ( invalid() ) {
1753  return InvalidTuple;
1754  }
1755  if ( rowWise() ) {
1756  return InvalidOperation;
1757  }
1758 
1759  // get the matrix itself
1760  FMatrix* var = fMatrix( name, rows, cols );
1761  if ( !var ) {
1762  return InvalidColumn;
1763  }
1764 
1766  for ( size_t iCol = 0; iCol < cols; ++iCol ) {
1767  for ( size_t iRow = 0; iRow < rows; ++iRow ) {
1768  ( *var )[iRow][iCol] = data[iRow][iCol];
1769  }
1770  };
1771  return StatusCode::SUCCESS;
1772  }
1773  // =======================================================================
1774  public:
1775  // =======================================================================
1792  template <class TYPE>
1793  StatusCode column( const std::string& name, const ROOT::Math::LorentzVector<TYPE>& v )
1794  {
1795  return columns( v, std::make_pair( name + "E", &ROOT::Math::LorentzVector<TYPE>::E ),
1796  std::make_pair( name + "X", &ROOT::Math::LorentzVector<TYPE>::Px ),
1797  std::make_pair( name + "Y", &ROOT::Math::LorentzVector<TYPE>::Py ),
1798  std::make_pair( name + "Z", &ROOT::Math::LorentzVector<TYPE>::Pz ) );
1799  }
1800  // =======================================================================
1817  template <class TYPE, class TAG>
1819  {
1820  return this->columns( v, std::make_pair( name + "X", &ROOT::Math::DisplacementVector3D<TYPE, TAG>::X ),
1823  }
1824  // =======================================================================
1841  template <class TYPE, class TAG>
1843  {
1844  return this->columns( v, std::make_pair( name + "X", &ROOT::Math::PositionVector3D<TYPE, TAG>::X ),
1847  }
1848  // =======================================================================
1857  template <class TYPE, unsigned int D1, unsigned int D2, class REP>
1858  StatusCode matrix( const std::string& name, const ROOT::Math::SMatrix<TYPE, D1, D2, REP>& mtrx )
1859  {
1860  if ( invalid() ) {
1861  return InvalidTuple;
1862  }
1863  if ( rowWise() ) {
1864  return InvalidOperation;
1865  }
1866 
1867  // get the matrix itself
1868  FMatrix* var = fMatrix( name, (MIndex)D1, (MIndex)D2 );
1869  if ( !var ) {
1870  return InvalidColumn;
1871  }
1872 
1874  for ( size_t iCol = 0; iCol < D2; ++iCol ) {
1875  for ( size_t iRow = 0; iRow < D1; ++iRow ) {
1876  ( *var )[iRow][iCol] = mtrx( iRow, iCol );
1877  }
1878  };
1879 
1880  return StatusCode::SUCCESS;
1881  }
1882  // =======================================================================
1900  template <class KEY, class VALUE>
1902  const std::string& length, const size_t maxv = 100 )
1903  {
1904  using Info = std::pair<KEY, VALUE>;
1905  static const std::array<std::function<float( const Info& )>, 2> fns = {
1906  {[]( const Info& i ) { return i.first; }, []( const Info& i ) { return i.second; }}};
1907  return fmatrix( name, std::begin( fns ), std::end( fns ), std::begin( info ), std::end( info ), length, maxv );
1908  }
1909  // =======================================================================
1910  public:
1911  // =======================================================================
1919  template <class TYPE>
1920  StatusCode put( const std::string& name, const TYPE* obj );
1921  // =======================================================================
1922  public:
1923  // =======================================================================
1927  StatusCode write();
1928  // =======================================================================
1930  const std::string& name() const { return m_name; }
1931  // =======================================================================
1935  const NTuple::Tuple* tuple() const { return m_tuple; }
1936  // =======================================================================
1940  NTuple::Tuple* tuple() { return m_tuple; }
1941  // =======================================================================
1945  unsigned long refCount() const { return m_refCount; }
1946  // =======================================================================
1950  unsigned long addRef() { return ++m_refCount; }
1951  // =======================================================================
1956  void release();
1957  // =======================================================================
1959  const CLID& clid() const { return m_clid; }
1960  // =======================================================================
1962  Tuples::Type type() const { return m_type; }
1963  // =======================================================================
1965  bool columnWise() const { return CLID_ColumnWiseTuple == clid(); }
1966  // =======================================================================
1968  bool rowWise() const { return CLID_RowWiseTuple == clid(); }
1969  // =======================================================================
1971  bool evtColType() const { return Tuples::EVTCOL == type(); }
1972  // =======================================================================
1974  bool valid() const { return 0 != tuple(); }
1975  // =======================================================================
1977  bool invalid() const { return !valid(); }
1978  // =======================================================================
1979  public:
1980  // =======================================================================
1987  {
1988  return m_items.emplace( std::move( name ), std::move( type ) ).second;
1989  }
1990  // =======================================================================
1995  bool goodItem( const std::string& name ) const { return m_items.end() == m_items.find( name ); }
1996  // =======================================================================
1998  const ItemMap& items() const { return m_items; }
1999  // =======================================================================
2000  public:
2001  // =======================================================================
2002  virtual StatusCode Error( const std::string& msg, const StatusCode sc = StatusCode::FAILURE ) const = 0;
2003  // =======================================================================
2004  virtual StatusCode Warning( const std::string& msg, const StatusCode sc = StatusCode::FAILURE ) const = 0;
2005  // =======================================================================
2006  private:
2007  // =======================================================================
2009  Int* ints( const std::string& name, int minv, int maxv );
2010  // =======================================================================
2012  FArray* fArray( const std::string& name, Int* item );
2013  // =======================================================================
2015  FArray* fArray( const std::string& name, const MIndex& rows );
2016  // =======================================================================
2018  Address* addresses( const std::string& name );
2019  // =======================================================================
2021  FMatrix* fMatrix( const std::string& name, Int* item, const MIndex& cols );
2022  // =======================================================================
2024  FMatrix* fMatrix( const std::string& name, const MIndex& rows, const MIndex& cols );
2025  // =======================================================================
2026  private:
2027  // =======================================================================
2029  TupleObj() = delete;
2030  TupleObj( const TupleObj& ) = delete;
2031  TupleObj& operator=( const TupleObj& ) = delete;
2032  // =======================================================================
2033  private:
2034  // =======================================================================
2037  // =======================================================================
2040  // =======================================================================
2043  // =======================================================================
2046  // =======================================================================
2049  // =======================================================================
2052  // =======================================================================
2055  // =======================================================================
2058  // =======================================================================
2061  // =======================================================================
2064  // =======================================================================
2067  // =======================================================================
2070  // =======================================================================
2073  // =======================================================================
2076  // =======================================================================
2077  private:
2078  // =======================================================================
2081  // =======================================================================
2084  // =======================================================================
2087  // =======================================================================
2090  // =======================================================================
2092  size_t m_refCount = 0;
2093  // =======================================================================
2095  mutable Bools m_bools;
2096  // =======================================================================
2098  mutable Chars m_chars;
2099  // =======================================================================
2101  mutable UChars m_uchars;
2102  // =======================================================================
2104  mutable Shorts m_shorts;
2105  // =======================================================================
2107  mutable UShorts m_ushorts;
2108  // =======================================================================
2110  mutable Ints m_ints;
2111  // =======================================================================
2113  mutable UInts m_uints;
2114  // =======================================================================
2116  mutable LongLongs m_longlongs;
2117  // =======================================================================
2119  mutable ULongLongs m_ulonglongs;
2120  // =======================================================================
2122  mutable Floats m_floats;
2123  // =======================================================================
2125  mutable Doubles m_doubles;
2126  // =======================================================================
2128  mutable Addresses m_addresses;
2129  // =======================================================================
2131  mutable FArrays m_farrays;
2132  // =======================================================================
2134  mutable FArrays m_arraysf;
2135  // =======================================================================
2137  mutable FMatrices m_fmatrices;
2138  // =======================================================================
2140  mutable FMatrices m_matricesf;
2141  // =======================================================================
2143  ItemMap m_items;
2144  // =======================================================================
2145  };
2146  // ==========================================================================
2147 } // end of namespace Tuples
2148 // ============================================================================
2149 // GaudiAlg
2150 // ============================================================================
2151 #include "GaudiAlg/TuplePut.h"
2152 // ============================================================================
2153 // The END
2154 // ============================================================================
2155 #endif // GAUDIALG_TUPLEOBJ_H
2156 // ============================================================================
StatusCode column(const std::string &name, const ROOT::Math::DisplacementVector3D< TYPE, TAG > &v)
Useful shortcut to put 3D-Vector directly into N-Tuple:
Definition: TupleObj.h:1818
UShorts m_ushorts
the actual storage of all &#39;unsigned int&#39; columns
Definition: TupleObj.h:2107
FMatrices m_fmatrices
the actual storage of all &#39;FArray&#39; columns
Definition: TupleObj.h:2137
A bit modified version of &#39;Loki::AssocVector&#39; associative vector from Loki library by Andrei Alexandr...
Definition: VectorMap.h:103
CLID m_clid
tuple CLID
Definition: TupleObj.h:2086
std::map< std::string, std::string > ItemMap
Definition: TupleObj.h:249
const NTuple::Tuple * tuple() const
provide the access to underlying Gaudi N-tuple
Definition: TupleObj.h:1935
T copy(T...args)
StatusCode matrix(const std::string &name, const MATRIX &data, const MIndex &rows, const MIndex &cols)
fill N-Tuple with fixed-size matrix
Definition: TupleObj.h:1750
T forward_as_tuple(T...args)
T distance(T...args)
GAUDI_API std::string format(const char *,...)
MsgStream format utility "a la sprintf(...)".
Definition: MsgStream.cpp:120
NTuple::Item< float > Float
basic type for float items
Definition: TupleObj.h:231
bool goodItem(const std::string &name) const
check the uniqueness of the name
Definition: TupleObj.h:1995
bool evtColType() const
Event collection ?
Definition: TupleObj.h:1971
Doubles m_doubles
the actual storage of all &#39;Double&#39; columns
Definition: TupleObj.h:2125
Tuples::Type m_type
tuple &#39;type&#39;
Definition: TupleObj.h:2089
StatusCode farray(const Container< Item > &items, Iterator first, Iterator last, const std::string &length, size_t maxv)
Put arbitrary number of functions from one data array into LoKi-style N-Tuple simultaneously (effecti...
Definition: TupleObj.h:1077
StatusCode columns_helper(const Value &value, const Tuple &tup, std::index_sequence< I... >)
Set the values for several columns simultaneously, for the same object Non-existing columns will be a...
Definition: TupleObj.h:792
Class acting as a smart pointer holding a N tuple _Item.
Definition: NTuple.h:53
NTuple::Item< IOpaqueAddress * > Address
basic type for address items
Definition: TupleObj.h:237
FMatrices m_matricesf
the actual storage of all &#39;FMatrix&#39; columns (fixed)
Definition: TupleObj.h:2140
Floats m_floats
the actual storage of all &#39;Float&#39; columns
Definition: TupleObj.h:2122
GAUDI_API void fill(AIDA::IHistogram1D *histo, const double value, const double weight=1.0)
simple function to fill AIDA::IHistogram1D objects
Definition: Fill.cpp:35
NTuple::Item< unsigned long long > ULongLong
basic type for unsigned long long items
Definition: TupleObj.h:228
FArrays m_farrays
the actual storage of all &#39;FArray&#39; columns
Definition: TupleObj.h:2131
NTuple::Item< unsigned short > UShort
basic type for unsigned int items
Definition: TupleObj.h:216
T end(T...args)
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.
Definition: TupleObj.h:1314
unsigned short MIndex
Definition: TupleObj.h:246
GaudiUtils::HashMap< std::string, std::unique_ptr< Char > > Chars
the actual storage type for short columns
Definition: TupleObj.h:2039
std::string m_name
name
Definition: TupleObj.h:2080
NTuple::Tuple * tuple()
provide the access to underlying Gaudi N-tuple
Definition: TupleObj.h:1940
GaudiUtils::HashMap< std::string, std::unique_ptr< Short > > Shorts
the actual storage type for short columns
Definition: TupleObj.h:2045
FArrays m_arraysf
the actual storage of all &#39;FArray&#39; columns (fixed)
Definition: TupleObj.h:2134
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.
Definition: TupleObj.h:892
NTuple::Item< unsigned char > UChar
basic type for unsigned int items
Definition: TupleObj.h:210
Bools m_bools
the actual storage of all &#39;bool&#39; columns
Definition: TupleObj.h:2095
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)
Definition: reverse.h:58
bool columnWise() const
column wise NTuple ?
Definition: TupleObj.h:1965
PropertyMgr & operator=(const PropertyMgr &)=delete
constexpr double second
STL class.
NTuple::Item< short > Short
basic type for int items
Definition: TupleObj.h:213
Chars m_chars
the actual storage of all &#39;Int&#39; columns
Definition: TupleObj.h:2098
A simple wrapper class over standard Gaudi NTuple::Tuple facility.
Definition: Tuple.h:117
bool addItem(std::string name, std::string type)
add the item name into the list of known items
Definition: TupleObj.h:1986
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...
Definition: TupleObj.h:1516
GaudiUtils::HashMap< std::string, std::unique_ptr< Int > > Ints
the actual storage type for integer columns
Definition: TupleObj.h:2051
ULongLongs m_ulonglongs
the actual storage of all &#39;ulonglong&#39; columns
Definition: TupleObj.h:2119
TupleObj.h GaudiAlg/TupleObj.h namespace with few technical implementations.
A simple wrapper class over standard Gaudi NTuple::Tuple facility.
Definition: TupleObj.h:199
T next(T...args)
StatusCode array(const std::string &name, const ARRAY &data)
fill N-Tuple with fixed-size array
Definition: TupleObj.h:1692
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:28
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!) ...
Definition: TupleObj.h:1202
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.
Definition: TupleObj.h:942
NTuple::Matrix< float > FMatrix
basic type for matrix of floats
Definition: TupleObj.h:243
UInts m_uints
the actual storage of all &#39;unsigned int&#39; columns
Definition: TupleObj.h:2113
StatusCode matrix(const std::string &name, const ROOT::Math::SMatrix< TYPE, D1, D2, REP > &mtrx)
shortcut to put Smatrix into N-tuple:
Definition: TupleObj.h:1858
GaudiUtils::HashMap< std::string, std::unique_ptr< Double > > Doubles
the actual storage type for float columns
Definition: TupleObj.h:2066
GaudiUtils::HashMap< std::string, std::unique_ptr< FArray > > FArrays
the actual storage type for array columns
Definition: TupleObj.h:2072
T operator()(Arg &&i) const
Definition: TupleObj.h:67
GaudiUtils::HashMap< std::string, std::unique_ptr< UInt > > UInts
the actual storage type for unsigned integer columns
Definition: TupleObj.h:2054
T make_pair(T...args)
ItemMap m_items
all booked types:
Definition: TupleObj.h:2143
NTuple::Item< bool > Bool
basic type for int items
Definition: TupleObj.h:204
auto end(reverse_wrapper< T > &w)
Definition: reverse.h:64
NTuple::Item< double > Double
basic type for double items
Definition: TupleObj.h:234
GaudiUtils::HashMap< std::string, std::unique_ptr< FMatrix > > FMatrices
the actual storage type for matrix columns
Definition: TupleObj.h:2075
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!) ...
Definition: TupleObj.h:1158
Specialization acting as a smart pointer holding a N tuple _Item.
Definition: NTuple.h:318
Ints m_ints
the actual storage of all &#39;Int&#39; columns
Definition: TupleObj.h:2110
unsigned int CLID
Class ID definition.
Definition: ClassID.h:8
GaudiUtils::HashMap< std::string, std::unique_ptr< Bool > > Bools
the actual storage type for short columns
Definition: TupleObj.h:2036
LongLongs m_longlongs
the actual storage of all &#39;longlong&#39; columns
Definition: TupleObj.h:2116
GaudiUtils::HashMap< std::string, std::unique_ptr< LongLong > > LongLongs
the actual storage type for longlong columns
Definition: TupleObj.h:2057
bool valid() const
valid pointer to tuple ?
Definition: TupleObj.h:1974
T move(T...args)
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.
Definition: TupleObj.h:1392
unsigned long addRef()
add the reference to TupleObj
Definition: TupleObj.h:1950
unsigned long refCount() const
return the reference counter
Definition: TupleObj.h:1945
bool rowWise() const
row wise NTuple ?
Definition: TupleObj.h:1968
Stream & ostream_joiner(Stream &os, Iterator first, Iterator last, Separator sep, OutputElement output=OutputElement{})
Definition: SerializeSTL.h:40
Abstract base class which allows the user to interact with the actual N tuple implementation.
Definition: NTuple.h:412
typename std::add_const< typename std::iterator_traits< Iterator >::reference >::type const_ref_t
Definition: TupleObj.h:76
StatusCode column(const std::string &name, signed char value)
Set the value for the selected tuple column.
Definition: TupleObj.h:707
ErrorCodes
Tuple error codes.
Definition: TupleObj.h:96
NTuple::Item< long long > LongLong
basic type for unsigned long long items
Definition: TupleObj.h:225
Addresses m_addresses
the actual storage of all &#39;Address&#39; columns
Definition: TupleObj.h:2128
T find_if_not(T...args)
GaudiUtils::HashMap< std::string, std::unique_ptr< ULongLong > > ULongLongs
the actual storage type for ulonglong columns
Definition: TupleObj.h:2060
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!) ...
Definition: TupleObj.h:1250
StatusCode array(const std::string &name, DATA first, DATA last)
fill N-Tuple with fixed-size array
Definition: TupleObj.h:1587
struct GAUDI_API array
Parametrisation class for redirection array - like implementation.
STL class.
NTuple::Tuple * m_tuple
tuple itself
Definition: TupleObj.h:2083
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
Definition: TupleObj.h:1901
T cref(T...args)
Tuples::Type type() const
accessor to the N-Tuple type
Definition: TupleObj.h:1962
boost::spirit::classic::position_iterator2< ForwardIterator > Iterator
Definition: Iterator.h:18
T begin(T...args)
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.
Definition: TupleObj.h:1010
T back_inserter(T...args)
T any_of(T...args)
double fun(const std::vector< double > &x)
Definition: PFuncTest.cpp:26
NTuple::Item< char > Char
basic type for int items
Definition: TupleObj.h:207
Common class providing an architecture-independent hash map.
Definition: HashMap.h:74
STL class.
NTuple::Item< int > Int
basic type for int items
Definition: TupleObj.h:219
GaudiUtils::HashMap< std::string, std::unique_ptr< UShort > > UShorts
the actual storage type for unsigned short columns
Definition: TupleObj.h:2048
StatusCode column(const std::string &name, const ROOT::Math::LorentzVector< TYPE > &v)
Useful shortcut to put LorentzVector directly into N-Tuple:
Definition: TupleObj.h:1793
Shorts m_shorts
the actual storage of all &#39;Int&#39; columns
Definition: TupleObj.h:2104
bool invalid() const
invalid pointer to tuple ?
Definition: TupleObj.h:1977
T transform(T...args)
const ItemMap & items() const
get the full list of booked items
Definition: TupleObj.h:1998
NTuple::Array< float > FArray
basic type for array of floats
Definition: TupleObj.h:240
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)...))
Definition: invoke.h:83
Implementation file for Tuple::TupleObj::put method.
Opaque address interface definition.
Class acting as a smart pointer holding a N tuple _Item.
Definition: NTuple.h:49
const CLID & clid() const
accessor to the N-Tuple CLID
Definition: TupleObj.h:1959
StatusCode array(const std::string &name, const ARRAY &data, const MIndex &length)
fill N-Tuple with fixed-size array
Definition: TupleObj.h:1651
T for_each(T...args)
GaudiUtils::HashMap< std::string, std::unique_ptr< UChar > > UChars
the actual storage type for unsigned short columns
Definition: TupleObj.h:2042
Class acting as a smart pointer holding a N tuple _Item.
Definition: NTuple.h:51
GaudiUtils::HashMap< std::string, std::unique_ptr< Address > > Addresses
the actual storage type for address columns
Definition: TupleObj.h:2069
#define GAUDI_API
Definition: Kernel.h:110
Type
the list of available types for ntuples
Definition: TupleObj.h:84
STL class.
const std::string & name() const
get the name
Definition: TupleObj.h:1930
NTuple::Item< unsigned int > UInt
basic type for unsigned int items
Definition: TupleObj.h:222
StatusCode columns(Value &&value, Args &&...args)
Definition: TupleObj.h:808
UChars m_uchars
the actual storage of all &#39;unsigned int&#39; columns
Definition: TupleObj.h:2101
Out1 * put(DataObjectHandle< Out1 > &out_handle, Out2 &&out)
T reserve(T...args)
GaudiUtils::HashMap< std::string, std::unique_ptr< Float > > Floats
the actual storage type for float columns
Definition: TupleObj.h:2063
General namespace for Tuple properties.
Definition: Maps.h:34
StatusCode column(const std::string &name, const ROOT::Math::PositionVector3D< TYPE, TAG > &v)
Useful shortcut to put 3D-Vector directly into N-Tuple:
Definition: TupleObj.h:1842