10 #include <klm/dbobjects/bklm/BKLMSimulationPar.h>
13 #include <framework/gearbox/GearDir.h>
14 #include <framework/logging/Logger.h>
22 BKLMSimulationPar::BKLMSimulationPar(
const GearDir& content)
27 BKLMSimulationPar::~BKLMSimulationPar()
31 void BKLMSimulationPar::read(
const GearDir& content)
34 B2FATAL(
"The GearDir to look for BKLM simulation parameters is not valid.");
38 double weight[c_MAX_NHIT];
40 for (
int div = 0; div <= c_NDIV; ++div) {
41 for (
int j = 0; j < c_MAX_NHIT; ++j) {
42 m_PhiMultiplicityCDF[div][j] = 1.0;
43 m_ZMultiplicityCDF[div][j] = 1.0;
47 m_HitTimeMax = content.getWithUnit(
"/HitTimeMax");
50 phiContent.
append(
"/RPCStripMultiplicity/Phi");
52 int nDiv = min(phiContent.
getNumberNodes(
"/Division"), c_NDIV + 1);
53 for (
int div = 0; div < nDiv; ++div) {
54 sprintf(name,
"/Division[@id=\"%d\"]", div);
58 int nWeight = min(divContent.
getNumberNodes(
"/Weight"), c_MAX_NHIT - 1);
60 for (
int j = 1; j <= nWeight; ++j) {
61 sprintf(name,
"/Weight[@multiplicity=\"%d\"]", j);
62 m_PhiWeight[div][j] = divContent.
getDouble(name);
63 weight[j] = divContent.
getDouble(name) + weight[j - 1];
64 weight[0] = weight[j];
66 for (
int j = 1; j < c_MAX_NHIT; ++j) {
67 m_PhiMultiplicityCDF[div][j] = (j <= nWeight ? weight[j] / weight[0] : 1.0);
72 zContent.
append(
"/RPCStripMultiplicity/Z");
75 for (
int div = 0; div < nDiv; ++div) {
76 sprintf(name,
"/Division[@id=\"%d\"]", div);
79 int nWeight = min(divContent.
getNumberNodes(
"/Weight"), c_MAX_NHIT - 1);
82 for (
int j = 1; j <= nWeight; ++j) {
83 sprintf(name,
"/Weight[@multiplicity=\"%d\"]", j);
84 m_ZWeight[div][j] = divContent.
getDouble(name);
85 weight[j] = divContent.
getDouble(name) + weight[j - 1];
86 weight[0] = weight[j];
88 for (
int j = 1; j < c_MAX_NHIT; ++j) {
89 m_ZMultiplicityCDF[div][j] = (j <= nWeight ? weight[j] / weight[0] : 1.0);
94 double BKLMSimulationPar::getPhiMultiplicityCDF(
double stripDiv,
int mult)
const
98 if (mult >= c_MAX_NHIT)
100 int stripIndex = (int) fabs(stripDiv * c_NDIV / 0.5);
101 if (stripIndex > c_NDIV)
103 return m_PhiMultiplicityCDF[stripIndex][mult];
106 double BKLMSimulationPar::getZMultiplicityCDF(
double stripDiv,
int mult)
const
110 if (mult >= c_MAX_NHIT)
112 int stripIndex = (int) fabs(stripDiv * c_NDIV / 0.5);
113 if (stripIndex > c_NDIV)
115 return m_ZMultiplicityCDF[stripIndex][mult];
GearDir is the basic class used for accessing the parameter store.
void append(const std::string &path)
Append something to the current path, modifying the GearDir in place.
virtual int getNumberNodes(const std::string &path="") const override
Return the number of nodes a given path will expand to.
double getDouble(const std::string &path="") const noexcept(false)
Get the parameter path as a double.
Abstract base class for different kinds of events.