10#include <klm/muid/MuidBuilder.h>
13#include <klm/dataobjects/KLMMuidLikelihood.h>
16#include <framework/logging/Logger.h>
17#include <framework/utilities/Spline.h>
29 for (
unsigned int layer = 0;
54 if (hypothesis == MuidElementNumbers::c_NotValid)
55 B2FATAL(
"The particle associated to the PDG code " << pdg <<
" is not supported.");
59 B2FATAL(
"Invalid PDFs for PDG code " << pdg);
73 for (
unsigned int layer = 0; layer < layerPDF.size(); ++layer) {
74 m_LayerPDF[outcome][lastLayer][layer] = layerPDF[layer];
87 std::vector<double> reducedChiSquaredPDF =
m_LikelihoodParameters->getTransversePDF(hypothesis, detector, halfNdof * 2);
89 B2ERROR(
"TransversePDF vector for hypothesis " << hypothesis <<
" detector " << detector
117 unsigned int outcome = muid->getOutcome();
120 int barrelExtLayer = muid->getBarrelExtLayer();
123 int endcapExtLayer = muid->getEndcapExtLayer();
126 unsigned int extLayerPattern = muid->getExtLayerPattern();
127 unsigned int hitLayerPattern = muid->getHitLayerPattern();
128 int lastLayer = (endcapExtLayer < 0) ? barrelExtLayer : endcapExtLayer;
132 unsigned int testBit = 1;
133 for (
int layer = 0; layer <= barrelExtLayer; ++layer) {
134 if ((testBit & extLayerPattern) != 0) {
135 if ((testBit & hitLayerPattern) != 0) {
138 if (((layer == 0) && (outcome < MuidElementNumbers::c_CrossBarrelStopInForwardMin))
140 pdf *= 1 -
m_LayerPDF[outcome][lastLayer][layer] * muid->getExtBKLMEfficiencyValue(layer);
150 for (
int layer = 0; layer <= endcapExtLayer; ++layer) {
151 if ((testBit & extLayerPattern) != 0) {
152 if ((testBit & hitLayerPattern) != 0) {
155 if ((layer == 0) || (layer == maxLayer) || (layer < endcapExtLayer)) {
157 muid->getExtEKLMEfficiencyValue(layer);
169 int ndof = muid->getDegreesOfFreedom();
172 double chiSquared = muid->getChiSquared();
173 if (chiSquared < 0.0)
175 int halfNdof = (ndof >> 1);
176 double x = chiSquared / ndof;
179 int detector = MuidElementNumbers::c_Both;
180 if (muid->getEndcapExtLayer() < 0) {
181 detector = MuidElementNumbers::c_OnlyBarrel;
182 }
else if (muid->getBarrelExtLayer() < 0) {
183 detector = MuidElementNumbers::c_OnlyEndcap;
197 }
else if (halfNdof == 2) {
199 }
else if (halfNdof == 3) {
212 pdf = std::exp(logPdf);
Class to store the likelihoods from KLM with additional information related to the extrapolation.
MuidBuilder()
Default constructor.
double getLongitudinalPDF(const KLMMuidLikelihood *muid) const
Calculate the longitudinal PDF for a given hypothesis.
double getTransversePDF(const KLMMuidLikelihood *muid) const
Calculate the transverse PDF for a given hypothesis.
double m_LayerPDF[MuidElementNumbers::getMaximalOutcome()+1][MuidElementNumbers::getMaximalBarrelLayer()+1][MuidElementNumbers::getMaximalBarrelLayer()+MuidElementNumbers::getMaximalEndcapForwardLayer()+2]
Longitudinal PDF.
double m_ReducedChiSquaredPDF[MuidElementNumbers::getMaximalDetector()+1][MuidElementNumbers::getMaximalHalfNdof()+1][MuidElementNumbers::getSizeReducedChiSquared()]
Reduced chi-squared (transverse) PDF (overflows in last bin).
void fillPDFs(MuidElementNumbers::Hypothesis hypothesis)
Retrieve the PDFs from the database according to the given hypothesis.
double m_ReducedChiSquaredDx
Reduced chi-squared (transverse) PDF's bin size.
double m_ReducedChiSquaredScaleY[MuidElementNumbers::getMaximalDetector()+1][MuidElementNumbers::getMaximalHalfNdof()+1]
Reduced chi-squared (transverse) analytical PDF: vertical scale.
double m_ReducedChiSquaredD1[MuidElementNumbers::getMaximalDetector()+1][MuidElementNumbers::getMaximalHalfNdof()+1][MuidElementNumbers::getSizeReducedChiSquared()]
First derivative of reduced chi-squared PDF (for spline interpolation).
double getPDF(const KLMMuidLikelihood *muid) const
Get total PDG for a given hypothesis.
DBObjPtr< KLMLikelihoodParameters > m_LikelihoodParameters
Likelihood parameters.
double m_ReducedChiSquaredThreshold[MuidElementNumbers::getMaximalDetector()+1][MuidElementNumbers::getMaximalHalfNdof()+1]
Reduced chi-squared (transverse) analytical PDF: threshold.
~MuidBuilder()
Destructor.
double m_ReducedChiSquaredD2[MuidElementNumbers::getMaximalDetector()+1][MuidElementNumbers::getMaximalHalfNdof()+1][MuidElementNumbers::getSizeReducedChiSquared()]
Second derivative of reduced chi-squared PDF (for spline interpolation).
double m_ReducedChiSquaredScaleX[MuidElementNumbers::getMaximalDetector()+1][MuidElementNumbers::getMaximalHalfNdof()+1]
Reduced chi-squared (transverse) analytical PDF: horizontal scale ~ 1.
double m_ReducedChiSquaredD3[MuidElementNumbers::getMaximalDetector()+1][MuidElementNumbers::getMaximalHalfNdof()+1][MuidElementNumbers::getSizeReducedChiSquared()]
Third derivative of reduced chi-squared PDF (for spline interpolation).
static constexpr int getMaximalDetector()
Get maximal value of the detector selector (for transverse scattering).
static constexpr int getMaximalEndcapForwardLayer()
Get maximal endcap-forward layer number (0-based).
static constexpr int getMaximalHalfNdof()
Get maximal value of NDof/2 (for transverse scattering).
static constexpr int getMaximalEndcapBackwardLayer()
Get maximal endcap-forward layer number (0-based).
static constexpr int getMaximalBarrelLayer()
Get maximal barrel layer number (0-based).
static constexpr double getMaximalReducedChiSquared()
Get maximal value of reduced chi-squared (for transverse scattering).
static bool checkExtrapolationOutcome(unsigned int outcome, int lastLayer)
Check the track extrapolation outcome.
Hypothesis
Hypothesis number.
static Hypothesis calculateHypothesisFromPDG(int pdg)
Calculate hypothesis number from PDG code.
static constexpr int getSizeReducedChiSquared()
Get size of array with reduced chi-squared values (for transverse scattering).
static constexpr int getMaximalOutcome()
Get maximal value of the track extrapolation outcome.
Abstract base class for different kinds of events.