Belle II Software development
CDCSpaceResols Class Reference

Database object for space resolutions. More...

#include <CDCSpaceResols.h>

Inheritance diagram for CDCSpaceResols:

Public Types

enum  {
  c_nSLayers = 56 ,
  c_maxNAlphaBins = 18 ,
  c_maxNThetaBins = 7 ,
  c_maxNSigmaParams = 9
}
 Constants. More...
 

Public Member Functions

 CDCSpaceResols ()
 Default constructor.
 
void setAlphaBin (const array3 &alpha)
 Set alpha-angle bin (rad)
 
void setThetaBin (const array3 &theta)
 Set theta-angle bin (rad)
 
void setSigmaParamMode (unsigned short mode)
 Set sigma parameterization mode.
 
void setMaxSpaceResol (float sigma)
 Set max.
 
void setSigmaParams (const SigmaID sigmaID, const std::vector< float > &params)
 Set sigma parameters for the specified id.
 
void setSigmaParams (unsigned short iCLayer, unsigned short iLR, unsigned short iAlpha, unsigned short iTheta, const std::vector< float > &params)
 Set sigma parameters for the specified id.
 
void addSigmaParams (const SigmaID sigmaID, const std::vector< float > &delta)
 Update parameters for the specified id.
 
void addSigmaParams (unsigned short iCLayer, unsigned short iLR, unsigned short iAlpha, unsigned short iTheta, const std::vector< float > &delta)
 Update 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 getSigmaParamMode () const
 Get parameterization mode.
 
float getMaxSpaceResol () const
 Get max.
 
SigmaID getSigmaID (unsigned short iCLayer, unsigned short iLR, unsigned short iAlpha, unsigned short iTheta) const
 Get id.
 
SigmaID getSigmaID (unsigned short iCLayer, unsigned short iLR, float alpha, float theta) const
 Get id.
 
const std::vector< float > & getSigmaParams (const SigmaID sigmaID) const
 Get sigma parameters for the specified id.
 
const std::vector< float > & getSigmaParams (unsigned short iCLayer, unsigned short iLR, unsigned short iAlpha, unsigned short iTheta) const
 Get sigma parameters for the specified id.
 
void dump () const
 Print all contents.
 
void outputToFile (std::string fileName) const
 Output the contents in text file format.
 

Static Public Member Functions

static bool comp (const array3 &lhs, const array3 &rhs)
 Static function for sorting.
 

Private Types

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

Private Member Functions

 ClassDef (CDCSpaceResols, 2)
 ClassDef.
 

Private Attributes

unsigned short m_sigmaParamMode
 Mode for sigma parameterization.
 
unsigned short m_nSigmaParams
 no.
 
float m_maxSpaceResol = 0.07
 max.
 
std::vector< array3m_alphaBins
 alpha bins for sigma (rad)
 
std::vector< array3m_thetaBins
 theta bins for sigma (rad)
 
std::map< SigmaID, std::vector< float > > m_sigmas
 Sigma coefficients for each layer, Left/Right, entrance angle and polar angle.
 

Detailed Description

Database object for space resolutions.

Definition at line 26 of file CDCSpaceResols.h.

Member Typedef Documentation

◆ array3

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

angle bin info.

Definition at line 28 of file CDCSpaceResols.h.

◆ SigmaID

typedef unsigned short SigmaID
private

id.

for resol.

Definition at line 29 of file CDCSpaceResols.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_maxNSigmaParams 

max.

no. of params. for sigma

Definition at line 35 of file CDCSpaceResols.h.

Constructor & Destructor Documentation

◆ CDCSpaceResols()

CDCSpaceResols ( )
inline

Default constructor.

Definition at line 44 of file CDCSpaceResols.h.

45 {}
unsigned short m_nSigmaParams
no.
unsigned short m_sigmaParamMode
Mode for sigma parameterization.

Member Function Documentation

◆ addSigmaParams() [1/2]

void addSigmaParams ( const SigmaID  sigmaID,
const std::vector< float > &  delta 
)
inline

Update parameters for the specified id.

(=bin)

Definition at line 127 of file CDCSpaceResols.h.

128 {
129 std::map<SigmaID, std::vector<float>>::iterator it = m_sigmas.find(sigmaID);
130
131 if (it != m_sigmas.end()) {
132 for (unsigned short i = 0; i < m_nSigmaParams; ++i) {
133 (it->second)[i] += delta[i];
134 }
135 } else {
136 B2FATAL("Specified params not found in addSigmaParams !");
137 }
138 }
std::map< SigmaID, std::vector< float > > m_sigmas
Sigma coefficients for each layer, Left/Right, entrance angle and polar angle.

