Belle II Software development
CDCTimeWalks Class Reference

Database object for time-walk. More...

#include <CDCTimeWalks.h>

Inheritance diagram for CDCTimeWalks:

Public Member Functions

 CDCTimeWalks ()
 Default constructor.
 
void setTwParamMode (unsigned short mode)
 Set tw parameterization mode mode=0: tw (in ns) = p0/sqrt(FADCsum); mode=1: tw( in ns) = p0*exp(-p1*FADCsum).
 
void setTimeWalkParams (unsigned short boardID, const std::vector< float > &params)
 Set the time-walk coefficients in the list.
 
void addTimeWalks (unsigned short boardID, const std::vector< float > &deltas)
 Update the time-walk coefficients in the list.
 
unsigned short getTwParamMode () const
 Get tw parameterization mode.
 
unsigned short getEntries () const
 Get the no.
 
std::map< unsigned short, std::vector< float > > getTimeWalkParams () const
 Get the whole list.
 
const std::vector< float > & getTimeWalkParams (unsigned short boardID) const
 Get the time-walk coefficients for the board.
 
void dump () const
 Print all contents.
 
void outputToFile (std::string fileName) const
 Output the contents in text file format.
 
double getGlobalParam (unsigned short element, unsigned short i) const
 Get global parameter.
 
void setGlobalParam (double value, unsigned short element, unsigned short i)
 Set global parameter.
 
std::vector< std::pair< unsigned short, unsigned short > > listGlobalParams () const
 list stored global parameters
 

Static Public Member Functions

static unsigned short getGlobalUniqueID ()
 Get global unique id.
 

Private Member Functions

 ClassDef (CDCTimeWalks, 2)
 ClassDef.
 

Private Attributes

unsigned short m_twParamMode
 Mode for tw parameterization; the initial value should be the one for classdef=1; do not modify it.
 
unsigned short m_nTwParams
 No.
 
std::map< unsigned short, std::vector< float > > m_tws
 tw list
 

Detailed Description

Database object for time-walk.

Definition at line 25 of file CDCTimeWalks.h.

Constructor & Destructor Documentation

◆ CDCTimeWalks()

CDCTimeWalks ( )
inline

Default constructor.

Definition at line 31 of file CDCTimeWalks.h.

31{}

Member Function Documentation

◆ addTimeWalks()

void addTimeWalks ( unsigned short  boardID,
const std::vector< float > &  deltas 
)
inline

Update the time-walk coefficients in the list.

Parameters
boardIDfront-end board id.
deltasdelta-coefficients

Definition at line 59 of file CDCTimeWalks.h.

60 {
61 std::map<unsigned short, std::vector<float>>::iterator it = m_tws.find(boardID);
62 if (it != m_tws.end()) {
63 for (unsigned short i = 0; i < m_nTwParams; ++i) {
64 (it->second)[i] += deltas[i];
65 }
66 } else {
67 B2FATAL("Specified tw params not found in addTimeWalks !");
68 }
69 }
unsigned short m_nTwParams
No.
Definition: CDCTimeWalks.h:186
std::map< unsigned short, std::vector< float > > m_tws
tw list
Definition: CDCTimeWalks.h:188

◆ dump()

void dump ( ) const
inline

Print all contents.

Definition at line 114 of file CDCTimeWalks.h.

115 {
116 std::cout << " " << std::endl;
117 std::cout << "Time walk coefficient list" << std::endl;
118 std::cout << "#entries= " << m_tws.size() << std::endl;
119 std::cout << m_twParamMode << " " << m_nTwParams << std::endl;
120 std::cout << "in order of board# and coefficients" << std::endl;
121
122 for (auto const& ent : m_tws) {
123 std::cout << ent.first;
124 for (unsigned short i = 0; i < m_nTwParams; ++i) {
125 std::cout << " " << (ent.second)[i];
126 }
127 std::cout << std::endl;
128 }
129 }
unsigned short m_twParamMode
Mode for tw parameterization; the initial value should be the one for classdef=1; do not modify it.
Definition: CDCTimeWalks.h:184

◆ getEntries()

unsigned short getEntries ( ) const
inline

Get the no.

of entries in the list

Definition at line 83 of file CDCTimeWalks.h.

84 {
85 return m_tws.size();
86 }

◆ getGlobalParam()

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

Get global parameter.

Definition at line 157 of file CDCTimeWalks.h.

158 {
159 return (getTimeWalkParams(element))[i];
160 }
std::map< unsigned short, std::vector< float > > getTimeWalkParams() const
Get the whole list.
Definition: CDCTimeWalks.h:91

