ATLAS Offline Software
Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Member Functions | Private Member Functions | Private Attributes | List of all members
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. More...
 
virtual uint16_t getType () const
 Returns TileCalibType::OFC. More...
 
uint32_t getNSamples () const
 Returns the number of sample stored. More...
 
int32_t getNPhases () const
 Returns the number of phases (WARNING: Can be negative!) More...
 
float getPhase (unsigned int channel, unsigned int adc, unsigned int phaseIdx) const
 Returns the stored phase. More...
 
uint32_t getNFields (uint16_t objVersion=0) const
 Returns the number of fields. More...
 
float getOfc (unsigned int field, unsigned int channel, unsigned int adc, float phase, unsigned int sample) const
 Returns OFC data. More...
 
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. More...
 
virtual void dump () const
 Prints out the object content to std::cout. More...
 
virtual void dump (std::ostream &stm) const
 Prints out the object content. More...
 
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. More...
 
void setOfc (unsigned int field, unsigned int channel, unsigned int adc, float phase, unsigned int sample, float value)
 Sets OFC data. More...
 
void setPhases (unsigned int channel, unsigned int adc, const std::vector< float > &phases)
 Sets a phase value. More...
 
virtual void clone (const TileCalibDrawerBase &other)
 Initialzes Blob with content of other Blob. More...
 
long getBlobSize () const
 Returns the BLOB size in units of bytes. More...
 
long getBlobSize32 () const
 Returns the BLOB size in units of uint32_t. More...
 
uint16_t getObjType () const
 Returns the BLOB object type. More...
 
uint16_t getObjVersion () const
 Returns the BLOB object version. More...
 
uint32_t getObjSizeUint32 () const
 Returns the size of a data object in units of uint32_t. More...
 
uint32_t getObjSizeByte () const
 Returns the size of a data object in units of bytes. More...
 
uint32_t getNObjs () const
 Returns the number of data objects stored int the BLOB. More...
 
uint16_t getNChans () const
 Returns the number of channels stored in the BLOB. More...
 
uint16_t getNGains () const
 Returns the number of gains stored for each channel. More...
 
uint32_t getCommentSizeUint32 () const
 Returns the space occupied by the comment fields in units of uint32_t. More...
 
uint32_t getCommentSizeChar () const
 Returns the space occupied by the comment fields in units of chars. More...
 
std::string getAuthor () const
 Returns the comment author. More...
 
std::string getComment () const
 Returns the actual comment. More...
 
uint64_t getTimeStamp () const
 Returns the unix timestamp of the comment (seconds since 1.1.1970) More...
 
std::string getDate () const
 Returns the date of the comment as string (derived from timestamp) More...
 
std::string getFullComment () const
 Returns a formated string build from all comment fields. More...
 
const void * getAddress (unsigned int iEle) const
 Returns start address of iEle-th basic unit. More...
 
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. More...
 
static const TileCalibDrawerOfcgetInstance (const coral::Blob &blob)
 Returns a pointer to a const TileCalibDrawerOfc. More...
 

Static Public Attributes

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

Protected Member Functions

 TileCalibDrawerOfc (const coral::Blob &blob)
 Ctor (const). More...
 
 TileCalibDrawerOfc (coral::Blob &blob)
 Ctor (non0const). More...
 
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. More...
 
void dumpHeader (std::ostream &stm) const
 Prints the BLOB header summary information. More...
 

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

Private Attributes

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

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.

45 {FieldA = 0, FieldB = 1, FieldG = 2, FieldC = 3, FieldDG = 4};

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 }

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

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

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

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

◆ 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;
209  if(!getCommentSizeUint32()){
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 }

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

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

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

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

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

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

