11 #include <Math/DistFunc.h>
65 const bool nonLinearTransportFlags[2])
69 if (!node)
return NULL;
83 node->
mName = strdup(name);
84 if (!node->
mName)
return NULL;
109 return AddNode(name ? name : buffer, z, mdim, nonLinearFlags);
154 char *qstr = strdup(str->mString), *qqstr = qstr;
161 char *comma = strchr(qqstr,
',');
167 if (comma) *comma = 0;
178 char *semicolon = strchr(qqstr,
':');
182 _RETURN_(-1,
"'fired-node-num': no semicolon found!\n");
187 _RETURN_(-1,
"'fired-node-num': value >=0 expected!\n");
195 char *plus = strchr(qqstr,
'+');
228 if (!node->mName)
continue;
243 node->mNodeGroupNum*
sizeof(
void*));
244 assert(node->mNodeGroups);
245 node->mNodeGroups[node->mNodeGroupNum-1] = group;
257 _RETURN_(-1,
"'fired-node-num': limit too high!\n");
273 _RETURN_(-1,
"'--kalman-tuning fired-node-min' option missing!\n");
313 it->second->mFired =
false;
317 group->mFiredNodeNum = group->mNdfControlFlag = 0;
325 if (group->mFiredNodeNum) group->mNdfControlFlag = 1;
337 group->mFiredNodeNumMin = min;
382 if (node->GetZ() == from->
GetZ()) {
388 if (node->mNonLinearTransportFlags[(fb+1)%2] ||
400 from->
FR = from->
FF[fb];
410 if (end && node == end)
break;
432 node->CP->Add(from->
Q);
450 node->RPI->SetToSum(node->MMTX, node->V);
457 node->ep->SetToProduct(node->H, node->xp);
458 node->ep->SetToDifference(node->m, node->ep);
460 node->xf->SetToSum(node->xp,
SVEC);
466 node->LB->SetToDifference(
SU,
SMTX);
486 node->RF->SetToDifference(node->V, node->RF);
492 for(
unsigned iq=0; iq<node->GetMdim(); iq++)
500 node->rf->SetToProduct(node->H, node->xf);
501 node->rf->SetToDifference(node->m, node->rf);
504 node->MMTX->CopyFrom(node->RF);
507 node->rf->VectorLengthSquare(node->MMTX, &node->mFilterChiSquareIncrement);
511 node->mFilterChiSquareIncrement = 0.;
518 node->xf->CopyFrom(node->xp);
519 node->CF->CopyFrom(node->CP);
525 if (end && node == end)
break;
598 node->CS->CopyFrom(node->CF);
599 node->xs->CopyFrom(node->xf);
617 node->CS->SetToDifference(node->CP,
SMTX);
623 printf(
"CS[][] positivity check failed at Z=%7.2f\n", node->GetZ());
635 node->CS->CorrelationPrint();
648 node->xs->SetToSum(node->xp,
SVEC);
653 node->CM->CopyFrom(node->CS);
656 node->MMTX->CopyFrom(node->V);
666 node->CM->Subtract(
SMTX);
669 node->xm->SetToProduct(node->CM,
SVEC);
672 node->rm->SetToProduct(node->H, node->xm);
673 node->rm->SetToDifference(node->m, node->rm);
680 if (!node->mFired)
continue;
683 node->rs->SetToProduct(node->H, node->xs);
684 node->rs->SetToDifference(node->m, node->rs);
689 node->RS->SetToDifference(node->V, node->RS);
693 node->MMTX->CopyFrom(node->RS);
696 printf(
" --> Z=%7.1f, RS[0][0] = %20.15f\n", node->GetZ(), node->RS->KFM(0,0));
699 node->rs->VectorLengthSquare(node->MMTX, &node->mSmootherChiSquare);
700 if (node->mSmootherChiSquare <= 0.0) {
704 printf(
"%f: smother chi^2 = %f\n", node->GetZ(), node->mSmootherChiSquare);
708 node->mSmootherChiSquareCCDF =
709 ROOT::Math::chisquared_cdf_c(node->GetSmootherChiSquare(), node->GetMdim());
720 int gr, resettable = 1;
722 for(gr=0; gr<node->mNodeGroupNum; gr++) {
747 unsigned ret, outlier_order_violation = 0;
779 if (group->mNdfControlFlag &&
780 group->mFiredNodeNum < group->mFiredNodeNumMin)
789 double worst_smoother_prob =
797 !(mode & _TRUST_SMOOTHER_FCN_)) &&
799 !(mode & _TRUST_FILTER_FCN_)))
808 (mode & _TRUST_FILTER_FCN_) &&
810 (mode & _TRUST_SMOOTHER_FCN_))
828 printf(
"chi^2 = %8.2f -> prob %10.7f -> removing %s (chi^2 incr %8.2f)\n",