tested full trace and 1 trace recording, full trace ~500Hz, 1 trace ~ 1kHz, all 64 channel on

This commit is contained in:
Ryan Tang 2023-01-20 16:18:41 -05:00
parent 2e35bac104
commit bde3bc1ef2
4 changed files with 62 additions and 25 deletions

View File

@ -435,12 +435,12 @@ int Digitizer2Gen::ReadData(){
return CAEN_FELib_UNKNOWN;
}
return ret;
if( ret != CAEN_FELib_Success) {
ErrorMsg("Set Read Data");
ErrorMsg("ReadData()");
return ret;
}
return ret;
}
//###########################################
@ -539,16 +539,29 @@ void Digitizer2Gen::ProgramPHA(bool testPulse){
WriteValue("/par/EnStatEvents", "true");
// Channel setting
//WriteValue("/ch/0..63/par/EventTriggerSource", "GlobalTriggerSource");
WriteValue("/ch/0..63/par/EventTriggerSource", "ChSelfTrigger");
WriteValue("/ch/0..63/par/ChEnable" , "true");
if( testPulse){
//WriteValue("/ch/0..63/par/ChEnable" , "false");
//WriteValue("/ch/0/par/ChEnable" , "true");
//WriteValue("/ch/1/par/ChEnable" , "true");
//WriteValue("/ch/2/par/ChEnable" , "true");
//WriteValue("/ch/3/par/ChEnable" , "true");
WriteValue("/ch/0..63/par/ChEnable" , "true");
WriteValue("/ch/0..63/par/EventTriggerSource", "GlobalTriggerSource");
WriteValue("/ch/0..63/par/WaveTriggerSource" , "GlobalTriggerSource"); // EventTriggerSource enought
}else{
WriteValue("/ch/0..63/par/EventTriggerSource", "ChSelfTrigger");
WriteValue("/ch/0..63/par/ChEnable" , "true");
}
WriteValue("/ch/0..63/par/DCOffset" , "10"); /// 10%
WriteValue("/ch/0..63/par/WaveSaving" , "Always");
// Global trigger configuration
if( testPulse ) {
WriteValue("/par/GlobalTriggerSource", "SwTrg | TestPulse");
WriteValue("/par/TestPulsePeriod" , "500000"); // 0.5 msec = 2kHz
WriteValue("/par/TestPulsePeriod" , "2000000"); // 2.0 msec = 500Hz, tested, 1 trace recording
WriteValue("/par/TestPulseWidth" , "1000"); // nsec
WriteValue("/par/TestPulseLowLevel" , "0");
WriteValue("/par/TestPulseHighLevel" , "10000");

View File

@ -17,18 +17,22 @@ class SolReader {
unsigned int filePos;
unsigned int totNumBlock;
unsigned short blockStart;
unsigned short blockStartIdentifier;
unsigned int numBlock;
bool isScanned;
void init();
std::vector<unsigned int> blockPos;
public:
SolReader();
SolReader(std::string fileName, unsigned short dataType);
~SolReader();
void OpenFile(std::string fileName);
int ReadBlock(int opt); // opt = 0, noraml, 1, fast
int ReadNextBlock(int opt = 0); // opt = 0, noraml, 1, fast
int ReadBlock(unsigned int ID);
void ScanNumBlock();
@ -42,10 +46,16 @@ class SolReader {
};
void SolReader::init(){
inFileSize = 0;
numBlock = 0;
filePos = 0;
totNumBlock = 0;
evt = new Event();
isScanned = false;
blockPos.clear();
}
SolReader::SolReader(){
@ -73,22 +83,29 @@ inline void SolReader::OpenFile(std::string fileName){
}
}
inline int SolReader::ReadBlock(int opt = 0){
inline int SolReader::ReadBlock(unsigned int ID){
fseek(inFile, 0L, SEEK_SET);
fseek(inFile, blockPos[ID], SEEK_CUR);
return ReadNextBlock();
}
inline int SolReader::ReadNextBlock(int opt){
if( inFile == NULL ) return -1;
if( feof(inFile) ) return -1;
if( filePos >= inFileSize) return -1;
fread(&blockStart, 2, 1, inFile);
fread(&blockStartIdentifier, 2, 1, inFile);
if( (blockStart & 0xAAA0) != 0xAAA0 ) {
if( (blockStartIdentifier & 0xAAA0) != 0xAAA0 ) {
printf("header fail.\n");
return -2 ;
}
if( ( blockStart & 0xF ) == 15 ){
if( ( blockStartIdentifier & 0xF ) == 15 ){
evt->SetDataType(15);
}
evt->dataType = blockStart & 0xF;
evt->dataType = blockStartIdentifier & 0xF;
if( evt->dataType == 0){
if( opt == 0 ){
@ -171,26 +188,27 @@ inline int SolReader::ReadBlock(int opt = 0){
return 0;
}
void SolReader::ScanNumBlock(){
if( inFile == NULL ) return;
if( feof(inFile) ) return;
numBlock = 0;
blockPos.clear();
while( ReadBlock(1) == 0){
blockPos.push_back(0);
while( ReadNextBlock(1) == 0){
blockPos.push_back(filePos);
//printf("%u, traceLen %lu, %u/%u\n", numBlock, evt->traceLenght, filePos, inFileSize);
}
totNumBlock = numBlock;
numBlock = 0;
isScanned = true;
printf("Scan complete: number of data Block : %u\n", totNumBlock);
rewind(inFile);
filePos = 0;
}
#endif

View File

@ -10,16 +10,20 @@ void script(){
reader->ScanNumBlock();
/*
for( int i = 0; i < reader->GetTotalNumBlock() ; i++){
//for( int i = 0; i < reader->GetTotalNumBlock() ; i++){
for( int i = 0; i < 4 ; i++){
printf("########################## nBlock : %u, %u/%u\n", reader->GetNumBlock(),
reader->GetFilePos(),
reader->GetFileSize());
reader->ReadBlock();
reader->ReadNextBlock();
evt->PrintAll();
//evt->PrintAllTrace();
}
reader->ReadBlock(100);
evt->PrintAll();
//printf("reader traceLength : %lu \n", evt->traceLenght);

View File

@ -41,7 +41,7 @@ static void ReadDataLoop(){
}
if( readCount % 100 == 0 ) {
clock_gettime(CLOCK_REALTIME, &tb);
printf("%4d, duration : %.0f\n", readCount, tb.tv_nsec-ta.tv_nsec + tb.tv_sec*1e+9 - ta.tv_sec*1e+9);
printf("%4d, duration : %10.0f\n", readCount, tb.tv_nsec-ta.tv_nsec + tb.tv_sec*1e+9 - ta.tv_sec*1e+9);
ta = tb;
}
readCount++;
@ -91,7 +91,7 @@ int main(int argc, char* argv[]){
digi->OpenDigitizer(url);
digi->ProgramPHA(false);
digi->ProgramPHA(true);
//printf("%s \n", digi->ReadValue("/ch/0/par/ChRealtimeMonitor").c_str());
//printf("%s \n", digi->ReadValue("/ch/0/par/Energy_Nbit").c_str());
@ -152,7 +152,9 @@ int main(int argc, char* argv[]){
th2.join();
clock_gettime(CLOCK_REALTIME, &t1);
printf("t1-t0 : %.0f\n", t1.tv_nsec-t0.tv_nsec + t1.tv_sec*1e+9 - t0.tv_sec*1e+9);
printf("t1-t0 : %.0f ns = %.2f sec\n",
t1.tv_nsec-t0.tv_nsec + t1.tv_sec*1e+9 - t0.tv_sec*1e+9,
(t1.tv_nsec-t0.tv_nsec + t1.tv_sec*1e+9 - t0.tv_sec*1e+9)*1.0/1e9);
digi->CloseOutFile();
digi->CloseDigitizer();