Loading [MathJax]/extensions/tex2jax.js
The Gaudi Framework  v31r0 (aeb156f0)
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
TupleObj.h
Go to the documentation of this file.
1 // ============================================================================
2 #ifndef GAUDIALG_TUPLEOBJ_H
3 #define GAUDIALG_TUPLEOBJ_H 1
4 // ============================================================================
5 // Include files
6 // ============================================================================
7 // STD&STL
8 // ============================================================================
9 #include <array>
10 #include <cstddef>
11 #include <functional>
12 #include <limits>
13 #include <numeric>
14 #include <set>
15 #include <sstream>
16 #include <string>
17 // ============================================================================
18 // GaudiKernel
19 // ============================================================================
20 #include "GaudiKernel/NTuple.h"
22 #include "GaudiKernel/VectorMap.h"
23 #include "GaudiKernel/invoke.h"
24 // ============================================================================
25 // GaudiAlg
26 // ============================================================================
27 #include "GaudiAlg/Maps.h"
28 #include "GaudiAlg/Tuples.h"
29 // ============================================================================
30 // ROOT
31 // ============================================================================
32 #include "Math/Point3D.h"
33 #include "Math/SMatrix.h"
34 #include "Math/SVector.h"
35 #include "Math/Vector3D.h"
36 #include "Math/Vector4D.h"
37 // ============================================================================
38 // forward declaration
39 // ============================================================================
40 // GaudiKernel
41 // ============================================================================
42 class IOpaqueAddress;
43 // ============================================================================
52 // ============================================================================
60 namespace Tuples {
61  namespace detail {
62  template <typename T>
63  struct to_ {
64  template <typename Arg>
65  T operator()( Arg&& i ) const {
66  return T( std::forward<Arg>( i ) );
67  }
68  };
69  constexpr to_<float> to_float{};
70 
71  template <typename Iterator>
72  using const_ref_t = std::add_const_t<typename std::iterator_traits<Iterator>::reference>;
73  } // namespace detail
74  // ==========================================================================
80  enum Type {
81  NTUPLE, // Analysis nTuple
82  EVTCOL // Event Collection
83  };
84  // ==========================================================================
93  InvalidTuple = 100,
98  TruncateValue = 200
99  };
100 } // namespace Tuples
101 
103 
104 namespace Tuples {
105  // ==========================================================================
201  public:
202  // ========================================================================
205  // ========================================================================
208  // ========================================================================
211  // ========================================================================
214  // ========================================================================
217  // ========================================================================
220  // ========================================================================
223  // ========================================================================
226  // ========================================================================
229  // ========================================================================
232  // ========================================================================
235  // ========================================================================
238  // ========================================================================
241  // ========================================================================
244  // ========================================================================
245  // the actual type for variable size matrix indices
246  typedef unsigned short MIndex;
247  // ========================================================================
248  // the map of all items
250  // ========================================================================
251  protected:
252  // ========================================================================
260  TupleObj( std::string name, NTuple::Tuple* tuple, const CLID& clid = CLID_ColumnWiseTuple,
261  const Tuples::Type type = Tuples::NTUPLE );
262  // ========================================================================
263  public:
264  // ========================================================================
265  virtual ~TupleObj();
266  // ========================================================================
282  StatusCode column( const std::string& name, float value );
283  // ========================================================================
284  public:
285  // ========================================================================
302  StatusCode column( const std::string& name, double value );
303  // ========================================================================
304  public:
305  // ========================================================================
321  StatusCode column( const std::string& name, short value );
322  // ========================================================================
340  StatusCode column( const std::string& name, short value, short minv, short maxv );
341  // ========================================================================
342  public:
343  // ========================================================================
359  StatusCode column( const std::string& name, unsigned short value );
360  // ========================================================================
378  StatusCode column( const std::string& name, unsigned short value, unsigned short minv, unsigned short maxv );
379  // ========================================================================
380  public:
381  // ========================================================================
397  StatusCode column( const std::string& name, char value );
398  // ========================================================================
416  StatusCode column( const std::string& name, char value, char minv, char maxv );
417  // ========================================================================
418  public:
419  // ========================================================================
435  StatusCode column( const std::string& name, unsigned char value );
436  // ========================================================================
454  StatusCode column( const std::string& name, unsigned char value, unsigned char minv, unsigned char maxv );
455  // ========================================================================
456  public:
457  // ========================================================================
473  StatusCode column( const std::string& name, int value );
474  // ========================================================================
492  StatusCode column( const std::string& name, int value, int minv, int maxv );
493  // ========================================================================
494  public:
495  // ========================================================================
511  StatusCode column( const std::string& name, unsigned int value );
512  // ========================================================================
530  StatusCode column( const std::string& name, unsigned int value, unsigned int minv, unsigned int maxv );
531  // ========================================================================
532  public:
533  // ========================================================================
550  StatusCode column( const std::string& name, long value );
551  // ========================================================================
569  StatusCode column( const std::string& name, long value, long minv, long maxv );
570  // ========================================================================
571  public:
572  // ========================================================================
589  StatusCode column( const std::string& name, unsigned long value );
590  // ========================================================================
608  StatusCode column( const std::string& name, unsigned long value, unsigned long minv, unsigned long maxv );
609  // ========================================================================
610  public:
611  // ========================================================================
627  StatusCode column( const std::string& name, long long value );
628  // ========================================================================
646  StatusCode column( const std::string& name, long long value, long long minv, long long maxv );
647  // ========================================================================
648  public:
649  // ========================================================================
665  StatusCode column( const std::string& name, unsigned long long value );
666  // ========================================================================
684  StatusCode column( const std::string& name, unsigned long long value, unsigned long long minv,
685  unsigned long long maxv );
686  // ========================================================================
687  public:
688  // ========================================================================
704  StatusCode column( const std::string& name, signed char value ) {
706  }
707  // ========================================================================
708  public:
709  // ========================================================================
724  StatusCode column( const std::string& name, bool value );
725  // ========================================================================
726  public:
727  // ========================================================================
746  StatusCode column( const std::string& name, IOpaqueAddress* address );
747  // ========================================================================
764  StatusCode column( IOpaqueAddress* address );
765  // ========================================================================
766  public:
767  // ========================================================================
787  template <typename Value, typename... Args>
788  StatusCode columns( Value&& value, Args&&... args ) {
789  if ( sizeof...( Args ) == 0 ) return StatusCode::SUCCESS;
791  this->column( std::get<0>( args ), Gaudi::invoke( std::get<1>( args ), value ) )...};
792  return std::accumulate( std::next( begin( scs ) ), end( scs ), *begin( scs ),
793  []( StatusCode sc, const StatusCode& i ) {
794  i.ignore(); // make sure there are no unchecked StatusCodes...
795  return sc.isFailure() ? sc : i; // latch to the first non-success case
796  } );
797  }
798  // ========================================================================
799  public:
800  // ========================================================================
824  StatusCode fill( const char* format... );
825  // =======================================================================
826  public:
827  // =======================================================================
876  template <typename ITERATOR1, typename ITERATOR2>
877  StatusCode farray( const std::string& name, ITERATOR1&& first, ITERATOR2&& last, const std::string& length,
878  size_t maxv ) {
879  return farray( name, detail::to_float, std::forward<ITERATOR1>( first ), std::forward<ITERATOR2>( last ), length,
880  maxv );
881  }
882  // =======================================================================
925  template <class DATA>
926  StatusCode farray( const std::string& name, const DATA& data, const std::string& length, const size_t maxv ) {
927  return farray( name, std::begin( data ), std::end( data ), length, maxv );
928  }
929  // =======================================================================
992  template <class FUNCTION, class ITERATOR>
993  StatusCode farray( const std::string& name, const FUNCTION& function, ITERATOR first, ITERATOR last,
994  const std::string& length, size_t maxv ) {
995  if ( invalid() ) return ErrorCodes::InvalidTuple;
996  if ( rowWise() ) return ErrorCodes::InvalidOperation;
997 
998  // adjust the length
999  if ( std::distance( first, last ) > static_cast<std::ptrdiff_t>( maxv ) ) {
1000  Warning( "farray('" + name + "'): array is overflow, skip extra entries" );
1001  last = std::next( first, maxv );
1002  }
1003 
1004  // get the length item
1005  Int* len = ints( length, 0, maxv );
1006  if ( !len ) return ErrorCodes::InvalidColumn;
1007 
1008  // adjust the length
1009  *len = std::distance( first, last );
1010 
1011  // get the array itself
1012  FArray* var = fArray( name, len );
1013  if ( !var ) return ErrorCodes::InvalidColumn;
1014 
1015  // fill the array
1016  std::transform( first, last, std::begin( *var ),
1017  [&]( auto&& i ) { return Gaudi::invoke( function, std::forward<decltype( i )>( i ) ); } );
1018 
1019  return StatusCode::SUCCESS;
1020  }
1021  // =======================================================================
1049  template <typename FunIterator, typename DataIterator>
1050  StatusCode farray_impl( FunIterator first_item, FunIterator last_item, DataIterator first, DataIterator last,
1051  const std::string& length, size_t maxv ) {
1052  if ( invalid() ) return ErrorCodes::InvalidTuple;
1053  if ( rowWise() ) return ErrorCodes::InvalidOperation;
1054 
1055  // adjust the length
1056  if ( std::distance( first, last ) > static_cast<std::ptrdiff_t>( maxv ) ) {
1058  std::ostringstream os;
1059  ostream_joiner( os, first_item, last_item, ",",
1060  []( std::ostream& os, const auto& i ) -> decltype( auto ) { return os << i.first; } );
1061  Warning( "farray('" + os.str() + "'): array overflow, skipping extra entries" ).ignore();
1062  last = std::next( first, maxv );
1063  }
1064 
1065  // get the length item
1066  Int* len = ints( length, 0, maxv );
1067  if ( !len ) return ErrorCodes::InvalidColumn;
1068 
1069  // adjust the length
1070  *len = std::distance( first, last );
1071 
1072  // get the arrays themselves
1073  std::vector<FArray*> vars;
1074  vars.reserve( std::distance( first_item, last_item ) );
1075  std::transform( first_item, last_item, std::back_inserter( vars ),
1076  [&]( const auto& item ) { return this->fArray( item.first, len ); } );
1077  if ( std::any_of( vars.begin(), vars.end(), []( const FArray* f ) { return !f; } ) ) {
1079  }
1080 
1081  // fill the array
1082  for ( size_t index = 0; first != last; ++first, ++index ) {
1083  auto item = first_item;
1084  for ( auto& var : vars ) { ( *var )[index] = Gaudi::invoke( ( item++ )->second, *first ); }
1085  }
1086 
1087  return StatusCode::SUCCESS;
1088  }
1089 
1090  template <
1091  typename DataIterator, template <typename, typename...> class Container = std::initializer_list,
1093  typename = std::enable_if_t<!std::is_convertible<Container<NamedFunction>, std::string>::value>>
1094  StatusCode farray( const Container<NamedFunction>& funs, DataIterator first, DataIterator last,
1095  const std::string& length, size_t maxv ) {
1096  return farray_impl( funs.begin(), funs.end(), std::forward<DataIterator>( first ),
1097  std::forward<DataIterator>( last ), length, maxv );
1098  }
1099 
1100  template <typename NamedFunctions, typename DataIterator,
1101  typename = std::enable_if_t<!std::is_convertible<NamedFunctions, std::string>::value>>
1102  StatusCode farray( const NamedFunctions& funs, DataIterator first, DataIterator last, const std::string& length,
1103  size_t maxv ) {
1104  return farray_impl( funs.begin(), funs.end(), std::forward<DataIterator>( first ),
1105  std::forward<DataIterator>( last ), length, maxv );
1106  }
1107  // =======================================================================
1139  template <class FUNC1, class FUNC2, class Iterator>
1140  StatusCode farray( const std::string& name1, const FUNC1& func1, const std::string& name2, const FUNC2& func2,
1141  Iterator&& first, Iterator&& last, const std::string& length, size_t maxv ) {
1142  return farray( {{name1, std::cref( func1 )}, {name2, std::cref( func2 )}}, std::forward<Iterator>( first ),
1143  std::forward<Iterator>( last ), length, maxv );
1144  }
1145  // =======================================================================
1182  template <class FUNC1, class FUNC2, class FUNC3, class Iterator>
1183  StatusCode farray( const std::string& name1, const FUNC1& func1, const std::string& name2, const FUNC2& func2,
1184  const std::string& name3, const FUNC3& func3, Iterator&& first, Iterator&& last,
1185  const std::string& length, size_t maxv ) {
1186  return farray( {{name1, std::cref( func1 )}, {name2, std::cref( func2 )}, {name3, std::cref( func3 )}},
1187  std::forward<Iterator>( first ), std::forward<Iterator>( last ), length, maxv );
1188  }
1189  // =======================================================================
1229  template <class FUNC1, class FUNC2, class FUNC3, class FUNC4, class Iterator>
1230  StatusCode farray( const std::string& name1, const FUNC1& func1, const std::string& name2, const FUNC2& func2,
1231  const std::string& name3, const FUNC3& func3, const std::string& name4, const FUNC4& func4,
1232  Iterator&& first, Iterator&& last, const std::string& length, size_t maxv ) {
1233  return farray( {{name1, std::cref( func1 )},
1234  {name2, std::cref( func2 )},
1235  {name3, std::cref( func3 )},
1236  {name4, std::cref( func4 )}},
1237  std::forward<Iterator>( first ), std::forward<Iterator>( last ), length, maxv );
1238  }
1239  // =======================================================================
1240  public:
1241  // =======================================================================
1292  template <class MATRIX>
1293  StatusCode fmatrix( const std::string& name, const MATRIX& data, size_t rows, const MIndex& cols,
1294  const std::string& length, size_t maxv ) {
1295  if ( invalid() ) return ErrorCodes::InvalidTuple;
1296  if ( rowWise() ) return ErrorCodes::InvalidOperation;
1297 
1298  // adjust the length
1299  if ( rows >= maxv ) {
1300  Warning( "fmatrix('" + name + "'): matrix is overflow, skip extra items" ).ignore();
1301  rows = ( 0 < maxv ) ? ( maxv - 1 ) : 0;
1302  }
1303 
1304  // get the length item
1305  Int* len = ints( length, 0, maxv );
1306  if ( !len ) return ErrorCodes::InvalidColumn;
1307 
1308  // adjust the length item
1309  *len = rows;
1310 
1311  // get the array itself
1312  FMatrix* var = fMatrix( name, len, cols );
1313  if ( !var ) return ErrorCodes::InvalidColumn;
1314 
1316  for ( size_t iCol = 0; iCol < cols; ++iCol ) {
1317  for ( MIndex iRow = 0; iRow < rows; ++iRow ) { ( *var )[iRow][iCol] = data[iRow][iCol]; }
1318  }
1319 
1320  return StatusCode::SUCCESS;
1321  }
1322  // =======================================================================
1359  template <class DATA>
1360  StatusCode fmatrix( const std::string& name, DATA first, DATA last, const MIndex& cols, const std::string& length,
1361  size_t maxv ) {
1362  if ( invalid() ) return ErrorCodes::InvalidTuple;
1363  if ( rowWise() ) return ErrorCodes::InvalidOperation;
1364 
1365  // adjust the length
1366  if ( first + maxv < last ) {
1367  Warning( "fmatrix('" + name + "'): matrix is overflow, skip extra items" ).ignore();
1368  last = first + maxv;
1369  }
1370 
1371  // get the length item
1372  Int* len = ints( length, 0, maxv );
1373  if ( !len ) return ErrorCodes::InvalidColumn;
1374 
1375  // adjust the length item
1376  *len = last - first;
1377 
1378  // get the array itself
1379  FMatrix* var = fMatrix( name, len, cols );
1380  if ( !var ) return ErrorCodes::InvalidColumn;
1381 
1383  size_t iRow = 0;
1384  for ( ; first != last; ++first ) {
1385  //
1386  for ( MIndex iCol = 0; iCol < cols; ++iCol ) { ( *var )[iRow][iCol] = ( *first )[iCol]; }
1387  //
1388  ++iRow;
1389  }
1390 
1391  return StatusCode::SUCCESS;
1392  }
1393  // =======================================================================
1472  template <class FUN, class DATA>
1473  StatusCode fmatrix( const std::string& name, FUN funF, FUN funL, DATA first, DATA last, const std::string& length,
1474  size_t maxv ) {
1475  if ( invalid() ) return ErrorCodes::InvalidTuple;
1476  if ( rowWise() ) return ErrorCodes::InvalidOperation;
1477 
1478  // adjust the length
1479  if ( std::distance( first, last ) > static_cast<std::ptrdiff_t>( maxv ) ) {
1480  Warning( "fmatrix('" + name + "'): matrix is overflow, skip extra items" ).ignore();
1481  last = std::next( first, maxv );
1482  }
1483 
1484  // get the length item
1485  Int* len = ints( length, 0, maxv );
1486 
1487  if ( !len ) return ErrorCodes::InvalidColumn;
1488 
1489  // adjust the length item
1490  *len = std::distance( first, last );
1491 
1492  // get the array itself
1493  auto cols = std::distance( funF, funL );
1494  FMatrix* var = fMatrix( name, len, cols );
1495  if ( !var ) return ErrorCodes::InvalidColumn;
1496 
1498  size_t iRow = 0;
1499  for ( ; first != last; ++first ) {
1500  //
1501  for ( FUN fun = funF; fun < funL; ++fun ) { ( *var )[iRow][fun - funF] = Gaudi::invoke( *fun, *first ); }
1502  //
1503  ++iRow;
1504  }
1505 
1506  return StatusCode::SUCCESS;
1507  }
1508  // =======================================================================
1509  public:
1510  // =======================================================================
1533  template <class DATA>
1534  StatusCode array( const std::string& name, DATA first, DATA last )
1535 
1536  {
1537  if ( invalid() ) return ErrorCodes::InvalidTuple;
1538  if ( rowWise() ) return ErrorCodes::InvalidOperation;
1539 
1540  // get the length (fixed!)
1541  auto length = std::distance( first, last );
1542 
1543  // get the array itself
1544  FArray* var = fArray( name, length );
1545  if ( !var ) return ErrorCodes::InvalidColumn;
1546 
1548  std::copy( first, last, std::begin( *var ) );
1549 
1550  return StatusCode::SUCCESS;
1551  }
1552  // =======================================================================
1591  template <class ARRAY>
1592  StatusCode array( const std::string& name, const ARRAY& data, const MIndex& length ) {
1593  using std::begin; // allow data to be eg. CLHEP::HepVector (which does not define HepVector::begin()!,
1594  // in which case ADL prefers CLHEP::begin (yah! at least they (now) use a namespace)
1595  // so one just to insure double* CLHEP::begin(CLHEP::HepVector& v) { return &v[0]; }
1596  // is visible when this function gets instantiated for CLHEP::HepVector...
1597  auto first = begin( data );
1598  return array( name, first, std::next( first, length ) );
1599  }
1600  // =======================================================================
1631  template <class ARRAY>
1632  StatusCode array( const std::string& name, const ARRAY& data ) {
1633  using std::begin;
1634  using std::end;
1635  return array( name, begin( data ), end( data ) );
1636  }
1637  // =======================================================================
1638  public:
1639  // =======================================================================
1688  template <class MATRIX>
1689  StatusCode matrix( const std::string& name, const MATRIX& data, const MIndex& rows, const MIndex& cols ) {
1690  if ( invalid() ) return ErrorCodes::InvalidTuple;
1691  if ( rowWise() ) return ErrorCodes::InvalidOperation;
1692 
1693  // get the matrix itself
1694  FMatrix* var = fMatrix( name, rows, cols );
1695  if ( !var ) return ErrorCodes::InvalidColumn;
1696 
1698  for ( size_t iCol = 0; iCol < cols; ++iCol ) {
1699  for ( size_t iRow = 0; iRow < rows; ++iRow ) { ( *var )[iRow][iCol] = data[iRow][iCol]; }
1700  };
1701  return StatusCode::SUCCESS;
1702  }
1703  // =======================================================================
1704  public:
1705  // =======================================================================
1722  template <class TYPE>
1723  StatusCode column( const std::string& name, const ROOT::Math::LorentzVector<TYPE>& v ) {
1724  return columns( v, std::make_pair( name + "E", &ROOT::Math::LorentzVector<TYPE>::E ),
1725  std::make_pair( name + "X", &ROOT::Math::LorentzVector<TYPE>::Px ),
1726  std::make_pair( name + "Y", &ROOT::Math::LorentzVector<TYPE>::Py ),
1727  std::make_pair( name + "Z", &ROOT::Math::LorentzVector<TYPE>::Pz ) );
1728  }
1729  // =======================================================================
1746  template <class TYPE, class TAG>
1748  return this->columns( v, std::make_pair( name + "X", &ROOT::Math::DisplacementVector3D<TYPE, TAG>::X ),
1751  }
1752  // =======================================================================
1769  template <class TYPE, class TAG>
1771  return this->columns( v, std::make_pair( name + "X", &ROOT::Math::PositionVector3D<TYPE, TAG>::X ),
1774  }
1775  // =======================================================================
1784  template <class TYPE, unsigned int D1, unsigned int D2, class REP>
1785  StatusCode matrix( const std::string& name, const ROOT::Math::SMatrix<TYPE, D1, D2, REP>& mtrx ) {
1786  if ( invalid() ) return ErrorCodes::InvalidTuple;
1787  if ( rowWise() ) return ErrorCodes::InvalidOperation;
1788 
1789  // get the matrix itself
1790  FMatrix* var = fMatrix( name, (MIndex)D1, (MIndex)D2 );
1791  if ( !var ) return ErrorCodes::InvalidColumn;
1792 
1794  for ( size_t iCol = 0; iCol < D2; ++iCol ) {
1795  for ( size_t iRow = 0; iRow < D1; ++iRow ) { ( *var )[iRow][iCol] = mtrx( iRow, iCol ); }
1796  };
1797 
1798  return StatusCode::SUCCESS;
1799  }
1800  // =======================================================================
1818  template <class KEY, class VALUE>
1820  const std::string& length, const size_t maxv = 100 ) {
1821  using Info = std::pair<KEY, VALUE>;
1822  static const std::array<float ( * )( const Info& ), 2> fns = {
1823  {[]( const Info& i ) -> float { return i.first; }, []( const Info& i ) -> float { return i.second; }}};
1824  return fmatrix( name, begin( fns ), end( fns ), begin( info ), end( info ), length, maxv );
1825  }
1826  // =======================================================================
1827  public:
1828  // =======================================================================
1836  template <class TYPE>
1837  StatusCode put( const std::string& name, const TYPE* obj );
1838  // =======================================================================
1839  public:
1840  // =======================================================================
1844  StatusCode write();
1845  // =======================================================================
1847  const std::string& name() const { return m_name; }
1848  // =======================================================================
1852  const NTuple::Tuple* tuple() const { return m_tuple; }
1853  // =======================================================================
1857  NTuple::Tuple* tuple() { return m_tuple; }
1858  // =======================================================================
1860  const CLID& clid() const { return m_clid; }
1861  // =======================================================================
1863  Tuples::Type type() const { return m_type; }
1864  // =======================================================================
1866  bool columnWise() const { return CLID_ColumnWiseTuple == clid(); }
1867  // =======================================================================
1869  bool rowWise() const { return CLID_RowWiseTuple == clid(); }
1870  // =======================================================================
1872  bool evtColType() const { return Tuples::EVTCOL == type(); }
1873  // =======================================================================
1875  bool valid() const { return 0 != tuple(); }
1876  // =======================================================================
1878  bool invalid() const { return !valid(); }
1879  // =======================================================================
1880  public:
1881  // =======================================================================
1888  return m_items.emplace( std::move( name ), std::move( type ) ).second;
1889  }
1890  // =======================================================================
1895  bool goodItem( const std::string& name ) const { return m_items.end() == m_items.find( name ); }
1896  // =======================================================================
1898  const ItemMap& items() const { return m_items; }
1899  // =======================================================================
1900  public:
1901  // =======================================================================
1902  virtual StatusCode Error( const std::string& msg, const StatusCode sc = StatusCode::FAILURE ) const = 0;
1903  // =======================================================================
1904  virtual StatusCode Warning( const std::string& msg, const StatusCode sc = StatusCode::FAILURE ) const = 0;
1905  // =======================================================================
1906  private:
1907  // =======================================================================
1909  Int* ints( const std::string& name, int minv, int maxv );
1910  // =======================================================================
1912  FArray* fArray( const std::string& name, Int* item );
1913  // =======================================================================
1915  FArray* fArray( const std::string& name, const MIndex& rows );
1916  // =======================================================================
1918  Address* addresses( const std::string& name );
1919  // =======================================================================
1921  FMatrix* fMatrix( const std::string& name, Int* item, const MIndex& cols );
1922  // =======================================================================
1924  FMatrix* fMatrix( const std::string& name, const MIndex& rows, const MIndex& cols );
1925  // =======================================================================
1927  TupleObj( const TupleObj& ) = delete;
1928  TupleObj& operator=( const TupleObj& ) = delete;
1929  // =======================================================================
1930  private:
1931  // =======================================================================
1934  // =======================================================================
1937  // =======================================================================
1940  // =======================================================================
1943  // =======================================================================
1945  size_t m_refCount = 0;
1946  // =======================================================================
1947  // helper type to define the actual storage types
1948  template <typename T>
1950  // =======================================================================
1953  // =======================================================================
1956  // =======================================================================
1959  // =======================================================================
1962  // =======================================================================
1965  // =======================================================================
1968  // =======================================================================
1971  // =======================================================================
1974  // =======================================================================
1977  // =======================================================================
1980  // =======================================================================
1983  // =======================================================================
1986  // =======================================================================
1989  // =======================================================================
1992  // =======================================================================
1995  // =======================================================================
1998  // =======================================================================
2000  ItemMap m_items;
2001  // =======================================================================
2002  };
2003  // ==========================================================================
2004 } // end of namespace Tuples
2005 
2006 // ============================================================================
2007 // GaudiAlg
2008 // ============================================================================
2009 #include "GaudiAlg/TuplePut.h"
2010 // ============================================================================
2011 // The END
2012 // ============================================================================
2013 #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:1747
ColumnStorage< FArray > m_arraysf
the actual storage of all &#39;FArray&#39; columns (fixed)
Definition: TupleObj.h:1991
A bit modified version of &#39;Loki::AssocVector&#39; associative vector from Loki library by Andrei Alexandr...
Definition: VectorMap.h:102
CLID m_clid
tuple CLID
Definition: TupleObj.h:1939
ColumnStorage< Float > m_floats
the actual storage of all &#39;Float&#39; columns
Definition: TupleObj.h:1979
ColumnStorage< Address > m_addresses
the actual storage of all &#39;Address&#39; columns
Definition: TupleObj.h:1985
std::map< std::string, std::string > ItemMap
Definition: TupleObj.h:249
const NTuple::Tuple * tuple() const
provide the access to underlying Gaudi N-tuple
Definition: TupleObj.h:1852
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:1689
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:231
ColumnStorage< Bool > m_bools
the actual storage of all &#39;bool&#39; columns
Definition: TupleObj.h:1952
bool goodItem(const std::string &name) const
check the uniqueness of the name
Definition: TupleObj.h:1895
bool evtColType() const
Event collection ?
Definition: TupleObj.h:1872
Tuples::Type m_type
tuple &#39;type&#39;
Definition: TupleObj.h:1942
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:237
ErrorCodes
Tuple error codes.
Definition: TupleObj.h:92
constexpr static const auto SUCCESS
Definition: StatusCode.h:85
GAUDI_API void fill(AIDA::IHistogram1D *histo, const double value, const double weight=1.0)
simple function to fill AIDA::IHistogram1D objects
Definition: Fill.cpp:35
NTuple::Item< unsigned long long > ULongLong
basic type for unsigned long long items
Definition: TupleObj.h:228
#define STATUSCODE_ENUM_DECL(ENUM)
Declare an enum to be used as StatusCode value.
Definition: StatusCode.h:239
NTuple::Item< unsigned short > UShort
basic type for unsigned int items
Definition: TupleObj.h:216
T end(T...args)
StatusCode fmatrix(const std::string &name, const MATRIX &data, size_t rows, const MIndex &cols, const std::string &length, size_t maxv)
Fill N-Tuple with data from variable-size matrix.
Definition: TupleObj.h:1293
unsigned short MIndex
Definition: TupleObj.h:246
ColumnStorage< LongLong > m_longlongs
the actual storage of all &#39;long long&#39; columns
Definition: TupleObj.h:1973
ColumnStorage< UShort > m_ushorts
the actual storage of all &#39;unsigned int&#39; columns
Definition: TupleObj.h:1964
std::string m_name
name
Definition: TupleObj.h:1933
bool isFailure() const
Definition: StatusCode.h:130
NTuple::Tuple * tuple()
provide the access to underlying Gaudi N-tuple
Definition: TupleObj.h:1857
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:877
NTuple::Item< unsigned char > UChar
basic type for unsigned int items
Definition: TupleObj.h:210
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:1866
ColumnStorage< UInt > m_uints
the actual storage of all &#39;unsigned int&#39; columns
Definition: TupleObj.h:1970
PropertyMgr & operator=(const PropertyMgr &)=delete
constexpr double second
STL class.
NTuple::Item< short > Short
basic type for int items
Definition: TupleObj.h:213
bool addItem(std::string name, std::string type)
add the item name into the list of known items
Definition: TupleObj.h:1887
ColumnStorage< Double > m_doubles
the actual storage of all &#39;Double&#39; columns
Definition: TupleObj.h:1982
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:1473
ColumnStorage< FMatrix > m_fmatrices
the actual storage of all &#39;FArray&#39; columns
Definition: TupleObj.h:1994
constexpr to_< float > to_float
Definition: TupleObj.h:69
ColumnStorage< ULongLong > m_ulonglongs
the actual storage of all &#39;unsigned long long&#39; columns
Definition: TupleObj.h:1976
TupleObj.h GaudiAlg/TupleObj.h namespace with few technical implementations.
A simple wrapper class over standard Gaudi NTuple::Tuple facility.
Definition: TupleObj.h:200
T next(T...args)
StatusCode array(const std::string &name, const ARRAY &data)
fill N-Tuple with fixed-size array
Definition: TupleObj.h:1632
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:50
ColumnStorage< Char > m_chars
the actual storage of all &#39;Int&#39; columns
Definition: TupleObj.h:1955
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:1183
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:926
NTuple::Matrix< float > FMatrix
basic type for matrix of floats
Definition: TupleObj.h:243
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:1785
ColumnStorage< Short > m_shorts
the actual storage of all &#39;Int&#39; columns
Definition: TupleObj.h:1961
T operator()(Arg &&i) const
Definition: TupleObj.h:65
T make_pair(T...args)
ItemMap m_items
all booked types:
Definition: TupleObj.h:2000
NTuple::Item< bool > Bool
basic type for int items
Definition: TupleObj.h:204
NTuple::Item< double > Double
basic type for double items
Definition: TupleObj.h:234
ColumnStorage< Int > m_ints
the actual storage of all &#39;Int&#39; columns
Definition: TupleObj.h:1967
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:1140
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
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:1050
bool valid() const
valid pointer to tuple ?
Definition: TupleObj.h:1875
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:1360
bool rowWise() const
row wise NTuple ?
Definition: TupleObj.h:1869
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:704
NTuple::Item< long long > LongLong
basic type for unsigned long long items
Definition: TupleObj.h:225
StatusCode farray(const NamedFunctions &funs, DataIterator first, DataIterator last, const std::string &length, size_t maxv)
Definition: TupleObj.h:1102
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:1230
StatusCode array(const std::string &name, DATA first, DATA last)
fill N-Tuple with fixed-size array
Definition: TupleObj.h:1534
struct GAUDI_API array
Parametrisation class for redirection array - like implementation.
STL class.
NTuple::Tuple * m_tuple
tuple itself
Definition: TupleObj.h:1936
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:1819
T cref(T...args)
Tuples::Type type() const
accessor to the N-Tuple type
Definition: TupleObj.h:1863
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:1997
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:993
T back_inserter(T...args)
T any_of(T...args)
const StatusCode & ignore() const
Ignore/check StatusCode.
Definition: StatusCode.h:153
StatusCode farray(const Container< NamedFunction > &funs, DataIterator first, DataIterator last, const std::string &length, size_t maxv)
Definition: TupleObj.h:1094
double fun(const std::vector< double > &x)
Definition: PFuncTest.cpp:26
NTuple::Item< char > Char
basic type for int items
Definition: TupleObj.h:207
std::add_const_t< typename std::iterator_traits< Iterator >::reference > const_ref_t
Definition: TupleObj.h:72
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:219
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:1723
bool invalid() const
invalid pointer to tuple ?
Definition: TupleObj.h:1878
T transform(T...args)
const ItemMap & items() const
get the full list of booked items
Definition: TupleObj.h:1898
NTuple::Array< float > FArray
basic type for array of floats
Definition: TupleObj.h:240
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:82
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
const CLID & clid() const
accessor to the N-Tuple CLID
Definition: TupleObj.h:1860
StatusCode array(const std::string &name, const ARRAY &data, const MIndex &length)
fill N-Tuple with fixed-size array
Definition: TupleObj.h:1592
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:80
STL class.
const std::string & name() const
get the name
Definition: TupleObj.h:1847
NTuple::Item< unsigned int > UInt
basic type for unsigned int items
Definition: TupleObj.h:222
T forward(T...args)
ColumnStorage< UChar > m_uchars
the actual storage of all &#39;unsigned int&#39; columns
Definition: TupleObj.h:1958
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:788
Out1 * put(DataObjectHandle< Out1 > &out_handle, Out2 &&out)
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 &#39;FArray&#39; columns
Definition: TupleObj.h:1988
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:1770