Belle II Software development
CDCXtRelations Class Reference

Database object for xt-relations. More...

#include <CDCXtRelations.h>

Inheritance diagram for CDCXtRelations:

Public Types

enum  {
  c_nSLayers = 56 ,
  c_maxNAlphaBins = 18 ,
  c_maxNThetaBins = 7 ,
  c_maxNXtParams = 8
}
 Constants. More...
 

Public Member Functions

 CDCXtRelations ()
 Default constructor.
 
void setAlphaBin (const array3 &alpha)
 Set alpha-angle bin (rad)
 
void setThetaBin (const array3 &theta)
 Set theta-angle bin (rad)
 
void setXtParamMode (unsigned short mode)
 Set xt parameterization mode.
 
void setXtParams (const XtID xtID, const std::vector< float > &params)
 Set xt parameters for the specified id.
 
void setXtParams (unsigned short iCLayer, unsigned short iLR, unsigned short iAlpha, unsigned short iTheta, const std::vector< float > &params)
 Set xt parameters for the specified id.
 
void addXTParams (const XtID xtID, const std::vector< float > &delta)
 Update xt parameters for the specified id.
 
void addXTParams (unsigned short iCLayer, unsigned short iLR, unsigned short iAlpha, unsigned short iTheta, const std::vector< float > &delta)
 Update xt parameters for the specified id.
 
void replaceXTParams (const XtID xtID, const std::vector< float > &param)
 Replace xt parameters for the specified id.
 
void replaceXTParams (unsigned short iCLayer, unsigned short iLR, unsigned short iAlpha, unsigned short iTheta, const std::vector< float > &param)
 Replace xt parameters for the specified id.
 
unsigned short getNoOfAlphaBins () const
 Get no.
 
unsigned short getNoOfThetaBins () const
 Get no.
 
const array3getAlphaBin (unsigned short i) const
 Get i-th alpha-angle bin info.
 
float getAlphaPoint (unsigned short i) const
 Get i-th alpha-angle point (rad)
 
const array3getThetaBin (unsigned short i) const
 Get i-th theta-angle bin info.
 
float getThetaPoint (unsigned short i) const
 Get i-th theta-angle point (rad)
 
unsigned short getXtParamMode () const
 Get xt parameterization mode.
 
XtID getXtID (unsigned short iCLayer, unsigned short iLR, unsigned short iAlpha, unsigned short iTheta) const
 Get xt id.
 
XtID getXtID (unsigned short iCLayer, unsigned short iLR, float alpha, float theta) const
 Get xt id.
 
const std::vector< float > & getXtParams (const XtID xtID) const
 Get xt parameters for the specified id.
 
const std::vector< float > & getXtParams (unsigned short iCLayer, unsigned short iLR, unsigned short iAlpha, unsigned short iTheta) const
 Get xt parameters for the specified id.
 
void dump () const
 Print all contents.
 
void outputToFile (std::string fileName) const
 Output the contents in test file format.
 
double getGlobalParam (unsigned short xtId, unsigned short i) const
 Get global parameter for i-th component of the specified xtId.
 
void setGlobalParam (double value, unsigned short xtId, unsigned short i)
 Set global parameter for i-th component of the specified xtId.
 
std::vector< std::pair< unsigned short, unsigned short > > listGlobalParams () const
 list stored global parameters TODO FIXME CDC not ready
 

Static Public Member Functions

static bool comp (const array3 &lhs, const array3 &rhs)
 Static function for sorting.
 
static unsigned short getGlobalUniqueID ()
 Get global unique id.
 

Private Types

typedef std::array< float, 3 > array3
 angle bin info.
 
typedef unsigned short XtID
 id.
 

Private Member Functions

 ClassDef (CDCXtRelations, 2)
 ClassDef.
 

Private Attributes

unsigned short m_xtParamMode
 Mode for xt parameterization.
 
unsigned short m_nXtParams
 no.
 
