The Gaudi Framework  v33r0 (d5ea422b)
TupleObj.h
Go to the documentation of this file.
1 /***********************************************************************************\
2 * (c) Copyright 1998-2019 CERN for the benefit of the LHCb and ATLAS collaborations *
3 * *
4 * This software is distributed under the terms of the Apache version 2 licence, *
5 * copied verbatim in the file "LICENSE". *
6 * *
7 * In applying this licence, CERN does not waive the privileges and immunities *
8 * granted to it by virtue of its status as an Intergovernmental Organization *
9 * or submit itself to any jurisdiction. *
10 \***********************************************************************************/
11 // ============================================================================
12 #ifndef GAUDIALG_TUPLEOBJ_H
13 #define GAUDIALG_TUPLEOBJ_H 1
14 // ============================================================================
15 // Include files
16 // ============================================================================
17 // STD&STL
18 // ============================================================================
19 #include <array>
20 #include <cstddef>
21 #include <functional>
22 #include <limits>
23 #include <numeric>
24 #include <set>
25 #include <sstream>
26 #include <string>
27 // ============================================================================
28 // GaudiKernel
29 // ============================================================================
30 #include "GaudiKernel/NTuple.h"
32 #include "GaudiKernel/VectorMap.h"
33 // ============================================================================
34 // GaudiAlg
35 // ============================================================================
36 #include "GaudiAlg/Maps.h"
37 #include "GaudiAlg/Tuples.h"
38 // ============================================================================
39 // ROOT
40 // ============================================================================
41 #include "Math/Point3D.h"
42 #include "Math/SMatrix.h"
43 #include "Math/SVector.h"
44 #include "Math/Vector3D.h"
45 #include "Math/Vector4D.h"
46 // ============================================================================
47 // forward declaration
48 // ============================================================================
49 // GaudiKernel
50 // ============================================================================
51 class IOpaqueAddress;
52 // ============================================================================
61 // ============================================================================
69 namespace Tuples {
70  namespace detail {
71  template <typename T>
72  struct to_ {
73  template <typename Arg>
74  T operator()( Arg&& i ) const {
75  return T( std::forward<Arg>( i ) );
76  }
77  };
78  constexpr to_<float> to_float{};
79 
80  template <typename Iterator>
81  using const_ref_t = std::add_const_t<typename std::iterator_traits<Iterator>::reference>;
82  } // namespace detail
83  // ==========================================================================
89  enum Type {
90  NTUPLE, // Analysis nTuple
91  EVTCOL // Event Collection
92  };
93  // ==========================================================================
102  InvalidTuple = 100,
106  InvalidItem,
107  TruncateValue = 200
108  };
109 } // namespace Tuples
110 
112 
113 namespace Tuples {
114  // ==========================================================================
210  public:
211  // ========================================================================
214  // ========================================================================
217  // ========================================================================
220  // ========================================================================
223  // ========================================================================
226  // ========================================================================
229  // ========================================================================
232  // ========================================================================
235  // ========================================================================
238  // ========================================================================
241  // ========================================================================
244  // ========================================================================
247  // ========================================================================
250  // ========================================================================
253  // ========================================================================
254  // the actual type for variable size matrix indices
255  typedef unsigned short MIndex;
256  // ========================================================================
257  // the map of all items
259  // ========================================================================
260  protected:
261  // ========================================================================
269  TupleObj( std::string name, NTuple::Tuple* tuple, const CLID& clid = CLID_ColumnWiseTuple,
270  const Tuples::Type type = Tuples::NTUPLE );
271  // ========================================================================
272  public:
273  // ========================================================================
274  virtual ~TupleObj();
275  // ========================================================================
291  StatusCode column( const std::string& name, float value );
292  // ========================================================================
293  public:
294  // ========================================================================
311  StatusCode column( const std::string& name, double value );
312  // ========================================================================
313  public:
314  // ========================================================================
330  StatusCode column( const std::string& name, short value );
331  // ========================================================================
349  StatusCode column( const std::string& name, short value, short minv, short maxv );
350  // ========================================================================
351  public:
352  // ========================================================================
368  StatusCode column( const std::string& name, unsigned short value );
369  // ========================================================================
387  StatusCode column( const std::string& name, unsigned short value, unsigned short minv, unsigned short maxv );
388  // ========================================================================
389  public:
390  // ========================================================================
406  StatusCode column( const std::string& name, char value );
407  // ========================================================================
425  StatusCode column( const std::string& name, char value, char minv, char maxv );
426  // ========================================================================
427  public:
428  // ========================================================================
444  StatusCode column( const std::string& name, unsigned char value );
445  // ========================================================================
463  StatusCode column( const std::string& name, unsigned char value, unsigned char minv, unsigned char maxv );
464  // ========================================================================
465  public:
466  // ========================================================================
482  StatusCode column( const std::string& name, int value );
483  // ========================================================================
501  StatusCode column( const std::string& name, int value, int minv, int maxv );
502  // ========================================================================
503  public:
504  // ========================================================================
520  StatusCode column( const std::string& name, unsigned int value );
521  // ========================================================================
539  StatusCode column( const std::string& name, unsigned int value, unsigned int minv, unsigned int maxv );
540  // ========================================================================
541  public:
542  // ========================================================================
559  StatusCode column( const std::string& name, long value );
560  // ========================================================================
578  StatusCode column( const std::string& name, long value, long minv, long maxv );
579  // ========================================================================
580  public:
581  // ========================================================================
598  StatusCode column( const std::string& name, unsigned long value );
599  // ========================================================================
617  StatusCode column( const std::string& name, unsigned long value, unsigned long minv, unsigned long maxv );
618  // ========================================================================
619  public:
620  // ========================================================================
636  StatusCode column( const std::string& name, long long value );
637  // ========================================================================
655  StatusCode column( const std::string& name, long long value, long long minv, long long maxv );
656  // ========================================================================
657  public:
658  // ========================================================================
674  StatusCode column( const std::string& name, unsigned long long value );
675  // ========================================================================
693  StatusCode column( const std::string& name, unsigned long long value, unsigned long long minv,
694  unsigned long long maxv );
695  // ========================================================================
696  public:
697  // ========================================================================
713  StatusCode column( const std::string& name, signed char value ) {
715  }
716  // ========================================================================
717  public:
718  // ========================================================================
733  StatusCode column( const std::string& name, bool value );
734  // ========================================================================
735  public:
736  // ========================================================================
755  StatusCode column( const std::string& name, IOpaqueAddress* address );
756  // ========================================================================
773  StatusCode column( IOpaqueAddress* address );
774  // ========================================================================
775  public:
776  // ========================================================================
796  template <typename Value, typename... Args>
797  StatusCode columns( Value&& value, Args&&... args ) {
798  if ( sizeof...( Args ) == 0 ) return StatusCode::SUCCESS;
800  this->column( std::get<0>( args ), std::invoke( std::get<1>( args ), value ) )...};
801  return std::accumulate( std::next( begin( scs ) ), end( scs ), *begin( scs ),
802  []( StatusCode sc, const StatusCode& i ) {
803  i.ignore(); // make sure there are no unchecked StatusCodes...
804  return sc.isFailure() ? sc : i; // latch to the first non-success case
805  } );
806  }
807  // ========================================================================
808  public:
809  // ========================================================================
833  StatusCode fill( const char* format... );
834  // =======================================================================
835  public:
836  // =======================================================================
885  template <typename ITERATOR1, typename ITERATOR2>
886  StatusCode farray( const std::string& name, ITERATOR1&& first, ITERATOR2&& last, const std::string& length,
887  size_t maxv ) {
888  return farray( name, detail::to_float, std::forward<ITERATOR1>( first ), std::forward<ITERATOR2>( last ), length,
889  maxv );
890  }
891  // =======================================================================
934  template <class DATA>
935  StatusCode farray( const std::string& name, const DATA& data, const std::string& length, const size_t maxv ) {
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  if ( invalid() ) return ErrorCodes::InvalidTuple;
1005  if ( rowWise() ) return ErrorCodes::InvalidOperation;
1006 
1007  // adjust the length
1008  if ( std::distance( first, last ) > static_cast<std::ptrdiff_t>( maxv ) ) {
1009  Warning( "farray('" + name + "'): array is overflow, skip extra entries" );
1010  last = std::next( first, maxv );
1011  }
1012 
1013  // get the length item
1014  Int* len = ints( length, 0, maxv );
1015  if ( !len ) return ErrorCodes::InvalidColumn;
1016 
1017  // adjust the length
1018  *len = std::distance( first, last );
1019 
1020  // get the array itself
1021  FArray* var = fArray( name, len );
1022  if ( !var ) return ErrorCodes::InvalidColumn;
1023 
1024  // fill the array
1025  std::transform( first, last, std::begin( *var ),
1026  [&]( auto&& i ) { return std::invoke( function, std::forward<decltype( i )>( i ) ); } );
1027 
1028  return StatusCode::SUCCESS;
1029  }
1030  // =======================================================================
1058  template <typename FunIterator, typename DataIterator>
1059  StatusCode farray_impl( FunIterator first_item, FunIterator last_item, DataIterator first, DataIterator last,
1060  const std::string& length, size_t maxv ) {
1061  if ( invalid() ) return ErrorCodes::InvalidTuple;
1062  if ( rowWise() ) return ErrorCodes::InvalidOperation;
1063 
1064  // adjust the length
1065  if ( std::distance( first, last ) > static_cast<std::ptrdiff_t>( maxv ) ) {
1067  std::ostringstream os;
1068  ostream_joiner( os, first_item, last_item, ",",
1069  []( std::ostream& os, const auto& i ) -> decltype( auto ) { return os << i.first; } );
1070  Warning( "farray('" + os.str() + "'): array overflow, skipping extra entries" ).ignore();
1071  last = std::next( first, maxv );
1072  }
1073 
1074  // get the length item
1075  Int* len = ints( length, 0, maxv );
1076  if ( !len ) return ErrorCodes::InvalidColumn;
1077 
1078  // adjust the length
1079  *len = std::distance( first, last );
1080 
1081  // get the arrays themselves
1082  std::vector<FArray*> vars;
1083  vars.reserve( std::distance( first_item, last_item ) );
1084  std::transform( first_item, last_item, std::back_inserter( vars ),
1085  [&]( const auto& item ) { return this->fArray( item.first, len ); } );
1086  if ( std::any_of( vars.begin(), vars.end(), []( const FArray* f ) { return !f; } ) ) {
1088  }
1089 
1090  // fill the array
1091  for ( size_t index = 0; first != last; ++first, ++index ) {
1092  auto item = first_item;
1093  for ( auto& var : vars ) { ( *var )[index] = std::invoke( ( item++ )->second, *first ); }
1094  }
1095 
1096  return StatusCode::SUCCESS;
1097  }
1098 
1099  template <
1100  typename DataIterator, template <typename, typename...> class Container = std::initializer_list,
1101  typename NamedFunction = std::pair<std::string, std::function<float( detail::const_ref_t<DataIterator> )>>,
1102  typename = std::enable_if_t<!std::is_convertible_v<Container<NamedFunction>, std::string>>>
1103  StatusCode farray( const Container<NamedFunction>& funs, DataIterator first, DataIterator last,
1104  const std::string& length, size_t maxv ) {
1105  return farray_impl( funs.begin(), funs.end(), std::forward<DataIterator>( first ),
1106  std::forward<DataIterator>( last ), length, maxv );
1107  }
1108 
1109  template <typename NamedFunctions, typename DataIterator,
1110  typename = std::enable_if_t<!std::is_convertible_v<NamedFunctions, std::string>>>
1111  StatusCode farray( const NamedFunctions& funs, DataIterator first, DataIterator last, const std::string& length,
1112  size_t maxv ) {
1113  return farray_impl( funs.begin(), funs.end(), std::forward<DataIterator>( first ),
1114  std::forward<DataIterator>( last ), length, maxv );
1115  }
1116  // =======================================================================
1148  template <class FUNC1, class FUNC2, class Iterator>
1149  StatusCode farray( const std::string& name1, const FUNC1& func1, const std::string& name2, const FUNC2& func2,
1150  Iterator&& first, Iterator&& last, const std::string& length, size_t maxv ) {
1151  return farray( {{name1, std::cref( func1 )}, {name2, std::cref( func2 )}}, std::forward<Iterator>( first ),
1152  std::forward<Iterator>( last ), length, maxv );
1153  }
1154  // =======================================================================
1191  template <class FUNC1, class FUNC2, class FUNC3, class Iterator>
1192  StatusCode farray( const std::string& name1, const FUNC1& func1, const std::string& name2, const FUNC2& func2,
1193  const std::string& name3, const FUNC3& func3, Iterator&& first, Iterator&& last,
1194  const std::string& length, size_t maxv ) {
1195  return farray( {{name1, std::cref( func1 )}, {name2, std::cref( func2 )}, {name3, std::cref( func3 )}},
1196  std::forward<Iterator>( first ), std::forward<Iterator>( last ), length, maxv );
1197  }
1198  // =======================================================================
1238  template <class FUNC1, class FUNC2, class FUNC3, class FUNC4, class Iterator>
1239  StatusCode farray( const std::string& name1, const FUNC1& func1, const std::string& name2, const FUNC2& func2,
1240  const std::string& name3, const FUNC3& func3, const std::string& name4, const FUNC4& func4,
1241  Iterator&& first, Iterator&& last, const std::string& length, size_t maxv ) {
1242  return farray( {{name1, std::cref( func1 )},
1243  {name2, std::cref( func2 )},
1244  {name3, std::cref( func3 )},
1245  {name4, std::cref( func4 )}},
1246  std::forward<Iterator>( first ), std::forward<Iterator>( last ), length, maxv );
1247  }
1248  // =======================================================================
1249  public:
1250  // =======================================================================
1301  template <class MATRIX>
1302  StatusCode fmatrix( const std::string& name, const MATRIX& data, size_t rows, const MIndex& cols,
1303  const std::string& length, size_t maxv ) {
1304  if ( invalid() ) return ErrorCodes::InvalidTuple;
1305  if ( rowWise() ) return ErrorCodes::InvalidOperation;
1306 
1307  // adjust the length
1308  if ( rows >= maxv ) {
1309  Warning( "fmatrix('" + name + "'): matrix is overflow, skip extra items" ).ignore();
1310  rows = ( 0 < maxv ) ? ( maxv - 1 ) : 0;
1311  }
1312 
1313  // get the length item
1314  Int* len = ints( length, 0, maxv );
1315  if ( !len ) return ErrorCodes::InvalidColumn;
1316 
1317  // adjust the length item
1318  *len = rows;
1319 
1320  // get the array itself
1321  FMatrix* var = fMatrix( name, len, cols );
1322  if ( !var ) return ErrorCodes::InvalidColumn;
1323 
1325  for ( size_t iCol = 0; iCol < cols; ++iCol ) {
1326  for ( MIndex iRow = 0; iRow < rows; ++iRow ) { ( *var )[iRow][iCol] = data[iRow][iCol]; }
1327  }
1328 
1329  return StatusCode::SUCCESS;
1330  }
1331  // =======================================================================
1368  template <class DATA>
1369  StatusCode fmatrix( const std::string& name, DATA first, DATA last, const MIndex& cols, const std::string& length,
1370  size_t maxv ) {
1371  if ( invalid() ) return ErrorCodes::InvalidTuple;
1372  if ( rowWise() ) return ErrorCodes::InvalidOperation;
1373 
1374  // adjust the length
1375  if ( first + maxv < last ) {
1376  Warning( "fmatrix('" + name + "'): matrix is overflow, skip extra items" ).ignore();
1377  last = first + maxv;
1378  }
1379 
1380  // get the length item
1381  Int* len = ints( length, 0, maxv );
1382  if ( !len ) return ErrorCodes::InvalidColumn;
1383 
1384  // adjust the length item
1385  *len = last - first;
1386 
1387  // get the array itself
1388  FMatrix* var = fMatrix( name, len, cols );
1389  if ( !var ) return ErrorCodes::InvalidColumn;
1390 
1392  size_t iRow = 0;
1393  for ( ; first != last; ++first ) {
1394  //
1395  for ( MIndex iCol = 0; iCol < cols; ++iCol ) { ( *var )[iRow][iCol] = ( *first )[iCol]; }
1396  //
1397  ++iRow;
1398  }
1399 
1400  return StatusCode::SUCCESS;
1401  }
1402  // =======================================================================
1481  template <class FUN, class DATA>
1482  StatusCode fmatrix( const std::string& name, FUN funF, FUN funL, DATA first, DATA last, const std::string& length,
1483  size_t maxv ) {
1484  if ( invalid() ) return ErrorCodes::InvalidTuple;
1485  if ( rowWise() ) return ErrorCodes::InvalidOperation;
1486 
1487  // adjust the length
1488  if ( std::distance( first, last ) > static_cast<std::ptrdiff_t>( maxv ) ) {
1489  Warning( "fmatrix('" + name + "'): matrix is overflow, skip extra items" ).ignore();
1490  last = std::next( first, maxv );
1491  }
1492 
1493  // get the length item
1494  Int* len = ints( length, 0, maxv );
1495 
1496  if ( !len ) return ErrorCodes::InvalidColumn;
1497 
1498  // adjust the length item
1499  *len = std::distance( first, last );
1500 
1501  // get the array itself
1502  auto cols = std::distance( funF, funL );
1503  FMatrix* var = fMatrix( name, len, cols );
1504  if ( !var ) return ErrorCodes::InvalidColumn;
1505 
1507  size_t iRow = 0;
1508  for ( ; first != last; ++first ) {
1509  //
1510  for ( FUN fun = funF; fun < funL; ++fun ) { ( *var )[iRow][fun - funF] = std::invoke( *fun, *first ); }
1511  //
1512  ++iRow;
1513  }
1514 
1515  return StatusCode::SUCCESS;
1516  }
1517  // =======================================================================
1518  public:
1519  // =======================================================================
1542  template <class DATA>
1543  StatusCode array( const std::string& name, DATA first, DATA last )
1544 
1545  {
1546  if ( invalid() ) return ErrorCodes::InvalidTuple;
1547  if ( rowWise() ) return ErrorCodes::InvalidOperation;
1548 
1549  // get the length (fixed!)
1550  auto length = std::distance( first, last );
1551 
1552  // get the array itself
1553  FArray* var = fArray( name, length );
1554  if ( !var ) return ErrorCodes::InvalidColumn;
1555 
1557  std::copy( first, last, std::begin( *var ) );
1558 
1559  return StatusCode::SUCCESS;
1560  }
1561  // =======================================================================
1600  template <class ARRAY>
1601  StatusCode array( const std::string& name, const ARRAY& data, const MIndex& length ) {
1602  using std::begin; // allow data to be eg. CLHEP::HepVector (which does not define HepVector::begin()!,
1603  // in which case ADL prefers CLHEP::begin (yah! at least they (now) use a namespace)
1604  // so one just to insure double* CLHEP::begin(CLHEP::HepVector& v) { return &v[0]; }
1605  // is visible when this function gets instantiated for CLHEP::HepVector...
1606  auto first = begin( data );
1607  return array( name, first, std::next( first, length ) );
1608  }
1609  // =======================================================================
1640  template <class ARRAY>
1641  StatusCode array( const std::string& name, const ARRAY& data ) {
1642  using std::begin;
1643  using std::end;
1644  return array( name, begin( data ), end( data ) );
1645  }
1646  // =======================================================================
1647  public:
1648  // =======================================================================
1697  template <class MATRIX>
1698  StatusCode matrix( const std::string& name, const MATRIX& data, const MIndex& rows, const MIndex& cols ) {
1699  if ( invalid() ) return ErrorCodes::InvalidTuple;
1700  if ( rowWise() ) return ErrorCodes::InvalidOperation;
1701 
1702  // get the matrix itself
1703  FMatrix* var = fMatrix( name, rows, cols );
1704  if ( !var ) return ErrorCodes::InvalidColumn;
1705 
1707  for ( size_t iCol = 0; iCol < cols; ++iCol ) {
1708  for ( size_t iRow = 0; iRow < rows; ++iRow ) { ( *var )[iRow][iCol] = data[iRow][iCol]; }
1709  };
1710  return StatusCode::SUCCESS;
1711  }
1712  // =======================================================================
1713  public:
1714  // =======================================================================
1731  template <class TYPE>
1732  StatusCode column( const std::string& name, const ROOT::Math::LorentzVector<TYPE>& v ) {
1733  return columns( v, std::make_pair( name + "E", &ROOT::Math::LorentzVector<TYPE>::E ),
1734  std::make_pair( name + "X", &ROOT::Math::LorentzVector<TYPE>::Px ),
1735  std::make_pair( name + "Y", &ROOT::Math::LorentzVector<TYPE>::Py ),
1736  std::make_pair( name + "Z", &ROOT::Math::LorentzVector<TYPE>::Pz ) );
1737  }
1738  // =======================================================================
1755  template <class TYPE, class TAG>
1757  return this->columns( v, std::make_pair( name + "X", &ROOT::Math::DisplacementVector3D<TYPE, TAG>::X ),
1760  }
1761  // =======================================================================
1778  template <class TYPE, class TAG>
1780  return this->columns( v, std::make_pair( name + "X", &ROOT::Math::PositionVector3D<TYPE, TAG>::X ),
1783  }
1784  // =======================================================================
1793  template <class TYPE, unsigned int D1, unsigned int D2, class REP>
1794  StatusCode matrix( const std::string& name, const ROOT::Math::SMatrix<TYPE, D1, D2, REP>& mtrx ) {
1795  if ( invalid() ) return ErrorCodes::InvalidTuple;
1796  if ( rowWise() ) return ErrorCodes::InvalidOperation;
1797 
1798  // get the matrix itself
1799  FMatrix* var = fMatrix( name, (MIndex)D1, (MIndex)D2 );
1800  if ( !var ) return ErrorCodes::InvalidColumn;
1801 
1803  for ( size_t iCol = 0; iCol < D2; ++iCol ) {
1804  for ( size_t iRow = 0; iRow < D1; ++iRow ) { ( *var )[iRow][iCol] = mtrx( iRow, iCol ); }
1805  };
1806 
1807  return StatusCode::SUCCESS;
1808  }
1809  // =======================================================================
1827  template <class KEY, class VALUE>
1829  const std::string& length, const size_t maxv = 100 ) {
1830  using Info = std::pair<KEY, VALUE>;
1831  static const std::array<float ( * )( const Info& ), 2> fns = {
1832  {[]( const Info& i ) -> float { return i.first; }, []( const Info& i ) -> float { return i.second; }}};
1833  return fmatrix( name, begin( fns ), end( fns ), begin( info ), end( info ), length, maxv );
1834  }
1835  // =======================================================================
1836  public:
1837  // =======================================================================
1845  template <class TYPE>
1846  StatusCode put( const std::string& name, const TYPE* obj );
1847  // =======================================================================
1848  public:
1849  // =======================================================================
1853  StatusCode write();
1854  // =======================================================================
1856  const std::string& name() const { return m_name; }
1857  // =======================================================================
1861  const NTuple::Tuple* tuple() const { return m_tuple; }
1862  // =======================================================================
1866  NTuple::Tuple* tuple() { return m_tuple; }
1867  // =======================================================================
1869  const CLID& clid() const { return m_clid; }
1870  // =======================================================================
1872  Tuples::Type type() const { return m_type; }
1873  // =======================================================================
1875  bool columnWise() const { return CLID_ColumnWiseTuple == clid(); }
1876  // =======================================================================
1878  bool rowWise() const { return CLID_RowWiseTuple == clid(); }
1879  // =======================================================================
1881  bool evtColType() const { return Tuples::EVTCOL == type(); }
1882  // =======================================================================
1884  bool valid() const { return 0 != tuple(); }
1885  // =======================================================================
1887  bool invalid() const { return !valid(); }
1888  // =======================================================================
1889  public:
1890  // =======================================================================
1897  return m_items.emplace( std::move( name ), std::move( type ) ).second;
1898  }
1899  // =======================================================================
1904  bool goodItem( const std::string& name ) const { return m_items.end() == m_items.find( name ); }
1905  // =======================================================================
1907  const ItemMap& items() const { return m_items; }
1908  // =======================================================================
1909  public:
1910  // =======================================================================
1911  virtual StatusCode Error( const std::string& msg, const StatusCode sc = StatusCode::FAILURE ) const = 0;
1912  // =======================================================================
1913  virtual StatusCode Warning( const std::string& msg, const StatusCode sc = StatusCode::FAILURE ) const = 0;
1914  // =======================================================================
1915  private:
1916  // =======================================================================
1918  Int* ints( const std::string& name, int minv, int maxv );
1919  // =======================================================================
1921  FArray* fArray( const std::string& name, Int* item );
1922  // =======================================================================
1924  FArray* fArray( const std::string& name, const MIndex& rows );
1925  // =======================================================================
1927  Address* addresses( const std::string& name );
1928  // =======================================================================
1930  FMatrix* fMatrix( const std::string& name, Int* item, const MIndex& cols );
1931  // =======================================================================
1933  FMatrix* fMatrix( const std::string& name, const MIndex& rows, const MIndex& cols );
1934  // =======================================================================
1936  TupleObj( const TupleObj& ) = delete;
1937  TupleObj& operator=( const TupleObj& ) = delete;
1938  // =======================================================================
1939  private:
1940  // =======================================================================
1943  // =======================================================================
1946  // =======================================================================
1949  // =======================================================================
1952  // =======================================================================
1954  size_t m_refCount = 0;
1955  // =======================================================================
1956  // helper type to define the actual storage types
1957  template <typename T>
1959  // =======================================================================
1962  // =======================================================================
1965  // =======================================================================
1968  // =======================================================================
1971  // =======================================================================
1974  // =======================================================================
1977  // =======================================================================
1980  // =======================================================================
1983  // =======================================================================
1986  // =======================================================================
1989  // =======================================================================
1992  // =======================================================================
1995  // =======================================================================
1998  // =======================================================================
2001  // =======================================================================
2004  // =======================================================================
2007  // =======================================================================
2010  // =======================================================================
2011  };
2012  // ==========================================================================
2013 } // end of namespace Tuples
2014 
2015 // ============================================================================
2016 // GaudiAlg
2017 // ============================================================================
2018 #include "GaudiAlg/TuplePut.h"
2019 // ============================================================================
2020 // The END
2021 // ============================================================================
2022 #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:1756
ColumnStorage< FArray > m_arraysf
the actual storage of all 'FArray' columns (fixed)
Definition: TupleObj.h:2000
Out1 * put(const DataObjectHandle< Out1 > &out_handle, Out2 &&out)
A bit modified version of 'Loki::AssocVector' associative vector from Loki library by Andrei Alexandr...
Definition: VectorMap.h:112
CLID m_clid
tuple CLID
Definition: TupleObj.h:1948
ColumnStorage< Float > m_floats
the actual storage of all 'Float' columns
Definition: TupleObj.h:1988
ColumnStorage< Address > m_addresses
the actual storage of all 'Address' columns
Definition: TupleObj.h:1994
std::map< std::string, std::string > ItemMap
Definition: TupleObj.h:258
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:1698
T distance(T... args)
GAUDI_API std::string format(const char *,...)
MsgStream format utility "a la sprintf(...)".
Definition: MsgStream.cpp:119
NTuple::Item< float > Float
basic type for float items
Definition: TupleObj.h:240
ColumnStorage< Bool > m_bools
the actual storage of all 'bool' columns
Definition: TupleObj.h:1961
Tuples::Type m_type
tuple 'type'
Definition: TupleObj.h:1951
Class acting as a smart pointer holding a N tuple _Item.
Definition: NTuple.h:62
NTuple::Item< IOpaqueAddress * > Address
basic type for address items
Definition: TupleObj.h:246
ErrorCodes
Tuple error codes.
Definition: TupleObj.h:101
constexpr static const auto SUCCESS
Definition: StatusCode.h:96
const CLID & clid() const
accessor to the N-Tuple CLID
Definition: TupleObj.h:1869
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:45
NTuple::Item< unsigned long long > ULongLong
basic type for unsigned long long items
Definition: TupleObj.h:237
NTuple::Item< unsigned short > UShort
basic type for unsigned int items
Definition: TupleObj.h:225
bool invalid() const
invalid pointer to tuple ?
Definition: TupleObj.h:1887
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:1302
unsigned short MIndex
Definition: TupleObj.h:255
ColumnStorage< LongLong > m_longlongs
the actual storage of all 'long long' columns
Definition: TupleObj.h:1982
ColumnStorage< UShort > m_ushorts
the actual storage of all 'unsigned int' columns
Definition: TupleObj.h:1973
Tuples::Type type() const
accessor to the N-Tuple type
Definition: TupleObj.h:1872
std::string m_name
name
Definition: TupleObj.h:1942
bool evtColType() const
Event collection ?
Definition: TupleObj.h:1881
NTuple::Tuple * tuple()
provide the access to underlying Gaudi N-tuple
Definition: TupleObj.h:1866
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:886
NTuple::Item< unsigned char > UChar
basic type for unsigned int items
Definition: TupleObj.h:219
Provide serialization function (output only) for some common STL classes (vectors,...
ColumnStorage< UInt > m_uints
the actual storage of all 'unsigned int' columns
Definition: TupleObj.h:1979
constexpr double second
STL class.
NTuple::Item< short > Short
basic type for int items
Definition: TupleObj.h:222
bool addItem(std::string name, std::string type)
add the item name into the list of known items
Definition: TupleObj.h:1896
ColumnStorage< Double > m_doubles
the actual storage of all 'Double' columns
Definition: TupleObj.h:1991
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:1482
ColumnStorage< FMatrix > m_fmatrices
the actual storage of all 'FArray' columns
Definition: TupleObj.h:2003
constexpr to_< float > to_float
Definition: TupleObj.h:78
ColumnStorage< ULongLong > m_ulonglongs
the actual storage of all 'unsigned long long' columns
Definition: TupleObj.h:1985
#define STATUSCODE_ENUM_DECL(ENUM)
Declare an enum to be used as StatusCode value.
Definition: StatusCode.h:333
TupleObj.h GaudiAlg/TupleObj.h namespace with few technical implementations.
A simple wrapper class over standard Gaudi NTuple::Tuple facility.
Definition: TupleObj.h:209
T next(T... args)
StatusCode array(const std::string &name, const ARRAY &data)
fill N-Tuple with fixed-size array
Definition: TupleObj.h:1641
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:61
ColumnStorage< Char > m_chars
the actual storage of all 'Int' columns
Definition: TupleObj.h:1964
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:1192
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:935
NTuple::Matrix< float > FMatrix
basic type for matrix of floats
Definition: TupleObj.h:252
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:1794
ColumnStorage< Short > m_shorts
the actual storage of all 'Int' columns
Definition: TupleObj.h:1970
T make_pair(T... args)
ItemMap m_items
all booked types:
Definition: TupleObj.h:2009
NTuple::Item< bool > Bool
basic type for int items
Definition: TupleObj.h:213
NTuple::Item< double > Double
basic type for double items
Definition: TupleObj.h:243
ColumnStorage< Int > m_ints
the actual storage of all 'Int' columns
Definition: TupleObj.h:1976
const NTuple::Tuple * tuple() const
provide the access to underlying Gaudi N-tuple
Definition: TupleObj.h:1861
def end
Definition: IOTest.py:123
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:1149
Specialization acting as a smart pointer holding a N tuple _Item.
Definition: NTuple.h:305
unsigned int CLID
Class ID definition.
Definition: ClassID.h:18
bool columnWise() const
column wise NTuple ?
Definition: TupleObj.h:1875
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:1059
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:1369
Stream & ostream_joiner(Stream &os, Iterator first, Iterator last, Separator sep, OutputElement output=OutputElement{})
Definition: SerializeSTL.h:47
Abstract base class which allows the user to interact with the actual N tuple implementation.
Definition: NTuple.h:385
StatusCode column(const std::string &name, signed char value)
Set the value for the selected tuple column.
Definition: TupleObj.h:713
NTuple::Item< long long > LongLong
basic type for unsigned long long items
Definition: TupleObj.h:234
const std::string & name() const
get the name
Definition: TupleObj.h:1856
StatusCode farray(const NamedFunctions &funs, DataIterator first, DataIterator last, const std::string &length, size_t maxv)
Definition: TupleObj.h:1111
const StatusCode & ignore() const
Ignore/check StatusCode.
Definition: StatusCode.h:164
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:1239
StatusCode array(const std::string &name, DATA first, DATA last)
fill N-Tuple with fixed-size array
Definition: TupleObj.h:1543
struct GAUDI_API array
Parametrisation class for redirection array - like implementation.
STL class.
NTuple::Tuple * m_tuple
tuple itself
Definition: TupleObj.h:1945
const ItemMap & items() const
get the full list of booked items
Definition: TupleObj.h:1907
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:1828
T cref(T... args)
boost::spirit::classic::position_iterator2< ForwardIterator > Iterator
Definition: Iterator.h:28
bool rowWise() const
row wise NTuple ?
Definition: TupleObj.h:1878
T begin(T... args)
ColumnStorage< FMatrix > m_matricesf
the actual storage of all 'FMatrix' columns (fixed)
Definition: TupleObj.h:2006
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)
StatusCode farray(const Container< NamedFunction > &funs, DataIterator first, DataIterator last, const std::string &length, size_t maxv)
Definition: TupleObj.h:1103
NTuple::Item< char > Char
basic type for int items
Definition: TupleObj.h:216
std::add_const_t< typename std::iterator_traits< Iterator >::reference > const_ref_t
Definition: TupleObj.h:81
Common class providing an architecture-independent hash map.
Definition: HashMap.h:83
STL class.
NTuple::Item< int > Int
basic type for int items
Definition: TupleObj.h:228
constexpr static const auto FAILURE
Definition: StatusCode.h:97
StatusCode column(const std::string &name, const ROOT::Math::LorentzVector< TYPE > &v)
Useful shortcut to put LorentzVector directly into N-Tuple:
Definition: TupleObj.h:1732
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:797
bool valid() const
valid pointer to tuple ?
Definition: TupleObj.h:1884
T transform(T... args)
NTuple::Array< float > FArray
basic type for array of floats
Definition: TupleObj.h:249
bool isFailure() const
Definition: StatusCode.h:141
AttribStringParser::Iterator begin(const AttribStringParser &parser)
T accumulate(T... args)
Implementation file for Tuple::TupleObj::put method.
Opaque address interface definition.
Class acting as a smart pointer holding a N tuple _Item.
Definition: NTuple.h:58
StatusCode array(const std::string &name, const ARRAY &data, const MIndex &length)
fill N-Tuple with fixed-size array
Definition: TupleObj.h:1601
Class acting as a smart pointer holding a N tuple _Item.
Definition: NTuple.h:60
#define GAUDI_API
Definition: Kernel.h:81
Type
the list of available types for ntuples
Definition: TupleObj.h:89
STL class.
bool goodItem(const std::string &name) const
check the uniqueness of the name
Definition: TupleObj.h:1904
NTuple::Item< unsigned int > UInt
basic type for unsigned int items
Definition: TupleObj.h:231
T forward(T... args)
ColumnStorage< UChar > m_uchars
the actual storage of all 'unsigned int' columns
Definition: TupleObj.h:1967
T operator()(Arg &&i) const
Definition: TupleObj.h:74
T reserve(T... args)
unsigned long code_t
type of StatusCode value
Definition: StatusCode.h:63
ColumnStorage< FArray > m_farrays
the actual storage of all 'FArray' columns
Definition: TupleObj.h:1997
General namespace for Tuple properties.
Definition: Maps.h:43
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:1779