Belle II Software development
KLMLikelihoodParametersImporter Class Reference

This class imports KLMLikelihoodParameters into the database. More...

#include <KLMLikelihoodParametersImporter.h>

Public Member Functions

 KLMLikelihoodParametersImporter ()=default
 Constructor.
 
 ~KLMLikelihoodParametersImporter ()=default
 Destructor.
 
void writeLikelihoodParameters ()
 Write KLMLikelihoodParameters into the database.
 
void readLikelihoodParameters ()
 Read KLMLikelihoodParameters from the database.
 

Detailed Description

This class imports KLMLikelihoodParameters into the database.

Definition at line 20 of file KLMLikelihoodParametersImporter.h.

Member Function Documentation

◆ readLikelihoodParameters()

void readLikelihoodParameters ( )

Read KLMLikelihoodParameters from the database.

Definition at line 79 of file KLMLikelihoodParametersImporter.cc.

80{
81 DBObjPtr<KLMLikelihoodParameters> likelihoodParameters;
82 std::vector<std::string> const hypotheses = {"Positron", "Electron", "Deuteron", "Antideuteron", "Proton", "Antiproton", "PionPlus", "PionMinus", "KaonPlus", "KaonMinus", "MuonPlus", "MuonMinus" };
83 for (unsigned int hypothesis = 0; hypothesis < hypotheses.size(); hypothesis++) {
84 B2INFO(" hypothesisName " << hypotheses[hypothesis]);
85 for (int outcome = 1; outcome <= MuidElementNumbers::getMaximalOutcome(); ++outcome) {
86 B2INFO(" outcome " << outcome);
87 for (int lastLayer = 0; lastLayer <= MuidElementNumbers::getMaximalBarrelLayer(); ++lastLayer) {
88 B2INFO(" lastLayer " << lastLayer);
89 if (!(MuidElementNumbers::checkExtrapolationOutcome(outcome, lastLayer)))
90 break;
91 std::vector<double> layerPDF = likelihoodParameters->getLongitudinalPDF(hypothesis, outcome, lastLayer);
92 B2INFO(" layerPDF: ");
93 for (unsigned int layer = 0; layer < layerPDF.size(); ++layer) {
94 B2INFO(layerPDF[layer] << " , ");
95 }
96 }
97 }
98 const char* detectorNames[] = {"BarrelAndEndcap", "BarrelOnly", "EndcapOnly"};
99 for (int detector = 0; detector <= MuidElementNumbers::getMaximalDetector(); ++detector) {
100 B2INFO(" detectorName " << detectorNames[detector]);
101 for (int halfNdof = 1; halfNdof <= MuidElementNumbers::getMaximalHalfNdof(); ++halfNdof) {
102 B2INFO(" Ndof " << halfNdof * 2);
103 B2INFO(" ReducedChiSquaredThreshold " << likelihoodParameters->getTransverseThreshold(hypothesis, detector, halfNdof * 2));
104 B2INFO(" ReducedChiSquaredScaleY " << likelihoodParameters->getTransverseScaleY(hypothesis, detector, halfNdof * 2));
105 B2INFO(" ReducedChiSquaredScaleX " << likelihoodParameters->getTransverseScaleX(hypothesis, detector, halfNdof * 2));
106 std::vector<double> reducedChiSquaredPDF = likelihoodParameters->getTransversePDF(hypothesis, detector, halfNdof * 2);
107 if (reducedChiSquaredPDF.size() != MuidElementNumbers::getSizeReducedChiSquared()) {
108 B2ERROR("KLMLikelihoodParametersImporter::TransversePDF vector for hypothesis " << hypotheses[hypothesis] << " detector " <<
109 detectorNames[detector]
110 << " has " << reducedChiSquaredPDF.size() << " entries; should be " << MuidElementNumbers::getSizeReducedChiSquared());
111 } else {
112 for (int i = 0; i < MuidElementNumbers::getSizeReducedChiSquared(); ++i) {
113 B2INFO(" PDF " << reducedChiSquaredPDF[i]);
114 }
115 }
116 }
117 }
118 }
119}
Class for accessing objects in the database.
Definition: DBObjPtr.h:21
static constexpr int getMaximalDetector()
Get maximal value of the detector selector (for transverse scattering).
static constexpr int getMaximalHalfNdof()
Get maximal value of NDof/2 (for transverse scattering).
static constexpr int getMaximalBarrelLayer()
Get maximal barrel layer number (0-based).
static bool checkExtrapolationOutcome(unsigned int outcome, int lastLayer)
Check the track extrapolation outcome.
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.