std::vector< array3m_alphaBins
 alpha bins for xt (rad)
 
std::vector< array3m_thetaBins
 theta bins for xt (rad)
 
std::map< XtID, std::vector< float > > m_xts
 XT-relation coefficients for each layer, Left/Right, entrance angle and polar angle.
 

Detailed Description

Database object for xt-relations.

Definition at line 28 of file CDCXtRelations.h.

Member Typedef Documentation

◆ array3

typedef std::array<float, 3> array3
private

angle bin info.

Definition at line 30 of file CDCXtRelations.h.

◆ XtID

typedef unsigned short XtID
private

id.

for xt

Definition at line 31 of file CDCXtRelations.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum

Constants.

Enumerator
c_nSLayers 

no.

of layers

c_maxNAlphaBins 

max.

no. of alpha angle bins

c_maxNThetaBins 

max.

no. of theta angle bins

c_maxNXtParams 

max.

no. of params. for xt

Definition at line 37 of file CDCXtRelations.h.

Constructor & Destructor Documentation

◆ CDCXtRelations()

CDCXtRelations ( )
inline

Default constructor.

Definition at line 46 of file CDCXtRelations.h.

47 {}
unsigned short m_xtParamMode
Mode for xt parameterization.
unsigned short m_nXtParams
no.

Member Function Documentation

◆ addXTParams() [1/2]

void addXTParams ( const XtID  xtID,
const std::vector< float > &  delta 
)
inline

Update xt parameters for the specified id.

(=bin)

Definition at line 121 of file CDCXtRelations.h.

122 {
123 std::map<XtID, std::vector<float>>::iterator it = m_xts.find(xtID);
124
125 if (it != m_xts.end()) {
126 for (unsigned short i = 0; i < m_nXtParams; ++i) {
127 (it->second)[i] += delta[i];
128 }
129 } else {
130 B2FATAL("Specified xt params not found in addXTParams !");
131 }
132 }
std::map< XtID, std::vector< float > > m_xts
XT-relation coefficients for each layer, Left/Right, entrance angle and polar angle.

◆ addXTParams() [2/2]

void addXTParams ( unsigned short  iCLayer,
unsigned short  iLR,
unsigned short  iAlpha,
unsigned short  iTheta,
const std::vector< float > &  delta 
)
inline

Update xt parameters for the specified id.

(=bin)

Definition at line 137 of file CDCXtRelations.h.

139 {
140 const XtID xtID = getXtID(iCLayer, iLR, iAlpha, iTheta);
141 addXTParams(xtID, delta);
142 }
XtID getXtID(unsigned short iCLayer, unsigned short iLR, unsigned short iAlpha, unsigned short iTheta) const
Get xt id.
unsigned short XtID
id.
void addXTParams(const XtID xtID, const std::vector< float > &delta)
Update xt parameters for the specified id.

◆ comp()

static bool comp ( const array3 lhs,
const array3 rhs 
)
inlinestatic

Static function for sorting.

Definition at line 79 of file CDCXtRelations.h.

80 {
81 return lhs[0] < rhs[0];
82 }

◆ dump()

void dump ( ) const
inline

Print all contents.

Definition at line 319 of file CDCXtRelations.h.

