added programSetting.h/cpp, added bufferSize calculation, not tested
This commit is contained in:
parent
029177cd9b
commit
d6a29e1b8f
25
ClassData.h
25
ClassData.h
|
@ -30,6 +30,7 @@ class Data{
|
||||||
double TriggerRate[MaxNChannels]; /// Hz
|
double TriggerRate[MaxNChannels]; /// Hz
|
||||||
unsigned long TotNumEvents[MaxNChannels];
|
unsigned long TotNumEvents[MaxNChannels];
|
||||||
unsigned long long Timestamp[MaxNChannels][MaxNData];
|
unsigned long long Timestamp[MaxNChannels][MaxNData];
|
||||||
|
unsigned short fineTime[MaxNChannels][MaxNData]; /// 10 bits, in unit of ch2ns / 1000 = ps
|
||||||
unsigned short Energy[MaxNChannels][MaxNData];
|
unsigned short Energy[MaxNChannels][MaxNData];
|
||||||
unsigned short Energy2[MaxNChannels][MaxNData]; /// in PSD, Energy = Qshort, Energy2 = Qlong
|
unsigned short Energy2[MaxNChannels][MaxNData]; /// in PSD, Energy = Qshort, Energy2 = Qlong
|
||||||
|
|
||||||
|
@ -46,6 +47,7 @@ class Data{
|
||||||
~Data();
|
~Data();
|
||||||
|
|
||||||
void AllocateMemory();
|
void AllocateMemory();
|
||||||
|
void AllocateMemory(unsigned long size);
|
||||||
|
|
||||||
void SetSaveWaveToMemory(bool OnOff) { this->SaveWaveToMemory = OnOff; }
|
void SetSaveWaveToMemory(bool OnOff) { this->SaveWaveToMemory = OnOff; }
|
||||||
|
|
||||||
|
@ -98,15 +100,15 @@ inline Data::~Data(){
|
||||||
delete buffer;
|
delete buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void Data::AllocateMemory(){
|
inline void Data::AllocateMemory(unsigned long size){
|
||||||
|
|
||||||
delete buffer;
|
delete buffer;
|
||||||
//TODO calculate Suitable buffer size
|
BufferSize = size;
|
||||||
BufferSize = 10* 1024* 1024; /// 10M byte
|
|
||||||
buffer = (char *) malloc( BufferSize);
|
buffer = (char *) malloc( BufferSize);
|
||||||
printf("Allocated %d byte for buffer \n", BufferSize);
|
printf("Allocated %d byte for buffer \n", BufferSize);
|
||||||
///for( int i = 0 ; i < MaxNChannels ; i++ ) Events[i] = (CAEN_DGTZ_DPP_PHA_Event_t *) malloc( BufferSize);
|
}
|
||||||
///printf("Allocated %d byte for Events for each channel \n", BufferSize);
|
|
||||||
|
inline void Data::AllocateMemory(){
|
||||||
|
AllocateMemory( 10 * 1024 * 1024 ); /// 10 M Byte
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void Data::ClearTriggerRate(){ for( int i = 0 ; i < MaxNChannels; i++) TriggerRate[i] = 0.0; }
|
inline void Data::ClearTriggerRate(){ for( int i = 0 ; i < MaxNChannels; i++) TriggerRate[i] = 0.0; }
|
||||||
|
@ -121,6 +123,7 @@ inline void Data::ClearData(){
|
||||||
///TriggerRate[i] = 0.0;
|
///TriggerRate[i] = 0.0;
|
||||||
for( int j = 0; j < MaxNData; j++){
|
for( int j = 0; j < MaxNData; j++){
|
||||||
Timestamp[i][j] = 0;
|
Timestamp[i][j] = 0;
|
||||||
|
fineTime[i][j] = 0;
|
||||||
Energy[i][j] = 0;
|
Energy[i][j] = 0;
|
||||||
Energy2[i][j] = 0;
|
Energy2[i][j] = 0;
|
||||||
Waveform1[i][j].clear();
|
Waveform1[i][j].clear();
|
||||||
|
@ -400,9 +403,9 @@ inline int Data::DecodePHADualChannelBlock(unsigned int ChannelMask, bool fastDe
|
||||||
nw = nw +1 ; word = ReadBuffer(nw, verbose);
|
nw = nw +1 ; word = ReadBuffer(nw, verbose);
|
||||||
unsigned int extra2 = word;
|
unsigned int extra2 = word;
|
||||||
unsigned long long extTimeStamp = 0;
|
unsigned long long extTimeStamp = 0;
|
||||||
if( extra2Option == 0 || extra2Option == 2 ) extTimeStamp = (extra2 >> 15);
|
if( extra2Option == 0 || extra2Option == 2 ) extTimeStamp = (extra2 >> 16);
|
||||||
|
|
||||||
unsigned long long timeStamp = (extTimeStamp << 30) ;
|
unsigned long long timeStamp = (extTimeStamp << 31) ;
|
||||||
timeStamp = timeStamp + timeStamp0;
|
timeStamp = timeStamp + timeStamp0;
|
||||||
|
|
||||||
if( verbose >= 2) printf("TimeStamp : %llu\n", timeStamp);
|
if( verbose >= 2) printf("TimeStamp : %llu\n", timeStamp);
|
||||||
|
@ -432,7 +435,7 @@ inline int Data::DecodePHADualChannelBlock(unsigned int ChannelMask, bool fastDe
|
||||||
if( rollOver == 0 ) {
|
if( rollOver == 0 ) {
|
||||||
Energy[channel][NumEvents[channel]] = energy;
|
Energy[channel][NumEvents[channel]] = energy;
|
||||||
Timestamp[channel][NumEvents[channel]] = timeStamp;
|
Timestamp[channel][NumEvents[channel]] = timeStamp;
|
||||||
|
if(extra2Option == 0 || extra2Option == 2 ) fineTime[channel][NumEvents[channel]] = (extra2 & 0x07FF );
|
||||||
NumEvents[channel] ++;
|
NumEvents[channel] ++;
|
||||||
TotNumEvents[channel] ++;
|
TotNumEvents[channel] ++;
|
||||||
}
|
}
|
||||||
|
@ -591,9 +594,9 @@ inline int Data::DecodePSDDualChannelBlock(unsigned int ChannelMask, bool fastDe
|
||||||
nw = nw +1 ; word = ReadBuffer(nw, verbose);
|
nw = nw +1 ; word = ReadBuffer(nw, verbose);
|
||||||
unsigned int extra = word;
|
unsigned int extra = word;
|
||||||
unsigned long long extTimeStamp = 0;
|
unsigned long long extTimeStamp = 0;
|
||||||
if( extraOption == 0 || extraOption == 2 ) extTimeStamp = (extra >> 15);
|
if( extraOption == 0 || extraOption == 2 ) extTimeStamp = (extra >> 16);
|
||||||
|
|
||||||
unsigned long long timeStamp = (extTimeStamp << 30) ;
|
unsigned long long timeStamp = (extTimeStamp << 31) ;
|
||||||
timeStamp = timeStamp + timeStamp0;
|
timeStamp = timeStamp + timeStamp0;
|
||||||
|
|
||||||
nw = nw +1 ; word = ReadBuffer(nw, verbose);
|
nw = nw +1 ; word = ReadBuffer(nw, verbose);
|
||||||
|
|
|
@ -20,7 +20,7 @@ void Digitizer::Initalization(){
|
||||||
portID = -1;
|
portID = -1;
|
||||||
boardID = -1;
|
boardID = -1;
|
||||||
handle = -1;
|
handle = -1;
|
||||||
NChannel = 0;
|
NChannel = 16;
|
||||||
ADCbits = 1;
|
ADCbits = 1;
|
||||||
DPPType = 0;
|
DPPType = 0;
|
||||||
DPPTypeStr = "";
|
DPPTypeStr = "";
|
||||||
|
@ -58,7 +58,7 @@ void Digitizer::Reset(){
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Digitizer::PrintBoard(){
|
void Digitizer::PrintBoard (){
|
||||||
printf("Connected to Model %s with handle %d using %s\n", BoardInfo.ModelName, handle, LinkType == CAEN_DGTZ_USB ? "USB" : "Optical Link");
|
printf("Connected to Model %s with handle %d using %s\n", BoardInfo.ModelName, handle, LinkType == CAEN_DGTZ_USB ? "USB" : "Optical Link");
|
||||||
printf("Sampling rate : %.0f MHz = %.1f ns \n", 1000/ch2ns, ch2ns);
|
printf("Sampling rate : %.0f MHz = %.1f ns \n", 1000/ch2ns, ch2ns);
|
||||||
printf("Number of Channels : %d = 0x%X\n", NChannel, channelMask);
|
printf("Number of Channels : %d = 0x%X\n", NChannel, channelMask);
|
||||||
|
@ -313,9 +313,9 @@ int Digitizer::ProgramPHABoard(){
|
||||||
ret |= CAEN_DGTZ_WriteRegister(handle, (uint32_t)(Register::DPP::PreTrigger) + 0x7000 , 124 );
|
ret |= CAEN_DGTZ_WriteRegister(handle, (uint32_t)(Register::DPP::PreTrigger) + 0x7000 , 124 );
|
||||||
ret |= CAEN_DGTZ_WriteRegister(handle, (uint32_t)(Register::DPP::InputDynamicRange) + 0x7000 , 0x0 );
|
ret |= CAEN_DGTZ_WriteRegister(handle, (uint32_t)(Register::DPP::InputDynamicRange) + 0x7000 , 0x0 );
|
||||||
|
|
||||||
ret |= CAEN_DGTZ_WriteRegister(handle, (int32_t)(Register::DPP::NumberEventsPerAggregate_G) + 0x7000, 511);
|
ret |= CAEN_DGTZ_WriteRegister(handle, (int32_t)(Register::DPP::NumberEventsPerAggregate_G) + 0x7000, 10);
|
||||||
ret |= CAEN_DGTZ_WriteRegister(handle, (int32_t)(Register::DPP::AggregateOrganization), 0);
|
ret |= CAEN_DGTZ_WriteRegister(handle, (int32_t)(Register::DPP::AggregateOrganization), 0);
|
||||||
ret |= CAEN_DGTZ_WriteRegister(handle, (int32_t)(Register::DPP::MaxAggregatePerBlockTransfer), 40);
|
ret |= CAEN_DGTZ_WriteRegister(handle, (int32_t)(Register::DPP::MaxAggregatePerBlockTransfer), 200);
|
||||||
ret |= CAEN_DGTZ_WriteRegister(handle, (int32_t)(Register::DPP::DPPAlgorithmControl) + 0x7000, 0xe30200f);
|
ret |= CAEN_DGTZ_WriteRegister(handle, (int32_t)(Register::DPP::DPPAlgorithmControl) + 0x7000, 0xe30200f);
|
||||||
|
|
||||||
if( ret != 0 ) { printf("==== set channels error.\n"); return 0;}
|
if( ret != 0 ) { printf("==== set channels error.\n"); return 0;}
|
||||||
|
@ -350,16 +350,47 @@ void Digitizer::StopACQ(){
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int Digitizer::CalByteForBuffer(){
|
unsigned int Digitizer::CalByteForBuffer(){
|
||||||
|
unsigned int numAggBLT;
|
||||||
|
unsigned int chMask ;
|
||||||
|
unsigned int boardCfg ;
|
||||||
|
unsigned int eventAgg[NChannel/2];
|
||||||
|
unsigned int recordLength[NChannel/2];
|
||||||
|
|
||||||
//TODO
|
if( isConnected ){
|
||||||
unsigned int numAggBLT = ReadRegister(Register::DPP::MaxAggregatePerBlockTransfer);
|
numAggBLT = ReadRegister(Register::DPP::MaxAggregatePerBlockTransfer, 0, false);
|
||||||
|
chMask = ReadRegister(Register::DPP::ChannelEnableMask, 0, false);
|
||||||
|
boardCfg = ReadRegister(Register::DPP::BoardConfiguration, 0, false);
|
||||||
|
|
||||||
|
for( int pCh = 0; pCh < NChannel/2; pCh++){
|
||||||
|
eventAgg[pCh] = ReadRegister(Register::DPP::NumberEventsPerAggregate_G, pCh * 2 , false);
|
||||||
|
recordLength[pCh] = ReadRegister(Register::DPP::RecordLength_G, pCh * 2 , false);
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
numAggBLT = GetSettingFromMemory(Register::DPP::MaxAggregatePerBlockTransfer);
|
||||||
|
chMask = GetSettingFromMemory(Register::DPP::ChannelEnableMask);
|
||||||
|
boardCfg = GetSettingFromMemory(Register::DPP::BoardConfiguration);
|
||||||
|
for( int pCh = 0; pCh < NChannel/2; pCh++){
|
||||||
|
eventAgg[pCh] = GetSettingFromMemory(Register::DPP::NumberEventsPerAggregate_G, pCh * 2 );
|
||||||
|
recordLength[pCh] = GetSettingFromMemory(Register::DPP::RecordLength_G, pCh * 2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Channel Mask
|
//printf(" Channel Mask : %04X \n", chMask);
|
||||||
/// is takeing waveForm
|
//printf("Max number of Agg per Readout : %u \n", numAggBLT);
|
||||||
/// Record Length
|
//printf(" is Extra2 enabed : %u \n", ((boardCfg >> 17) & 0x1) );
|
||||||
|
//
|
||||||
|
//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]);
|
||||||
|
//}
|
||||||
|
|
||||||
return 0;
|
unsigned int bufferSize = 4; /// Board Agg. header
|
||||||
|
/// Cal size for each dual channel aggregation
|
||||||
|
for( int pCh = 0; pCh < NChannel/2 ; pCh++){
|
||||||
|
if( (chMask & ( 3 << (2 * pCh) )) == 0 ) continue;
|
||||||
|
bufferSize += ( 2 + ((boardCfg >> 17) & 0x1) + recordLength[pCh]*4 ) * eventAgg[pCh] ;
|
||||||
|
}
|
||||||
|
|
||||||
|
return bufferSize * 4 * numAggBLT; /// 1 word = 4 byte;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Digitizer::ReadData(){
|
void Digitizer::ReadData(){
|
||||||
|
@ -383,7 +414,7 @@ void Digitizer::ReadData(){
|
||||||
//===========================================================
|
//===========================================================
|
||||||
//===========================================================
|
//===========================================================
|
||||||
//===========================================================
|
//===========================================================
|
||||||
void Digitizer::WriteRegister(Reg registerAddress, uint32_t value, int ch, bool isSave2MemAndFile){
|
void Digitizer::WriteRegister (Reg registerAddress, uint32_t value, int ch, bool isSave2MemAndFile){
|
||||||
if( !isConnected ) return;
|
if( !isConnected ) return;
|
||||||
//printf("0x%X, ch:%02d, 0x%X=%u\n", registerAddress, ch, value, value);
|
//printf("0x%X, ch:%02d, 0x%X=%u\n", registerAddress, ch, value, value);
|
||||||
|
|
||||||
|
@ -396,7 +427,7 @@ void Digitizer::WriteRegister(Reg registerAddress, uint32_t value, int ch, bool
|
||||||
ErrorMsg("WriteRegister:" + std::to_string(registerAddress));
|
ErrorMsg("WriteRegister:" + std::to_string(registerAddress));
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t Digitizer::ReadRegister(Reg registerAddress, unsigned short ch, bool isSave2MemAndFile, string str ){
|
uint32_t Digitizer::ReadRegister(Reg registerAddress, unsigned short ch, bool isSave2MemAndFile, std::string str ){
|
||||||
if( !isConnected ) return 0;
|
if( !isConnected ) return 0;
|
||||||
|
|
||||||
uint32_t data[1];
|
uint32_t data[1];
|
||||||
|
@ -410,7 +441,6 @@ uint32_t Digitizer::ReadRegister(Reg registerAddress, unsigned short ch, bool is
|
||||||
if( str != "" ) printf("%s : 0x%04X(0x%04X) is 0x%08X \n", str.c_str(),
|
if( str != "" ) printf("%s : 0x%04X(0x%04X) is 0x%08X \n", str.c_str(),
|
||||||
registerAddress.ActualAddress(ch), registerAddress.GetAddress(), data[0]);
|
registerAddress.ActualAddress(ch), registerAddress.GetAddress(), data[0]);
|
||||||
return data[0];
|
return data[0];
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Digitizer::PrintACQStatue(){
|
void Digitizer::PrintACQStatue(){
|
||||||
|
@ -420,7 +450,7 @@ void Digitizer::PrintACQStatue(){
|
||||||
printf("=================== Print ACQ status \n");
|
printf("=================== Print ACQ status \n");
|
||||||
printf(" 32 28 24 20 16 12 8 4 0\n");
|
printf(" 32 28 24 20 16 12 8 4 0\n");
|
||||||
printf(" | | | | | | | | |\n");
|
printf(" | | | | | | | | |\n");
|
||||||
cout <<" 0b" << bitset<32>(status) << endl;
|
std::cout <<" 0b" << std::bitset<32>(status) << std::endl;
|
||||||
printf(" Acq state (0x%1X): %s \n", (status >> 2) & 0x1, ((status >> 2) & 0x1) == 0? "stopped" : "running");
|
printf(" Acq state (0x%1X): %s \n", (status >> 2) & 0x1, ((status >> 2) & 0x1) == 0? "stopped" : "running");
|
||||||
printf(" Event Ready (0x%1X): %s \n", (status >> 3) & 0x1, ((status >> 3) & 0x1) == 0? "no event in buffer" : "event in buffer");
|
printf(" Event Ready (0x%1X): %s \n", (status >> 3) & 0x1, ((status >> 3) & 0x1) == 0? "no event in buffer" : "event in buffer");
|
||||||
printf(" Event Full (0x%1X): %s \n", (status >> 4) & 0x1, ((status >> 4) & 0x1) == 0? "not full" : "full");
|
printf(" Event Full (0x%1X): %s \n", (status >> 4) & 0x1, ((status >> 4) & 0x1) == 0? "not full" : "full");
|
||||||
|
@ -429,11 +459,9 @@ void Digitizer::PrintACQStatue(){
|
||||||
printf(" Ch shutDown (0x%1X): %s \n", (status >> 19) & 0x1, ((status >> 19) & 0x1) == 0? "Channels are on" : "channels are shutdown");
|
printf(" Ch shutDown (0x%1X): %s \n", (status >> 19) & 0x1, ((status >> 19) & 0x1) == 0? "Channels are on" : "channels are shutdown");
|
||||||
printf(" TRG-IN 0x%1X \n", (status >> 16) & 0x1);
|
printf(" TRG-IN 0x%1X \n", (status >> 16) & 0x1);
|
||||||
printf(" Ch temp state 0x%04X \n", (status >> 20) & 0xF);
|
printf(" Ch temp state 0x%04X \n", (status >> 20) & 0xF);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//========================================== setting file IO
|
//========================================== setting file IO
|
||||||
|
|
||||||
Reg Digitizer::FindRegister(uint32_t address){
|
Reg Digitizer::FindRegister(uint32_t address){
|
||||||
|
|
||||||
Reg tempReg;
|
Reg tempReg;
|
||||||
|
@ -513,13 +541,13 @@ void Digitizer::ProgramSettingsToBoard(){
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Digitizer::SetSettingToMemory(Reg registerAddress, unsigned int value, int ch ){
|
void Digitizer::SetSettingToMemory(Reg registerAddress, unsigned int value, unsigned short ch ){
|
||||||
unsigned short index = registerAddress.Index(ch);
|
unsigned short index = registerAddress.Index(ch);
|
||||||
if( index > SETTINGSIZE ) return;
|
if( index > SETTINGSIZE ) return;
|
||||||
setting[index] = value;
|
setting[index] = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int Digitizer::GetSettingFromMemory(Reg registerAddress, int ch ){
|
unsigned int Digitizer::GetSettingFromMemory(Reg registerAddress, unsigned short ch ){
|
||||||
unsigned short index = registerAddress.Index(ch);
|
unsigned short index = registerAddress.Index(ch);
|
||||||
if( index > SETTINGSIZE ) return 0xFFFF;
|
if( index > SETTINGSIZE ) return 0xFFFF;
|
||||||
return setting[index] ;
|
return setting[index] ;
|
||||||
|
@ -529,7 +557,7 @@ void Digitizer::PrintSettingFromMemory(){
|
||||||
for( int i = 0; i < SETTINGSIZE; i++) printf("%4d | 0x%04X |0x%08X = %u \n", i, i*4, setting[i], setting[i]);
|
for( int i = 0; i < SETTINGSIZE; i++) printf("%4d | 0x%04X |0x%08X = %u \n", i, i*4, setting[i], setting[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Digitizer::OpenSettingBinary(string fileName){
|
void Digitizer::OpenSettingBinary(std::string fileName){
|
||||||
if( settingFile != NULL ) delete settingFile;
|
if( settingFile != NULL ) delete settingFile;
|
||||||
|
|
||||||
settingFile = fopen(fileName.c_str(), "r+");
|
settingFile = fopen(fileName.c_str(), "r+");
|
||||||
|
@ -555,7 +583,7 @@ void Digitizer::OpenSettingBinary(string fileName){
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Digitizer::LoadSettingBinary(string fileName){
|
void Digitizer::LoadSettingBinary(std::string fileName){
|
||||||
|
|
||||||
settingFile = fopen(fileName.c_str(), "r+");
|
settingFile = fopen(fileName.c_str(), "r+");
|
||||||
|
|
||||||
|
@ -572,11 +600,10 @@ void Digitizer::LoadSettingBinary(string fileName){
|
||||||
size_t dummy = fread( setting, SETTINGSIZE * sizeof(unsigned int), 1, settingFile);
|
size_t dummy = fread( setting, SETTINGSIZE * sizeof(unsigned int), 1, settingFile);
|
||||||
|
|
||||||
ProgramSettingsToBoard();
|
ProgramSettingsToBoard();
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int Digitizer::ReadSettingFromFile(Reg registerAddress, int ch){
|
unsigned int Digitizer::ReadSettingFromFile(Reg registerAddress, unsigned short ch){
|
||||||
if ( !settingFileExist ) return -1;
|
if ( !settingFileExist ) return -1;
|
||||||
|
|
||||||
unsigned short index = registerAddress.Index(ch);
|
unsigned short index = registerAddress.Index(ch);
|
||||||
|
@ -593,10 +620,10 @@ unsigned int Digitizer::ReadSettingFromFile(Reg registerAddress, int ch){
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Digitizer::SaveSettingToFile(Reg registerAddress, unsigned int value, int ch){
|
void Digitizer::SaveSettingToFile(Reg registerAddress, unsigned int value, unsigned short ch){
|
||||||
if ( !settingFileExist ) return ;
|
if ( !settingFileExist ) return ;
|
||||||
|
|
||||||
unsigned short index = registerAddress,Index(ch);
|
unsigned short index = registerAddress.Index(ch);
|
||||||
setting[index] = value;
|
setting[index] = value;
|
||||||
|
|
||||||
settingFile = fopen (settingFileName.c_str(),"r+");
|
settingFile = fopen (settingFileName.c_str(),"r+");
|
||||||
|
@ -608,7 +635,7 @@ void Digitizer::SaveSettingToFile(Reg registerAddress, unsigned int value, int c
|
||||||
fclose (settingFile);
|
fclose (settingFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Digitizer::SaveSettingAsText(string fileName){
|
void Digitizer::SaveSettingAsText(std::string fileName){
|
||||||
|
|
||||||
FILE * txtFile = fopen(fileName.c_str(), "w+");
|
FILE * txtFile = fopen(fileName.c_str(), "w+");
|
||||||
|
|
||||||
|
@ -651,7 +678,7 @@ void Digitizer::SaveSettingAsText(string fileName){
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Digitizer::ErrorMsg(string header){
|
void Digitizer::ErrorMsg(std::string header){
|
||||||
switch (ret){
|
switch (ret){
|
||||||
///case CAEN_DGTZ_Success : /** 0 */ printf("%s | Operation completed successfully.\n", header.c_str()); break;
|
///case CAEN_DGTZ_Success : /** 0 */ printf("%s | Operation completed successfully.\n", header.c_str()); break;
|
||||||
case CAEN_DGTZ_CommError : /** -1 */ printf("%s | Communication Error.\n", header.c_str()); break;
|
case CAEN_DGTZ_CommError : /** -1 */ printf("%s | Communication Error.\n", header.c_str()); break;
|
||||||
|
|
|
@ -16,8 +16,6 @@
|
||||||
#include "ClassData.h"
|
#include "ClassData.h"
|
||||||
#include "RegisterAddress.h"
|
#include "RegisterAddress.h"
|
||||||
|
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
//################################################################
|
//################################################################
|
||||||
class Digitizer{
|
class Digitizer{
|
||||||
|
|
||||||
|
@ -50,14 +48,14 @@ class Digitizer{
|
||||||
bool AcqRun; /// true when digitizer is taking data
|
bool AcqRun; /// true when digitizer is taking data
|
||||||
|
|
||||||
/// ------- setting
|
/// ------- setting
|
||||||
string settingFileName; ///
|
std::string settingFileName; ///
|
||||||
FILE * settingFile; ///
|
FILE * settingFile; ///
|
||||||
bool settingFileExist; ///
|
bool settingFileExist; ///
|
||||||
bool isSettingFilledinMemeory; /// false for disabled ReadAllSettingFromBoard()
|
bool isSettingFilledinMemeory; /// false for disabled ReadAllSettingFromBoard()
|
||||||
unsigned int setting[SETTINGSIZE]; /// Setting, 4bytes x 2048 = 8192 bytes
|
unsigned int setting[SETTINGSIZE]; /// Setting, 4bytes x 2048 = 8192 bytes
|
||||||
|
|
||||||
///---------- protected functions
|
///---------- protected functions
|
||||||
void ErrorMsg(string header = "");
|
void ErrorMsg(std::string header = "");
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Digitizer(); /// no digitizer open
|
Digitizer(); /// no digitizer open
|
||||||
|
@ -72,44 +70,44 @@ class Digitizer{
|
||||||
void Initalization();
|
void Initalization();
|
||||||
void Reset();
|
void Reset();
|
||||||
|
|
||||||
void PrintBoard();
|
void PrintBoard() ;
|
||||||
virtual int ProgramBoard(); /// program a generic board, no program channel
|
virtual int ProgramBoard() ; /// program a generic board, no program channel
|
||||||
int ProgramPHABoard(); /// program a default PHA board
|
int ProgramPHABoard() ; /// program a default PHA board
|
||||||
|
|
||||||
///================ ACQ control
|
///================ ACQ control
|
||||||
void StopACQ();
|
void StopACQ();
|
||||||
void StartACQ();
|
void StartACQ();
|
||||||
void ReadData();
|
void ReadData();
|
||||||
bool IsRunning() {return AcqRun;}
|
bool IsRunning() const {return AcqRun;}
|
||||||
Data * GetData(){ return data;}
|
Data * GetData() const {return data;}
|
||||||
void PrintACQStatue();
|
void PrintACQStatue();
|
||||||
|
|
||||||
unsigned int CalByteForBuffer();
|
unsigned int CalByteForBuffer();
|
||||||
|
|
||||||
///=================Settings
|
///=================Settings
|
||||||
/// write value to digitizer, memory, and settingFile (if exist)
|
/// write value to digitizer, memory, and settingFile (if exist)
|
||||||
void WriteRegister(Reg registerAddress, uint32_t value, int ch = -1, bool isSave2MemAndFile = true);
|
void WriteRegister (Reg registerAddress, uint32_t value, int ch = -1, bool isSave2MemAndFile = true);
|
||||||
/// read value from digitizer and memory, and save to memory, and settingFile(if exist),
|
/// read value from digitizer and memory, and save to memory, and settingFile(if exist),
|
||||||
/// ch must be >= 0,
|
/// ch must be >= 0,
|
||||||
/// for board setting, ignore ch
|
/// for board setting, ignore ch
|
||||||
uint32_t ReadRegister(Reg registerAddress, unsigned short ch = 0, bool isSave2MemAndFile = true, string str = "" );
|
uint32_t ReadRegister (Reg registerAddress, unsigned short ch = 0, bool isSave2MemAndFile = true, std::string str = "" );
|
||||||
uint32_t PrintRegister(uint32_t address, std::string msg);
|
uint32_t PrintRegister(uint32_t address, std::string msg);
|
||||||
|
|
||||||
///================ Get Settings
|
///================ Get Settings
|
||||||
std::string GetModelName() {return BoardInfo.ModelName;}
|
std::string GetModelName() const {return BoardInfo.ModelName;}
|
||||||
int GetSerialNumber() {return BoardInfo.SerialNumber;}
|
int GetSerialNumber() const {return BoardInfo.SerialNumber;}
|
||||||
int GetChannelMask() {return channelMask;}
|
int GetChannelMask() const {return channelMask;}
|
||||||
bool GetChannelOnOff(unsigned ch) {return (channelMask & ( 1 << ch) );}
|
bool GetChannelOnOff(unsigned ch) const {return (channelMask & ( 1 << ch) );}
|
||||||
float GetCh2ns() {return ch2ns;}
|
float GetCh2ns() const {return ch2ns;}
|
||||||
int GetNChannel() {return NChannel;}
|
int GetNChannel() const {return NChannel;}
|
||||||
int GetHandle() {return handle;}
|
int GetHandle() const {return handle;}
|
||||||
bool GetConnectionStatus() {return isConnected;}
|
bool GetConnectionStatus() const {return isConnected;}
|
||||||
int GetDPPType() {return DPPType;}
|
int GetDPPType() const {return DPPType;}
|
||||||
std::string GetDPPTypeString() {return DPPTypeStr;}
|
std::string GetDPPTypeString() const {return DPPTypeStr;}
|
||||||
int GetADCBits() {return BoardInfo.ADC_NBits;}
|
int GetADCBits() const {return BoardInfo.ADC_NBits;}
|
||||||
std::string GetROCVersion() {return BoardInfo.ROC_FirmwareRel;}
|
std::string GetROCVersion() const {return BoardInfo.ROC_FirmwareRel;}
|
||||||
std::string GetAMCVersion() {return BoardInfo.AMC_FirmwareRel;}
|
std::string GetAMCVersion() const {return BoardInfo.AMC_FirmwareRel;}
|
||||||
CAEN_DGTZ_ConnectionType GetLinkType() {return LinkType;}
|
CAEN_DGTZ_ConnectionType GetLinkType() const {return LinkType;}
|
||||||
|
|
||||||
///================ Setting
|
///================ Setting
|
||||||
Reg FindRegister(uint32_t address);
|
Reg FindRegister(uint32_t address);
|
||||||
|
@ -118,18 +116,18 @@ class Digitizer{
|
||||||
void ProgramSettingsToBoard ();
|
void ProgramSettingsToBoard ();
|
||||||
|
|
||||||
/// simply read settings from memory
|
/// simply read settings from memory
|
||||||
void SetSettingToMemory (Reg registerAddress, unsigned int value, int ch = -1);
|
void SetSettingToMemory (Reg registerAddress, unsigned int value, unsigned short ch = -1);
|
||||||
unsigned int GetSettingFromMemory (Reg registerAddress, int ch = -1);
|
unsigned int GetSettingFromMemory (Reg registerAddress, unsigned short ch = -1);
|
||||||
void PrintSettingFromMemory ();
|
void PrintSettingFromMemory ();
|
||||||
unsigned int * GetSetting() {return setting;};
|
unsigned int * GetSetting() {return setting;};
|
||||||
|
|
||||||
/// memory <--> file
|
/// memory <--> file
|
||||||
void SaveSettingAsText (string fileName);
|
void SaveSettingAsText (std::string fileName);
|
||||||
string GetSettingFileName() {return settingFileName;}
|
std::string GetSettingFileName() {return settingFileName;}
|
||||||
void OpenSettingBinary (string fileName); /// Open setting file, if file not exist, call create and save settings, if file exit set the settignFileName but not overwrite
|
void OpenSettingBinary (std::string fileName); /// Open setting file, if file not exist, call create and save settings, if file exit set the settignFileName but not overwrite
|
||||||
void LoadSettingBinary (string fileName); /// load settign file to memory, if digitizer connected, program digitizer
|
void LoadSettingBinary (std::string fileName); /// load settign file to memory, if digitizer connected, program digitizer
|
||||||
void SaveSettingToFile (Reg registerAddress, unsigned int value, int ch = -1);
|
void SaveSettingToFile (Reg registerAddress, unsigned int value, unsigned short ch = 0); /// also save to memory
|
||||||
unsigned int ReadSettingFromFile (Reg registerAddress, int ch = -1); /// read from setting binary
|
unsigned int ReadSettingFromFile (Reg registerAddress, unsigned short ch = 0); /// read from setting binary
|
||||||
|
|
||||||
///=================== Relic methods
|
///=================== Relic methods
|
||||||
///void SetRecordLength (unsigned int ns, int ch = -1); /// when ch == -1, mean set all channels
|
///void SetRecordLength (unsigned int ns, int ch = -1); /// when ch == -1, mean set all channels
|
||||||
|
|
38
FSUDAQ.cpp
38
FSUDAQ.cpp
|
@ -26,15 +26,13 @@ enum MenuIdentifiers{
|
||||||
M_FILE_OPEN,
|
M_FILE_OPEN,
|
||||||
M_EXIT,
|
M_EXIT,
|
||||||
M_LOAD_SETTINGS,
|
M_LOAD_SETTINGS,
|
||||||
M_VIEW_SETTINGS, // TODO
|
|
||||||
M_TRIGGER_SUMMARY,
|
M_TRIGGER_SUMMARY,
|
||||||
M_CH_SETTING_PHA,
|
M_CH_SETTING_PHA,
|
||||||
M_CH_SETTING_PSD,
|
M_CH_SETTING_PSD,
|
||||||
M_REGISTER_SETTING,
|
M_REGISTER_SETTING,
|
||||||
M_BOARD_SETTINGS,
|
M_BOARD_SETTINGS,
|
||||||
M_PROGRAM_SETTINGS,
|
M_PROGRAM_SETTINGS,
|
||||||
M_FINDPEAKS,
|
M_FINDPEAKS
|
||||||
M_SHOW_CHANNELS_RATE
|
|
||||||
};
|
};
|
||||||
|
|
||||||
enum ModeIdentifiers{
|
enum ModeIdentifiers{
|
||||||
|
@ -103,16 +101,15 @@ MainWindow::MainWindow(const TGWindow *p,UInt_t w,UInt_t h) {
|
||||||
fMenuDigitizers->AddEntry("&Channel Settings (PHA)", M_CH_SETTING_PHA);
|
fMenuDigitizers->AddEntry("&Channel Settings (PHA)", M_CH_SETTING_PHA);
|
||||||
fMenuDigitizers->AddEntry("&Channel Settings (PSD)", M_CH_SETTING_PSD);
|
fMenuDigitizers->AddEntry("&Channel Settings (PSD)", M_CH_SETTING_PSD);
|
||||||
fMenuDigitizers->AddEntry("&Register Setting", M_REGISTER_SETTING);
|
fMenuDigitizers->AddEntry("&Register Setting", M_REGISTER_SETTING);
|
||||||
//fMenuDigitizers->AddSeparator();
|
fMenuDigitizers->AddSeparator();
|
||||||
//fMenuDigitizers->AddEntry("&Program Settings", M_PROGRAM_SETTINGS);
|
fMenuDigitizers->AddEntry("&Program Settings", M_PROGRAM_SETTINGS);
|
||||||
fMenuDigitizers->Connect("Activated(Int_t)", "MainWindow", this, "HandleMenu(Int_t)");
|
fMenuDigitizers->Connect("Activated(Int_t)", "MainWindow", this, "HandleMenu(Int_t)");
|
||||||
fMenuBar->AddPopup("&Digitizers", fMenuDigitizers, new TGLayoutHints(kLHintsTop | kLHintsLeft, 0, 4, 0, 0));
|
fMenuBar->AddPopup("&Digitizers", fMenuDigitizers, new TGLayoutHints(kLHintsTop | kLHintsLeft, 0, 4, 0, 0));
|
||||||
|
|
||||||
fMenuDigitizers->DisableEntry( M_REGISTER_SETTING);
|
fMenuDigitizers->DisableEntry( M_REGISTER_SETTING);
|
||||||
|
|
||||||
fMenuUtility = new TGPopupMenu(gClient->GetRoot());
|
fMenuUtility = new TGPopupMenu(gClient->GetRoot());
|
||||||
fMenuUtility->AddEntry("Plot Channels Rate", M_SHOW_CHANNELS_RATE);
|
//fMenuDigitizers->AddSeparator();
|
||||||
fMenuDigitizers->AddSeparator();
|
|
||||||
fMenuUtility->AddEntry("Find &Peaks", M_FINDPEAKS);
|
fMenuUtility->AddEntry("Find &Peaks", M_FINDPEAKS);
|
||||||
fMenuUtility->Connect("Activated(Int_t)", "MainWindow", this, "HandleMenu(Int_t)");
|
fMenuUtility->Connect("Activated(Int_t)", "MainWindow", this, "HandleMenu(Int_t)");
|
||||||
fMenuBar->AddPopup("&Utility", fMenuUtility, new TGLayoutHints(kLHintsTop | kLHintsLeft, 0, 4, 0, 0));
|
fMenuBar->AddPopup("&Utility", fMenuUtility, new TGLayoutHints(kLHintsTop | kLHintsLeft, 0, 4, 0, 0));
|
||||||
|
@ -204,8 +201,8 @@ MainWindow::MainWindow(const TGWindow *p,UInt_t w,UInt_t h) {
|
||||||
/// Map all subwindows of main frame
|
/// Map all subwindows of main frame
|
||||||
fMain->MapSubwindows();
|
fMain->MapSubwindows();
|
||||||
/// Initialize the layout algorithm
|
/// Initialize the layout algorithm
|
||||||
fMain->Resize(fMain->GetDefaultSize());
|
|
||||||
fMain->SetWMPosition(200, 200); //does not work??
|
fMain->SetWMPosition(200, 200); //does not work??
|
||||||
|
fMain->Resize(fMain->GetDefaultSize());
|
||||||
|
|
||||||
/// Map main frame
|
/// Map main frame
|
||||||
fMain->MapWindow();
|
fMain->MapWindow();
|
||||||
|
@ -216,8 +213,10 @@ MainWindow::MainWindow(const TGWindow *p,UInt_t w,UInt_t h) {
|
||||||
|
|
||||||
boardSetting = NULL;
|
boardSetting = NULL;
|
||||||
channelSettingPHA = NULL;
|
channelSettingPHA = NULL;
|
||||||
|
channelSettingPSD = NULL;
|
||||||
registerSetting = NULL;
|
registerSetting = NULL;
|
||||||
///scalarPanel = NULL;
|
triggerSummary = NULL;
|
||||||
|
programSetting = NULL;
|
||||||
|
|
||||||
LogMsg((char*)"Please \"Open Digitizers\" to start.");
|
LogMsg((char*)"Please \"Open Digitizers\" to start.");
|
||||||
|
|
||||||
|
@ -242,17 +241,20 @@ MainWindow::~MainWindow() {
|
||||||
delete fMenuFile;
|
delete fMenuFile;
|
||||||
delete fMenuDigitizers;
|
delete fMenuDigitizers;
|
||||||
delete fMenuUtility;
|
delete fMenuUtility;
|
||||||
|
delete fEcanvas;
|
||||||
|
|
||||||
delete boardIDEntry;
|
delete boardIDEntry;
|
||||||
delete chIDEntry;
|
delete chIDEntry;
|
||||||
|
|
||||||
delete teLog;
|
delete teLog;
|
||||||
//delete tePath;
|
|
||||||
|
|
||||||
delete bOpenDigitizers;
|
delete bOpenDigitizers;
|
||||||
delete bStartRun;
|
delete bStartRun;
|
||||||
delete bStopRun;
|
delete bStopRun;
|
||||||
delete cbMode;
|
delete cbMode;
|
||||||
|
|
||||||
|
delete dataPrefix;
|
||||||
|
delete runIDEntry;
|
||||||
|
|
||||||
delete bPlotSingleTrace;
|
delete bPlotSingleTrace;
|
||||||
delete bFitTrace;
|
delete bFitTrace;
|
||||||
|
@ -262,9 +264,9 @@ MainWindow::~MainWindow() {
|
||||||
delete boardSetting;
|
delete boardSetting;
|
||||||
delete channelSettingPHA;
|
delete channelSettingPHA;
|
||||||
delete channelSettingPSD;
|
delete channelSettingPSD;
|
||||||
|
|
||||||
delete registerSetting;
|
delete registerSetting;
|
||||||
delete triggerSummary;
|
delete triggerSummary;
|
||||||
|
delete programSetting;
|
||||||
|
|
||||||
delete fillHistThread;
|
delete fillHistThread;
|
||||||
|
|
||||||
|
@ -297,7 +299,7 @@ void MainWindow::HandleMenu(Int_t id){
|
||||||
|
|
||||||
///========================= File Open
|
///========================= File Open
|
||||||
case M_FILE_OPEN:{
|
case M_FILE_OPEN:{
|
||||||
|
LogMsg((char *) "Not implemented.");
|
||||||
|
|
||||||
}break;
|
}break;
|
||||||
|
|
||||||
|
@ -342,11 +344,9 @@ void MainWindow::HandleMenu(Int_t id){
|
||||||
|
|
||||||
///========================= Program setting
|
///========================= Program setting
|
||||||
case M_PROGRAM_SETTINGS:{
|
case M_PROGRAM_SETTINGS:{
|
||||||
LogMsg((char*)"[Program settings] Not impelmented");
|
programSetting = new ProgramSetting(gClient->GetRoot());
|
||||||
}break;
|
|
||||||
|
LogMsg((char*) Form("database : %s, name : %s ", ProgramSetting::IP.c_str(), ProgramSetting::databaseName.c_str() ));
|
||||||
///====================== Show channel rate;
|
|
||||||
case M_SHOW_CHANNELS_RATE:{
|
|
||||||
|
|
||||||
}break;
|
}break;
|
||||||
|
|
||||||
|
@ -367,7 +367,7 @@ void MainWindow::OpenDigitizers(){
|
||||||
for( int i = 0 ; i < nDigi; i++ ) delete digi[i];
|
for( int i = 0 ; i < nDigi; i++ ) delete digi[i];
|
||||||
|
|
||||||
LogMsg((char*)"============= detect digitizers");
|
LogMsg((char*)"============= detect digitizers");
|
||||||
vector<int> DPPType;
|
std::vector<int> DPPType;
|
||||||
DPPType.clear();
|
DPPType.clear();
|
||||||
portID.clear();
|
portID.clear();
|
||||||
boardID.clear();
|
boardID.clear();
|
||||||
|
@ -407,7 +407,7 @@ void MainWindow::OpenDigitizers(){
|
||||||
digi[i]->GetDPPTypeString().c_str(),
|
digi[i]->GetDPPTypeString().c_str(),
|
||||||
digi[i]->GetModelName().c_str()));
|
digi[i]->GetModelName().c_str()));
|
||||||
|
|
||||||
digi[i]->OpenSettingBinary("./setting_" + to_string(digi[i]->GetSerialNumber()) + ".bin");
|
digi[i]->OpenSettingBinary("./setting_" + std::to_string(digi[i]->GetSerialNumber()) + ".bin");
|
||||||
}
|
}
|
||||||
|
|
||||||
fMenuDigitizers->DisableEntry( M_DIGITIZER_OPEN);
|
fMenuDigitizers->DisableEntry( M_DIGITIZER_OPEN);
|
||||||
|
|
8
FSUDAQ.h
8
FSUDAQ.h
|
@ -22,6 +22,7 @@
|
||||||
#include "channelSettingPSD.h"
|
#include "channelSettingPSD.h"
|
||||||
#include "registerSetting.h"
|
#include "registerSetting.h"
|
||||||
#include "triggerSummary.h"
|
#include "triggerSummary.h"
|
||||||
|
#include "programSetting.h"
|
||||||
|
|
||||||
class TGWindow;
|
class TGWindow;
|
||||||
class TGMainFrame;
|
class TGMainFrame;
|
||||||
|
@ -52,9 +53,9 @@ private:
|
||||||
TGTextButton *bFitTrace;
|
TGTextButton *bFitTrace;
|
||||||
|
|
||||||
unsigned short nDigi;
|
unsigned short nDigi;
|
||||||
vector<int> portID;
|
std::vector<int> portID;
|
||||||
vector<int> boardID;
|
std::vector<int> boardID;
|
||||||
vector<int> serialNum;
|
std::vector<int> serialNum;
|
||||||
static Digitizer ** digi;
|
static Digitizer ** digi;
|
||||||
|
|
||||||
static BoardSetting * boardSetting;
|
static BoardSetting * boardSetting;
|
||||||
|
@ -62,6 +63,7 @@ private:
|
||||||
ChannelSettingPSD * channelSettingPSD;
|
ChannelSettingPSD * channelSettingPSD;
|
||||||
RegisterSetting * registerSetting;
|
RegisterSetting * registerSetting;
|
||||||
TriggerSummary * triggerSummary;
|
TriggerSummary * triggerSummary;
|
||||||
|
ProgramSetting * programSetting;
|
||||||
|
|
||||||
TThread * fillHistThread;
|
TThread * fillHistThread;
|
||||||
|
|
||||||
|
|
13
Makefile
13
Makefile
|
@ -11,8 +11,7 @@ CAENLIBS = -lCAENDigitizer
|
||||||
|
|
||||||
ROOTLIBS = `root-config --cflags --glibs`
|
ROOTLIBS = `root-config --cflags --glibs`
|
||||||
|
|
||||||
#OBJS = channelSettingPSD.o channelSettingPHA.o boardSetting.o ClassDigitizer.o DigitizerPHA.o DigitizerPSD.o FSUDAQ.o
|
OBJS = programSetting.o triggerSummary.o registerSetting.o channelSettingPSD.o channelSettingPHA.o boardSetting.o ClassDigitizer.o FSUDAQ.o
|
||||||
OBJS = triggerSummary.o registerSetting.o channelSettingPSD.o channelSettingPHA.o boardSetting.o ClassDigitizer.o FSUDAQ.o
|
|
||||||
|
|
||||||
#########################################################################
|
#########################################################################
|
||||||
|
|
||||||
|
@ -24,12 +23,6 @@ clean :
|
||||||
ClassDigitizer.o : ClassDigitizer.cpp ClassDigitizer.h RegisterAddress.h macro.h ClassData.h
|
ClassDigitizer.o : ClassDigitizer.cpp ClassDigitizer.h RegisterAddress.h macro.h ClassData.h
|
||||||
$(CC) $(COPTS) -c ClassDigitizer.cpp
|
$(CC) $(COPTS) -c ClassDigitizer.cpp
|
||||||
|
|
||||||
#DigitizerPHA.o : DigitizerPHA.cpp DigitizerPHA.h ClassDigitizer.o
|
|
||||||
# $(CC) $(COPTS) -c DigitizerPHA.cpp
|
|
||||||
#
|
|
||||||
#DigitizerPSD.o : DigitizerPSD.cpp DigitizerPSD.h ClassDigitizer.o
|
|
||||||
# $(CC) $(COPTS) -c DigitizerPSD.cpp
|
|
||||||
|
|
||||||
test : test.cpp ClassDigitizer.o
|
test : test.cpp ClassDigitizer.o
|
||||||
@echo "--------- making test"
|
@echo "--------- making test"
|
||||||
$(CC) $(COPTS) -o test test.cpp ClassDigitizer.o $(CAENLIBS) $(ROOTLIBS)
|
$(CC) $(COPTS) -o test test.cpp ClassDigitizer.o $(CAENLIBS) $(ROOTLIBS)
|
||||||
|
@ -70,6 +63,10 @@ triggerSummary.o : triggerSummary.h triggerSummary.cpp
|
||||||
@echo "----------- creating triggerSummary.o"
|
@echo "----------- creating triggerSummary.o"
|
||||||
$(CC) $(COPTS) -c triggerSummary.cpp $(ROOTLIBS)
|
$(CC) $(COPTS) -c triggerSummary.cpp $(ROOTLIBS)
|
||||||
|
|
||||||
|
programSetting.o : programSetting.h programSetting.cpp
|
||||||
|
@echo "----------- creating programSetting.o"
|
||||||
|
$(CC) $(COPTS) -c programSetting.cpp $(ROOTLIBS)
|
||||||
|
|
||||||
|
|
||||||
#CutsCreator: $(OBJS3) src/CutsCreator.c
|
#CutsCreator: $(OBJS3) src/CutsCreator.c
|
||||||
# g++ -std=c++17 -pthread src/CutsCreator.c -o CutsCreator $(ROOTLIBS)
|
# g++ -std=c++17 -pthread src/CutsCreator.c -o CutsCreator $(ROOTLIBS)
|
||||||
|
|
|
@ -713,11 +713,6 @@ BoardSetting::~BoardSetting(){
|
||||||
isOpened = false;
|
isOpened = false;
|
||||||
|
|
||||||
printf("close BoardSetting window\n");
|
printf("close BoardSetting window\n");
|
||||||
|
|
||||||
//for( int i = 0; i < nDigi; i++) digi[i] = 0;
|
|
||||||
//pha = 0;
|
|
||||||
//psd = 0;
|
|
||||||
//delete readStatusThread;
|
|
||||||
|
|
||||||
delete boardIDEntry;
|
delete boardIDEntry;
|
||||||
for(int i = 0; i < NUM_BOARD_INFO; i++) delete entry[i];
|
for(int i = 0; i < NUM_BOARD_INFO; i++) delete entry[i];
|
||||||
|
|
|
@ -557,46 +557,14 @@ void ChannelSettingPHA::SetAllChannels(){
|
||||||
short ch = chIDEntry->GetNumber();
|
short ch = chIDEntry->GetNumber();
|
||||||
|
|
||||||
///use memory from this channel and set to all other channal
|
///use memory from this channel and set to all other channal
|
||||||
|
for( int p = 0; (int) RegisterPHAList.size(); p++){
|
||||||
//digi[boardID]
|
unsigned short temp = digi[boardID]->GetSettingFromMemory(RegisterPHAList[p], ch);
|
||||||
|
|
||||||
|
for( int i = 0; i < digi[boardID]->GetNChannel() ; i++){
|
||||||
|
if( i == ch ) continue;
|
||||||
/*
|
digi[boardID]->WriteRegister(RegisterPHAList[p], temp, i);
|
||||||
uint32_t bit = 0;
|
}
|
||||||
bit += numTrapScale->GetNumber();
|
|
||||||
bit += ((cbDecimation->GetSelected() & 0x3) << 8) ;
|
|
||||||
bit += ((cbDecimationGain->GetSelected() & 0x3) << 10);
|
|
||||||
bit += ((cbPeakMean->GetSelected() & 0x3) << 12);
|
|
||||||
bit += ((cbPolarity->GetSelected() & 0x3) << 16);
|
|
||||||
bit += ((cbTriggerMode->GetSelected() & 0x3) << 18);
|
|
||||||
bit += ((cbBaseLineAvg->GetSelected() & 0x7) << 20);
|
|
||||||
bit += ((cbDisableSelfTrigger->GetSelected() & 0x1) << 24);
|
|
||||||
bit += ((cbRollOver->GetSelected() & 0x1) << 26);
|
|
||||||
bit += ((cbPileUp->GetSelected() & 0x1) << 27);
|
|
||||||
|
|
||||||
printf(" DPP1 bit: 0x%x\n", bit);
|
|
||||||
digi[boardID]->WriteRegister(Register::DPP::DPPAlgorithmControl, bit, -1);
|
|
||||||
|
|
||||||
bit = 0;
|
|
||||||
if( cbLocalShapedTrigger->GetSelected() >= 0 ){
|
|
||||||
bit += cbLocalShapedTrigger->GetSelected();
|
|
||||||
bit += ( 1 << 2);
|
|
||||||
}
|
}
|
||||||
if( cbLocalTriggerValid->GetSelected() >= 0 ){
|
|
||||||
bit += ((cbLocalTriggerValid->GetSelected() << 4) & 0x3);
|
|
||||||
bit += ( 1 << 6);
|
|
||||||
}
|
|
||||||
bit += ((cbExtra2WordOption->GetSelected() & 0x7) << 8 );
|
|
||||||
bit += ((cbVetoSource->GetSelected() & 0x3) << 14 );
|
|
||||||
bit += ((cbTriggerCounterRate->GetSelected() & 0x3) << 16 );
|
|
||||||
bit += ((cbBaselineCal->GetSelected() & 0x1) << 18 );
|
|
||||||
bit += ((cbTagCorrelatedEvent->GetSelected() & 0x1) << 19 );
|
|
||||||
bit += ((cbBaselineOptimize->GetSelected() & 0x1) << 29 );
|
|
||||||
|
|
||||||
printf(" DPP2 bit: 0x%x\n", bit);
|
|
||||||
digi[boardID]->WriteRegister(Register::DPP::PHA::DPPAlgorithmControl2_G, bit, -1);
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChannelSettingPHA::SetChannelMask(){
|
void ChannelSettingPHA::SetChannelMask(){
|
||||||
|
|
67
programSetting.cpp
Normal file
67
programSetting.cpp
Normal file
|
@ -0,0 +1,67 @@
|
||||||
|
#include <TApplication.h>
|
||||||
|
#include <TGClient.h>
|
||||||
|
#include <TCanvas.h>
|
||||||
|
#include <TF1.h>
|
||||||
|
#include <TRandom.h>
|
||||||
|
#include <TRootEmbeddedCanvas.h>
|
||||||
|
#include <TGTableContainer.h>
|
||||||
|
#include <TGFileDialog.h>
|
||||||
|
|
||||||
|
#include "programSetting.h"
|
||||||
|
|
||||||
|
std::string ProgramSetting::IP = "http://fsunuc.physics.fsu.edu/influx/";
|
||||||
|
std::string ProgramSetting::databaseName = "testing";
|
||||||
|
|
||||||
|
ProgramSetting::ProgramSetting(const TGWindow *p){
|
||||||
|
fMain = new TGMainFrame(p, 600, 400);
|
||||||
|
fMain->SetWindowName("Program Setting");
|
||||||
|
fMain->Connect("CloseWindow()", "ProgramSetting", this, "CloseWindow()");
|
||||||
|
|
||||||
|
TGVerticalFrame * vframe = new TGVerticalFrame(fMain); fMain->AddFrame(vframe);
|
||||||
|
|
||||||
|
{///============== Database
|
||||||
|
TGGroupFrame * gfDatabase = new TGGroupFrame(vframe, "Database Setting", kHorizontalFrame); vframe->AddFrame(gfDatabase, new TGLayoutHints(kLHintsExpandY, 5, 5, 5, 5));
|
||||||
|
|
||||||
|
TGVerticalFrame * vfDB = new TGVerticalFrame(gfDatabase); gfDatabase->AddFrame(vfDB);
|
||||||
|
|
||||||
|
TGHorizontalFrame * hfDB1 = new TGHorizontalFrame(vfDB); vfDB->AddFrame(hfDB1);
|
||||||
|
TGLabel * lbIP = new TGLabel(hfDB1, "IP :"); hfDB1->AddFrame(lbIP, new TGLayoutHints(kLHintsLeft | kLHintsCenterY, 5,5,3,3));
|
||||||
|
txtIP = new TGTextEntry(hfDB1, IP.c_str()); hfDB1->AddFrame(txtIP, new TGLayoutHints(kLHintsLeft | kLHintsCenterY, 5,5,3,3));
|
||||||
|
txtIP->Resize(300, 20);
|
||||||
|
txtIP->Connect("ReturnPressed()", "ProgramSetting", this, "SetDataBase()");
|
||||||
|
|
||||||
|
TGHorizontalFrame * hfDB2 = new TGHorizontalFrame(vfDB); vfDB->AddFrame(hfDB2);
|
||||||
|
TGLabel * lbDBName = new TGLabel(hfDB2, "DB Name :"); hfDB2->AddFrame(lbDBName, new TGLayoutHints(kLHintsLeft | kLHintsCenterY, 5,5,3,3));
|
||||||
|
txtDBName = new TGTextEntry(hfDB2, databaseName.c_str()); hfDB2->AddFrame(txtDBName, new TGLayoutHints(kLHintsLeft | kLHintsCenterY, 5,5,3,3));
|
||||||
|
txtDBName->Connect("ReturnPressed()", "ProgramSetting", this, "SetDataBase()");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
{///============== Read Time event building
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
fMain->MapSubwindows();
|
||||||
|
fMain->Resize(fMain->GetDefaultSize());
|
||||||
|
fMain->MapWindow();
|
||||||
|
}
|
||||||
|
|
||||||
|
ProgramSetting::~ProgramSetting(){
|
||||||
|
|
||||||
|
delete txtIP;
|
||||||
|
delete txtDBName;
|
||||||
|
|
||||||
|
fMain->Cleanup();
|
||||||
|
delete fMain;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ProgramSetting::SetDataBase(){
|
||||||
|
|
||||||
|
IP = txtIP->GetText();
|
||||||
|
databaseName = txtDBName->GetText();
|
||||||
|
|
||||||
|
printf("IP: %s\n", IP.c_str());
|
||||||
|
printf("Name: %s\n", databaseName.c_str());
|
||||||
|
|
||||||
|
}
|
38
programSetting.h
Normal file
38
programSetting.h
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
#ifndef PROGRAM_SETTING_H
|
||||||
|
#define PROGRAM_SETTING_H
|
||||||
|
|
||||||
|
#include <TQObject.h>
|
||||||
|
#include <RQ_OBJECT.h>
|
||||||
|
#include <TGNumberEntry.h>
|
||||||
|
#include <TGButton.h>
|
||||||
|
#include <TGComboBox.h>
|
||||||
|
#include <TThread.h>
|
||||||
|
#include <TGLabel.h>
|
||||||
|
#include <TGTextEdit.h>
|
||||||
|
#include "ClassDigitizer.h"
|
||||||
|
#include "macro.h"
|
||||||
|
|
||||||
|
class TGWindow;
|
||||||
|
class TGMainFrame;
|
||||||
|
|
||||||
|
class ProgramSetting{
|
||||||
|
RQ_OBJECT("ProgramSetting")
|
||||||
|
private:
|
||||||
|
TGMainFrame * fMain;
|
||||||
|
|
||||||
|
TGTextEntry * txtIP;
|
||||||
|
TGTextEntry * txtDBName;
|
||||||
|
|
||||||
|
public:
|
||||||
|
ProgramSetting(const TGWindow *p);
|
||||||
|
virtual ~ProgramSetting();
|
||||||
|
|
||||||
|
void CloseWindow() { delete this;}
|
||||||
|
|
||||||
|
static std::string IP;
|
||||||
|
static std::string databaseName;
|
||||||
|
|
||||||
|
void SetDataBase();
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
|
@ -134,14 +134,16 @@ RegisterSetting::~RegisterSetting(){
|
||||||
|
|
||||||
delete bSetALLChannel;
|
delete bSetALLChannel;
|
||||||
delete lbValueUnit;
|
delete lbValueUnit;
|
||||||
delete txtInfo;
|
//delete txtInfo;
|
||||||
|
|
||||||
for(int i = 0; i < MaxNChannels; i++) {
|
for(int i = 0; i < MaxNChannels; i++) {
|
||||||
delete txtValueHex[i];
|
delete txtValueHex[i];
|
||||||
delete txtValueDec[i];
|
delete txtValueDec[i];
|
||||||
delete txtValueUnit[i];
|
delete txtValueUnit[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for( int i = 0; i < nDigi; i++ ) digi[i] = 0;
|
||||||
|
|
||||||
fMain->Cleanup();
|
fMain->Cleanup();
|
||||||
delete fMain;
|
delete fMain;
|
||||||
|
|
||||||
|
|
|
@ -26,15 +26,13 @@ class RegisterSetting{
|
||||||
TGComboBox * cbName;
|
TGComboBox * cbName;
|
||||||
|
|
||||||
TGCheckButton * bSetALLChannel;
|
TGCheckButton * bSetALLChannel;
|
||||||
|
TGLabel * lbValueUnit;
|
||||||
|
//TGLabel * txtInfo;
|
||||||
|
|
||||||
TGTextEntry * txtValueHex[MaxNChannels];
|
TGTextEntry * txtValueHex[MaxNChannels];
|
||||||
TGTextEntry * txtValueDec[MaxNChannels];
|
TGTextEntry * txtValueDec[MaxNChannels];
|
||||||
TGTextEntry * txtValueUnit[MaxNChannels];
|
TGTextEntry * txtValueUnit[MaxNChannels];
|
||||||
|
|
||||||
TGLabel * lbValueUnit;
|
|
||||||
|
|
||||||
TGLabel * txtInfo;
|
|
||||||
|
|
||||||
unsigned int value[MaxNChannels];
|
unsigned int value[MaxNChannels];
|
||||||
|
|
||||||
int textID;
|
int textID;
|
||||||
|
|
29
test.cpp
29
test.cpp
|
@ -8,8 +8,8 @@
|
||||||
#include "TGraph.h"
|
#include "TGraph.h"
|
||||||
#include "TH1.h"
|
#include "TH1.h"
|
||||||
|
|
||||||
#include <sys/time.h> /* struct timeval, select() */
|
#include <sys/time.h> /** struct timeval, select() */
|
||||||
#include <termios.h> /* tcgetattr(), tcsetattr() */
|
#include <termios.h> /** tcgetattr(), tcsetattr() */
|
||||||
|
|
||||||
static struct termios g_old_kbd_mode;
|
static struct termios g_old_kbd_mode;
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@ static void cooked(void){
|
||||||
|
|
||||||
static void uncooked(void){
|
static void uncooked(void){
|
||||||
struct termios new_kbd_mode;
|
struct termios new_kbd_mode;
|
||||||
/* put keyboard (stdin, actually) in raw, unbuffered mode */
|
/** put keyboard (stdin, actually) in raw, unbuffered mode */
|
||||||
tcgetattr(0, &g_old_kbd_mode);
|
tcgetattr(0, &g_old_kbd_mode);
|
||||||
memcpy(&new_kbd_mode, &g_old_kbd_mode, sizeof(struct termios));
|
memcpy(&new_kbd_mode, &g_old_kbd_mode, sizeof(struct termios));
|
||||||
new_kbd_mode.c_lflag &= ~(ICANON | ECHO);
|
new_kbd_mode.c_lflag &= ~(ICANON | ECHO);
|
||||||
|
@ -32,9 +32,9 @@ static void raw(void){
|
||||||
|
|
||||||
static char init;
|
static char init;
|
||||||
if(init) return;
|
if(init) return;
|
||||||
/* put keyboard (stdin, actually) in raw, unbuffered mode */
|
/** put keyboard (stdin, actually) in raw, unbuffered mode */
|
||||||
uncooked();
|
uncooked();
|
||||||
/* when we exit, go back to normal, "cooked" mode */
|
/** when we exit, go back to normal, "cooked" mode */
|
||||||
atexit(cooked);
|
atexit(cooked);
|
||||||
|
|
||||||
init = 1;
|
init = 1;
|
||||||
|
@ -47,7 +47,7 @@ int keyboardhit(){
|
||||||
int status;
|
int status;
|
||||||
|
|
||||||
raw();
|
raw();
|
||||||
/* check stdin (fd 0) for activity */
|
/** check stdin (fd 0) for activity */
|
||||||
FD_ZERO(&read_handles);
|
FD_ZERO(&read_handles);
|
||||||
FD_SET(0, &read_handles);
|
FD_SET(0, &read_handles);
|
||||||
timeout.tv_sec = timeout.tv_usec = 0;
|
timeout.tv_sec = timeout.tv_usec = 0;
|
||||||
|
@ -61,11 +61,9 @@ int keyboardhit(){
|
||||||
|
|
||||||
int getch(void){
|
int getch(void){
|
||||||
unsigned char temp;
|
unsigned char temp;
|
||||||
|
|
||||||
raw();
|
raw();
|
||||||
/* stdin = fd 0 */
|
/** stdin = fd 0 */
|
||||||
if(read(0, &temp, 1) != 1) return 0;
|
if(read(0, &temp, 1) != 1) return 0;
|
||||||
//printf("%s", &temp);
|
|
||||||
return temp;
|
return temp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -91,9 +89,18 @@ int main(int argc, char* argv[]){
|
||||||
//dig->OpenSettingBinary("setting_323.bin");
|
//dig->OpenSettingBinary("setting_323.bin");
|
||||||
dig->LoadSettingBinary("setting_323.bin");
|
dig->LoadSettingBinary("setting_323.bin");
|
||||||
//dig->PrintSettingFromMemory();
|
//dig->PrintSettingFromMemory();
|
||||||
printf("##############################################################\n");
|
//printf("##############################################################\n");
|
||||||
dig->SaveSettingAsText("haha.txt");
|
//dig->SaveSettingAsText("haha.txt");
|
||||||
|
|
||||||
|
//for( int i = 0; i < dig->GetNChannel(); i++){
|
||||||
|
// dig->SaveSettingToFile(Register::DPP::NumberEventsPerAggregate_G, 10, i);
|
||||||
|
//}
|
||||||
|
|
||||||
|
dig->SaveSettingToFile(Register::DPP::MaxAggregatePerBlockTransfer, 200, 0);
|
||||||
|
|
||||||
|
unsigned int bSize = dig->CalByteForBuffer();
|
||||||
|
|
||||||
|
printf("Buffer Size : %u byte = %.2f MB \n", bSize, bSize/1024./1024.);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
const int nBoard = 2;
|
const int nBoard = 2;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user