◆ 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) {
158  ++idx;
159  }
160 
161 }

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:
TileCalibDrawerBase::getAuthor
std::string getAuthor() const
Returns the comment author.
Definition: TileCalibDrawerBase.cxx:147
checkFileSG.nObjs
nObjs
Definition: checkFileSG.py:90
ReadOfcFromCool.phase
phase
Definition: ReadOfcFromCool.py:127
TileCalibDrawerBase::getBlobSize
long getBlobSize() const
Returns the BLOB size in units of bytes.
Definition: TileCalibDrawerBase.h:92
TileCalibDrawerOfc::getOfc
float getOfc(unsigned int field, unsigned int channel, unsigned int adc, float phase, unsigned int sample) const
Returns OFC data.
TileCalib::IndexOutOfRange
Thrown if an index is out of range.
Definition: TileCalorimeter/TileCalib/TileCalibBlobObjs/TileCalibBlobObjs/Exception.h:141
plotting.yearwise_efficiency.channel
channel
Definition: yearwise_efficiency.py:24
TileCalibDrawerBase::getNGains
uint16_t getNGains() const
Returns the number of gains stored for each channel.
TileCalibDrawerBase::m_blobStart32
const uint32_t * m_blobStart32
Cache blob starting address as uint_32t*.
Definition: TileCalibDrawerBase.h:178
find
std::string find(const std::string &s)
return a remapped string
Definition: hcg.cxx:135
TileCalibBlobPython_writeOfc.phases
phases
Definition: TileCalibBlobPython_writeOfc.py:89
TileCalibDrawerBase::m_blob_nc
coral::Blob * m_blob_nc
Non-const reference to the BLOB.
Definition: TileCalibDrawerBase.h:174
TileCalibDrawerBase::m_hdrSize32
static const unsigned int m_hdrSize32
The header size in units of uint32_t.
Definition: TileCalibDrawerBase.h:138
xAOD::uint32_t
setEventNumber uint32_t
Definition: EventInfo_v1.cxx:127
TileCalib::InvalidBlob
Thrown if coral::Blob does not conform with expected structure.
Definition: TileCalorimeter/TileCalib/TileCalibBlobObjs/TileCalibBlobObjs/Exception.h:63
PHASE_PRECISION
#define PHASE_PRECISION
Class for storing Optimal Filtering Coefficients (OFCs) in a coral::Blob.
Definition: TileCalibDrawerOfc.h:38
TileCalibDrawerOfc::initCheck
void initCheck()
Definition: TileCalibDrawerOfc.cxx:58
MuonGM::round
float round(const float toRound, const unsigned int decimals)
Definition: Mdt.cxx:27
TileCalibDrawerOfc::getNPhases
int32_t getNPhases() const
Returns the number of phases (WARNING: Can be negative!)
TileCalibDrawerBase::getCommentSizeUint32
uint32_t getCommentSizeUint32() const
Returns the space occupied by the comment fields in units of uint32_t.
TileCalibType::getClassName
static std::string getClassName(TileCalibType::TYPE type)
Returns the class name.
Definition: TileCalibType.cxx:10
TileCalibDrawerBase::getCommentSizeChar
uint32_t getCommentSizeChar() const
Returns the space occupied by the comment fields in units of chars.
Definition: TileCalibDrawerBase.h:112
TileCalibDrawerBase::dumpHeader
void dumpHeader(std::ostream &stm) const
Prints the BLOB header summary information.
Definition: TileCalibDrawerBase.cxx:200
ReadOfcFromCool.field
field
Definition: ReadOfcFromCool.py:48
TileCalib::SizeConflict
Thrown if BLOB size is not correct.
Definition: TileCalorimeter/TileCalib/TileCalibBlobObjs/TileCalibBlobObjs/Exception.h:120
pi
#define pi
Definition: TileMuonFitter.cxx:65
TileCalibBlobPython_writeOfc.objVersion
objVersion
Definition: TileCalibBlobPython_writeOfc.py:71
TileCalibDrawerBase::getObjVersion
uint16_t getObjVersion() const
Returns the BLOB object version.
TileCalibDrawerBase::getTimeStamp
uint64_t getTimeStamp() const
Returns the unix timestamp of the comment (seconds since 1.1.1970)
TileCalibDrawerBase::getObjSizeByte
uint32_t getObjSizeByte() const
Returns the size of a data object in units of bytes.
Definition: TileCalibDrawerBase.h:102
TileCalibDrawerOfc::getType
virtual uint16_t getType() const
Returns TileCalibType::OFC.
Definition: TileCalibDrawerOfc.h:51
xAOD::uint16_t
setWord1 uint16_t
Definition: eFexEMRoI_v1.cxx:93
FullCPAlgorithmsTest_eljob.sample
sample
Definition: FullCPAlgorithmsTest_eljob.py:113
lumiFormat.i
int i
Definition: lumiFormat.py:85
D3PDSizeSummary.ff
ff
Definition: D3PDSizeSummary.py:305
python.DecayParser.buf
buf
print ("=> [%s]"cmd)
Definition: DecayParser.py:27
TileCalibDrawerOfc::dump
virtual void dump() const
Prints out the object content to std::cout.
Definition: TileCalibDrawerOfc.h:122
TileCalibDrawerBase::getNChans
uint16_t getNChans() const
Returns the number of channels stored in the BLOB.
TileCalibDrawerBase::getDate
std::string getDate() const
Returns the date of the comment as string (derived from timestamp)
Definition: TileCalibDrawerBase.cxx:176
xAOD::uint64_t
uint64_t
Definition: EventInfo_v1.cxx:123
TileCalibType::OFC
@ OFC
Enum for TileCalibDrawerOfc class.
Definition: TileCalibType.h:29
CaloCondBlobAlgs_fillNoiseFromASCII.comment
string comment
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:27
TileCalibDrawerBase::createBlob
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.
Definition: TileCalibDrawerBase.cxx:87
TileCalibDrawerOfc::getPhase
float getPhase(unsigned int channel, unsigned int adc, unsigned int phaseIdx) const
Returns the stored phase.
TileCalibDrawerOfc::FieldC
@ FieldC
Definition: TileCalibDrawerOfc.h:45
TileCalibDrawerBase::getComment
std::string getComment() const
Returns the actual comment.
Definition: TileCalibDrawerBase.cxx:161
BchCleanup.calibDrawer
calibDrawer
Definition: BchCleanup.py:217
TileCalibDrawerOfc::FieldB
@ FieldB
Definition: TileCalibDrawerOfc.h:45
xAOD::timeStamp
setEventNumber timeStamp
Definition: EventInfo_v1.cxx:128
TileCalibDrawerOfc
Definition: TileCalibDrawerOfc.h:40
TileCalibDrawerBase::m_blobSize32
uint64_t m_blobSize32
Cache blob size in units of uint32_t.
Definition: TileCalibDrawerBase.h:182
CheckAppliedSFs.pu
pu
Definition: CheckAppliedSFs.py:311
InDetDD::other
@ other
Definition: InDetDD_Defs.h:16
TileCalibDrawerBase::getObjType
uint16_t getObjType() const
Returns the BLOB object type.
CaloSwCorrections.time
def time(flags, cells_name, *args, **kw)
Definition: CaloSwCorrections.py:242
ReadFloatFromCool.adc
adc
Definition: ReadFloatFromCool.py:48
TileCalibDrawerOfc::FieldDG
@ FieldDG
Definition: TileCalibDrawerOfc.h:45
CaloCondBlobAlgs_fillNoiseFromASCII.author
string author
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:26
TileCalibDrawerOfc::TileCalibDrawerOfc
TileCalibDrawerOfc(const coral::Blob &blob)
Ctor (const).
Definition: TileCalibDrawerOfc.cxx:42
LArNewCalib_DelayDump_OFC_Cali.idx
idx
Definition: LArNewCalib_DelayDump_OFC_Cali.py:69
TileCalibDrawerOfc::getNSamples
uint32_t getNSamples() const
Returns the number of sample stored.
TileCalibDrawerOfc::getPhaseStartAddress
const int32_t * getPhaseStartAddress(unsigned int channel, unsigned int adc, unsigned int phaseIdx) const
Returns pointer to the requested phase value.
TileCalibDrawerOfc::FieldA
@ FieldA
Definition: TileCalibDrawerOfc.h:45
TileCalibDrawerBase::TileCalibDrawerBase
TileCalibDrawerBase(const TileCalibDrawerBase &other)
Copy Ctor.
Definition: TileCalibDrawerBase.cxx:44
TileCalibDrawerOfc::getNFields
uint32_t getNFields(uint16_t objVersion=0) const
Returns the number of fields.
TileCalib::TypeConflict
Thrown if object type in BLOB does not agree with class type.
Definition: TileCalorimeter/TileCalib/TileCalibBlobObjs/TileCalibBlobObjs/Exception.h:99
LArDigits2NtupleDumper.nSamples
nSamples
Definition: LArDigits2NtupleDumper.py:70
TileCalibDrawerBase::m_blob
const coral::Blob * m_blob
Const reference to the BLOB (always there)
Definition: TileCalibDrawerBase.h:176
TileCalibDrawerBase::getObjSizeUint32
uint32_t getObjSizeUint32() const
Returns the size of a data object in units of uint32_t.
TileCalibDrawerOfc::FieldG
@ FieldG
Definition: TileCalibDrawerOfc.h:45
zero
void zero(TH2 *h)
zero the contents of a 2d histogram
Definition: comparitor.cxx:436
TileCalibDrawerBase::getAddress
const void * getAddress(unsigned int iEle) const
Returns start address of iEle-th basic unit.
CaloCondBlobAlgs_fillNoiseFromASCII.blob
blob
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:96
TileCalibDrawerBase::m_blobStart16
const uint16_t * m_blobStart16
Cache blob starting address as uint_16t*.
Definition: TileCalibDrawerBase.h:180
TileCalibDrawerBase::getNObjs
uint32_t getNObjs() const
Returns the number of data objects stored int the BLOB.