320 {
321 std::cout << " " << std::endl;
322 std::cout << "Contents of xt db" << std::endl;
323 std::cout << "alpha bins" << std::endl;
324
325 const double deg = 180. / M_PI;
326
327 unsigned short nAlphaBins = m_alphaBins.size();
328 for (unsigned short i = 0; i < nAlphaBins; ++i) {
329 std::cout << " " << deg* m_alphaBins[i][0] << " " << deg* m_alphaBins[i][1] << " " << deg* m_alphaBins[i][2] << " " << std::endl;
330 }
331
332 std::cout << " " << std::endl;
333 std::cout << "theta bins" << std::endl;
334
335 unsigned short nThetaBins = m_thetaBins.size();
336 for (unsigned short i = 0; i < nThetaBins; ++i) {
337 std::cout << " " << deg* m_thetaBins[i][0] << " " << deg* m_thetaBins[i][1] << " " << deg* m_thetaBins[i][2] << " " << std::endl;
338 }
339
340 std::cout << " " << std::endl;
341 std::cout << "coefficients for xt" << std::endl;
342
343 for (unsigned short iT = 0; iT < nThetaBins; ++iT) {
344 for (unsigned short iA = 0; iA < nAlphaBins; ++iA) {
345 for (unsigned short iCL = 0; iCL < c_nSLayers; ++iCL) {
346 for (unsigned short iLR = 0; iLR < 2; ++iLR) {
347 unsigned short iLRp = abs(iLR - 1);
348 std::cout << iCL << " " << deg* m_thetaBins[iT][2] << " " << deg* m_alphaBins[iA][2] << " " << iLRp;
349 const std::vector<float> params = getXtParams(iCL, iLRp, iA, iT);
350 for (unsigned short i = 0; i < m_nXtParams; ++i) {
351 std::cout << " " << params[i];
352 }
353 std::cout << " " << std::endl;
354 }
355 }
356 }
357 }
358 }
const std::vector< float > & getXtParams(const XtID xtID) const
Get xt parameters for the specified id.
std::vector< array3 > m_alphaBins
alpha bins for xt (rad)
std::vector< array3 > m_thetaBins
theta bins for xt (rad)

◆ getAlphaBin()

const array3 & getAlphaBin ( unsigned short  i) const
inline

Get i-th alpha-angle bin info.

(rad)

Definition at line 190 of file CDCXtRelations.h.

191 {
192 return m_alphaBins[i];
193 }

◆ getAlphaPoint()

float getAlphaPoint ( unsigned short  i) const
inline

Get i-th alpha-angle point (rad)

Definition at line 198 of file CDCXtRelations.h.

199 {
200 return m_alphaBins[i][2];
201 }

◆ getGlobalParam()

double getGlobalParam ( unsigned short  xtId,
unsigned short  i 
) const
inline

Get global parameter for i-th component of the specified xtId.

Definition at line 414 of file CDCXtRelations.h.

415 {
416 return getXtParams(xtId).at(i);
417 }

◆ getGlobalUniqueID()

static unsigned short getGlobalUniqueID ( )
inlinestatic

Get global unique id.

Definition at line 412 of file CDCXtRelations.h.

412{return 29;}

◆ getNoOfAlphaBins()

unsigned short getNoOfAlphaBins ( ) const
inline

Get no.

of alpha-angle bin

Definition at line 174 of file CDCXtRelations.h.

175 {
176 return m_alphaBins.size();
177 }

◆ getNoOfThetaBins()

unsigned short getNoOfThetaBins ( ) const
inline

Get no.

of theta-angle bin

Definition at line 182 of file CDCXtRelations.h.

183 {
184 return m_thetaBins.size();
185 }

◆ getThetaBin()

const array3 & getThetaBin ( unsigned short  i) const
inline

Get i-th theta-angle bin info.

(rad)

Definition at line 206 of file CDCXtRelations.h.

207 {
208 return m_thetaBins[i];
209 }

◆ getThetaPoint()

float getThetaPoint ( unsigned short  i) const
inline

Get i-th theta-angle point (rad)

Definition at line 214 of file CDCXtRelations.h.

215 {
216 return m_thetaBins[i][2];
217 }

◆ getXtID() [1/2]

XtID getXtID ( unsigned short  iCLayer,
unsigned short  iLR,
float  alpha,
float  theta 
) const
inline

Get xt id.

(=bin id.)

Definition at line 243 of file CDCXtRelations.h.

