tested the buffer size calculation with real signal. the CEAN one is 2 times more
This commit is contained in:
parent
5f4fd901c3
commit
f9ced8aac7
11
ClassData.h
11
ClassData.h
|
@ -52,8 +52,8 @@ class Data{
|
||||||
Data();
|
Data();
|
||||||
~Data();
|
~Data();
|
||||||
|
|
||||||
void AllocateMemory();
|
void Allocate10MBMemory();
|
||||||
void AllocateMemory(unsigned long size);
|
void AllocateMemory(uint32_t size);
|
||||||
|
|
||||||
void SetSaveWaveToMemory(bool OnOff) { this->SaveWaveToMemory = OnOff; }
|
void SetSaveWaveToMemory(bool OnOff) { this->SaveWaveToMemory = OnOff; }
|
||||||
|
|
||||||
|
@ -114,14 +114,15 @@ inline Data::~Data(){
|
||||||
delete buffer;
|
delete buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void Data::AllocateMemory(unsigned long size){
|
inline void Data::AllocateMemory(uint32_t size){
|
||||||
delete buffer;
|
delete buffer;
|
||||||
|
printf("===== size : %u \n", size);
|
||||||
BufferSize = size;
|
BufferSize = size;
|
||||||
buffer = (char *) malloc( BufferSize);
|
buffer = (char *) malloc( BufferSize);
|
||||||
printf("Allocated %d byte for buffer \n", BufferSize);
|
printf("Allocated %u byte for buffer = %u words\n", BufferSize, BufferSize / 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void Data::AllocateMemory(){
|
inline void Data::Allocate10MBMemory(){
|
||||||
AllocateMemory( 10 * 1024 * 1024 ); /// 10 M Byte
|
AllocateMemory( 10 * 1024 * 1024 ); /// 10 M Byte
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -90,7 +90,7 @@ int Digitizer::OpenDigitizer(int boardID, int portID, bool program, bool verbose
|
||||||
LinkType = CAEN_DGTZ_OpticalLink ;
|
LinkType = CAEN_DGTZ_OpticalLink ;
|
||||||
ret = (int) CAEN_DGTZ_OpenDigitizer(LinkType, portID, boardID, VMEBaseAddress, &handle);
|
ret = (int) CAEN_DGTZ_OpenDigitizer(LinkType, portID, boardID, VMEBaseAddress, &handle);
|
||||||
}
|
}
|
||||||
ErrorMsg("=== Open Digitizer");
|
ErrorMsg("=== Open Digitizer port " +std::to_string(portID) + " board " + std::to_string(boardID));
|
||||||
|
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
if( verbose) printf("Can't open digitizer\n");
|
if( verbose) printf("Can't open digitizer\n");
|
||||||
|
@ -179,8 +179,9 @@ int Digitizer::OpenDigitizer(int boardID, int portID, bool program, bool verbose
|
||||||
|
|
||||||
ErrorMsg("end of OpenDigitizer");
|
ErrorMsg("end of OpenDigitizer");
|
||||||
|
|
||||||
|
if( isConnected ) isDummy = false;
|
||||||
|
|
||||||
if( isConnected && program) {
|
if( isConnected && program) {
|
||||||
isDummy = false;
|
|
||||||
ProgramBoard();
|
ProgramBoard();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -374,23 +375,20 @@ unsigned int Digitizer::CalByteForBuffer(){
|
||||||
printf(" Channel Mask : %04X \n", chMask);
|
printf(" Channel Mask : %04X \n", chMask);
|
||||||
printf("Max number of Agg per Readout : %u \n", numAggBLT);
|
printf("Max number of Agg per Readout : %u \n", numAggBLT);
|
||||||
printf(" is Extra2 enabed : %u \n", ((boardCfg >> 17) & 0x1) );
|
printf(" is Extra2 enabed : %u \n", ((boardCfg >> 17) & 0x1) );
|
||||||
|
|
||||||
for( int pCh = 0; pCh < NChannel/2; pCh++){
|
for( int pCh = 0; pCh < NChannel/2; pCh++){
|
||||||
printf("Paied Ch : %d, RecordLength (bit value): %u, Event per Agg. : %u \n", pCh, recordLength[pCh], eventAgg[pCh]);
|
printf("Paired Ch : %d, RecordLength (bit value): %u, Event per Agg. : %u \n", pCh, recordLength[pCh], eventAgg[pCh]);
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int bufferSize = 4; /// Board Agg. header
|
unsigned int bufferSize = 0;
|
||||||
/// Cal size for each dual channel aggregation
|
|
||||||
for( int pCh = 0; pCh < NChannel/2 ; pCh++){
|
for( int pCh = 0; pCh < NChannel/2 ; pCh++){
|
||||||
if( (chMask & ( 3 << (2 * pCh) )) == 0 ) continue;
|
if( (chMask & ( 3 << (2 * pCh) )) == 0 ) continue;
|
||||||
bufferSize += ( 2 + ((boardCfg >> 17) & 0x1) + recordLength[pCh]*4 ) * eventAgg[pCh] ;
|
bufferSize += 2 + ( 2 + ((boardCfg >> 17) & 0x1) + recordLength[pCh]*4 ) * eventAgg[pCh] ;
|
||||||
}
|
}
|
||||||
|
bufferSize += 4; /// Bd. Agg Header
|
||||||
///return bufferSize * numAggBLT * 4; /// 1 word = 4 byte;
|
bufferSize = bufferSize * numAggBLT * 4; /// 1 words = 4 byte
|
||||||
|
|
||||||
///to Match CAEN calculation
|
printf("================ Buffer Size : %d Byte \n", bufferSize );
|
||||||
return ( ( bufferSize * 2 + 28 ) * numAggBLT + 4 ) * 4; /// 1 word = 4 byte;
|
return bufferSize ;
|
||||||
/// this is effectively, means, the board Agg. header size is 36 words, and dual channel is count for MaxNChannel.
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Digitizer::ReadData(){
|
void Digitizer::ReadData(){
|
||||||
|
|
|
@ -417,6 +417,9 @@ void MainWindow::OpenDigitizers(){
|
||||||
|
|
||||||
fMenuDigitizers->DisableEntry( M_DIGITIZER_OPEN);
|
fMenuDigitizers->DisableEntry( M_DIGITIZER_OPEN);
|
||||||
fMenuDigitizers->DisableEntry( M_LOAD_SETTINGS);
|
fMenuDigitizers->DisableEntry( M_LOAD_SETTINGS);
|
||||||
|
fMenuDigitizers->EnableEntry( M_BOARD_SETTINGS);
|
||||||
|
fMenuDigitizers->EnableEntry( M_CH_SETTING_PHA);
|
||||||
|
fMenuDigitizers->EnableEntry( M_CH_SETTING_PSD);
|
||||||
fMenuDigitizers->EnableEntry( M_TRIGGER_SUMMARY);
|
fMenuDigitizers->EnableEntry( M_TRIGGER_SUMMARY);
|
||||||
fMenuDigitizers->EnableEntry( M_REGISTER_SETTING);
|
fMenuDigitizers->EnableEntry( M_REGISTER_SETTING);
|
||||||
bOpenDigitizers->SetEnabled(false);
|
bOpenDigitizers->SetEnabled(false);
|
||||||
|
|
|
@ -962,7 +962,6 @@ void BoardSetting::ChangeBoard(){
|
||||||
/// Trigger Validation Mask
|
/// Trigger Validation Mask
|
||||||
for( int i = 0; i < 8; i++){
|
for( int i = 0; i < 8; i++){
|
||||||
tempBits = digi[boardID]->GetSettingFromMemory(Register::DPP::TriggerValidationMask_G, 2*i);
|
tempBits = digi[boardID]->GetSettingFromMemory(Register::DPP::TriggerValidationMask_G, 2*i);
|
||||||
printf("%2d | 0x%04X \n", i, tempBits);
|
|
||||||
for( int j = 0; j < 8; j++){
|
for( int j = 0; j < 8; j++){
|
||||||
cbTRGValMskCh[i][j]->SetState( ((tempBits >> j ) & 0x1) == 0 ? kButtonUp : kButtonDown , false);
|
cbTRGValMskCh[i][j]->SetState( ((tempBits >> j ) & 0x1) == 0 ? kButtonUp : kButtonDown , false);
|
||||||
}
|
}
|
||||||
|
@ -1521,6 +1520,7 @@ void BoardSetting::SaveSettingFile(){
|
||||||
|
|
||||||
}else{
|
}else{
|
||||||
int boardID = boardIDEntry->GetNumber();
|
int boardID = boardIDEntry->GetNumber();
|
||||||
|
//TODO saev as same file
|
||||||
digi[boardID]->OpenSettingBinary( fi.fFilename );
|
digi[boardID]->OpenSettingBinary( fi.fFilename );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -127,6 +127,7 @@ ChannelSettingPHA::ChannelSettingPHA(const TGWindow *p, UInt_t w, UInt_t h, Digi
|
||||||
TGLabel * lbDCOffset = new TGLabel(vfInput1, "DC offset [%]"); vfInput1->AddFrame(lbDCOffset, layoutHintsR);
|
TGLabel * lbDCOffset = new TGLabel(vfInput1, "DC offset [%]"); vfInput1->AddFrame(lbDCOffset, layoutHintsR);
|
||||||
numDCOffset = new TGNumberEntry(vfInput2, 20, 0, 0, TGNumberFormat::kNESRealTwo, TGNumberFormat::kNEANonNegative); vfInput2->AddFrame(numDCOffset, layoutHints);
|
numDCOffset = new TGNumberEntry(vfInput2, 20, 0, 0, TGNumberFormat::kNESRealTwo, TGNumberFormat::kNEANonNegative); vfInput2->AddFrame(numDCOffset, layoutHints);
|
||||||
numDCOffset->Resize(width, 20);
|
numDCOffset->Resize(width, 20);
|
||||||
|
numDCOffset->SetLimits(TGNumberFormat::kNELLimitMinMax, 0, 100);
|
||||||
numDCOffset->Connect("Modified()", "ChannelSettingPHA", this, "SetDCOffset()");
|
numDCOffset->Connect("Modified()", "ChannelSettingPHA", this, "SetDCOffset()");
|
||||||
|
|
||||||
///const uint32_t ShapedTriggerWidth = 0x1084; /// R/W not sure
|
///const uint32_t ShapedTriggerWidth = 0x1084; /// R/W not sure
|
||||||
|
@ -504,7 +505,7 @@ void ChannelSettingPHA::ChangeCh(){
|
||||||
numEventAgg->SetNumber( digi[boardID]->GetSettingFromMemory(Register::DPP::NumberEventsPerAggregate_G, ch), false);
|
numEventAgg->SetNumber( digi[boardID]->GetSettingFromMemory(Register::DPP::NumberEventsPerAggregate_G, ch), false);
|
||||||
|
|
||||||
uint32_t temp = digi[boardID]->GetSettingFromMemory(Register::DPP::ChannelDCOffset, ch);
|
uint32_t temp = digi[boardID]->GetSettingFromMemory(Register::DPP::ChannelDCOffset, ch);
|
||||||
numDCOffset->SetNumber( 1.0 - temp * 1.0/0xFFFF , false);
|
numDCOffset->SetNumber( 100.0 - temp * 100.0/0xFFFF , false);
|
||||||
|
|
||||||
eTemp->SetText(Form("%d C", digi[boardID]->GetSettingFromMemory(Register::DPP::ChannelADCTemperature_R, ch)), false);
|
eTemp->SetText(Form("%d C", digi[boardID]->GetSettingFromMemory(Register::DPP::ChannelADCTemperature_R, ch)), false);
|
||||||
|
|
||||||
|
@ -708,9 +709,9 @@ void ChannelSettingPHA::SetDCOffset(){
|
||||||
short boardID = boardIDEntry->GetNumber();
|
short boardID = boardIDEntry->GetNumber();
|
||||||
short ch = chIDEntry->GetNumber();
|
short ch = chIDEntry->GetNumber();
|
||||||
double temp = numDCOffset->GetNumber();
|
double temp = numDCOffset->GetNumber();
|
||||||
uint32_t bit = uint32_t((1.0 - temp) * 0xFFFF);
|
uint16_t bit = uint16_t((1.0 - temp/100.) * 0xFFFF);
|
||||||
printf("%.2f = 0x%x \n", temp, bit);
|
printf("%.2f = 0x%x \n", temp, bit);
|
||||||
if( digi != NULL ) digi[boardID]->WriteRegister(Register::DPP::ChannelDCOffset, bit , ch);
|
if( digi != NULL ) digi[boardID]->WriteRegister(Register::DPP::ChannelDCOffset, (bit & 0xFFFF) , ch);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChannelSettingPHA::SetTriggerSmoothing(){
|
void ChannelSettingPHA::SetTriggerSmoothing(){
|
||||||
|
|
51
test.cpp
51
test.cpp
|
@ -87,43 +87,62 @@ int main(int argc, char* argv[]){
|
||||||
dig->LoadSettingBinary("setting_323.bin");
|
dig->LoadSettingBinary("setting_323.bin");
|
||||||
|
|
||||||
//dig->ProgramPHABoard();
|
//dig->ProgramPHABoard();
|
||||||
|
//dig->OpenSettingBinary("setting_323.bin");
|
||||||
|
//dig->ReadAllSettingsFromBoard();
|
||||||
|
|
||||||
//dig->PrintSettingFromMemory();
|
//dig->PrintSettingFromMemory();
|
||||||
|
|
||||||
|
dig->WriteRegister(Register::DPP::SoftwareClear_W, 1);
|
||||||
|
|
||||||
///dig->SaveSettingAsText("haha.txt");
|
///dig->SaveSettingAsText("haha.txt");
|
||||||
|
|
||||||
|
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++){
|
for( int i = 0; i < dig->GetNChannel(); i++){
|
||||||
dig->WriteRegister(Register::DPP::NumberEventsPerAggregate_G, 2, i);
|
dig->WriteRegister(Register::DPP::NumberEventsPerAggregate_G, Eg, i);
|
||||||
dig->WriteRegister(Register::DPP::RecordLength_G, 200, i);
|
dig->WriteRegister(Register::DPP::RecordLength_G, RL, i);
|
||||||
}
|
}
|
||||||
dig->WriteRegister(Register::DPP::MaxAggregatePerBlockTransfer, 5, 0);
|
dig->WriteRegister(Register::DPP::MaxAggregatePerBlockTransfer, B, 0);
|
||||||
dig->WriteRegister(Register::DPP::BoardConfiguration, 0x0F8115); /// has Extra2
|
dig->WriteRegister(Register::DPP::BoardConfiguration, 0x0F8115); /// has Extra2
|
||||||
//dig->WriteRegister(Register::DPP::BoardConfiguration, 0x0D8115); /// no Extra2
|
//dig->WriteRegister(Register::DPP::BoardConfiguration, 0x0D8115); /// no Extra2
|
||||||
|
|
||||||
|
|
||||||
unsigned int bSize = dig->CalByteForBuffer();
|
unsigned int bSize = dig->CalByteForBuffer();
|
||||||
printf(" Buffer Size : %8u byte = %.2f MB \n", bSize, bSize/1024./1024.);
|
|
||||||
|
//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);
|
||||||
|
|
||||||
usleep(1e6);
|
usleep(1e6);
|
||||||
|
|
||||||
|
///using CAEN method
|
||||||
char * buffer = NULL;
|
char * buffer = NULL;
|
||||||
uint32_t size;
|
uint32_t size;
|
||||||
CAEN_DGTZ_MallocReadoutBuffer(dig->GetHandle(), (char **)& buffer, &size);
|
CAEN_DGTZ_MallocReadoutBuffer(dig->GetHandle(), (char **)& buffer, &size);
|
||||||
|
|
||||||
printf("CAEN calculated Buffer Size : %8u byte = %.2f MB \n", size, size/1024./1024.);
|
printf("CAEN calculated Buffer Size : %8u byte = %.2f MB \n", size, size/1024./1024.);
|
||||||
|
|
||||||
printf(" diff : %8u byte \n", size > bSize ? size - bSize : bSize - size);
|
printf(" diff : %8u byte \n", size > bSize ? size - bSize : bSize - size);
|
||||||
|
|
||||||
///Block
|
|
||||||
/// 1 -> 128
|
|
||||||
/// 2 -> 240
|
|
||||||
/// 3 -> 352
|
|
||||||
/// 4 -> 464
|
|
||||||
/// 5 -> 576
|
|
||||||
|
|
||||||
delete buffer;
|
delete buffer;
|
||||||
|
|
||||||
//delete dig;
|
|
||||||
|
dig->StartACQ();
|
||||||
|
|
||||||
|
for( int i = 0; i < 5; i++){
|
||||||
|
usleep(1000000);
|
||||||
|
dig->ReadData();
|
||||||
|
printf("------------------- %d\n", i);
|
||||||
|
dig->GetData()->DecodeBuffer(false,2);
|
||||||
|
dig->GetData()->PrintStat();
|
||||||
|
}
|
||||||
|
|
||||||
|
dig->StopACQ();
|
||||||
|
|
||||||
|
|
||||||
/**///##################### test with 2 digitizers
|
/**///##################### test with 2 digitizers
|
||||||
|
|
||||||
|
|
|
@ -175,7 +175,7 @@ int main(int argc, char* argv[]){
|
||||||
int handle;
|
int handle;
|
||||||
|
|
||||||
printf("======== open board\n");
|
printf("======== open board\n");
|
||||||
int ret = CAEN_DGTZ_OpenDigitizer(CAEN_DGTZ_OpticalLink, 0, 0, 0, &handle);
|
int ret = CAEN_DGTZ_OpenDigitizer(CAEN_DGTZ_OpticalLink, 1, 0, 0, &handle);
|
||||||
|
|
||||||
CAEN_DGTZ_BoardInfo_t BoardInfo;
|
CAEN_DGTZ_BoardInfo_t BoardInfo;
|
||||||
ret = (int) CAEN_DGTZ_GetInfo(handle, &BoardInfo);
|
ret = (int) CAEN_DGTZ_GetInfo(handle, &BoardInfo);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user