ATLAS Offline Software
Loading...
Searching...
No Matches
TileCalibDrawerFlt Class Reference

Generic class for storing a number of floats (Flt) for each channel or ADC. More...

#include <TileCalibDrawerFlt.h>

Inheritance diagram for TileCalibDrawerFlt:
Collaboration diagram for TileCalibDrawerFlt:

Public Types

typedef std::vector< std::vector< float > > DefType
 Object to hold default data used for initialization.

Public Member Functions

virtual ~TileCalibDrawerFlt ()
 Dtor.
virtual uint16_t getType () const
 Returns TileCalibType::FLT.
float getCalib (unsigned int channel, unsigned int adc, float energy, bool invert=false) const
 Returns the calibrated energy for a given channel/ADC and input energy.
bool getYDY (unsigned int channel, unsigned int adc, float x, float &y, float &dy) const
 Returns y and derivative dy for a given x for function blob of type 200.
float getY (unsigned int channel, unsigned int adc, float x) const
 Returns y for a given x for function blob of type 200.
float getDY (unsigned int channel, unsigned int adc, float x) const
 Returns y for a given x for function blob of type 200.
float getData (unsigned int channel, unsigned int adc, unsigned int idx) const
 Returns a single T belonging to a channel/ADC.
void init (const DefType &def, uint16_t nChans, uint16_t objVers, const std::string &author="", const std::string &comment="", uint64_t timeStamp=0)
 Initializing function.
void setData (unsigned int channel, unsigned int adc, unsigned int idx, float data)
 Sets a single T belonging to a channel/ADC.
virtual void dump () const
 Prints out the content of the blob to std::out.
virtual void dump (std::ostream &stm) const
 Prints the BLOB header summary information.
const void * getAddress (unsigned int iEle) const
 Returns start address of iEle-th basic unit.
void * getAddress (unsigned int iEle)
virtual void clone (const TileCalibDrawerBase &other)
 Initialzes Blob with content of other Blob.
long getBlobSize () const
 Returns the BLOB size in units of bytes.
long getBlobSize32 () const
 Returns the BLOB size in units of uint32_t.
uint16_t getObjType () const
 Returns the BLOB object type.
uint16_t getObjVersion () const
 Returns the BLOB object version.
uint32_t getObjSizeUint32 () const
 Returns the size of a data object in units of uint32_t.
uint32_t getObjSizeByte () const
 Returns the size of a data object in units of bytes.
uint32_t getNObjs () const
 Returns the number of data objects stored int the BLOB.
uint16_t getNChans () const
 Returns the number of channels stored in the BLOB.
uint16_t getNGains () const
 Returns the number of gains stored for each channel.
uint32_t getCommentSizeUint32 () const
 Returns the space occupied by the comment fields in units of uint32_t.
uint32_t getCommentSizeChar () const
 Returns the space occupied by the comment fields in units of chars.
std::string getAuthor () const
 Returns the comment author.
std::string getComment () const
 Returns the actual comment.
uint64_t getTimeStamp () const
 Returns the unix timestamp of the comment (seconds since 1.1.1970)
std::string getDate () const
 Returns the date of the comment as string (derived from timestamp)
std::string getFullComment () const
 Returns a formated string build from all comment fields.

Static Public Member Functions

static const TileCalibDrawerFltgetInstance (const coral::Blob &blob)
 Returns a pointer to a const TileCalibDrawerFlt.
static TileCalibDrawerFltgetInstance (coral::Blob &blob, const DefType &def, uint16_t nChans, uint16_t objVers, const std::string &author="", const std::string &comment="", uint64_t timeStamp=0)
 Returns a pointer to a non-const TileCalibDrawerFlt.

Static Public Attributes

static const unsigned int m_hdrSize32
 The header size in units of uint32_t.

Protected Member Functions

 TileCalibDrawerFlt (const coral::Blob &blob)
 Ctor (const).
 TileCalibDrawerFlt (coral::Blob &blob)
 Ctor (non-const).
const float * getAddress (unsigned int channel, unsigned int adc) const
 Returns a pointer to the first value for the specified channel & ADC.
uint32_t createBlob (uint16_t objType, uint16_t objVersion, uint32_t objSizeUint32, uint32_t nObjs, uint16_t nChans, uint16_t nGains, const std::string &author="", const std::string &comment="", uint64_t timeStamp=0)
 (re-)creation of the referenced BLOB object.
