g4tools  5.4.0
Public Member Functions | Static Public Member Functions | List of all members
tools::aida::ntuple Class Reference
Inheritance diagram for tools::aida::ntuple:
Inheritance graph
[legend]
Collaboration diagram for tools::aida::ntuple:
Collaboration graph
[legend]

Public Member Functions

virtual void * cast (const std::string &a_class) const
 
virtual const std::string & s_cls () const
 
 ntuple (std::ostream &a_out, const std::string &a_title)
 
virtual ~ntuple ()
 
 ntuple (const ntuple &a_from)
 
ntupleoperator= (const ntuple &a_from)
 
template<class T >
aida_col< T > * create_col (const std::string &a_name, const T &a_def=T())
 
template<class T >
aida_col< T > * find_column (const std::string &a_name)
 
template<class T >
bool find_column (const std::string &a_name, aida_col< T > *&a_col, bool a_case_sensitive=true)
 
aida_base_colfind_aida_base_column (const std::string &a_name, bool a_case_sensitive=true)
 
bool get_row () const
 
bool set_binding (std::ostream &a_out, const ntuple_binding &a_bd=ntuple_binding())
 
template<class T >
bool column_min (unsigned int a_col, T &a_value)
 
template<class T >
bool column_max (unsigned int a_col, T &a_value)
 
- Public Member Functions inherited from tools::aida::base_ntu
std::ostream & out () const
 
const std::vector< base_col * > & columns () const
 
size_t number_of_columns () const
 
const std::vector< base_col * > & cols () const
 
void column_names (std::vector< std::string > &a_names) const
 
const std::string & title () const
 
void set_title (const std::string &a_title)
 
uint64 rows () const
 
bool number_of_entries (uint64 &a_value) const
 
void clear ()
 
bool reset ()
 
void start ()
 
bool next ()
 
int64 row_index () const
 
bool add_row ()
 
base_colfind_column (const std::string &a_name)
 
void add_column (base_col *a_col)
 

Static Public Member Functions

static cid id_class ()
 
static const std::string & s_class ()
 
- Static Public Member Functions inherited from tools::aida::base_ntu
static const std::string & s_class ()
 

Additional Inherited Members

- Protected Member Functions inherited from tools::aida::base_ntu
 base_ntu (std::ostream &a_out, const std::string &a_title)
 
virtual ~base_ntu ()
 
 base_ntu (const base_ntu &a_from)
 
base_ntuoperator= (const base_ntu &a_from)
 
void set_columns_index (uint64 a_index)
 
- Protected Attributes inherited from tools::aida::base_ntu
std::ostream & m_out
 
std::string m_title
 
int64 m_index
 
std::vector< base_col * > m_cols
 

Detailed Description

Definition at line 503 of file aida_ntuple.

Constructor & Destructor Documentation

◆ ntuple() [1/2]

tools::aida::ntuple::ntuple ( std::ostream &  a_out,
const std::string &  a_title 
)
inline

Definition at line 517 of file aida_ntuple.

518  :base_ntu(a_out,a_title)
519  {}

◆ ~ntuple()

virtual tools::aida::ntuple::~ntuple ( )
inlinevirtual

Definition at line 520 of file aida_ntuple.

520 {}

◆ ntuple() [2/2]

tools::aida::ntuple::ntuple ( const ntuple a_from)
inline

Definition at line 522 of file aida_ntuple.

522 : base_ntu(a_from){}

Member Function Documentation

◆ cast()

virtual void* tools::aida::ntuple::cast ( const std::string &  a_class) const
inlinevirtual

Reimplemented from tools::aida::base_ntu.

Definition at line 511 of file aida_ntuple.

511  {
512  if(void* p = cmp_cast<ntuple>(this,a_class)) {return p;}
513  return base_ntu::cast(a_class);
514  }

◆ column_max()

template<class T >
bool tools::aida::ntuple::column_max ( unsigned int  a_col,
T &  a_value 
)
inline

Definition at line 619 of file aida_ntuple.

619  {
620  a_value = T();
621  if(m_cols.empty()) return false;
622  if(a_col>=m_cols.size()) return false;
623  base_col* _base_col = m_cols[a_col];
624  aida_col<T>* _col = safe_cast<base_col, aida_col<T> >(*_base_col);
625  if(!_col) return false;
626  start();
627  uint64 _rows = rows();
628  T v;
629  {for(uint64 row=0;row<_rows;row++) {
630  if(!next()) {a_value = T();return false;}
631  if(!_col->get_entry(v)) {}
632  if(!row) {
633  a_value = v;
634  } else {
635  a_value = mx<T>(a_value,v);
636  }
637  }}
638  return true;
639  }

◆ column_min()

template<class T >
bool tools::aida::ntuple::column_min ( unsigned int  a_col,
T &  a_value 
)
inline

Definition at line 596 of file aida_ntuple.

596  {
597  a_value = T();
598  if(m_cols.empty()) return false;
599  if(a_col>=m_cols.size()) return false;
600  base_col* _base_col = m_cols[a_col];
601  aida_col<T>* _col = safe_cast<base_col, aida_col<T> >(*_base_col);
602  if(!_col) return false;
603  start();
604  uint64 _rows = rows();
605  T v;
606  {for(uint64 row=0;row<_rows;row++) {
607  if(!next()) {a_value = T();return false;}
608  if(!_col->get_entry(v)) {}
609  if(!row) {
610  a_value = v;
611  } else {
612  a_value = mn<T>(a_value,v);
613  }
614  }}
615  return true;
616  }

◆ create_col()

