tested Ch64Trigger
This commit is contained in:
parent
bde3bc1ef2
commit
63333f2663
17
.vscode/c_cpp_properties.json
vendored
Normal file
17
.vscode/c_cpp_properties.json
vendored
Normal file
|
@ -0,0 +1,17 @@
|
|||
{
|
||||
"configurations": [
|
||||
{
|
||||
"name": "Linux",
|
||||
"includePath": [
|
||||
"${workspaceFolder}/**",
|
||||
"/opt/root/include/"
|
||||
],
|
||||
"defines": [],
|
||||
"compilerPath": "/usr/bin/gcc",
|
||||
"cStandard": "gnu17",
|
||||
"cppStandard": "gnu++17",
|
||||
"intelliSenseMode": "linux-gcc-x64"
|
||||
}
|
||||
],
|
||||
"version": 4
|
||||
}
|
|
@ -158,8 +158,6 @@ int Digitizer2Gen::OpenDigitizer(const char * url){
|
|||
ReadValue("/par/InputType", true);
|
||||
ReadValue("/par/Zin", true);
|
||||
|
||||
|
||||
///SendCommand("/cmd/reset");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -187,7 +185,7 @@ void Digitizer2Gen::StartACQ(){
|
|||
void Digitizer2Gen::StopACQ(){
|
||||
|
||||
SendCommand("/cmd/SwStopAcquisition");
|
||||
//SendCommand("/cmd/disarmacquisition");
|
||||
SendCommand("/cmd/disarmacquisition");
|
||||
|
||||
acqON = false;
|
||||
}
|
||||
|
@ -436,7 +434,7 @@ int Digitizer2Gen::ReadData(){
|
|||
}
|
||||
|
||||
if( ret != CAEN_FELib_Success) {
|
||||
ErrorMsg("ReadData()");
|
||||
//ErrorMsg("ReadData()");
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -526,6 +524,8 @@ void Digitizer2Gen::SaveDataToFile(){
|
|||
|
||||
|
||||
//###########################################
|
||||
void Digitizer2Gen::Reset(){ SendCommand("/cmd/Reset"); }
|
||||
|
||||
void Digitizer2Gen::ProgramPHA(bool testPulse){
|
||||
if( !isConnected ) return ;
|
||||
|
||||
|
@ -540,38 +540,59 @@ void Digitizer2Gen::ProgramPHA(bool testPulse){
|
|||
|
||||
// Channel setting
|
||||
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" , "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/ChEnable" , "true");
|
||||
|
||||
WriteValue("/ch/0..63/par/EventTriggerSource", "GlobalTriggerSource");
|
||||
WriteValue("/ch/0..63/par/WaveTriggerSource" , "GlobalTriggerSource"); // EventTriggerSource enought
|
||||
|
||||
WriteValue("/par/GlobalTriggerSource", "SwTrg | TestPulse");
|
||||
WriteValue("/par/TestPulsePeriod" , "1000000"); // 1.0 msec = 1000Hz, tested, 1 trace recording
|
||||
WriteValue("/par/TestPulseWidth" , "1000"); // nsec
|
||||
WriteValue("/par/TestPulseLowLevel" , "0");
|
||||
WriteValue("/par/TestPulseHighLevel" , "10000");
|
||||
|
||||
}else{
|
||||
WriteValue("/ch/0..63/par/EventTriggerSource", "ChSelfTrigger");
|
||||
//======= this is for manual send trigger signal via software
|
||||
//WriteValue("/ch/0..63/par/EventTriggerSource", "SwTrg");
|
||||
//WriteValue("/ch/0..63/par/WaveTriggerSource" , "SwTrg");
|
||||
|
||||
|
||||
//======== Self trigger for each channel
|
||||
//WriteValue("/ch/0..63/par/EventTriggerSource", "ChSelfTrigger");
|
||||
//WriteValue("/ch/0..63/par/WaveTriggerSource" , "ChSelfTrigger");
|
||||
|
||||
//======== One (or more) slef-trigger can trigger whole board, ??? depend on Channel Trigger mask
|
||||
WriteValue("/ch/0..63/par/EventTriggerSource", "Ch64Trigger");
|
||||
WriteValue("/ch/0..63/par/WaveTriggerSource" , "Ch64Trigger");
|
||||
|
||||
WriteValue("/ch/0..63/par/ChannelsTriggerMask", "0x0000FFFF000F000F");
|
||||
//WriteValue("/ch/0/par/ChannelsTriggerMask", "0x000F");
|
||||
//WriteValue("/ch/12/par/ChannelsTriggerMask", "0x000F");
|
||||
//WriteValue("/ch/38/par/ChannelsTriggerMask", "0x000F"); // when channel has no input, it still record.
|
||||
|
||||
//WriteValue("/ch/0..63/par/CoincidenceMask", "Ch64Trigger");
|
||||
//WriteValue("/ch/0..63/par/CoincidenceLength", "100"); //ns
|
||||
|
||||
//======== ACQ trigger?
|
||||
//WriteValue("/ch/0..63/par/EventTriggerSource", "GlobalTriggerSource");
|
||||
//WriteValue("/ch/0..63/par/WaveTriggerSource" , "GlobalTriggerSource");
|
||||
|
||||
//WriteValue("/par/GlobalTriggerSource", "SwTrg");
|
||||
|
||||
|
||||
WriteValue("/ch/0..63/par/ChEnable" , "true");
|
||||
//WriteValue("/ch/0..15/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" , "2000000"); // 2.0 msec = 500Hz, tested, 1 trace recording
|
||||
WriteValue("/par/TestPulseWidth" , "1000"); // nsec
|
||||
WriteValue("/par/TestPulseLowLevel" , "0");
|
||||
WriteValue("/par/TestPulseHighLevel" , "10000");
|
||||
}else{
|
||||
WriteValue("/par/GlobalTriggerSource", "SwTrg");
|
||||
}
|
||||
|
||||
// Wave configuration
|
||||
//WriteValue("/ch/0..63/par/WaveTriggerSource" , "ChSelfTrigger"); // EventTriggerSource enought
|
||||
|
||||
WriteValue("/ch/0..63/par/ChRecordLengthS" , "512"); /// 4096 ns
|
||||
WriteValue("/ch/0..63/par/ChPreTriggerS" , "125"); /// 1000 ns
|
||||
WriteValue("/ch/0..63/par/WaveResolution" , "RES8"); /// 8 ns
|
||||
|
@ -583,7 +604,6 @@ void Digitizer2Gen::ProgramPHA(bool testPulse){
|
|||
WriteValue("/ch/0..63/par/WaveDigitalProbe2" , "TimeFilterArmed");
|
||||
WriteValue("/ch/0..63/par/WaveDigitalProbe3" , "EnergyFilterPeakReady");
|
||||
|
||||
|
||||
// Filter parameters
|
||||
WriteValue("/ch/0..63/par/TimeFilterRiseTimeS" , "10"); // 80 ns
|
||||
WriteValue("/ch/0..63/par/TriggerThr" , "1000");
|
||||
|
@ -617,6 +637,10 @@ void Digitizer2Gen::ReadDigitizerSettings(){
|
|||
ReadValue("/ch/4/par/WaveDigitalProbe2", true);
|
||||
ReadValue("/ch/4/par/WaveDigitalProbe3", true);
|
||||
|
||||
ReadValue("/ch/4/par/ChannelsTriggerMask", true);
|
||||
|
||||
ReadValue("/ch/0/par/ChannelsTriggerMask", true);
|
||||
|
||||
}
|
||||
|
||||
std::string Digitizer2Gen::ErrorMsg(const char * funcName){
|
||||
|
|
|
@ -87,6 +87,7 @@ class Digitizer2Gen {
|
|||
int ReadStat();
|
||||
void PrintStat();
|
||||
|
||||
void Reset();
|
||||
void ProgramPHA(bool testPulse = false);
|
||||
void ReadDigitizerSettings();
|
||||
|
||||
|
|
15
Event.h
15
Event.h
|
@ -49,12 +49,27 @@ class Event {
|
|||
energy = 0;
|
||||
timestamp = 0;
|
||||
fine_timestamp = 0;
|
||||
downSampling = 0;
|
||||
board_fail = false;
|
||||
flush = false;
|
||||
flags_low_priority = 0;
|
||||
flags_high_priority = 0;
|
||||
trigger_threashold = 0;
|
||||
event_size = 0;
|
||||
aggCounter = 0;
|
||||
analog_probes[0] = NULL;
|
||||
analog_probes[1] = NULL;
|
||||
digital_probes[0] = NULL;
|
||||
digital_probes[1] = NULL;
|
||||
digital_probes[2] = NULL;
|
||||
digital_probes[3] = NULL;
|
||||
|
||||
analog_probes_type[0] = 0xFF;
|
||||
analog_probes_type[1] = 0xFF;
|
||||
digital_probes_type[0] = 0xFF;
|
||||
digital_probes_type[1] = 0xFF;
|
||||
digital_probes_type[2] = 0xFF;
|
||||
digital_probes_type[3] = 0xFF;
|
||||
data = NULL;
|
||||
}
|
||||
|
||||
|
|
1
Makefile
1
Makefile
|
@ -1,6 +1,7 @@
|
|||
CC = g++
|
||||
COPTS = -fPIC -DLINUX -O2 -std=c++17 -lpthread
|
||||
CAENLIBS = -lCAEN_FELib
|
||||
ROOTLIBS = `root-config --cflags --glibs`
|
||||
|
||||
all: test test_indep ClassDigitizer2Gen.o influxdb.o
|
||||
|
||||
|
|
30
SolReader.h
30
SolReader.h
|
@ -32,7 +32,7 @@ class SolReader {
|
|||
|
||||
void OpenFile(std::string fileName);
|
||||
int ReadNextBlock(int opt = 0); // opt = 0, noraml, 1, fast
|
||||
int ReadBlock(unsigned int ID);
|
||||
int ReadBlock(unsigned int index);
|
||||
|
||||
void ScanNumBlock();
|
||||
|
||||
|
@ -41,6 +41,8 @@ class SolReader {
|
|||
unsigned int GetFilePos() {return filePos;}
|
||||
unsigned int GetFileSize() {return inFileSize;}
|
||||
|
||||
void RewindFile();
|
||||
|
||||
Event * evt;
|
||||
|
||||
};
|
||||
|
@ -70,6 +72,7 @@ SolReader::SolReader(std::string fileName, unsigned short dataType = 0){
|
|||
|
||||
SolReader::~SolReader(){
|
||||
if( !inFile ) fclose(inFile);
|
||||
delete evt;
|
||||
}
|
||||
|
||||
inline void SolReader::OpenFile(std::string fileName){
|
||||
|
@ -83,9 +86,16 @@ inline void SolReader::OpenFile(std::string fileName){
|
|||
}
|
||||
}
|
||||
|
||||
inline int SolReader::ReadBlock(unsigned int ID){
|
||||
inline int SolReader::ReadBlock(unsigned int index){
|
||||
if( isScanned == false) return -1;
|
||||
if( index >= totNumBlock )return -1;
|
||||
fseek(inFile, 0L, SEEK_SET);
|
||||
fseek(inFile, blockPos[ID], SEEK_CUR);
|
||||
|
||||
printf("-----------%u, %u\n", index, blockPos[index]);
|
||||
|
||||
fseek(inFile, blockPos[index], SEEK_CUR);
|
||||
|
||||
numBlock = index;
|
||||
|
||||
return ReadNextBlock();
|
||||
}
|
||||
|
@ -188,6 +198,12 @@ inline int SolReader::ReadNextBlock(int opt){
|
|||
return 0;
|
||||
}
|
||||
|
||||
void SolReader::RewindFile(){
|
||||
rewind(inFile);
|
||||
filePos = 0;
|
||||
numBlock = 0;
|
||||
}
|
||||
|
||||
void SolReader::ScanNumBlock(){
|
||||
if( inFile == NULL ) return;
|
||||
if( feof(inFile) ) return;
|
||||
|
@ -199,16 +215,20 @@ void SolReader::ScanNumBlock(){
|
|||
|
||||
while( ReadNextBlock(1) == 0){
|
||||
blockPos.push_back(filePos);
|
||||
//printf("%u, traceLen %lu, %u/%u\n", numBlock, evt->traceLenght, filePos, inFileSize);
|
||||
printf("%u, %.2f%% %u/%u\n\033[A\r", numBlock, filePos*100./inFileSize, filePos, inFileSize);
|
||||
}
|
||||
|
||||
totNumBlock = numBlock;
|
||||
numBlock = 0;
|
||||
isScanned = true;
|
||||
printf("Scan complete: number of data Block : %u\n", totNumBlock);
|
||||
printf("\nScan complete: number of data Block : %u\n", totNumBlock);
|
||||
rewind(inFile);
|
||||
filePos = 0;
|
||||
|
||||
//for( int i = 0; i < totNumBlock; i++){
|
||||
// printf("%7d | %u \n", i, blockPos[i]);
|
||||
//}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
56
script.C
56
script.C
|
@ -1,4 +1,7 @@
|
|||
#include "SolReader.h"
|
||||
#include "TH1.h"
|
||||
#include "TCanvas.h"
|
||||
|
||||
|
||||
void script(){
|
||||
|
||||
|
@ -9,21 +12,52 @@ void script(){
|
|||
|
||||
reader->ScanNumBlock();
|
||||
|
||||
if( reader->GetTotalNumBlock() == 0 ) return;
|
||||
|
||||
unsigned long startTime, endTime;
|
||||
reader->ReadBlock(0);
|
||||
startTime = evt->timestamp;
|
||||
reader->ReadBlock(reader->GetTotalNumBlock() - 1);
|
||||
endTime = evt->timestamp;
|
||||
|
||||
double duration = double(endTime - startTime)*8./1e9;
|
||||
printf("============== %lu ns = %.4f sec.\n", (endTime - startTime)*8, duration);
|
||||
printf(" avarge rate (16ch): %f Hz\n", reader->GetTotalNumBlock()/duration/16);
|
||||
reader->RewindFile();
|
||||
|
||||
|
||||
//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());
|
||||
TCanvas * canvas = new TCanvas("c1", "c1", 600, 600);
|
||||
|
||||
TH1F * h1 = new TH1F("h1", "h1", 1000, startTime, endTime);
|
||||
TH2F * h2 = new TH2F("h2", "h2", 1000, startTime, endTime, 1000, 0, reader->GetTotalNumBlock());
|
||||
|
||||
uint64_t tOld = startTime;
|
||||
|
||||
for( int i = 0; i < reader->GetTotalNumBlock() ; i++){
|
||||
//for( int i = 0; i < 8 ; i++){
|
||||
|
||||
reader->ReadNextBlock();
|
||||
evt->PrintAll();
|
||||
//evt->PrintAllTrace();
|
||||
|
||||
if( i < 8 ){
|
||||
printf("########################## nBlock : %u, %u/%u\n", reader->GetNumBlock(),
|
||||
reader->GetFilePos(),
|
||||
reader->GetFileSize());
|
||||
evt->PrintAll();
|
||||
//evt->PrintAllTrace();
|
||||
}
|
||||
|
||||
h1->Fill(evt->timestamp);
|
||||
h2->Fill(evt->timestamp, i);
|
||||
|
||||
if( i > 0 ){
|
||||
if( evt->timestamp < tOld) printf("-------- time not sorted.");
|
||||
tOld = evt->timestamp;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
reader->ReadBlock(100);
|
||||
evt->PrintAll();
|
||||
|
||||
h2->Draw();
|
||||
|
||||
//printf("reader traceLength : %lu \n", evt->traceLenght);
|
||||
|
||||
|
@ -34,4 +68,8 @@ void script(){
|
|||
|
||||
}
|
||||
*/
|
||||
|
||||
evt = NULL;
|
||||
delete reader;
|
||||
|
||||
}
|
25
test.cpp
25
test.cpp
|
@ -35,16 +35,15 @@ static void ReadDataLoop(){
|
|||
digi->ErrorMsg("No more data");
|
||||
break;
|
||||
}else{
|
||||
digi->ErrorMsg("ReadData()");
|
||||
//digiMTX.unlock();
|
||||
//break;
|
||||
digi->ErrorMsg("ReadDataLoop()");
|
||||
}
|
||||
if( readCount % 100 == 0 ) {
|
||||
clock_gettime(CLOCK_REALTIME, &tb);
|
||||
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++;
|
||||
//if( readCount % 1000 == 0 ) {
|
||||
// clock_gettime(CLOCK_REALTIME, &tb);
|
||||
// double duration = tb.tv_nsec-ta.tv_nsec + tb.tv_sec*1e+9 - ta.tv_sec*1e+9;
|
||||
// printf("%4d, duration : %10.0f, %6.1f\n", readCount, duration, 1e9/duration);
|
||||
// ta = tb;
|
||||
//}
|
||||
//readCount++;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -69,7 +68,7 @@ static void StatLoop(){
|
|||
//digi->ReadValue("/ch/4/par/ChWaveCnt", true);
|
||||
digiMTX.unlock();
|
||||
|
||||
|
||||
//influx->PrintDataPoints();
|
||||
influx->WriteData("testing");
|
||||
influx->ClearDataPointsBuffer();
|
||||
digi->PrintStat();
|
||||
|
@ -89,9 +88,9 @@ int main(int argc, char* argv[]){
|
|||
|
||||
const char * url = "dig2://192.168.0.100/";
|
||||
|
||||
|
||||
digi->OpenDigitizer(url);
|
||||
digi->ProgramPHA(true);
|
||||
digi->Reset();
|
||||
digi->ProgramPHA(false);
|
||||
|
||||
//printf("%s \n", digi->ReadValue("/ch/0/par/ChRealtimeMonitor").c_str());
|
||||
//printf("%s \n", digi->ReadValue("/ch/0/par/Energy_Nbit").c_str());
|
||||
|
@ -123,7 +122,7 @@ int main(int argc, char* argv[]){
|
|||
|
||||
digi->ReadDigitizerSettings();
|
||||
|
||||
digi->SetPHADataFormat(0);
|
||||
digi->SetPHADataFormat(1);
|
||||
|
||||
//printf("0x%X \n", atoi(digi->ReadValue("/par/AcquisitionStatus").c_str()) & 0x3F );
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user