◆ addSigmaParams() [2/2]

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

Update parameters for the specified id.

(=bin)

Definition at line 143 of file CDCSpaceResols.h.

145 {
146 const SigmaID sigmaID = getSigmaID(iCLayer, iLR, iAlpha, iTheta);
147 addSigmaParams(sigmaID, delta);
148 }
unsigned short SigmaID
id.
void addSigmaParams(const SigmaID sigmaID, const std::vector< float > &delta)
Update parameters for the specified id.
SigmaID getSigmaID(unsigned short iCLayer, unsigned short iLR, unsigned short iAlpha, unsigned short iTheta) const
Get id.

◆ comp()

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

Static function for sorting.

Definition at line 77 of file CDCSpaceResols.h.

78 {
79 return lhs[0] < rhs[0];
80 }

◆ dump()

void dump ( ) const
inline

Print all contents.

Definition at line 307 of file CDCSpaceResols.h.

308 {
309 std::cout << " " << std::endl;
310 std::cout << "Contents of sigma db" << std::endl;
311 std::cout << "alpha bins" << std::endl;
312
313 const double deg = 180. / M_PI;
314
315 unsigned short nAlphaBins = m_alphaBins.size();
316 for (unsigned short i = 0; i < nAlphaBins; ++i) {
317 std::cout << " " << deg* m_alphaBins[i][0] << " " << deg* m_alphaBins[i][1] << " " << deg* m_alphaBins[i][2] << " " << std::endl;
318 }
319
320 std::cout << " " << std::endl;
321 std::cout << "theta bins" << std::endl;
322
323 unsigned short nThetaBins = m_thetaBins.size();
324 for (unsigned short i = 0; i < nThetaBins; ++i) {
325 std::cout << " " << deg* m_thetaBins[i][0] << " " << deg* m_thetaBins[i][1] << " " << deg* m_thetaBins[i][2] << " " << std::endl;
326 }
327
328 std::cout << " " << std::endl;
329 std::cout << "coefficients for sigma" << std::endl;
330
331 for (unsigned short iT = 0; iT < nThetaBins; ++iT) {
332 for (unsigned short iA = 0; iA < nAlphaBins; ++iA) {
333 for (unsigned short iCL = 0; iCL < c_nSLayers; ++iCL) {
334 for (unsigned short iLR = 0; iLR < 2; ++iLR) {
335 unsigned short iLRp = abs(iLR - 1);
336 std::cout << iCL << " " << deg* m_thetaBins[iT][2] << " " << deg* m_alphaBins[iA][2] << " " << iLRp;
337 const std::vector<float> params = getSigmaParams(iCL, iLRp, iA, iT);
338 for (unsigned short i = 0; i < m_nSigmaParams; ++i) {
339 std::cout << " " << params[i];
340 }
341 std::cout << " " << std::endl;
342 }
343 }
344 }
345 }
346 }
const std::vector< float > & getSigmaParams(const SigmaID sigmaID) const
Get sigma parameters for the specified id.
std::vector< array3 > m_alphaBins
alpha bins for sigma (rad)
std::vector< array3 > m_thetaBins
theta bins for sigma (rad)

◆ getAlphaBin()

const array3 & getAlphaBin ( unsigned short  i) const
inline

Get i-th alpha-angle bin info.

(rad)

Definition at line 170 of file CDCSpaceResols.h.

171 {
172 return m_alphaBins[i];
173 }

◆ getAlphaPoint()

float getAlphaPoint ( unsigned short  i) const
inline

Get i-th alpha-angle point (rad)

Definition at line 178 of file CDCSpaceResols.h.

179 {
180 return m_alphaBins[i][2];
181 }

◆ getMaxSpaceResol()

float getMaxSpaceResol ( ) const
inline

Get max.

allowed space resolution

Definition at line 210 of file CDCSpaceResols.h.

211 {
212 return m_maxSpaceResol;
213 }

◆ getNoOfAlphaBins()

unsigned short getNoOfAlphaBins ( ) const
inline

Get no.

of alpha-angle bin

Definition at line 154 of file CDCSpaceResols.h.

155 {
156 return m_alphaBins.size();
157 }

◆ getNoOfThetaBins()

unsigned short getNoOfThetaBins ( ) const
inline

Get no.

of theta-angle bin

Definition at line 162 of file CDCSpaceResols.h.

163 {
164 return m_thetaBins.size();
165 }

◆ getSigmaID() [1/2]

SigmaID getSigmaID ( unsigned short  iCLayer,
unsigned short  iLR,
float  alpha,
float  theta 
) const
inline

Get id.

(=bin id.)

