9#include <top/reconstruction_cpp/PDFConstructor.h>
10#include <top/reconstruction_cpp/TOPRecoManager.h>
11#include <top/reconstruction_cpp/func.h>
12#include <top/geometry/TOPGeometryPar.h>
13#include <framework/logging/Logger.h>
37 if (not track.isValid()) {
38 B2ERROR(
"TOP::PDFConstructor: TOPTrack is not valid, cannot continue");
44 B2ERROR(
"TOP::PDFConstructor: missing reconstruction objects, cannot continue");
48 m_beta = track.getBeta(hypothesis, overrideMass);
49 m_yScanner->prepare(track.getMomentumMag(),
m_beta, track.getLengthInQuartz());
50 m_tof = track.getTOF(hypothesis, 0, overrideMass);
62 const auto& pixelPositions =
m_yScanner->getPixelPositions();
63 int numPixels = pixelPositions.getNumPixels();
67 unsigned lastPmtType = 0;
68 for (
int pixelID = 1; pixelID <= numPixels; pixelID++) {
69 auto pmtType = pixelPositions.get(pixelID).pmtType;
70 if (not tts or pmtType != lastPmtType) {
71 tts = &geo->getTTS(pmtType);
72 lastPmtType = pmtType;
87 if (signalPDF.getPDFPeaks().empty())
continue;
115 if (
m_track.getEmissionPoint().position.Z() > prism.zR) {
140 const auto& pixelPositions =
m_yScanner->getPixelPositions();
146 double xmi = 0, xma = 0;
147 bool ok =
rangeOfX(prism.zD, xmi, xma);
154 for (
int k = kmi; k <= kma; k++) {
155 for (
unsigned col = 0; col < pixelPositions.getNumPixelColumns(); col++) {
156 const auto& pixel = pixelPositions.get(col + 1);
157 if (pixel.Dx == 0)
continue;
159 if (xD < xmi or xD > xma)
continue;
171 const auto& emiPoint =
m_track.getEmissionPoint().position;
175 double xmi = 0, xma = 0;
176 bool ok =
rangeOfX(mirror.zb, xmi, xma);
183 double xE = emiPoint.X();
184 double zE = emiPoint.Z();
185 double Ah = bar.A / 2;
186 for (
int k = kmi; k <= kma; k++) {
189 double xL =
func::clip(-Ah, k, bar.A, xmi, xma);
190 double xR =
func::clip(Ah, k, bar.A, xmi, xma);
199 const auto& pixelPositions =
m_yScanner->getPixelPositions();
205 std::vector<double> xDs;
206 double minLen = 1e10;
209 if (xDs.size() < 2)
return;
214 std::sort(xDs.begin(), xDs.end());
215 double xmi = xDs.front();
216 double xma = xDs.back();
223 for (
int k = kmi; k <= kma; k++) {
224 for (
unsigned col = 0; col < pixelPositions.getNumPixelColumns(); col++) {
225 const auto& pixel = pixelPositions.get(col + 1);
226 if (pixel.Dx == 0)
continue;
228 if (xD < xmi or xD > xma)
continue;
230 setSignalPDF(reflected, col, xD, prism.zD, Nxm, xmMin, xmMax);
241 if (i0 < 0)
return false;
244 for (
unsigned i = 0; i < 2; i++) {
247 const auto& sol = solutions[i0];
248 xDs.push_back(sol.xD);
249 minLen = std::min(minLen, sol.len);
259 const double precision = 0.01;
262 double y1 =
deltaXD(x1, sol, xD);
263 if (isnan(y1))
return false;
267 double step = -dFic_dx * y1;
268 for (
int i = 1; i < 20; i++) {
269 double x2 = step * i;
270 double y2 =
deltaXD(x2, sol, xD);
271 if (isnan(y2))
return false;
277 for (
int k = 0; k < 20; k++) {
278 double x = (x2 + x3) / 2;
279 double y =
deltaXD(x, sol, xD);
280 if (isnan(y))
return false;
289 if (y2 * y1 > 0)
return false;
293 for (
int k = 0; k < 20; k++) {
294 double x = (x1 + x2) / 2;
295 double y =
deltaXD(x, sol, xD);
296 if (isnan(y))
return false;
321 for (
int i = 0; i < 10; i++) {
326 if (not ok)
return false;
329 for (
int i = 0; i < 10; i++) {
334 if (not ok)
return false;
337 for (
int i = 0; i < 10; i++) {
338 ok =
raytrace(rayTracer_dFic, 0, 0, dFic);
342 if (not ok)
return false;
346 double dLen_dL = (rayTracer_dL.getPropagationLen() -
m_fastRaytracer->getPropagationLen()) / dL;
347 double dLen_de = (rayTracer_de.getPropagationLen() -
m_fastRaytracer->getPropagationLen()) / de;
348 double dLen_dFic = (rayTracer_dFic.getPropagationLen() -
m_fastRaytracer->getPropagationLen()) / dFic;
350 double dyB_dL = (rayTracer_dL.getYB() -
m_fastRaytracer->getYB()) / dL;
351 double dyB_de = (rayTracer_de.getYB() -
m_fastRaytracer->getYB()) / de;
352 double dyB_dFic = (rayTracer_dFic.getYB() -
m_fastRaytracer->getYB()) / dFic;
356 double dx_dFic = (rayTracer_dFic.getXD() -
m_fastRaytracer->getXD()) / dFic;
358 if (dx_dFic == 0)
return false;
362 D.dLen_dx = dLen_dFic / dx_dFic;
363 D.dLen_de = dLen_de - dLen_dFic * dx_de / dx_dFic;
364 D.dLen_dL = dLen_dL - dLen_dFic * dx_dL / dx_dFic;
366 D.dyB_dx = dyB_dFic / dx_dFic;
367 D.dyB_de = dyB_de - dyB_dFic * dx_de / dx_dFic;
368 D.dyB_dL = dyB_dL - dyB_dFic * dx_dL / dx_dFic;
370 D.dFic_dx = 1 / dx_dFic;
371 D.dFic_de = - dx_de / dx_dFic;
372 D.dFic_dL = - dx_dL / dx_dFic;
380 const auto& emi =
m_track.getEmissionPoint(dL);
381 const auto& trk = emi.trackAngles;
384 double fic =
m_Fic + dFic;
385 double cosFic = cos(fic);
386 double sinFic = sin(fic);
387 double a = trk.cosTh * cer.sinThc * cosFic + trk.sinTh * cer.cosThc;
388 double b = cer.sinThc * sinFic;
389 double kx = a * trk.cosFi - b * trk.sinFi;
390 double ky = a * trk.sinFi + b * trk.cosFi;
391 double kz = trk.cosTh * cer.cosThc - trk.sinTh * cer.sinThc * cosFic;
420 double dTime =
m_fastRaytracer->getPropagationLenDelta() / speedOfLightQuartz;
424 double dt_dx = D.dLen_dx / speedOfLightQuartz;
428 double sigmaScat = D.dLen_de *
m_yScanner->getSigmaScattering() / speedOfLightQuartz;
431 double sigmaAlpha = D.dLen_de *
m_yScanner->getSigmaAlpha() / speedOfLightQuartz;
434 const auto& pixel =
m_yScanner->getPixelPositions().get(col + 1);
435 double L =
m_track.getLengthInQuartz();
438 double wid0 = (pow(dt_dx * pixel.Dx, 2) + pow(dt_dL * L, 2) + pow(dTime, 2)) / 12 + pow(sigmaScat, 2) +
439 pow(sigmaAlpha, 2) * Ny_eff;
442 double wid = wid0 + pow(dt_de *
m_yScanner->getRMSEnergy(), 2);
446 const auto& atPrismEntrance = photonStates[photonStates.size() - 2];
447 double dydz = atPrismEntrance.getKy() / atPrismEntrance.getKz();
452 double time =
m_tof + Len / speedOfLightQuartz;
453 doScan =
m_track.isScanRequired(col, time, wid);
456 m_yScanner->expand(col, yB, dydz, D, Ny_eff, doScan);
458 double numPhotons =
m_yScanner->getNumPhotons() * std::abs(D.dFic_dx * pixel.Dx);
461 for (
const auto& result :
m_yScanner->getResults()) {
462 double RQE =
m_yScanner->getPixelEfficiencies().get(result.pixelID);
463 if (RQE == 0)
continue;
465 double dE = result.e0 -
m_yScanner->getMeanEnergy();
466 double propLen = Len + D.dLen_de * dE;
470 peak.
t0 =
m_tof + propLen / speedOfLight;
471 peak.
wid = wid0 + dt_de * dt_de * result.sigsq;
474 signalPDF.append(peak);
481 extra.
sige = result.sigsq;
492 const auto& firstState = photonStates.front();
493 extra.
kxE = firstState.getKx();
494 extra.
kyE = firstState.getKy();
495 extra.
kzE = firstState.getKz();
496 const auto& lastState = photonStates.back();
497 extra.
kxD = lastState.getKx();
498 extra.
kyD = lastState.getKy();
499 extra.
kzD = lastState.getKz();
501 signalPDF.append(extra);
512 double surf =
m_yScanner->getSurfaceReflectivity(std::abs(nx) + std::abs(ny));
513 double p = exp(-propLen / bulk) * surf;
521 if (maxLen < 0)
return false;
523 const auto& emission =
m_track.getEmissionPoint();
524 const auto& trk = emission.trackAngles;
529 double dz = z - emission.position.Z();
530 double cosFicLimit = (trk.cosTh * cer.cosThc - dz / maxLen) / (trk.sinTh * cer.sinThc);
531 double cosLimit = (dz > 0) ? cosFicLimit : -cosFicLimit;
532 if (cosLimit < -1)
return false;
534 std::vector<double> xmima;
535 double x0 = emission.position.X();
537 xmima.push_back(x0 - maxLen);
538 xmima.push_back(x0 + maxLen);
540 double a = trk.cosTh * cer.sinThc * cosFicLimit + trk.sinTh * cer.cosThc;
541 double b = cer.sinThc *
sqrt(1 - cosFicLimit * cosFicLimit);
542 xmima.push_back(x0 + maxLen * (a * trk.cosFi - b * trk.sinFi));
543 xmima.push_back(x0 + maxLen * (a * trk.cosFi + b * trk.sinFi));
544 std::sort(xmima.begin(), xmima.end());
551 double theta = acos(trk.cosTh);
552 if (dz < 0) theta = M_PI - theta;
554 double thetaCer = acos(cer.cosThc);
555 if (theta - thetaCer >= M_PI / 2)
return false;
557 std::vector<double> dxdz;
558 double a = -cos(theta + thetaCer) * cos(theta - thetaCer);
559 double b = sin(2 * theta) * trk.cosFi;
560 double c = pow(trk.sinFi * cer.sinThc, 2) - pow(trk.cosFi, 2) * sin(theta + thetaCer) * sin(theta - thetaCer);
561 double D = b * b - 4 * a * c;
562 if (D < 0)
return true;
565 dxdz.push_back((-b - D) / 2 / a);
566 dxdz.push_back((-b + D) / 2 / a);
568 if (b == 0)
return true;
569 dxdz.push_back(-c / b);
570 dxdz.push_back(copysign(INFINITY, b));
572 std::vector<double> cosFic(2, cosLimit);
573 for (
int i = 0; i < 2; i++) {
574 if (std::abs(dxdz[i]) < INFINITY) {
575 double aa = (dxdz[i] * cos(theta) - trk.cosFi * sin(theta)) * cer.cosThc;
576 double bb = (dxdz[i] * sin(theta) + trk.cosFi * cos(theta)) * cer.sinThc;
577 double dd = trk.sinFi * cer.sinThc;
578 cosFic[i] = aa * bb / (bb * bb + dd * dd);
579 double kz = cos(theta) * cer.cosThc - sin(theta) * cer.sinThc * cosFic[i];
580 if (kz < 0) dxdz[i] = copysign(INFINITY, dxdz[1 - i] - dxdz[i]);
583 if (dxdz[0] > dxdz[1]) {
584 std::reverse(dxdz.begin(), dxdz.end());
585 std::reverse(cosFic.begin(), cosFic.end());
587 for (
int i = 0; i < 2; i++) {
588 if (cosFic[i] < cosLimit) xmima[i] = x0 + dxdz[i] * dz;
592 xmi = std::max(xmima[0], x0 - maxLen);
593 xma = std::min(xmima[1], x0 + maxLen);
601 double z =
sqrt(1 - x * x);
602 double kx = (x - xe);
603 double kz = (z - ze);
604 double s = 2 * (kx * x + kz * z);
605 double qx = kx - s * x;
606 double qz = kz - s * z;
608 double der_z = -x / z;
609 double der_s = 2 * (kx + der_z * kz);
610 double der_qx = (1 - s) - der_s * x;
611 double der_qz = (1 - s) * der_z - der_s * z;
613 return 1 - der_z * qx / qz + (zd - z) * (der_qx * qz - der_qz * qx) / (qz * qz);
627 double xe = (xE - mirror.
xc) / mirror.
R;
628 double ze = (zE - mirror.
zc) / mirror.
R;
629 double zd = (zD - mirror.
zc) / mirror.
R;
633 double x1 = (-Ah - mirror.
xc) / mirror.
R;
635 if (y1 != y1 or std::abs(y1) == INFINITY)
return -Ah;
637 double x2 = (Ah - mirror.
xc) / mirror.
R;
639 if (y2 != y2 or std::abs(y2) == INFINITY)
return -Ah;
641 if (y1 * y2 > 0)
return -Ah;
643 for (
int i = 0; i < 50; i++) {
644 double x = (x1 + x2) / 2;
646 if (y != y or std::abs(y) == INFINITY)
return -Ah;
654 double x = (x1 + x2) / 2;
656 return x * mirror.
R + mirror.
xc;
663 const auto& pixelPositions =
m_yScanner->getPixelPositions();
667 double xE =
m_track.getEmissionPoint().position.X();
668 int nxmi = (xE > 0) ? 0 : -1;
669 int nxma = (xE > 0) ? 1 : 0;
671 for (
const auto& pixel : pixelPositions.getPixels()) {
672 if (not
m_yScanner->getPixelMasks().isActive(pixel.ID))
continue;
673 double RQE =
m_yScanner->getPixelEfficiencies().get(pixel.ID);
674 if (RQE == 0)
continue;
676 for (
int Nxe = nxmi; Nxe <= nxma; Nxe++) {
677 for (
size_t k = 0; k < prism.unfoldedWindows.size(); k++) {
679 if (sol.len == 0 or std::abs(sol.L) >
m_track.getLengthInQuartz() / 2)
continue;
682 if (not ok)
continue;
683 int Nye = k - prism.k0;
689 double slope = lastState.getKy() / lastState.getKz();
690 double dz = prism.zD - prism.zFlat;
691 double y2 = std::min(pixel.yc + pixel.Dy / 2, prism.yUp + slope * dz);
692 double y1 = std::max(pixel.yc - pixel.Dy / 2, prism.yDown + slope * dz);
694 if (Dy < 0)
continue;
697 for (
int i = 0; i < 4; i++) {
703 if (not ok)
continue;
707 for (
int i = 0; i < 4; i++) {
713 if (not ok)
continue;
717 for (
int i = 0; i < 4; i++) {
723 if (not ok)
continue;
726 double dx_dL = (lastState_dL.getX() - lastState.getX()) / dL;
727 double dy_dL = (lastState_dL.getY() - lastState.getY()) / dL;
728 double dx_dFic = (lastState_dFic.getX() - lastState.getX()) / dFic;
729 double dy_dFic = (lastState_dFic.getY() - lastState.getY()) / dFic;
730 double Jacobi = dx_dL * dy_dFic - dy_dL * dx_dFic;
731 double numPhotons =
m_yScanner->getNumPhotonsPerLen() * pixel.Dx * Dy / std::abs(Jacobi) * RQE;
733 double dLen_de = (lastState_de.getPropagationLen() - lastState.getPropagationLen()) / de;
734 double dLen_dL = (lastState_dL.getPropagationLen() - lastState.getPropagationLen()) / dL;
735 double dLen_dFic = (lastState_dFic.getPropagationLen() - lastState.getPropagationLen()) / dFic;
738 double dt_dL = dLen_dL / speedOfLightQuartz;
739 double dt_dFic = dLen_dFic / speedOfLightQuartz;
741 double chromatic = pow(dt_de *
m_yScanner->getRMSEnergy(), 2);
743 double DL = (dy_dFic * pixel.Dx - dx_dFic * pixel.Dy) / Jacobi;
744 double DFic = (dx_dL * pixel.Dy - dy_dL * pixel.Dx) / Jacobi;
745 double paralax = (pow(dt_dL * DL, 2) + pow(dt_dFic * DFic, 2)) / 12;
747 double scattering = pow(dLen_de *
m_yScanner->getSigmaScattering() / speedOfLightQuartz, 2);
751 peak.
wid = chromatic + paralax + scattering;
752 peak.
nph = 1 - exp(-numPhotons);
753 peak.
fic = atan2(sol.sinFic, sol.cosFic);
754 signalPDF.append(peak);
764 extra.
xD = lastState.getXD();
765 extra.
yD = lastState.getYD();
766 extra.
zD = lastState.getZD();
767 extra.
kxE = firstState.getKx();
768 extra.
kyE = firstState.getKy();
769 extra.
kzE = firstState.getKz();
770 extra.
kxD = lastState.getKx();
771 extra.
kyD = lastState.getKy();
772 extra.
kzD = lastState.getKz();
774 signalPDF.append(extra);
785 const auto& emi =
m_track.getEmissionPoint(sol.
L + dL);
786 const auto& trk = emi.trackAngles;
795 double cosFic = sol.
cosFic * cosDFic - sol.
sinFic * sinDFic;
796 double sinFic = sol.
sinFic * cosDFic + sol.
cosFic * sinDFic;
797 double a = trk.cosTh * cer.sinThc * cosFic + trk.sinTh * cer.cosThc;
798 double b = cer.sinThc * sinFic;
799 double kx = a * trk.cosFi - b * trk.sinFi;
800 double ky = a * trk.sinFi + b * trk.cosFi;
801 double kz = trk.cosTh * cer.cosThc - trk.sinTh * cer.sinThc * cosFic;
813 const auto& win = prism.unfoldedWindows[k];
814 double dz = std::abs(prism.zD - prism.zFlat);
816 pixel.
yc * win.sy + win.y0 + win.ny * dz,
817 pixel.
yc * win.sz + win.z0 + win.nz * dz);
820 for (
int iter = 0; iter < 100; iter++) {
822 if (std::abs(sol.L) >
m_track.getLengthInQuartz() / 2)
return sol;
823 if (std::abs(sol.L - L) < 0.01)
return sol;
826 B2DEBUG(20,
"TOP::PDFConstructor::prismSolution: iterations not converging");
833 const auto& emi =
m_track.getEmissionPoint(L);
837 auto r = rD - emi.position;
838 const auto& trk = emi.trackAngles;
839 double xx = r.X() * trk.cosFi + r.Y() * trk.sinFi;
840 double y = -r.X() * trk.sinFi + r.Y() * trk.cosFi;
841 double x = xx * trk.cosTh - r.Z() * trk.sinTh;
842 double z = xx * trk.sinTh + r.Z() * trk.cosTh;
846 double rho =
sqrt(x * x + y * y);
850 sol.
len = rho / cer.sinThc;
851 sol.
L = L + z - sol.
len * cer.cosThc;
863 B2ERROR(
"TOP::PDFConstructor::getLogL(): object status is invalid - cannot provide log likelihood");
870 double f =
pdfValue(hit.pixelID, hit.time, hit.timeErr);
874 B2ERROR(
"TOP::PDFConstructor::getLogL(): PDF value is zero or negative"
876 <<
LogVar(
"pixelID", hit.pixelID) <<
LogVar(
"time", hit.time) <<
LogVar(
"PDFValue", f));
891 B2ERROR(
"TOP::PDFConstructor::getLogL(): object status is invalid - cannot provide log likelihood");
897 if (hit.time < minTime or hit.time > maxTime)
continue;
898 double f =
pdfValue(hit.pixelID, hit.time - t0, hit.timeErr, sigt);
902 B2ERROR(
"TOP::PDFConstructor::getLogL(): PDF value is zero or negative"
904 <<
LogVar(
"pixelID", hit.pixelID) <<
LogVar(
"time", hit.time) <<
LogVar(
"PDFValue", f));
919 B2ERROR(
"TOP::PDFConstructor::getBackgroundLogL(): object status is invalid - cannot provide log likelihood");
927 if (hit.time < minTime or hit.time > maxTime)
continue;
932 B2ERROR(
"TOP::PDFConstructor::getBackgroundLogL(): PDF value is zero or negative"
934 <<
LogVar(
"pixelID", hit.pixelID) <<
LogVar(
"time", hit.time) <<
LogVar(
"PDFValue", f));
945 const std::vector<PDFConstructor::LogL>&
949 B2ERROR(
"TOP::PDFConstructor::getPixelLogLs(): object status is invalid - cannot provide log likelihoods");
956 if (hit.time < minTime or hit.time > maxTime)
continue;
957 double f =
pdfValue(hit.pixelID, hit.time - t0, hit.timeErr, sigt);
961 B2ERROR(
"TOP::PDFConstructor::getPixelLogLs(): PDF value is zero or negative"
963 <<
LogVar(
"pixelID", hit.pixelID) <<
LogVar(
"time", hit.time) <<
LogVar(
"PDFValue", f));
967 unsigned k = hit.pixelID - 1;
971 LL.effectiveSignalYield +=
m_f0 / f;
983 for (
const auto* other :
m_pdfOtherTracks) bfot += other->getExpectedDeltaPhotons(minTime, maxTime);
987 unsigned k = signalPDF.getPixelID() - 1;
988 double phot = signalPDF.getIntegral(minTime, maxTime) *
m_signalPhotons + bfot * pixelPDF[k];
990 const auto& otherPDFs = other->getSignalPDF();
991 phot += otherPDFs[k].getIntegral(minTime, maxTime) * other->getExpectedSignalPhotons();
1021 for (
const auto& peak : signalPDF.getPDFPeaks()) {
1022 minT0 = std::min(minT0, peak.t0);
1023 for (
const auto& gaus : signalPDF.getTTS()->getTTS()) {
1024 double sig2 = peak.wid + gaus.sigma * gaus.sigma + wid0;
1025 double x = pow(hit.
time - peak.t0 - gaus.position, 2) / sig2;
1026 if (x > 100)
continue;
1027 double wt = signalFract * peak.nph * gaus.fraction /
sqrt(2 * M_PI * sig2) * exp(-x / 2);
1038 if (sum == 0)
return;
1039 for (
size_t i = i0; i <
m_pulls.size(); i++)
m_pulls[i].wt /= sum;
Provides a type-safe way to pass members of the chargedStableSet set.
static const double speedOfLight
[cm/ns]
Nominal time transition spread of PMT.
Fast photon propagation in quartz optics.
int getNyb() const
Returns signed number of reflections in y after mirror and before prism.
const std::vector< PhotonState > & getExtraStates() const
Returns extra states.
int getNxm() const
Returns signed number of reflections in x before mirror.
int getNxb() const
Returns signed number of reflections in x after mirror and before prism.
void propagate(const PhotonState &photon, bool averaging=false) const
Propagate photon to photo-detector plane.
int getNym() const
Returns signed number of reflections in y before mirror.
int getNxe() const
Returns signed number of reflections in x inside prism.
bool getPropagationStatus() const
Returns propagation status.
int getNye() const
Returns signed number of reflections in y inside prism.
double m_cosTotal
cosine of total reflection angle
void setSignalPDF_prism()
Sets signal PDF for track crossing prism.
int m_ncallsExpandPDF[3]
number of calls to expandSignalPDF, indexed with SignalPDF::EPeakType
void setSignalPDF()
Sets signal PDF.
double m_bkgRate
estimated background hit rate
double m_beta
particle hypothesis beta
const BackgroundPDF * getBackgroundPDF() const
Returns background PDF.
const InverseRaytracer::CerenkovAngle & cerenkovAngle(double dE=0)
Returns cosine and sine of cerenkov angle.
bool detectionPositionX(double xM, int Nxm, std::vector< double > &xDs, double &minLen)
Calculates unfolded detection position from known reflection position on the mirror and emission poin...
double m_minPeakT0
position of the earliest PDF peak of all pixels [ns]
const YScanner * m_yScanner
PDF expander in y.
std::vector< SignalPDF > m_signalPDFs
parameterized signal PDF in pixels (index = pixelID - 1)
void setSignalPDF_reflected()
Sets signal PDF for reflected photons.
LogL getBackgroundLogL() const
Returns extended log likelihood for background hypothesis using default time window.
PrismSolution prismSolution(const PixelPositions::PixelData &pixel, unsigned k, int nx)
General solution of inverse raytracing in prism: iterative procedure calling basic solution.
LogL getLogL() const
Returns extended log likelihood (using the default time window)
double m_maxTime
time window upper edge
const InverseRaytracer * m_inverseRaytracer
inverse ray-tracer
double m_minTime
time window lower edge
double getExpectedDeltaPhotons() const
Returns the expected number of delta-ray photons within the default time window.
EStoreOption m_storeOption
signal PDF storing option
double m_Fic
temporary storage for Cerenkov azimuthal angle
double m_sumOfPeaks
sum over the pixels of the normalized number of photons in all peaks
bool m_hasPeaks
true if at least one pixel has a PDF peak
bool setDerivatives(YScanner::Derivatives &D, double dL, double de, double dFic)
Sets the derivatives (numerically) using forward ray-tracing.
double m_groupIndex
group refractive index at mean photon energy
std::vector< const PDFConstructor * > m_pdfOtherTracks
most probable PDF's of other tracks in the module
double m_bkgPhotons
expected number of uniform background photons
const std::vector< LogL > & getPixelLogLs(double t0, double sigt=0) const
Returns extended log likelihoods in pixels for PDF shifted in time.
double propagationLosses(double E, double propLen, int nx, int ny, SignalPDF::EPeakType type) const
Returns photon propagation losses (bulk absorption, surface reflectivity, mirror reflectivity)
int getModuleID() const
Returns slot ID.
double m_deltaPhotons
expected number of delta-ray photons
const std::vector< Pull > & getPulls() const
Returns photon pulls w.r.t PDF peaks.
double getCosCerenkovAngle(double E) const
Returns cosine of Cerenkov angle at given photon energy.
double m_maxPeakT0
position of the latest PDF peak of all pixels [ns]
double m_signalPhotons
expected number of signal photons
static double derivativeOfReflectedX(double x, double xe, double ze, double zd)
Returns the derivative of reflected position at given x.
void appendPulls(const TOPTrack::SelectedHit &hit) const
Appends pulls of a photon hit.
double getExpectedPhotons() const
Returns the expected number of all photons within the default time window.
bool m_valid
cross-check flag, true if track is valid and all the pointers above are valid
DeltaRayPDF m_deltaRayPDF
delta-ray PDF
double deltaXD(double dFic, const InverseRaytracer::Solution &sol, double xD)
Returns the difference in xD between ray-traced solution rotated by dFic and input argument.
bool doRaytracingCorrections(const InverseRaytracer::Solution &sol, double dFic_dx, double xD)
Corrects the solution of inverse ray-tracing with fast ray-tracing.
bool raytrace(const FastRaytracer &rayTracer, double dL=0, double de=0, double dFic=0)
Forward ray-tracing (called by setDerivatives)
std::vector< Pull > m_pulls
photon pulls w.r.t PDF peaks
const FastRaytracer * m_fastRaytracer
fast ray-tracer
EStoreOption
Options for storing signal PDF parameters.
@ c_Reduced
only PDF peak data
static double findReflectionExtreme(double xE, double zE, double zD, int Nxm, double A, const RaytracerBase::Mirror &mirror)
Finds the position on the mirror of the extreme reflection.
const TOPTrack & m_track
temporary reference to track at TOP
std::vector< LogL > m_pixelLLs
pixel log likelihoods (index = pixelID - 1)
EPDFOption m_PDFOption
signal PDF construction option
const BackgroundPDF * m_backgroundPDF
background PDF
EPDFOption
Signal PDF construction options.
@ c_Optimal
y dependent only where necessary
@ c_Fine
y dependent everywhere
double pdfValue(int pixelID, double time, double timeErr, double sigt=0) const
Returns the value of PDF normalized to the number of expected photons.
void expandSignalPDF(unsigned col, const YScanner::Derivatives &D, SignalPDF::EPeakType type)
Expands signal PDF in y (y-scan)
std::vector< FastRaytracer > m_rayTracers
copies of fast ray-tracer used to compute derivatives
const Const::ChargedStable m_hypothesis
particle hypothesis
bool prismRaytrace(const PrismSolution &sol, double dL=0, double dFic=0, double de=0)
Do forward raytracing of inverse raytracing solution in prism.
double m_groupIndexDerivative
derivative (dn_g/dE) of group refractive index at mean photon energy
void initializePixelLogLs(double minTime, double maxTime) const
Initializes pixel log likelihoods.
bool rangeOfX(double z, double &xmi, double &xma)
Estimates range of unfolded x coordinate of the hits on given plane perpendicular to z-axis.
std::vector< TOPTrack::SelectedHit > m_selectedHits
selected photon hits
void setSignalPDF_direct()
Sets signal PDF for direct photons.
std::set< int > m_zeroPixels
collection of pixelID's with zero pdfValue
double m_f0
temporary value of signal PDF
double m_tof
time-of-flight from IP to average photon emission position
PDFConstructor(const TOPTrack &track, const Const::ChargedStable &hypothesis, EPDFOption PDFOption=c_Optimal, EStoreOption storeOption=c_Reduced, double overrideMass=0)
Class constructor.
State of the Cerenkov photon in the quartz optics.
Parametrization of signal PDF in a single pixel.
EPeakType
Enumerator for single PDF peak types.
@ c_Reflected
reflected photon
static double getAbsorptionLength(double energy)
Returns bulk absorption length of quartz at given photon energy.
static double getGroupIndexDerivative(double energy)
Returns the derivative (dn_g/dE) of group refractive index of quartz at given photon energy.
static double getGroupIndex(double energy)
Returns group refractive index of quartz at given photon energy.
static TOPGeometryPar * Instance()
Static method to obtain the pointer to its instance.
Singleton class providing pre-constructed reconstruction objects.
static double getMaxTime()
Returns time window upper edge.
static double getMinTime()
Returns time window lower edge.
Reconstructed track at TOP.
Class to store variables with their name which were sent to the logging service.
double sqrt(double a)
sqrt for double
double unfold(double x, int nx, double A)
unfold a coordinate.
double clip(double x, int Nx, double A, double xmi, double xma)
Performs a clip on x w.r.t xmi and xma.
double within2PI(double angle)
Returns angle within 0 and 2PI.
long lround(double x)
Rounds to the nearest integer, halfway cases away from zero.
Abstract base class for different kinds of events.
Solution of inverse ray-tracing.
Structure that enables defining a template function: direct photons.
Structure that enables defining a template function: reflected photons.
Useful data type for returning the results of log likelihood calculation.
double effectiveSignalYield
effective number of signal photons in data
unsigned numPhotons
detected number of photons
double logL
extended log likelihood
Solution of inverse raytracing in prism.
double L
emission position distance along particle trajectory
double cosFic
cosine of azimuthal Cerenkov angle
double sinFic
sine of azimuthal Cerenkov angle
double len
propagation length
Data type for storing photon pull w.r.t PDF peak.
position and size of a pixel
double yc
position of center in y
double xc
position of center in x
spherical mirror data in module local frame.
double xc
center of curvature in x
double zc
center of curvature in z
double t0
peak position [ns]
double fic
Cerenkov azimuthal angle.
double wid
peak width squared [ns^2]
double nph
normalized number of photons in a peak
selected photon hit from TOPDigits
double timeErr
time uncertainty