template<class T >
aida_col<T>* tools::aida::ntuple::create_col ( const std::string &  a_name,
const T &  a_def = T() 
)
inline

Definition at line 529 of file aida_ntuple.

529  {
530  if(find_named<base_col>(m_cols,a_name)) {
531  m_out << s_class() << "::create_col :"
532  << " a column with name " << sout(a_name) << " already exists."
533  << std::endl;
534  return 0;
535  }
536  aida_col<T>* col = new aida_col<T>(m_out,a_name,a_def);
537  if(!col) {
538  m_out << s_class() << "::create_col :"
539  << " can't create aida_col<T> " << sout(a_name) << "."
540  << std::endl;
541  return 0;
542  }
543  m_cols.push_back(col);
544  return col;
545  }

◆ find_aida_base_column()

aida_base_col* tools::aida::ntuple::find_aida_base_column ( const std::string &  a_name,
bool  a_case_sensitive = true 
)
inline

Definition at line 562 of file aida_ntuple.

562  { //for opaw/panntu.
563  base_col* col = a_case_sensitive ? find_named<base_col>(m_cols,a_name) : find_named_case_insensitive<base_col>(m_cols,a_name);
564  if(!col) return 0;
565  return safe_cast<base_col,aida_base_col>(*col);
566  }

◆ find_column() [1/2]

template<class T >
aida_col<T>* tools::aida::ntuple::find_column ( const std::string &  a_name)
inline

Definition at line 548 of file aida_ntuple.

548  {
549  base_col* col = find_named<base_col>(m_cols,a_name);
550  if(!col) return 0;
551  return safe_cast<base_col, aida_col<T> >(*col);
552  }

◆ find_column() [2/2]

template<class T >
bool tools::aida::ntuple::find_column ( const std::string &  a_name,
aida_col< T > *&  a_col,
bool  a_case_sensitive = true 
)
inline

Definition at line 555 of file aida_ntuple.

555  { //for exlib::evaluator.
556  base_col* col = a_case_sensitive ? find_named<base_col>(m_cols,a_name) : find_named_case_insensitive<base_col>(m_cols,a_name);
557  if(!col) {a_col = 0;return false;}
558  a_col = safe_cast<base_col, aida_col<T> >(*col);
559  return a_col?true:false;
560  }

◆ get_row()

bool tools::aida::ntuple::get_row ( ) const
inline

Definition at line 568 of file aida_ntuple.

568  {
569  bool status = true;
570  tools_vforcit(base_col*,m_cols,it) {
571  if(!(*it)->fetch_entry()) status = false;
572  }
573  return status;
574  }

◆ id_class()

static cid tools::aida::ntuple::id_class ( )
inlinestatic

Definition at line 505 of file aida_ntuple.

505 {return 2000;} //for ntuple_binding.

◆ operator=()

ntuple& tools::aida::ntuple::operator= ( const ntuple a_from)
inline

Definition at line 523 of file aida_ntuple.

523  {
524  base_ntu::operator=(a_from);
525  return *this;
526  }

◆ s_class()

static const std::string& tools::aida::ntuple::s_class ( )
inlinestatic

Definition at line 507 of file aida_ntuple.

507  {
508  static const std::string s_v("tools::aida::ntuple");
509  return s_v;
510  }

◆ s_cls()

virtual const std::string& tools::aida::ntuple::s_cls ( ) const
inlinevirtual

Definition at line 515 of file aida_ntuple.

515 {return s_class();}

◆ set_binding()

bool tools::aida::ntuple::set_binding ( std::ostream &  a_out,
const ntuple_binding a_bd = ntuple_binding() 
)
inline

Definition at line 576 of file aida_ntuple.

576  {
577  tools_vforcit(column_binding,a_bd.columns(),itb) {
578  bool found = false;
579  tools_vforcit(base_col*,m_cols,itc) {
580  if((*itc)->name()==(*itb).name()) {
581  (*itc)->set_user_variable((*itb).user_obj());
582  found = true;
583  }
584  }
585  if(!found) {
586  a_out << "tools::aida::ntuple :"
587  << " binding name " << sout((*itb).name()) << " does not match any ntuple column."
588  << std::endl;
589  return false;
590  }
591  }
592  return true;
593  }

The documentation for this class was generated from the following file:
tools::aida::base_ntu::m_out
std::ostream & m_out
Definition: aida_ntuple:234
tools::find_named_case_insensitive
T * find_named_case_insensitive(const std::vector< T * > &a_vec, const std::string &a_name)
Definition: vfind:48
tools::uint64
unsigned long long uint64
Definition: typedefs:72
tools::aida::base_ntu::m_cols
std::vector< base_col * > m_cols
Definition: aida_ntuple:237
tools::aida::base_ntu::start
void start()
Definition: aida_ntuple:193
tools::aida::base_ntu::rows
uint64 rows() const
Definition: aida_ntuple:168
tools::aida::ntuple::s_class
static const std::string & s_class()
Definition: aida_ntuple:507
tools::aida::base_ntu::next
bool next()
Definition: aida_ntuple:194
tools::aida::base_ntu::cast
virtual void * cast(const std::string &a_class) const
Definition: aida_ntuple:91
tools::aida::base_ntu::base_ntu
base_ntu(std::ostream &a_out, const std::string &a_title)
Definition: aida_ntuple:96
tools::aida::base_ntu::operator=
base_ntu & operator=(const base_ntu &a_from)
Definition: aida_ntuple:129
tools::file::found
bool found(const std::string &a_file, const std::string &a_what, std::vector< std::string > &a_found)
Definition: file:507
tools_vforcit
#define tools_vforcit(a__T, a__v, a__it)
Definition: forit:7