244 {
245 /*
246 unsigned short iTheta = 999;
247 unsigned short ibin = 0;
248 for (std::vector<array3>::const_iterator it = m_thetaBins.begin(); it != m_thetaBins.end(); ++it) {
249 if ((*it)[0] <= theta && theta <= (*it)[1]) {
250 iTheta = ibin;
251 break;
252 }
253 ++ibin;
254 }
255 */
256 unsigned short iTheta = 999;
257 unsigned short ibin = 0;
258 for (auto const& it : m_thetaBins) {
259 if (it[0] <= theta && theta <= it[1]) {
260 iTheta = ibin;
261 break;
262 }
263 ++ibin;
264 }
265 if (iTheta == 999) B2FATAL("Theta bin not found !");
266
267 /*
268 unsigned short iAlpha = 999;
269 ibin = 0;
270 for (std::vector<array3>::const_iterator it = m_alphaBins.begin(); it != m_alphaBins.end(); ++it) {
271 if ((*it)[0] <= alpha && alpha <= (*it)[1]) {
272 iAlpha = ibin;
273 break;
274 }
275 ++ibin;
276 }
277 */
278 unsigned short iAlpha = 999;
279 ibin = 0;
280 for (auto const& it : m_alphaBins) {
281 if (it[0] <= alpha && alpha <= it[1]) {
282 iAlpha = ibin;
283 break;
284 }
285 ++ibin;
286 }
287 if (iAlpha == 999) B2FATAL("Alpha bin not found ! " << alpha);
288
289 return getXtID(iCLayer, iLR, iAlpha, iTheta);
290 }

◆ getXtID() [2/2]

XtID getXtID ( unsigned short  iCLayer,
unsigned short  iLR,
unsigned short  iAlpha,
unsigned short  iTheta 
) const
inline

Get xt id.

(=bin id.) bit#00 - 05: used for layer no. bit#06 - 06: used for left/right bit#07 - 11: used for alpha angle bin bit#12 - 15: used for theta angle bin

Definition at line 234 of file CDCXtRelations.h.

235 {
236 XtID id = iCLayer + 64 * iLR + 128 * iAlpha + 4096 * iTheta;
237 return id;
238 }

◆ getXtParamMode()

unsigned short getXtParamMode ( ) const
inline

Get xt parameterization mode.

Definition at line 222 of file CDCXtRelations.h.

223 {
224 return m_xtParamMode;
225 }

◆ getXtParams() [1/2]

const std::vector< float > & getXtParams ( const XtID  xtID) const
inline

Get xt parameters for the specified id.

(=bin)

Definition at line 295 of file CDCXtRelations.h.

296 {
297 std::map<XtID, std::vector<float>>::const_iterator it = m_xts.find(xtID);
298 if (it != m_xts.end()) {
299 return it->second;
300 } else {
301 B2FATAL("Specified xt params. not found in getXtParams !");
302 }
303 }

◆ getXtParams() [2/2]

const std::vector< float > & getXtParams ( unsigned short  iCLayer,
unsigned short  iLR,
unsigned short  iAlpha,
unsigned short  iTheta 
) const
inline

Get xt parameters for the specified id.

(=bin)

Definition at line 308 of file CDCXtRelations.h.

310 {
311 const XtID xtID = getXtID(iCLayer, iLR, iAlpha, iTheta);
312 // std::cout <<"xtID in getXtParams= " << xtID << std::endl;
313 return getXtParams(xtID);
314 }

◆ listGlobalParams()

std::vector< std::pair< unsigned short, unsigned short > > listGlobalParams ( ) const
inline

list stored global parameters TODO FIXME CDC not ready

Definition at line 435 of file CDCXtRelations.h.

436 {
437 std::vector<std::pair<unsigned short, unsigned short>> result;
438 for (auto ixt : m_xts) {
439 for (int i = 0; i < 8; ++i) {
440 result.push_back({ixt.first, i});
441 }
442 }
443 return result;
444 }

◆ outputToFile()

void outputToFile ( std::string  fileName) const
inline

Output the contents in test file format.

