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

#include <TileCalibDrawerOfc.h>

Inheritance diagram for TileCalibDrawerOfc:
Collaboration diagram for TileCalibDrawerOfc:

Public Types

enum  FIELD {
  FieldA = 0 , FieldB = 1 , FieldG = 2 , FieldC = 3 ,
  FieldDG = 4
}
 OFC field identifier. More...

Public Member Functions

virtual ~TileCalibDrawerOfc ()
 Dtor.
virtual uint16_t getType () const
 Returns TileCalibType::OFC.
uint32_t getNSamples () const
 Returns the number of sample stored.
int32_t getNPhases () const
 Returns the number of phases (WARNING: Can be negative!)
float getPhase (unsigned int channel, unsigned int adc, unsigned int phaseIdx) const
 Returns the stored phase.
uint32_t getNFields (uint16_t objVersion=0) const
 Returns the number of fields.
float getOfc (unsigned int field, unsigned int channel, unsigned int adc, float phase, unsigned int sample) const
 Returns OFC data.
void fillOfc (unsigned int channel, unsigned int adc, float &phase, float *w_a, float *w_b, float *w_c, float *g, float *dg) const
 Fill all OFC for optimazation.
virtual void dump () const
 Prints out the object content to std::cout.
virtual void dump (std::ostream &stm) const
 Prints out the object content.
void init (uint16_t objVersion, uint32_t nSamples, int32_t nPhases, uint16_t nChans, uint16_t nGains, const std::string &author="", const std::string &comment="", uint64_t timeStamp=0)
 Function for initializing a TileCalibDrawerOfc BLOB.
void setOfc (unsigned int field, unsigned int channel, unsigned int adc, float phase, unsigned int sample, float value)
 Sets OFC data.
void setPhases (unsigned int channel, unsigned int adc, const std::vector< float > &phases)
 Sets a phase value.
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.
const void * getAddress (unsigned int iEle) const
 Returns start address of iEle-th basic unit.
void * getAddress (unsigned int iEle)

Static Public Member Functions

static TileCalibDrawerOfcgetInstance (coral::Blob &blob, uint16_t objVersion, uint32_t nSamples, int32_t nPhases, uint16_t nChans, uint16_t nGains, const std::string &author="", const std::string &comment="", uint64_t timeStamp=0)
 Returns a pointer to a non-const TileCalibDrawerOfc.
static const TileCalibDrawerOfcgetInstance (const coral::Blob &blob)
 Returns a pointer to a const TileCalibDrawerOfc.

Static Public Attributes

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

Protected Member Functions

 TileCalibDrawerOfc (const coral::Blob &blob)
 Ctor (const).
 TileCalibDrawerOfc (coral::Blob &blob)
 Ctor (non0const).
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 Member Functions

void initCheck ()
const float * getOfcStartAddress (unsigned int field, unsigned int channel, unsigned int adc, float &phase) const
 Returns pointer to first data OFC for a given field, ADC & phase.
float * getOfcStartAddress (unsigned int field, unsigned int channel, unsigned int adc, float &phase)
unsigned int getOfcStartOffset (unsigned int field, unsigned int channel, unsigned int adc, float &phase) const
const int32_t * getPhaseStartAddress (unsigned int channel, unsigned int adc, unsigned int phaseIdx) const
 Returns pointer to the requested phase value.
int32_t * getPhaseStartAddress (unsigned int channel, unsigned int adc, unsigned int phaseIdx)
unsigned int getPhaseStartOffset (unsigned int channel, unsigned int adc, unsigned int phaseIdx) const
unsigned int getPhaseNumber (unsigned int channel, unsigned int adc, float &phase) const
 Returns the index for a given phase.

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

Definition at line 40 of file TileCalibDrawerOfc.h.

Member Enumeration Documentation

◆ FIELD

OFC field identifier.

Enumerator
FieldA 
FieldB 
FieldG 
FieldC 
FieldDG 

Definition at line 45 of file TileCalibDrawerOfc.h.

Constructor & Destructor Documentation

◆ ~TileCalibDrawerOfc()

virtual TileCalibDrawerOfc::~TileCalibDrawerOfc ( )
inlinevirtual

Dtor.

Definition at line 48 of file TileCalibDrawerOfc.h.

48{}

◆ TileCalibDrawerOfc() [1/2]

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

