26 #ifndef ROOT_TMVA_NodekNN 27 #define ROOT_TMVA_NodekNN 98 void Print(std::ostream& os,
const std::string &offset =
"")
const;
186 return fEvent.GetWeight();
255 assert(
fMod == depth % event.GetNVar() &&
"Wrong recursive depth in Node<>::Add");
269 fNodeL =
new Node<T>(
this, event, (depth + 1) % event.GetNVar());
278 fNodeR =
new Node<T>(
this, event, (depth + 1) % event.GetNVar());
297 os << offset <<
"-----------------------------------------------------------" << std::endl;
298 os << offset <<
"Node: mod " <<
fMod 300 <<
" with weight: " <<
GetWeight() << std::endl
304 os << offset <<
"Has left node " << std::endl;
307 os << offset <<
"Has right node" << std::endl;
311 os << offset <<
"PrInt_t left node " << std::endl;
315 os << offset <<
"PrInt_t right node" << std::endl;
339 if (!node || nfind < 1) {
349 if (!nlist.empty()) {
351 max_dist = nlist.back().second;
353 if (nlist.size() == nfind) {
370 if (nlist.size() < nfind) {
373 else if (nlist.size() == nfind) {
374 if (distance < max_dist) {
380 std::cerr <<
"TMVA::kNN::Find() - logic error in recursive procedure" << std::endl;
387 typename std::list<std::pair<const Node<T> *,
Float_t> >::iterator lit = nlist.begin();
390 for (; lit != nlist.end(); ++lit) {
391 if (distance < lit->second) {
399 nlist.insert(lit, std::pair<
const Node<T> *,
Float_t>(node, distance));
449 if (!node || !(nfind < 0.0)) {
459 if (!nlist.empty()) {
461 max_dist = nlist.back().second;
463 if (!(ncurr < nfind)) {
482 else if (!nlist.empty()) {
483 if (distance < max_dist) {
488 std::cerr <<
"TMVA::kNN::Find() - logic error in recursive procedure" << std::endl;
498 typename std::list<std::pair<const Node<T> *,
Float_t> >::iterator lit = nlist.begin();
501 for (; lit != nlist.end(); ++lit) {
502 if (distance < lit->second) {
509 lit = nlist.insert(lit, std::pair<
const Node<T> *,
Float_t>(node, distance));
511 for (; lit != nlist.end(); ++lit) {
513 if (!(ncurr < nfind)) {
519 if(lit != nlist.end())
521 nlist.erase(lit, nlist.end());
529 count +=
Find(nlist, node->
GetNodeL(), event, nfind, ncurr);
530 count +=
Find(nlist, node->
GetNodeR(), event, nfind, ncurr);
533 count +=
Find(nlist, node->
GetNodeR(), event, nfind, ncurr);
534 count +=
Find(nlist, node->
GetNodeL(), event, nfind, ncurr);
539 count +=
Find(nlist, node->
GetNodeL(), event, nfind, ncurr);
542 count +=
Find(nlist, node->
GetNodeR(), event, nfind, ncurr);
const Node * GetNodeR() const
static Vc_ALWAYS_INLINE int_v min(const int_v &x, const int_v &y)
Double_t distance(const TPoint2 &p1, const TPoint2 &p2)
const Node * Add(const T &event, UInt_t depth)
UInt_t Depth(const Node< T > *node)
const Node & operator=(const Node &)
Float_t GetVarMin() const
void SetNodeL(Node *node)
const Node * GetNodeP() const
const Node * GetNodeL() const
Float_t GetVarMax() const
Double_t GetWeight() const
const T & GetEvent() const
UInt_t Find(std::list< std::pair< const Node< T > *, Float_t > > &nlist, const Node< T > *node, const T &event, UInt_t nfind)
static Vc_ALWAYS_INLINE int_v max(const int_v &x, const int_v &y)
Abstract ClassifierFactory template that handles arbitrary types.
void SetNodeR(Node *node)
Float_t GetVarDis() const