Definition at line 363 of file CDCXtRelations.h.

364 {
365 std::ofstream fout(fileName);
366
367 if (fout.bad()) {
368 B2ERROR("Specified output file could not be opened!");
369 } else {
370 const double deg = 180. / M_PI;
371
372 unsigned short nAlphaBins = m_alphaBins.size();
373 fout << nAlphaBins << std::endl;
374
375 for (unsigned short i = 0; i < nAlphaBins; ++i) {
376 fout << deg* m_alphaBins[i][0] << " " << deg* m_alphaBins[i][1] << " " << deg* m_alphaBins[i][2] << std::endl;
377 }
378
379 unsigned short nThetaBins = m_thetaBins.size();
380 fout << nThetaBins << std::endl;
381
382 for (unsigned short i = 0; i < nThetaBins; ++i) {
383 fout << deg* m_thetaBins[i][0] << " " << deg* m_thetaBins[i][1] << " " << deg* m_thetaBins[i][2] << std::endl;
384 }
385
386 fout << m_xtParamMode << " " << m_nXtParams << std::endl;
387
388 signed short phiAngle = 0.;
389 for (unsigned short iT = 0; iT < nThetaBins; ++iT) {
390 for (unsigned short iA = 0; iA < nAlphaBins; ++iA) {
391 for (unsigned short iCL = 0; iCL < c_nSLayers; ++iCL) {
392 for (unsigned short iLR = 0; iLR < 2; ++iLR) {
393 unsigned short iLRp = abs(iLR - 1);
394 fout << std::setw(2) << std::right << std::fixed << iCL << " " << std::setw(5) << std::setprecision(
395 1) << deg* m_thetaBins[iT][2] << " " << std::setw(5) << std::right << deg* m_alphaBins[iA][2] << " " << std::setw(
396 1) << std::setprecision(1) << phiAngle << " " << std::setw(1) << iLRp;
397 const std::vector<float> params = getXtParams(iCL, iLRp, iA, iT);
398 for (unsigned short i = 0; i < m_nXtParams; ++i) {
399 fout << " " << std::setw(15) << std::scientific << std::setprecision(8) << params[i];
400 }
401 fout << std::endl;
402 }
403 }
404 }
405 }
406 fout.close();
407 }
408 }

◆ replaceXTParams() [1/2]

void replaceXTParams ( const XtID  xtID,
const std::vector< float > &  param 
)
inline

Replace xt parameters for the specified id.

(=bin)

Definition at line 147 of file CDCXtRelations.h.

148 {
149 std::map<XtID, std::vector<float>>::iterator it = m_xts.find(xtID);
150
151 if (it != m_xts.end()) {
152 for (unsigned short i = 0; i < m_nXtParams; ++i) {
153 (it->second)[i] = param[i];
154 }
155 } else {
156 B2FATAL("Specified xt params not found in replaceXTParams !");
157 }
158 }

◆ replaceXTParams() [2/2]

void replaceXTParams ( unsigned short  iCLayer,
unsigned short  iLR,
unsigned short  iAlpha,
unsigned short  iTheta,
const std::vector< float > &  param 
)
inline

Replace xt parameters for the specified id.

(=bin)

Definition at line 163 of file CDCXtRelations.h.

165 {
166 const XtID xtID = getXtID(iCLayer, iLR, iAlpha, iTheta);
167 replaceXTParams(xtID, param);
168 }
void replaceXTParams(const XtID xtID, const std::vector< float > &param)
Replace xt parameters for the specified id.

◆ setAlphaBin()

void setAlphaBin ( const array3 alpha)
inline

Set alpha-angle bin (rad)

Definition at line 52 of file CDCXtRelations.h.

