master with all recent fixes into the raisor branch for work this week #1

Open
calemhoffman wants to merge 35 commits from master into raisor
5 changed files with 34 additions and 45 deletions
Showing only changes of commit 4e111085c0 - Show all commits

View File

@ -16,9 +16,6 @@
#include "macro.h"
//#define MaxNData 10000 /// store 10k events per channels
#define DefaultDataSize 10000
enum DPPTypeCode{
DPP_PHA_CODE = 0x8B,
DPP_PSD_CODE = 0x88,
@ -58,11 +55,11 @@ class Data{
uShort GetDataSize() const {return dataSize;}
ullong GetTimestamp(unsigned short ch, unsigned int index) const {return Timestamp[ch][index];}
uShort GetFineTime(unsigned short ch, unsigned int index) const {return fineTime[ch][index];}
uShort GetEnergy(unsigned short ch, unsigned int index) const {return Energy[ch][index];}
uShort GetEnergy2(unsigned short ch, unsigned int index) const {return Energy2[ch][index];}
bool GetPileUp(unsigned short ch, unsigned int index) const {return PileUp[ch][index];}
ullong GetTimestamp(unsigned short ch, unsigned int index) const {return Timestamp[ch][index % dataSize];}
uShort GetFineTime(unsigned short ch, unsigned int index) const {return fineTime[ch][index % dataSize];}
uShort GetEnergy(unsigned short ch, unsigned int index) const {return Energy[ch][index % dataSize];}
uShort GetEnergy2(unsigned short ch, unsigned int index) const {return Energy2[ch][index % dataSize];}
bool GetPileUp(unsigned short ch, unsigned int index) const {return PileUp[ch][index % dataSize];}
uInt GetWordIndex() const {return nw;}

View File

@ -441,7 +441,7 @@ int Digitizer::ProgramBoard_PSD(){
ret |= CAEN_DGTZ_WriteRegister(handle, (uint32_t)(DPP::PSD::DPPAlgorithmControl2_G) + 0x7000 , 0x00000200 ); // use fine time
ret |= CAEN_DGTZ_WriteRegister(handle, (uint32_t)(DPP::DPPAlgorithmControl) + 0x7000 , 0x00100002 ); // baseline 16 sample, 80fC
ret |= CAEN_DGTZ_WriteRegister(handle, (uint32_t)(DPP::DPPAlgorithmControl) + 0x7000 , 0x00100003 ); // baseline 16 sample, 320fC
ret |= CAEN_DGTZ_WriteRegister(handle, (uint32_t)(DPP::PSD::TriggerThreshold) + 0x7000 , 100 );

View File

@ -13,8 +13,7 @@ SingleSpectra::SingleSpectra(Digitizer ** digi, unsigned int nDigi, QString rawD
this->nDigi = nDigi;
this->settingPath = rawDataPath + "/HistogramSettings.txt";
maxFillTimeinMilliSec = 900;
maxFillTimePerDigi = maxFillTimeinMilliSec/nDigi;
maxFillTimeinMilliSec = SingleHistogramFillingTime;
isSignalSlotActive = true;
@ -155,11 +154,11 @@ SingleSpectra::SingleSpectra(Digitizer ** digi, unsigned int nDigi, QString rawD
histWorker->moveToThread(workerThread);
workerThread->start();
// connect(timer, &QTimer::timeout, histWorker, &HistWorker::FillHistograms);
connect( histWorker, &HistWorker::workDone, this, &SingleSpectra::ReplotHistograms);
// workerThread->start();
connect(timer, &QTimer::timeout, this, [=](){
if( isFillingHistograms == false){
histWorker->FillHistograms();
@ -194,7 +193,6 @@ void SingleSpectra::ClearInternalDataCount(){
for( unsigned int i = 0; i < nDigi; i++){
for( int ch = 0; ch < MaxRegChannel ; ch++) {
lastFilledIndex[i][ch] = -1;
loopFilledIndex[i][ch] = 0;
}
}
}
@ -273,10 +271,11 @@ void SingleSpectra::FillHistograms(){
clock_gettime(CLOCK_REALTIME, &ta);
std::vector<int> digiChList; // (digi*1000 + ch)
std::vector<int> digiChLastIndex; // lastIndex
std::vector<int> digiChLoopIndex; // loopIndex
std::vector<int> digiChLastIndex; // loop * dataSize + index;
std::vector<int> digiChAvalibleData;
std::vector<bool> digiChFilled;
std::vector<int> digiChFilledCount;
for( int ID = 0; ID < nDigi; ID++){
for( int ch = 0; ch < digi[ID]->GetNumInputCh(); ch++){
@ -284,19 +283,22 @@ void SingleSpectra::FillHistograms(){
int loopIndex = digi[ID]->GetData()->GetLoopIndex(ch);
int temp1 = lastIndex + loopIndex * digi[ID]->GetData()->GetDataSize();
int temp2 = lastFilledIndex[ID][ch] + loopFilledIndex[ID][ch] * digi[ID]->GetData()->GetDataSize() + 1;
int temp2 = lastFilledIndex[ID][ch];
if( temp1 <= temp2 ) continue;
digiChList.push_back( ID*1000 + ch ) ;
digiChLastIndex.push_back(lastIndex);
digiChLoopIndex.push_back(loopIndex);
digiChLastIndex.push_back(temp1);
digiChAvalibleData.push_back(temp1-temp2);
digiChFilled.push_back(false);
digiChFilledCount.push_back(0);
}
}
int nSize = digiChList.size();
clock_gettime(CLOCK_REALTIME, &tb);
printf("Checking time : %8.3f ms\n", (tb.tv_nsec - ta.tv_nsec)/1e6 + (tb.tv_sec - ta.tv_sec)*1e3 );
// printf("------------ nSize : %d \n", nSize);
if( nSize == 0 ) {
@ -320,28 +322,17 @@ void SingleSpectra::FillHistograms(){
int ch = digiCh % 1000;
// printf(" -------------------- %d / %d | %d\n", randomValue, nSize-1, digiCh);
int lastIndex = digiChLastIndex[randomValue];
int loopIndex = digiChLoopIndex[randomValue];
int temp1 = lastIndex + loopIndex * digi[ID]->GetData()->GetDataSize();
int temp2 = lastFilledIndex[ID][ch] + loopFilledIndex[ID][ch] * digi[ID]->GetData()->GetDataSize() + 1;
if( temp1 <= temp2 ) {
if( digiChLastIndex[randomValue] <= lastFilledIndex[ID][ch] ) {
digiChFilled[randomValue] = true;
// printf("Digi-%2d ch-%2d all filled | %zu\n", ID, ch, digiChList.size());
continue;
}
if( temp1 - temp2 > digi[ID]->GetData()->GetDataSize() ) { //DefaultDataSize = 10k
temp2 = temp1 - digi[ID]->GetData()->GetDataSize();
lastFilledIndex[ID][ch] = lastIndex;
loopFilledIndex[ID][ch] = loopIndex - 1;
if( digiChLastIndex[randomValue] - lastFilledIndex[ID][ch] > digi[ID]->GetData()->GetDataSize() ) { //DefaultDataSize = 10k
lastFilledIndex[ID][ch] = digiChLastIndex[randomValue] - digi[ID]->GetData()->GetDataSize() ;
}
lastFilledIndex[ID][ch] ++;
if( lastFilledIndex[ID][ch] > digi[ID]->GetData()->GetDataSize() ) {
lastFilledIndex[ID][ch] = 0;
loopFilledIndex[ID][ch] ++;
}
digiChFilledCount[randomValue]++;
uShort data = digi[ID]->GetData()->GetEnergy(ch, lastFilledIndex[ID][ch]);
@ -352,8 +343,13 @@ void SingleSpectra::FillHistograms(){
}
hist2D[ID]->Fill(ch, data);
usleep(10);
clock_gettime(CLOCK_REALTIME, &tb);
}while( isFillingHistograms || (tb.tv_nsec - ta.tv_nsec)/1e6 + (tb.tv_sec - ta.tv_sec)*1e3 < maxFillTimeinMilliSec );
}while( isFillingHistograms && (tb.tv_nsec - ta.tv_nsec)/1e6 + (tb.tv_sec - ta.tv_sec)*1e3 < maxFillTimeinMilliSec );
clock_gettime(CLOCK_REALTIME, &tb);
printf("Filling time : %8.3f ms\n", (tb.tv_nsec - ta.tv_nsec)/1e6 + (tb.tv_sec - ta.tv_sec)*1e3 );
//*--------------- generate fillign report
for( size_t i = 0; i < digiChFilled.size() ; i++){
@ -362,13 +358,7 @@ void SingleSpectra::FillHistograms(){
int ch = digiCh % 1000;
// printf(" -------------------- %d / %d | %d\n", randomValue, nSize-1, digiCh);
int lastIndex = digiChLastIndex[i];
int loopIndex = digiChLoopIndex[i];
int temp1 = lastIndex + loopIndex * digi[ID]->GetData()->GetDataSize();
int temp2 = lastFilledIndex[ID][ch] + loopFilledIndex[ID][ch] * digi[ID]->GetData()->GetDataSize() + 1;
printf("Digi-%2d ch-%2d | event unfilled %d / %d\n", ID, ch, temp1 - temp2, digiChAvalibleData[i] );
printf("Digi-%2d ch-%2d | event filled %d / %d\n", ID, ch, digiChFilledCount[i], digiChAvalibleData[i] );
}
clock_gettime(CLOCK_REALTIME, &tb);

View File

@ -64,11 +64,9 @@ private:
Digitizer ** digi;
unsigned short nDigi;
int lastFilledIndex[MaxNDigitizer][MaxNChannels];
int loopFilledIndex[MaxNDigitizer][MaxNChannels];
long lastFilledIndex[MaxNDigitizer][MaxNChannels]; // index * dataSize + index
bool histVisibility[MaxNDigitizer][MaxNChannels];
bool hist2DVisibility[MaxNDigitizer];
unsigned short maxFillTimePerDigi;
bool isFillingHistograms;
Histogram1D * hist[MaxNDigitizer][MaxNChannels];

View File

@ -11,8 +11,12 @@
#define MaxRecordLength 0x3fff * 8
#define MaxSaveFileSize 1024 * 1024 * 1024 * 2
#define DefaultDataSize 10000 /// store 10k events per channels
#define ScalarUpdateinMiliSec 1000 // msec
#define SingleHistogramFillingTime 900 // msec
#define MaxDisplayTraceTimeLength 20000 //ns
#define ScopeUpdateMiliSec 200 // msec
#define MaxNumberOfTrace 5 // in an event