95 void Print(std::ostream& os,
const std::string &offset =
"")
const;
183 return fEvent.GetWeight();
253 assert(
fMod == depth % event.GetNVar() &&
"Wrong recursive depth in Node<>::Add");
264 return fNodeL->Add(event, depth + 1);
267 fNodeL =
new Node<T>(
this, event, (depth + 1) % event.GetNVar());
273 return fNodeR->Add(event, depth + 1);
276 fNodeR =
new Node<T>(
this, event, (depth + 1) % event.GetNVar());
295 os << offset <<
"-----------------------------------------------------------" << std::endl;
296 os << offset <<
"Node: mod " <<
fMod
298 <<
" with weight: " <<
GetWeight() << std::endl
302 os << offset <<
"Has left node " << std::endl;
305 os << offset <<
"Has right node" << std::endl;
309 os << offset <<
"PrInt_t left node " << std::endl;
310 fNodeL->Print(os, offset +
" ");
313 os << offset <<
"PrInt_t right node" << std::endl;
314 fNodeR->Print(os, offset +
" ");
336 if (!node || nfind < 1) {
346 if (!nlist.empty()) {
348 max_dist = nlist.back().second;
350 if (nlist.size() == nfind) {
355 if (value < node->GetVarMin() &&
367 if (nlist.size() < nfind) {
370 else if (nlist.size() == nfind) {
371 if (distance < max_dist) {
377 std::cerr <<
"TMVA::kNN::Find() - logic error in recursive procedure" << std::endl;
384 typename std::list<std::pair<const Node<T> *,
Float_t> >::iterator lit = nlist.begin();
387 for (; lit != nlist.end(); ++lit) {
388 if (distance < lit->second) {
396 nlist.insert(lit, std::pair<
const Node<T> *,
Float_t>(node, distance));
406 if (value < node->GetVarDis()) {
442 const TMVA::kNN::Node<T> *node,
const T &event,
const Double_t nfind,
Double_t ncurr)
445 if (!node || !(nfind < 0.0)) {
455 if (!nlist.empty()) {
457 max_dist = nlist.back().second;
459 if (!(ncurr < nfind)) {
464 if (value < node->GetVarMin() &&
478 else if (!nlist.empty()) {
479 if (distance < max_dist) {
484 std::cerr <<
"TMVA::kNN::Find() - logic error in recursive procedure" << std::endl;
494 typename std::list<std::pair<const Node<T> *,
Float_t> >::iterator lit = nlist.begin();
497 for (; lit != nlist.end(); ++lit) {
498 if (distance < lit->second) {
502 ncurr += lit -> first -> GetWeight();
505 lit = nlist.insert(lit, std::pair<
const Node<T> *,
Float_t>(node, distance));
507 for (; lit != nlist.end(); ++lit) {
508 ncurr += lit -> first -> GetWeight();
509 if (!(ncurr < nfind)) {
515 if(lit != nlist.end())
517 nlist.erase(lit, nlist.end());
524 if (value < node->GetVarDis()) {
525 count +=
Find(nlist, node->
GetNodeL(), event, nfind, ncurr);
526 count +=
Find(nlist, node->
GetNodeR(), event, nfind, ncurr);
529 count +=
Find(nlist, node->
GetNodeR(), event, nfind, ncurr);
530 count +=
Find(nlist, node->
GetNodeL(), event, nfind, ncurr);
535 count +=
Find(nlist, node->
GetNodeL(), event, nfind, ncurr);
538 count +=
Find(nlist, node->
GetNodeR(), event, nfind, ncurr);