53 {
54 if (m_alphaBins.size() <= c_maxNAlphaBins) {
55 m_alphaBins.push_back(alpha);
56 sort(m_alphaBins.begin(), m_alphaBins.end(), comp);
57 } else {
58 // std::cout<< m_alphaBins.size() <<" "<< c_maxNAlphaBins <<std::endl;
59 B2FATAL("The no. of alpha bins > limit !");
60 }
61 }
static bool comp(const array3 &lhs, const array3 &rhs)
Static function for sorting.

◆ setGlobalParam()

void setGlobalParam ( double  value,
unsigned short  xtId,
unsigned short  i 
)
inline

Set global parameter for i-th component of the specified xtId.

Definition at line 419 of file CDCXtRelations.h.

420 {
421
422 std::map<XtID, std::vector<float>>::const_iterator it = m_xts.find(xtId);
423 if (it != m_xts.end()) {
424 std::vector<float> allParams = it->second;
425 allParams.at(i) = value;
426 setXtParams(xtId, allParams);
427 } else {
428 B2INFO("Specified xt params. not found in getXtParams.");
429 std::vector<float> allParams {0., 0., 0., 0., 0., 0., 0., 0.};
430 allParams.at(i) = value;
431 setXtParams(xtId, allParams);
432 }
433 }
void setXtParams(const XtID xtID, const std::vector< float > &params)
Set xt parameters for the specified id.

◆ setThetaBin()

void setThetaBin ( const array3 theta)
inline

Set theta-angle bin (rad)

Definition at line 66 of file CDCXtRelations.h.

67 {
68 if (m_thetaBins.size() <= c_maxNThetaBins) {
69 m_thetaBins.push_back(theta);
70 sort(m_thetaBins.begin(), m_thetaBins.end(), comp);
71 } else {
72 B2FATAL("The no. of theta bins > limit !");
73 }
74 }

◆ setXtParamMode()

void setXtParamMode ( unsigned short  mode)
inline

Set xt parameterization mode.

Definition at line 87 of file CDCXtRelations.h.

88 {
89 m_xtParamMode = mode;
90 }

◆ setXtParams() [1/2]

void setXtParams ( const XtID  xtID,
const std::vector< float > &  params 
)
inline

Set xt parameters for the specified id.

(=bin)

Definition at line 95 of file CDCXtRelations.h.

96 {
97 unsigned short nXtParams = params.size();
98
99 if (nXtParams <= c_maxNXtParams) {
100 m_nXtParams = nXtParams;
101 m_xts.insert(std::pair<XtID, std::vector<float>>(xtID, params));
102 // std::cout <<"xtID in setXtParams= " << xtID << std::endl;
103 } else {
104 B2FATAL("The no. of xt params. > limit !");
105 }
106 }

◆ setXtParams() [2/2]

void setXtParams ( unsigned short  iCLayer,
unsigned short  iLR,
unsigned short  iAlpha,
unsigned short  iTheta,
const std::vector< float > &  params 
)
inline

Set xt parameters for the specified id.

(=bin)

Definition at line 111 of file CDCXtRelations.h.

113 {
114 const XtID xtID = getXtID(iCLayer, iLR, iAlpha, iTheta);
115 setXtParams(xtID, params);
116 }

Member Data Documentation

◆ m_alphaBins

std::vector<array3> m_alphaBins
private

alpha bins for xt (rad)

Definition at line 448 of file CDCXtRelations.h.

◆ m_nXtParams

unsigned short m_nXtParams
private

no.

of xt parameters per bin

Definition at line 447 of file CDCXtRelations.h.

◆ m_thetaBins

std::vector<array3> m_thetaBins
private

theta bins for xt (rad)

Definition at line 449 of file CDCXtRelations.h.

◆ m_xtParamMode

unsigned short m_xtParamMode
private

Mode for xt parameterization.

Definition at line 446 of file CDCXtRelations.h.

◆ m_xts

std::map<XtID, std::vector<float> > m_xts
private

XT-relation coefficients for each layer, Left/Right, entrance angle and polar angle.


Definition at line 451 of file CDCXtRelations.h.


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