void dumpHeader (std::ostream &stm) const
 Prints the BLOB header summary information.

Private Attributes

coral::Blob * m_blob_nc
 Non-const reference to the BLOB.
const coral::Blob * m_blob
 Const reference to the BLOB (always there)
const uint32_t * m_blobStart32
 Cache blob starting address as uint_32t*.
const uint16_t * m_blobStart16
 Cache blob starting address as uint_16t*.
uint64_t m_blobSize32
 Cache blob size in units of uint32_t.
bool m_isBlobOwner
 Is this TileCalibDrawer owner of the BLOB.

Detailed Description

Generic class for storing a number of floats (Flt) for each channel or ADC.

Author
Nils Gollub nils..nosp@m.goll.nosp@m.ub@ce.nosp@m.rn.c.nosp@m.h

This class implements the infrastructure to store a (variable) number of floats for each channel or ADC. The number of floats to store is encoded in the objSize header variable. The object version header variable is used to encode different functional forms on the stored data, accessed through the getCalib function.

Definition at line 26 of file TileCalibDrawerFlt.h.

Member Typedef Documentation

◆ DefType

typedef std::vector<std::vector<float> > TileCalibDrawerDat< float >::DefType
inherited

Object to hold default data used for initialization.

The length of the first and second vector determines respectively the number of gains and values per gain to be stored. The indexing is thus DefType[iGain][iValue].

Definition at line 37 of file TileCalibDrawerDat.h.

Constructor & Destructor Documentation

◆ ~TileCalibDrawerFlt()

virtual TileCalibDrawerFlt::~TileCalibDrawerFlt ( )
inlinevirtual

Dtor.

Definition at line 31 of file TileCalibDrawerFlt.h.

31{}

◆ TileCalibDrawerFlt() [1/2]

TileCalibDrawerFlt::TileCalibDrawerFlt ( const coral::Blob & blob)
protected

Ctor (const).

Definition at line 40 of file TileCalibDrawerFlt.cxx.

40 :
42{
43 if(getBlobSize()){
45 throw TileCalib::TypeConflict("TileCalibDrawerFlt::Ctor",getObjType(),TileCalibDrawerFlt::getType());
46 }
47 }
48}
uint16_t getObjType() const
TileCalibDrawerDat(const coral::Blob &blob)
virtual uint16_t getType() const
Returns TileCalibType::FLT.

◆ TileCalibDrawerFlt() [2/2]

TileCalibDrawerFlt::TileCalibDrawerFlt ( coral::Blob & blob)
protected

Ctor (non-const).

Definition at line 52 of file TileCalibDrawerFlt.cxx.

52 :
54{
55 if(getBlobSize()){
57 throw TileCalib::TypeConflict("TileCalibDrawerFlt::Ctor",getObjType(),TileCalibDrawerFlt::getType());
58 }
59 }
60}

Member Function Documentation

◆ clone()

void TileCalibDrawerBase::clone ( const TileCalibDrawerBase & other)
virtualinherited

Initialzes Blob with content of other Blob.

Parameters
otherTileCalibDrawer used for initialization

Definition at line 77 of file TileCalibDrawerBase.cxx.

75{
76 //=== copy content of other blob
78 //=== and reset cached attributes
79 m_blobStart32 = static_cast<const uint32_t*>(m_blob->startingAddress());
80 m_blobStart16 = static_cast<const uint16_t*>(m_blob->startingAddress());
81 m_blobSize32 = m_blob->size()/sizeof(uint32_t);
82}
const coral::Blob * m_blob
Const reference to the BLOB (always there)
Generic template class for storing a number of "T"s for each channel or ADC.

◆ createBlob()

uint32_t TileCalibDrawerBase::createBlob ( uint16_t objType,
uint16_t objVersion,
uint32_t objSizeUint32,
uint32_t nObjs,
uint16_t nChans,
uint16_t nGains,
const std::string & author = "",
const std::string & comment = "",
uint64_t timeStamp = 0 )
protectedinherited

(re-)creation of the referenced BLOB object.

Parameters
objTypeObject type
objVersionObject version
objSizeUint32Size of a data object (in uint32_t)
nObjsTotal number of data objects
nChansnumber of stored channels
nGainsnumber of stored gains
authorcomment author
commentactual comment
timeStampunix time stamp (if 0, current time is used)

