The Gaudi Framework  v28r3 (cc1cf868)
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 <cstddef>
10 #include <set>
11 #include <string>
12 #include <limits>
13 #include <array>
14 #include <functional>
15 #include <numeric>
16 #include <sstream>
17 // ============================================================================
18 // GaudiKernel
19 // ============================================================================
20 #include "GaudiKernel/NTuple.h"
21 #include "GaudiKernel/VectorMap.h"
23 #include "GaudiKernel/invoke.h"
24 // ============================================================================
25 // GaudiAlg
26 // ============================================================================
27 #include "GaudiAlg/Tuples.h"
28 #include "GaudiAlg/Maps.h"
29 // ============================================================================
30 // ROOT
31 // ============================================================================
32 #include "Math/Point3D.h"
33 #include "Math/Vector3D.h"
34 #include "Math/Vector4D.h"
35 #include "Math/SVector.h"
36 #include "Math/SMatrix.h"
37 // ============================================================================
38 // forward declaration
39 // ============================================================================
40 // GaudiKernel
41 // ============================================================================
42 class IOpaqueAddress ;
43 // ============================================================================
52 // ============================================================================
60 namespace Tuples
61 {
62  namespace detail {
63  template <typename T> struct to_ {
64  template <typename Arg>
65  T operator()(Arg&& i) const
66  { return T(std::forward<Arg>(i)); }
67  };
68  constexpr struct to_<float> to_float {};
69 
70  template <typename Iterator>
72 
73  }
74  // ==========================================================================
80  enum Type
81  {
82  NTUPLE , // Analysis nTuple
83  EVTCOL // Event Collection
84  };
85  // ==========================================================================
94  {
95  InvalidTuple = 100 ,
101  };
102  // ==========================================================================
198  {
199  public:
200  // ========================================================================
203  // ========================================================================
206  // ========================================================================
209  // ========================================================================
212  // ========================================================================
215  // ========================================================================
218  // ========================================================================
221  // ========================================================================
224  // ========================================================================
227  // ========================================================================
230  // ========================================================================
233  // ========================================================================
236  // ========================================================================
239  // ========================================================================
242  // ========================================================================
243  // the actual type for variable size matrix indices
244  typedef unsigned short MIndex ;
245  // ========================================================================
246  // the map of all items
248  // ========================================================================
249  protected:
250  // ========================================================================
259  NTuple::Tuple* tuple ,
260  const CLID& clid = CLID_ColumnWiseTuple ,
261  const Tuples::Type type = Tuples::NTUPLE ) ;
262  // ========================================================================
263  protected:
264  // ========================================================================
266  virtual ~TupleObj();
267  // ========================================================================
268  public:
269  // ========================================================================
285  StatusCode column ( const std::string& name , float value );
286  // ========================================================================
287  public:
288  // ========================================================================
305  StatusCode column ( const std::string& name , double value );
306  // ========================================================================
307  public:
308  // ========================================================================
324  StatusCode column ( const std::string& name , short value );
325  // ========================================================================
343  StatusCode column ( const std::string& name ,
344  short value ,
345  short minv ,
346  short maxv );
347  // ========================================================================
348  public:
349  // ========================================================================
365  StatusCode column ( const std::string& name , unsigned short value );
366  // ========================================================================
384  StatusCode column ( const std::string& name ,
385  unsigned short value ,
386  unsigned short minv ,
387  unsigned short maxv );
388  // ========================================================================
389  public:
390  // ========================================================================
406  StatusCode column ( const std::string& name , char value );
407  // ========================================================================
425  StatusCode column ( const std::string& name ,
426  char value ,
427  char minv ,
428  char maxv );
429  // ========================================================================
430  public:
431  // ========================================================================
447  StatusCode column ( const std::string& name , unsigned char value );
448  // ========================================================================
466  StatusCode column ( const std::string& name ,
467  unsigned char value ,
468  unsigned char minv ,
469  unsigned char maxv );
470  // ========================================================================
471  public:
472  // ========================================================================
488  StatusCode column ( const std::string& name , int value );
489  // ========================================================================
507  StatusCode column ( const std::string& name ,
508  int value ,
509  int minv ,
510  int maxv );
511  // ========================================================================
512  public:
513  // ========================================================================
529  StatusCode column ( const std::string& name , unsigned int value );
530  // ========================================================================
548  StatusCode column ( const std::string& name ,
549  unsigned int value ,
550  unsigned int minv ,
551  unsigned int maxv );
552  // ========================================================================
553  public:
554  // ========================================================================
571  StatusCode column ( const std::string& name , long value );
572  // ========================================================================
590  StatusCode column ( const std::string& name ,
591  long value ,
592  long minv ,
593  long maxv );
594  // ========================================================================
595  public:
596  // ========================================================================
613  StatusCode column ( const std::string& name , unsigned long value );
614  // ========================================================================
632  StatusCode column ( const std::string& name ,
633  unsigned long value ,
634  unsigned long minv ,
635  unsigned long maxv );
636  // ========================================================================
637  public:
638  // ========================================================================
654  StatusCode column ( const std::string& name , long long value );
655  // ========================================================================
673  StatusCode column ( const std::string& name ,
674  long long value ,
675  long long minv ,
676  long long maxv );
677  // ========================================================================
678  public:
679  // ========================================================================
695  StatusCode column ( const std::string& name , unsigned long long value );
696  // ========================================================================
714  StatusCode column ( const std::string& name ,
715  unsigned long long value ,
716  unsigned long long minv ,
717  unsigned long long maxv );
718  // ========================================================================
719  public:
720  // ========================================================================
736  StatusCode column ( const std::string& name, signed char value )
737  {
738  return column ( name , value ,
741  }
742  // ========================================================================
743  public:
744  // ========================================================================
759  StatusCode column ( const std::string& name ,
760  bool value );
761  // ========================================================================
762  public:
763  // ========================================================================
782  StatusCode column ( const std::string& name ,
783  IOpaqueAddress* address ) ;
784  // ========================================================================
801  StatusCode column ( IOpaqueAddress* address ) ;
802  // ========================================================================
803  public:
804  // ========================================================================
823 private:
824  template <typename Tuple, typename Value, std::size_t... I>
825  StatusCode columns_helper( const Value& value, const Tuple& tup, std::index_sequence<I...>) {
827  this->column(std::get<I>(tup).first, Gaudi::invoke(std::get<I>(tup).second,value))...
828  };
829  auto is_ok = [](const StatusCode& sc) -> bool { return sc; };
830  auto i = std::find_if_not(begin(scs), end(scs), is_ok );
831  if (i!=end(scs)) {
832  // avoid unchecked StatusCodes...
833  std::for_each(std::next(i),end(scs),is_ok);
834  return *i;
835  }
836  return StatusCode::SUCCESS;
837  }
838 
839 public:
840  template <typename Value, typename... Args>
841  StatusCode columns(Value&& value, Args&&... args ) {
842  return columns_helper(std::forward<Value>(value),
843  std::forward_as_tuple(std::forward<Args>(args)...),
844  std::index_sequence_for<Args...>{});
845  }
846  // ========================================================================
847  public:
848  // ========================================================================
872  StatusCode fill( const char* format ... ) ;
873  // =======================================================================
874  public:
875  // =======================================================================
924  template <typename ITERATOR1,typename ITERATOR2>
925  StatusCode farray ( const std::string& name ,
926  ITERATOR1&& first ,
927  ITERATOR2&& last ,
928  const std::string& length ,
929  size_t maxv )
930  {
931  return farray( name, detail::to_float,
932  std::forward<ITERATOR1>(first), std::forward<ITERATOR2>(last),
933  length, maxv );
934  }
935  // =======================================================================
978  template <class DATA>
979  StatusCode farray ( const std::string& name ,
980  const DATA& data ,
981  const std::string& length ,
982  const size_t maxv )
983  { return farray ( name , std::begin(data) , std::end(data) , length , maxv ) ; }
984  // =======================================================================
1047  template <class FUNCTION, class ITERATOR>
1049  const FUNCTION& function ,
1050  ITERATOR first ,
1051  ITERATOR last ,
1052  const std::string& length ,
1053  size_t maxv )
1054  {
1055  if ( invalid () ) { return InvalidTuple ; }
1056  if ( rowWise () ) { return InvalidOperation ; }
1057 
1058  // adjust the length
1059  if( std::distance(first,last) > static_cast<std::ptrdiff_t>(maxv) ) {
1060  Warning("farray('"
1061  + name + "'): array is overflow, skip extra entries") ;
1062  last = std::next(first,maxv);
1063  }
1064 
1065  // get the length item
1066  Int* len = ints( length , 0 , maxv ) ;
1067  if( !len ) { return InvalidColumn ; }
1068 
1069  // adjust the length
1070  *len = std::distance(first,last);
1071 
1072  // get the array itself
1073  FArray* var = fArray ( name , len ) ;
1074  if( !var ) { return InvalidColumn ; }
1075 
1076  // fill the array
1077  std::transform( first, last, std::begin(*var), std::cref(function) );
1078 
1079  return StatusCode::SUCCESS ;
1080  }
1081  // =======================================================================
1108  template <typename Iterator, template <typename,typename...> class Container = std::initializer_list,
1110  typename Item = std::pair<std::string,Fun>,
1111  typename = std::enable_if_t<!std::is_same<std::string,Container<Item>>::value >>
1112  StatusCode farray ( const Container<Item>& items ,
1113  Iterator first ,
1114  Iterator last ,
1115  const std::string& length,
1116  size_t maxv )
1117  {
1118  if ( invalid () ) { return InvalidTuple ; }
1119  if ( rowWise () ) { return InvalidOperation ; }
1120 
1121  // adjust the lenfth
1122  if( std::distance(first,last) > static_cast<std::ptrdiff_t>(maxv) ) {
1124  std::ostringstream os;
1125  ostream_joiner( os, items, ",",
1126  [](std::ostream& os, const auto& i) -> std::ostream&
1127  { return os << i.first; } );
1128  Warning( "farray('" + os.str()
1129  + "'): array overflow, skipping extra entries").ignore() ;
1130  last = std::next(first, maxv) ;
1131  }
1132 
1133  // get the length item
1134  Int* len = ints ( length , 0 , maxv ) ;
1135  if ( !len ) { return InvalidColumn ; }
1136 
1137  // adjust the length
1138  *len = std::distance(first,last);
1139 
1140  // get the arrays themselves
1141  std::vector<FArray*> vars; vars.reserve(items.size());
1142  std::transform( items.begin(), items.end(), std::back_inserter(vars),
1143  [&](const auto& item) { return this->fArray(item.first,len); } );
1144  if ( std::any_of( vars.begin(), vars.end(), [](const FArray* f) { return !f; } ) ) {
1145  return InvalidColumn ;
1146  }
1147 
1148  // fill the array
1149  for(size_t index = 0; first != last; ++first,++index ) {
1150  auto item = items.begin();
1151  for( auto& var : vars ) {
1152  (*var)[index] = (item++)->second(*first);
1153  }
1154  }
1155 
1156  return StatusCode::SUCCESS ;
1157  }
1158  // =======================================================================
1190  template <class FUNC1, class FUNC2, class Iterator>
1191  StatusCode farray ( const std::string& name1 ,
1192  const FUNC1& func1 ,
1193  const std::string& name2 ,
1194  const FUNC2& func2 ,
1195  Iterator&& first ,
1196  Iterator&& last ,
1197  const std::string& length ,
1198  size_t maxv )
1199  {
1200  return farray( { { name1, std::cref(func1) },
1201  { name2, std::cref(func2) } },
1202  std::forward<Iterator>(first), std::forward<Iterator>(last),
1203  length, maxv );
1204  }
1205  // =======================================================================
1242  template <class FUNC1, class FUNC2, class FUNC3, class Iterator>
1243  StatusCode farray ( const std::string& name1 ,
1244  const FUNC1& func1 ,
1245  const std::string& name2 ,
1246  const FUNC2& func2 ,
1247  const std::string& name3 ,
1248  const FUNC3& func3 ,
1249  Iterator&& first ,
1250  Iterator&& last ,
1251  const std::string& length ,
1252  size_t maxv )
1253  {
1254  return farray( {{name1,std::cref(func1)},
1255  {name2,std::cref(func2)},
1256  {name3,std::cref(func3)}},
1257  std::forward<Iterator>(first), std::forward<Iterator>(last),
1258  length, maxv );
1259  }
1260  // =======================================================================
1300  template <class FUNC1, class FUNC2, class FUNC3, class FUNC4, class Iterator>
1301  StatusCode farray ( const std::string& name1 ,
1302  const FUNC1& func1 ,
1303  const std::string& name2 ,
1304  const FUNC2& func2 ,
1305  const std::string& name3 ,
1306  const FUNC3& func3 ,
1307  const std::string& name4 ,
1308  const FUNC4& func4 ,
1309  Iterator&& first ,
1310  Iterator&& last ,
1311  const std::string& length ,
1312  size_t maxv )
1313  {
1314  return farray( {{name1,std::cref(func1)},
1315  {name2,std::cref(func2)},
1316  {name3,std::cref(func3)},
1317  {name4,std::cref(func4)}},
1318  std::forward<Iterator>(first), std::forward<Iterator>(last),
1319  length, maxv );
1320  }
1321  // =======================================================================
1322  public:
1323  // =======================================================================
1374  template <class MATRIX>
1376  const MATRIX& data ,
1377  size_t rows ,
1378  const MIndex& cols ,
1379  const std::string& length ,
1380  size_t maxv )
1381  {
1382  if ( invalid () ) { return InvalidTuple ; }
1383  if ( rowWise () ) { return InvalidOperation ; }
1384 
1385  // adjust the length
1386  if ( rows >= maxv )
1387  {
1388  Warning ( "fmatrix('"+name+"'): matrix is overflow, skip extra items").ignore() ;
1389  rows = ( 0 < maxv ) ? ( maxv - 1 ) : 0 ;
1390  }
1391 
1392  // get the length item
1393  Int* len = ints( length , 0 , maxv ) ;
1394  if ( !len ) { return InvalidColumn; }
1395 
1396  // adjust the length item
1397  *len = rows ;
1398 
1399  // get the array itself
1400  FMatrix* var = fMatrix ( name , len , cols ) ;
1401  if ( !var ) { return InvalidColumn ; }
1402 
1404  for ( size_t iCol = 0 ; iCol < cols ; ++iCol )
1405  {
1406  for ( MIndex iRow = 0 ; iRow < rows ; ++iRow )
1407  { (*var)[ iRow ] [ iCol ] = data[ iRow ][ iCol ] ; }
1408  }
1409 
1410  return StatusCode::SUCCESS ;
1411  }
1412  // =======================================================================
1449  template <class DATA>
1451  DATA first ,
1452  DATA last ,
1453  const MIndex& cols ,
1454  const std::string& length ,
1455  size_t maxv )
1456  {
1457  if ( invalid () ) { return InvalidTuple ; }
1458  if ( rowWise () ) { return InvalidOperation ; }
1459 
1460  // adjust the length
1461  if ( first + maxv < last )
1462  {
1463  Warning("fmatrix('"+name+"'): matrix is overflow, skip extra items").ignore() ;
1464  last = first + maxv ;
1465  }
1466 
1467  // get the length item
1468  Int* len = ints( length , 0 , maxv ) ;
1469  if ( !len ) { return InvalidColumn; }
1470 
1471  // adjust the length item
1472  *len = last - first ;
1473 
1474  // get the array itself
1475  FMatrix* var = fMatrix ( name , len , cols ) ;
1476  if ( !var ) { return InvalidColumn ; }
1477 
1479  size_t iRow = 0 ;
1480  for ( ; first != last ; ++first )
1481  {
1482  //
1483  for ( MIndex iCol = 0 ; iCol < cols ; ++iCol )
1484  { (*var)[ iRow ] [ iCol ] = (float)((*first)[ iCol ]) ; }
1485  //
1486  ++iRow ;
1487  }
1488 
1489  return StatusCode::SUCCESS ;
1490  }
1491  // =======================================================================
1570  template <class FUN,class DATA>
1572  FUN funF ,
1573  FUN funL ,
1574  DATA first ,
1575  DATA last ,
1576  const std::string& length ,
1577  size_t maxv )
1578  {
1579  if ( invalid () ) { return InvalidTuple ; }
1580  if ( rowWise () ) { return InvalidOperation ; }
1581 
1582  // adjust the length
1583  if ( std::distance(first,last) > static_cast<std::ptrdiff_t>(maxv) )
1584  {
1585  Warning("fmatrix('"+name+"'): matrix is overflow, skip extra items").ignore() ;
1586  last = std::next(first, maxv) ;
1587  }
1588 
1589  // get the length item
1590  Int* len = ints( length , 0 , maxv ) ;
1591  if ( !len ) { return InvalidColumn; }
1592 
1593  // adjust the length item
1594  *len = std::distance(first,last);
1595 
1596  // get the array itself
1597  auto cols = std::distance(funF,funL);
1598  FMatrix* var = fMatrix ( name , len , cols ) ;
1599  if ( !var ) { return InvalidColumn ; }
1600 
1602  size_t iRow = 0 ;
1603  for ( ; first != last ; ++first )
1604  {
1605  //
1606  for ( FUN fun = funF ; fun < funL ; ++fun )
1607  { (*var)[ iRow ] [ fun - funF ] = (*fun) ( *first ) ; }
1608  //
1609  ++iRow;
1610  }
1611 
1612  return StatusCode::SUCCESS ;
1613  }
1614  // =======================================================================
1615  public:
1616  // =======================================================================
1639  template <class DATA>
1640  StatusCode array ( const std::string& name ,
1641  DATA first ,
1642  DATA last )
1643 
1644  {
1645  if ( invalid () ) { return InvalidTuple ; }
1646  if ( rowWise () ) { return InvalidOperation ; }
1647 
1648  // get the length (fixed!)
1649  auto length = std::distance(first,last);
1650 
1651  // get the array itself
1652  FArray* var = fArray ( name , length ) ;
1653  if ( !var ) { return InvalidColumn ; }
1654 
1656  std::copy( first, last, std::begin(*var) );
1657 
1658  return StatusCode::SUCCESS ;
1659  }
1660  // =======================================================================
1699  template <class ARRAY>
1700  StatusCode array ( const std::string& name ,
1701  const ARRAY& data ,
1702  const MIndex& length )
1703  {
1704  using std::begin; // allow data to be eg. CLHEP::HepVector (which does not define HepVector::begin()!,
1705  // in which case ADL prefers CLHEP::begin (yah! at least they (now) use a namespace)
1706  // so one just to insure double* CLHEP::begin(CLHEP::HepVector& v) { return &v[0]; }
1707  // is visible when this function gets instantiated for CLHEP::HepVector...
1708  auto first = begin(data);
1709  return array( name, first, std::next( first, length ) );
1710  }
1711  // =======================================================================
1742  template <class ARRAY>
1743  StatusCode array ( const std::string& name ,
1744  const ARRAY& data )
1745  {
1746  using std::begin; using std::end;
1747  return array ( name , begin(data) , end(data) ) ;
1748  }
1749  // =======================================================================
1750  public:
1751  // =======================================================================
1800  template <class MATRIX>
1802  const MATRIX& data ,
1803  const MIndex& rows ,
1804  const MIndex& cols )
1805  {
1806  if ( invalid () ) { return InvalidTuple ; }
1807  if ( rowWise () ) { return InvalidOperation ; }
1808 
1809  // get the matrix itself
1810  FMatrix* var = fMatrix ( name , rows , cols ) ;
1811  if ( !var ) { return InvalidColumn ; }
1812 
1814  for ( size_t iCol = 0 ; iCol < cols ; ++iCol )
1815  {
1816  for ( size_t iRow = 0 ; iRow < rows ; ++iRow )
1817  { (*var)[iRow][iCol] = data[iRow][iCol]; }
1818  };
1819  return StatusCode::SUCCESS ;
1820  }
1821  // =======================================================================
1822  public:
1823  // =======================================================================
1840  template <class TYPE>
1841  StatusCode column ( const std::string& name , const ROOT::Math::LorentzVector<TYPE>& v )
1842  {
1843  return columns( v, std::make_pair( name + "E", &ROOT::Math::LorentzVector<TYPE>::E ),
1844  std::make_pair( name + "X", &ROOT::Math::LorentzVector<TYPE>::Px),
1845  std::make_pair( name + "Y", &ROOT::Math::LorentzVector<TYPE>::Py),
1846  std::make_pair( name + "Z", &ROOT::Math::LorentzVector<TYPE>::Pz) );
1847  }
1848  // =======================================================================
1865  template <class TYPE,class TAG>
1868  {
1869  return this->columns( v, std::make_pair( name + "X", &ROOT::Math::DisplacementVector3D<TYPE,TAG>::X ),
1872  }
1873  // =======================================================================
1890  template <class TYPE,class TAG>
1892  ( const std::string& name ,
1894  {
1895  return this->columns( v,
1899  }
1900  // =======================================================================
1909  template <class TYPE,unsigned int D1,unsigned int D2,class REP>
1911  ( const std::string& name ,
1912  const ROOT::Math::SMatrix<TYPE,D1,D2,REP>& mtrx )
1913  {
1914  if ( invalid () ) { return InvalidTuple ; }
1915  if ( rowWise () ) { return InvalidOperation ; }
1916 
1917  // get the matrix itself
1918  FMatrix* var = fMatrix ( name , (MIndex)D1 , (MIndex)D2 ) ;
1919  if ( !var ) { return InvalidColumn ; }
1920 
1922  for ( size_t iCol = 0 ; iCol < D2 ; ++iCol )
1923  {
1924  for ( size_t iRow = 0 ; iRow < D1 ; ++iRow )
1925  { (*var)[iRow][iCol] = mtrx(iRow,iCol) ; }
1926  };
1927 
1928  return StatusCode::SUCCESS ;
1929  }
1930  // =======================================================================
1948  template <class KEY, class VALUE>
1950  ( const std::string& name ,
1951  const GaudiUtils::VectorMap<KEY,VALUE>& info ,
1952  const std::string& length ,
1953  const size_t maxv = 100 )
1954  {
1955  using Info = std::pair<KEY,VALUE>;
1957  fns = { { [](const Info& i) { return i.first; } ,
1958  [](const Info& i) { return i.second; } } };
1959  return fmatrix( name,
1960  std::begin(fns), std::end(fns),
1961  std::begin(info), std::end(info),
1962  length,maxv );
1963  }
1964  // =======================================================================
1965  public:
1966  // =======================================================================
1974  template <class TYPE>
1975  StatusCode put
1976  ( const std::string& name , const TYPE* obj ) ;
1977  // =======================================================================
1978  public:
1979  // =======================================================================
1983  StatusCode write () ;
1984  // =======================================================================
1986  const std::string& name() const { return m_name ; }
1987  // =======================================================================
1991  const NTuple::Tuple* tuple() const { return m_tuple ; }
1992  // =======================================================================
1996  NTuple::Tuple* tuple() { return m_tuple ; }
1997  // =======================================================================
2001  unsigned long refCount() const { return m_refCount ; }
2002  // =======================================================================
2006  unsigned long addRef () { return ++m_refCount ; }
2007  // =======================================================================
2012  void release () ;
2013  // =======================================================================
2015  const CLID& clid() const { return m_clid ; }
2016  // =======================================================================
2018  Tuples::Type type() const { return m_type ; }
2019  // =======================================================================
2021  bool columnWise() const { return CLID_ColumnWiseTuple == clid() ; }
2022  // =======================================================================
2024  bool rowWise () const { return CLID_RowWiseTuple == clid() ; }
2025  // =======================================================================
2027  bool evtColType() const { return Tuples::EVTCOL == type() ; }
2028  // =======================================================================
2030  bool valid () const { return 0 != tuple() ; }
2031  // =======================================================================
2033  bool invalid () const { return ! valid() ; }
2034  // =======================================================================
2035  public:
2036  // =======================================================================
2042  bool addItem ( std::string name ,
2043  std::string type )
2044  { return m_items.emplace ( std::move(name) , std::move(type) ).second ; }
2045  // =======================================================================
2050  bool goodItem ( const std::string& name ) const
2051  { return m_items.end() == m_items.find ( name ) ; }
2052  // =======================================================================
2054  const ItemMap& items() const { return m_items ; }
2055  // =======================================================================
2056  public:
2057  // =======================================================================
2058  virtual StatusCode Error
2059  ( const std::string& msg ,
2060  const StatusCode sc = StatusCode::FAILURE ) const = 0 ;
2061  // =======================================================================
2062  virtual StatusCode Warning
2063  ( const std::string& msg ,
2064  const StatusCode sc = StatusCode::FAILURE ) const = 0 ;
2065  // =======================================================================
2066  private:
2067  // =======================================================================
2069  Int* ints ( const std::string& name ,
2070  int minv ,
2071  int maxv ) ;
2072  // =======================================================================
2074  FArray* fArray ( const std::string& name ,
2075  Int* item ) ;
2076  // =======================================================================
2078  FArray* fArray ( const std::string& name ,
2079  const MIndex& rows ) ;
2080  // =======================================================================
2082  Address* addresses ( const std::string& name ) ;
2083  // =======================================================================
2085  FMatrix* fMatrix ( const std::string& name ,
2086  Int* item ,
2087  const MIndex& cols ) ;
2088  // =======================================================================
2090  FMatrix* fMatrix ( const std::string& name ,
2091  const MIndex& rows ,
2092  const MIndex& cols ) ;
2093  // =======================================================================
2094  private:
2095  // =======================================================================
2097  TupleObj () = delete;
2098  TupleObj ( const TupleObj& ) = delete;
2099  TupleObj& operator= ( const TupleObj& ) = delete;
2100  // =======================================================================
2101  private:
2102  // =======================================================================
2105  // =======================================================================
2108  // =======================================================================
2111  // =======================================================================
2114  // =======================================================================
2117  // =======================================================================
2120  // =======================================================================
2123  // =======================================================================
2126  // =======================================================================
2129  // =======================================================================
2132  // =======================================================================
2135  // =======================================================================
2138  // =======================================================================
2141  // =======================================================================
2144  // =======================================================================
2145  private:
2146 
2147  // =======================================================================
2150  // =======================================================================
2153  // =======================================================================
2156  // =======================================================================
2159  // =======================================================================
2161  size_t m_refCount = 0;
2162  // =======================================================================
2164  mutable Bools m_bools ;
2165  // =======================================================================
2167  mutable Chars m_chars ;
2168  // =======================================================================
2170  mutable UChars m_uchars ;
2171  // =======================================================================
2173  mutable Shorts m_shorts ;
2174  // =======================================================================
2176  mutable UShorts m_ushorts ;
2177  // =======================================================================
2179  mutable Ints m_ints ;
2180  // =======================================================================
2182  mutable UInts m_uints ;
2183  // =======================================================================
2185  mutable LongLongs m_longlongs ;
2186  // =======================================================================
2188  mutable ULongLongs m_ulonglongs ;
2189  // =======================================================================
2191  mutable Floats m_floats ;
2192  // =======================================================================
2194  mutable Doubles m_doubles ;
2195  // =======================================================================
2197  mutable Addresses m_addresses ;
2198  // =======================================================================
2200  mutable FArrays m_farrays ;
2201  // =======================================================================
2203  mutable FArrays m_arraysf ;
2204  // =======================================================================
2206  mutable FMatrices m_fmatrices ;
2207  // =======================================================================
2209  mutable FMatrices m_matricesf ;
2210  // =======================================================================
2212  ItemMap m_items ;
2213  // =======================================================================
2214  } ;
2215  // ==========================================================================
2216 } // end of namespace Tuples
2217 // ============================================================================
2218 // GaudiAlg
2219 // ============================================================================
2220 #include "GaudiAlg/TuplePut.h"
2221 // ============================================================================
2222 // The END
2223 // ============================================================================
2224 #endif // GAUDIALG_TUPLEOBJ_H
2225 // ============================================================================
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:1866
UShorts m_ushorts
the actual storage of all &#39;unsigned int&#39; columns
Definition: TupleObj.h:2176
FMatrices m_fmatrices
the actual storage of all &#39;FArray&#39; columns
Definition: TupleObj.h:2206
A bit modified version of &#39;Loki::AssocVector&#39; associative vector from Loki library by Andrei Alexandr...
Definition: VectorMap.h:108
CLID m_clid
tuple CLID
Definition: TupleObj.h:2155
const NTuple::Tuple * tuple() const
provide the access to underlying Gaudi N-tuple
Definition: TupleObj.h:1991
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:1801
GaudiUtils::HashMap< std::string, std::unique_ptr< FMatrix > > FMatrices
the actual storage type for matrix columns
Definition: TupleObj.h:2143
T forward_as_tuple(T...args)
T distance(T...args)
GAUDI_API std::string format(const char *,...)
MsgStream format utility "a la sprintf(...)".
Definition: MsgStream.cpp:121
NTuple::Item< float > Float
basic type for float items
Definition: TupleObj.h:229
bool goodItem(const std::string &name) const
check the uniqueness of the name
Definition: TupleObj.h:2050
bool evtColType() const
Event collection ?
Definition: TupleObj.h:2027
Doubles m_doubles
the actual storage of all &#39;Double&#39; columns
Definition: TupleObj.h:2194
Tuples::Type m_type
tuple &#39;type&#39;
Definition: TupleObj.h:2158
StatusCode columns_helper(const Value &value, const Tuple &tup, std::index_sequence< I... >)
Set the values for several columns simultaneously, for the same object Non-existing columns will be a...
Definition: TupleObj.h:825
Class acting as a smart pointer holding a N tuple _Item.
Definition: NTuple.h:44
NTuple::Item< IOpaqueAddress * > Address
basic type for address items
Definition: TupleObj.h:235
FMatrices m_matricesf
the actual storage of all &#39;FMatrix&#39; columns (fixed)
Definition: TupleObj.h:2209
Floats m_floats
the actual storage of all &#39;Float&#39; columns
Definition: TupleObj.h:2191
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:36
NTuple::Item< unsigned long long > ULongLong
basic type for unsigned long long items
Definition: TupleObj.h:226
FArrays m_farrays
the actual storage of all &#39;FArray&#39; columns
Definition: TupleObj.h:2200
NTuple::Item< unsigned short > UShort
basic type for unsigned int items
Definition: TupleObj.h:214
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:1375
unsigned short MIndex
Definition: TupleObj.h:244
std::string m_name
name
Definition: TupleObj.h:2149
GaudiUtils::HashMap< std::string, std::unique_ptr< LongLong > > LongLongs
the actual storage type for longlong columns
Definition: TupleObj.h:2125
NTuple::Tuple * tuple()
provide the access to underlying Gaudi N-tuple
Definition: TupleObj.h:1996
FArrays m_arraysf
the actual storage of all &#39;FArray&#39; columns (fixed)
Definition: TupleObj.h:2203
GaudiUtils::HashMap< std::string, std::unique_ptr< Address > > Addresses
the actual storage type for address columns
Definition: TupleObj.h:2137
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:925
NTuple::Item< unsigned char > UChar
basic type for unsigned int items
Definition: TupleObj.h:208
Bools m_bools
the actual storage of all &#39;bool&#39; columns
Definition: TupleObj.h:2164
Provide serialization function (output only) for some common STL classes (vectors, lists, pairs, maps) plus GaudiUtils::Map and GaudiUtils::HashMap.
auto begin(reverse_wrapper< T > &w)
Definition: reverse.h:48
bool columnWise() const
column wise NTuple ?
Definition: TupleObj.h:2021
PropertyMgr & operator=(const PropertyMgr &)=delete
constexpr double second
STL class.
NTuple::Item< short > Short
basic type for int items
Definition: TupleObj.h:211
Chars m_chars
the actual storage of all &#39;Int&#39; columns
Definition: TupleObj.h:2167
A simple wrapper class over standard Gaudi NTuple::Tuple facility.
Definition: Tuple.h:116
bool addItem(std::string name, std::string type)
add the item name into the list of known items
Definition: TupleObj.h:2042
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:1571
ULongLongs m_ulonglongs
the actual storage of all &#39;ulonglong&#39; columns
Definition: TupleObj.h:2188
TupleObj.h GaudiAlg/TupleObj.h namespace with few technical implementations.
A simple wrapper class over standard Gaudi NTuple::Tuple facility.
Definition: TupleObj.h:197
T next(T...args)
StatusCode array(const std::string &name, const ARRAY &data)
fill N-Tuple with fixed-size array
Definition: TupleObj.h:1743
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
StatusCode farray(const std::string &name1, const FUNC1 &func1, const std::string &name2, const FUNC2 &func2, const std::string &name3, const FUNC3 &func3, Iterator &&first, Iterator &&last, const std::string &length, size_t maxv)
Put three functions from one data array into LoKi-style N-Tuple simultaneously (effective!) ...
Definition: TupleObj.h:1243
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:979
NTuple::Matrix< float > FMatrix
basic type for matrix of floats
Definition: TupleObj.h:241
UInts m_uints
the actual storage of all &#39;unsigned int&#39; columns
Definition: TupleObj.h:2182
T operator()(Arg &&i) const
Definition: TupleObj.h:65
T make_pair(T...args)
ItemMap m_items
all booked types:
Definition: TupleObj.h:2212
NTuple::Item< bool > Bool
basic type for int items
Definition: TupleObj.h:202
auto end(reverse_wrapper< T > &w)
Definition: reverse.h:50
NTuple::Item< double > Double
basic type for double items
Definition: TupleObj.h:232
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:1191
Specialization acting as a smart pointer holding a N tuple _Item.
Definition: NTuple.h:297
Ints m_ints
the actual storage of all &#39;Int&#39; columns
Definition: TupleObj.h:2179
unsigned int CLID
Class ID definition.
Definition: ClassID.h:8
GaudiUtils::HashMap< std::string, std::unique_ptr< UShort > > UShorts
the actual storage type for unsigned short columns
Definition: TupleObj.h:2116
LongLongs m_longlongs
the actual storage of all &#39;longlong&#39; columns
Definition: TupleObj.h:2185
bool valid() const
valid pointer to tuple ?
Definition: TupleObj.h:2030
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:1450
unsigned long addRef()
add the reference to TupleObj
Definition: TupleObj.h:2006
unsigned long refCount() const
return the reference counter
Definition: TupleObj.h:2001
bool rowWise() const
row wise NTuple ?
Definition: TupleObj.h:2024
Stream & ostream_joiner(Stream &os, Iterator first, Iterator last, Separator sep, OutputElement output=OutputElement{})
Definition: SerializeSTL.h:35
Abstract base class which allows the user to interact with the actual N tuple implementation.
Definition: NTuple.h:370
typename std::add_const< typename std::iterator_traits< Iterator >::reference >::type const_ref_t
Definition: TupleObj.h:71
StatusCode column(const std::string &name, signed char value)
Set the value for the selected tuple column.
Definition: TupleObj.h:736
ErrorCodes
Tuple error codes.
Definition: TupleObj.h:93
NTuple::Item< long long > LongLong
basic type for unsigned long long items
Definition: TupleObj.h:223
Addresses m_addresses
the actual storage of all &#39;Address&#39; columns
Definition: TupleObj.h:2197
GaudiUtils::HashMap< std::string, std::unique_ptr< FArray > > FArrays
the actual storage type for array columns
Definition: TupleObj.h:2140
GaudiUtils::HashMap< std::string, std::unique_ptr< Float > > Floats
the actual storage type for float columns
Definition: TupleObj.h:2131
T find_if_not(T...args)
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:1301
StatusCode array(const std::string &name, DATA first, DATA last)
fill N-Tuple with fixed-size array
Definition: TupleObj.h:1640
struct GAUDI_API array
Parametrisation class for redirection array - like implementation.
STL class.
NTuple::Tuple * m_tuple
tuple itself
Definition: TupleObj.h:2152
GaudiUtils::HashMap< std::string, std::unique_ptr< Double > > Doubles
the actual storage type for float columns
Definition: TupleObj.h:2134
T cref(T...args)
Tuples::Type type() const
accessor to the N-Tuple type
Definition: TupleObj.h:2018
boost::spirit::classic::position_iterator2< ForwardIterator > Iterator
Definition: Iterator.h:18
T begin(T...args)
StatusCode farray(const std::string &name, const FUNCTION &function, ITERATOR first, ITERATOR last, const std::string &length, size_t maxv)
Put an indexed array into LoKi-style N-Tuple.
Definition: TupleObj.h:1048
T back_inserter(T...args)
T any_of(T...args)
double fun(const std::vector< double > &x)
Definition: PFuncTest.cpp:26
NTuple::Item< char > Char
basic type for int items
Definition: TupleObj.h:205
Common class providing an architecture-independent hash map.
Definition: HashMap.h:77
STL class.
NTuple::Item< int > Int
basic type for int items
Definition: TupleObj.h:217
GaudiUtils::HashMap< std::string, std::unique_ptr< Char > > Chars
the actual storage type for short columns
Definition: TupleObj.h:2107
StatusCode column(const std::string &name, const ROOT::Math::LorentzVector< TYPE > &v)
Useful shortcut to put LorentzVector directly into N-Tuple:
Definition: TupleObj.h:1841
Shorts m_shorts
the actual storage of all &#39;Int&#39; columns
Definition: TupleObj.h:2173
bool invalid() const
invalid pointer to tuple ?
Definition: TupleObj.h:2033
T transform(T...args)
const ItemMap & items() const
get the full list of booked items
Definition: TupleObj.h:2054
NTuple::Array< float > FArray
basic type for array of floats
Definition: TupleObj.h:238
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:89
Implementation file for Tuple::TupleObj::put method.
Opaque address interface definition.
GaudiUtils::HashMap< std::string, std::unique_ptr< UInt > > UInts
the actual storage type for unsigned integer columns
Definition: TupleObj.h:2122
Class acting as a smart pointer holding a N tuple _Item.
Definition: NTuple.h:42
const CLID & clid() const
accessor to the N-Tuple CLID
Definition: TupleObj.h:2015
GaudiUtils::HashMap< std::string, std::unique_ptr< Int > > Ints
the actual storage type for integer columns
Definition: TupleObj.h:2119
StatusCode array(const std::string &name, const ARRAY &data, const MIndex &length)
fill N-Tuple with fixed-size array
Definition: TupleObj.h:1700
GaudiUtils::HashMap< std::string, std::unique_ptr< Short > > Shorts
the actual storage type for short columns
Definition: TupleObj.h:2113
T for_each(T...args)
Class acting as a smart pointer holding a N tuple _Item.
Definition: NTuple.h:43
std::map< std::string, std::string > ItemMap
Definition: TupleObj.h:247
#define GAUDI_API
Definition: Kernel.h:107
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:1986
NTuple::Item< unsigned int > UInt
basic type for unsigned int items
Definition: TupleObj.h:220
StatusCode columns(Value &&value, Args &&...args)
Definition: TupleObj.h:841
GaudiUtils::HashMap< std::string, std::unique_ptr< ULongLong > > ULongLongs
the actual storage type for ulonglong columns
Definition: TupleObj.h:2128
UChars m_uchars
the actual storage of all &#39;unsigned int&#39; columns
Definition: TupleObj.h:2170
GaudiUtils::HashMap< std::string, std::unique_ptr< Bool > > Bools
the actual storage type for short columns
Definition: TupleObj.h:2104
Out1 * put(DataObjectHandle< Out1 > &out_handle, Out2 &&out)
T reserve(T...args)
GaudiUtils::HashMap< std::string, std::unique_ptr< UChar > > UChars
the actual storage type for unsigned short columns
Definition: TupleObj.h:2110
General namespace for Tuple properties.
Definition: Maps.h:34