Ctor (const).

Definition at line 42 of file TileCalibDrawerOfc.cxx.

44{
45 initCheck();
46}
TileCalibDrawerBase(const TileCalibDrawerBase &other)
Copy Ctor.

◆ TileCalibDrawerOfc() [2/2]

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

Ctor (non0const).

Definition at line 50 of file TileCalibDrawerOfc.cxx.

52{
53 initCheck();
54}

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 74 of file TileCalibDrawerBase.cxx.

75{
76 //=== copy content of other blob
77 *m_blob_nc = *other.m_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}
uint64_t m_blobSize32
Cache blob size in units of uint32_t.
const uint32_t * m_blobStart32
Cache blob starting address as uint_32t*.
const coral::Blob * m_blob
Const reference to the BLOB (always there)
const uint16_t * m_blobStart16
Cache blob starting address as uint_16t*.
coral::Blob * m_blob_nc
Non-const reference to the BLOB.
setWord1 uint16_t
setEventNumber uint32_t

◆ 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 87 of file TileCalibDrawerBase.cxx.

96{
97 //=== blob data length including header in bytes
98 uint32_t dataSizeByte = (m_hdrSize32+objSizeUint32*nObjs) * sizeof(uint32_t);
99
100 //=== calculate comment length, including two ASCII NULLs to end text fields
101 uint32_t commentSizeChar(0);
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
105 commentSizeChar += (commentSizeChar % sizeof(uint32_t)) ?
106 (sizeof(uint32_t)-(commentSizeChar % sizeof(uint32_t))) : 0;
107 }
108
109 //=== create blob
110 uint32_t blobSizeInBytes = dataSizeByte+commentSizeChar;
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
116 m_blobStart32 = blobStart32;
117 m_blobStart16 = blobStart16;
118
119 //=== fill header
120 blobStart16[0] = objType;
121 blobStart16[1] = objVersion;
122 blobStart32[1] = objSizeUint32;
123 blobStart32[2] = nObjs;
124 blobStart16[6] = nChans;
125 blobStart16[7] = nGains;
126 blobStart32[4] = commentSizeChar/sizeof(uint32_t);
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));
132 pTimeStamp[0] = timeStamp;
133 char* pChar = reinterpret_cast<char*>(++pTimeStamp);
134 std::string::const_iterator iStr = author.begin();
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
The header size in units of uint32_t.
setEventNumber timeStamp

◆ dump() [1/2]

virtual void TileCalibDrawerOfc::dump ( ) const
inlinevirtual

Prints out the object content to std::cout.

Reimplemented from TileCalibDrawerBase.

Definition at line 122 of file TileCalibDrawerOfc.h.

122{ dump(std::cout); }
virtual void dump() const
Prints out the object content to std::cout.

◆ dump() [2/2]

void TileCalibDrawerOfc::dump ( std::ostream & stm) const
virtual

Prints out the object content.

Parameters
stmThe stream to print to

Reimplemented from TileCalibDrawerBase.

Definition at line 165 of file TileCalibDrawerOfc.cxx.

165 {
167 unsigned int channel = 0;
168 for(int iPhase = 0; iPhase < std::abs(getNPhases()); ++iPhase){
169 for(unsigned int sample = 0; sample < getNSamples(); ++sample){
170 for(unsigned int adc = 0; adc < getNGains(); ++adc){
171 float phase = getPhase(channel, adc, iPhase);
172 stm << channel << "/" << phase << "/" << sample << "/" << adc << "\t";
173 for(unsigned int field = 0; field < getNFields(getObjVersion()); ++field){
174 stm << getOfc(field,channel, adc, phase, sample) << "\t";
175 }
176 stm << std::endl;
177 }
178 }
179 }
180}
uint16_t getNGains() const
Returns the number of gains stored for each channel.
void dumpHeader(std::ostream &stm) const
Prints the BLOB header summary information.
uint16_t getObjVersion() const
Returns the BLOB object version.
int32_t getNPhases() const
Returns the number of phases (WARNING: Can be negative!)
float getPhase(unsigned int channel, unsigned int adc, unsigned int phaseIdx) const
Returns the stored phase.
uint32_t getNSamples() const
Returns the number of sample stored.
float getOfc(unsigned int field, unsigned int channel, unsigned int adc, float phase, unsigned int sample) const
Returns OFC data.
uint32_t getNFields(uint16_t objVersion=0) const
Returns the number of fields.