Definition at line 157 of file TileCalibDrawerBase.cxx.

96{
97 //=== blob data length including header in bytes
99
100 //=== calculate comment length, including two ASCII NULLs to end text fields
102 if(author.size() || comment.size() || timeStamp){
103 commentSizeChar += author.size()+comment.size()+sizeof(uint64_t) + 2;
104 //=== force comment length to end on 4 byte boundary
106 (sizeof(uint32_t)-(commentSizeChar % sizeof(uint32_t))) : 0;
107 }
108
109 //=== create blob
111 m_blob_nc->resize(blobSizeInBytes);
112 uint32_t* blobStart32 = static_cast<uint32_t*>(m_blob_nc->startingAddress());
113 uint16_t* blobStart16 = static_cast<uint16_t*>(m_blob_nc->startingAddress());
114 m_blobSize32 = m_blob_nc->size()/sizeof(uint32_t);
115
118
119 //=== fill header
120 blobStart16[0] = objType;
123 blobStart32[2] = nObjs;
124 blobStart16[6] = nChans;
125 blobStart16[7] = nGains;
127
128 //==== fill comment fields
129 if(commentSizeChar){
130 if(!timeStamp) timeStamp = ::time(0);
131 uint64_t* pTimeStamp = reinterpret_cast<uint64_t*>(blobStart32+dataSizeByte/sizeof(uint32_t));
133 char* pChar = reinterpret_cast<char*>(++pTimeStamp);
135 for(; iStr!=author.end(); ++iStr){ *pChar = *iStr; ++pChar; }
136 *pChar = 0;
137 for(iStr=comment.begin(); iStr!=comment.end(); ++iStr){ *(++pChar) = *iStr; }
138 *(++pChar) = 0;
139 }
140
141 return (blobSizeInBytes/sizeof(uint32_t));
142}
static const unsigned int m_hdrSize32

◆ dump() [1/2]

virtual void TileCalibDrawerBase::dump ( std::ostream & stm) const
inlinevirtualinherited

Prints the BLOB header summary information.

Parameters
stmThe output stream to use

Reimplemented in TileCalibDrawerCmt, TileCalibDrawerDat< T >, and TileCalibDrawerOfc.

Definition at line 86 of file TileCalibDrawerBase.h.

86{dumpHeader(stm);}
void dumpHeader(std::ostream &stm) const
Prints the BLOB header summary information.

◆ dump() [2/2]

virtual void TileCalibDrawerDat< float >::dump ( ) const
inlinevirtualinherited

Prints out the content of the blob to std::out.

Reimplemented from TileCalibDrawerBase.

Definition at line 81 of file TileCalibDrawerDat.h.

81{ dump(std::cout); }

◆ dumpHeader()

void TileCalibDrawerBase::dumpHeader ( std::ostream & stm) const
protectedinherited

Prints the BLOB header summary information.

Parameters
stmoutput stream to use

Definition at line 169 of file TileCalibDrawerBase.cxx.

201{
202 stm << "This is a " << TileCalibType::getClassName(getObjType()) << std::endl;
203 stm << "ObjType : " << getObjType() << std::endl;
204 stm << "ObjVersion : " << getObjVersion() << std::endl;
205 stm << "ObjSize [bytes]: " << getObjSizeByte() << std::endl;
206 stm << "NObjs : " << getNObjs() << std::endl;
207 stm << "NChannels : " << getNChans() << std::endl;
208 stm << "NGains : " << getNGains() << std::endl;
210 stm << "=== No comment available ===" << std::endl;
211 }
212 else{
213 stm << "Author : " << getAuthor() << std::endl;
214 stm << "Date : " << getDate() << " ("<< getTimeStamp() << ")" << std::endl;
215 stm << "Comment: : " << getComment() << std::endl;
216 }
217}
uint32_t getCommentSizeUint32() const
uint16_t getNChans() const
uint16_t getNGains() const
uint64_t getTimeStamp() const
uint32_t getNObjs() const
uint16_t getObjVersion() const
static std::string getClassName(TileCalibType::TYPE type)
Returns the class name.

◆ getAddress() [1/3]

const float * TileCalibDrawerDat< float >::getAddress ( unsigned int channel,
unsigned int adc ) const
protectedinherited

