added fast decode, that skipp waveform

This commit is contained in:
carina@hades 2022-10-24 17:01:05 -04:00
parent f9ced8aac7
commit 12f965f788
4 changed files with 180 additions and 174 deletions

View File

@ -65,7 +65,7 @@ class Data{
unsigned int GetPresentFileSize() {return presentFileSizeByte;}
void PrintBuffer() const; //Incorrect
void DecodeBuffer(bool fastDecode, int verbose = 0);
void DecodeBuffer(bool fastDecode, int verbose = 0); /// fastDecode will not save waveform
void DecodeBuffer(char * buffer, unsigned int size, bool fastDecode, int verbose = 0); // for outside data
void PrintStat() const;
@ -192,9 +192,8 @@ inline void Data::SaveBuffer(const char * fileName){
inline void Data::PrintStat() const{
printf("========= %d \n", IsNotRollOverFakeAgg);
if( IsNotRollOverFakeAgg ) {
printf(" this is roll-over fake event.\n");
printf(" this is roll-over fake event or no events.\n");
return;
}
printf("%2s | %6s | %9s | %6s\n", "ch", "# Evt.", "Rate [Hz]", "Tot. Evt.");
@ -330,12 +329,12 @@ inline int Data::DecodePHADualChannelBlock(unsigned int ChannelMask, bool fastDe
nSample = ( word & 0xFFFF ) * 8;
extra2Option = ( (word >> 24 ) & 0x7 );
hasExtra2 = ( (word >> 28 ) & 0x1 );
if( !fastDecode) {
unsigned int digitalProbe = ( (word >> 16 ) & 0xF );
unsigned int analogProbe2 = ( (word >> 20 ) & 0x3 );
unsigned int analogProbe1 = ( (word >> 22 ) & 0x3 );
bool hasWaveForm = ( (word >> 27 ) & 0x1 );
hasExtra2 = ( (word >> 28 ) & 0x1 );
bool hasTimeStamp = ( (word >> 29 ) & 0x1 );
bool hasEnergy = ( (word >> 30 ) & 0x1 );
hasDualTrace = ( (word >> 31 ) & 0x1 );
@ -344,7 +343,6 @@ inline int Data::DecodePHADualChannelBlock(unsigned int ChannelMask, bool fastDe
printf("DualTrace : %d, Energy : %d, Time: %d, Wave : %d, Extra2: %d \n",
hasDualTrace, hasEnergy, hasTimeStamp, hasWaveForm, hasExtra2);
}
if( verbose >= 3){
if( hasExtra2 ){
printf("...... extra 2 : ");
@ -390,6 +388,7 @@ inline int Data::DecodePHADualChannelBlock(unsigned int ChannelMask, bool fastDe
case 12 : printf("Busy = memory is full \n"); break;
}
}
}
nEvents = aggSize / (nSample/2 + 2 + hasExtra2 );
if( verbose >= 2 ) printf("-------------------nEvents : %d \n", nEvents);
}else{
@ -408,13 +407,16 @@ inline int Data::DecodePHADualChannelBlock(unsigned int ChannelMask, bool fastDe
//TODO Skip
///===== read waveform
if( SaveWaveToMemory ) {
if( !fastDecode && SaveWaveToMemory ) {
tempWaveform1.clear();
tempWaveform2.clear();
tempDigiWaveform1.clear();
}
unsigned int triggerAtSample = 0 ;
if( fastDecode ){
nw += nSample/2;
}else{
for( int wi = 0; wi < nSample/2; wi++){
nw = nw +1 ; word = ReadBuffer(nw, verbose - 2);
bool isTrigger1 = (( word >> 31 ) & 0x1 );
@ -455,7 +457,7 @@ inline int Data::DecodePHADualChannelBlock(unsigned int ChannelMask, bool fastDe
}
DigiWaveform1[channel][NumEvents[channel]] = tempDigiWaveform1;
}
}
unsigned long long extTimeStamp = 0;
unsigned int extra2 = 0;
if( hasExtra2 ){
@ -471,13 +473,12 @@ inline int Data::DecodePHADualChannelBlock(unsigned int ChannelMask, bool fastDe
nw = nw +1 ; word = ReadBuffer(nw, verbose);
unsigned int extra = (( word >> 16) & 0x3FF);
unsigned int energy = (word & 0x7FFF);
bool pileUpOrRollOver = ((word >> 15) & 0x1);
bool pileUp = (extra & 0x200);
bool rollOver = (extra & 0x002);
bool pileUp = (extra & 0x200);
bool pileUpOrRollOver = ((word >> 15) & 0x1);
if( verbose >= 3 ) {
printf("PileUp : %d , extra : 0x%03x, energy : %d \n", pileUp, extra, energy);
printf(" lost event : %d \n", ((extra >> 0) & 0x1) );
printf(" roll-over : %d (fake event)\n", ((extra >> 1) & 0x1) );
printf(" fake-event : %d \n", ((extra >> 3) & 0x1) );
@ -601,13 +602,16 @@ inline int Data::DecodePSDDualChannelBlock(unsigned int ChannelMask, bool fastDe
if( verbose >= 2 ) printf("ch : %d, timeStamp %u \n", channel, timeStamp0);
///===== read waveform
if( SaveWaveToMemory ) {
if( !fastDecode && SaveWaveToMemory ) {
tempWaveform1.clear();
tempWaveform2.clear();
tempDigiWaveform1.clear();
tempDigiWaveform2.clear();
}
if( fastDecode ){
nw += nSample/2;
}else{
for( int wi = 0; wi < nSample/2; wi++){
nw = nw +1 ; word = ReadBuffer(nw, verbose - 2);
bool dp2b = (( word >> 31 ) & 0x1 );
@ -637,7 +641,6 @@ inline int Data::DecodePSDDualChannelBlock(unsigned int ChannelMask, bool fastDe
printf("%4d| %5d, %d, %d \n", 2*wi+1, waveb, dp1b, dp2b);
}
}
if( SaveWaveToMemory ) {
if( hasDualTrace ){
Waveform1[channel][NumEvents[channel]] = tempWaveform1;
@ -648,7 +651,7 @@ inline int Data::DecodePSDDualChannelBlock(unsigned int ChannelMask, bool fastDe
DigiWaveform1[channel][NumEvents[channel]] = tempDigiWaveform1;
DigiWaveform2[channel][NumEvents[channel]] = tempDigiWaveform2;
}
}
nw = nw +1 ; word = ReadBuffer(nw, verbose);
unsigned int extra = word;
unsigned long long extTimeStamp = 0;

View File

@ -431,7 +431,7 @@ void Digitizer::PrintACQStatue(){
//===========================================================
void Digitizer::WriteRegister (Reg registerAddress, uint32_t value, int ch, bool isSave2MemAndFile){
printf("%s[0x%04X](ch-%02d) [0x%04X]: %u \n", registerAddress.GetNameChar(), registerAddress.GetAddress(),ch, registerAddress.ActualAddress(ch), value);
printf("%s[0x%04X](ch-%02d) [0x%04X]: 0x%08X \n", registerAddress.GetNameChar(), registerAddress.GetAddress(),ch, registerAddress.ActualAddress(ch), value);
if( !isConnected ) {
SetSettingToMemory(registerAddress, value, ch);

View File

@ -115,7 +115,7 @@ ChannelSettingPHA::ChannelSettingPHA(const TGWindow *p, UInt_t w, UInt_t h, Digi
TGLabel * lbEventAgg = new TGLabel(vfInput1, "Events / Aggregate"); vfInput1->AddFrame(lbEventAgg, layoutHintsR);
numEventAgg = new TGNumberEntry(vfInput2, 512, 0, 0, TGNumberFormat::kNESInteger, TGNumberFormat::kNEANonNegative); vfInput2->AddFrame(numEventAgg, layoutHints);
numEventAgg->Resize(width, 20);
numEventAgg->SetLimits(TGNumberFormat::kNELLimitMinMax, 0, 511);
numEventAgg->SetLimits(TGNumberFormat::kNELLimitMinMax, 1, 511);
numEventAgg->Connect("Modified()", "ChannelSettingPHA", this, "SetEventAggregate()");
TGLabel * lbBuffer = new TGLabel(vfInput1, "Buffer Size [MByte]"); vfInput1->AddFrame(lbBuffer, layoutHintsR);

View File

@ -92,31 +92,31 @@ int main(int argc, char* argv[]){
//dig->PrintSettingFromMemory();
dig->WriteRegister(Register::DPP::SoftwareClear_W, 1);
//dig->WriteRegister(Register::DPP::SoftwareClear_W, 1);
///dig->SaveSettingAsText("haha.txt");
/****
{///============ Checking the buffer size calculation
unsigned short B = 1; /// BLT
unsigned short Eg = 10; /// Event / dual channel
unsigned short E2 = 1; /// extra 2;
unsigned short RL = 250; /// record Length
for( int i = 0; i < dig->GetNChannel(); i++){
dig->WriteRegister(Register::DPP::NumberEventsPerAggregate_G, Eg, i);
dig->WriteRegister(Register::DPP::RecordLength_G, RL, i);
}
dig->WriteRegister(Register::DPP::MaxAggregatePerBlockTransfer, B, 0);
dig->WriteRegister(Register::DPP::BoardConfiguration, 0x0F8115); /// has Extra2
//for( int i = 0; i < dig->GetNChannel(); i++){
// dig->WriteRegister(Register::DPP::NumberEventsPerAggregate_G, Eg, i);
// dig->WriteRegister(Register::DPP::RecordLength_G, RL, i);
//}
//dig->WriteRegister(Register::DPP::MaxAggregatePerBlockTransfer, B, 0);
//dig->WriteRegister(Register::DPP::BoardConfiguration, 0x0F8115); /// has Extra2
//dig->WriteRegister(Register::DPP::BoardConfiguration, 0x0D8115); /// no Extra2
unsigned int bSize = dig->CalByteForBuffer();
//int bbbb = (((2 + E2 + RL*4) * Eg + 2)*8 + 4)*B *4;
//int bbb2 = (((2 + E2 + RL*4) * Eg + 2)*2 + 4)*B *4;
//
//printf("============== exp Buffer size : %8u byte \n", bbbb);
//printf("============== exp 2 ch size : %8u byte = %u words\n", bbb2, bbb2/4);
int bbbb = (((2 + E2 + RL*4) * Eg + 2)*8 + 4)*B *4;
int bbb2 = (((2 + E2 + RL*4) * Eg + 2)*3 + 4)*B *4;
printf("============== exp Buffer size : %8u byte \n", bbbb);
printf("============== exp 3 ch size : %8u byte = %u words\n", bbb2, bbb2/4);
usleep(1e6);
@ -129,7 +129,7 @@ int main(int argc, char* argv[]){
printf(" diff : %8u byte \n", size > bSize ? size - bSize : bSize - size);
delete buffer;
}*/
dig->StartACQ();
@ -137,7 +137,10 @@ int main(int argc, char* argv[]){
usleep(1000000);
dig->ReadData();
printf("------------------- %d\n", i);
dig->GetData()->DecodeBuffer(false,2);
unsigned long time1 = get_time();
dig->GetData()->DecodeBuffer(true,0);
unsigned long time2 = get_time();
printf("********************* decode time : %lu usec\n", time2-time1);
dig->GetData()->PrintStat();
}