From e9d6f2a312221d26ceca135779113339b786f334 Mon Sep 17 00:00:00 2001 From: "Ryan@WorkStation" Date: Tue, 26 Sep 2023 10:41:24 -0400 Subject: [PATCH] rename Eevnt class to Hit --- ClassDigitizer2Gen.cpp | 364 ++++++++++++++++++++--------------------- ClassDigitizer2Gen.h | 4 +- CustomThreads.h | 2 +- Event.h => Hit.h | 11 +- SOLARIS_Qt6_DAQ.pro | 2 +- SolReader.h | 130 +++++++-------- makeTest | 2 +- scope.cpp | 10 +- script.C | 38 ++--- windowID.cpp | 94 ----------- 10 files changed, 282 insertions(+), 375 deletions(-) rename Event.h => Hit.h (99%) delete mode 100644 windowID.cpp diff --git a/ClassDigitizer2Gen.cpp b/ClassDigitizer2Gen.cpp index f3fbfa6..d43ffda 100644 --- a/ClassDigitizer2Gen.cpp +++ b/ClassDigitizer2Gen.cpp @@ -33,7 +33,7 @@ void Digitizer2Gen::Initialization(){ outFile = NULL; outFileSize = 0; - evt = NULL; + hit = NULL; acqON = false; @@ -357,9 +357,9 @@ void Digitizer2Gen::SetDataFormat(unsigned short dataFormat){ } } - if( evt ) delete evt; - evt = new Event(); - evt->SetDataType(dataFormat, FPGAType); + if( hit ) delete hit; + hit = new Hit(); + hit->SetDataType(dataFormat, FPGAType); dataStartIndetifier = 0xAA00 + dataFormat; if(FPGAType == DPPType::PSD ) dataStartIndetifier += 0x0010; @@ -592,177 +592,177 @@ void Digitizer2Gen::PrintStat(){ } int Digitizer2Gen::ReadData(){ - //printf("Digitizer2Gen::%s, DPP : %s, dataFormat : %d \n", __func__, FPGAType.c_str(), evt->dataType); + //printf("Digitizer2Gen::%s, DPP : %s, dataFormat : %d \n", __func__, FPGAType.c_str(), hit->dataType); if( FPGAType != DPPType::PHA && FPGAType != DPPType::PSD ) return -404; - if( evt->dataType == DataFormat::ALL ){ + if( hit->dataType == DataFormat::ALL ){ if( FPGAType == DPPType::PHA ){ ret = CAEN_FELib_ReadData(ep_handle, 100, - &evt->channel, - &evt->timestamp, - &evt->fine_timestamp, - &evt->energy, - evt->analog_probes[0], - evt->analog_probes[1], - evt->digital_probes[0], - evt->digital_probes[1], - evt->digital_probes[2], - evt->digital_probes[3], - &evt->analog_probes_type[0], - &evt->analog_probes_type[1], - &evt->digital_probes_type[0], - &evt->digital_probes_type[1], - &evt->digital_probes_type[2], - &evt->digital_probes_type[3], - &evt->traceLenght, - &evt->flags_low_priority, - &evt->flags_high_priority, - &evt->trigger_threashold, - &evt->downSampling, - &evt->board_fail, - &evt->flush, - &evt->aggCounter, - &evt->event_size + &hit->channel, + &hit->timestamp, + &hit->fine_timestamp, + &hit->energy, + hit->analog_probes[0], + hit->analog_probes[1], + hit->digital_probes[0], + hit->digital_probes[1], + hit->digital_probes[2], + hit->digital_probes[3], + &hit->analog_probes_type[0], + &hit->analog_probes_type[1], + &hit->digital_probes_type[0], + &hit->digital_probes_type[1], + &hit->digital_probes_type[2], + &hit->digital_probes_type[3], + &hit->traceLenght, + &hit->flags_low_priority, + &hit->flags_high_priority, + &hit->trigger_threashold, + &hit->downSampling, + &hit->board_fail, + &hit->flush, + &hit->aggCounter, + &hit->event_size ); - //printf("ch:%02d, trace Length %ld \n", evt->channel, evt->traceLenght); + //printf("ch:%02d, trace Length %ld \n", hit->channel, hit->traceLenght); }else{ ret = CAEN_FELib_ReadData(ep_handle, 100, - &evt->channel, - &evt->timestamp, - &evt->fine_timestamp, - &evt->energy, - &evt->energy_short, - evt->analog_probes[0], - evt->analog_probes[1], - evt->digital_probes[0], - evt->digital_probes[1], - evt->digital_probes[2], - evt->digital_probes[3], - &evt->analog_probes_type[0], - &evt->analog_probes_type[1], - &evt->digital_probes_type[0], - &evt->digital_probes_type[1], - &evt->digital_probes_type[2], - &evt->digital_probes_type[3], - &evt->traceLenght, - &evt->flags_low_priority, - &evt->flags_high_priority, - &evt->trigger_threashold, - &evt->downSampling, - &evt->board_fail, - &evt->flush, - &evt->aggCounter, - &evt->event_size + &hit->channel, + &hit->timestamp, + &hit->fine_timestamp, + &hit->energy, + &hit->energy_short, + hit->analog_probes[0], + hit->analog_probes[1], + hit->digital_probes[0], + hit->digital_probes[1], + hit->digital_probes[2], + hit->digital_probes[3], + &hit->analog_probes_type[0], + &hit->analog_probes_type[1], + &hit->digital_probes_type[0], + &hit->digital_probes_type[1], + &hit->digital_probes_type[2], + &hit->digital_probes_type[3], + &hit->traceLenght, + &hit->flags_low_priority, + &hit->flags_high_priority, + &hit->trigger_threashold, + &hit->downSampling, + &hit->board_fail, + &hit->flush, + &hit->aggCounter, + &hit->event_size ); - //printf("ch:%02d, energy: %d, trace Length %ld \n", evt->channel, evt->energy, evt->traceLenght); + //printf("ch:%02d, energy: %d, trace Length %ld \n", hit->channel, hit->energy, hit->traceLenght); } - evt->isTraceAllZero = false; + hit->isTraceAllZero = false; - }else if( evt->dataType == DataFormat::OneTrace){ + }else if( hit->dataType == DataFormat::OneTrace){ if( FPGAType == DPPType::PHA ){ ret = CAEN_FELib_ReadData(ep_handle, 100, - &evt->channel, - &evt->timestamp, - &evt->fine_timestamp, - &evt->energy, - evt->analog_probes[0], - &evt->analog_probes_type[0], - &evt->traceLenght, - &evt->flags_low_priority, - &evt->flags_high_priority, - &evt->trigger_threashold, - &evt->downSampling, - &evt->board_fail, - &evt->flush, - &evt->aggCounter, - &evt->event_size + &hit->channel, + &hit->timestamp, + &hit->fine_timestamp, + &hit->energy, + hit->analog_probes[0], + &hit->analog_probes_type[0], + &hit->traceLenght, + &hit->flags_low_priority, + &hit->flags_high_priority, + &hit->trigger_threashold, + &hit->downSampling, + &hit->board_fail, + &hit->flush, + &hit->aggCounter, + &hit->event_size ); }else{ ret = CAEN_FELib_ReadData(ep_handle, 100, - &evt->channel, - &evt->timestamp, - &evt->fine_timestamp, - &evt->energy, - &evt->energy_short, - evt->analog_probes[0], - &evt->analog_probes_type[0], - &evt->traceLenght, - &evt->flags_low_priority, - &evt->flags_high_priority, - &evt->trigger_threashold, - &evt->downSampling, - &evt->board_fail, - &evt->flush, - &evt->aggCounter, - &evt->event_size + &hit->channel, + &hit->timestamp, + &hit->fine_timestamp, + &hit->energy, + &hit->energy_short, + hit->analog_probes[0], + &hit->analog_probes_type[0], + &hit->traceLenght, + &hit->flags_low_priority, + &hit->flags_high_priority, + &hit->trigger_threashold, + &hit->downSampling, + &hit->board_fail, + &hit->flush, + &hit->aggCounter, + &hit->event_size ); } - evt->isTraceAllZero = false; + hit->isTraceAllZero = false; - }else if( evt->dataType == DataFormat::NoTrace){ + }else if( hit->dataType == DataFormat::NoTrace){ if( FPGAType == DPPType::PHA ){ ret = CAEN_FELib_ReadData(ep_handle, 100, - &evt->channel, - &evt->timestamp, - &evt->fine_timestamp, - &evt->energy, - &evt->flags_low_priority, - &evt->flags_high_priority, - &evt->trigger_threashold, - &evt->downSampling, - &evt->board_fail, - &evt->flush, - &evt->aggCounter, - &evt->event_size + &hit->channel, + &hit->timestamp, + &hit->fine_timestamp, + &hit->energy, + &hit->flags_low_priority, + &hit->flags_high_priority, + &hit->trigger_threashold, + &hit->downSampling, + &hit->board_fail, + &hit->flush, + &hit->aggCounter, + &hit->event_size ); }else{ ret = CAEN_FELib_ReadData(ep_handle, 100, - &evt->channel, - &evt->timestamp, - &evt->fine_timestamp, - &evt->energy, - &evt->energy_short, - &evt->flags_low_priority, - &evt->flags_high_priority, - &evt->trigger_threashold, - &evt->downSampling, - &evt->board_fail, - &evt->flush, - &evt->aggCounter, - &evt->event_size + &hit->channel, + &hit->timestamp, + &hit->fine_timestamp, + &hit->energy, + &hit->energy_short, + &hit->flags_low_priority, + &hit->flags_high_priority, + &hit->trigger_threashold, + &hit->downSampling, + &hit->board_fail, + &hit->flush, + &hit->aggCounter, + &hit->event_size ); } - evt->isTraceAllZero = true; + hit->isTraceAllZero = true; - }else if( evt->dataType == DataFormat::Minimum){ + }else if( hit->dataType == DataFormat::Minimum){ if( FPGAType == DPPType::PHA ){ ret = CAEN_FELib_ReadData(ep_handle, 100, - &evt->channel, - &evt->timestamp, - &evt->energy + &hit->channel, + &hit->timestamp, + &hit->energy ); }else{ ret = CAEN_FELib_ReadData(ep_handle, 100, - &evt->channel, - &evt->timestamp, - &evt->energy, - &evt->energy_short + &hit->channel, + &hit->timestamp, + &hit->energy, + &hit->energy_short ); } - evt->isTraceAllZero = true; - }else if( evt->dataType == DataFormat::RAW){ - ret = CAEN_FELib_ReadData(ep_handle, 100, evt->data, &evt->dataSize, &evt->n_events ); + hit->isTraceAllZero = true; + }else if( hit->dataType == DataFormat::RAW){ + ret = CAEN_FELib_ReadData(ep_handle, 100, hit->data, &hit->dataSize, &hit->n_events ); //printf("data size: %lu byte\n", evt.dataSize); - evt->isTraceAllZero = true; //assume no trace, as the trace need to be extracted. + hit->isTraceAllZero = true; //assume no trace, as the trace need to be extracted. }else{ return CAEN_FELib_UNKNOWN; } @@ -804,61 +804,61 @@ void Digitizer2Gen::SaveDataToFile(){ outFile = fopen(outFileName, "wb"); //overwrite binary } - if( evt->dataType == DataFormat::ALL){ + if( hit->dataType == DataFormat::ALL){ fwrite(&dataStartIndetifier, 2, 1, outFile); - fwrite(&evt->channel, 1, 1, outFile); - fwrite(&evt->energy, 2, 1, outFile); - if( FPGAType == DPPType::PSD ) fwrite(&evt->energy_short, 2, 1, outFile); - fwrite(&evt->timestamp, 6, 1, outFile); - fwrite(&evt->fine_timestamp, 2, 1, outFile); - fwrite(&evt->flags_high_priority, 1, 1, outFile); - fwrite(&evt->flags_low_priority, 2, 1, outFile); - fwrite(&evt->downSampling, 1, 1, outFile); - fwrite(&evt->board_fail, 1, 1, outFile); - fwrite(&evt->flush, 1, 1, outFile); - fwrite(&evt->trigger_threashold, 2, 1, outFile); - fwrite(&evt->event_size, 8, 1, outFile); - fwrite(&evt->aggCounter, 4, 1, outFile); - fwrite(&evt->traceLenght, 8, 1, outFile); - fwrite(evt->analog_probes_type, 2, 1, outFile); - fwrite(evt->digital_probes_type, 4, 1, outFile); - fwrite(evt->analog_probes[0], evt->traceLenght*4, 1, outFile); - fwrite(evt->analog_probes[1], evt->traceLenght*4, 1, outFile); - fwrite(evt->digital_probes[0], evt->traceLenght, 1, outFile); - fwrite(evt->digital_probes[1], evt->traceLenght, 1, outFile); - fwrite(evt->digital_probes[2], evt->traceLenght, 1, outFile); - fwrite(evt->digital_probes[3], evt->traceLenght, 1, outFile); - }else if( evt->dataType == DataFormat::OneTrace){ + fwrite(&hit->channel, 1, 1, outFile); + fwrite(&hit->energy, 2, 1, outFile); + if( FPGAType == DPPType::PSD ) fwrite(&hit->energy_short, 2, 1, outFile); + fwrite(&hit->timestamp, 6, 1, outFile); + fwrite(&hit->fine_timestamp, 2, 1, outFile); + fwrite(&hit->flags_high_priority, 1, 1, outFile); + fwrite(&hit->flags_low_priority, 2, 1, outFile); + fwrite(&hit->downSampling, 1, 1, outFile); + fwrite(&hit->board_fail, 1, 1, outFile); + fwrite(&hit->flush, 1, 1, outFile); + fwrite(&hit->trigger_threashold, 2, 1, outFile); + fwrite(&hit->event_size, 8, 1, outFile); + fwrite(&hit->aggCounter, 4, 1, outFile); + fwrite(&hit->traceLenght, 8, 1, outFile); + fwrite(hit->analog_probes_type, 2, 1, outFile); + fwrite(hit->digital_probes_type, 4, 1, outFile); + fwrite(hit->analog_probes[0], hit->traceLenght*4, 1, outFile); + fwrite(hit->analog_probes[1], hit->traceLenght*4, 1, outFile); + fwrite(hit->digital_probes[0], hit->traceLenght, 1, outFile); + fwrite(hit->digital_probes[1], hit->traceLenght, 1, outFile); + fwrite(hit->digital_probes[2], hit->traceLenght, 1, outFile); + fwrite(hit->digital_probes[3], hit->traceLenght, 1, outFile); + }else if( hit->dataType == DataFormat::OneTrace){ fwrite(&dataStartIndetifier, 2, 1, outFile); - fwrite(&evt->channel, 1, 1, outFile); - fwrite(&evt->energy, 2, 1, outFile); - if( FPGAType == DPPType::PSD ) fwrite(&evt->energy_short, 2, 1, outFile); - fwrite(&evt->timestamp, 6, 1, outFile); - fwrite(&evt->fine_timestamp, 2, 1, outFile); - fwrite(&evt->flags_high_priority, 1, 1, outFile); - fwrite(&evt->flags_low_priority, 2, 1, outFile); - fwrite(&evt->traceLenght, 8, 1, outFile); - fwrite(&evt->analog_probes_type[0], 1, 1, outFile); - fwrite(evt->analog_probes[0], evt->traceLenght*4, 1, outFile); - }else if( evt->dataType == DataFormat::NoTrace ){ + fwrite(&hit->channel, 1, 1, outFile); + fwrite(&hit->energy, 2, 1, outFile); + if( FPGAType == DPPType::PSD ) fwrite(&hit->energy_short, 2, 1, outFile); + fwrite(&hit->timestamp, 6, 1, outFile); + fwrite(&hit->fine_timestamp, 2, 1, outFile); + fwrite(&hit->flags_high_priority, 1, 1, outFile); + fwrite(&hit->flags_low_priority, 2, 1, outFile); + fwrite(&hit->traceLenght, 8, 1, outFile); + fwrite(&hit->analog_probes_type[0], 1, 1, outFile); + fwrite(hit->analog_probes[0], hit->traceLenght*4, 1, outFile); + }else if( hit->dataType == DataFormat::NoTrace ){ fwrite(&dataStartIndetifier, 2, 1, outFile); - fwrite(&evt->channel, 1, 1, outFile); - fwrite(&evt->energy, 2, 1, outFile); - if( FPGAType == DPPType::PSD ) fwrite(&evt->energy_short, 2, 1, outFile); - fwrite(&evt->timestamp, 6, 1, outFile); - fwrite(&evt->fine_timestamp, 2, 1, outFile); - fwrite(&evt->flags_high_priority, 1, 1, outFile); - fwrite(&evt->flags_low_priority, 2, 1, outFile); - }else if( evt->dataType == DataFormat::Minimum ){ + fwrite(&hit->channel, 1, 1, outFile); + fwrite(&hit->energy, 2, 1, outFile); + if( FPGAType == DPPType::PSD ) fwrite(&hit->energy_short, 2, 1, outFile); + fwrite(&hit->timestamp, 6, 1, outFile); + fwrite(&hit->fine_timestamp, 2, 1, outFile); + fwrite(&hit->flags_high_priority, 1, 1, outFile); + fwrite(&hit->flags_low_priority, 2, 1, outFile); + }else if( hit->dataType == DataFormat::Minimum ){ fwrite(&dataStartIndetifier, 2, 1, outFile); - fwrite(&evt->channel, 1, 1, outFile); - fwrite(&evt->energy, 2, 1, outFile); - if( FPGAType == DPPType::PSD ) fwrite(&evt->energy_short, 2, 1, outFile); - fwrite(&evt->timestamp, 6, 1, outFile); - }else if( evt->dataType == DataFormat::RAW){ + fwrite(&hit->channel, 1, 1, outFile); + fwrite(&hit->energy, 2, 1, outFile); + if( FPGAType == DPPType::PSD ) fwrite(&hit->energy_short, 2, 1, outFile); + fwrite(&hit->timestamp, 6, 1, outFile); + }else if( hit->dataType == DataFormat::RAW){ fwrite(&dataStartIndetifier, 2, 1, outFile); - fwrite(&evt->dataSize, 8, 1, outFile); - fwrite(evt->data, evt->dataSize, 1, outFile); + fwrite(&hit->dataSize, 8, 1, outFile); + fwrite(hit->data, hit->dataSize, 1, outFile); } outFileSize = ftell(outFile); // unsigned int = Max ~4GB diff --git a/ClassDigitizer2Gen.h b/ClassDigitizer2Gen.h index 64a1434..8c2a5c8 100644 --- a/ClassDigitizer2Gen.h +++ b/ClassDigitizer2Gen.h @@ -7,7 +7,7 @@ #include #include -#include "Event.h" +#include "Hit.h" #define MaxOutFileSize 2*1024*1024*1024 //2GB //#define MaxOutFileSize 20*1024*1024 //20MB @@ -125,7 +125,7 @@ class Digitizer2Gen { unsigned short GetCh2ns() const {return ch2ns;} uint64_t GetHandle() const {return handle;} - Event *evt; // should be evt[MaxNumber], when full or stopACQ, save into file + Hit *hit; // should be hit[MaxNumber], when full or stopACQ, save into file void OpenOutFile(std::string fileName, const char * mode = "wb"); //overwrite binary void CloseOutFile(); void SaveDataToFile(); diff --git a/CustomThreads.h b/CustomThreads.h index 9e27270..4f2c823 100644 --- a/CustomThreads.h +++ b/CustomThreads.h @@ -40,7 +40,7 @@ public: break; }else{ //digi->ErrorMsg("ReadDataLoop()"); - //digi->evt->ClearTrace(); + digi->hit->ClearTrace(); } if( isSaveData ){ diff --git a/Event.h b/Hit.h similarity index 99% rename from Event.h rename to Hit.h index 2f63a4b..948a1de 100644 --- a/Event.h +++ b/Hit.h @@ -1,9 +1,10 @@ -#ifndef EVENT_H -#define EVENT_H +#ifndef HIT_H +#define HIT_H #include #include #include +#include #define MaxTraceLenght 8100 @@ -24,7 +25,7 @@ namespace DPPType{ }; -class Event { +class Hit { public: unsigned short dataType; @@ -57,11 +58,11 @@ class Event { bool isTraceAllZero; - Event(){ + Hit(){ Init(); } - ~Event(){ + ~Hit(){ ClearMemory(); } diff --git a/SOLARIS_Qt6_DAQ.pro b/SOLARIS_Qt6_DAQ.pro index f9f03eb..0b7442f 100644 --- a/SOLARIS_Qt6_DAQ.pro +++ b/SOLARIS_Qt6_DAQ.pro @@ -20,7 +20,7 @@ LIBS += -lcurl -lCAEN_FELib -lX11 # Input HEADERS += ClassDigitizer2Gen.h \ - Event.h \ + Hit.h \ influxdb.h \ mainwindow.h \ digiSettingsPanel.h \ diff --git a/SolReader.h b/SolReader.h index 5da393e..64230ed 100644 --- a/SolReader.h +++ b/SolReader.h @@ -8,7 +8,7 @@ #include #include // time in nano-sec -#include "Event.h" +#include "Hit.h" class SolReader { private: @@ -43,7 +43,7 @@ class SolReader { void RewindFile(); - Event * evt; + Hit * hit; }; @@ -52,7 +52,7 @@ void SolReader::init(){ numBlock = 0; filePos = 0; totNumBlock = 0; - evt = new Event(); + hit = new Hit(); isScanned = false; @@ -67,12 +67,12 @@ SolReader::SolReader(){ SolReader::SolReader(std::string fileName, unsigned short dataType = 0){ init(); OpenFile(fileName); - evt->SetDataType(dataType, DPPType::PHA); + hit->SetDataType(dataType, DPPType::PHA); } SolReader::~SolReader(){ if( !inFile ) fclose(inFile); - delete evt; + delete hit; } inline void SolReader::OpenFile(std::string fileName){ @@ -113,88 +113,88 @@ inline int SolReader::ReadNextBlock(int opt){ } if( ( blockStartIdentifier & 0xF ) == DataFormat::RAW ){ - evt->SetDataType(DataFormat::RAW, ((blockStartIdentifier >> 1) & 0xF) == 0 ? DPPType::PHA : DPPType::PSD); + hit->SetDataType(DataFormat::RAW, ((blockStartIdentifier >> 1) & 0xF) == 0 ? DPPType::PHA : DPPType::PSD); } - evt->dataType = blockStartIdentifier & 0xF; - evt->DPPType = ((blockStartIdentifier >> 1) & 0xF) == 0 ? DPPType::PHA : DPPType::PSD; + hit->dataType = blockStartIdentifier & 0xF; + hit->DPPType = ((blockStartIdentifier >> 1) & 0xF) == 0 ? DPPType::PHA : DPPType::PSD; - if( evt->dataType == DataFormat::ALL){ + if( hit->dataType == DataFormat::ALL){ if( opt == 0 ){ - fread(&evt->channel, 1, 1, inFile); - fread(&evt->energy, 2, 1, inFile); - if( evt->DPPType == DPPType::PSD ) fread(&evt->energy_short, 2, 1, inFile); - fread(&evt->timestamp, 6, 1, inFile); - fread(&evt->fine_timestamp, 2, 1, inFile); - fread(&evt->flags_high_priority, 1, 1, inFile); - fread(&evt->flags_low_priority, 2, 1, inFile); - fread(&evt->downSampling, 1, 1, inFile); - fread(&evt->board_fail, 1, 1, inFile); - fread(&evt->flush, 1, 1, inFile); - fread(&evt->trigger_threashold, 2, 1, inFile); - fread(&evt->event_size, 8, 1, inFile); - fread(&evt->aggCounter, 4, 1, inFile); + fread(&hit->channel, 1, 1, inFile); + fread(&hit->energy, 2, 1, inFile); + if( hit->DPPType == DPPType::PSD ) fread(&hit->energy_short, 2, 1, inFile); + fread(&hit->timestamp, 6, 1, inFile); + fread(&hit->fine_timestamp, 2, 1, inFile); + fread(&hit->flags_high_priority, 1, 1, inFile); + fread(&hit->flags_low_priority, 2, 1, inFile); + fread(&hit->downSampling, 1, 1, inFile); + fread(&hit->board_fail, 1, 1, inFile); + fread(&hit->flush, 1, 1, inFile); + fread(&hit->trigger_threashold, 2, 1, inFile); + fread(&hit->event_size, 8, 1, inFile); + fread(&hit->aggCounter, 4, 1, inFile); }else{ - fseek(inFile, evt->DPPType == DPPType::PHA ? 31 : 33, SEEK_CUR); + fseek(inFile, hit->DPPType == DPPType::PHA ? 31 : 33, SEEK_CUR); } - fread(&evt->traceLenght, 8, 1, inFile); + fread(&hit->traceLenght, 8, 1, inFile); if( opt == 0){ - fread(evt->analog_probes_type, 2, 1, inFile); - fread(evt->digital_probes_type, 4, 1, inFile); - fread(evt->analog_probes[0], evt->traceLenght*4, 1, inFile); - fread(evt->analog_probes[1], evt->traceLenght*4, 1, inFile); - fread(evt->digital_probes[0], evt->traceLenght, 1, inFile); - fread(evt->digital_probes[1], evt->traceLenght, 1, inFile); - fread(evt->digital_probes[2], evt->traceLenght, 1, inFile); - fread(evt->digital_probes[3], evt->traceLenght, 1, inFile); + fread(hit->analog_probes_type, 2, 1, inFile); + fread(hit->digital_probes_type, 4, 1, inFile); + fread(hit->analog_probes[0], hit->traceLenght*4, 1, inFile); + fread(hit->analog_probes[1], hit->traceLenght*4, 1, inFile); + fread(hit->digital_probes[0], hit->traceLenght, 1, inFile); + fread(hit->digital_probes[1], hit->traceLenght, 1, inFile); + fread(hit->digital_probes[2], hit->traceLenght, 1, inFile); + fread(hit->digital_probes[3], hit->traceLenght, 1, inFile); }else{ - fseek(inFile, 6 + evt->traceLenght*(12), SEEK_CUR); + fseek(inFile, 6 + hit->traceLenght*(12), SEEK_CUR); } - }else if( evt->dataType == DataFormat::OneTrace){ + }else if( hit->dataType == DataFormat::OneTrace){ if( opt == 0 ){ - fread(&evt->channel, 1, 1, inFile); - fread(&evt->energy, 2, 1, inFile); - if( evt->DPPType == DPPType::PSD ) fread(&evt->energy_short, 2, 1, inFile); - fread(&evt->timestamp, 6, 1, inFile); - fread(&evt->fine_timestamp, 2, 1, inFile); - fread(&evt->flags_high_priority, 1, 1, inFile); - fread(&evt->flags_low_priority, 2, 1, inFile); + fread(&hit->channel, 1, 1, inFile); + fread(&hit->energy, 2, 1, inFile); + if( hit->DPPType == DPPType::PSD ) fread(&hit->energy_short, 2, 1, inFile); + fread(&hit->timestamp, 6, 1, inFile); + fread(&hit->fine_timestamp, 2, 1, inFile); + fread(&hit->flags_high_priority, 1, 1, inFile); + fread(&hit->flags_low_priority, 2, 1, inFile); }else{ - fseek(inFile, evt->DPPType == DPPType::PHA ? 14 : 16, SEEK_CUR); + fseek(inFile, hit->DPPType == DPPType::PHA ? 14 : 16, SEEK_CUR); } - fread(&evt->traceLenght, 8, 1, inFile); + fread(&hit->traceLenght, 8, 1, inFile); if( opt == 0){ - fread(&evt->analog_probes_type[0], 1, 1, inFile); - fread(evt->analog_probes[0], evt->traceLenght*4, 1, inFile); + fread(&hit->analog_probes_type[0], 1, 1, inFile); + fread(hit->analog_probes[0], hit->traceLenght*4, 1, inFile); }else{ - fseek(inFile, 1 + evt->traceLenght*4, SEEK_CUR); + fseek(inFile, 1 + hit->traceLenght*4, SEEK_CUR); } - }else if( evt->dataType == DataFormat::NoTrace){ + }else if( hit->dataType == DataFormat::NoTrace){ if( opt == 0 ){ - fread(&evt->channel, 1, 1, inFile); - fread(&evt->energy, 2, 1, inFile); - if( evt->DPPType == DPPType::PSD ) fread(&evt->energy_short, 2, 1, inFile); - fread(&evt->timestamp, 6, 1, inFile); - fread(&evt->fine_timestamp, 2, 1, inFile); - fread(&evt->flags_high_priority, 1, 1, inFile); - fread(&evt->flags_low_priority, 2, 1, inFile); + fread(&hit->channel, 1, 1, inFile); + fread(&hit->energy, 2, 1, inFile); + if( hit->DPPType == DPPType::PSD ) fread(&hit->energy_short, 2, 1, inFile); + fread(&hit->timestamp, 6, 1, inFile); + fread(&hit->fine_timestamp, 2, 1, inFile); + fread(&hit->flags_high_priority, 1, 1, inFile); + fread(&hit->flags_low_priority, 2, 1, inFile); }else{ - fseek(inFile, evt->DPPType == DPPType::PHA ? 14 : 16, SEEK_CUR); + fseek(inFile, hit->DPPType == DPPType::PHA ? 14 : 16, SEEK_CUR); } - }else if( evt->dataType == DataFormat::Minimum){ + }else if( hit->dataType == DataFormat::Minimum){ if( opt == 0 ){ - fread(&evt->channel, 1, 1, inFile); - fread(&evt->energy, 2, 1, inFile); - if( evt->DPPType == DPPType::PSD ) fread(&evt->energy_short, 2, 1, inFile); - fread(&evt->timestamp, 6, 1, inFile); + fread(&hit->channel, 1, 1, inFile); + fread(&hit->energy, 2, 1, inFile); + if( hit->DPPType == DPPType::PSD ) fread(&hit->energy_short, 2, 1, inFile); + fread(&hit->timestamp, 6, 1, inFile); }else{ - fseek(inFile, evt->DPPType == DPPType::PHA ? 9 : 11, SEEK_CUR); + fseek(inFile, hit->DPPType == DPPType::PHA ? 9 : 11, SEEK_CUR); } - }else if( evt->dataType == DataFormat::RAW){ - fread(&evt->dataSize, 8, 1, inFile); + }else if( hit->dataType == DataFormat::RAW){ + fread(&hit->dataSize, 8, 1, inFile); if( opt == 0){ - fread(evt->data, evt->dataSize, 1, inFile); + fread(hit->data, hit->dataSize, 1, inFile); }else{ - fseek(inFile, evt->dataSize, SEEK_CUR); + fseek(inFile, hit->dataSize, SEEK_CUR); } } diff --git a/makeTest b/makeTest index 00cf516..3789401 100644 --- a/makeTest +++ b/makeTest @@ -15,7 +15,7 @@ test : test.cpp ClassDigitizer2Gen.o influxdb.o @echo "------- test" $(CC) $(COPTS) $(OBJS) -o test test.cpp $(CAENLIBS) $(CURLLIBS) # -ClassDigitizer2Gen.o : ClassDigitizer2Gen.cpp ClassDigitizer2Gen.h Event.h DigiParameters.h +ClassDigitizer2Gen.o : ClassDigitizer2Gen.cpp ClassDigitizer2Gen.h Hit.h DigiParameters.h @echo "------- ClassDigitizer2Gen.o" $(CC) $(COPTS) -c ClassDigitizer2Gen.cpp $(CAENLIBS) # diff --git a/scope.cpp b/scope.cpp index cf24f07..77220d2 100644 --- a/scope.cpp +++ b/scope.cpp @@ -662,7 +662,7 @@ void Scope::UpdateScope(){ std::string haha = digi[iDigi]->ReadValue(PHA::CH::SelfTrgRate, ch); leTriggerRate->setText(QString::fromStdString(haha)); - //unsigned int traceLength = qMin((int) digi[iDigi]->evt->traceLenght, MaxDisplayTraceDataLength); + //unsigned int traceLength = qMin((int) digi[iDigi]->hit->traceLenght, MaxDisplayTraceDataLength); unsigned int traceLength = qMin( atoi(digi[iDigi]->GetSettingValue(PHA::CH::RecordLength, ch).c_str())/sample2ns, MaxDisplayTraceDataLength ); if( atoi(haha.c_str()) == 0 ) { @@ -677,19 +677,19 @@ void Scope::UpdateScope(){ return; } - //printf("%s, traceLength : %d , %d\n", __func__, traceLength, digi[iDigi]->evt->analog_probes[0][10]); + //printf("%s, traceLength : %d , %d\n", __func__, traceLength, digi[iDigi]->hit->analog_probes[0][10]); for( int j = 0; j < 2; j++) { QVector points; - for( unsigned int i = 0 ; i < traceLength; i++) points.append(QPointF(sample2ns * i , digi[iDigi]->evt->analog_probes[j][i])); + for( unsigned int i = 0 ; i < traceLength; i++) points.append(QPointF(sample2ns * i , digi[iDigi]->hit->analog_probes[j][i])); dataTrace[j]->replace(points); } for( int j = 0; j < 4; j++) { QVector points; - for( unsigned int i = 0 ; i < traceLength; i++) points.append(QPointF(sample2ns * i , (j+1)*5000 + 4000*digi[iDigi]->evt->digital_probes[j][i])); + for( unsigned int i = 0 ; i < traceLength; i++) points.append(QPointF(sample2ns * i , (j+1)*5000 + 4000*digi[iDigi]->hit->digital_probes[j][i])); dataTrace[j+2]->replace(points); } - //digi[iDigi]->evt->ClearTrace(); + //digi[iDigi]->hit->ClearTrace(); digiMTX[iDigi].unlock(); plot->axes(Qt::Horizontal).first()->setRange(0, sample2ns * traceLength); diff --git a/script.C b/script.C index 503ec06..b953462 100644 --- a/script.C +++ b/script.C @@ -10,7 +10,7 @@ void script(std::string fileName){ SolReader * reader = new SolReader(fileName); - Event * evt = reader->evt; + Hit * hit = reader->hit; printf("----------file size: %u Byte\n", reader->GetFileSize()); @@ -20,9 +20,9 @@ void script(std::string fileName){ unsigned long startTime, endTime; reader->ReadBlock(0); - startTime = evt->timestamp; + startTime = hit->timestamp; reader->ReadBlock(reader->GetTotalNumBlock() - 1); - endTime = evt->timestamp; + endTime = hit->timestamp; double duration = double(endTime - startTime)*8./1e9; printf("============== %lu ns = %.4f sec.\n", (endTime - startTime)*8, duration); @@ -52,23 +52,23 @@ void script(std::string fileName){ printf("########################## nBlock : %u, %u/%u\n", reader->GetNumBlock(), reader->GetFilePos(), reader->GetFileSize()); - evt->PrintAll(); - //evt->PrintAllTrace(); + hit->PrintAll(); + //hit->PrintAllTrace(); } - hid->Fill(evt->channel); - if( evt->channel == 0 ) h1->Fill(evt->timestamp*8/1e9); - h2->Fill(evt->timestamp*8/1e9, i); + hid->Fill(hit->channel); + if( hit->channel == 0 ) h1->Fill(hit->timestamp*8/1e9); + h2->Fill(hit->timestamp*8/1e9, i); if( i == 0){ - for( int i = 0; i < evt->traceLenght; i++){ - g1->AddPoint(i*8, evt->analog_probes[0][i]); - g2->AddPoint(i*8, evt->analog_probes[1][i]); - ga->AddPoint(i*8, 10000+5000*evt->digital_probes[0][i]); - gb->AddPoint(i*8, 20000+5000*evt->digital_probes[1][i]); - gc->AddPoint(i*8, 30000+5000*evt->digital_probes[2][i]); - gd->AddPoint(i*8, 40000+5000*evt->digital_probes[3][i]); + for( int i = 0; i < hit->traceLenght; i++){ + g1->AddPoint(i*8, hit->analog_probes[0][i]); + g2->AddPoint(i*8, hit->analog_probes[1][i]); + ga->AddPoint(i*8, 10000+5000*hit->digital_probes[0][i]); + gb->AddPoint(i*8, 20000+5000*hit->digital_probes[1][i]); + gc->AddPoint(i*8, 30000+5000*hit->digital_probes[2][i]); + gd->AddPoint(i*8, 40000+5000*hit->digital_probes[3][i]); } } } @@ -87,17 +87,17 @@ void script(std::string fileName){ gb->Draw("same"); gc->Draw("same"); gd->Draw("same"); - //printf("reader traceLength : %lu \n", evt->traceLenght); + //printf("reader traceLength : %lu \n", hit->traceLenght); /* - for( int i = 0; i < evt->traceLenght; i++){ + for( int i = 0; i < hit->traceLenght; i++){ - printf("%4d| %d\n", i, evt->analog_probes[0][i]); + printf("%4d| %d\n", i, hit->analog_probes[0][i]); } */ - evt = NULL; + hit = NULL; delete reader; } \ No newline at end of file diff --git a/windowID.cpp b/windowID.cpp deleted file mode 100644 index 2a9d624..0000000 --- a/windowID.cpp +++ /dev/null @@ -1,94 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include - -void saveScreenshot(Display* display, const Window window, const char* filename){ - - XWindowAttributes attrs; - XGetWindowAttributes(display, window, &attrs); - - printf("(x,y) :(%d, %d), (w,h) : (%d, %d) \n", attrs.x, attrs.y, attrs.width, attrs.height); - - int window_width = attrs.width; - int window_height = attrs.height; - - XImage *image = XGetImage(display, window, 0, 0, window_width, window_height, AllPlanes, ZPixmap); - - png_bytep *row_pointers = new png_bytep[window_height]; - for (int i = 0; i < window_height; i++) { - row_pointers[i] = (png_bytep)(image->data + i * image->bytes_per_line); - } - - FILE *png_file = fopen(filename, "w"); - png_structp png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); - png_infop info_ptr = png_create_info_struct(png_ptr); - png_init_io(png_ptr, png_file); - png_set_IHDR(png_ptr, info_ptr, window_width, window_height, 8, PNG_COLOR_TYPE_RGBA, PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE); - png_write_info(png_ptr, info_ptr); - png_write_image(png_ptr, row_pointers); - png_write_end(png_ptr, NULL); - png_destroy_write_struct(&png_ptr, &info_ptr); - fclose(png_file); - - XFree(image->data); - -} - -int main(int argc, char* argv[]){ - - Window screenID; - if( argc > 1){ - screenID = atoi(argv[1]); - } - - // Connect to the X server - Display *display = XOpenDisplay(nullptr); - - //============== show all windows ID - Window root = DefaultRootWindow(display); - - Window parent; - Window *children; - unsigned int numChildren; - Status status = XQueryTree(display, root, &root, &parent, &children, &numChildren); - - if (!status) { - std::cerr << "Failed to query window tree\n"; - return 1; - } - - for (unsigned int i = 0; i < numChildren; i++) { - XTextProperty windowName; - status = XGetWMName(display, children[i], &windowName); - if( i == 0 ) { - printf("%12s | %12s \n", "Window ID", "Name"); - printf("--------------+--------------------------------\n"); - } - if (status) { - char **list; - int count; - status = XmbTextPropertyToTextList(display, &windowName, &list, &count); - if (status >= Success && count > 0 && *list) { - printf("%12ld | %s \n", children[i], *list); - //std::cout << "Window ID: " << children[i] << ", Window Name: " << *list << "\n"; - XFreeStringList(list); - } - XFree(windowName.value); - } - } - XFree(children); - //================ end of show windows ID - - if( argc >1 ){ - saveScreenshot(display, screenID, "screenshot.png"); - printf("captured screenshot of windowID(%ld) as screenshot.png\n", screenID); - } - // Close the display connection - XCloseDisplay(display); - return 0; -} \ No newline at end of file