Definition at line 231 of file CDCSpaceResols.h.

232 {
233 /*
234 unsigned short iTheta = 999;
235 unsigned short ibin = 0;
236 for (std::vector<array3>::const_iterator it = m_thetaBins.begin(); it != m_thetaBins.end(); ++it) {
237 if ((*it)[0] <= theta && theta <= (*it)[1]) {
238 iTheta = ibin;
239 break;
240 }
241 ++ibin;
242 }
243 */
244 unsigned short iTheta = 999;
245 unsigned short ibin = 0;
246 for (auto const& it : m_thetaBins) {
247 if (it[0] <= theta && theta <= it[1]) {
248 iTheta = ibin;
249 break;
250 }
251 ++ibin;
252 }
253 if (iTheta == 999) B2FATAL("Theta bin not found !");
254
255 /*
256 unsigned short iAlpha = 999;
257 ibin = 0;
258 for (std::vector<array3>::const_iterator it = m_alphaBins.begin(); it != m_alphaBins.end(); ++it) {
259 if ((*it)[0] <= alpha && alpha <= (*it)[1]) {
260 iAlpha = ibin;
261 break;
262 }
263 ++ibin;
264 }
265 */
266 unsigned short iAlpha = 999;
267 ibin = 0;
268 for (auto const& it : m_alphaBins) {
269 if (it[0] <= alpha && alpha <= it[1]) {
270 iAlpha = ibin;
271 break;
272 }
273 ++ibin;
274 }
275 if (iAlpha == 999) B2FATAL("Alpha bin not found !");
276
277 return getSigmaID(iCLayer, iLR, iAlpha, iTheta);
278 }

◆ getSigmaID() [2/2]

SigmaID getSigmaID ( unsigned short  iCLayer,
unsigned short  iLR,
unsigned short  iAlpha,
unsigned short  iTheta 
) const
inline

Get 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 222 of file CDCSpaceResols.h.

223 {
224 SigmaID id = iCLayer + 64 * iLR + 128 * iAlpha + 4096 * iTheta;
225 return id;
226 }

◆ getSigmaParamMode()

unsigned short getSigmaParamMode ( ) const
inline

Get parameterization mode.

Definition at line 202 of file CDCSpaceResols.h.

203 {
204 return m_sigmaParamMode;
205 }

◆ getSigmaParams() [1/2]

const std::vector< float > & getSigmaParams ( const SigmaID  sigmaID) const
inline

Get sigma parameters for the specified id.

(=bin)

Definition at line 283 of file CDCSpaceResols.h.

284 {
285 std::map<SigmaID, std::vector<float>>::const_iterator it = m_sigmas.find(sigmaID);
286 if (it != m_sigmas.end()) {
287 return it->second;
288 } else {
289 B2FATAL("Specified params. not found in getSigmaParams !");
290 }
291 }

◆ getSigmaParams() [2/2]

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

Get sigma parameters for the specified id.

(=bin)

Definition at line 296 of file CDCSpaceResols.h.

298 {
299 const SigmaID sigmaID = getSigmaID(iCLayer, iLR, iAlpha, iTheta);
300 // std::cout <<"sigmaID in getSigmaParams= " << sigmaID << std::endl;
301 return getSigmaParams(sigmaID);
302 }

◆ getThetaBin()

const array3 & getThetaBin ( unsigned short  i) const
inline

Get i-th theta-angle bin info.

(rad)

Definition at line 186 of file CDCSpaceResols.h.

187 {
188 return m_thetaBins[i];
189 }

◆ getThetaPoint()

float getThetaPoint ( unsigned short  i) const
inline

Get i-th theta-angle point (rad)

Definition at line 194 of file CDCSpaceResols.h.

195 {
196 return m_thetaBins[i][2];
197 }

◆ outputToFile()

void outputToFile ( std::string  fileName) const
inline

Output the contents in text file format.

Definition at line 351 of file CDCSpaceResols.h.

