The Gaudi Framework  v30r3 (a5ef0a68)
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 to_<float> to_float{};
73 
74  template <typename Iterator>
75  using const_ref_t = std::add_const_t<typename std::iterator_traits<Iterator>::reference>;
76  }
77  // ==========================================================================
83  enum Type {
84  NTUPLE, // Analysis nTuple
85  EVTCOL // Event Collection
86  };
87  // ==========================================================================
96  InvalidTuple = 100,
100  InvalidItem,
101  TruncateValue = 200
102  };
103 }
104 
106 
107 namespace Tuples
108 {
109  // ==========================================================================
205  {
206  public:
207  // ========================================================================
210  // ========================================================================
213  // ========================================================================
216  // ========================================================================
219  // ========================================================================
222  // ========================================================================
225  // ========================================================================
228  // ========================================================================
231  // ========================================================================
234  // ========================================================================
237  // ========================================================================
240  // ========================================================================
243  // ========================================================================
246  // ========================================================================
249  // ========================================================================
250  // the actual type for variable size matrix indices
251  typedef unsigned short MIndex;
252  // ========================================================================
253  // the map of all items
255  // ========================================================================
256  protected:
257  // ========================================================================
265  TupleObj( std::string name, NTuple::Tuple* tuple, const CLID& clid = CLID_ColumnWiseTuple,
266  const Tuples::Type type = Tuples::NTUPLE );
267  // ========================================================================
268  public:
269  // ========================================================================
270  virtual ~TupleObj();
271  // ========================================================================
287  StatusCode column( const std::string& name, float value );
288  // ========================================================================
289  public:
290  // ========================================================================
307  StatusCode column( const std::string& name, double value );
308  // ========================================================================
309  public:
310  // ========================================================================
326  StatusCode column( const std::string& name, short value );
327  // ========================================================================
345  StatusCode column( const std::string& name, short value, short minv, short maxv );
346  // ========================================================================
347  public:
348  // ========================================================================
364  StatusCode column( const std::string& name, unsigned short value );
365  // ========================================================================
383  StatusCode column( const std::string& name, unsigned short value, unsigned short minv, unsigned short maxv );
384  // ========================================================================
385  public:
386  // ========================================================================
402  StatusCode column( const std::string& name, char value );
403  // ========================================================================
421  StatusCode column( const std::string& name, char value, char minv, char maxv );
422  // ========================================================================
423  public:
424  // ========================================================================
440  StatusCode column( const std::string& name, unsigned char value );
441  // ========================================================================
459  StatusCode column( const std::string& name, unsigned char value, unsigned char minv, unsigned char maxv );
460  // ========================================================================
461  public:
462  // ========================================================================
478  StatusCode column( const std::string& name, int value );
479  // ========================================================================
497  StatusCode column( const std::string& name, int value, int minv, int maxv );
498  // ========================================================================
499  public:
500  // ========================================================================
516  StatusCode column( const std::string& name, unsigned int value );
517  // ========================================================================
535  StatusCode column( const std::string& name, unsigned int value, unsigned int minv, unsigned int maxv );
536  // ========================================================================
537  public:
538  // ========================================================================
555  StatusCode column( const std::string& name, long value );
556  // ========================================================================
574  StatusCode column( const std::string& name, long value, long minv, long maxv );
575  // ========================================================================
576  public:
577  // ========================================================================
594  StatusCode column( const std::string& name, unsigned long value );
595  // ========================================================================
613  StatusCode column( const std::string& name, unsigned long value, unsigned long minv, unsigned long maxv );
614  // ========================================================================
615  public:
616  // ========================================================================
632  StatusCode column( const std::string& name, long long value );
633  // ========================================================================
651  StatusCode column( const std::string& name, long long value, long long minv, long long maxv );
652  // ========================================================================
653  public:
654  // ========================================================================
670  StatusCode column( const std::string& name, unsigned long long value );
671  // ========================================================================
689  StatusCode column( const std::string& name, unsigned long long value, unsigned long long minv,
690  unsigned long long maxv );
691  // ========================================================================
692  public:
693  // ========================================================================
709  StatusCode column( const std::string& name, signed char value )
710  {
712  }
713  // ========================================================================
714  public:
715  // ========================================================================
730  StatusCode column( const std::string& name, bool value );
731  // ========================================================================
732  public:
733  // ========================================================================
752  StatusCode column( const std::string& name, IOpaqueAddress* address );
753  // ========================================================================
770  StatusCode column( IOpaqueAddress* address );
771  // ========================================================================
772  public:
773  // ========================================================================
793  template <typename Value, typename... Args>
794  StatusCode columns( Value&& value, Args&&... args )
795  {
796  if ( sizeof...( Args ) == 0 ) return StatusCode::SUCCESS;
798  this->column( std::get<0>( args ), Gaudi::invoke( std::get<1>( args ), value ) )...};
799  return std::accumulate( std::next( begin( scs ) ), end( scs ), *begin( scs ),
800  []( StatusCode sc, const StatusCode& i ) {
801  i.ignore(); // make sure there are no unchecked StatusCodes...
802  return sc.isFailure() ? sc : i; // latch to the first non-success case
803  } );
804  }
805  // ========================================================================
806  public:
807  // ========================================================================
831  StatusCode fill( const char* format... );
832  // =======================================================================
833  public:
834  // =======================================================================
883  template <typename ITERATOR1, typename ITERATOR2>
884  StatusCode farray( const std::string& name, ITERATOR1&& first, ITERATOR2&& last, const std::string& length,
885  size_t maxv )
886  {
887  return farray( name, detail::to_float, std::forward<ITERATOR1>( first ), std::forward<ITERATOR2>( last ), length,
888  maxv );
889  }
890  // =======================================================================
933  template <class DATA>
934  StatusCode farray( const std::string& name, const DATA& data, const std::string& length, const size_t maxv )
935  {
936  return farray( name, std::begin( data ), std::end( data ), length, maxv );
937  }
938  // =======================================================================
1001  template <class FUNCTION, class ITERATOR>
1002  StatusCode farray( const std::string& name, const FUNCTION& function, ITERATOR first, ITERATOR last,
1003  const std::string& length, size_t maxv )
1004  {
1005  if ( invalid() ) return ErrorCodes::InvalidTuple;
1006  if ( rowWise() ) return ErrorCodes::InvalidOperation;
1007 
1008  // adjust the length
1009  if ( std::distance( first, last ) > static_cast<std::ptrdiff_t>( maxv ) ) {
1010  Warning( "farray('" + name + "'): array is overflow, skip extra entries" );
1011  last = std::next( first, maxv );
1012  }
1013 
1014  // get the length item
1015  Int* len = ints( length, 0, maxv );
1016  if ( !len ) return ErrorCodes::InvalidColumn;
1017 
1018  // adjust the length
1019  *len = std::distance( first, last );
1020 
1021  // get the array itself
1022  FArray* var = fArray( name, len );
1023  if ( !var ) return ErrorCodes::InvalidColumn;
1024 
1025  // fill the array
1026  std::transform( first, last, std::begin( *var ),
1027  [&]( auto&& i ) { return Gaudi::invoke( function, std::forward<decltype( i )>( i ) ); } );
1028 
1029  return StatusCode::SUCCESS;
1030  }
1031  // =======================================================================
1059  template <typename FunIterator, typename DataIterator>
1060  StatusCode farray_impl( FunIterator first_item, FunIterator last_item, DataIterator first, DataIterator last,
1061  const std::string& length, size_t maxv )
1062  {
1063  if ( invalid() ) return ErrorCodes::InvalidTuple;
1064  if ( rowWise() ) return ErrorCodes::InvalidOperation;
1065 
1066  // adjust the length
1067  if ( std::distance( first, last ) > static_cast<std::ptrdiff_t>( maxv ) ) {
1069  std::ostringstream os;
1070  ostream_joiner( os, first_item, last_item, ",",
1071  []( std::ostream& os, const auto& i ) -> decltype( auto ) { return os << i.first; } );
1072  Warning( "farray('" + os.str() + "'): array overflow, skipping extra entries" ).ignore();
1073  last = std::next( first, maxv );
1074  }
1075 
1076  // get the length item
1077  Int* len = ints( length, 0, maxv );
1078  if ( !len ) return ErrorCodes::InvalidColumn;
1079 
1080  // adjust the length
1081  *len = std::distance( first, last );
1082 
1083  // get the arrays themselves
1084  std::vector<FArray*> vars;
1085  vars.reserve( std::distance( first_item, last_item ) );
1086  std::transform( first_item, last_item, std::back_inserter( vars ),
1087  [&]( const auto& item ) { return this->fArray( item.first, len ); } );
1088  if ( std::any_of( vars.begin(), vars.end(), []( const FArray* f ) { return !f; } ) ) {
1090  }
1091 
1092  // fill the array
1093  for ( size_t index = 0; first != last; ++first, ++index ) {
1094  auto item = first_item;
1095  for ( auto& var : vars ) {
1096  ( *var )[index] = Gaudi::invoke( ( item++ )->second, *first );
1097  }
1098  }
1099 
1100  return StatusCode::SUCCESS;
1101  }
1102 
1103  template <
1104  typename DataIterator, template <typename, typename...> class Container = std::initializer_list,
1106  typename = std::enable_if_t<!std::is_convertible<Container<NamedFunction>, std::string>::value>>
1107  StatusCode farray( const Container<NamedFunction>& funs, DataIterator first, DataIterator last,
1108  const std::string& length, size_t maxv )
1109  {
1110  return farray_impl( funs.begin(), funs.end(), std::forward<DataIterator>( first ),
1111  std::forward<DataIterator>( last ), length, maxv );
1112  }
1113 
1114  template <typename NamedFunctions, typename DataIterator,
1115  typename = std::enable_if_t<!std::is_convertible<NamedFunctions, std::string>::value>>
1116  StatusCode farray( const NamedFunctions& funs, DataIterator first, DataIterator last, const std::string& length,
1117  size_t maxv )
1118  {
1119  return farray_impl( funs.begin(), funs.end(), std::forward<DataIterator>( first ),
1120  std::forward<DataIterator>( last ), length, maxv );
1121  }
1122  // =======================================================================
1154  template <class FUNC1, class FUNC2, class Iterator>
1155  StatusCode farray( const std::string& name1, const FUNC1& func1, const std::string& name2, const FUNC2& func2,
1156  Iterator&& first, Iterator&& last, const std::string& length, size_t maxv )
1157  {
1158  return farray( {{name1, std::cref( func1 )}, {name2, std::cref( func2 )}}, std::forward<Iterator>( first ),
1159  std::forward<Iterator>( last ), length, maxv );
1160  }
1161  // =======================================================================
1198  template <class FUNC1, class FUNC2, class FUNC3, class Iterator>
1199  StatusCode farray( const std::string& name1, const FUNC1& func1, const std::string& name2, const FUNC2& func2,
1200  const std::string& name3, const FUNC3& func3, Iterator&& first, Iterator&& last,
1201  const std::string& length, size_t maxv )
1202  {
1203  return farray( {{name1, std::cref( func1 )}, {name2, std::cref( func2 )}, {name3, std::cref( func3 )}},
1204  std::forward<Iterator>( first ), std::forward<Iterator>( last ), length, maxv );
1205  }
1206  // =======================================================================
1246  template <class FUNC1, class FUNC2, class FUNC3, class FUNC4, class Iterator>
1247  StatusCode farray( const std::string& name1, const FUNC1& func1, const std::string& name2, const FUNC2& func2,
1248  const std::string& name3, const FUNC3& func3, const std::string& name4, const FUNC4& func4,
1249  Iterator&& first, Iterator&& last, const std::string& length, size_t maxv )
1250  {
1251  return farray( {{name1, std::cref( func1 )},
1252  {name2, std::cref( func2 )},
1253  {name3, std::cref( func3 )},
1254  {name4, std::cref( func4 )}},
1255  std::forward<Iterator>( first ), std::forward<Iterator>( last ), length, maxv );
1256  }
1257  // =======================================================================
1258  public:
1259  // =======================================================================
1310  template <class MATRIX>
1311  StatusCode fmatrix( const std::string& name, const MATRIX& data, size_t rows, const MIndex& cols,
1312  const std::string& length, size_t maxv )
1313  {
1314  if ( invalid() ) return ErrorCodes::InvalidTuple;
1315  if ( rowWise() ) return ErrorCodes::InvalidOperation;
1316 
1317  // adjust the length
1318  if ( rows >= maxv ) {
1319  Warning( "fmatrix('" + name + "'): matrix is overflow, skip extra items" ).ignore();
1320  rows = ( 0 < maxv ) ? ( maxv - 1 ) : 0;
1321  }
1322 
1323  // get the length item
1324  Int* len = ints( length, 0, maxv );
1325  if ( !len ) return ErrorCodes::InvalidColumn;
1326 
1327  // adjust the length item
1328  *len = rows;
1329 
1330  // get the array itself
1331  FMatrix* var = fMatrix( name, len, cols );
1332  if ( !var ) return ErrorCodes::InvalidColumn;
1333 
1335  for ( size_t iCol = 0; iCol < cols; ++iCol ) {
1336  for ( MIndex iRow = 0; iRow < rows; ++iRow ) {
1337  ( *var )[iRow][iCol] = data[iRow][iCol];
1338  }
1339  }
1340 
1341  return StatusCode::SUCCESS;
1342  }
1343  // =======================================================================
1380  template <class DATA>
1381  StatusCode fmatrix( const std::string& name, DATA first, DATA last, const MIndex& cols, const std::string& length,
1382  size_t maxv )
1383  {
1384  if ( invalid() ) return ErrorCodes::InvalidTuple;
1385  if ( rowWise() ) return ErrorCodes::InvalidOperation;
1386 
1387  // adjust the length
1388  if ( first + maxv < last ) {
1389  Warning( "fmatrix('" + name + "'): matrix is overflow, skip extra items" ).ignore();
1390  last = first + maxv;
1391  }
1392 
1393  // get the length item
1394  Int* len = ints( length, 0, maxv );
1395  if ( !len ) return ErrorCodes::InvalidColumn;
1396 
1397  // adjust the length item
1398  *len = last - first;
1399 
1400  // get the array itself
1401  FMatrix* var = fMatrix( name, len, cols );
1402  if ( !var ) return ErrorCodes::InvalidColumn;
1403 
1405  size_t iRow = 0;
1406  for ( ; first != last; ++first ) {
1407  //
1408  for ( MIndex iCol = 0; iCol < cols; ++iCol ) {
1409  ( *var )[iRow][iCol] = ( *first )[iCol];
1410  }
1411  //
1412  ++iRow;
1413  }
1414 
1415  return StatusCode::SUCCESS;
1416  }
1417  // =======================================================================
1496  template <class FUN, class DATA>
1497  StatusCode fmatrix( const std::string& name, FUN funF, FUN funL, DATA first, DATA last, const std::string& length,
1498  size_t maxv )
1499  {
1500  if ( invalid() ) return ErrorCodes::InvalidTuple;
1501  if ( rowWise() ) return ErrorCodes::InvalidOperation;
1502 
1503  // adjust the length
1504  if ( std::distance( first, last ) > static_cast<std::ptrdiff_t>( maxv ) ) {
1505  Warning( "fmatrix('" + name + "'): matrix is overflow, skip extra items" ).ignore();
1506  last = std::next( first, maxv );
1507  }
1508 
1509  // get the length item
1510  Int* len = ints( length, 0, maxv );
1511 
1512  if ( !len ) return ErrorCodes::InvalidColumn;
1513 
1514  // adjust the length item
1515  *len = std::distance( first, last );
1516 
1517  // get the array itself
1518  auto cols = std::distance( funF, funL );
1519  FMatrix* var = fMatrix( name, len, cols );
1520  if ( !var ) return ErrorCodes::InvalidColumn;
1521 
1523  size_t iRow = 0;
1524  for ( ; first != last; ++first ) {
1525  //
1526  for ( FUN fun = funF; fun < funL; ++fun ) {
1527  ( *var )[iRow][fun - funF] = Gaudi::invoke( *fun, *first );
1528  }
1529  //
1530  ++iRow;
1531  }
1532 
1533  return StatusCode::SUCCESS;
1534  }
1535  // =======================================================================
1536  public:
1537  // =======================================================================
1560  template <class DATA>
1561  StatusCode array( const std::string& name, DATA first, DATA last )
1562 
1563  {
1564  if ( invalid() ) return ErrorCodes::InvalidTuple;
1565  if ( rowWise() ) return ErrorCodes::InvalidOperation;
1566 
1567  // get the length (fixed!)
1568  auto length = std::distance( first, last );
1569 
1570  // get the array itself
1571  FArray* var = fArray( name, length );
1572  if ( !var ) return ErrorCodes::InvalidColumn;
1573 
1575  std::copy( first, last, std::begin( *var ) );
1576 
1577  return StatusCode::SUCCESS;
1578  }
1579  // =======================================================================
1618  template <class ARRAY>
1619  StatusCode array( const std::string& name, const ARRAY& data, const MIndex& length )
1620  {
1621  using std::begin; // allow data to be eg. CLHEP::HepVector (which does not define HepVector::begin()!,
1622  // in which case ADL prefers CLHEP::begin (yah! at least they (now) use a namespace)
1623  // so one just to insure double* CLHEP::begin(CLHEP::HepVector& v) { return &v[0]; }
1624  // is visible when this function gets instantiated for CLHEP::HepVector...
1625  auto first = begin( data );
1626  return array( name, first, std::next( first, length ) );
1627  }
1628  // =======================================================================
1659  template <class ARRAY>
1660  StatusCode array( const std::string& name, const ARRAY& data )
1661  {
1662  using std::begin;
1663  using std::end;
1664  return array( name, begin( data ), end( data ) );
1665  }
1666  // =======================================================================
1667  public:
1668  // =======================================================================
1717  template <class MATRIX>
1718  StatusCode matrix( const std::string& name, const MATRIX& data, const MIndex& rows, const MIndex& cols )
1719  {
1720  if ( invalid() ) return ErrorCodes::InvalidTuple;
1721  if ( rowWise() ) return ErrorCodes::InvalidOperation;
1722 
1723  // get the matrix itself
1724  FMatrix* var = fMatrix( name, rows, cols );
1725  if ( !var ) return ErrorCodes::InvalidColumn;
1726 
1728  for ( size_t iCol = 0; iCol < cols; ++iCol ) {
1729  for ( size_t iRow = 0; iRow < rows; ++iRow ) {
1730  ( *var )[iRow][iCol] = data[iRow][iCol];
1731  }
1732  };
1733  return StatusCode::SUCCESS;
1734  }
1735  // =======================================================================
1736  public:
1737  // =======================================================================
1754  template <class TYPE>
1755  StatusCode column( const std::string& name, const ROOT::Math::LorentzVector<TYPE>& v )
1756  {
1757  return columns( v, std::make_pair( name + "E", &ROOT::Math::LorentzVector<TYPE>::E ),
1758  std::make_pair( name + "X", &ROOT::Math::LorentzVector<TYPE>::Px ),
1759  std::make_pair( name + "Y", &ROOT::Math::LorentzVector<TYPE>::Py ),
1760  std::make_pair( name + "Z", &ROOT::Math::LorentzVector<TYPE>::Pz ) );
1761  }
1762  // =======================================================================
1779  template <class TYPE, class TAG>
1781  {
1782  return this->columns( v, std::make_pair( name + "X", &ROOT::Math::DisplacementVector3D<TYPE, TAG>::X ),
1785  }
1786  // =======================================================================
1803  template <class TYPE, class TAG>
1805  {
1806  return this->columns( v, std::make_pair( name + "X", &ROOT::Math::PositionVector3D<TYPE, TAG>::X ),
1809  }
1810  // =======================================================================
1819  template <class TYPE, unsigned int D1, unsigned int D2, class REP>
1820  StatusCode matrix( const std::string& name, const ROOT::Math::SMatrix<TYPE, D1, D2, REP>& mtrx )
1821  {
1822  if ( invalid() ) return ErrorCodes::InvalidTuple;
1823  if ( rowWise() ) return ErrorCodes::InvalidOperation;
1824 
1825  // get the matrix itself
1826  FMatrix* var = fMatrix( name, (MIndex)D1, (MIndex)D2 );
1827  if ( !var ) return ErrorCodes::InvalidColumn;
1828 
1830  for ( size_t iCol = 0; iCol < D2; ++iCol ) {
1831  for ( size_t iRow = 0; iRow < D1; ++iRow ) {
1832  ( *var )[iRow][iCol] = mtrx( iRow, iCol );
1833  }
1834  };
1835 
1836  return StatusCode::SUCCESS;
1837  }
1838  // =======================================================================
1856  template <class KEY, class VALUE>
1858  const std::string& length, const size_t maxv = 100 )
1859  {
1860  using Info = std::pair<KEY, VALUE>;
1861  static const std::array<float ( * )( const Info& ), 2> fns = {
1862  {[]( const Info& i ) -> float { return i.first; }, []( const Info& i ) -> float { return i.second; }}};
1863  return fmatrix( name, begin( fns ), end( fns ), begin( info ), end( info ), length, maxv );
1864  }
1865  // =======================================================================
1866  public:
1867  // =======================================================================
1875  template <class TYPE>
1876  StatusCode put( const std::string& name, const TYPE* obj );
1877  // =======================================================================
1878  public:
1879  // =======================================================================
1883  StatusCode write();
1884  // =======================================================================
1886  const std::string& name() const { return m_name; }
1887  // =======================================================================
1891  const NTuple::Tuple* tuple() const { return m_tuple; }
1892  // =======================================================================
1896  NTuple::Tuple* tuple() { return m_tuple; }
1897  // =======================================================================
1899  const CLID& clid() const { return m_clid; }
1900  // =======================================================================
1902  Tuples::Type type() const { return m_type; }
1903  // =======================================================================
1905  bool columnWise() const { return CLID_ColumnWiseTuple == clid(); }
1906  // =======================================================================
1908  bool rowWise() const { return CLID_RowWiseTuple == clid(); }
1909  // =======================================================================
1911  bool evtColType() const { return Tuples::EVTCOL == type(); }
1912  // =======================================================================
1914  bool valid() const { return 0 != tuple(); }
1915  // =======================================================================
1917  bool invalid() const { return !valid(); }
1918  // =======================================================================
1919  public:
1920  // =======================================================================
1927  {
1928  return m_items.emplace( std::move( name ), std::move( type ) ).second;
1929  }
1930  // =======================================================================
1935  bool goodItem( const std::string& name ) const { return m_items.end() == m_items.find( name ); }
1936  // =======================================================================
1938  const ItemMap& items() const { return m_items; }
1939  // =======================================================================
1940  public:
1941  // =======================================================================
1942  virtual StatusCode Error( const std::string& msg, const StatusCode sc = StatusCode::FAILURE ) const = 0;
1943  // =======================================================================
1944  virtual StatusCode Warning( const std::string& msg, const StatusCode sc = StatusCode::FAILURE ) const = 0;
1945  // =======================================================================
1946  private:
1947  // =======================================================================
1949  Int* ints( const std::string& name, int minv, int maxv );
1950  // =======================================================================
1952  FArray* fArray( const std::string& name, Int* item );
1953  // =======================================================================
1955  FArray* fArray( const std::string& name, const MIndex& rows );
1956  // =======================================================================
1958  Address* addresses( const std::string& name );
1959  // =======================================================================
1961  FMatrix* fMatrix( const std::string& name, Int* item, const MIndex& cols );
1962  // =======================================================================
1964  FMatrix* fMatrix( const std::string& name, const MIndex& rows, const MIndex& cols );
1965  // =======================================================================
1967  TupleObj( const TupleObj& ) = delete;
1968  TupleObj& operator=( const TupleObj& ) = delete;
1969  // =======================================================================
1970  private:
1971  // =======================================================================
1974  // =======================================================================
1977  // =======================================================================
1980  // =======================================================================
1983  // =======================================================================
1985  size_t m_refCount = 0;
1986  // =======================================================================
1987  // helper type to define the actual storage types
1988  template <typename T>
1990  // =======================================================================
1993  // =======================================================================
1996  // =======================================================================
1999  // =======================================================================
2002  // =======================================================================
2005  // =======================================================================
2008  // =======================================================================
2011  // =======================================================================
2014  // =======================================================================
2017  // =======================================================================
2020  // =======================================================================
2023  // =======================================================================
2026  // =======================================================================
2029  // =======================================================================
2032  // =======================================================================
2035  // =======================================================================
2038  // =======================================================================
2040  ItemMap m_items;
2041  // =======================================================================
2042  };
2043  // ==========================================================================
2044 } // end of namespace Tuples
2045 
2046 // ============================================================================
2047 // GaudiAlg
2048 // ============================================================================
2049 #include "GaudiAlg/TuplePut.h"
2050 // ============================================================================
2051 // The END
2052 // ============================================================================
2053 #endif // GAUDIALG_TUPLEOBJ_H
2054 // ============================================================================
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:1780
constexpr static const auto FAILURE
Definition: StatusCode.h:88
ColumnStorage< FArray > m_arraysf
the actual storage of all &#39;FArray&#39; columns (fixed)
Definition: TupleObj.h:2031
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:1979
ColumnStorage< Float > m_floats
the actual storage of all &#39;Float&#39; columns
Definition: TupleObj.h:2019
ColumnStorage< Address > m_addresses
the actual storage of all &#39;Address&#39; columns
Definition: TupleObj.h:2025
std::map< std::string, std::string > ItemMap
Definition: TupleObj.h:254
const NTuple::Tuple * tuple() const
provide the access to underlying Gaudi N-tuple
Definition: TupleObj.h:1891
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:1718
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:236
ColumnStorage< Bool > m_bools
the actual storage of all &#39;bool&#39; columns
Definition: TupleObj.h:1992
bool goodItem(const std::string &name) const
check the uniqueness of the name
Definition: TupleObj.h:1935
bool evtColType() const
Event collection ?
Definition: TupleObj.h:1911
Tuples::Type m_type
tuple &#39;type&#39;
Definition: TupleObj.h:1982
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:242
ErrorCodes
Tuple error codes.
Definition: TupleObj.h:95
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:233
#define STATUSCODE_ENUM_DECL(ENUM)
Declare an enum to be used as StatusCode value.
Definition: StatusCode.h:258
NTuple::Item< unsigned short > UShort
basic type for unsigned int items
Definition: TupleObj.h:221
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:1311
unsigned short MIndex
Definition: TupleObj.h:251
ColumnStorage< LongLong > m_longlongs
the actual storage of all &#39;longlong&#39; columns
Definition: TupleObj.h:2013
ColumnStorage< UShort > m_ushorts
the actual storage of all &#39;unsigned int&#39; columns
Definition: TupleObj.h:2004
std::string m_name
name
Definition: TupleObj.h:1973
bool isFailure() const
Definition: StatusCode.h:139
NTuple::Tuple * tuple()
provide the access to underlying Gaudi N-tuple
Definition: TupleObj.h:1896
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:884
NTuple::Item< unsigned char > UChar
basic type for unsigned int items
Definition: TupleObj.h:215
Provide serialization function (output only) for some common STL classes (vectors, lists, pairs, maps) plus GaudiUtils::Map and GaudiUtils::HashMap.
bool columnWise() const
column wise NTuple ?
Definition: TupleObj.h:1905
ColumnStorage< UInt > m_uints
the actual storage of all &#39;unsigned int&#39; columns
Definition: TupleObj.h:2010
PropertyMgr & operator=(const PropertyMgr &)=delete
constexpr double second
STL class.
NTuple::Item< short > Short
basic type for int items
Definition: TupleObj.h:218
bool addItem(std::string name, std::string type)
add the item name into the list of known items
Definition: TupleObj.h:1926
ColumnStorage< Double > m_doubles
the actual storage of all &#39;Double&#39; columns
Definition: TupleObj.h:2022
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:1497
ColumnStorage< FMatrix > m_fmatrices
the actual storage of all &#39;FArray&#39; columns
Definition: TupleObj.h:2034
constexpr to_< float > to_float
Definition: TupleObj.h:72
ColumnStorage< ULongLong > m_ulonglongs
the actual storage of all &#39;ulonglong&#39; columns
Definition: TupleObj.h:2016
TupleObj.h GaudiAlg/TupleObj.h namespace with few technical implementations.
A simple wrapper class over standard Gaudi NTuple::Tuple facility.
Definition: TupleObj.h:204
T next(T...args)
StatusCode array(const std::string &name, const ARRAY &data)
fill N-Tuple with fixed-size array
Definition: TupleObj.h:1660
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:51
ColumnStorage< Char > m_chars
the actual storage of all &#39;Int&#39; columns
Definition: TupleObj.h:1995
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:1199
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:934
NTuple::Matrix< float > FMatrix
basic type for matrix of floats
Definition: TupleObj.h:248
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:1820
ColumnStorage< Short > m_shorts
the actual storage of all &#39;Int&#39; columns
Definition: TupleObj.h:2001
T operator()(Arg &&i) const
Definition: TupleObj.h:67
T make_pair(T...args)
ItemMap m_items
all booked types:
Definition: TupleObj.h:2040
NTuple::Item< bool > Bool
basic type for int items
Definition: TupleObj.h:209
NTuple::Item< double > Double
basic type for double items
Definition: TupleObj.h:239
ColumnStorage< Int > m_ints
the actual storage of all &#39;Int&#39; columns
Definition: TupleObj.h:2007
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:1155
Specialization acting as a smart pointer holding a N tuple _Item.
Definition: NTuple.h:316
unsigned int CLID
Class ID definition.
Definition: ClassID.h:8
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:1060
bool valid() const
valid pointer to tuple ?
Definition: TupleObj.h:1914
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:1381
constexpr static const auto SUCCESS
Definition: StatusCode.h:87
bool rowWise() const
row wise NTuple ?
Definition: TupleObj.h:1908
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:407
StatusCode column(const std::string &name, signed char value)
Set the value for the selected tuple column.
Definition: TupleObj.h:709
NTuple::Item< long long > LongLong
basic type for unsigned long long items
Definition: TupleObj.h:230
StatusCode farray(const NamedFunctions &funs, DataIterator first, DataIterator last, const std::string &length, size_t maxv)
Definition: TupleObj.h:1116
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:1247
StatusCode array(const std::string &name, DATA first, DATA last)
fill N-Tuple with fixed-size array
Definition: TupleObj.h:1561
struct GAUDI_API array
Parametrisation class for redirection array - like implementation.
STL class.
NTuple::Tuple * m_tuple
tuple itself
Definition: TupleObj.h:1976
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:1857
T cref(T...args)
Tuples::Type type() const
accessor to the N-Tuple type
Definition: TupleObj.h:1902
boost::spirit::classic::position_iterator2< ForwardIterator > Iterator
Definition: Iterator.h:18
T begin(T...args)
ColumnStorage< FMatrix > m_matricesf
the actual storage of all &#39;FMatrix&#39; columns (fixed)
Definition: TupleObj.h:2037
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:1002
T back_inserter(T...args)
T any_of(T...args)
const StatusCode & ignore() const
Ignore/check StatusCode.
Definition: StatusCode.h:165
StatusCode farray(const Container< NamedFunction > &funs, DataIterator first, DataIterator last, const std::string &length, size_t maxv)
Definition: TupleObj.h:1107
double fun(const std::vector< double > &x)
Definition: PFuncTest.cpp:26
NTuple::Item< char > Char
basic type for int items
Definition: TupleObj.h:212
std::add_const_t< typename std::iterator_traits< Iterator >::reference > const_ref_t
Definition: TupleObj.h:75
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:224
StatusCode column(const std::string &name, const ROOT::Math::LorentzVector< TYPE > &v)
Useful shortcut to put LorentzVector directly into N-Tuple:
Definition: TupleObj.h:1755
bool invalid() const
invalid pointer to tuple ?
Definition: TupleObj.h:1917
T transform(T...args)
const ItemMap & items() const
get the full list of booked items
Definition: TupleObj.h:1938
NTuple::Array< float > FArray
basic type for array of floats
Definition: TupleObj.h:245
AttribStringParser::Iterator begin(const AttribStringParser &parser)
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:93
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:49
const CLID & clid() const
accessor to the N-Tuple CLID
Definition: TupleObj.h:1899
StatusCode array(const std::string &name, const ARRAY &data, const MIndex &length)
fill N-Tuple with fixed-size array
Definition: TupleObj.h:1619
Class acting as a smart pointer holding a N tuple _Item.
Definition: NTuple.h:51
#define GAUDI_API
Definition: Kernel.h:104
Type
the list of available types for ntuples
Definition: TupleObj.h:83
STL class.
const std::string & name() const
get the name
Definition: TupleObj.h:1886
NTuple::Item< unsigned int > UInt
basic type for unsigned int items
Definition: TupleObj.h:227
T forward(T...args)
ColumnStorage< UChar > m_uchars
the actual storage of all &#39;unsigned int&#39; columns
Definition: TupleObj.h:1998
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:794
Out1 * put(DataObjectHandle< Out1 > &out_handle, Out2 &&out)
T reserve(T...args)
unsigned long code_t
type of StatusCode value
Definition: StatusCode.h:54
ColumnStorage< FArray > m_farrays
the actual storage of all &#39;FArray&#39; columns
Definition: TupleObj.h:2028
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:1804