296 {
297
298 bool retVal(true);
299
302
303 double deltaJac = 0.005;
304 double deltaNoise = 0.00001;
305 double deltaState = 3.E-6;
306
307 if (fx) {
308 deltaJac = 0.1;
309 deltaNoise = 0.1;
310 deltaState = 5.E-4;
311 }
312
316
317
318
319 TVector3
pos(gRandom->Gaus(0,0.1),gRandom->Gaus(0,0.1),gRandom->Gaus(0,0.1));
320 TVector3
mom(0, 0.5, gRandom->Gaus(0, 1));
322 mom.SetMag(gRandom->Uniform(2)+0.3);
323
324
325 TMatrixD jac_f, jac_fi, jac_b, jac_bi;
326 TMatrixDSym noise_f, noise_fi, noise_b, noise_bi;
327 TVectorD c_f, c_fi, c_b, c_bi;
328 TVectorD state_man, stateOrig_man;
329
330
333
334 static const double smear = 0.2;
335 TVector3 normal(mom);
336 normal.SetMag(1);
337 normal.SetXYZ(gRandom->Gaus(normal.X(), smear),
338 gRandom->Gaus(normal.Y(), smear),
339 gRandom->Gaus(normal.Z(), smear));
341
342 double rotAngleOrig = gRandom->Uniform(2.*TMath::Pi());
343 origPlanePtr->
rotate(rotAngleOrig);
345
347
349
350
351
353 normal.SetMag(1);
354 normal.SetXYZ(gRandom->Gaus(normal.X(), smear),
355 gRandom->Gaus(normal.Y(), smear),
356 gRandom->Gaus(normal.Z(), smear));
360
361 double rotAngle = gRandom->Uniform(2.*TMath::Pi());
362 planePtr->
rotate(rotAngle);
364
365
366
367
368
369
370
371
372 TMatrixD jac_f_num;
374
375
376
378 try {
379
381
382 extrapolatedState = state;
385 }
387 std::cerr << e.
what();
388
389 delete rep;
391 return false;
392 }
393
394
395 try {
396
398
401 }
403 std::cerr << e.
what();
404
405 delete rep;
407 return false;
408 }
409
410
411
412 if (!((origState.getState() - state.getState()).Abs() < deltaState) ) {
413 std::cout << "(origState.getState() - state.getState()) ";
414 (origState.getState() - state.getState()).Print();
415
416 retVal = false;
417 }
418
419
420 if (!((jac_f * origState.getState() + c_f - extrapolatedState.
getState()).Abs() < deltaState) ||
421 !((jac_bi * origState.getState() + c_bi - extrapolatedState.
getState()).Abs() < deltaState) ||
422 !((jac_b * extrapolatedState.
getState() + c_b - origState.getState()).Abs() < deltaState) ||
423 !((jac_fi * extrapolatedState.
getState() + c_fi - origState.getState()).Abs() < deltaState) ) {
424
425 std::cout << "(jac_f * origState.getState() + c_f - extrapolatedState.getState()) ";
426 (jac_f * origState.getState() + c_f - extrapolatedState.
getState()).Print();
427 std::cout << "(jac_bi * origState.getState() + c_bi - extrapolatedState.getState()) ";
428 (jac_bi * origState.getState() + c_bi - extrapolatedState.
getState()).Print();
429 std::cout << "(jac_b * extrapolatedState.getState() + c_b - origState.getState()) ";
430 (jac_b * extrapolatedState.
getState() + c_b - origState.getState()).Print();
431 std::cout << "(jac_fi * extrapolatedState.getState() + c_fi - origState.getState()) ";
432 (jac_fi * extrapolatedState.
getState() + c_fi - origState.getState()).Print();
433
434 retVal = false;
435 }
436
438 retVal = false;
439 }
440
441
442
444 std::cout << "jac_f = "; jac_f.Print();
445 std::cout << "jac_bi = "; jac_bi.Print();
446 std::cout << std::endl;
447
448 retVal = false;
449 }
450
451
453 std::cout << "jac_b = "; jac_b.Print();
454 std::cout << "jac_fi = "; jac_fi.Print();
455 std::cout << std::endl;
456
457 retVal = false;
458 }
459
460
462 std::cout << "noise_f = "; noise_f.Print();
463 std::cout << "noise_bi = "; noise_bi.Print();
464 std::cout << std::endl;
465
466 retVal = false;
467 }
468
469
471 std::cout << "noise_b = "; noise_b.Print();
472 std::cout << "noise_fi = "; noise_fi.Print();
473 std::cout << std::endl;
474
475 retVal = false;
476 }
477
478
479 if (!fx) {
480
482 std::cout << "jac_f = "; jac_f.Print();
483 std::cout << "jac_f_num = "; jac_f_num.Print();
484 std::cout << std::endl;
485
486 retVal = false;
487 }
488 }
489
490 delete rep;
492
493 return retVal;
494}
void calcJacobianNumerically(const genfit::StateOnPlane &origState, const genfit::SharedPlanePtr destPlane, TMatrixD &jacobian) const
Calculate Jacobian of transportation numerically. Slow but accurate. Can be used to validate (semi)an...
virtual void getForwardJacobianAndNoise(TMatrixD &jacobian, TMatrixDSym &noise, TVectorD &deltaState) const =0
Get the jacobian and noise matrix of the last extrapolation.
virtual void getBackwardJacobianAndNoise(TMatrixD &jacobian, TMatrixDSym &noise, TVectorD &deltaState) const =0
Get the jacobian and noise matrix of the last extrapolation if it would have been done in opposite di...
void rotate(double angle)
rotate u and v around normal. Angle is in rad. More for debugging than for actual use.
void setNoEffects(bool opt=true)
static MaterialEffects * getInstance()
const TVectorD & getState() const
bool compareMatrices(const TMatrixTBase< double > &A, const TMatrixTBase< double > &B, double maxRelErr)