PandaRoot
PndMvaUtil.h File Reference
#include <typeinfo>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <cmath>
#include <cassert>

Go to the source code of this file.

Classes

struct  StepError
 Structure to hold the per step error values. More...
 
struct  PndMvaDistObj
 

Functions

bool CompLess (PndMvaDistObj const *a, PndMvaDistObj const *b)
 Less than, comparison funtion. More...
 
template<typename T >
T const & minFunct (T const &a, T const &b)
 
template<typename T >
bool compareL (T const *l, T const *r)
 Less than, comparison funtion. More...
 
template<typename Set1 , typename Set2 >
bool is_disjoint (Set1 const &set1, Set2 const &set2)
 
float ComputeDist (std::vector< float > const &EvtData, std::vector< float > const &Example)
 
int str2int (std::string const &str)
 
unsigned int str2Uint (std::string const &str)
 
std::string int2str (int n)
 

Function Documentation

◆ compareL()

template<typename T >
bool compareL ( T const *  l,
T const *  r 
)
inline

Less than, comparison funtion.

Definition at line 135 of file PndMvaUtil.h.

136 {
137  assert(l && r);
138  return ((*l) < (*r));
139 };

◆ CompLess()

bool CompLess ( PndMvaDistObj const *  a,
PndMvaDistObj const *  b 
)
inline

Less than, comparison funtion.

Definition at line 114 of file PndMvaUtil.h.

115 {
116  assert(a && b);
117  return ((*a).m_dist < (*b).m_dist);
118 };

◆ ComputeDist()

float ComputeDist ( std::vector< float > const &  EvtData,
std::vector< float > const &  Example 
)

Computes the Euclidean distance between two given vectors of event features.

Referenced by is_disjoint().

◆ int2str()

std::string int2str ( int  n)

Referenced by is_disjoint().

◆ is_disjoint()

template<typename Set1 , typename Set2 >
bool is_disjoint ( Set1 const &  set1,
Set2 const &  set2 
)

If 2 sets are disjoint.

Input two sorted (ASC) sequences.

Returns
true if the sets are disjoint.

NOTE: In some cases one might consider using std::set_intersection from <algorithm>

Definition at line 151 of file PndMvaUtil.h.

References ComputeDist(), int2str(), str2int(), and str2Uint().

152 {
153  // IF one of the sets is empty. O(1) true on empty sets per
154  // definition.
155  if (set1.empty() || set2.empty()) {
156  return true;
157  }
158  // Start and end iterators of the first sequence.
159  typename Set1::const_iterator it1 = set1.begin();
160  typename Set1::const_iterator it1End = set1.end();
161 
162  // Start and end iterators of the second sequence.
163  typename Set2::const_iterator it2 = set2.begin();
164  typename Set2::const_iterator it2End = set2.end();
165 
166  // This holds because the sequences are pre-sorted. O(1)
167  if (*it1 > *set2.rbegin() || *it2 > *set1.rbegin()) {
168  return true;
169  }
170 
171  // Investigate element-wise.
172  while ((it1 != it1End) && (it2 != it2End)) {
173  if (*it1 == *it2) {
174  return false;
175  }
176 
177  if (*it1 < *it2) {
178  it1++;
179  } else {
180  it2++;
181  }
182  } // WHILE
183  return true;
184 }

◆ minFunct()

template<typename T >
T const& minFunct ( T const &  a,
T const &  b 
)
inline

Binary Minimum function.

Definition at line 127 of file PndMvaUtil.h.

128 {
129  // or: return comp(a,b)?a:b; for the comp version
130  return (a < b) ? a : b;
131 };

◆ str2int()

int str2int ( std::string const &  str)

Referenced by is_disjoint().

◆ str2Uint()

unsigned int str2Uint ( std::string const &  str)

Referenced by is_disjoint().