◆ getGlobalUniqueID()

static unsigned short getGlobalUniqueID ( )
inlinestatic

Get global unique id.

Definition at line 155 of file CDCTimeWalks.h.

155{return 26;}

◆ getTimeWalkParams() [1/2]

std::map< unsigned short, std::vector< float > > getTimeWalkParams ( ) const
inline

Get the whole list.

Definition at line 91 of file CDCTimeWalks.h.

92 {
93 return m_tws;
94 }

◆ getTimeWalkParams() [2/2]

const std::vector< float > & getTimeWalkParams ( unsigned short  boardID) const
inline

Get the time-walk coefficients for the board.

Parameters
boardIDfront-end board id.
Returns
time-walk coefficients for the board id.

Definition at line 101 of file CDCTimeWalks.h.

102 {
103 std::map<unsigned short, std::vector<float>>::const_iterator it = m_tws.find(boardID);
104 if (it != m_tws.end()) {
105 return it->second;
106 } else {
107 B2FATAL("Specified tw params not found in getTimeWalks !");
108 }
109 }

◆ getTwParamMode()

unsigned short getTwParamMode ( ) const
inline

Get tw parameterization mode.

Definition at line 75 of file CDCTimeWalks.h.

76 {
77 return m_twParamMode;
78 }

◆ listGlobalParams()

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

list stored global parameters

Definition at line 172 of file CDCTimeWalks.h.

173 {
174 std::vector<std::pair<unsigned short, unsigned short>> result;
175 for (auto id_timewalk : m_tws) {
176 result.push_back({id_timewalk.first, 0});
177 result.push_back({id_timewalk.first, 1});
178 }
179 return result;
180 }

◆ outputToFile()

void outputToFile ( std::string  fileName) const
inline

Output the contents in text file format.

Definition at line 134 of file CDCTimeWalks.h.

135 {
136 std::ofstream fout(fileName);
137
138 if (fout.bad()) {
139 B2ERROR("Specified output file could not be opened!");
140 } else {
141 fout << m_twParamMode << " " << m_nTwParams << std::endl;
142 for (auto const& ent : m_tws) {
143 fout << std::setw(3) << std::right << ent.first;
144 for (unsigned short i = 0; i < m_nTwParams; ++i) {
145 fout << " " << std::setw(15) << std::scientific << std::setprecision(8) << ent.second[i];
146 }
147 fout << std::endl;
148 }
149 fout.close();
150 }
151 }

◆ setGlobalParam()

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

Set global parameter.

Definition at line 162 of file CDCTimeWalks.h.

163 {
164 std::map<unsigned short, std::vector<float>>::iterator it = m_tws.find(element);
165 if (it != m_tws.end()) {
166 (it->second)[i] = static_cast<float>(value);
167 } else {
168 m_tws.insert(std::pair<unsigned short, std::vector<float>>(element, {static_cast<float>(value), 0.}));
169 }
170 }

◆ setTimeWalkParams()

void setTimeWalkParams ( unsigned short  boardID,
const std::vector< float > &  params 
)
inline

Set the time-walk coefficients in the list.

Parameters
boardIDfront-end board id.
paramscoefficients for the time-walk corr. term

Definition at line 48 of file CDCTimeWalks.h.

49 {
50 m_nTwParams = params.size();
51 m_tws.insert(std::pair<unsigned short, std::vector<float>>(boardID, params));
52 }

◆ setTwParamMode()

void setTwParamMode ( unsigned short  mode)
inline

Set tw parameterization mode mode=0: tw (in ns) = p0/sqrt(FADCsum); mode=1: tw( in ns) = p0*exp(-p1*FADCsum).

Definition at line 38 of file CDCTimeWalks.h.

39 {
40 m_twParamMode = mode;
41 }

Member Data Documentation

◆ m_nTwParams

unsigned short m_nTwParams
private
Initial value:
=
2

No.

of tw parameters; the initial value should be the one for classdef=1; do not modify it.

Definition at line 186 of file CDCTimeWalks.h.

◆ m_twParamMode

unsigned short m_twParamMode
private
Initial value:
=
1

Mode for tw parameterization; the initial value should be the one for classdef=1; do not modify it.

Definition at line 184 of file CDCTimeWalks.h.

◆ m_tws

std::map<unsigned short, std::vector<float> > m_tws
private

tw list

Definition at line 188 of file CDCTimeWalks.h.


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