11 #include <top/reconstruction/TOPalign.h>
12 #include <framework/logging/Logger.h>
17 void data_put_(
int*,
int*,
float*,
float*,
int*);
18 void set_top_par_(
float*,
float*);
20 void rtra_set_hypo_(
int*,
float*);
21 void rtra_set_hypid_(
int*,
int*);
22 void rtra_put_(
float*,
float*,
float*,
float*,
float*,
float*,
float*,
23 int*,
int*,
int*,
int*);
24 void set_pdf_opt_(
int*,
int*,
int*);
25 void top_alignment_(
int*,
float*,
float*,
double*,
float*,
float*,
int*);
26 int rtra_get_nfot_(
int*);
40 m_parNames.push_back(
"x");
41 m_parNames.push_back(
"y");
42 m_parNames.push_back(
"z");
43 m_parNames.push_back(
"alpha");
44 m_parNames.push_back(
"beta");
45 m_parNames.push_back(
"gamma");
46 m_parNames.push_back(
"t0");
47 m_parNames.push_back(
"dn/n");
48 unsigned numPar = m_parNames.size();
49 m_parInit.resize(numPar, 0);
51 m_steps.resize(numPar, 0);
52 m_fixed.resize(numPar,
false);
53 m_COV.resize(numPar * numPar, 0);
54 m_U.resize(numPar * numPar, 0);
55 m_maxDpar.resize(numPar, 0);
59 void TOPalign::setSteps(
double position,
double angle,
double time,
double refind)
61 m_steps[0] = position;
62 m_steps[1] = position;
63 m_steps[2] = position;
73 void TOPalign::clearData()
78 int TOPalign::addData(
int moduleID,
int pixelID,
double time,
double timeError)
83 float t = (float) time;
84 float terr = (float) timeError;
85 data_put_(&moduleID, &pixelID, &t, &terr, &status);
88 B2WARNING(
"addData: no space available in /TOP_DATA/");
91 B2ERROR(
"addData: invalid module ID."
92 <<
LogVar(
"moduleID", moduleID + 1));
95 B2ERROR(
"addData: invalid pixel ID."
96 <<
LogVar(
"pixelID", pixelID + 1));
99 B2DEBUG(100,
"addData: digit should already be masked-out (different masks used?)");
106 void TOPalign::setPhotonYields(
double bkgPerModule,
double scaleN0)
108 float bkg = bkgPerModule;
110 set_top_par_(&bkg, &sf);
117 if (track.getModuleID() != m_moduleID)
return -3;
120 float x = track.getX();
121 float y = track.getY();
122 float z = track.getZ();
123 float t = track.getTrackLength() / Const::speedOfLight;
124 float px = track.getPx();
125 float py = track.getPy();
126 float pz = track.getPz();
127 int Q = track.getCharge();
130 int moduleID = m_moduleID - 1;
132 rtra_put_(&x, &y, &z, &t, &px, &py, &pz, &Q, &HYP, &REF, &moduleID);
136 float mass = hypothesis.
getMass();
138 rtra_set_hypo_(&Num, &mass);
139 rtra_set_hypid_(&Num, &pdg);
142 set_pdf_opt_(&m_opt, &m_NP, &m_NC);
146 int np = m_par.size();
147 std::vector<float> dpar(np, 0);
148 auto steps = m_steps;
149 for (
size_t i = 0; i < steps.size(); i++) {
150 if (m_fixed[i]) steps[i] = 0;
152 top_alignment_(&np, m_par.data(), steps.data(), m_U.data(),
153 dpar.data(), m_COV.data(), &ier);
154 if (ier < 0)
return ier;
158 m_numPhotons = rtra_get_nfot_(&K);
159 if (ier != 0)
return ier;
161 for (
size_t i = 0; i < dpar.size(); i++) {
162 if (fabs(dpar[i]) > m_maxDpar[i])
return ier;
164 for (
size_t i = 0; i < dpar.size(); i++) {
167 m_numUsedTracks = m_numTracks;
173 void TOPalign::reset()
176 for (
auto& x : m_COV) x = 0;
177 for (
auto& x : m_U) x = 0;
183 std::vector<float> TOPalign::getErrors()
const
185 std::vector<float> errors;
186 int numPar = m_par.size();
187 for (
int i = 0; i < numPar; i++) {
188 errors.push_back(sqrt(m_COV[i * (numPar + 1)]));