Loading [MathJax]/extensions/tex2jax.js
The Gaudi Framework  v29r3 (fa547fc2)
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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  // =======================================================================
1074  template <typename FunIterator, typename DataIterator>
1075  StatusCode farray_impl( FunIterator first_item, FunIterator last_item, DataIterator first, DataIterator last,
1076  const std::string& length, size_t maxv )
1077  {
1078  if ( invalid() ) return InvalidTuple;
1079  if ( rowWise() ) return InvalidOperation;
1080 
1081  // adjust the length
1082  if ( std::distance( first, last ) > static_cast<std::ptrdiff_t>( maxv ) ) {
1084  std::ostringstream os;
1085  ostream_joiner( os, first_item, last_item, ",",
1086  []( std::ostream& os, const auto& i ) -> std::ostream& { return os << i.first; } );
1087  Warning( "farray('" + os.str() + "'): array overflow, skipping extra entries" ).ignore();
1088  last = std::next( first, maxv );
1089  }
1090 
1091  // get the length item
1092  Int* len = ints( length, 0, maxv );
1093  if ( !len ) {
1094  return InvalidColumn;
1095  }
1096 
1097  // adjust the length
1098  *len = std::distance( first, last );
1099 
1100  // get the arrays themselves
1101  std::vector<FArray*> vars;
1102  vars.reserve( std::distance( first_item, last_item ) );
1103  std::transform( first_item, last_item, std::back_inserter( vars ),
1104  [&]( const auto& item ) { return this->fArray( item.first, len ); } );
1105  if ( std::any_of( vars.begin(), vars.end(), []( const FArray* f ) { return !f; } ) ) {
1106  return InvalidColumn;
1107  }
1108 
1109  // fill the array
1110  for ( size_t index = 0; first != last; ++first, ++index ) {
1111  auto item = first_item;
1112  for ( auto& var : vars ) {
1113  ( *var )[index] = ( item++ )->second( *first );
1114  }
1115  }
1116 
1117  return StatusCode::SUCCESS;
1118  }
1119 
1120  template <
1121  typename DataIterator, template <typename, typename...> class Container = std::initializer_list,
1123  typename = std::enable_if_t<!std::is_convertible<Container<NamedFunction>, std::string>::value>>
1124  StatusCode farray( const Container<NamedFunction>& funs, DataIterator first, DataIterator last,
1125  const std::string& length, size_t maxv )
1126  {
1127  return farray_impl( funs.begin(), funs.end(), std::forward<DataIterator>( first ),
1128  std::forward<DataIterator>( last ), length, maxv );
1129  }
1130 
1131  template <typename NamedFunctions, typename DataIterator,
1132  typename = std::enable_if_t<!std::is_convertible<NamedFunctions, std::string>::value>>
1133  StatusCode farray( const NamedFunctions& funs, DataIterator first, DataIterator last, const std::string& length,
1134  size_t maxv )
1135  {
1136  return farray_impl( funs.begin(), funs.end(), std::forward<DataIterator>( first ),
1137  std::forward<DataIterator>( last ), length, maxv );
1138  }
1139  // =======================================================================
1171  template <class FUNC1, class FUNC2, class Iterator>
1172  StatusCode farray( const std::string& name1, const FUNC1& func1, const std::string& name2, const FUNC2& func2,
1173  Iterator&& first, Iterator&& last, const std::string& length, size_t maxv )
1174  {
1175  return farray( {{name1, std::cref( func1 )}, {name2, std::cref( func2 )}}, std::forward<Iterator>( first ),
1176  std::forward<Iterator>( last ), length, maxv );
1177  }
1178  // =======================================================================
1215  template <class FUNC1, class FUNC2, class FUNC3, class Iterator>
1216  StatusCode farray( const std::string& name1, const FUNC1& func1, const std::string& name2, const FUNC2& func2,
1217  const std::string& name3, const FUNC3& func3, Iterator&& first, Iterator&& last,
1218  const std::string& length, size_t maxv )
1219  {
1220  return farray( {{name1, std::cref( func1 )}, {name2, std::cref( func2 )}, {name3, std::cref( func3 )}},
1221  std::forward<Iterator>( first ), std::forward<Iterator>( last ), length, maxv );
1222  }
1223  // =======================================================================
1263  template <class FUNC1, class FUNC2, class FUNC3, class FUNC4, class Iterator>
1264  StatusCode farray( const std::string& name1, const FUNC1& func1, const std::string& name2, const FUNC2& func2,
1265  const std::string& name3, const FUNC3& func3, const std::string& name4, const FUNC4& func4,
1266  Iterator&& first, Iterator&& last, const std::string& length, size_t maxv )
1267  {
1268  return farray( {{name1, std::cref( func1 )},
1269  {name2, std::cref( func2 )},
1270  {name3, std::cref( func3 )},
1271  {name4, std::cref( func4 )}},
1272  std::forward<Iterator>( first ), std::forward<Iterator>( last ), length, maxv );
1273  }
1274  // =======================================================================
1275  public:
1276  // =======================================================================
1327  template <class MATRIX>
1328  StatusCode fmatrix( const std::string& name, const MATRIX& data, size_t rows, const MIndex& cols,
1329  const std::string& length, size_t maxv )
1330  {
1331  if ( invalid() ) {
1332  return InvalidTuple;
1333  }
1334  if ( rowWise() ) {
1335  return InvalidOperation;
1336  }
1337 
1338  // adjust the length
1339  if ( rows >= maxv ) {
1340  Warning( "fmatrix('" + name + "'): matrix is overflow, skip extra items" ).ignore();
1341  rows = ( 0 < maxv ) ? ( maxv - 1 ) : 0;
1342  }
1343 
1344  // get the length item
1345  Int* len = ints( length, 0, maxv );
1346  if ( !len ) {
1347  return InvalidColumn;
1348  }
1349 
1350  // adjust the length item
1351  *len = rows;
1352 
1353  // get the array itself
1354  FMatrix* var = fMatrix( name, len, cols );
1355  if ( !var ) {
1356  return InvalidColumn;
1357  }
1358 
1360  for ( size_t iCol = 0; iCol < cols; ++iCol ) {
1361  for ( MIndex iRow = 0; iRow < rows; ++iRow ) {
1362  ( *var )[iRow][iCol] = data[iRow][iCol];
1363  }
1364  }
1365 
1366  return StatusCode::SUCCESS;
1367  }
1368  // =======================================================================
1405  template <class DATA>
1406  StatusCode fmatrix( const std::string& name, DATA first, DATA last, const MIndex& cols, const std::string& length,
1407  size_t maxv )
1408  {
1409  if ( invalid() ) {
1410  return InvalidTuple;
1411  }
1412  if ( rowWise() ) {
1413  return InvalidOperation;
1414  }
1415 
1416  // adjust the length
1417  if ( first + maxv < last ) {
1418  Warning( "fmatrix('" + name + "'): matrix is overflow, skip extra items" ).ignore();
1419  last = first + maxv;
1420  }
1421 
1422  // get the length item
1423  Int* len = ints( length, 0, maxv );
1424  if ( !len ) {
1425  return InvalidColumn;
1426  }
1427 
1428  // adjust the length item
1429  *len = last - first;
1430 
1431  // get the array itself
1432  FMatrix* var = fMatrix( name, len, cols );
1433  if ( !var ) {
1434  return InvalidColumn;
1435  }
1436 
1438  size_t iRow = 0;
1439  for ( ; first != last; ++first ) {
1440  //
1441  for ( MIndex iCol = 0; iCol < cols; ++iCol ) {
1442  ( *var )[iRow][iCol] = (float)( ( *first )[iCol] );
1443  }
1444  //
1445  ++iRow;
1446  }
1447 
1448  return StatusCode::SUCCESS;
1449  }
1450  // =======================================================================
1529  template <class FUN, class DATA>
1530  StatusCode fmatrix( const std::string& name, FUN funF, FUN funL, DATA first, DATA last, const std::string& length,
1531  size_t maxv )
1532  {
1533  if ( invalid() ) {
1534  return InvalidTuple;
1535  }
1536  if ( rowWise() ) {
1537  return InvalidOperation;
1538  }
1539 
1540  // adjust the length
1541  if ( std::distance( first, last ) > static_cast<std::ptrdiff_t>( maxv ) ) {
1542  Warning( "fmatrix('" + name + "'): matrix is overflow, skip extra items" ).ignore();
1543  last = std::next( first, maxv );
1544  }
1545 
1546  // get the length item
1547  Int* len = ints( length, 0, maxv );
1548  if ( !len ) {
1549  return InvalidColumn;
1550  }
1551 
1552  // adjust the length item
1553  *len = std::distance( first, last );
1554 
1555  // get the array itself
1556  auto cols = std::distance( funF, funL );
1557  FMatrix* var = fMatrix( name, len, cols );
1558  if ( !var ) {
1559  return InvalidColumn;
1560  }
1561 
1563  size_t iRow = 0;
1564  for ( ; first != last; ++first ) {
1565  //
1566  for ( FUN fun = funF; fun < funL; ++fun ) {
1567  ( *var )[iRow][fun - funF] = ( *fun )( *first );
1568  }
1569  //
1570  ++iRow;
1571  }
1572 
1573  return StatusCode::SUCCESS;
1574  }
1575  // =======================================================================
1576  public:
1577  // =======================================================================
1600  template <class DATA>
1601  StatusCode array( const std::string& name, DATA first, DATA last )
1602 
1603  {
1604  if ( invalid() ) {
1605  return InvalidTuple;
1606  }
1607  if ( rowWise() ) {
1608  return InvalidOperation;
1609  }
1610 
1611  // get the length (fixed!)
1612  auto length = std::distance( first, last );
1613 
1614  // get the array itself
1615  FArray* var = fArray( name, length );
1616  if ( !var ) {
1617  return InvalidColumn;
1618  }
1619 
1621  std::copy( first, last, std::begin( *var ) );
1622 
1623  return StatusCode::SUCCESS;
1624  }
1625  // =======================================================================
1664  template <class ARRAY>
1665  StatusCode array( const std::string& name, const ARRAY& data, const MIndex& length )
1666  {
1667  using std::begin; // allow data to be eg. CLHEP::HepVector (which does not define HepVector::begin()!,
1668  // in which case ADL prefers CLHEP::begin (yah! at least they (now) use a namespace)
1669  // so one just to insure double* CLHEP::begin(CLHEP::HepVector& v) { return &v[0]; }
1670  // is visible when this function gets instantiated for CLHEP::HepVector...
1671  auto first = begin( data );
1672  return array( name, first, std::next( first, length ) );
1673  }
1674  // =======================================================================
1705  template <class ARRAY>
1706  StatusCode array( const std::string& name, const ARRAY& data )
1707  {
1708  using std::begin;
1709  using std::end;
1710  return array( name, begin( data ), end( data ) );
1711  }
1712  // =======================================================================
1713  public:
1714  // =======================================================================
1763  template <class MATRIX>
1764  StatusCode matrix( const std::string& name, const MATRIX& data, const MIndex& rows, const MIndex& cols )
1765  {
1766  if ( invalid() ) {
1767  return InvalidTuple;
1768  }
1769  if ( rowWise() ) {
1770  return InvalidOperation;
1771  }
1772 
1773  // get the matrix itself
1774  FMatrix* var = fMatrix( name, rows, cols );
1775  if ( !var ) {
1776  return InvalidColumn;
1777  }
1778 
1780  for ( size_t iCol = 0; iCol < cols; ++iCol ) {
1781  for ( size_t iRow = 0; iRow < rows; ++iRow ) {
1782  ( *var )[iRow][iCol] = data[iRow][iCol];
1783  }
1784  };
1785  return StatusCode::SUCCESS;
1786  }
1787  // =======================================================================
1788  public:
1789  // =======================================================================
1806  template <class TYPE>
1807  StatusCode column( const std::string& name, const ROOT::Math::LorentzVector<TYPE>& v )
1808  {
1809  return columns( v, std::make_pair( name + "E", &ROOT::Math::LorentzVector<TYPE>::E ),
1810  std::make_pair( name + "X", &ROOT::Math::LorentzVector<TYPE>::Px ),
1811  std::make_pair( name + "Y", &ROOT::Math::LorentzVector<TYPE>::Py ),
1812  std::make_pair( name + "Z", &ROOT::Math::LorentzVector<TYPE>::Pz ) );
1813  }
1814  // =======================================================================
1831  template <class TYPE, class TAG>
1833  {
1834  return this->columns( v, std::make_pair( name + "X", &ROOT::Math::DisplacementVector3D<TYPE, TAG>::X ),
1837  }
1838  // =======================================================================
1855  template <class TYPE, class TAG>
1857  {
1858  return this->columns( v, std::make_pair( name + "X", &ROOT::Math::PositionVector3D<TYPE, TAG>::X ),
1861  }
1862  // =======================================================================
1871  template <class TYPE, unsigned int D1, unsigned int D2, class REP>
1872  StatusCode matrix( const std::string& name, const ROOT::Math::SMatrix<TYPE, D1, D2, REP>& mtrx )
1873  {
1874  if ( invalid() ) {
1875  return InvalidTuple;
1876  }
1877  if ( rowWise() ) {
1878  return InvalidOperation;
1879  }
1880 
1881  // get the matrix itself
1882  FMatrix* var = fMatrix( name, (MIndex)D1, (MIndex)D2 );
1883  if ( !var ) {
1884  return InvalidColumn;
1885  }
1886 
1888  for ( size_t iCol = 0; iCol < D2; ++iCol ) {
1889  for ( size_t iRow = 0; iRow < D1; ++iRow ) {
1890  ( *var )[iRow][iCol] = mtrx( iRow, iCol );
1891  }
1892  };
1893 
1894  return StatusCode::SUCCESS;
1895  }
1896  // =======================================================================
1914  template <class KEY, class VALUE>
1916  const std::string& length, const size_t maxv = 100 )
1917  {
1918  using Info = std::pair<KEY, VALUE>;
1919  static const std::array<std::function<float( const Info& )>, 2> fns = {
1920  {[]( const Info& i ) { return i.first; }, []( const Info& i ) { return i.second; }}};
1921  return fmatrix( name, std::begin( fns ), std::end( fns ), std::begin( info ), std::end( info ), length, maxv );
1922  }
1923  // =======================================================================
1924  public:
1925  // =======================================================================
1933  template <class TYPE>
1934  StatusCode put( const std::string& name, const TYPE* obj );
1935  // =======================================================================
1936  public:
1937  // =======================================================================
1941  StatusCode write();
1942  // =======================================================================
1944  const std::string& name() const { return m_name; }
1945  // =======================================================================
1949  const NTuple::Tuple* tuple() const { return m_tuple; }
1950  // =======================================================================
1954  NTuple::Tuple* tuple() { return m_tuple; }
1955  // =======================================================================
1959  unsigned long refCount() const { return m_refCount; }
1960  // =======================================================================
1964  unsigned long addRef() { return ++m_refCount; }
1965  // =======================================================================
1970  void release();
1971  // =======================================================================
1973  const CLID& clid() const { return m_clid; }
1974  // =======================================================================
1976  Tuples::Type type() const { return m_type; }
1977  // =======================================================================
1979  bool columnWise() const { return CLID_ColumnWiseTuple == clid(); }
1980  // =======================================================================
1982  bool rowWise() const { return CLID_RowWiseTuple == clid(); }
1983  // =======================================================================
1985  bool evtColType() const { return Tuples::EVTCOL == type(); }
1986  // =======================================================================
1988  bool valid() const { return 0 != tuple(); }
1989  // =======================================================================
1991  bool invalid() const { return !valid(); }
1992  // =======================================================================
1993  public:
1994  // =======================================================================
2001  {
2002  return m_items.emplace( std::move( name ), std::move( type ) ).second;
2003  }
2004  // =======================================================================
2009  bool goodItem( const std::string& name ) const { return m_items.end() == m_items.find( name ); }
2010  // =======================================================================
2012  const ItemMap& items() const { return m_items; }
2013  // =======================================================================
2014  public:
2015  // =======================================================================
2016  virtual StatusCode Error( const std::string& msg, const StatusCode sc = StatusCode::FAILURE ) const = 0;
2017  // =======================================================================
2018  virtual StatusCode Warning( const std::string& msg, const StatusCode sc = StatusCode::FAILURE ) const = 0;
2019  // =======================================================================
2020  private:
2021  // =======================================================================
2023  Int* ints( const std::string& name, int minv, int maxv );
2024  // =======================================================================
2026  FArray* fArray( const std::string& name, Int* item );
2027  // =======================================================================
2029  FArray* fArray( const std::string& name, const MIndex& rows );
2030  // =======================================================================
2032  Address* addresses( const std::string& name );
2033  // =======================================================================
2035  FMatrix* fMatrix( const std::string& name, Int* item, const MIndex& cols );
2036  // =======================================================================
2038  FMatrix* fMatrix( const std::string& name, const MIndex& rows, const MIndex& cols );
2039  // =======================================================================
2040  private:
2041  // =======================================================================
2043  TupleObj() = delete;
2044  TupleObj( const TupleObj& ) = delete;
2045  TupleObj& operator=( const TupleObj& ) = delete;
2046  // =======================================================================
2047  private:
2048  // =======================================================================
2051  // =======================================================================
2054  // =======================================================================
2057  // =======================================================================
2060  // =======================================================================
2063  // =======================================================================
2066  // =======================================================================
2069  // =======================================================================
2072  // =======================================================================
2075  // =======================================================================
2078  // =======================================================================
2081  // =======================================================================
2084  // =======================================================================
2087  // =======================================================================
2090  // =======================================================================
2091  private:
2092  // =======================================================================
2095  // =======================================================================
2098  // =======================================================================
2101  // =======================================================================
2104  // =======================================================================
2106  size_t m_refCount = 0;
2107  // =======================================================================
2109  mutable Bools m_bools;
2110  // =======================================================================
2112  mutable Chars m_chars;
2113  // =======================================================================
2115  mutable UChars m_uchars;
2116  // =======================================================================
2118  mutable Shorts m_shorts;
2119  // =======================================================================
2121  mutable UShorts m_ushorts;
2122  // =======================================================================
2124  mutable Ints m_ints;
2125  // =======================================================================
2127  mutable UInts m_uints;
2128  // =======================================================================
2130  mutable LongLongs m_longlongs;
2131  // =======================================================================
2133  mutable ULongLongs m_ulonglongs;
2134  // =======================================================================
2136  mutable Floats m_floats;
2137  // =======================================================================
2139  mutable Doubles m_doubles;
2140  // =======================================================================
2142  mutable Addresses m_addresses;
2143  // =======================================================================
2145  mutable FArrays m_farrays;
2146  // =======================================================================
2148  mutable FArrays m_arraysf;
2149  // =======================================================================
2151  mutable FMatrices m_fmatrices;
2152  // =======================================================================
2154  mutable FMatrices m_matricesf;
2155  // =======================================================================
2157  ItemMap m_items;
2158  // =======================================================================
2159  };
2160  // ==========================================================================
2161 } // end of namespace Tuples
2162 // ============================================================================
2163 // GaudiAlg
2164 // ============================================================================
2165 #include "GaudiAlg/TuplePut.h"
2166 // ============================================================================
2167 // The END
2168 // ============================================================================
2169 #endif // GAUDIALG_TUPLEOBJ_H
2170 // ============================================================================
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:1832
UShorts m_ushorts
the actual storage of all &#39;unsigned int&#39; columns
Definition: TupleObj.h:2121
FMatrices m_fmatrices
the actual storage of all &#39;FArray&#39; columns
Definition: TupleObj.h:2151
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:2100
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:1949
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:1764
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:2009
bool evtColType() const
Event collection ?
Definition: TupleObj.h:1985
Doubles m_doubles
the actual storage of all &#39;Double&#39; columns
Definition: TupleObj.h:2139
Tuples::Type m_type
tuple &#39;type&#39;
Definition: TupleObj.h:2103
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:2154
Floats m_floats
the actual storage of all &#39;Float&#39; columns
Definition: TupleObj.h:2136
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:2145
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:1328
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:2053
std::string m_name
name
Definition: TupleObj.h:2094
NTuple::Tuple * tuple()
provide the access to underlying Gaudi N-tuple
Definition: TupleObj.h:1954
GaudiUtils::HashMap< std::string, std::unique_ptr< Short > > Shorts
the actual storage type for short columns
Definition: TupleObj.h:2059
FArrays m_arraysf
the actual storage of all &#39;FArray&#39; columns (fixed)
Definition: TupleObj.h:2148
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:2109
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:1979
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:2112
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:2000
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:1530
GaudiUtils::HashMap< std::string, std::unique_ptr< Int > > Ints
the actual storage type for integer columns
Definition: TupleObj.h:2065
ULongLongs m_ulonglongs
the actual storage of all &#39;ulonglong&#39; columns
Definition: TupleObj.h:2133
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:1706
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
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:1216
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:2127
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:1872
GaudiUtils::HashMap< std::string, std::unique_ptr< Double > > Doubles
the actual storage type for float columns
Definition: TupleObj.h:2080
GaudiUtils::HashMap< std::string, std::unique_ptr< FArray > > FArrays
the actual storage type for array columns
Definition: TupleObj.h:2086
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:2068
T make_pair(T...args)
ItemMap m_items
all booked types:
Definition: TupleObj.h:2157
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:2089
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:1172
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:2124
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:2050
LongLongs m_longlongs
the actual storage of all &#39;longlong&#39; columns
Definition: TupleObj.h:2130
GaudiUtils::HashMap< std::string, std::unique_ptr< LongLong > > LongLongs
the actual storage type for longlong columns
Definition: TupleObj.h:2071
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...
Definition: TupleObj.h:1075
bool valid() const
valid pointer to tuple ?
Definition: TupleObj.h:1988
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:1406
unsigned long addRef()
add the reference to TupleObj
Definition: TupleObj.h:1964
unsigned long refCount() const
return the reference counter
Definition: TupleObj.h:1959
bool rowWise() const
row wise NTuple ?
Definition: TupleObj.h:1982
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:2142
StatusCode farray(const NamedFunctions &funs, DataIterator first, DataIterator last, const std::string &length, size_t maxv)
Definition: TupleObj.h:1133
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:2074
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:1264
StatusCode array(const std::string &name, DATA first, DATA last)
fill N-Tuple with fixed-size array
Definition: TupleObj.h:1601
struct GAUDI_API array
Parametrisation class for redirection array - like implementation.
STL class.
NTuple::Tuple * m_tuple
tuple itself
Definition: TupleObj.h:2097
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:1915
T cref(T...args)
Tuples::Type type() const
accessor to the N-Tuple type
Definition: TupleObj.h:1976
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)
StatusCode farray(const Container< NamedFunction > &funs, DataIterator first, DataIterator last, const std::string &length, size_t maxv)
Definition: TupleObj.h:1124
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:2062
StatusCode column(const std::string &name, const ROOT::Math::LorentzVector< TYPE > &v)
Useful shortcut to put LorentzVector directly into N-Tuple:
Definition: TupleObj.h:1807
Shorts m_shorts
the actual storage of all &#39;Int&#39; columns
Definition: TupleObj.h:2118
bool invalid() const
invalid pointer to tuple ?
Definition: TupleObj.h:1991
T transform(T...args)
const ItemMap & items() const
get the full list of booked items
Definition: TupleObj.h:2012
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:85
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:1973
StatusCode array(const std::string &name, const ARRAY &data, const MIndex &length)
fill N-Tuple with fixed-size array
Definition: TupleObj.h:1665
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:2056
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:2083
#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:1944
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:2115
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:2077
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:1856