Hotfix for bug in handling waves data. Properly size first hit when peaking number of samples. Limit amount of dynamic memory allocation when reading in data. Fix ROOT weirdness when using uint64_t for a branch by making DPPChannel calibrated energy int64_t (hardly ever used)

This commit is contained in:
Gordon McCann 2022-05-23 09:23:12 -04:00
parent 36bfd91e59
commit 0ad5d9cd30
3 changed files with 9 additions and 6 deletions

View File

@ -90,8 +90,8 @@ namespace EventBuilder {
if(IsWaves()) if(IsWaves())
{ {
m_hitsize += 5; m_hitsize += 5;
char* firstHit = new char[24]; //A compass hit by default has 24 bytes (at least in our setup) char* firstHit = new char[m_hitsize]; //A compass hit by default has 24 bytes (at least in our setup)
m_file->read(firstHit, 24); m_file->read(firstHit, m_hitsize);
firstHit += m_hitsize - 4; firstHit += m_hitsize - 4;
uint32_t nsamples = *((uint32_t*) firstHit); uint32_t nsamples = *((uint32_t*) firstHit);
m_hitsize += nsamples * 2; //Each sample is a 2 byte data value m_hitsize += nsamples * 2; //Each sample is a 2 byte data value
@ -184,16 +184,18 @@ namespace EventBuilder {
m_bufferIter += 1; m_bufferIter += 1;
m_currentHit.Ns = *((uint32_t*)m_bufferIter); m_currentHit.Ns = *((uint32_t*)m_bufferIter);
m_bufferIter += 4; m_bufferIter += 4;
for(uint32_t i=0; i<m_currentHit.Ns; i++) if(m_currentHit.samples.size() != m_currentHit.Ns)
m_currentHit.samples.resize(m_currentHit.Ns);
for(size_t i=0; i<m_currentHit.samples.size(); i++)
{ {
m_currentHit.samples.push_back(*(uint16_t*)m_bufferIter); m_currentHit.samples[i] = *((uint16_t*)m_bufferIter);
m_bufferIter += 2; m_bufferIter += 2;
} }
} }
if(m_smap != nullptr) if(m_smap != nullptr)
{ //memory safety { //memory safety
int gchan = m_currentHit.channel + m_currentHit.board*16; int gchan = m_currentHit.channel + m_currentHit.board*m_channels_per_board;
m_currentHit.timestamp += m_smap->GetShift(gchan); m_currentHit.timestamp += m_smap->GetShift(gchan);
} }

View File

@ -64,6 +64,7 @@ namespace EventBuilder {
bool m_hitUsedFlag; bool m_hitUsedFlag;
int m_bufsize = 200000; //size of the buffer in hits int m_bufsize = 200000; //size of the buffer in hits
int m_hitsize; //size of a CompassHit in bytes (without alignment padding) int m_hitsize; //size of a CompassHit in bytes (without alignment padding)
int m_channels_per_board = 16; //Number of channels per digitzer board, important for generating id!
uint16_t m_header; uint16_t m_header;
int m_buffersize; int m_buffersize;

View File

@ -13,7 +13,7 @@ struct DPPChannel
{ {
double Timestamp; double Timestamp;
int Channel, Board, Energy, EnergyShort; int Channel, Board, Energy, EnergyShort;
uint64_t EnergyCal; int64_t EnergyCal;
int Flags; int Flags;
std::vector<uint16_t> Samples; std::vector<uint16_t> Samples;
}; };