The Gaudi Framework  v32r2 (46d42edc)
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 // ============================================================================
24 // GaudiAlg
25 // ============================================================================
26 #include "GaudiAlg/Maps.h"
27 #include "GaudiAlg/Tuples.h"
28 // ============================================================================
29 // ROOT
30 // ============================================================================
31 #include "Math/Point3D.h"
32 #include "Math/SMatrix.h"
33 #include "Math/SVector.h"
34 #include "Math/Vector3D.h"
35 #include "Math/Vector4D.h"
36 // ============================================================================
37 // forward declaration
38 // ============================================================================
39 // GaudiKernel
40 // ============================================================================
41 class IOpaqueAddress;
42 // ============================================================================
51 // ============================================================================
59 namespace Tuples {
60  namespace detail {
61  template <typename T>
62  struct to_ {
63  template <typename Arg>
64  T operator()( Arg&& i ) const {
65  return T( std::forward<Arg>( i ) );
66  }
67  };
68  constexpr to_<float> to_float{};
69 
70  template <typename Iterator>
71  using const_ref_t = std::add_const_t<typename std::iterator_traits<Iterator>::reference>;
72  } // namespace detail
73  // ==========================================================================
79  enum Type {
80  NTUPLE, // Analysis nTuple
81  EVTCOL // Event Collection
82  };
83  // ==========================================================================
92  InvalidTuple = 100,
97  TruncateValue = 200
98  };
99 } // namespace Tuples
100 
102 
103 namespace Tuples {
104  // ==========================================================================
200  public:
201  // ========================================================================
204  // ========================================================================
207  // ========================================================================
210  // ========================================================================
213  // ========================================================================
216  // ========================================================================
219  // ========================================================================
222  // ========================================================================
225  // ========================================================================
228  // ========================================================================
231  // ========================================================================
234  // ========================================================================
237  // ========================================================================
240  // ========================================================================
243  // ========================================================================
244  // the actual type for variable size matrix indices
245  typedef unsigned short MIndex;
246  // ========================================================================
247  // the map of all items
249  // ========================================================================
250  protected:
251  // ========================================================================
259  TupleObj( std::string name, NTuple::Tuple* tuple, const CLID& clid = CLID_ColumnWiseTuple,
260  const Tuples::Type type = Tuples::NTUPLE );
261  // ========================================================================
262  public:
263  // ========================================================================
264  virtual ~TupleObj();
265  // ========================================================================
281  StatusCode column( const std::string& name, float value );
282  // ========================================================================
283  public:
284  // ========================================================================
301  StatusCode column( const std::string& name, double value );
302  // ========================================================================
303  public:
304  // ========================================================================
320  StatusCode column( const std::string& name, short value );
321  // ========================================================================
339  StatusCode column( const std::string& name, short value, short minv, short maxv );
340  // ========================================================================
341  public:
342  // ========================================================================
358  StatusCode column( const std::string& name, unsigned short value );
359  // ========================================================================
377  StatusCode column( const std::string& name, unsigned short value, unsigned short minv, unsigned short maxv );
378  // ========================================================================
379  public:
380  // ========================================================================
396  StatusCode column( const std::string& name, char value );
397  // ========================================================================
415  StatusCode column( const std::string& name, char value, char minv, char maxv );
416  // ========================================================================
417  public:
418  // ========================================================================
434  StatusCode column( const std::string& name, unsigned char value );
435  // ========================================================================
453  StatusCode column( const std::string& name, unsigned char value, unsigned char minv, unsigned char maxv );
454  // ========================================================================
455  public:
456  // ========================================================================
472  StatusCode column( const std::string& name, int value );
473  // ========================================================================
491  StatusCode column( const std::string& name, int value, int minv, int maxv );
492  // ========================================================================
493  public:
494  // ========================================================================
510  StatusCode column( const std::string& name, unsigned int value );
511  // ========================================================================
529  StatusCode column( const std::string& name, unsigned int value, unsigned int minv, unsigned int maxv );
530  // ========================================================================
531  public:
532  // ========================================================================
549  StatusCode column( const std::string& name, long value );
550  // ========================================================================
568  StatusCode column( const std::string& name, long value, long minv, long maxv );
569  // ========================================================================
570  public:
571  // ========================================================================
588  StatusCode column( const std::string& name, unsigned long value );
589  // ========================================================================
607  StatusCode column( const std::string& name, unsigned long value, unsigned long minv, unsigned long maxv );
608  // ========================================================================
609  public:
610  // ========================================================================
626  StatusCode column( const std::string& name, long long value );
627  // ========================================================================
645  StatusCode column( const std::string& name, long long value, long long minv, long long maxv );
646  // ========================================================================
647  public:
648  // ========================================================================
664  StatusCode column( const std::string& name, unsigned long long value );
665  // ========================================================================
683  StatusCode column( const std::string& name, unsigned long long value, unsigned long long minv,
684  unsigned long long maxv );
685  // ========================================================================
686  public:
687  // ========================================================================
703  StatusCode column( const std::string& name, signed char value ) {
705  }
706  // ========================================================================
707  public:
708  // ========================================================================
723  StatusCode column( const std::string& name, bool value );
724  // ========================================================================
725  public:
726  // ========================================================================
745  StatusCode column( const std::string& name, IOpaqueAddress* address );
746  // ========================================================================
763  StatusCode column( IOpaqueAddress* address );
764  // ========================================================================
765  public:
766  // ========================================================================
786  template <typename Value, typename... Args>
787  StatusCode columns( Value&& value, Args&&... args ) {
788  if ( sizeof...( Args ) == 0 ) return StatusCode::SUCCESS;
790  this->column( std::get<0>( args ), std::invoke( std::get<1>( args ), value ) )...};
791  return std::accumulate( std::next( begin( scs ) ), end( scs ), *begin( scs ),
792  []( StatusCode sc, const StatusCode& i ) {
793  i.ignore(); // make sure there are no unchecked StatusCodes...
794  return sc.isFailure() ? sc : i; // latch to the first non-success case
795  } );
796  }
797  // ========================================================================
798  public:
799  // ========================================================================
823  StatusCode fill( const char* format... );
824  // =======================================================================
825  public:
826  // =======================================================================
875  template <typename ITERATOR1, typename ITERATOR2>
876  StatusCode farray( const std::string& name, ITERATOR1&& first, ITERATOR2&& last, const std::string& length,
877  size_t maxv ) {
878  return farray( name, detail::to_float, std::forward<ITERATOR1>( first ), std::forward<ITERATOR2>( last ), length,
879  maxv );
880  }
881  // =======================================================================
924  template <class DATA>
925  StatusCode farray( const std::string& name, const DATA& data, const std::string& length, const size_t maxv ) {
926  return farray( name, std::begin( data ), std::end( data ), length, maxv );
927  }
928  // =======================================================================
991  template <class FUNCTION, class ITERATOR>
992  StatusCode farray( const std::string& name, const FUNCTION& function, ITERATOR first, ITERATOR last,
993  const std::string& length, size_t maxv ) {
994  if ( invalid() ) return ErrorCodes::InvalidTuple;
995  if ( rowWise() ) return ErrorCodes::InvalidOperation;
996 
997  // adjust the length
998  if ( std::distance( first, last ) > static_cast<std::ptrdiff_t>( maxv ) ) {
999  Warning( "farray('" + name + "'): array is overflow, skip extra entries" );
1000  last = std::next( first, maxv );
1001  }
1002 
1003  // get the length item
1004  Int* len = ints( length, 0, maxv );
1005  if ( !len ) return ErrorCodes::InvalidColumn;
1006 
1007  // adjust the length
1008  *len = std::distance( first, last );
1009 
1010  // get the array itself
1011  FArray* var = fArray( name, len );
1012  if ( !var ) return ErrorCodes::InvalidColumn;
1013 
1014  // fill the array
1015  std::transform( first, last, std::begin( *var ),
1016  [&]( auto&& i ) { return std::invoke( function, std::forward<decltype( i )>( i ) ); } );
1017 
1018  return StatusCode::SUCCESS;
1019  }
1020  // =======================================================================
1048  template <typename FunIterator, typename DataIterator>
1049  StatusCode farray_impl( FunIterator first_item, FunIterator last_item, DataIterator first, DataIterator last,
1050  const std::string& length, size_t maxv ) {
1051  if ( invalid() ) return ErrorCodes::InvalidTuple;
1052  if ( rowWise() ) return ErrorCodes::InvalidOperation;
1053 
1054  // adjust the length
1055  if ( std::distance( first, last ) > static_cast<std::ptrdiff_t>( maxv ) ) {
1057  std::ostringstream os;
1058  ostream_joiner( os, first_item, last_item, ",",
1059  []( std::ostream& os, const auto& i ) -> decltype( auto ) { return os << i.first; } );
1060  Warning( "farray('" + os.str() + "'): array overflow, skipping extra entries" ).ignore();
1061  last = std::next( first, maxv );
1062  }
1063 
1064  // get the length item
1065  Int* len = ints( length, 0, maxv );
1066  if ( !len ) return ErrorCodes::InvalidColumn;
1067 
1068  // adjust the length
1069  *len = std::distance( first, last );
1070 
1071  // get the arrays themselves
1072  std::vector<FArray*> vars;
1073  vars.reserve( std::distance( first_item, last_item ) );
1074  std::transform( first_item, last_item, std::back_inserter( vars ),
1075  [&]( const auto& item ) { return this->fArray( item.first, len ); } );
1076  if ( std::any_of( vars.begin(), vars.end(), []( const FArray* f ) { return !f; } ) ) {
1078  }
1079 
1080  // fill the array
1081  for ( size_t index = 0; first != last; ++first, ++index ) {
1082  auto item = first_item;
1083  for ( auto& var : vars ) { ( *var )[index] = std::invoke( ( item++ )->second, *first ); }
1084  }
1085 
1086  return StatusCode::SUCCESS;
1087  }
1088 
1089  template <
1090  typename DataIterator, template <typename, typename...> class Container = std::initializer_list,
1091  typename NamedFunction = std::pair<std::string, std::function<float( detail::const_ref_t<DataIterator> )>>,
1092  typename = std::enable_if_t<!std::is_convertible_v<Container<NamedFunction>, std::string>>>
1093  StatusCode farray( const Container<NamedFunction>& funs, DataIterator first, DataIterator last,
1094  const std::string& length, size_t maxv ) {
1095  return farray_impl( funs.begin(), funs.end(), std::forward<DataIterator>( first ),
1096  std::forward<DataIterator>( last ), length, maxv );
1097  }
1098 
1099  template <typename NamedFunctions, typename DataIterator,
1100  typename = std::enable_if_t<!std::is_convertible_v<NamedFunctions, std::string>>>
1101  StatusCode farray( const NamedFunctions& funs, DataIterator first, DataIterator last, const std::string& length,
1102  size_t maxv ) {
1103  return farray_impl( funs.begin(), funs.end(), std::forward<DataIterator>( first ),
1104  std::forward<DataIterator>( last ), length, maxv );
1105  }
1106  // =======================================================================
1138  template <class FUNC1, class FUNC2, class Iterator>
1139  StatusCode farray( const std::string& name1, const FUNC1& func1, const std::string& name2, const FUNC2& func2,
1140  Iterator&& first, Iterator&& last, const std::string& length, size_t maxv ) {
1141  return farray( {{name1, std::cref( func1 )}, {name2, std::cref( func2 )}}, std::forward<Iterator>( first ),
1142  std::forward<Iterator>( last ), length, maxv );
1143  }
1144  // =======================================================================
1181  template <class FUNC1, class FUNC2, class FUNC3, class Iterator>
1182  StatusCode farray( const std::string& name1, const FUNC1& func1, const std::string& name2, const FUNC2& func2,
1183  const std::string& name3, const FUNC3& func3, Iterator&& first, Iterator&& last,
1184  const std::string& length, size_t maxv ) {
1185  return farray( {{name1, std::cref( func1 )}, {name2, std::cref( func2 )}, {name3, std::cref( func3 )}},
1186  std::forward<Iterator>( first ), std::forward<Iterator>( last ), length, maxv );
1187  }
1188  // =======================================================================
1228  template <class FUNC1, class FUNC2, class FUNC3, class FUNC4, class Iterator>
1229  StatusCode farray( const std::string& name1, const FUNC1& func1, const std::string& name2, const FUNC2& func2,
1230  const std::string& name3, const FUNC3& func3, const std::string& name4, const FUNC4& func4,
1231  Iterator&& first, Iterator&& last, const std::string& length, size_t maxv ) {
1232  return farray( {{name1, std::cref( func1 )},
1233  {name2, std::cref( func2 )},
1234  {name3, std::cref( func3 )},
1235  {name4, std::cref( func4 )}},
1236  std::forward<Iterator>( first ), std::forward<Iterator>( last ), length, maxv );
1237  }
1238  // =======================================================================
1239  public:
1240  // =======================================================================
1291  template <class MATRIX>
1292  StatusCode fmatrix( const std::string& name, const MATRIX& data, size_t rows, const MIndex& cols,
1293  const std::string& length, size_t maxv ) {
1294  if ( invalid() ) return ErrorCodes::InvalidTuple;
1295  if ( rowWise() ) return ErrorCodes::InvalidOperation;
1296 
1297  // adjust the length
1298  if ( rows >= maxv ) {
1299  Warning( "fmatrix('" + name + "'): matrix is overflow, skip extra items" ).ignore();
1300  rows = ( 0 < maxv ) ? ( maxv - 1 ) : 0;
1301  }
1302 
1303  // get the length item
1304  Int* len = ints( length, 0, maxv );
1305  if ( !len ) return ErrorCodes::InvalidColumn;
1306 
1307  // adjust the length item
1308  *len = rows;
1309 
1310  // get the array itself
1311  FMatrix* var = fMatrix( name, len, cols );
1312  if ( !var ) return ErrorCodes::InvalidColumn;
1313 
1315  for ( size_t iCol = 0; iCol < cols; ++iCol ) {
1316  for ( MIndex iRow = 0; iRow < rows; ++iRow ) { ( *var )[iRow][iCol] = data[iRow][iCol]; }
1317  }
1318 
1319  return StatusCode::SUCCESS;
1320  }
1321  // =======================================================================
1358  template <class DATA>
1359  StatusCode fmatrix( const std::string& name, DATA first, DATA last, const MIndex& cols, const std::string& length,
1360  size_t maxv ) {
1361  if ( invalid() ) return ErrorCodes::InvalidTuple;
1362  if ( rowWise() ) return ErrorCodes::InvalidOperation;
1363 
1364  // adjust the length
1365  if ( first + maxv < last ) {
1366  Warning( "fmatrix('" + name + "'): matrix is overflow, skip extra items" ).ignore();
1367  last = first + maxv;
1368  }
1369 
1370  // get the length item
1371  Int* len = ints( length, 0, maxv );
1372  if ( !len ) return ErrorCodes::InvalidColumn;
1373 
1374  // adjust the length item
1375  *len = last - first;
1376 
1377  // get the array itself
1378  FMatrix* var = fMatrix( name, len, cols );
1379  if ( !var ) return ErrorCodes::InvalidColumn;
1380 
1382  size_t iRow = 0;
1383  for ( ; first != last; ++first ) {
1384  //
1385  for ( MIndex iCol = 0; iCol < cols; ++iCol ) { ( *var )[iRow][iCol] = ( *first )[iCol]; }
1386  //
1387  ++iRow;
1388  }
1389 
1390  return StatusCode::SUCCESS;
1391  }
1392  // =======================================================================
1471  template <class FUN, class DATA>
1472  StatusCode fmatrix( const std::string& name, FUN funF, FUN funL, DATA first, DATA last, const std::string& length,
1473  size_t maxv ) {
1474  if ( invalid() ) return ErrorCodes::InvalidTuple;
1475  if ( rowWise() ) return ErrorCodes::InvalidOperation;
1476 
1477  // adjust the length
1478  if ( std::distance( first, last ) > static_cast<std::ptrdiff_t>( maxv ) ) {
1479  Warning( "fmatrix('" + name + "'): matrix is overflow, skip extra items" ).ignore();
1480  last = std::next( first, maxv );
1481  }
1482 
1483  // get the length item
1484  Int* len = ints( length, 0, maxv );
1485 
1486  if ( !len ) return ErrorCodes::InvalidColumn;
1487 
1488  // adjust the length item
1489  *len = std::distance( first, last );
1490 
1491  // get the array itself
1492  auto cols = std::distance( funF, funL );
1493  FMatrix* var = fMatrix( name, len, cols );
1494  if ( !var ) return ErrorCodes::InvalidColumn;
1495 
1497  size_t iRow = 0;
1498  for ( ; first != last; ++first ) {
1499  //
1500  for ( FUN fun = funF; fun < funL; ++fun ) { ( *var )[iRow][fun - funF] = std::invoke( *fun, *first ); }
1501  //
1502  ++iRow;
1503  }
1504 
1505  return StatusCode::SUCCESS;
1506  }
1507  // =======================================================================
1508  public:
1509  // =======================================================================
1532  template <class DATA>
1533  StatusCode array( const std::string& name, DATA first, DATA last )
1534 
1535  {
1536  if ( invalid() ) return ErrorCodes::InvalidTuple;
1537  if ( rowWise() ) return ErrorCodes::InvalidOperation;
1538 
1539  // get the length (fixed!)
1540  auto length = std::distance( first, last );
1541 
1542  // get the array itself
1543  FArray* var = fArray( name, length );
1544  if ( !var ) return ErrorCodes::InvalidColumn;
1545 
1547  std::copy( first, last, std::begin( *var ) );
1548 
1549  return StatusCode::SUCCESS;
1550  }
1551  // =======================================================================
1590  template <class ARRAY>
1591  StatusCode array( const std::string& name, const ARRAY& data, const MIndex& length ) {
1592  using std::begin; // allow data to be eg. CLHEP::HepVector (which does not define HepVector::begin()!,
1593  // in which case ADL prefers CLHEP::begin (yah! at least they (now) use a namespace)
1594  // so one just to insure double* CLHEP::begin(CLHEP::HepVector& v) { return &v[0]; }
1595  // is visible when this function gets instantiated for CLHEP::HepVector...
1596  auto first = begin( data );
1597  return array( name, first, std::next( first, length ) );
1598  }
1599  // =======================================================================
1630  template <class ARRAY>
1631  StatusCode array( const std::string& name, const ARRAY& data ) {
1632  using std::begin;
1633  using std::end;
1634  return array( name, begin( data ), end( data ) );
1635  }
1636  // =======================================================================
1637  public:
1638  // =======================================================================
1687  template <class MATRIX>
1688  StatusCode matrix( const std::string& name, const MATRIX& data, const MIndex& rows, const MIndex& cols ) {
1689  if ( invalid() ) return ErrorCodes::InvalidTuple;
1690  if ( rowWise() ) return ErrorCodes::InvalidOperation;
1691 
1692  // get the matrix itself
1693  FMatrix* var = fMatrix( name, rows, cols );
1694  if ( !var ) return ErrorCodes::InvalidColumn;
1695 
1697  for ( size_t iCol = 0; iCol < cols; ++iCol ) {
1698  for ( size_t iRow = 0; iRow < rows; ++iRow ) { ( *var )[iRow][iCol] = data[iRow][iCol]; }
1699  };
1700  return StatusCode::SUCCESS;
1701  }
1702  // =======================================================================
1703  public:
1704  // =======================================================================
1721  template <class TYPE>
1722  StatusCode column( const std::string& name, const ROOT::Math::LorentzVector<TYPE>& v ) {
1723  return columns( v, std::make_pair( name + "E", &ROOT::Math::LorentzVector<TYPE>::E ),
1724  std::make_pair( name + "X", &ROOT::Math::LorentzVector<TYPE>::Px ),
1725  std::make_pair( name + "Y", &ROOT::Math::LorentzVector<TYPE>::Py ),
1726  std::make_pair( name + "Z", &ROOT::Math::LorentzVector<TYPE>::Pz ) );
1727  }
1728  // =======================================================================
1745  template <class TYPE, class TAG>
1747  return this->columns( v, std::make_pair( name + "X", &ROOT::Math::DisplacementVector3D<TYPE, TAG>::X ),
1750  }
1751  // =======================================================================
1768  template <class TYPE, class TAG>
1770  return this->columns( v, std::make_pair( name + "X", &ROOT::Math::PositionVector3D<TYPE, TAG>::X ),
1773  }
1774  // =======================================================================
1783  template <class TYPE, unsigned int D1, unsigned int D2, class REP>
1784  StatusCode matrix( const std::string& name, const ROOT::Math::SMatrix<TYPE, D1, D2, REP>& mtrx ) {
1785  if ( invalid() ) return ErrorCodes::InvalidTuple;
1786  if ( rowWise() ) return ErrorCodes::InvalidOperation;
1787 
1788  // get the matrix itself
1789  FMatrix* var = fMatrix( name, (MIndex)D1, (MIndex)D2 );
1790  if ( !var ) return ErrorCodes::InvalidColumn;
1791 
1793  for ( size_t iCol = 0; iCol < D2; ++iCol ) {
1794  for ( size_t iRow = 0; iRow < D1; ++iRow ) { ( *var )[iRow][iCol] = mtrx( iRow, iCol ); }
1795  };
1796 
1797  return StatusCode::SUCCESS;
1798  }
1799  // =======================================================================
1817  template <class KEY, class VALUE>
1819  const std::string& length, const size_t maxv = 100 ) {
1820  using Info = std::pair<KEY, VALUE>;
1821  static const std::array<float ( * )( const Info& ), 2> fns = {
1822  {[]( const Info& i ) -> float { return i.first; }, []( const Info& i ) -> float { return i.second; }}};
1823  return fmatrix( name, begin( fns ), end( fns ), begin( info ), end( info ), length, maxv );
1824  }
1825  // =======================================================================
1826  public:
1827  // =======================================================================
1835  template <class TYPE>
1836  StatusCode put( const std::string& name, const TYPE* obj );
1837  // =======================================================================
1838  public:
1839  // =======================================================================
1843  StatusCode write();
1844  // =======================================================================
1846  const std::string& name() const { return m_name; }
1847  // =======================================================================
1851  const NTuple::Tuple* tuple() const { return m_tuple; }
1852  // =======================================================================
1856  NTuple::Tuple* tuple() { return m_tuple; }
1857  // =======================================================================
1859  const CLID& clid() const { return m_clid; }
1860  // =======================================================================
1862  Tuples::Type type() const { return m_type; }
1863  // =======================================================================
1865  bool columnWise() const { return CLID_ColumnWiseTuple == clid(); }
1866  // =======================================================================
1868  bool rowWise() const { return CLID_RowWiseTuple == clid(); }
1869  // =======================================================================
1871  bool evtColType() const { return Tuples::EVTCOL == type(); }
1872  // =======================================================================
1874  bool valid() const { return 0 != tuple(); }
1875  // =======================================================================
1877  bool invalid() const { return !valid(); }
1878  // =======================================================================
1879  public:
1880  // =======================================================================
1887  return m_items.emplace( std::move( name ), std::move( type ) ).second;
1888  }
1889  // =======================================================================
1894  bool goodItem( const std::string& name ) const { return m_items.end() == m_items.find( name ); }
1895  // =======================================================================
1897  const ItemMap& items() const { return m_items; }
1898  // =======================================================================
1899  public:
1900  // =======================================================================
1901  virtual StatusCode Error( const std::string& msg, const StatusCode sc = StatusCode::FAILURE ) const = 0;
1902  // =======================================================================
1903  virtual StatusCode Warning( const std::string& msg, const StatusCode sc = StatusCode::FAILURE ) const = 0;
1904  // =======================================================================
1905  private:
1906  // =======================================================================
1908  Int* ints( const std::string& name, int minv, int maxv );
1909  // =======================================================================
1911  FArray* fArray( const std::string& name, Int* item );
1912  // =======================================================================
1914  FArray* fArray( const std::string& name, const MIndex& rows );
1915  // =======================================================================
1917  Address* addresses( const std::string& name );
1918  // =======================================================================
1920  FMatrix* fMatrix( const std::string& name, Int* item, const MIndex& cols );
1921  // =======================================================================
1923  FMatrix* fMatrix( const std::string& name, const MIndex& rows, const MIndex& cols );
1924  // =======================================================================
1926  TupleObj( const TupleObj& ) = delete;
1927  TupleObj& operator=( const TupleObj& ) = delete;
1928  // =======================================================================
1929  private:
1930  // =======================================================================
1933  // =======================================================================
1936  // =======================================================================
1939  // =======================================================================
1942  // =======================================================================
1944  size_t m_refCount = 0;
1945  // =======================================================================
1946  // helper type to define the actual storage types
1947  template <typename T>
1949  // =======================================================================
1952  // =======================================================================
1955  // =======================================================================
1958  // =======================================================================
1961  // =======================================================================
1964  // =======================================================================
1967  // =======================================================================
1970  // =======================================================================
1973  // =======================================================================
1976  // =======================================================================
1979  // =======================================================================
1982  // =======================================================================
1985  // =======================================================================
1988  // =======================================================================
1991  // =======================================================================
1994  // =======================================================================
1997  // =======================================================================
2000  // =======================================================================
2001  };
2002  // ==========================================================================
2003 } // end of namespace Tuples
2004 
2005 // ============================================================================
2006 // GaudiAlg
2007 // ============================================================================
2008 #include "GaudiAlg/TuplePut.h"
2009 // ============================================================================
2010 // The END
2011 // ============================================================================
2012 #endif // GAUDIALG_TUPLEOBJ_H
StatusCode column(const std::string &name, const ROOT::Math::DisplacementVector3D< TYPE, TAG > &v)
Useful shortcut to put 3D-Vector directly into N-Tuple:
Definition: TupleObj.h:1746
ColumnStorage< FArray > m_arraysf
the actual storage of all 'FArray' columns (fixed)
Definition: TupleObj.h:1990
Out1 * put(const DataObjectHandle< Out1 > &out_handle, Out2 &&out)
A bit modified version of 'Loki::AssocVector' associative vector from Loki library by Andrei Alexandr...
Definition: VectorMap.h:102
CLID m_clid
tuple CLID
Definition: TupleObj.h:1938
ColumnStorage< Float > m_floats
the actual storage of all 'Float' columns
Definition: TupleObj.h:1978
ColumnStorage< Address > m_addresses
the actual storage of all 'Address' columns
Definition: TupleObj.h:1984
std::map< std::string, std::string > ItemMap
Definition: TupleObj.h:248
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:1688
T distance(T... args)
GAUDI_API std::string format(const char *,...)
MsgStream format utility "a la sprintf(...)".
Definition: MsgStream.cpp:109
NTuple::Item< float > Float
basic type for float items
Definition: TupleObj.h:230
ColumnStorage< Bool > m_bools
the actual storage of all 'bool' columns
Definition: TupleObj.h:1951
Tuples::Type m_type
tuple 'type'
Definition: TupleObj.h:1941
Class acting as a smart pointer holding a N tuple _Item.
Definition: NTuple.h:52
NTuple::Item< IOpaqueAddress * > Address
basic type for address items
Definition: TupleObj.h:236
ErrorCodes
Tuple error codes.
Definition: TupleObj.h:91
constexpr static const auto SUCCESS
Definition: StatusCode.h:85
const CLID & clid() const
accessor to the N-Tuple CLID
Definition: TupleObj.h:1859
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:227
NTuple::Item< unsigned short > UShort
basic type for unsigned int items
Definition: TupleObj.h:215
bool invalid() const
invalid pointer to tuple ?
Definition: TupleObj.h:1877
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:1292
unsigned short MIndex
Definition: TupleObj.h:245
ColumnStorage< LongLong > m_longlongs
the actual storage of all 'long long' columns
Definition: TupleObj.h:1972
ColumnStorage< UShort > m_ushorts
the actual storage of all 'unsigned int' columns
Definition: TupleObj.h:1963
Tuples::Type type() const
accessor to the N-Tuple type
Definition: TupleObj.h:1862
std::string m_name
name
Definition: TupleObj.h:1932
bool evtColType() const
Event collection ?
Definition: TupleObj.h:1871
NTuple::Tuple * tuple()
provide the access to underlying Gaudi N-tuple
Definition: TupleObj.h:1856
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:876
NTuple::Item< unsigned char > UChar
basic type for unsigned int items
Definition: TupleObj.h:209
Provide serialization function (output only) for some common STL classes (vectors,...
ColumnStorage< UInt > m_uints
the actual storage of all 'unsigned int' columns
Definition: TupleObj.h:1969
constexpr double second
STL class.
NTuple::Item< short > Short
basic type for int items
Definition: TupleObj.h:212
bool addItem(std::string name, std::string type)
add the item name into the list of known items
Definition: TupleObj.h:1886
ColumnStorage< Double > m_doubles
the actual storage of all 'Double' columns
Definition: TupleObj.h:1981
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:1472
ColumnStorage< FMatrix > m_fmatrices
the actual storage of all 'FArray' columns
Definition: TupleObj.h:1993
constexpr to_< float > to_float
Definition: TupleObj.h:68
ColumnStorage< ULongLong > m_ulonglongs
the actual storage of all 'unsigned long long' columns
Definition: TupleObj.h:1975
#define STATUSCODE_ENUM_DECL(ENUM)
Declare an enum to be used as StatusCode value.
Definition: StatusCode.h:239
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:1631
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:50
ColumnStorage< Char > m_chars
the actual storage of all 'Int' columns
Definition: TupleObj.h:1954
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:1182
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:925
NTuple::Matrix< float > FMatrix
basic type for matrix of floats
Definition: TupleObj.h:242
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:1784
ColumnStorage< Short > m_shorts
the actual storage of all 'Int' columns
Definition: TupleObj.h:1960
T make_pair(T... args)
ItemMap m_items
all booked types:
Definition: TupleObj.h:1999
NTuple::Item< bool > Bool
basic type for int items
Definition: TupleObj.h:203
NTuple::Item< double > Double
basic type for double items
Definition: TupleObj.h:233
ColumnStorage< Int > m_ints
the actual storage of all 'Int' columns
Definition: TupleObj.h:1966
const NTuple::Tuple * tuple() const
provide the access to underlying Gaudi N-tuple
Definition: TupleObj.h:1851
def end
Definition: IOTest.py:113
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:1139
Specialization acting as a smart pointer holding a N tuple _Item.
Definition: NTuple.h:295
unsigned int CLID
Class ID definition.
Definition: ClassID.h:8
bool columnWise() const
column wise NTuple ?
Definition: TupleObj.h:1865
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:1049
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:1359
Stream & ostream_joiner(Stream &os, Iterator first, Iterator last, Separator sep, OutputElement output=OutputElement{})
Definition: SerializeSTL.h:37
Abstract base class which allows the user to interact with the actual N tuple implementation.
Definition: NTuple.h:375
StatusCode column(const std::string &name, signed char value)
Set the value for the selected tuple column.
Definition: TupleObj.h:703
NTuple::Item< long long > LongLong
basic type for unsigned long long items
Definition: TupleObj.h:224
const std::string & name() const
get the name
Definition: TupleObj.h:1846
StatusCode farray(const NamedFunctions &funs, DataIterator first, DataIterator last, const std::string &length, size_t maxv)
Definition: TupleObj.h:1101
const StatusCode & ignore() const
Ignore/check StatusCode.
Definition: StatusCode.h:153
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:1229
StatusCode array(const std::string &name, DATA first, DATA last)
fill N-Tuple with fixed-size array
Definition: TupleObj.h:1533
struct GAUDI_API array
Parametrisation class for redirection array - like implementation.
STL class.
NTuple::Tuple * m_tuple
tuple itself
Definition: TupleObj.h:1935
const ItemMap & items() const
get the full list of booked items
Definition: TupleObj.h:1897
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:1818
T cref(T... args)
boost::spirit::classic::position_iterator2< ForwardIterator > Iterator
Definition: Iterator.h:18
bool rowWise() const
row wise NTuple ?
Definition: TupleObj.h:1868
T begin(T... args)
ColumnStorage< FMatrix > m_matricesf
the actual storage of all 'FMatrix' columns (fixed)
Definition: TupleObj.h:1996
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:992
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:1093
NTuple::Item< char > Char
basic type for int items
Definition: TupleObj.h:206
std::add_const_t< typename std::iterator_traits< Iterator >::reference > const_ref_t
Definition: TupleObj.h:71
Common class providing an architecture-independent hash map.
Definition: HashMap.h:73
STL class.
NTuple::Item< int > Int
basic type for int items
Definition: TupleObj.h:218
constexpr static const auto FAILURE
Definition: StatusCode.h:86
StatusCode column(const std::string &name, const ROOT::Math::LorentzVector< TYPE > &v)
Useful shortcut to put LorentzVector directly into N-Tuple:
Definition: TupleObj.h:1722
StatusCode columns(Value &&value, Args &&... args)
Set the values for several columns simultaneously, for the same object Non-existing columns will be a...
Definition: TupleObj.h:787
bool valid() const
valid pointer to tuple ?
Definition: TupleObj.h:1874
T transform(T... args)
NTuple::Array< float > FArray
basic type for array of floats
Definition: TupleObj.h:239
bool isFailure() const
Definition: StatusCode.h:130
AttribStringParser::Iterator begin(const AttribStringParser &parser)
T accumulate(T... args)
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:48
StatusCode array(const std::string &name, const ARRAY &data, const MIndex &length)
fill N-Tuple with fixed-size array
Definition: TupleObj.h:1591
Class acting as a smart pointer holding a N tuple _Item.
Definition: NTuple.h:50
#define GAUDI_API
Definition: Kernel.h:71
Type
the list of available types for ntuples
Definition: TupleObj.h:79
STL class.
bool goodItem(const std::string &name) const
check the uniqueness of the name
Definition: TupleObj.h:1894
NTuple::Item< unsigned int > UInt
basic type for unsigned int items
Definition: TupleObj.h:221
T forward(T... args)
ColumnStorage< UChar > m_uchars
the actual storage of all 'unsigned int' columns
Definition: TupleObj.h:1957
T operator()(Arg &&i) const
Definition: TupleObj.h:64
T reserve(T... args)
unsigned long code_t
type of StatusCode value
Definition: StatusCode.h:52
ColumnStorage< FArray > m_farrays
the actual storage of all 'FArray' columns
Definition: TupleObj.h:1987
General namespace for Tuple properties.
Definition: Maps.h:33
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:1769