◆ writeLikelihoodParameters()

void writeLikelihoodParameters ( )

Write KLMLikelihoodParameters into the database.

cppcheck-suppress unreachableCode

Definition at line 30 of file KLMLikelihoodParametersImporter.cc.

31{
32 B2WARNING("The method KLMLikelihoodParametersImporter::writeMuidParameters() is temporary unavailable, sorry! :(");
33 return;
35 DBImportObjPtr<KLMLikelihoodParameters> likelihoodParameters;
36 likelihoodParameters.construct();
37 std::vector<std::string> const hypotheses = {"Positron", "Electron", "Deuteron", "Antideuteron", "Proton", "Antiproton", "PionPlus", "PionMinus", "KaonPlus", "KaonMinus", "MuonPlus", "MuonMinus" };
38 for (unsigned int hypothesis = 0; hypothesis < hypotheses.size(); hypothesis++) {
39 GearDir content("/Detector/Muid/MuidParameters//Experiment[@exp=\"0\"]/");
40 content.append(hypotheses[hypothesis]);
41 for (int outcome = 1; outcome <= MuidElementNumbers::getMaximalOutcome(); ++outcome) {
42 GearDir outcomeContent(content);
43 outcomeContent.append((boost::format("/LayerProfile/Outcome[@outcome=\"%1%\"]/") % (outcome)).str());
44 for (int lastLayer = 0; lastLayer <= MuidElementNumbers::getMaximalBarrelLayer(); ++lastLayer) {
45 if (!(MuidElementNumbers::checkExtrapolationOutcome(outcome, lastLayer)))
46 break;
47 std::vector<double> layerPDF = outcomeContent.getArray((boost::format("LastLayer[@layer=\"%1%\"]") % (lastLayer)).str());
48 likelihoodParameters->setLongitudinalPDF(hypothesis, outcome, lastLayer, layerPDF);
49 }
50 }
51 for (int detector = 0; detector <= MuidElementNumbers::getMaximalDetector(); ++detector) {
52 GearDir detectorContent(content);
53 if (detector == 0)
54 detectorContent.append("/TransversePDF/BarrelAndEndcap");
55 if (detector == 1)
56 detectorContent.append("/TransversePDF/BarrelOnly");
57 if (detector == 2)
58 detectorContent.append("/TransversePDF/EndcapOnly");
59 for (int halfNdof = 1; halfNdof <= MuidElementNumbers::getMaximalHalfNdof(); ++halfNdof) {
60 double reducedChiSquaredThreshold = detectorContent.getDouble((boost::format("DegreesOfFreedom[@ndof=\"%1%\"]/Tail/Threshold") %
61 (2 * halfNdof)).str());
62 double reducedChiSquaredScaleY = detectorContent.getDouble((boost::format("DegreesOfFreedom[@ndof=\"%1%\"]/Tail/ScaleY") %
63 (2 * halfNdof)).str());
64 double reducedChiSquaredScaleX = detectorContent.getDouble((boost::format("DegreesOfFreedom[@ndof=\"%1%\"]/Tail/ScaleX") %
65 (2 * halfNdof)).str());
66 std::vector<double> reducedChiSquaredPDF = detectorContent.getArray((boost::format("DegreesOfFreedom[@ndof=\"%1%\"]/Histogram") %
67 (2 * halfNdof)).str());
68 likelihoodParameters->setTransversePDF(hypothesis, detector, halfNdof * 2, reducedChiSquaredPDF);
69 likelihoodParameters->setTransverseThreshold(hypothesis, detector, halfNdof * 2, reducedChiSquaredThreshold);
70 likelihoodParameters->setTransverseScaleY(hypothesis, detector, halfNdof * 2, reducedChiSquaredScaleY);
71 likelihoodParameters->setTransverseScaleX(hypothesis, detector, halfNdof * 2, reducedChiSquaredScaleX);
72 }
73 }
74 }
75 IntervalOfValidity Iov(0, 0, -1, -1);
76 likelihoodParameters.import(Iov);
77}
bool import(const IntervalOfValidity &iov)
Import the object to database.
Definition: DBImportBase.cc:36
Class for importing a single object to the database.
void construct(Args &&... params)
Construct an object of type T in this DBImportObjPtr using the provided constructor arguments.
GearDir is the basic class used for accessing the parameter store.
Definition: GearDir.h:31
A class that describes the interval of experiments/runs for which an object in the database is valid.

The documentation for this class was generated from the following files: