11#include <top/reconstruction_cpp/TOPTrack.h>
12#include <top/reconstruction_cpp/InverseRaytracer.h>
13#include <top/reconstruction_cpp/FastRaytracer.h>
14#include <top/reconstruction_cpp/YScanner.h>
15#include <top/reconstruction_cpp/SignalPDF.h>
16#include <top/reconstruction_cpp/BackgroundPDF.h>
17#include <top/reconstruction_cpp/DeltaRayPDF.h>
18#include <top/geometry/TOPGeometryPar.h>
94 Pull(
int pix,
double t,
double t0,
double tts0,
double sig,
double phi,
double w):
208 photons += other->getExpectedSignalPhotons() + other->getExpectedDeltaPhotons();
232 ps += signalPDF.getIntegral(minTime, maxTime);
259 photons += other->getExpectedSignalPhotons(minTime, maxTime) + other->getExpectedDeltaPhotons(minTime, maxTime);
284 double getPDFValue(
int pixelID,
double time,
double timeErr,
double sigt = 0)
const
311 LogL
getLogL(
double t0,
double minTime,
double maxTime,
double sigt = 0)
const;
344 const std::vector<LogL>&
getPixelLogLs(
double t0,
double minTime,
double maxTime,
double sigt = 0)
const;
350 const std::vector<Pull>&
getPulls()
const;
379 if (not pdfOther)
return;
417 int solve(
double xD,
double zD,
int,
double,
double,
444 int solve(
double xD,
double zD,
int Nxm,
double xmMin,
double xmMax,
463 void setSignalPDF(T& t,
unsigned col,
double xD,
double zD,
int Nxm = 0,
double xmMin = 0,
double xmMax = 0);
508 bool detectionPositionX(
double xM,
int Nxm, std::vector<double>& xDs,
double& minLen);
575 bool rangeOfX(
double z,
double& xmi,
double& xma);
610 bool prismRaytrace(
const PrismSolution& sol,
double dL = 0,
double dFic = 0,
double de = 0);
627 PrismSolution
prismSolution(
const ROOT::Math::XYZPoint& rD,
double L);
637 double pdfValueSignal(
int pixelID,
double time,
double timeErr,
double sigt = 0)
const;
647 double pdfValueSignalDelta(
int pixelID,
double time,
double timeErr,
double sigt = 0)
const;
657 double pdfValue(
int pixelID,
double time,
double timeErr,
double sigt = 0)
const;
720 unsigned k = pixelID - 1;
743 for (
const auto* other :
m_pdfOtherTracks) f += other->pdfValueSignalDelta(pixelID, time, timeErr, sigt);
759 return std::min(1 /
m_beta / refind, 1.0);
765 if (cer.cosThc == 0 and cer.sinThc == 0) {
785 if (i0 < 0 or not m_inverseRaytracer->getStatus())
return;
787 for (
unsigned i = 0; i < 2; i++) {
790 const auto& sol = solutions[i0];
801 if (i_dx < 0)
return;
805 B2DEBUG(20,
"TOP::PDFConstructor::setSignalPDF: failed to find the same Nym (dx)");
810 if (i_dx < 0)
return;
816 for (
unsigned i = 0; i < 2; i++) {
819 const auto& sol = solutions[i0];
820 const auto& sol_dx = solutions[i_dx];
830 if (not ok)
continue;
843 B2DEBUG(20,
"TOP::PDFConstructor::setSignalPDF: failed to determine derivatives: "
849 <<
LogVar(
"peak type", t.type));
Provides a type-safe way to pass members of the chargedStableSet set.
static const double speedOfLight
[cm/ns]
Parametrization of background PDF in pixels of single module.
double getPDFValue(int pixelID) const
Returns PDF value for given pixel.
Parametrization of delta-ray PDF in pixels of single module.
double getIntegral(double minTime, double maxTime) const
Returns integral of PDF from minTime to maxTime.
double getPDFValue(int pixelID, double time) const
Returns PDF value at given time and pixel.
Fast photon propagation in quartz optics.
double getPropagationLen() const
Returns total propagation length since initial position.
void propagate(const PhotonState &photon, bool averaging=false) const
Propagate photon to photo-detector plane.
bool getPropagationStatus() const
Returns propagation status.
double getXD() const
Returns unfolded position in x at virtual Detector plane.
Utility for solving inverse ray-tracing problem.
int solveReflected(double xD, double zD, int Nxm, double xmMin, double xmMax, const TOPTrack::AssumedEmission &assumedEmission, const CerenkovAngle &cer, double step=0) const
Solve inverse ray-tracing for reflected photon.
PhotonState getReconstructedPhoton(const Solution &sol, double DFic=0) const
Returns reconstructed photon at emission for a given solution of inverse raytracing.
bool getStatus() const
Returns status.
bool isNymDifferent() const
Checks if Nym differs between solutions front and back in at least one of the vectors.
std::vector< Solution > & getSolutions(unsigned i) const
Returns the solutions of inverse ray-tracing.
int solveDirect(double xD, double zD, const TOPTrack::AssumedEmission &assumedEmission, const CerenkovAngle &cer, double step=0) const
Solve inverse ray-tracing for direct photon.
void clear() const
Clear the solutions to prepare for the new round.
PDF construction and log likelihood determination for a given track and particle hypothesis.
double m_cosTotal
cosine of total reflection angle
void setSignalPDF_prism()
Sets signal PDF for track crossing prism.
void setSignalPDF()
Sets signal PDF.
double m_bkgRate
estimated background hit rate
LogL getLogL(double t0, double sigt=0) const
Returns extended log likelihood for PDF shifted in time.
double getPDFValue(int pixelID, double time, double timeErr, double sigt=0) const
Returns PDF value.
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.
int getNCalls_setPDF(SignalPDF::EPeakType type) const
Returns number of calls of template function setSignalPDF<T> for a given peak type.
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...
void switchOnDeltaRayPDF() const
Include delta-ray PDF in log likelihood calculation (this is default)
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.
double getBkgRate() const
Returns estimated background hit rate.
LogL getBackgroundLogL() const
Returns extended log likelihood for background hypothesis using default time window.
double pdfValueSignal(int pixelID, double time, double timeErr, double sigt=0) const
Returns the value of signal PDF normalized to the number of expected photons.
void switchOffDeltaRayPDF() const
Exclude delta-ray PDF in log likelihood calculation.
PrismSolution prismSolution(const PixelPositions::PixelData &pixel, unsigned k, int nx)
General solution of inverse raytracing in prism: iterative procedure calling basic solution.
std::map< SignalPDF::EPeakType, int > m_ncallsSetPDF
number of calls to setSignalPDF<T>
LogL getLogL() const
Returns extended log likelihood (using the default time window)
const std::vector< TOPTrack::SelectedHit > & getSelectedHits() const
Returns selected photon hits belonging to this slot.
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.
double getExpectedBkgPhotons(double minTime, double maxTime) const
Returns the expected number of background photons within a given time window.
bool isValid() const
Checks the object status.
const std::vector< SignalPDF > & getSignalPDF() const
Returns signal PDF.
EStoreOption m_storeOption
signal PDF storing option
double m_Fic
temporary storage for Cerenkov azimuthal angle
double getExpectedSignalPhotons() const
Returns the expected number of signal photons within the default time window.
double getExpectedSignalPhotons(double minTime, double maxTime) const
Returns the expected number of signal photons within a given time window.
double derivativeOfReflectedX(double x, double xe, double ze, double zd) const
Returns the derivative of reflected position at given x.
bool setDerivatives(YScanner::Derivatives &D, double dL, double de, double dFic)
Sets the derivatives (numerically) using forward ray-tracing.
double getExpectedDeltaPhotons(double minTime, double maxTime) const
Returns the expected number of delta-ray photons within a given time window.
double m_groupIndex
group refractive index at mean photon energy
int getNCalls_expandPDF(SignalPDF::EPeakType type) const
Returns number of calls of function expandSignalPDF for a given peak type.
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 getCosTotal() const
Returns cosine of total reflection angle.
double m_signalPhotons
expected number of signal photons
std::map< SignalPDF::EPeakType, int > m_ncallsExpandPDF
number of calls to expandSignalPDF
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
double findReflectionExtreme(double xE, double zE, double zD, int Nxm, double A, const RaytracerBase::Mirror &mirror) const
Finds the position on the mirror of the extreme reflection.
const Const::ChargedStable & getHypothesis() const
Returns particle hypothesis.
EStoreOption
Options for storing signal PDF parameters.
@ c_Reduced
only PDF peak data
@ c_Full
also extra information and derivatives
const std::map< double, YScanner::Derivatives > & getDerivatives() const
Returns a collection of derivatives for debugging purposes.
const TOPTrack & m_track
temporary reference to track at TOP
std::vector< LogL > m_pixelLLs
pixel log likelihoods (index = pixelID - 1)
void appendPDFOther(const PDFConstructor *pdfOther)
Append most probable PDF of other track in this module.
EPDFOption m_PDFOption
signal PDF construction option
const BackgroundPDF * m_backgroundPDF
background PDF
bool m_deltaPDFOn
include/exclude delta-ray PDF in likelihood calculation
EPDFOption
Signal PDF construction options.
@ c_Optimal
y dependent only where necessary
@ c_Fine
y dependent everywhere
@ c_Rough
no dependence on y
std::map< double, InverseRaytracer::CerenkovAngle > m_cerenkovAngles
sine and cosine of Cerenkov angles
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
double getExpectedBkgPhotons() const
Returns the expected number of background photons within the default time window.
bool prismRaytrace(const PrismSolution &sol, double dL=0, double dFic=0, double de=0)
Do forward raytracing of inverse raytracing solution in prism.
void clearPDFOther()
Clear the container of PDF's of other tracks.
double m_groupIndexDerivative
derivative (dn_g/dE) of group refractive index at mean photon energy
double pdfValueSignalDelta(int pixelID, double time, double timeErr, double sigt=0) const
Returns the value of signal + deltaRay PDF normalized to the number of expected photons.
void switchDeltaRayPDF(bool deltaPDFOn) const
Include or exclude delta-ray PDF in log likelihood calculation.
const DeltaRayPDF & getDeltaRayPDF() const
Returns delta-ray PDF.
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.
double getExpectedPhotons(double minTime, double maxTime) const
Returns the expected number of all photons within a given time window.
std::set< int > m_zeroPixels
collection of pixelID's with zero pdfValue
std::map< double, YScanner::Derivatives > m_derivatives
a map of xD and derivatives
double m_f0
temporary value of signal PDF
double m_dFic
temporary storage for dFic used in last call to deltaXD
double m_tof
time-of-flight from IP to average photon emission position
EPeakType
Enumerator for single PDF peak types.
@ c_Reflected
reflected photon
static TOPGeometryPar * Instance()
Static method to obtain the pointer to its instance.
double getPhaseIndex(double energy) const
Returns phase refractive index of quartz at given photon energy.
Reconstructed track at TOP.
const TOPTrack::AssumedEmission & getEmissionPoint(double dL=0) const
Returns assumed photon emission position and track direction.
double getMomentumMag() const
Returns momentum magnitude (extrapolated to TOP)
Utility for expanding the PDF in y direction.
double getMeanEnergy() const
Returns mean photon energy.
Class to store variables with their name which were sent to the logging service.
Abstract base class for different kinds of events.
Sine and cosine of Cerenkov angle.
Solution of inverse ray-tracing.
Structure that enables defining a template function: direct photons.
const SignalPDF::EPeakType type
PDF peak type.
int solve(double xD, double zD, int, double, double, const TOPTrack::AssumedEmission &assumedEmission, const InverseRaytracer::CerenkovAngle &cer, double step=0) const
Solve inverse ray-tracing for direct photon.
const InverseRaytracer * inverseRaytracer
inverse ray-tracer
Structure that enables defining a template function: reflected photons.
const SignalPDF::EPeakType type
PDF peak type.
int solve(double xD, double zD, int Nxm, double xmMin, double xmMax, const TOPTrack::AssumedEmission &assumedEmission, const InverseRaytracer::CerenkovAngle &cer, double step=0) const
Solve inverse ray-tracing for reflected photon.
const InverseRaytracer * inverseRaytracer
inverse ray-tracer
Useful data type for returning the results of log likelihood calculation.
double expPhotons
expected number of photons
double effectiveSignalYield
effective number of signal photons in data
LogL(double phot)
Constructor.
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.
double sigma
peak overall sigma (signal) or 0 (background)
double peakT0
PDF peak time (signal) or minimal PDF peak time in pixel (background)
double ttsT0
TTS gaussian peak time (signal) or 0 (background)
Pull(int pix, double t, double t0, double tts0, double sig, double phi, double w)
Constructor.
double phiCer
azimuthal Cerenkov angle (signal) or 0 (background)
position and size of a pixel
spherical mirror data in module local frame.
assumed photon emission point in local frame
ROOT::Math::XYZPoint position
position
selected photon hit from TOPDigits
static double dFic_d(const InverseRaytracer::Solution &sol0, const InverseRaytracer::Solution &sol1)
Calculates the derivative of Cerenkov azimuthal angle.