Returns a pointer to the first value for the specified channel & ADC.

Parameters
channelThe channel number; If channel number >= getNChans() it is reset to channel % (maximum number of channels in drawer) if channel number > (maximum number of channels in drawer) otherwise it is reset to 0 without warning (default policy)
adcThe gain index; if >= getNGains() it is reset to 0 without warning (default policy)

Definition at line 100 of file TileCalibDrawerDat.h.

195{
196 unsigned int idx = channel*getNGains() + adc;
197 return static_cast<const T*>(TileCalibDrawerBase::getAddress(idx));
198}
const void * getAddress(unsigned int iEle) const
Returns start address of iEle-th basic unit.

◆ getAddress() [2/3]

void * TileCalibDrawerBase::getAddress ( unsigned int iEle)
inherited

◆ getAddress() [3/3]

const void * TileCalibDrawerBase::getAddress ( unsigned int iEle) const
inherited

Returns start address of iEle-th basic unit.

Parameters
iElesequential basic unit number

◆ getAuthor()

std::string TileCalibDrawerBase::getAuthor ( ) const
inherited

Returns the comment author.

Definition at line 118 of file TileCalibDrawerBase.cxx.

148{
149 if(!getCommentSizeUint32()) return std::string("");
150 const char* iBeg =
151 reinterpret_cast<const char*>(m_blobStart32 + m_hdrSize32 +
153 sizeof(uint64_t)/sizeof(uint32_t));
154 return std::string(iBeg);
155}
uint32_t getObjSizeUint32() const

◆ getBlobSize()

long TileCalibDrawerBase::getBlobSize ( ) const
inlineinherited

Returns the BLOB size in units of bytes.

Definition at line 92 of file TileCalibDrawerBase.h.

92{ return m_blobSize32 * sizeof(uint32_t); }

◆ getBlobSize32()

long TileCalibDrawerBase::getBlobSize32 ( ) const
inlineinherited

Returns the BLOB size in units of uint32_t.

Definition at line 94 of file TileCalibDrawerBase.h.

94{ return m_blobSize32; }

◆ getCalib()

float TileCalibDrawerFlt::getCalib ( unsigned int channel,
unsigned int adc,
float energy,
bool invert = false ) const

Returns the calibrated energy for a given channel/ADC and input energy.

Parameters
channelThe channel number; If channel number >= getNChans() it is reset to channel % (maximum number of channels in drawer) if channel number > (maximum number of channels in drawer) otherwise it is reset to 0 without warning (default policy)
adcThe gain index; if >= getNGains() it is reset to 0 without warning (default policy)
energyThe energy that should be calibrated
invertIf true, the calibration is inverted

Definition at line 65 of file TileCalibDrawerFlt.cxx.

66{
67 //=== interpretation of data depends on the objVersion
68 if(getObjVersion()==1){
69
70 //=== Application of a single slope
71 float slope = TileCalibDrawerFlt::getData(channel,adc,0);
72 if(invert)
73 {
74 energy *= slope;
75 }
76 else
77 {
78 if(slope==0.) throw TileCalib::InvalidValue("TileCalibDrawerFlt::getCalib(), SLOPE",slope);
79 energy /= slope;
80 }
81 return energy;
82
83 }
84 else if(getObjVersion()==100){
85
86 //============================================================================
87 //=== Look up table (LUT)
88 //=== Values are stored in one x and one y column
89 //=== Note: when filling the vector for the sqlite input file
90 //=== first insert all x-values and then all y-values
91 //=== Linear interpolation is done between two x-value entries
92 //=== Under- and overflows return the input value (convenient for CIS LUT)
93 //=== The return value is the LUT value!
94 //============================================================================
95
96 //NGO need to do something if "invert" is requested
97
98 //NGO change LUT format to slope and residual? Makes it more consistent with rest
99 //NGO and easier for visualization??
100
101 //=== need at least 2 (x,y) pairs,
102 //=== return unit function as default
103 if(getObjSizeUint32()<4){
104 return energy;
105 }
106
107 //=== Tile Default Policy has to be enforced here again,
108 //=== since getAddress() below assumes valid channel & adc
109
110 if(channel >= getNChans()) {
111 if (channel <= TileCalibUtils::MAX_CHAN) {
112 channel = 0;
113 } else {
115 if (channel >= getNChans()) channel = 0;
116 }
117 }
118
119 if(adc >= getNGains()) {adc = 0;}
120
121 //=== determine position in table
122 const float* xBeg = getAddress(channel,adc);
123 const float* xEnd = xBeg + getObjSizeUint32()/2;
124 const float* iX = std::upper_bound(xBeg,xEnd,energy);
125 unsigned int offset = iX-xBeg;
126 float y(0.);
127 //=== boundary values
128 if(iX==xBeg || iX==xEnd){
129 y = energy;
130 }
131 //=== linear interpolation
132 else{
133 float x1 = *(iX );
134 float x0 = *(iX-1);
135 float y1 = *(xEnd+offset );
136 float y0 = *(xEnd+offset-1);
137 y = y0+(energy-x0)*(y1-y0)/(x1-x0);
138 }
139 return y;
140 }
141
142 //=== did not recognize the blob version
143 throw TileCalib::VersionConflict("TileCalibDrawerFlt::getCalib",getObjVersion());
144}
#define y
float getData(unsigned int channel, unsigned int adc, unsigned int idx) const
const float * getAddress(unsigned int channel, unsigned int adc) const
static const unsigned int MAX_CHAN
Number of channels in drawer.

◆ getComment()

std::string TileCalibDrawerBase::getComment ( ) const
inherited

Returns the actual comment.

Definition at line 120 of file TileCalibDrawerBase.cxx.

162{
163 if(!getCommentSizeUint32()) return std::string("");
164 const char* iBeg =
165 reinterpret_cast<const char*>(m_blobStart32 + m_hdrSize32 +
167 sizeof(uint64_t)/sizeof(uint32_t));
168 const char* iEnd = iBeg + getCommentSizeChar();
169 iBeg = std::find(iBeg,iEnd,0);
170 return std::string(++iBeg);
171}

◆ getCommentSizeChar()

uint32_t TileCalibDrawerBase::getCommentSizeChar ( ) const
inlineinherited

Returns the space occupied by the comment fields in units of chars.

Definition at line 112 of file TileCalibDrawerBase.h.

112{return getCommentSizeUint32()*sizeof(uint32_t);}

◆ getCommentSizeUint32()

uint32_t TileCalibDrawerBase::getCommentSizeUint32 ( ) const
inherited

Returns the space occupied by the comment fields in units of uint32_t.

◆ getData()

float TileCalibDrawerDat< float >::getData ( unsigned int channel,
unsigned int adc,
unsigned int idx ) const
inherited

Returns a single T belonging to a channel/ADC.

Parameters
adcThe gain index; if >= getNGains() it is reset to 0 without warning (default policy)
idxThe index of the requested value

Definition at line 49 of file TileCalibDrawerDat.h.

141{
142 if(idx>=getObjSizeUint32()){
143 throw TileCalib::IndexOutOfRange("TileCalibDrawerDat::getData",idx,getObjVersion());
144 }
145
146 //=== Tile Default Policy
147
148 if(channel >= getNChans()) {
150 channel = 0;
151 } else {
153 if (channel >= getNChans()) channel = 0;
154 }
155 }
156
157 if(adc >= getNGains()) {adc = 0;}
158
159 return getAddress(channel,adc)[idx];
160}

◆ getDate()

std::string TileCalibDrawerBase::getDate ( ) const
inherited

Returns the date of the comment as string (derived from timestamp)

Definition at line 124 of file TileCalibDrawerBase.cxx.

177{
178 if(!getCommentSizeUint32()) return std::string("");
180 char buf[32];
181 char* iBeg = ::ctime_r(&timeStamp, buf);
182 char* iEnd = iBeg;
183 while(*iEnd!='\n'){++iEnd;}
184 return std::string(iBeg,iEnd-iBeg);
185}

◆ getDY()

float TileCalibDrawerFlt::getDY ( unsigned int channel,
unsigned int adc,
float x ) const

Returns y for a given x for function blob of type 200.

This function is inefficient and created for python use only. (Python does not like float references)

Definition at line 275 of file TileCalibDrawerFlt.cxx.

276{
277 float y(-9999.), dy(-9999.);
278 (void)getYDY(channel,adc,x,y,dy);
279 return dy;
280}
#define x
bool getYDY(unsigned int channel, unsigned int adc, float x, float &y, float &dy) const
Returns y and derivative dy for a given x for function blob of type 200.

