rename Eevnt class to Hit

This commit is contained in:
Ryan Tang 2023-09-26 10:41:24 -04:00
parent 2cc3056a9c
commit e9d6f2a312
10 changed files with 282 additions and 375 deletions

View File

@ -33,7 +33,7 @@ void Digitizer2Gen::Initialization(){
outFile = NULL; outFile = NULL;
outFileSize = 0; outFileSize = 0;
evt = NULL; hit = NULL;
acqON = false; acqON = false;
@ -357,9 +357,9 @@ void Digitizer2Gen::SetDataFormat(unsigned short dataFormat){
} }
} }
if( evt ) delete evt; if( hit ) delete hit;
evt = new Event(); hit = new Hit();
evt->SetDataType(dataFormat, FPGAType); hit->SetDataType(dataFormat, FPGAType);
dataStartIndetifier = 0xAA00 + dataFormat; dataStartIndetifier = 0xAA00 + dataFormat;
if(FPGAType == DPPType::PSD ) dataStartIndetifier += 0x0010; if(FPGAType == DPPType::PSD ) dataStartIndetifier += 0x0010;
@ -592,177 +592,177 @@ void Digitizer2Gen::PrintStat(){
} }
int Digitizer2Gen::ReadData(){ 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( FPGAType != DPPType::PHA && FPGAType != DPPType::PSD ) return -404;
if( evt->dataType == DataFormat::ALL ){ if( hit->dataType == DataFormat::ALL ){
if( FPGAType == DPPType::PHA ){ if( FPGAType == DPPType::PHA ){
ret = CAEN_FELib_ReadData(ep_handle, 100, ret = CAEN_FELib_ReadData(ep_handle, 100,
&evt->channel, &hit->channel,
&evt->timestamp, &hit->timestamp,
&evt->fine_timestamp, &hit->fine_timestamp,
&evt->energy, &hit->energy,
evt->analog_probes[0], hit->analog_probes[0],
evt->analog_probes[1], hit->analog_probes[1],
evt->digital_probes[0], hit->digital_probes[0],
evt->digital_probes[1], hit->digital_probes[1],
evt->digital_probes[2], hit->digital_probes[2],
evt->digital_probes[3], hit->digital_probes[3],
&evt->analog_probes_type[0], &hit->analog_probes_type[0],
&evt->analog_probes_type[1], &hit->analog_probes_type[1],
&evt->digital_probes_type[0], &hit->digital_probes_type[0],
&evt->digital_probes_type[1], &hit->digital_probes_type[1],
&evt->digital_probes_type[2], &hit->digital_probes_type[2],
&evt->digital_probes_type[3], &hit->digital_probes_type[3],
&evt->traceLenght, &hit->traceLenght,
&evt->flags_low_priority, &hit->flags_low_priority,
&evt->flags_high_priority, &hit->flags_high_priority,
&evt->trigger_threashold, &hit->trigger_threashold,
&evt->downSampling, &hit->downSampling,
&evt->board_fail, &hit->board_fail,
&evt->flush, &hit->flush,
&evt->aggCounter, &hit->aggCounter,
&evt->event_size &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{ }else{
ret = CAEN_FELib_ReadData(ep_handle, 100, ret = CAEN_FELib_ReadData(ep_handle, 100,
&evt->channel, &hit->channel,
&evt->timestamp, &hit->timestamp,
&evt->fine_timestamp, &hit->fine_timestamp,
&evt->energy, &hit->energy,
&evt->energy_short, &hit->energy_short,
evt->analog_probes[0], hit->analog_probes[0],
evt->analog_probes[1], hit->analog_probes[1],
evt->digital_probes[0], hit->digital_probes[0],
evt->digital_probes[1], hit->digital_probes[1],
evt->digital_probes[2], hit->digital_probes[2],
evt->digital_probes[3], hit->digital_probes[3],
&evt->analog_probes_type[0], &hit->analog_probes_type[0],
&evt->analog_probes_type[1], &hit->analog_probes_type[1],
&evt->digital_probes_type[0], &hit->digital_probes_type[0],
&evt->digital_probes_type[1], &hit->digital_probes_type[1],
&evt->digital_probes_type[2], &hit->digital_probes_type[2],
&evt->digital_probes_type[3], &hit->digital_probes_type[3],
&evt->traceLenght, &hit->traceLenght,
&evt->flags_low_priority, &hit->flags_low_priority,
&evt->flags_high_priority, &hit->flags_high_priority,
&evt->trigger_threashold, &hit->trigger_threashold,
&evt->downSampling, &hit->downSampling,
&evt->board_fail, &hit->board_fail,
&evt->flush, &hit->flush,
&evt->aggCounter, &hit->aggCounter,
&evt->event_size &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 ){ if( FPGAType == DPPType::PHA ){
ret = CAEN_FELib_ReadData(ep_handle, 100, ret = CAEN_FELib_ReadData(ep_handle, 100,
&evt->channel, &hit->channel,
&evt->timestamp, &hit->timestamp,
&evt->fine_timestamp, &hit->fine_timestamp,
&evt->energy, &hit->energy,
evt->analog_probes[0], hit->analog_probes[0],
&evt->analog_probes_type[0], &hit->analog_probes_type[0],
&evt->traceLenght, &hit->traceLenght,
&evt->flags_low_priority, &hit->flags_low_priority,
&evt->flags_high_priority, &hit->flags_high_priority,
&evt->trigger_threashold, &hit->trigger_threashold,
&evt->downSampling, &hit->downSampling,
&evt->board_fail, &hit->board_fail,
&evt->flush, &hit->flush,
&evt->aggCounter, &hit->aggCounter,
&evt->event_size &hit->event_size
); );
}else{ }else{
ret = CAEN_FELib_ReadData(ep_handle, 100, ret = CAEN_FELib_ReadData(ep_handle, 100,
&evt->channel, &hit->channel,
&evt->timestamp, &hit->timestamp,
&evt->fine_timestamp, &hit->fine_timestamp,
&evt->energy, &hit->energy,
&evt->energy_short, &hit->energy_short,
evt->analog_probes[0], hit->analog_probes[0],
&evt->analog_probes_type[0], &hit->analog_probes_type[0],
&evt->traceLenght, &hit->traceLenght,
&evt->flags_low_priority, &hit->flags_low_priority,
&evt->flags_high_priority, &hit->flags_high_priority,
&evt->trigger_threashold, &hit->trigger_threashold,
&evt->downSampling, &hit->downSampling,
&evt->board_fail, &hit->board_fail,
&evt->flush, &hit->flush,
&evt->aggCounter, &hit->aggCounter,
&evt->event_size &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 ){ if( FPGAType == DPPType::PHA ){
ret = CAEN_FELib_ReadData(ep_handle, 100, ret = CAEN_FELib_ReadData(ep_handle, 100,
&evt->channel, &hit->channel,
&evt->timestamp, &hit->timestamp,
&evt->fine_timestamp, &hit->fine_timestamp,
&evt->energy, &hit->energy,
&evt->flags_low_priority, &hit->flags_low_priority,
&evt->flags_high_priority, &hit->flags_high_priority,
&evt->trigger_threashold, &hit->trigger_threashold,
&evt->downSampling, &hit->downSampling,
&evt->board_fail, &hit->board_fail,
&evt->flush, &hit->flush,
&evt->aggCounter, &hit->aggCounter,
&evt->event_size &hit->event_size
); );
}else{ }else{
ret = CAEN_FELib_ReadData(ep_handle, 100, ret = CAEN_FELib_ReadData(ep_handle, 100,
&evt->channel, &hit->channel,
&evt->timestamp, &hit->timestamp,
&evt->fine_timestamp, &hit->fine_timestamp,
&evt->energy, &hit->energy,
&evt->energy_short, &hit->energy_short,
&evt->flags_low_priority, &hit->flags_low_priority,
&evt->flags_high_priority, &hit->flags_high_priority,
&evt->trigger_threashold, &hit->trigger_threashold,
&evt->downSampling, &hit->downSampling,
&evt->board_fail, &hit->board_fail,
&evt->flush, &hit->flush,
&evt->aggCounter, &hit->aggCounter,
&evt->event_size &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 ){ if( FPGAType == DPPType::PHA ){
ret = CAEN_FELib_ReadData(ep_handle, 100, ret = CAEN_FELib_ReadData(ep_handle, 100,
&evt->channel, &hit->channel,
&evt->timestamp, &hit->timestamp,
&evt->energy &hit->energy
); );
}else{ }else{
ret = CAEN_FELib_ReadData(ep_handle, 100, ret = CAEN_FELib_ReadData(ep_handle, 100,
&evt->channel, &hit->channel,
&evt->timestamp, &hit->timestamp,
&evt->energy, &hit->energy,
&evt->energy_short &hit->energy_short
); );
} }
evt->isTraceAllZero = true; hit->isTraceAllZero = true;
}else if( evt->dataType == DataFormat::RAW){ }else if( hit->dataType == DataFormat::RAW){
ret = CAEN_FELib_ReadData(ep_handle, 100, evt->data, &evt->dataSize, &evt->n_events ); ret = CAEN_FELib_ReadData(ep_handle, 100, hit->data, &hit->dataSize, &hit->n_events );
//printf("data size: %lu byte\n", evt.dataSize); //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{ }else{
return CAEN_FELib_UNKNOWN; return CAEN_FELib_UNKNOWN;
} }
@ -804,61 +804,61 @@ void Digitizer2Gen::SaveDataToFile(){
outFile = fopen(outFileName, "wb"); //overwrite binary outFile = fopen(outFileName, "wb"); //overwrite binary
} }
if( evt->dataType == DataFormat::ALL){ if( hit->dataType == DataFormat::ALL){
fwrite(&dataStartIndetifier, 2, 1, outFile); fwrite(&dataStartIndetifier, 2, 1, outFile);
fwrite(&evt->channel, 1, 1, outFile); fwrite(&hit->channel, 1, 1, outFile);
fwrite(&evt->energy, 2, 1, outFile); fwrite(&hit->energy, 2, 1, outFile);
if( FPGAType == DPPType::PSD ) fwrite(&evt->energy_short, 2, 1, outFile); if( FPGAType == DPPType::PSD ) fwrite(&hit->energy_short, 2, 1, outFile);
fwrite(&evt->timestamp, 6, 1, outFile); fwrite(&hit->timestamp, 6, 1, outFile);
fwrite(&evt->fine_timestamp, 2, 1, outFile); fwrite(&hit->fine_timestamp, 2, 1, outFile);
fwrite(&evt->flags_high_priority, 1, 1, outFile); fwrite(&hit->flags_high_priority, 1, 1, outFile);
fwrite(&evt->flags_low_priority, 2, 1, outFile); fwrite(&hit->flags_low_priority, 2, 1, outFile);
fwrite(&evt->downSampling, 1, 1, outFile); fwrite(&hit->downSampling, 1, 1, outFile);
fwrite(&evt->board_fail, 1, 1, outFile); fwrite(&hit->board_fail, 1, 1, outFile);
fwrite(&evt->flush, 1, 1, outFile); fwrite(&hit->flush, 1, 1, outFile);
fwrite(&evt->trigger_threashold, 2, 1, outFile); fwrite(&hit->trigger_threashold, 2, 1, outFile);
fwrite(&evt->event_size, 8, 1, outFile); fwrite(&hit->event_size, 8, 1, outFile);
fwrite(&evt->aggCounter, 4, 1, outFile); fwrite(&hit->aggCounter, 4, 1, outFile);
fwrite(&evt->traceLenght, 8, 1, outFile); fwrite(&hit->traceLenght, 8, 1, outFile);
fwrite(evt->analog_probes_type, 2, 1, outFile); fwrite(hit->analog_probes_type, 2, 1, outFile);
fwrite(evt->digital_probes_type, 4, 1, outFile); fwrite(hit->digital_probes_type, 4, 1, outFile);
fwrite(evt->analog_probes[0], evt->traceLenght*4, 1, outFile); fwrite(hit->analog_probes[0], hit->traceLenght*4, 1, outFile);
fwrite(evt->analog_probes[1], evt->traceLenght*4, 1, outFile); fwrite(hit->analog_probes[1], hit->traceLenght*4, 1, outFile);
fwrite(evt->digital_probes[0], evt->traceLenght, 1, outFile); fwrite(hit->digital_probes[0], hit->traceLenght, 1, outFile);
fwrite(evt->digital_probes[1], evt->traceLenght, 1, outFile); fwrite(hit->digital_probes[1], hit->traceLenght, 1, outFile);
fwrite(evt->digital_probes[2], evt->traceLenght, 1, outFile); fwrite(hit->digital_probes[2], hit->traceLenght, 1, outFile);
fwrite(evt->digital_probes[3], evt->traceLenght, 1, outFile); fwrite(hit->digital_probes[3], hit->traceLenght, 1, outFile);
}else if( evt->dataType == DataFormat::OneTrace){ }else if( hit->dataType == DataFormat::OneTrace){
fwrite(&dataStartIndetifier, 2, 1, outFile); fwrite(&dataStartIndetifier, 2, 1, outFile);
fwrite(&evt->channel, 1, 1, outFile); fwrite(&hit->channel, 1, 1, outFile);
fwrite(&evt->energy, 2, 1, outFile); fwrite(&hit->energy, 2, 1, outFile);
if( FPGAType == DPPType::PSD ) fwrite(&evt->energy_short, 2, 1, outFile); if( FPGAType == DPPType::PSD ) fwrite(&hit->energy_short, 2, 1, outFile);
fwrite(&evt->timestamp, 6, 1, outFile); fwrite(&hit->timestamp, 6, 1, outFile);
fwrite(&evt->fine_timestamp, 2, 1, outFile); fwrite(&hit->fine_timestamp, 2, 1, outFile);
fwrite(&evt->flags_high_priority, 1, 1, outFile); fwrite(&hit->flags_high_priority, 1, 1, outFile);
fwrite(&evt->flags_low_priority, 2, 1, outFile); fwrite(&hit->flags_low_priority, 2, 1, outFile);
fwrite(&evt->traceLenght, 8, 1, outFile); fwrite(&hit->traceLenght, 8, 1, outFile);
fwrite(&evt->analog_probes_type[0], 1, 1, outFile); fwrite(&hit->analog_probes_type[0], 1, 1, outFile);
fwrite(evt->analog_probes[0], evt->traceLenght*4, 1, outFile); fwrite(hit->analog_probes[0], hit->traceLenght*4, 1, outFile);
}else if( evt->dataType == DataFormat::NoTrace ){ }else if( hit->dataType == DataFormat::NoTrace ){
fwrite(&dataStartIndetifier, 2, 1, outFile); fwrite(&dataStartIndetifier, 2, 1, outFile);
fwrite(&evt->channel, 1, 1, outFile); fwrite(&hit->channel, 1, 1, outFile);
fwrite(&evt->energy, 2, 1, outFile); fwrite(&hit->energy, 2, 1, outFile);
if( FPGAType == DPPType::PSD ) fwrite(&evt->energy_short, 2, 1, outFile); if( FPGAType == DPPType::PSD ) fwrite(&hit->energy_short, 2, 1, outFile);
fwrite(&evt->timestamp, 6, 1, outFile); fwrite(&hit->timestamp, 6, 1, outFile);
fwrite(&evt->fine_timestamp, 2, 1, outFile); fwrite(&hit->fine_timestamp, 2, 1, outFile);
fwrite(&evt->flags_high_priority, 1, 1, outFile); fwrite(&hit->flags_high_priority, 1, 1, outFile);
fwrite(&evt->flags_low_priority, 2, 1, outFile); fwrite(&hit->flags_low_priority, 2, 1, outFile);
}else if( evt->dataType == DataFormat::Minimum ){ }else if( hit->dataType == DataFormat::Minimum ){
fwrite(&dataStartIndetifier, 2, 1, outFile); fwrite(&dataStartIndetifier, 2, 1, outFile);
fwrite(&evt->channel, 1, 1, outFile); fwrite(&hit->channel, 1, 1, outFile);
fwrite(&evt->energy, 2, 1, outFile); fwrite(&hit->energy, 2, 1, outFile);
if( FPGAType == DPPType::PSD ) fwrite(&evt->energy_short, 2, 1, outFile); if( FPGAType == DPPType::PSD ) fwrite(&hit->energy_short, 2, 1, outFile);
fwrite(&evt->timestamp, 6, 1, outFile); fwrite(&hit->timestamp, 6, 1, outFile);
}else if( evt->dataType == DataFormat::RAW){ }else if( hit->dataType == DataFormat::RAW){
fwrite(&dataStartIndetifier, 2, 1, outFile); fwrite(&dataStartIndetifier, 2, 1, outFile);
fwrite(&evt->dataSize, 8, 1, outFile); fwrite(&hit->dataSize, 8, 1, outFile);
fwrite(evt->data, evt->dataSize, 1, outFile); fwrite(hit->data, hit->dataSize, 1, outFile);
} }
outFileSize = ftell(outFile); // unsigned int = Max ~4GB outFileSize = ftell(outFile); // unsigned int = Max ~4GB

View File

@ -7,7 +7,7 @@
#include <string> #include <string>
#include <map> #include <map>
#include "Event.h" #include "Hit.h"
#define MaxOutFileSize 2*1024*1024*1024 //2GB #define MaxOutFileSize 2*1024*1024*1024 //2GB
//#define MaxOutFileSize 20*1024*1024 //20MB //#define MaxOutFileSize 20*1024*1024 //20MB
@ -125,7 +125,7 @@ class Digitizer2Gen {
unsigned short GetCh2ns() const {return ch2ns;} unsigned short GetCh2ns() const {return ch2ns;}
uint64_t GetHandle() const {return handle;} 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 OpenOutFile(std::string fileName, const char * mode = "wb"); //overwrite binary
void CloseOutFile(); void CloseOutFile();
void SaveDataToFile(); void SaveDataToFile();

View File

@ -40,7 +40,7 @@ public:
break; break;
}else{ }else{
//digi->ErrorMsg("ReadDataLoop()"); //digi->ErrorMsg("ReadDataLoop()");
//digi->evt->ClearTrace(); digi->hit->ClearTrace();
} }
if( isSaveData ){ if( isSaveData ){

View File

@ -1,9 +1,10 @@
#ifndef EVENT_H #ifndef HIT_H
#define EVENT_H #define HIT_H
#include <stdio.h> #include <stdio.h>
#include <cstdlib> #include <cstdlib>
#include <stdint.h> #include <stdint.h>
#include <string>
#define MaxTraceLenght 8100 #define MaxTraceLenght 8100
@ -24,7 +25,7 @@ namespace DPPType{
}; };
class Event { class Hit {
public: public:
unsigned short dataType; unsigned short dataType;
@ -57,11 +58,11 @@ class Event {
bool isTraceAllZero; bool isTraceAllZero;
Event(){ Hit(){
Init(); Init();
} }
~Event(){ ~Hit(){
ClearMemory(); ClearMemory();
} }

View File

@ -20,7 +20,7 @@ LIBS += -lcurl -lCAEN_FELib -lX11
# Input # Input
HEADERS += ClassDigitizer2Gen.h \ HEADERS += ClassDigitizer2Gen.h \
Event.h \ Hit.h \
influxdb.h \ influxdb.h \
mainwindow.h \ mainwindow.h \
digiSettingsPanel.h \ digiSettingsPanel.h \

View File

@ -8,7 +8,7 @@
#include <unistd.h> #include <unistd.h>
#include <time.h> // time in nano-sec #include <time.h> // time in nano-sec
#include "Event.h" #include "Hit.h"
class SolReader { class SolReader {
private: private:
@ -43,7 +43,7 @@ class SolReader {
void RewindFile(); void RewindFile();
Event * evt; Hit * hit;
}; };
@ -52,7 +52,7 @@ void SolReader::init(){
numBlock = 0; numBlock = 0;
filePos = 0; filePos = 0;
totNumBlock = 0; totNumBlock = 0;
evt = new Event(); hit = new Hit();
isScanned = false; isScanned = false;
@ -67,12 +67,12 @@ SolReader::SolReader(){
SolReader::SolReader(std::string fileName, unsigned short dataType = 0){ SolReader::SolReader(std::string fileName, unsigned short dataType = 0){
init(); init();
OpenFile(fileName); OpenFile(fileName);
evt->SetDataType(dataType, DPPType::PHA); hit->SetDataType(dataType, DPPType::PHA);
} }
SolReader::~SolReader(){ SolReader::~SolReader(){
if( !inFile ) fclose(inFile); if( !inFile ) fclose(inFile);
delete evt; delete hit;
} }
inline void SolReader::OpenFile(std::string fileName){ inline void SolReader::OpenFile(std::string fileName){
@ -113,88 +113,88 @@ inline int SolReader::ReadNextBlock(int opt){
} }
if( ( blockStartIdentifier & 0xF ) == DataFormat::RAW ){ 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; hit->dataType = blockStartIdentifier & 0xF;
evt->DPPType = ((blockStartIdentifier >> 1) & 0xF) == 0 ? DPPType::PHA : DPPType::PSD; hit->DPPType = ((blockStartIdentifier >> 1) & 0xF) == 0 ? DPPType::PHA : DPPType::PSD;
if( evt->dataType == DataFormat::ALL){ if( hit->dataType == DataFormat::ALL){
if( opt == 0 ){ if( opt == 0 ){
fread(&evt->channel, 1, 1, inFile); fread(&hit->channel, 1, 1, inFile);
fread(&evt->energy, 2, 1, inFile); fread(&hit->energy, 2, 1, inFile);
if( evt->DPPType == DPPType::PSD ) fread(&evt->energy_short, 2, 1, inFile); if( hit->DPPType == DPPType::PSD ) fread(&hit->energy_short, 2, 1, inFile);
fread(&evt->timestamp, 6, 1, inFile); fread(&hit->timestamp, 6, 1, inFile);
fread(&evt->fine_timestamp, 2, 1, inFile); fread(&hit->fine_timestamp, 2, 1, inFile);
fread(&evt->flags_high_priority, 1, 1, inFile); fread(&hit->flags_high_priority, 1, 1, inFile);
fread(&evt->flags_low_priority, 2, 1, inFile); fread(&hit->flags_low_priority, 2, 1, inFile);
fread(&evt->downSampling, 1, 1, inFile); fread(&hit->downSampling, 1, 1, inFile);
fread(&evt->board_fail, 1, 1, inFile); fread(&hit->board_fail, 1, 1, inFile);
fread(&evt->flush, 1, 1, inFile); fread(&hit->flush, 1, 1, inFile);
fread(&evt->trigger_threashold, 2, 1, inFile); fread(&hit->trigger_threashold, 2, 1, inFile);
fread(&evt->event_size, 8, 1, inFile); fread(&hit->event_size, 8, 1, inFile);
fread(&evt->aggCounter, 4, 1, inFile); fread(&hit->aggCounter, 4, 1, inFile);
}else{ }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){ if( opt == 0){
fread(evt->analog_probes_type, 2, 1, inFile); fread(hit->analog_probes_type, 2, 1, inFile);
fread(evt->digital_probes_type, 4, 1, inFile); fread(hit->digital_probes_type, 4, 1, inFile);
fread(evt->analog_probes[0], evt->traceLenght*4, 1, inFile); fread(hit->analog_probes[0], hit->traceLenght*4, 1, inFile);
fread(evt->analog_probes[1], evt->traceLenght*4, 1, inFile); fread(hit->analog_probes[1], hit->traceLenght*4, 1, inFile);
fread(evt->digital_probes[0], evt->traceLenght, 1, inFile); fread(hit->digital_probes[0], hit->traceLenght, 1, inFile);
fread(evt->digital_probes[1], evt->traceLenght, 1, inFile); fread(hit->digital_probes[1], hit->traceLenght, 1, inFile);
fread(evt->digital_probes[2], evt->traceLenght, 1, inFile); fread(hit->digital_probes[2], hit->traceLenght, 1, inFile);
fread(evt->digital_probes[3], evt->traceLenght, 1, inFile); fread(hit->digital_probes[3], hit->traceLenght, 1, inFile);
}else{ }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 ){ if( opt == 0 ){
fread(&evt->channel, 1, 1, inFile); fread(&hit->channel, 1, 1, inFile);
fread(&evt->energy, 2, 1, inFile); fread(&hit->energy, 2, 1, inFile);
if( evt->DPPType == DPPType::PSD ) fread(&evt->energy_short, 2, 1, inFile); if( hit->DPPType == DPPType::PSD ) fread(&hit->energy_short, 2, 1, inFile);
fread(&evt->timestamp, 6, 1, inFile); fread(&hit->timestamp, 6, 1, inFile);
fread(&evt->fine_timestamp, 2, 1, inFile); fread(&hit->fine_timestamp, 2, 1, inFile);
fread(&evt->flags_high_priority, 1, 1, inFile); fread(&hit->flags_high_priority, 1, 1, inFile);
fread(&evt->flags_low_priority, 2, 1, inFile); fread(&hit->flags_low_priority, 2, 1, inFile);
}else{ }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){ if( opt == 0){
fread(&evt->analog_probes_type[0], 1, 1, inFile); fread(&hit->analog_probes_type[0], 1, 1, inFile);
fread(evt->analog_probes[0], evt->traceLenght*4, 1, inFile); fread(hit->analog_probes[0], hit->traceLenght*4, 1, inFile);
}else{ }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 ){ if( opt == 0 ){
fread(&evt->channel, 1, 1, inFile); fread(&hit->channel, 1, 1, inFile);
fread(&evt->energy, 2, 1, inFile); fread(&hit->energy, 2, 1, inFile);
if( evt->DPPType == DPPType::PSD ) fread(&evt->energy_short, 2, 1, inFile); if( hit->DPPType == DPPType::PSD ) fread(&hit->energy_short, 2, 1, inFile);
fread(&evt->timestamp, 6, 1, inFile); fread(&hit->timestamp, 6, 1, inFile);
fread(&evt->fine_timestamp, 2, 1, inFile); fread(&hit->fine_timestamp, 2, 1, inFile);
fread(&evt->flags_high_priority, 1, 1, inFile); fread(&hit->flags_high_priority, 1, 1, inFile);
fread(&evt->flags_low_priority, 2, 1, inFile); fread(&hit->flags_low_priority, 2, 1, inFile);
}else{ }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 ){ if( opt == 0 ){
fread(&evt->channel, 1, 1, inFile); fread(&hit->channel, 1, 1, inFile);
fread(&evt->energy, 2, 1, inFile); fread(&hit->energy, 2, 1, inFile);
if( evt->DPPType == DPPType::PSD ) fread(&evt->energy_short, 2, 1, inFile); if( hit->DPPType == DPPType::PSD ) fread(&hit->energy_short, 2, 1, inFile);
fread(&evt->timestamp, 6, 1, inFile); fread(&hit->timestamp, 6, 1, inFile);
}else{ }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){ }else if( hit->dataType == DataFormat::RAW){
fread(&evt->dataSize, 8, 1, inFile); fread(&hit->dataSize, 8, 1, inFile);
if( opt == 0){ if( opt == 0){
fread(evt->data, evt->dataSize, 1, inFile); fread(hit->data, hit->dataSize, 1, inFile);
}else{ }else{
fseek(inFile, evt->dataSize, SEEK_CUR); fseek(inFile, hit->dataSize, SEEK_CUR);
} }
} }

View File

@ -15,7 +15,7 @@ test : test.cpp ClassDigitizer2Gen.o influxdb.o
@echo "------- test" @echo "------- test"
$(CC) $(COPTS) $(OBJS) -o test test.cpp $(CAENLIBS) $(CURLLIBS) $(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" @echo "------- ClassDigitizer2Gen.o"
$(CC) $(COPTS) -c ClassDigitizer2Gen.cpp $(CAENLIBS) $(CC) $(COPTS) -c ClassDigitizer2Gen.cpp $(CAENLIBS)
# #

View File

@ -662,7 +662,7 @@ void Scope::UpdateScope(){
std::string haha = digi[iDigi]->ReadValue(PHA::CH::SelfTrgRate, ch); std::string haha = digi[iDigi]->ReadValue(PHA::CH::SelfTrgRate, ch);
leTriggerRate->setText(QString::fromStdString(haha)); 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 ); unsigned int traceLength = qMin( atoi(digi[iDigi]->GetSettingValue(PHA::CH::RecordLength, ch).c_str())/sample2ns, MaxDisplayTraceDataLength );
if( atoi(haha.c_str()) == 0 ) { if( atoi(haha.c_str()) == 0 ) {
@ -677,19 +677,19 @@ void Scope::UpdateScope(){
return; 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++) { for( int j = 0; j < 2; j++) {
QVector<QPointF> points; QVector<QPointF> 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); dataTrace[j]->replace(points);
} }
for( int j = 0; j < 4; j++) { for( int j = 0; j < 4; j++) {
QVector<QPointF> points; QVector<QPointF> 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); dataTrace[j+2]->replace(points);
} }
//digi[iDigi]->evt->ClearTrace(); //digi[iDigi]->hit->ClearTrace();
digiMTX[iDigi].unlock(); digiMTX[iDigi].unlock();
plot->axes(Qt::Horizontal).first()->setRange(0, sample2ns * traceLength); plot->axes(Qt::Horizontal).first()->setRange(0, sample2ns * traceLength);

View File

@ -10,7 +10,7 @@
void script(std::string fileName){ void script(std::string fileName){
SolReader * reader = new SolReader(fileName); SolReader * reader = new SolReader(fileName);
Event * evt = reader->evt; Hit * hit = reader->hit;
printf("----------file size: %u Byte\n", reader->GetFileSize()); printf("----------file size: %u Byte\n", reader->GetFileSize());
@ -20,9 +20,9 @@ void script(std::string fileName){
unsigned long startTime, endTime; unsigned long startTime, endTime;
reader->ReadBlock(0); reader->ReadBlock(0);
startTime = evt->timestamp; startTime = hit->timestamp;
reader->ReadBlock(reader->GetTotalNumBlock() - 1); reader->ReadBlock(reader->GetTotalNumBlock() - 1);
endTime = evt->timestamp; endTime = hit->timestamp;
double duration = double(endTime - startTime)*8./1e9; double duration = double(endTime - startTime)*8./1e9;
printf("============== %lu ns = %.4f sec.\n", (endTime - startTime)*8, duration); 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(), printf("########################## nBlock : %u, %u/%u\n", reader->GetNumBlock(),
reader->GetFilePos(), reader->GetFilePos(),
reader->GetFileSize()); reader->GetFileSize());
evt->PrintAll(); hit->PrintAll();
//evt->PrintAllTrace(); //hit->PrintAllTrace();
} }
hid->Fill(evt->channel); hid->Fill(hit->channel);
if( evt->channel == 0 ) h1->Fill(evt->timestamp*8/1e9); if( hit->channel == 0 ) h1->Fill(hit->timestamp*8/1e9);
h2->Fill(evt->timestamp*8/1e9, i); h2->Fill(hit->timestamp*8/1e9, i);
if( i == 0){ if( i == 0){
for( int i = 0; i < evt->traceLenght; i++){ for( int i = 0; i < hit->traceLenght; i++){
g1->AddPoint(i*8, evt->analog_probes[0][i]); g1->AddPoint(i*8, hit->analog_probes[0][i]);
g2->AddPoint(i*8, evt->analog_probes[1][i]); g2->AddPoint(i*8, hit->analog_probes[1][i]);
ga->AddPoint(i*8, 10000+5000*evt->digital_probes[0][i]); ga->AddPoint(i*8, 10000+5000*hit->digital_probes[0][i]);
gb->AddPoint(i*8, 20000+5000*evt->digital_probes[1][i]); gb->AddPoint(i*8, 20000+5000*hit->digital_probes[1][i]);
gc->AddPoint(i*8, 30000+5000*evt->digital_probes[2][i]); gc->AddPoint(i*8, 30000+5000*hit->digital_probes[2][i]);
gd->AddPoint(i*8, 40000+5000*evt->digital_probes[3][i]); gd->AddPoint(i*8, 40000+5000*hit->digital_probes[3][i]);
} }
} }
} }
@ -87,17 +87,17 @@ void script(std::string fileName){
gb->Draw("same"); gb->Draw("same");
gc->Draw("same"); gc->Draw("same");
gd->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; delete reader;
} }

View File

@ -1,94 +0,0 @@
#include <X11/Xlib.h>
#include <X11/Xatom.h>
#include <X11/Xutil.h>
#include <png.h>
#include <fstream>
#include <cstring>
#include <vector>
#include <iostream>
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;
}