◆ dumpHeader()

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

Prints the BLOB header summary information.

Parameters
stmoutput stream to use

Definition at line 200 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
Returns the space occupied by the comment fields in units of uint32_t.
uint16_t getNChans() const
Returns the number of channels stored in the BLOB.
std::string getComment() const
Returns the actual comment.
uint16_t getObjType() const
Returns the BLOB object type.
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)
uint32_t getNObjs() const
Returns the number of data objects stored int the BLOB.
std::string getAuthor() const
Returns the comment author.
uint32_t getObjSizeByte() const
Returns the size of a data object in units of bytes.
static std::string getClassName(TileCalibType::TYPE type)
Returns the class name.

◆ fillOfc()

void TileCalibDrawerOfc::fillOfc ( unsigned int channel,
unsigned int adc,
float & phase,
float * w_a,
float * w_b,
float * w_c,
float * g,
float * dg ) const

Fill all OFC for optimazation.

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)
phaseThe phase of interest

◆ getAddress() [1/2]

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

◆ getAddress() [2/2]

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 147 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
Returns the size of a data object in units of uint32_t.

◆ 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; }

◆ getComment()

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

Returns the actual comment.

Definition at line 161 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}
uint32_t getCommentSizeChar() const
Returns the space occupied by the comment fields in units of chars.

◆ 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.

◆ getDate()

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

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

Definition at line 176 of file TileCalibDrawerBase.cxx.

177{
178 if(!getCommentSizeUint32()) return std::string("");
179 ::time_t timeStamp = getTimeStamp();
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}

◆ getFullComment()

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

Returns a formated string build from all comment fields.

Definition at line 190 of file TileCalibDrawerBase.cxx.

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

◆ getInstance() [1/2]

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

Returns a pointer to a const TileCalibDrawerOfc.

Definition at line 31 of file TileCalibDrawerOfc.cxx.

31 {
32
33 //=== const Blob needs to be correctly formated
34 if(blob.size() < static_cast<long>(m_hdrSize32)) {
35 throw TileCalib::InvalidBlob("TileCalibDrawerOfc::getInstance");
36 }
37 return (new TileCalibDrawerOfc(blob));
38}
TileCalibDrawerOfc(const coral::Blob &blob)
Ctor (const).

◆ getInstance() [2/2]

TileCalibDrawerOfc * TileCalibDrawerOfc::getInstance ( coral::Blob & blob,
uint16_t objVersion,
uint32_t nSamples,
int32_t nPhases,
uint16_t nChans,
uint16_t nGains,
const std::string & author = "",
const std::string & comment = "",
uint64_t timeStamp = 0 )
static

Returns a pointer to a non-const TileCalibDrawerOfc.

A negative nPhases value implies that the same phase table is used for all stored ADCs.

Parameters
blobReference to coral::Blob
objVersionThe objects version
nSamplesThe number of samples to store.
nPhasesThe number of phases to be stored for each ADC (negative: same phases for all ADCs)
nChansThe number of channels
nGainsThe number of gains
authorString containing the author user id
commentString containing the actual comment
timeStampUnix time stamp (if 0, current time is used)

Definition at line 14 of file TileCalibDrawerOfc.cxx.

23{
25 calibDrawer->init(objVersion, nSamples, nPhases, nChans, nGains, author, comment, timeStamp);
26 return calibDrawer;
27}

◆ getNChans()

uint16_t TileCalibDrawerBase::getNChans ( ) const
inherited

Returns the number of channels stored in the BLOB.

◆ getNFields()

uint32_t TileCalibDrawerOfc::getNFields ( uint16_t objVersion = 0) const

Returns the number of fields.

Returns 3 for OF1, 4 for OF2, 5 for OF2+pulse_derivative.

Parameters
objVersionThe object version If default objVersion is passed, the object version is determined from 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.

◆ getNPhases()

int32_t TileCalibDrawerOfc::getNPhases ( ) const

Returns the number of phases (WARNING: Can be negative!)

◆ getNSamples()

uint32_t TileCalibDrawerOfc::getNSamples ( ) const

Returns the number of sample stored.

◆ 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.

◆ getOfc()