◆ getFullComment()

std::string TileCalibDrawerBase::getFullComment ( ) const
inherited

Returns a formated string build from all comment fields.

Definition at line 126 of file TileCalibDrawerBase.cxx.

191{
192 if(!getCommentSizeUint32()) return std::string("");
193 return getAuthor()+" ("+getDate()+"): "+getComment();
194}

◆ getInstance() [1/2]

const TileCalibDrawerFlt * TileCalibDrawerFlt::getInstance ( const coral::Blob & blob)
static

Returns a pointer to a const TileCalibDrawerFlt.

Definition at line 13 of file TileCalibDrawerFlt.cxx.

14{
15 //=== const Blob needs to be correctly formated
16 if(blob.size()<static_cast<long>(m_hdrSize32)){
17 throw TileCalib::InvalidBlob("TileCalibDrawerFlt::getInstance");
18 }
19 return (new TileCalibDrawerFlt(blob));
20}
TileCalibDrawerFlt(const coral::Blob &blob)
Ctor (const).

◆ getInstance() [2/2]

TileCalibDrawerFlt * TileCalibDrawerFlt::getInstance ( coral::Blob & blob,
const DefType & def,
uint16_t nChans,
uint16_t objVers,
const std::string & author = "",
const std::string & comment = "",
uint64_t timeStamp = 0 )
static

Returns a pointer to a non-const TileCalibDrawerFlt.

Parameters
blobReference to a coral::Blob
defA reference to a DefType object, specifying the inital layout and values
nChansNumber of channels to create
objTypeType of the (derived class) object
objVersVersion of the (derived class) object
authorString containing the author user id
commentString containing the actual comment
timeStampUnix time stamp (if 0, current time is used)

Definition at line 25 of file TileCalibDrawerFlt.cxx.

32{
34 calibDrawer->init(def,nChans,objVers,author,comment,timeStamp);
35 return calibDrawer;
36}

◆ getNChans()

uint16_t TileCalibDrawerBase::getNChans ( ) const
inherited

Returns the number of channels stored in the BLOB.

◆ getNGains()

uint16_t TileCalibDrawerBase::getNGains ( ) const
inherited

Returns the number of gains stored for each channel.

◆ getNObjs()

uint32_t TileCalibDrawerBase::getNObjs ( ) const
inherited

Returns the number of data objects stored int the BLOB.

◆ getObjSizeByte()

uint32_t TileCalibDrawerBase::getObjSizeByte ( ) const
inlineinherited

Returns the size of a data object in units of bytes.

Definition at line 102 of file TileCalibDrawerBase.h.

102{return getObjSizeUint32()*sizeof(uint32_t);}

◆ getObjSizeUint32()

uint32_t TileCalibDrawerBase::getObjSizeUint32 ( ) const
inherited

Returns the size of a data object in units of uint32_t.

◆ getObjType()

uint16_t TileCalibDrawerBase::getObjType ( ) const
inherited

Returns the BLOB object type.

◆ getObjVersion()

uint16_t TileCalibDrawerBase::getObjVersion ( ) const
inherited

Returns the BLOB object version.

◆ getTimeStamp()

uint64_t TileCalibDrawerBase::getTimeStamp ( ) const
inherited

Returns the unix timestamp of the comment (seconds since 1.1.1970)

◆ getType()

virtual uint16_t TileCalibDrawerFlt::getType ( ) const
inlinevirtual

Returns TileCalibType::FLT.

Reimplemented from TileCalibDrawerBase.

Definition at line 34 of file TileCalibDrawerFlt.h.

34{return TileCalibType::FLT;}
@ FLT
Enum for TileCalibDrawerFlt class.

◆ getY()

float TileCalibDrawerFlt::getY ( unsigned int channel,
unsigned int adc,
float x ) const

Returns y for a given x for function blob of type 200.

This function is created as a helper function for TileCalibDrawer::getYDY and for python use. (Python does not like float references)

Definition at line 217 of file TileCalibDrawerFlt.cxx.

218{
219 float y(-9999.);
220 //=== need to have a "function" blob version
221 if(getObjVersion()!=200){
222 throw TileCalib::VersionConflict("TileCalibDrawerFlt::getY",getObjVersion());
223 }
224
225 //=== require minimum pulse shape
226 if(getObjSizeUint32()<4){
227 return false;
228 }
229
230 //=== Tile Default Policy has to be enforced here again,
231 //=== since getAddress() below assumes valid channel & adc
232
233 if(channel >= getNChans()) {
234 if (channel <= TileCalibUtils::MAX_CHAN) {
235 channel = 0;
236 } else {
238 if (channel >= getNChans()) channel = 0;
239 }
240 }
241
242 if(adc >= getNGains()) {adc = 0;}
243
244 //=== determine position in table
245 const float* xBeg = getAddress(channel,adc);
246 const float* xEnd = xBeg + getObjSizeUint32()/2;
247 const float* iX = std::upper_bound(xBeg,xEnd,x);
248 unsigned int offset = iX-xBeg;
249
250 //=== under-/overflow: return boundary y
251 if(iX==xBeg){
252 y = *(xEnd+offset);
253 return y;
254 }
255 else if(iX==xEnd){
256 y = *(xEnd+offset-1);
257 return y;
258 }
259
260 //=== linear interpolation to determine y
261 else{
262 float x1 = *(iX );
263 float x0 = *(iX-1);
264 float y1 = *(xEnd+offset );
265 float y0 = *(xEnd+offset-1);
266 float slope = (y1-y0)/(x1-x0);
267 y = y0+(x-x0)*slope;
268 }
269 return y;
270}

◆ getYDY()

bool TileCalibDrawerFlt::getYDY ( unsigned int channel,
unsigned int adc,
float x,
float & y,
float & dy ) const

Returns y and derivative dy for a given x for function blob of type 200.

Returns
A bool indicating whether x was within the function range (true) or outside (false)
Parameters
channelThe channel number; If channel number >= getNChans() it is reset to channel % (maximum number of channels in drawer) if channel number > (maximum number of channels in drawer) otherwise it is reset to 0 without warning (default policy)
adcThe gain index; if >= getNGains() it is reset to 0 without warning (default policy)
xInput x value
yY value corresponding to x
dyDerivative of the function at x

Definition at line 149 of file TileCalibDrawerFlt.cxx.

151{
152 //=== need to have a "function" blob version
153 if(getObjVersion()!=200){
154 throw TileCalib::VersionConflict("TileCalibDrawerFlt::getYDY",getObjVersion());
155 }
156
157 //=== require minimum pulse shape
158 if(getObjSizeUint32()<4){
159 return false;
160 }
161
162 //=== Tile Default Policy has to be enforced here again,
163 //=== since getAddress() below assumes valid channel & adc
164
165 if(channel >= getNChans()) {
166 if (channel <= TileCalibUtils::MAX_CHAN) {
167 channel = 0;
168 } else {
170 if (channel >= getNChans()) channel = 0;
171 }
172 }
173
174 if( adc >= getNGains()) {adc = 0;}
175
176 //=== determine position in table
177 const float* xBeg = getAddress(channel,adc);
178 const float* xEnd = xBeg + getObjSizeUint32()/2;
179 const float* iX = std::upper_bound(xBeg,xEnd,x);
180 unsigned int offset = iX-xBeg;
181
182 //=== under-/overflow: return boundary y and dy==0
183 //=== offset delta is to avoid float comparison troubles
184 const float delta = 1.0e-3;
185 if(iX==xBeg) {
186 y = *(xEnd+offset);
187 dy = 0.;
188 if (x < (*(xBeg) - delta)) return false;
189 }
190 else if(iX==xEnd) {
191 y = *(xEnd+offset-1);
192 dy = 0.;
193 if (x > (*(xEnd-1) + delta)) return false;
194 }
195
196 //=== linear interpolation to determine y
197 else{
198 float x1 = *(iX );
199 float x0 = *(iX-1);
200 float y1 = *(xEnd+offset );
201 float y0 = *(xEnd+offset-1);
202 float slope = (y1-y0)/(x1-x0);
203 y = y0+(x-x0)*slope;
204
205 //=== determine dy from secant near [x,y]
206 float dx = x1 - x0;
207 float xs1 = x + 0.5 * dx;
208 float xs0 = x - 0.5 * dx;
209 dy = (getY(channel, adc, xs1) - getY(channel, adc, xs0)) / dx;
210 }
211 return true;
212}
float getY(unsigned int channel, unsigned int adc, float x) const
Returns y for a given x for function blob of type 200.

