10#include <klm/calibration/KLMStripEfficiencyAlgorithm.h>
13#include <klm/dataobjects/KLMChannelIndex.h>
27 m_AchievedPrecision = results.m_AchievedPrecision;
28 m_MatchedDigits = results.m_MatchedDigits;
29 m_ExtHits = results.m_ExtHits;
31 m_Efficiency =
new float[nPlanes];
32 m_ExtHitsPlane =
new int[nPlanes];
33 std::memcpy(m_Efficiency, results.m_Efficiency, nPlanes *
sizeof(
float));
34 std::memcpy(m_ExtHitsPlane, results.m_ExtHitsPlane, nPlanes *
sizeof(
int));
39 if (m_Efficiency !=
nullptr)
41 if (m_ExtHitsPlane !=
nullptr)
42 delete m_ExtHitsPlane;
66 TH1F* efficiencyHistogram =
67 new TH1F(
"plane_efficiency",
"KLM plane efficiency",
68 nPlanes, -0.5,
double(nPlanes) - 0.5);
69 std::shared_ptr<TH1F> matchedDigitsInPlane;
70 matchedDigitsInPlane = getObjectPtr<TH1F>(
"matchedDigitsInPlane");
72 std::shared_ptr<TH1F> allExtHitsInPlane;
73 allExtHitsInPlane = getObjectPtr<TH1F>(
"allExtHitsInPlane");
75 matchedDigitsInPlane.get()->Sumw2();
76 allExtHitsInPlane.get()->Sumw2();
77 efficiencyHistogram->Divide(matchedDigitsInPlane.get(),
78 allExtHitsInPlane.get(), 1, 1,
"B");
79 for (
int i = 0; i < nPlanes; ++i) {
84 bool notEnoughData =
false;
90 int extHits = allExtHitsInPlane->GetBinContent(planeIndex + 1);
91 float efficiencyError = efficiencyHistogram->GetBinError(planeIndex + 1);
101 notEnoughData =
true;
105 notEnoughData =
true;
120 int section = klmChannel.getSection();
121 int sector = klmChannel.getSector();
122 int layer = klmChannel.getLayer();
123 int plane = klmChannel.getPlane();
124 int strip = klmChannel.getStrip();
128 section, sector, layer, plane);
131 section, sector, layer, plane);
134 float efficiency = efficiencyHistogram->GetBinContent(planeIndex + 1);
135 float efficiencyError = efficiencyHistogram->GetBinError(planeIndex + 1);
139 section, sector, layer, plane, strip, efficiency, efficiencyError);
142 section, sector, layer, plane, strip, efficiency, efficiencyError);
150 matchedDigitsInPlane.get()->Write();
151 allExtHitsInPlane.get()->Write();
152 efficiencyHistogram->Write();
153 delete efficiencyHistogram;
162 const float* efficiency)
const
166 for (
int i = 0; i < nPlanes; ++i) {
174 const int* extHitsPlane)
const
178 for (
int i = 0; i < nPlanes; ++i) {
179 if (m_ExtHitsPlane[i] > 0 && extHitsPlane[i] == 0)
Base class for calibration algorithms.
void saveCalibration(TClonesArray *data, const std::string &name)
Store DBArray payload with given name with default IOV.
EResult
The result of calibration.
@ c_OK
Finished successfully =0 in Python.
@ c_NotEnoughData
Needs more data =2 in Python.
int getSubdetector() const
Get subdetector.
@ c_IndexLevelPlane
Plane.
uint16_t getNElements() const
Get number of elements.
uint16_t getIndex(uint16_t number) const
Get element index.
KLMPlaneNumber planeNumberEKLM(int section, int sector, int layer, int plane) const
Get channel number for EKLM.
KLMPlaneNumber planeNumberBKLM(int section, int sector, int layer, int plane) const
Get plane number for BKLM.
static const KLMPlaneArrayIndex & Instance()
Instantiation.
Calibration results or supplementary results calculated from the input data.
int newMeasuredPlanes(const float *efficiency) const
Get number of new measured planes.
int m_MatchedDigits
Number of matched digits.
float * m_Efficiency
Efficiency.
int m_ExtHits
Number of ExtHits (overall).
float m_AchievedPrecision
Achieved precision of efficiency measurement.
int * m_ExtHitsPlane
Number of ExtHits per plane.
int newExtHitsPlanes(const int *extHitsPlane) const
Get number of new measured planes with ExtHits.
KLMStripEfficiencyAlgorithm()
Constructor.
@ c_MeasurablePlaneCheck
Check of set of planes with determined efficiency.
@ c_EfficiencyMeasurement
Measurement.
enum CalibrationStage m_CalibrationStage
Calibration stage.
bool m_ForcedCalibration
Whether the calibration is forced.
const KLMElementNumbers * m_ElementNumbers
Element numbers.
const KLMPlaneArrayIndex * m_PlaneArrayIndex
Plane array index.
Results m_Results
Calibration results.
KLMStripEfficiency * m_StripEfficiency
Efficiency data object.
~KLMStripEfficiencyAlgorithm()
Destructor.
CalibrationAlgorithm::EResult calibrate() override
Calibration.
int m_MinimalExtHits
Minimal number of ExtHits per plane.
float m_RequestedPrecision
Requested precision of efficiency measurement.
std::string m_OutputFileName
Output root file.
DBObject used to store the efficiencies of KLM strips.
void setEndcapEfficiency(int section, int sector, int layer, int plane, int strip, float efficiency, float efficiencyError=0.)
Set efficiency and relative error for a single EKLM strip using the geometrical infos.
void setBarrelEfficiency(int section, int sector, int layer, int plane, int strip, float efficiency, float efficiencyError=0.)
Set efficiency and relative error for a single BKLM strip using the geometrical infos.
uint16_t KLMPlaneNumber
Plane number.
Abstract base class for different kinds of events.