float TileCalibDrawerOfc::getOfc ( unsigned int field,
unsigned int channel,
unsigned int adc,
float phase,
unsigned int sample ) const

Returns OFC data.

Parameters
fieldThe field identifier
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)
phaseThe phase of interest
sampleThe sample of interest

◆ getOfcStartAddress() [1/2]

float * TileCalibDrawerOfc::getOfcStartAddress ( unsigned int field,
unsigned int channel,
unsigned int adc,
float & phase )
private

◆ getOfcStartAddress() [2/2]

const float * TileCalibDrawerOfc::getOfcStartAddress ( unsigned int field,
unsigned int channel,
unsigned int adc,
float & phase ) const
private

Returns pointer to first data OFC for a given field, ADC & phase.

Parameters
fieldThe field identifier
channelThe channel number
adcThe gain index
phaseThe phase

◆ getOfcStartOffset()

unsigned int TileCalibDrawerOfc::getOfcStartOffset ( unsigned int field,
unsigned int channel,
unsigned int adc,
float & phase ) const
private

◆ getPhase()

float TileCalibDrawerOfc::getPhase ( unsigned int channel,
unsigned int adc,
unsigned int phaseIdx ) const

Returns the stored phase.

Parameters
channelThe channel number
adcThe gain index
phaseIdxThe phase index

◆ getPhaseNumber()

unsigned int TileCalibDrawerOfc::getPhaseNumber ( unsigned int channel,
unsigned int adc,
float & phase ) const
private

Returns the index for a given phase.

Parameters
channelThe channel number
adcThe gain index
phaseThe phase of interest

◆ getPhaseStartAddress() [1/2]

int32_t * TileCalibDrawerOfc::getPhaseStartAddress ( unsigned int channel,
unsigned int adc,
unsigned int phaseIdx )
private

◆ getPhaseStartAddress() [2/2]

const int32_t * TileCalibDrawerOfc::getPhaseStartAddress ( unsigned int channel,
unsigned int adc,
unsigned int phaseIdx ) const
private

Returns pointer to the requested phase value.

Parameters
channelThe channel number
adcThe gain index
phaseIdxThe phase index

◆ getPhaseStartOffset()

unsigned int TileCalibDrawerOfc::getPhaseStartOffset ( unsigned int channel,
unsigned int adc,
unsigned int phaseIdx ) const
private

◆ getTimeStamp()

uint64_t TileCalibDrawerBase::getTimeStamp ( ) const
inherited

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

◆ getType()

virtual uint16_t TileCalibDrawerOfc::getType ( ) const
inlinevirtual

Returns TileCalibType::OFC.

Reimplemented from TileCalibDrawerBase.

Definition at line 51 of file TileCalibDrawerOfc.h.

51{return TileCalibType::OFC;}
@ OFC
Enum for TileCalibDrawerOfc class.

◆ init()

void TileCalibDrawerOfc::init ( uint16_t objVersion,
uint32_t nSamples,
int32_t nPhases,
uint16_t nChans,
uint16_t nGains,
const std::string & author = "",
const std::string & comment = "",
uint64_t timeStamp = 0 )

Function for initializing a TileCalibDrawerOfc BLOB.

Parameters
objVersionThe objects version
nSamplesThe number of samples to store.
nPhasesThe number of phases to be stored for each ADC (negative: same phases for all ADCs)
nChansThe number of channels
nGainsThe number of gains
authorString containing the author user id
commentString containing the actual comment
timeStampUnix time stamp (if 0, current time is used)

A negative nPhases value implies that the same phase table is used for all stored ADCs.

Definition at line 91 of file TileCalibDrawerOfc.cxx.