◆ init()

void TileCalibDrawerDat< float >::init ( const DefType & def,
uint16_t nChans,
uint16_t objVers,
const std::string & author = "",
const std::string & comment = "",
uint64_t timeStamp = 0 )
inherited

Initializing function.

Parameters
defA reference to a DefType object, specifying the inital layout and values
nChansNumber of channels to create
objTypeType of the (derived class) object
objVersVersion of the (derived class) object
authorString containing the author user id
commentString containing the actual comment
timeStampUnix time stamp (if 0, current time is used)

Definition at line 59 of file TileCalibDrawerDat.h.

113{
114 uint16_t nGains = def.size();
115 uint32_t objSize = nGains>0 ? def.begin()->size() * sizeof(T)/sizeof(uint32_t) : 0;
117
118 //=== ensure all gains have the same object size
119 for(unsigned int iGain=0; iGain<nGains; ++iGain){
120 unsigned int thisSize = def[iGain].size()*sizeof(T)/sizeof(uint32_t);
121 if( thisSize != objSize ){
122 throw TileCalib::SizeConflict("TileCalibDrawerDat<T>::init",thisSize,objSize);
123 }
124 }
125
126 //=== create blob
128
129 //=== fill the blob with default
130 for(unsigned int channel=0; channel<nChans; ++channel){
131 for(unsigned int adc=0; adc<nGains; ++adc){
133 }
134 }
135}
virtual uint16_t getType() const
uint32_t createBlob(uint16_t objType, uint16_t objVersion, uint32_t objSizeUint32, uint32_t nObjs, uint16_t nChans, uint16_t nGains, const std::string &author="", const std::string &comment="", uint64_t timeStamp=0)
void setData(unsigned int channel, unsigned int adc, unsigned int idx, float data)

◆ setData()

void TileCalibDrawerDat< float >::setData ( unsigned int channel,
unsigned int adc,
unsigned int idx,
float data )
inherited

Sets a single T belonging to a channel/ADC.

Parameters
channelThe channel number
adcThe gain index
idxThe index of the value to set
dataThe data value to set

Definition at line 71 of file TileCalibDrawerDat.h.

166{
167 //=== check for out of bounds
168 if(channel >= getNChans()){
169 throw TileCalib::IndexOutOfRange("TileCalibDrawerDat::getAddress(channel)",channel,getNChans());
170 }
171 if(adc>=getNGains()){
172 throw TileCalib::IndexOutOfRange("CaloCalibDrawerDat::getAddress(gain)",adc,getNGains());
173 }
174 if(idx>=getObjSizeUint32()){
175 throw TileCalib::IndexOutOfRange("TileCalibDrawerDat::getData",idx,getObjVersion());
176 }
177
179}

Member Data Documentation

◆ m_blob

const coral::Blob* TileCalibDrawerBase::m_blob
privateinherited

Const reference to the BLOB (always there)

Definition at line 176 of file TileCalibDrawerBase.h.

◆ m_blob_nc

coral::Blob* TileCalibDrawerBase::m_blob_nc
privateinherited

Non-const reference to the BLOB.

(Only present if we were created with a non-const blob.)

Definition at line 174 of file TileCalibDrawerBase.h.

◆ m_blobSize32

uint64_t TileCalibDrawerBase::m_blobSize32
privateinherited

Cache blob size in units of uint32_t.

Definition at line 182 of file TileCalibDrawerBase.h.

◆ m_blobStart16

const uint16_t* TileCalibDrawerBase::m_blobStart16
privateinherited

Cache blob starting address as uint_16t*.

Definition at line 180 of file TileCalibDrawerBase.h.

◆ m_blobStart32

const uint32_t* TileCalibDrawerBase::m_blobStart32
privateinherited

Cache blob starting address as uint_32t*.

Definition at line 178 of file TileCalibDrawerBase.h.

◆ m_hdrSize32

const unsigned int TileCalibDrawerBase::m_hdrSize32
staticinherited

The header size in units of uint32_t.

Definition at line 138 of file TileCalibDrawerBase.h.

◆ m_isBlobOwner

bool TileCalibDrawerBase::m_isBlobOwner
privateinherited

Is this TileCalibDrawer owner of the BLOB.

Definition at line 184 of file TileCalibDrawerBase.h.


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