352 {
353 std::ofstream fout(fileName);
354
355 if (fout.bad()) {
356 B2ERROR("Specified output file could not be opened!");
357 } else {
358 const double deg = 180. / M_PI;
359
360 unsigned short nAlphaBins = m_alphaBins.size();
361 fout << nAlphaBins << std::endl;
362
363 for (unsigned short i = 0; i < nAlphaBins; ++i) {
364 fout << deg* m_alphaBins[i][0] << " " << deg* m_alphaBins[i][1] << " " << deg* m_alphaBins[i][2] << std::endl;
365 }
366
367 unsigned short nThetaBins = m_thetaBins.size();
368 fout << nThetaBins << std::endl;
369
370 for (unsigned short i = 0; i < nThetaBins; ++i) {
371 fout << deg* m_thetaBins[i][0] << " " << deg* m_thetaBins[i][1] << " " << deg* m_thetaBins[i][2] << std::endl;
372 }
373
374 fout << m_sigmaParamMode << " " << m_nSigmaParams << std::endl;
375
376 fout << m_maxSpaceResol << std::endl;
377
378 for (unsigned short iT = 0; iT < nThetaBins; ++iT) {
379 for (unsigned short iA = 0; iA < nAlphaBins; ++iA) {
380 for (unsigned short iCL = 0; iCL < c_nSLayers; ++iCL) {
381 for (unsigned short iLR = 0; iLR < 2; ++iLR) {
382 unsigned short iLRp = abs(iLR - 1);
383 fout << std::setw(2) << std::right << std::fixed << iCL << " " << std::setw(5) << std::setprecision(
384 1) << deg* m_thetaBins[iT][2] << " " << std::setw(5) << std::right << deg* m_alphaBins[iA][2] << " " << std::setw(1) << iLRp;
385 const std::vector<float> params = getSigmaParams(iCL, iLRp, iA, iT);
386 for (unsigned short i = 0; i < m_nSigmaParams; ++i) {
387 fout << " " << std::setw(15) << std::scientific << std::setprecision(8) << params[i];
388 }
389 fout << std::endl;
390 }
391 }
392 }
393 }
394 fout.close();
395 }
396 }

◆ setAlphaBin()

void setAlphaBin ( const array3 alpha)
inline

Set alpha-angle bin (rad)

Definition at line 50 of file CDCSpaceResols.h.

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

◆ setMaxSpaceResol()

void setMaxSpaceResol ( float  sigma)
inline

Set max.

allowed space resolution

Definition at line 93 of file CDCSpaceResols.h.

94 {
95 m_maxSpaceResol = sigma;
96 }

◆ setSigmaParamMode()

void setSigmaParamMode ( unsigned short  mode)
inline

Set sigma parameterization mode.

Definition at line 85 of file CDCSpaceResols.h.

86 {
87 m_sigmaParamMode = mode;
88 }

◆ setSigmaParams() [1/2]

void setSigmaParams ( const SigmaID  sigmaID,
const std::vector< float > &  params 
)
inline

Set sigma parameters for the specified id.

(=bin)

Definition at line 101 of file CDCSpaceResols.h.

102 {
103 unsigned short nSigmaPars = params.size();
104
105 if (nSigmaPars <= c_maxNSigmaParams) {
106 m_nSigmaParams = nSigmaPars;
107 m_sigmas.insert(std::pair<SigmaID, std::vector<float>>(sigmaID, params));
108 // std::cout <<"sigmaID in setSigmaParams= " << sigmaID << std::endl;
109 } else {
110 B2FATAL("The no. of sigma params. > limit !");
111 }
112 }

◆ setSigmaParams() [2/2]

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

Set sigma parameters for the specified id.

(=bin)

Definition at line 117 of file CDCSpaceResols.h.

119 {
120 const SigmaID sigmaID = getSigmaID(iCLayer, iLR, iAlpha, iTheta);
121 setSigmaParams(sigmaID, params);
122 }
void setSigmaParams(const SigmaID sigmaID, const std::vector< float > &params)
Set sigma parameters for the specified id.

◆ setThetaBin()

void setThetaBin ( const array3 theta)
inline

Set theta-angle bin (rad)

Definition at line 64 of file CDCSpaceResols.h.

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

Member Data Documentation

◆ m_alphaBins

std::vector<array3> m_alphaBins
private

alpha bins for sigma (rad)

Definition at line 402 of file CDCSpaceResols.h.

◆ m_maxSpaceResol

float m_maxSpaceResol = 0.07
private

max.

space resol (cm) allowed

Definition at line 401 of file CDCSpaceResols.h.

◆ m_nSigmaParams

unsigned short m_nSigmaParams
private

no.

of sigma parameters per bin

Definition at line 400 of file CDCSpaceResols.h.

◆ m_sigmaParamMode

unsigned short m_sigmaParamMode
private

Mode for sigma parameterization.

Definition at line 399 of file CDCSpaceResols.h.

◆ m_sigmas

std::map<SigmaID, std::vector<float> > m_sigmas
private

Sigma coefficients for each layer, Left/Right, entrance angle and polar angle.


Definition at line 405 of file CDCSpaceResols.h.

◆ m_thetaBins

std::vector<array3> m_thetaBins
private

theta bins for sigma (rad)

Definition at line 403 of file CDCSpaceResols.h.


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