99{
100 const uint16_t extraHeaderSize(2);
101 uint16_t objType = getType();
102 uint32_t objSize = 1; // everything is either uint32_t or float
103 uint32_t objCount = extraHeaderSize;
104
105 //=== if nPhases<0, use one phase table for ADCs
106 //=== otherwise use one table per ADC
107 unsigned int nPhasesAbs = std::abs(nPhases);
108 int nPhasesSgn = nPhases < 0 ? -1 : 1;
109 unsigned int phasesSize = nPhasesAbs;
110 if(nPhasesSgn > 0){ phasesSize *= nChans*nGains; }
111 objCount += phasesSize;
112
113 uint32_t nFields = getNFields(objVersion);
114 objCount += ( nSamples * nFields * nGains * nPhasesAbs * nChans );
115
116 //=== create blob of correct type and size
117 uint32_t blobLengthUint32 =
118 createBlob(objType, objVersion, objSize, objCount, nChans, nGains, author, comment, timeStamp);
119
120 //=== fill header
121 uint32_t* pu = static_cast<uint32_t*>(getAddress(0));
122 *pu = nSamples;
123 int32_t* pi = reinterpret_cast<int32_t*>(++pu);
124 *pi = nPhases;
125 //=== initialize phase field to zero
126 for(unsigned int iPhase = 0; iPhase < phasesSize; ++iPhase){
127 *(++pi) = int32_t(0);
128 }
129
130 //=== initialize rest of blob to zero
131 union {
132 unsigned int ii;
133 float ff;
134 } zero;
135 zero.ff = 0;
136 for(unsigned int i = 0; i < blobLengthUint32 - (m_hdrSize32 + extraHeaderSize+phasesSize); ++i){
137 *(++pi) = zero.ii;
138 }
139}
#define pi
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.
const void * getAddress(unsigned int iEle) const
Returns start address of iEle-th basic unit.
virtual uint16_t getType() const
Returns TileCalibType::OFC.
void zero(TH2 *h)
zero the contents of a 2d histogram

◆ initCheck()

void TileCalibDrawerOfc::initCheck ( )
private

Definition at line 58 of file TileCalibDrawerOfc.cxx.

59{
60 if(getBlobSize()){
61
62 //=== check for correct blob type
63 if(getObjType() != getType()){
64 throw TileCalib::TypeConflict("TileCalibDrawerOfc::Ctor", getObjType(), getType());
65 }
66
67 //=== check for correct object size
68 unsigned int blobObjSize = getObjSizeByte();
69 unsigned int thisObjSize = 0;
70 if( getObjVersion() == 1){
71 //=== set object size to base unit (4 bytes)
72 thisObjSize = sizeof(uint32_t);
73 }
74 else if(getObjVersion() == 2){
75 //=== set object size to base unit (4 bytes)
76 thisObjSize = sizeof(uint32_t);
77 }
78 else if(getObjVersion() == 3){
79 //=== set object size to base unit (4 bytes)
80 thisObjSize = sizeof(uint32_t);
81 }
82 if(blobObjSize != thisObjSize){
83 throw TileCalib::SizeConflict("TileCalibDrawerOfc::Ctor", thisObjSize, blobObjSize);
84 }
85
86 }
87}
long getBlobSize() const
Returns the BLOB size in units of bytes.

◆ setOfc()

void TileCalibDrawerOfc::setOfc ( unsigned int field,
unsigned int channel,
unsigned int adc,
float phase,
unsigned int sample,
float value )

Sets OFC data.

Parameters
fieldThe field identifier
channelThe channel number
adcThe gain index
phaseThe phase
sampleThe sample number
valueThe value to set

◆ setPhases()

void TileCalibDrawerOfc::setPhases ( unsigned int channel,
unsigned int adc,
const std::vector< float > & phases )

Sets a phase value.

Parameters
channelThe channel number
adcThe gain index
phasesVector containing the phases to set

Definition at line 144 of file TileCalibDrawerOfc.cxx.

144 {
145
146 std::set<int32_t> phaseSet;
147 for (const float phase : phases) {
148 phaseSet.insert((int32_t) std::round(phase * (1 / PHASE_PRECISION))); // Phases are stored as int(10*phase) in DB
149 }
150
151 if(int(phaseSet.size()) != std::abs(getNPhases())){
152 throw TileCalib::IndexOutOfRange("TileCalibDrawerOfc::setPhases", phaseSet.size(), std::abs(getNPhases()));
153 }
154
155 unsigned int idx(0);
156 for (const int32_t phase : phaseSet) {
157 *(getPhaseStartAddress(channel, adc, idx)) = phase;
158 ++idx;
159 }
160
161}
#define PHASE_PRECISION
Class for storing Optimal Filtering Coefficients (OFCs) in a coral::Blob.
const int32_t * getPhaseStartAddress(unsigned int channel, unsigned int adc, unsigned int phaseIdx) const
Returns pointer to the requested phase value.

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 = 5
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: