All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
TupleObj.h
Go to the documentation of this file.
1 // ============================================================================
2 #ifndef GAUDIALG_TUPLEOBJ_H
3 #define GAUDIALG_TUPLEOBJ_H 1
4 // ============================================================================
5 // Include files
6 // ============================================================================
7 // STD&STL
8 // ============================================================================
9 #include <cstddef>
10 #include <set>
11 #include <string>
12 #include <limits>
13 #include <array>
14 #include <functional>
15 #include <sstream>
16 // ============================================================================
17 // GaudiKernel
18 // ============================================================================
19 #include "GaudiKernel/NTuple.h"
20 #include "GaudiKernel/VectorMap.h"
22 // ============================================================================
23 // GaudiAlg
24 // ============================================================================
25 #include "GaudiAlg/Tuples.h"
26 #include "GaudiAlg/Maps.h"
27 // ============================================================================
28 // ROOT
29 // ============================================================================
30 #include "Math/Point3D.h"
31 #include "Math/Vector3D.h"
32 #include "Math/Vector4D.h"
33 #include "Math/SVector.h"
34 #include "Math/SMatrix.h"
35 
36 // ============================================================================
37 // forward declaration
38 // ============================================================================
39 // GaudiKernel
40 // ============================================================================
41 class IOpaqueAddress ;
42 // ============================================================================
51 // ============================================================================
59 namespace Tuples
60 {
61  namespace detail {
62  template <typename T> struct to_ {
63  template <typename Arg>
64  T operator()(Arg&& i) const
65  { return T(std::forward<Arg>(i)); }
66  };
67  constexpr struct to_<float> to_float {};
68 
69  template <typename Iterator>
71 
72  }
73  // ==========================================================================
79  enum Type
80  {
81  NTUPLE , // Analysis nTuple
82  EVTCOL // Event Collection
83  };
84  // ==========================================================================
93  {
94  InvalidTuple = 100 ,
100  };
101  // ==========================================================================
197  {
198  public:
199  // ========================================================================
202  // ========================================================================
205  // ========================================================================
208  // ========================================================================
211  // ========================================================================
214  // ========================================================================
217  // ========================================================================
220  // ========================================================================
223  // ========================================================================
226  // ========================================================================
229  // ========================================================================
232  // ========================================================================
235  // ========================================================================
238  // ========================================================================
241  // ========================================================================
242  // the actual type for variable size matrix indices
243  typedef unsigned short MIndex ;
244  // ========================================================================
245  // the map of all items
247  // ========================================================================
248  protected:
249  // ========================================================================
257  TupleObj
258  ( std::string name ,
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 ,
286  float value );
287  // ========================================================================
288  public:
289  // ========================================================================
306  StatusCode column ( const std::string& name ,
307  double value );
308  // ========================================================================
309  public:
310  // ========================================================================
326  StatusCode column ( const std::string& name ,
327  short value );
328  // ========================================================================
346  StatusCode column ( const std::string& name ,
347  short value ,
348  short minv ,
349  short maxv );
350  // ========================================================================
351  public:
352  // ========================================================================
368  StatusCode column ( const std::string& name ,
369  unsigned short value );
370  // ========================================================================
388  StatusCode column ( const std::string& name ,
389  unsigned short value ,
390  unsigned short minv ,
391  unsigned short maxv );
392  // ========================================================================
393  public:
394  // ========================================================================
410  StatusCode column ( const std::string& name ,
411  char value );
412  // ========================================================================
430  StatusCode column ( const std::string& name ,
431  char value ,
432  char minv ,
433  char maxv );
434  // ========================================================================
435  public:
436  // ========================================================================
452  StatusCode column ( const std::string& name ,
453  unsigned char value );
454  // ========================================================================
472  StatusCode column ( const std::string& name ,
473  unsigned char value ,
474  unsigned char minv ,
475  unsigned char maxv );
476  // ========================================================================
477  public:
478  // ========================================================================
494  StatusCode column ( const std::string& name ,
495  int value );
496  // ========================================================================
514  StatusCode column ( const std::string& name ,
515  int value ,
516  int minv ,
517  int maxv );
518  // ========================================================================
519  public:
520  // ========================================================================
536  StatusCode column ( const std::string& name ,
537  unsigned int value );
538  // ========================================================================
556  StatusCode column ( const std::string& name ,
557  unsigned int value ,
558  unsigned int minv ,
559  unsigned int maxv );
560  // ========================================================================
561  public:
562  // ========================================================================
579  StatusCode column ( const std::string& name ,
580  long value );
581  // ========================================================================
599  StatusCode column ( const std::string& name ,
600  long value ,
601  long minv ,
602  long maxv );
603  // ========================================================================
604  public:
605  // ========================================================================
622  StatusCode column ( const std::string& name ,
623  unsigned long value );
624  // ========================================================================
642  StatusCode column ( const std::string& name ,
643  unsigned long value ,
644  unsigned long minv ,
645  unsigned long maxv );
646  // ========================================================================
647  public:
648  // ========================================================================
664  StatusCode column ( const std::string& name ,
665  long long value );
666  // ========================================================================
684  StatusCode column ( const std::string& name ,
685  long long value ,
686  long long minv ,
687  long long maxv );
688  // ========================================================================
689  public:
690  // ========================================================================
706  StatusCode column ( const std::string& name ,
707  unsigned long long value );
708  // ========================================================================
726  StatusCode column ( const std::string& name ,
727  unsigned long long value ,
728  unsigned long long minv ,
729  unsigned long long maxv );
730  // ========================================================================
731  public:
732  // ========================================================================
749  signed char value )
750  {
751  return column
752  ( name ,
753  value ,
756  }
757  // ========================================================================
758  public:
759  // ========================================================================
774  StatusCode column ( const std::string& name ,
775  bool value );
776  // ========================================================================
777  public:
778  // ========================================================================
797  StatusCode column ( const std::string& name ,
798  IOpaqueAddress* address ) ;
799  // ========================================================================
816  StatusCode column ( IOpaqueAddress* address ) ;
817  // ========================================================================
818  public:
819  // ========================================================================
843  StatusCode fill( const char* format ... ) ;
844  // =======================================================================
845  public:
846  // =======================================================================
895  template <typename ITERATOR1,typename ITERATOR2>
896  StatusCode farray ( const std::string& name ,
897  ITERATOR1&& first ,
898  ITERATOR2&& last ,
899  const std::string& length ,
900  size_t maxv )
901  {
902  return farray( name, detail::to_float,
903  std::forward<ITERATOR1>(first), std::forward<ITERATOR2>(last),
904  length, maxv );
905  }
906  // =======================================================================
949  template <class DATA>
950  StatusCode farray ( const std::string& name ,
951  const DATA& data ,
952  const std::string& length ,
953  const size_t maxv )
954  { return farray ( name , std::begin(data) , std::end(data) , length , maxv ) ; }
955  // =======================================================================
1018  template <class FUNCTION, class ITERATOR>
1020  const FUNCTION& function ,
1021  ITERATOR first ,
1022  ITERATOR last ,
1023  const std::string& length ,
1024  size_t maxv )
1025  {
1026  if ( invalid () ) { return InvalidTuple ; }
1027  if ( rowWise () ) { return InvalidOperation ; }
1028 
1029  // adjust the length
1030  if( std::distance(first,last) > static_cast<std::ptrdiff_t>(maxv) ) {
1031  Warning("farray('"
1032  + name + "'): array is overflow, skip extra entries") ;
1033  last = std::next(first,maxv);
1034  }
1035 
1036  // get the length item
1037  Int* len = ints( length , 0 , maxv ) ;
1038  if( !len ) { return InvalidColumn ; }
1039 
1040  // adjust the length
1041  *len = std::distance(first,last);
1042 
1043  // get the array itself
1044  FArray* var = fArray ( name , len ) ;
1045  if( !var ) { return InvalidColumn ; }
1046 
1047  // fill the array
1048  std::transform( first, last, std::begin(*var), std::cref(function) );
1049 
1050  return StatusCode::SUCCESS ;
1051  }
1052  // =======================================================================
1079  template <typename Iterator,
1081  typename Item = std::pair<std::string,Fun>>
1083  Iterator first ,
1084  Iterator last ,
1085  const std::string& length,
1086  size_t maxv )
1087  {
1088  if ( invalid () ) { return InvalidTuple ; }
1089  if ( rowWise () ) { return InvalidOperation ; }
1090 
1091  // adjust the lenfth
1092  if( std::distance(first,last) > static_cast<std::ptrdiff_t>(maxv) ) {
1094  std::ostringstream os;
1095  ostream_joiner( os, items, ",",
1096  [](std::ostream& os, const Item& i) -> std::ostream&
1097  { return os << i.first; } );
1098  Warning( "farray('" + os.str()
1099  + "'): array overflow, skipping extra entries").ignore() ;
1100  last = std::next(first, maxv) ;
1101  }
1102 
1103  // get the length item
1104  Int* len = ints ( length , 0 , maxv ) ;
1105  if ( !len ) { return InvalidColumn ; }
1106 
1107  // adjust the length
1108  *len = std::distance(first,last);
1109 
1110  // get the arrays themselves
1111  std::vector<FArray*> vars; vars.reserve(items.size());
1112  std::transform( items.begin(), items.end(), std::back_inserter(vars),
1113  [&](const Item& item) { return this->fArray(item.first,len); } );
1114  if ( std::any_of( vars.begin(), vars.end(), [](const FArray* f) { return !f; } ) ) {
1115  return InvalidColumn ;
1116  }
1117 
1118  // fill the array
1119  size_t index = 0;
1120  while( first != last ) {
1121  auto var = vars.begin();
1122  auto item = items.begin();
1123  while ( var != vars.end() ) {
1124  (**var)[index] = item->second(*first);
1125  ++var;
1126  ++item;
1127  }
1128  ++index;
1129  ++first;
1130  }
1131 
1132  return StatusCode::SUCCESS ;
1133  }
1134  // =======================================================================
1166  template <class FUNC1, class FUNC2, class Iterator>
1167  StatusCode farray ( const std::string& name1 ,
1168  const FUNC1& func1 ,
1169  const std::string& name2 ,
1170  const FUNC2& func2 ,
1171  Iterator&& first ,
1172  Iterator&& last ,
1173  const std::string& length ,
1174  size_t maxv )
1175  {
1176  return farray( { { name1, std::cref(func1) },
1177  { name2, std::cref(func2) } },
1178  std::forward<Iterator>(first), std::forward<Iterator>(last),
1179  length, maxv );
1180  }
1181  // =======================================================================
1218  template <class FUNC1, class FUNC2, class FUNC3, class Iterator>
1219  StatusCode farray ( const std::string& name1 ,
1220  const FUNC1& func1 ,
1221  const std::string& name2 ,
1222  const FUNC2& func2 ,
1223  const std::string& name3 ,
1224  const FUNC3& func3 ,
1225  Iterator&& first ,
1226  Iterator&& last ,
1227  const std::string& length ,
1228  size_t maxv )
1229  {
1230  return farray( {{name1,std::cref(func1)},
1231  {name2,std::cref(func2)},
1232  {name3,std::cref(func3)}},
1233  std::forward<Iterator>(first), std::forward<Iterator>(last),
1234  length, maxv );
1235  }
1236  // =======================================================================
1276  template <class FUNC1, class FUNC2, class FUNC3, class FUNC4, class Iterator>
1277  StatusCode farray ( const std::string& name1 ,
1278  const FUNC1& func1 ,
1279  const std::string& name2 ,
1280  const FUNC2& func2 ,
1281  const std::string& name3 ,
1282  const FUNC3& func3 ,
1283  const std::string& name4 ,
1284  const FUNC4& func4 ,
1285  Iterator&& first ,
1286  Iterator&& last ,
1287  const std::string& length ,
1288  size_t maxv )
1289  {
1290  return farray( {{name1,std::cref(func1)},
1291  {name2,std::cref(func2)},
1292  {name3,std::cref(func3)},
1293  {name4,std::cref(func4)}},
1294  std::forward<Iterator>(first), std::forward<Iterator>(last),
1295  length, maxv );
1296  }
1297  // =======================================================================
1298  public:
1299  // =======================================================================
1350  template <class MATRIX>
1352  const MATRIX& data ,
1353  size_t rows ,
1354  const MIndex& cols ,
1355  const std::string& length ,
1356  size_t maxv )
1357  {
1358  if ( invalid () ) { return InvalidTuple ; }
1359  if ( rowWise () ) { return InvalidOperation ; }
1360 
1361  // adjust the length
1362  if ( rows >= maxv )
1363  {
1364  Warning ( "fmatrix('"+name+"'): matrix is overflow, skip extra items").ignore() ;
1365  rows = ( 0 < maxv ) ? ( maxv - 1 ) : 0 ;
1366  }
1367 
1368  // get the length item
1369  Int* len = ints( length , 0 , maxv ) ;
1370  if ( !len ) { return InvalidColumn; }
1371 
1372  // adjust the length item
1373  *len = rows ;
1374 
1375  // get the array itself
1376  FMatrix* var = fMatrix ( name , len , cols ) ;
1377  if ( !var ) { return InvalidColumn ; }
1378 
1380  for ( size_t iCol = 0 ; iCol < cols ; ++iCol )
1381  {
1382  for ( MIndex iRow = 0 ; iRow < rows ; ++iRow )
1383  { (*var)[ iRow ] [ iCol ] = data[ iRow ][ iCol ] ; }
1384  }
1385 
1386  return StatusCode::SUCCESS ;
1387  }
1388  // =======================================================================
1425  template <class DATA>
1427  DATA first ,
1428  DATA last ,
1429  const MIndex& cols ,
1430  const std::string& length ,
1431  size_t maxv )
1432  {
1433  if ( invalid () ) { return InvalidTuple ; }
1434  if ( rowWise () ) { return InvalidOperation ; }
1435 
1436  // adjust the length
1437  if ( first + maxv < last )
1438  {
1439  Warning("fmatrix('"+name+"'): matrix is overflow, skip extra items").ignore() ;
1440  last = first + maxv ;
1441  }
1442 
1443  // get the length item
1444  Int* len = ints( length , 0 , maxv ) ;
1445  if ( !len ) { return InvalidColumn; }
1446 
1447  // adjust the length item
1448  *len = last - first ;
1449 
1450  // get the array itself
1451  FMatrix* var = fMatrix ( name , len , cols ) ;
1452  if ( !var ) { return InvalidColumn ; }
1453 
1455  size_t iRow = 0 ;
1456  for ( ; first != last ; ++first )
1457  {
1458  //
1459  for ( MIndex iCol = 0 ; iCol < cols ; ++iCol )
1460  { (*var)[ iRow ] [ iCol ] = (float)((*first)[ iCol ]) ; }
1461  //
1462  ++iRow ;
1463  }
1464 
1465  return StatusCode::SUCCESS ;
1466  }
1467  // =======================================================================
1546  template <class FUN,class DATA>
1548  FUN funF ,
1549  FUN funL ,
1550  DATA first ,
1551  DATA last ,
1552  const std::string& length ,
1553  size_t maxv )
1554  {
1555  if ( invalid () ) { return InvalidTuple ; }
1556  if ( rowWise () ) { return InvalidOperation ; }
1557 
1558  // adjust the length
1559  if ( std::distance(first,last) > static_cast<std::ptrdiff_t>(maxv) )
1560  {
1561  Warning("fmatrix('"+name+"'): matrix is overflow, skip extra items").ignore() ;
1562  last = std::next(first, maxv) ;
1563  }
1564 
1565  // get the length item
1566  Int* len = ints( length , 0 , maxv ) ;
1567  if ( !len ) { return InvalidColumn; }
1568 
1569  // adjust the length item
1570  *len = std::distance(first,last);
1571 
1572  // get the array itself
1573  auto cols = std::distance(funF,funL);
1574  FMatrix* var = fMatrix ( name , len , cols ) ;
1575  if ( !var ) { return InvalidColumn ; }
1576 
1578  size_t iRow = 0 ;
1579  for ( ; first != last ; ++first )
1580  {
1581  //
1582  for ( FUN fun = funF ; fun < funL ; ++fun )
1583  { (*var)[ iRow ] [ fun - funF ] = (*fun) ( *first ) ; }
1584  //
1585  ++iRow;
1586  }
1587 
1588  return StatusCode::SUCCESS ;
1589  }
1590  // =======================================================================
1591  public:
1592  // =======================================================================
1615  template <class DATA>
1616  StatusCode array ( const std::string& name ,
1617  DATA first ,
1618  DATA last )
1619 
1620  {
1621  if ( invalid () ) { return InvalidTuple ; }
1622  if ( rowWise () ) { return InvalidOperation ; }
1623 
1624  // get the length (fixed!)
1625  auto length = std::distance(first,last);
1626 
1627  // get the array itself
1628  FArray* var = fArray ( name , length ) ;
1629  if ( !var ) { return InvalidColumn ; }
1630 
1632  std::copy( first, last, std::begin(*var) );
1633 
1634  return StatusCode::SUCCESS ;
1635  }
1636  // =======================================================================
1675  template <class ARRAY>
1676  StatusCode array ( const std::string& name ,
1677  const ARRAY& data ,
1678  const MIndex& length )
1679  {
1680  using std::begin; // allow data to be eg. CLHEP::HepVector (which does not define HepVector::begin()!,
1681  // in which case ADL prefers CLHEP::begin (yah! at least they (now) use a namespace)
1682  // so one just to insure double* CLHEP::begin(CLHEP::HepVector& v) { return &v[0]; }
1683  // is visible when this function gets instantiated for CLHEP::HepVector...
1684  auto first = begin(data);
1685  return array( name, first, std::next( first, length ) );
1686  }
1687  // =======================================================================
1718  template <class ARRAY>
1719  StatusCode array ( const std::string& name ,
1720  const ARRAY& data )
1721  {
1722  using std::begin; using std::end;
1723  return array ( name , begin(data) , end(data) ) ;
1724  }
1725  // =======================================================================
1726  public:
1727  // =======================================================================
1776  template <class MATRIX>
1778  const MATRIX& data ,
1779  const MIndex& rows ,
1780  const MIndex& cols )
1781  {
1782  if ( invalid () ) { return InvalidTuple ; }
1783  if ( rowWise () ) { return InvalidOperation ; }
1784 
1785  // get the matrix itself
1786  FMatrix* var = fMatrix ( name , rows , cols ) ;
1787  if ( !var ) { return InvalidColumn ; }
1788 
1790  for ( size_t iCol = 0 ; iCol < cols ; ++iCol )
1791  {
1792  for ( size_t iRow = 0 ; iRow < rows ; ++iRow )
1793  { (*var)[iRow][iCol] = data[iRow][iCol]; }
1794  };
1795  return StatusCode::SUCCESS ;
1796  }
1797  // =======================================================================
1798  public:
1799  // =======================================================================
1816  template <class TYPE>
1818  ( const std::string& name ,
1819  const ROOT::Math::LorentzVector<TYPE>& v )
1820  {
1821  if ( invalid() ) { return InvalidTuple ; }
1822  // fill all separate columns:
1823  StatusCode sc1 = this -> column ( name + "E" , v.E () ) ;
1824  StatusCode sc2 = this -> column ( name + "X" , v.Px () ) ;
1825  StatusCode sc3 = this -> column ( name + "Y" , v.Py () ) ;
1826  StatusCode sc4 = this -> column ( name + "Z" , v.Pz () ) ;
1827  return
1828  sc1.isFailure () ? sc1 :
1829  sc2.isFailure () ? sc2 :
1830  sc3.isFailure () ? sc3 :
1831  sc4.isFailure () ? sc4 : StatusCode(StatusCode::SUCCESS) ;
1832  }
1833  // =======================================================================
1850  template <class TYPE,class TAG>
1852  ( const std::string& name ,
1854  {
1855  if ( invalid() ) { return InvalidTuple ; }
1857  StatusCode sc1 = this -> column ( name + "X" , v.X () ) ;
1858  StatusCode sc2 = this -> column ( name + "Y" , v.Y () ) ;
1859  StatusCode sc3 = this -> column ( name + "Z" , v.Z () ) ;
1860  return
1861  sc1.isFailure () ? sc1 :
1862  sc2.isFailure () ? sc2 :
1863  sc3.isFailure () ? sc3 : StatusCode(StatusCode::SUCCESS) ;
1864  }
1865  // =======================================================================
1882  template <class TYPE,class TAG>
1884  ( const std::string& name ,
1886  {
1887  if ( invalid() ) { return InvalidTuple ; }
1889  StatusCode sc1 = this -> column ( name + "X" , v.X () ) ;
1890  StatusCode sc2 = this -> column ( name + "Y" , v.Y () ) ;
1891  StatusCode sc3 = this -> column ( name + "Z" , v.Z () ) ;
1892  return
1893  sc1.isFailure () ? sc1 :
1894  sc2.isFailure () ? sc2 :
1895  sc3.isFailure () ? sc3 : StatusCode(StatusCode::SUCCESS) ;
1896  }
1897  // =======================================================================
1906  template <class TYPE,unsigned int D1,unsigned int D2,class REP>
1908  ( const std::string& name ,
1909  const ROOT::Math::SMatrix<TYPE,D1,D2,REP>& mtrx )
1910  {
1911  if ( invalid () ) { return InvalidTuple ; }
1912  if ( rowWise () ) { return InvalidOperation ; }
1913 
1914  // get the matrix itself
1915  FMatrix* var = fMatrix ( name , (MIndex)D1 , (MIndex)D2 ) ;
1916  if ( !var ) { return InvalidColumn ; }
1917 
1919  for ( size_t iCol = 0 ; iCol < D2 ; ++iCol )
1920  {
1921  for ( size_t iRow = 0 ; iRow < D1 ; ++iRow )
1922  { (*var)[iRow][iCol] = mtrx(iRow,iCol) ; }
1923  };
1924 
1925  return StatusCode::SUCCESS ;
1926  }
1927  // =======================================================================
1945  template <class KEY, class VALUE>
1947  ( const std::string& name ,
1948  const GaudiUtils::VectorMap<KEY,VALUE>& info ,
1949  const std::string& length ,
1950  const size_t maxv = 100 )
1951  {
1952  using Info = std::pair<KEY,VALUE>;
1954  fns = { { [](const Info& i) { return i.first; } ,
1955  [](const Info& i) { return i.second; } } };
1956  return fmatrix( name,
1957  std::begin(fns), std::end(fns),
1958  std::begin(info), std::end(info),
1959  length,maxv );
1960  }
1961  // =======================================================================
1962  public:
1963  // =======================================================================
1971  template <class TYPE>
1972  StatusCode put
1973  ( const std::string& name , const TYPE* obj ) ;
1974  // =======================================================================
1975  public:
1976  // =======================================================================
1980  StatusCode write () ;
1981  // =======================================================================
1983  const std::string& name() const { return m_name ; }
1984  // =======================================================================
1988  const NTuple::Tuple* tuple() const { return m_tuple ; }
1989  // =======================================================================
1993  NTuple::Tuple* tuple() { return m_tuple ; }
1994  // =======================================================================
1998  unsigned long refCount() const { return m_refCount ; }
1999  // =======================================================================
2003  unsigned long addRef () { return ++m_refCount ; }
2004  // =======================================================================
2009  void release () ;
2010  // =======================================================================
2012  const CLID& clid() const { return m_clid ; }
2013  // =======================================================================
2015  Tuples::Type type() const { return m_type ; }
2016  // =======================================================================
2018  bool columnWise() const { return CLID_ColumnWiseTuple == clid() ; }
2019  // =======================================================================
2021  bool rowWise () const { return CLID_RowWiseTuple == clid() ; }
2022  // =======================================================================
2024  bool evtColType() const { return Tuples::EVTCOL == type() ; }
2025  // =======================================================================
2027  bool valid () const { return 0 != tuple() ; }
2028  // =======================================================================
2030  bool invalid () const { return ! valid() ; }
2031  // =======================================================================
2032  public:
2033  // =======================================================================
2039  bool addItem ( std::string name ,
2040  std::string type )
2041  { return m_items.emplace ( std::move(name) , std::move(type) ).second ; }
2042  // =======================================================================
2047  bool goodItem ( const std::string& name ) const
2048  { return m_items.end() == m_items.find ( name ) ; }
2049  // =======================================================================
2051  const ItemMap& items() const { return m_items ; }
2052  // =======================================================================
2053  public:
2054  // =======================================================================
2055  virtual StatusCode Error
2056  ( const std::string& msg ,
2057  const StatusCode sc = StatusCode::FAILURE ) const = 0 ;
2058  // =======================================================================
2059  virtual StatusCode Warning
2060  ( const std::string& msg ,
2061  const StatusCode sc = StatusCode::FAILURE ) const = 0 ;
2062  // =======================================================================
2063  private:
2064  // =======================================================================
2066  Int* ints ( const std::string& name ,
2067  int minv ,
2068  int maxv ) ;
2069  // =======================================================================
2071  FArray* fArray ( const std::string& name ,
2072  Int* item ) ;
2073  // =======================================================================
2075  FArray* fArray ( const std::string& name ,
2076  const MIndex& rows ) ;
2077  // =======================================================================
2079  Address* addresses ( const std::string& name ) ;
2080  // =======================================================================
2082  FMatrix* fMatrix ( const std::string& name ,
2083  Int* item ,
2084  const MIndex& cols ) ;
2085  // =======================================================================
2087  FMatrix* fMatrix ( const std::string& name ,
2088  const MIndex& rows ,
2089  const MIndex& cols ) ;
2090  // =======================================================================
2091  private:
2092  // =======================================================================
2094  TupleObj () = delete;
2095  TupleObj ( const TupleObj& ) = delete;
2096  TupleObj& operator= ( const TupleObj& ) = delete;
2097  // =======================================================================
2098  private:
2099  // =======================================================================
2102  // =======================================================================
2105  // =======================================================================
2108  // =======================================================================
2111  // =======================================================================
2114  // =======================================================================
2117  // =======================================================================
2120  // =======================================================================
2123  // =======================================================================
2126  // =======================================================================
2129  // =======================================================================
2132  // =======================================================================
2135  // =======================================================================
2138  // =======================================================================
2141  // =======================================================================
2142  private:
2143 
2144  // =======================================================================
2147  // =======================================================================
2150  // =======================================================================
2153  // =======================================================================
2156  // =======================================================================
2158  size_t m_refCount = 0;
2159  // =======================================================================
2161  mutable Bools m_bools ;
2162  // =======================================================================
2164  mutable Chars m_chars ;
2165  // =======================================================================
2167  mutable UChars m_uchars ;
2168  // =======================================================================
2170  mutable Shorts m_shorts ;
2171  // =======================================================================
2173  mutable UShorts m_ushorts ;
2174  // =======================================================================
2176  mutable Ints m_ints ;
2177  // =======================================================================
2179  mutable UInts m_uints ;
2180  // =======================================================================
2182  mutable LongLongs m_longlongs ;
2183  // =======================================================================
2185  mutable ULongLongs m_ulonglongs ;
2186  // =======================================================================
2188  mutable Floats m_floats ;
2189  // =======================================================================
2191  mutable Doubles m_doubles ;
2192  // =======================================================================
2194  mutable Addresses m_addresses ;
2195  // =======================================================================
2197  mutable FArrays m_farrays ;
2198  // =======================================================================
2200  mutable FArrays m_arraysf ;
2201  // =======================================================================
2203  mutable FMatrices m_fmatrices ;
2204  // =======================================================================
2206  mutable FMatrices m_matricesf ;
2207  // =======================================================================
2209  ItemMap m_items ;
2210  // =======================================================================
2211  } ;
2212  // ==========================================================================
2213 } // end of namespace Tuples
2214 // ============================================================================
2215 // GaudiAlg
2216 // ============================================================================
2217 #include "GaudiAlg/TuplePut.h"
2218 // ============================================================================
2219 // The END
2220 // ============================================================================
2221 #endif // GAUDIALG_TUPLEOBJ_H
2222 // ============================================================================
UShorts m_ushorts
the actual storage of all &#39;unsigned int&#39; columns
Definition: TupleObj.h:2173
FMatrices m_fmatrices
the actual storage of all &#39;FArray&#39; columns
Definition: TupleObj.h:2203
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:2152
const NTuple::Tuple * tuple() const
provide the access to underlying Gaudi N-tuple
Definition: TupleObj.h:1988
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:1777
GaudiUtils::HashMap< std::string, std::unique_ptr< FMatrix > > FMatrices
the actual storage type for matrix columns
Definition: TupleObj.h:2140
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:228
bool goodItem(const std::string &name) const
check the uniqueness of the name
Definition: TupleObj.h:2047
bool evtColType() const
Event collection ?
Definition: TupleObj.h:2024
Doubles m_doubles
the actual storage of all &#39;Double&#39; columns
Definition: TupleObj.h:2191
Tuples::Type m_type
tuple &#39;type&#39;
Definition: TupleObj.h:2155
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:234
FMatrices m_matricesf
the actual storage of all &#39;FMatrix&#39; columns (fixed)
Definition: TupleObj.h:2206
Floats m_floats
the actual storage of all &#39;Float&#39; columns
Definition: TupleObj.h:2188
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:225
FArrays m_farrays
the actual storage of all &#39;FArray&#39; columns
Definition: TupleObj.h:2197
NTuple::Item< unsigned short > UShort
basic type for unsigned int items
Definition: TupleObj.h:213
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:1351
unsigned short MIndex
Definition: TupleObj.h:243
std::string m_name
name
Definition: TupleObj.h:2146
bool isFailure() const
Test for a status code of FAILURE.
Definition: StatusCode.h:84
GaudiUtils::HashMap< std::string, std::unique_ptr< LongLong > > LongLongs
the actual storage type for longlong columns
Definition: TupleObj.h:2122
NTuple::Tuple * tuple()
provide the access to underlying Gaudi N-tuple
Definition: TupleObj.h:1993
FArrays m_arraysf
the actual storage of all &#39;FArray&#39; columns (fixed)
Definition: TupleObj.h:2200
GaudiUtils::HashMap< std::string, std::unique_ptr< Address > > Addresses
the actual storage type for address columns
Definition: TupleObj.h:2134
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:896
NTuple::Item< unsigned char > UChar
basic type for unsigned int items
Definition: TupleObj.h:207
Bools m_bools
the actual storage of all &#39;bool&#39; columns
Definition: TupleObj.h:2161
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:47
bool columnWise() const
column wise NTuple ?
Definition: TupleObj.h:2018
PropertyMgr & operator=(const PropertyMgr &)=delete
STL class.
NTuple::Item< short > Short
basic type for int items
Definition: TupleObj.h:210
Chars m_chars
the actual storage of all &#39;Int&#39; columns
Definition: TupleObj.h:2164
bool addItem(std::string name, std::string type)
add the item name into the list of known items
Definition: TupleObj.h:2039
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:1547
ULongLongs m_ulonglongs
the actual storage of all &#39;ulonglong&#39; columns
Definition: TupleObj.h:2185
TupleObj.h GaudiAlg/TupleObj.h namespace with few technical implementations.
A simple wrapper class over standard Gaudi NTuple::Tuple facility.
Definition: TupleObj.h:196
T next(T...args)
StatusCode array(const std::string &name, const ARRAY &data)
fill N-Tuple with fixed-size array
Definition: TupleObj.h:1719
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:1219
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:950
NTuple::Matrix< float > FMatrix
basic type for matrix of floats
Definition: TupleObj.h:240
UInts m_uints
the actual storage of all &#39;unsigned int&#39; columns
Definition: TupleObj.h:2179
T operator()(Arg &&i) const
Definition: TupleObj.h:64
ItemMap m_items
all booked types:
Definition: TupleObj.h:2209
NTuple::Item< bool > Bool
basic type for int items
Definition: TupleObj.h:201
auto end(reverse_wrapper< T > &w)
Definition: reverse.h:49
NTuple::Item< double > Double
basic type for double items
Definition: TupleObj.h:231
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:1167
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:2176
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:2113
LongLongs m_longlongs
the actual storage of all &#39;longlong&#39; columns
Definition: TupleObj.h:2182
bool valid() const
valid pointer to tuple ?
Definition: TupleObj.h:2027
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:1426
unsigned long addRef()
add the reference to TupleObj
Definition: TupleObj.h:2003
unsigned long refCount() const
return the reference counter
Definition: TupleObj.h:1998
bool rowWise() const
row wise NTuple ?
Definition: TupleObj.h:2021
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:70
StatusCode column(const std::string &name, signed char value)
Set the value for the selected tuple column.
Definition: TupleObj.h:748
ErrorCodes
Tuple error codes.
Definition: TupleObj.h:92
NTuple::Item< long long > LongLong
basic type for unsigned long long items
Definition: TupleObj.h:222
Addresses m_addresses
the actual storage of all &#39;Address&#39; columns
Definition: TupleObj.h:2194
GaudiUtils::HashMap< std::string, std::unique_ptr< FArray > > FArrays
the actual storage type for array columns
Definition: TupleObj.h:2137
GaudiUtils::HashMap< std::string, std::unique_ptr< Float > > Floats
the actual storage type for float columns
Definition: TupleObj.h:2128
T size(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:1277
StatusCode array(const std::string &name, DATA first, DATA last)
fill N-Tuple with fixed-size array
Definition: TupleObj.h:1616
struct GAUDI_API array
Parametrisation class for redirection array - like implementation.
STL class.
NTuple::Tuple * m_tuple
tuple itself
Definition: TupleObj.h:2149
GaudiUtils::HashMap< std::string, std::unique_ptr< Double > > Doubles
the actual storage type for float columns
Definition: TupleObj.h:2131
T cref(T...args)
Tuples::Type type() const
accessor to the N-Tuple type
Definition: TupleObj.h:2015
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:1019
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:204
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:216
GaudiUtils::HashMap< std::string, std::unique_ptr< Char > > Chars
the actual storage type for short columns
Definition: TupleObj.h:2104
Shorts m_shorts
the actual storage of all &#39;Int&#39; columns
Definition: TupleObj.h:2170
bool invalid() const
invalid pointer to tuple ?
Definition: TupleObj.h:2030
T transform(T...args)
const ItemMap & items() const
get the full list of booked items
Definition: TupleObj.h:2051
NTuple::Array< float > FArray
basic type for array of floats
Definition: TupleObj.h:237
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:2119
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:2012
GaudiUtils::HashMap< std::string, std::unique_ptr< Int > > Ints
the actual storage type for integer columns
Definition: TupleObj.h:2116
StatusCode array(const std::string &name, const ARRAY &data, const MIndex &length)
fill N-Tuple with fixed-size array
Definition: TupleObj.h:1676
GaudiUtils::HashMap< std::string, std::unique_ptr< Short > > Shorts
the actual storage type for short columns
Definition: TupleObj.h:2110
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:246
#define GAUDI_API
Definition: Kernel.h:107
Type
the list of available types for ntuples
Definition: TupleObj.h:79
STL class.
const std::string & name() const
get the name
Definition: TupleObj.h:1983
NTuple::Item< unsigned int > UInt
basic type for unsigned int items
Definition: TupleObj.h:219
GaudiUtils::HashMap< std::string, std::unique_ptr< ULongLong > > ULongLongs
the actual storage type for ulonglong columns
Definition: TupleObj.h:2125
UChars m_uchars
the actual storage of all &#39;unsigned int&#39; columns
Definition: TupleObj.h:2167
GaudiUtils::HashMap< std::string, std::unique_ptr< Bool > > Bools
the actual storage type for short columns
Definition: TupleObj.h:2101
T reserve(T...args)
GaudiUtils::HashMap< std::string, std::unique_ptr< UChar > > UChars
the actual storage type for unsigned short columns
Definition: TupleObj.h:2107
General namespace for Tuple properties.
Definition: Maps.h:34