342 for (
int i = 0;
i < 8;
i++) {
343 xwire[
i] = mpath->xWirePos(
i);
344 zwire[
i] = mpath->zWirePos(
i);
345 tTDCvdrift[
i] = mpath->tWireTDC(
i);
353 for (
int lay = 0; lay < 8; lay++) {
355 LogDebug(
"MuonPathAnalyzerInChamber") <<
"In fitPerLat " << lay <<
" xwire " << xwire[lay] <<
" zwire "
356 << zwire[lay] <<
" tTDCvdrift " << tTDCvdrift[lay];
357 xhit[lay] = xwire[lay] + (-1 + 2 * laterality[lay]) * 1000 * tTDCvdrift[lay];
359 LogDebug(
"MuonPathAnalyzerInChamber") <<
"In fitPerLat " << lay <<
" xhit " << xhit[lay];
370 for (
int lay = 0; lay < 8; lay++) {
371 if (present_layer[lay] == 0)
374 LogDebug(
"MuonPathAnalyzerInChamber")
375 <<
" For layer " << lay + 1 <<
" xwire[lay] " << xwire[lay] <<
" zwire " << zwire[lay] <<
" b " <<
b[lay];
377 LogDebug(
"MuonPathAnalyzerInChamber") <<
" xhit[lat][lay] " << xhit[lay];
378 cbscal = (-1 + 2 * laterality[lay]) *
b[lay] + cbscal;
379 zbscal = zwire[lay] *
b[lay] + zbscal;
380 czscal = (-1 + 2 * laterality[lay]) * zwire[lay] + czscal;
382 bbscal =
b[lay] *
b[lay] + bbscal;
383 zzscal = zwire[lay] * zwire[lay] + zzscal;
384 ccscal = (-1 + 2 * laterality[lay]) * (-1 + 2 * laterality[lay]) + ccscal;
394 cz = (cbscal * zbscal - czscal * bbscal) / (zzscal * bbscal - zbscal * zbscal);
395 cb = (czscal * zbscal - cbscal * zzscal) / (zzscal * bbscal - zbscal * zbscal);
397 zb = (czscal * cbscal - zbscal * ccscal) / (bbscal * ccscal - cbscal * cbscal);
398 zc = (zbscal * cbscal - czscal * bbscal) / (bbscal * ccscal - cbscal * cbscal);
400 bc = (zbscal * czscal - cbscal * zzscal) / (ccscal * zzscal - czscal * czscal);
401 bz = (cbscal * czscal - zbscal * ccscal) / (ccscal * zzscal - czscal * czscal);
407 for (
int lay = 0; lay < 8; lay++) {
408 if (present_layer[lay] == 0)
411 LogDebug(
"MuonPathAnalyzerInChamber")
412 <<
" For layer " << lay + 1 <<
" xwire[lay] " << xwire[lay] <<
" zwire " << zwire[lay] <<
" b " <<
b[lay];
413 c_tilde[lay] = (-1 + 2 * laterality[lay]) + cz * zwire[lay] + cb *
b[lay];
414 z_tilde[lay] = zwire[lay] + zb *
b[lay] + zc * (-1 + 2 * laterality[lay]);
415 b_tilde[lay] =
b[lay] + bc * (-1 + 2 * laterality[lay]) + bz * zwire[lay];
419 double xctilde = 0.0;
420 double xztilde = 0.0;
421 double xbtilde = 0.0;
422 double ctildectilde = 0.0;
423 double ztildeztilde = 0.0;
424 double btildebtilde = 0.0;
426 double rect0vdrift = 0.0;
427 double recslope = 0.0;
430 for (
int lay = 0; lay < 8; lay++) {
431 if (present_layer[lay] == 0)
433 xctilde = xhit[lay] * c_tilde[lay] + xctilde;
434 ctildectilde = c_tilde[lay] * c_tilde[lay] + ctildectilde;
435 xztilde = xhit[lay] * z_tilde[lay] + xztilde;
436 ztildeztilde = z_tilde[lay] * z_tilde[lay] + ztildeztilde;
437 xbtilde = xhit[lay] * b_tilde[lay] + xbtilde;
438 btildebtilde = b_tilde[lay] * b_tilde[lay] + btildebtilde;
442 rect0vdrift = xctilde / ctildectilde;
443 recslope = xztilde / ztildeztilde;
444 recpos = xbtilde / btildebtilde;
446 LogDebug(
"MuonPathAnalyzerInChamber") <<
" In fitPerLat Reconstructed values per lat "
447 <<
" rect0vdrift " << rect0vdrift;
448 LogDebug(
"MuonPathAnalyzerInChamber")
450 << recslope <<
" recpos " << recpos;
456 double recchi2 = 0.0;
457 int sign_tdriftvdrift = {0};
458 int incell_tdriftvdrift = {0};
459 int physical_slope = {0};
465 for (
int lay = 0; lay < 8; lay++) {
466 if (present_layer[lay] == 0)
468 rectdriftvdrift[lay] = tTDCvdrift[lay] - rect0vdrift / 1000;
470 LogDebug(
"MuonPathAnalyzerInChamber") << rectdriftvdrift[lay];
471 recres[lay] = xhit[lay] - zwire[lay] * recslope -
b[lay] * recpos - (-1 + 2 * laterality[lay]) * rect0vdrift;
472 if ((present_layer[lay] == 1) && (rectdriftvdrift[lay] < -0.1)) {
473 sign_tdriftvdrift = -1;
474 if (-0.1 - rectdriftvdrift[lay] > maxDif) {
475 maxDif = -0.1 - rectdriftvdrift[lay];
479 if ((present_layer[lay] == 1) && (
abs(rectdriftvdrift[lay]) > 21.1)) {
480 incell_tdriftvdrift = -1;
481 if (rectdriftvdrift[lay] - 21.1 > maxDif) {
482 maxDif = rectdriftvdrift[lay] - 21.1;
488 if (fabs(recslope / 10) > 1.3)
491 if (physical_slope == -1 &&
debug_)
492 LogDebug(
"MuonPathAnalyzerInChamber") <<
"Combination with UNPHYSICAL slope ";
493 if (sign_tdriftvdrift == -1 &&
debug_)
494 LogDebug(
"MuonPathAnalyzerInChamber") <<
"Combination with negative tdrift-vdrift ";
495 if (incell_tdriftvdrift == -1 &&
debug_)
496 LogDebug(
"MuonPathAnalyzerInChamber") <<
"Combination with tdrift-vdrift larger than half cell ";
498 for (
int lay = 0; lay < 8; lay++) {
499 if (present_layer[lay] == 0)
501 recchi2 = recres[lay] * recres[lay] + recchi2;
504 LogDebug(
"MuonPathAnalyzerInChamber")
505 <<
"In fitPerLat Chi2 " << recchi2 <<
" with sign " << sign_tdriftvdrift <<
" within cell "
506 << incell_tdriftvdrift <<
" physical_slope " << physical_slope;
509 if (
true && maxInt != -1) {
510 present_layer[maxInt] = 0;
512 LogDebug(
"MuonPathAnalyzerInChamber") <<
"We get rid of hit in layer " << maxInt;
516 if (!(sign_tdriftvdrift == -1) && !(incell_tdriftvdrift == -1) && !(physical_slope == -1)) {
517 mpath->setBxTimeValue((rect0vdrift /
DRIFT_SPEED) / 1000);
518 mpath->setTanPhi(-1 * recslope / 10);
519 mpath->setHorizPos(recpos / 10000);
520 mpath->setChiSquare(recchi2 / 100000000);
523 LogDebug(
"MuonPathAnalyzerInChamber")
525 <<
"t0 " << mpath->bxTimeValue() <<
" slope " << mpath->tanPhi() <<
" pos " << mpath->horizPos() <<
" chi2 "
526 << mpath->chiSquare() <<
" rawId " << mpath->rawId();