12 #include <framework/logging/Logger.h>
30 class CDCXtRelations:
public TObject {
32 typedef std::array<float, 3>
array3;
33 typedef unsigned short XtID;
61 B2FATAL(
"The no. of alpha bins > limit !");
74 B2FATAL(
"The no. of theta bins > limit !");
81 static bool comp(
const array3& lhs,
const array3& rhs)
83 return lhs[0] < rhs[0];
99 unsigned short nXtParams = params.size();
103 m_xts.insert(std::pair<
XtID, std::vector<float>>(xtID, params));
106 B2FATAL(
"The no. of xt params. > limit !");
113 void setXtParams(
unsigned short iCLayer,
unsigned short iLR,
unsigned short iAlpha,
unsigned short iTheta,
114 const std::vector<float>& params)
116 const XtID xtID =
getXtID(iCLayer, iLR, iAlpha, iTheta);
125 std::map<XtID, std::vector<float>>::iterator it =
m_xts.find(xtID);
127 if (it !=
m_xts.end()) {
129 (it->second)[i] += delta[i];
132 B2FATAL(
"Specified xt params not found in addXTParams !");
139 void addXTParams(
unsigned short iCLayer,
unsigned short iLR,
unsigned short iAlpha,
unsigned short iTheta,
140 const std::vector<float>& delta)
142 const XtID xtID =
getXtID(iCLayer, iLR, iAlpha, iTheta);
151 std::map<XtID, std::vector<float>>::iterator it =
m_xts.find(xtID);
153 if (it !=
m_xts.end()) {
155 (it->second)[i] = param[i];
158 B2FATAL(
"Specified xt params not found in replaceXTParams !");
165 void replaceXTParams(
unsigned short iCLayer,
unsigned short iLR,
unsigned short iAlpha,
unsigned short iTheta,
166 const std::vector<float>& param)
168 const XtID xtID =
getXtID(iCLayer, iLR, iAlpha, iTheta);
236 XtID getXtID(
unsigned short iCLayer,
unsigned short iLR,
unsigned short iAlpha,
unsigned short iTheta)
const
238 XtID id = iCLayer + 64 * iLR + 128 * iAlpha + 4096 * iTheta;
245 XtID getXtID(
unsigned short iCLayer,
unsigned short iLR,
float alpha,
float theta)
const
258 unsigned short iTheta = 999;
259 unsigned short ibin = 0;
261 if (it[0] <= theta && theta <= it[1]) {
267 if (iTheta == 999) B2FATAL(
"Theta bin not found !");
280 unsigned short iAlpha = 999;
283 if (it[0] <= alpha && alpha <= it[1]) {
289 if (iAlpha == 999) B2FATAL(
"Alpha bin not found !");
291 return getXtID(iCLayer, iLR, iAlpha, iTheta);
299 std::map<XtID, std::vector<float>>::const_iterator it =
m_xts.find(xtID);
300 if (it !=
m_xts.end()) {
303 B2FATAL(
"Specified xt params. not found in getXtParams !");
310 const std::vector<float>&
getXtParams(
unsigned short iCLayer,
unsigned short iLR,
unsigned short iAlpha,
311 unsigned short iTheta)
const
313 const XtID xtID =
getXtID(iCLayer, iLR, iAlpha, iTheta);
323 std::cout <<
" " << std::endl;
324 std::cout <<
"Contents of xt db" << std::endl;
325 std::cout <<
"alpha bins" << std::endl;
327 const double deg = 180. / M_PI;
330 for (
unsigned short i = 0; i < nAlphaBins; ++i) {
334 std::cout <<
" " << std::endl;
335 std::cout <<
"theta bins" << std::endl;
338 for (
unsigned short i = 0; i < nThetaBins; ++i) {
342 std::cout <<
" " << std::endl;
343 std::cout <<
"coefficients for xt" << std::endl;
345 for (
unsigned short iT = 0; iT < nThetaBins; ++iT) {
346 for (
unsigned short iA = 0; iA < nAlphaBins; ++iA) {
347 for (
unsigned short iCL = 0; iCL <
c_nSLayers; ++iCL) {
348 for (
unsigned short iLR = 0; iLR < 2; ++iLR) {
349 unsigned short iLRp = abs(iLR - 1);
351 const std::vector<float> params =
getXtParams(iCL, iLRp, iA, iT);
353 std::cout <<
" " << params[i];
355 std::cout <<
" " << std::endl;
367 std::ofstream fout(fileName);
370 B2ERROR(
"Specified output file could not be opened!");
372 const double deg = 180. / M_PI;
375 fout << nAlphaBins << std::endl;
377 for (
unsigned short i = 0; i < nAlphaBins; ++i) {
382 fout << nThetaBins << std::endl;
384 for (
unsigned short i = 0; i < nThetaBins; ++i) {
390 signed short phiAngle = 0.;
391 for (
unsigned short iT = 0; iT < nThetaBins; ++iT) {
392 for (
unsigned short iA = 0; iA < nAlphaBins; ++iA) {
393 for (
unsigned short iCL = 0; iCL <
c_nSLayers; ++iCL) {
394 for (
unsigned short iLR = 0; iLR < 2; ++iLR) {
395 unsigned short iLRp = abs(iLR - 1);
396 fout << std::setw(2) << std::right << std::fixed << iCL <<
" " << std::setw(5) << std::setprecision(
397 1) << deg*
m_thetaBins[iT][2] <<
" " << std::setw(5) << std::right << deg*
m_alphaBins[iA][2] <<
" " << std::setw(
398 1) << std::setprecision(1) << phiAngle <<
" " << std::setw(1) << iLRp;
399 const std::vector<float> params =
getXtParams(iCL, iLRp, iA, iT);
401 fout <<
" " << std::setw(15) << std::scientific << std::setprecision(8) << params[i];
416 double getGlobalParam(
unsigned short xtId,
unsigned short xtParam)
const
421 void setGlobalParam(
double value,
unsigned short xtId,
unsigned short xtParam)
424 allParams.at(xtParam) = value;
428 std::vector<std::pair<unsigned short, unsigned short>>
listGlobalParams()
const
437 std::map<XtID, std::vector<float>>