Compare commits
16 Commits
Author | SHA1 | Date | |
---|---|---|---|
Ryan Tang | 0ee20bce0f | ||
Ryan Tang | 188d65897a | ||
Ryan Tang | 6123e307d8 | ||
04e27e9d70 | |||
1466f8540f | |||
be62125e77 | |||
f68d26de65 | |||
633df09ca4 | |||
b30e87392f | |||
b9158237e4 | |||
55bbb5a7cb | |||
60da1a4bd6 | |||
0ea74d8c70 | |||
cf2cf51095 | |||
f7b78a9f19 | |||
c8d5d2d0c4 |
7
.gitignore
vendored
7
.gitignore
vendored
|
@ -1,8 +1,12 @@
|
|||
*.o
|
||||
*.fsu
|
||||
*.root
|
||||
core.FSUDAQ*
|
||||
*.bin
|
||||
*.log
|
||||
|
||||
core.*
|
||||
|
||||
FSUDAQr
|
||||
FSUDAQ_Qt6
|
||||
test
|
||||
test_indep
|
||||
|
@ -27,6 +31,7 @@ Bin2Root
|
|||
data
|
||||
Data
|
||||
raw_binary
|
||||
log
|
||||
|
||||
*.d
|
||||
*.pcm
|
||||
|
|
|
@ -1331,7 +1331,7 @@ void Digitizer::SetBits(Reg address, unsigned int bitValue, unsigned int bitLeng
|
|||
DebugPrint("%s", "Digitizer");
|
||||
if( softwareDisable ) return;
|
||||
if( AcqRun ) return;
|
||||
///printf("address : 0x%X, value : 0x%X, len : %d, pos : %d, ch : %d \n", address, bitValue, bitLength, bitSmallestPos, ch);
|
||||
// printf("address : 0x%X, value : 0x%X, len : %d, pos : %d, ch : %d \n", address, bitValue, bitLength, bitSmallestPos, ch);
|
||||
uint32_t bit ;
|
||||
uint32_t bitmask = (uint(pow(2, bitLength)-1) << bitSmallestPos);
|
||||
int tempCh = ch;
|
||||
|
|
|
@ -207,7 +207,7 @@ class Digitizer{
|
|||
}
|
||||
|
||||
void SetTrace(bool onOff){
|
||||
SetBits(DPP::BoardConfiguration, DPP::Bit_BoardConfig::RecordTrace, onOff, -1);
|
||||
SetBits(DPP::BoardConfiguration, DPP::Bit_BoardConfig::RecordTrace, (short) onOff, -1);
|
||||
}
|
||||
|
||||
};
|
||||
|
|
6
FSUDAQ
6
FSUDAQ
|
@ -2,6 +2,10 @@
|
|||
|
||||
timestamp=$(date +%Y%m%d_%H%M%S)
|
||||
|
||||
outFile=program_${timestamp}.log
|
||||
outFile=log/program_${timestamp}.log
|
||||
|
||||
mkdir -p "$(dirname "$outFile")"
|
||||
|
||||
echo "FSUDAQ, save stdout to $outFile"
|
||||
|
||||
stdbuf -oL ./FSUDAQ_Qt6 | tee $outFile
|
55
FSUDAQ.cpp
55
FSUDAQ.cpp
|
@ -19,10 +19,19 @@
|
|||
#include "analyzers/SplitPoleAnalyzer.h"
|
||||
#include "analyzers/EncoreAnalyzer.h"
|
||||
#include "analyzers/MUSICAnalyzer.h"
|
||||
#include "analyzers/RAISOR.h"
|
||||
#include "analyzers/NeutronGamma.h"
|
||||
|
||||
std::vector<std::string> onlineAnalyzerList = {"Coincident","Splie-Pole", "Encore", "RAISOR", "MUSICS", "Neutron-Gamma"};
|
||||
#include "analyzers/RAISOR1.h"
|
||||
#include "analyzers/RAISOR2.h"
|
||||
#include "analyzers/TEST.h"
|
||||
#include "analyzers/MCP.h"
|
||||
#include "analyzers/MCPandPSD.h"
|
||||
#include "analyzers/PID.h"
|
||||
#include "analyzers/Cross.h"
|
||||
#include "analyzers/Target.h"
|
||||
#include "analyzers/BeamTune.h"
|
||||
|
||||
std::vector<std::string> onlineAnalyzerList = {"Coincident","Splie-Pole", "Encore", "MUSICS", "Neutron-Gamma", "RAISOR1", "MCP", "PID", "RAISOR2", "TEST", "MCPandPSD", "Cross", "Target", "BeamTune"};
|
||||
|
||||
FSUDAQ::FSUDAQ(QWidget *parent) : QMainWindow(parent){
|
||||
DebugPrint("%s", "FSUDAQ");
|
||||
|
@ -684,9 +693,6 @@ void FSUDAQ::OpenDigitizers(){
|
|||
digi[i] = new Digitizer(portList[i].first, portList[i].second);
|
||||
//digi[i]->Reset();
|
||||
|
||||
//===== set no trace, even when FSQDAQ segfault at scope, the digitizer will save no trace
|
||||
digi[i]->SetTrace(false);
|
||||
|
||||
if( cbOpenMethod->currentData().toInt() == 2 ) {
|
||||
digi[i]->ProgramBoard();
|
||||
}
|
||||
|
@ -731,6 +737,10 @@ void FSUDAQ::OpenDigitizers(){
|
|||
}
|
||||
digi[i]->ReadAllSettingsFromBoard(true);
|
||||
|
||||
//===== set no trace, even when FSQDAQ segfault at scope, the digitizer will save no trace
|
||||
digi[i]->SetTrace(false);
|
||||
// if( digi[i]->GetDPPType() == V1730_DPP_PHA_CODE) digi[i]->WriteRegister(DPP::BoardConfiguration, 0xE8915);
|
||||
|
||||
readDataThread[i] = new ReadDataThread(digi[i], i);
|
||||
connect(readDataThread[i], &ReadDataThread::sendMsg, this, &FSUDAQ::LogMsg);
|
||||
|
||||
|
@ -1207,7 +1217,7 @@ void FSUDAQ::StartACQ(){
|
|||
influx->ClearDataPointsBuffer();
|
||||
}
|
||||
|
||||
if( elogID > 0 && !chkElog->isChecked() && chkSaveData->isChecked() ){
|
||||
if( elogID > 0 && chkElog->isChecked() && chkSaveData->isChecked() ){
|
||||
QString msg = "================================= Run-" + QString::number(runID).rightJustified(3, '0') + "<p>"
|
||||
+ QDateTime::currentDateTime().toString("MM.dd hh:mm:ss") + "<p>"
|
||||
+ startComment + "<p>"
|
||||
|
@ -1297,7 +1307,7 @@ void FSUDAQ::StopACQ(){
|
|||
influx->ClearDataPointsBuffer();
|
||||
}
|
||||
|
||||
if( elogID > 0 && !chkElog->isChecked() && chkSaveData->isChecked()){
|
||||
if( elogID > 0 && chkElog->isChecked() && chkSaveData->isChecked()){
|
||||
QString msg = QDateTime::currentDateTime().toString("MM.dd hh:mm:ss") + "<p>" + stopComment + "<p>";
|
||||
uint64_t totalFileSize = 0;
|
||||
for(unsigned int i = 0 ; i < nDigi; i++){
|
||||
|
@ -1837,9 +1847,19 @@ void FSUDAQ::OpenAnalyzer(){
|
|||
if( id == 0 ) onlineAnalyzer = new CoincidentAnalyzer(digi, nDigi, rawDataPath);
|
||||
if( id == 1 ) onlineAnalyzer = new SplitPole(digi, nDigi);
|
||||
if( id == 2 ) onlineAnalyzer = new Encore(digi, nDigi);
|
||||
if( id == 3 ) onlineAnalyzer = new RAISOR(digi, nDigi);
|
||||
if( id == 4 ) onlineAnalyzer = new MUSIC(digi, nDigi);
|
||||
if( id == 5 ) onlineAnalyzer = new NeutronGamma(digi, nDigi, rawDataPath);
|
||||
if( id == 3 ) onlineAnalyzer = new MUSIC(digi, nDigi);
|
||||
if( id == 4 ) onlineAnalyzer = new NeutronGamma(digi, nDigi, rawDataPath);
|
||||
|
||||
if( id == 5 ) onlineAnalyzer = new RAISOR1(digi, nDigi);
|
||||
if( id == 6 ) onlineAnalyzer = new MCP(digi, nDigi);
|
||||
if( id == 7 ) onlineAnalyzer = new PID(digi, nDigi);
|
||||
if( id == 8 ) onlineAnalyzer = new RAISOR2(digi, nDigi);
|
||||
if( id == 9 ) onlineAnalyzer = new TEST(digi, nDigi);
|
||||
if( id == 10 ) onlineAnalyzer = new MCPandPSD(digi, nDigi);
|
||||
if( id == 11 ) onlineAnalyzer = new Cross(digi, nDigi);
|
||||
if( id == 12 ) onlineAnalyzer = new Target(digi, nDigi);
|
||||
if( id == 13 ) onlineAnalyzer = new BeamTune(digi, nDigi);
|
||||
|
||||
if( id >= 0 ) onlineAnalyzer->show();
|
||||
|
||||
if( isACQStarted ) onlineAnalyzer->startTimer();
|
||||
|
@ -1851,9 +1871,18 @@ void FSUDAQ::OpenAnalyzer(){
|
|||
if( id == 0 ) onlineAnalyzer = new CoincidentAnalyzer(digi, nDigi, rawDataPath);
|
||||
if( id == 1 ) onlineAnalyzer = new SplitPole(digi, nDigi);
|
||||
if( id == 2 ) onlineAnalyzer = new Encore(digi, nDigi);
|
||||
if( id == 3 ) onlineAnalyzer = new RAISOR(digi, nDigi);
|
||||
if( id == 4 ) onlineAnalyzer = new MUSIC(digi, nDigi);
|
||||
if( id == 5 ) onlineAnalyzer = new NeutronGamma(digi, nDigi, rawDataPath);
|
||||
if( id == 3 ) onlineAnalyzer = new MUSIC(digi, nDigi);
|
||||
if( id == 4 ) onlineAnalyzer = new NeutronGamma(digi, nDigi, rawDataPath);
|
||||
|
||||
if( id == 5 ) onlineAnalyzer = new RAISOR1(digi, nDigi);
|
||||
if( id == 6 ) onlineAnalyzer = new MCP(digi, nDigi);
|
||||
if( id == 7 ) onlineAnalyzer = new PID(digi, nDigi);
|
||||
if( id == 8 ) onlineAnalyzer = new RAISOR2(digi, nDigi);
|
||||
if( id == 9 ) onlineAnalyzer = new TEST(digi, nDigi);
|
||||
if( id == 10 ) onlineAnalyzer = new MCPandPSD(digi, nDigi);
|
||||
if( id == 11 ) onlineAnalyzer = new Cross(digi, nDigi);
|
||||
if( id == 12 ) onlineAnalyzer = new Target(digi, nDigi);
|
||||
if( id == 13 ) onlineAnalyzer = new BeamTune(digi, nDigi);
|
||||
|
||||
if( id >= 0 ){
|
||||
onlineAnalyzer->show();
|
||||
|
|
|
@ -25,28 +25,37 @@ QMAKE_CFLAGS_RELEASE = -O0
|
|||
# Input
|
||||
HEADERS += ClassData.h \
|
||||
ClassDigitizer.h \
|
||||
ClassInfluxDB.h\
|
||||
CustomThreads.h \
|
||||
CustomWidgets.h \
|
||||
Histogram1D.h \
|
||||
Histogram2D.h \
|
||||
DigiSettingsPanel.h \
|
||||
FSUDAQ.h \
|
||||
macro.h \
|
||||
RegisterAddress.h \
|
||||
ClassInfluxDB.h\
|
||||
Scope.h \
|
||||
SingleSpectra.h \
|
||||
Histogram1D.h \
|
||||
Histogram2D.h \
|
||||
Hit.h \
|
||||
macro.h \
|
||||
MultiBuilder.h \
|
||||
qcustomplot.h \
|
||||
analyzers/Isotope.h \
|
||||
RegisterAddress.h \
|
||||
Scope.h \
|
||||
SingleSpectra.h \
|
||||
analyzers/Analyser.h \
|
||||
analyzers/BeamTune.h\
|
||||
analyzers/CoincidentAnalyzer.h \
|
||||
analyzers/SplitPoleAnalyzer.h \
|
||||
analyzers/Cross.h\
|
||||
analyzers/EncoreAnalyzer.h \
|
||||
analyzers/Isotope.h \
|
||||
analyzers/MCP.h \
|
||||
analyzers/MCPandPSD.h \
|
||||
analyzers/PID.h \
|
||||
analyzers/RAISOR1.h \
|
||||
analyzers/RAISOR2.h \
|
||||
analyzers/SplitPoleAnalyzer.h \
|
||||
analyzers/Target.h\
|
||||
analyzers/TEST.h \
|
||||
analyzers/MUSICAnalyzer.h \
|
||||
analyzers/NeutronGamma.h \
|
||||
analyzers/RAISOR.h
|
||||
analyzers/NeutronGamma.h
|
||||
|
||||
SOURCES += ClassDigitizer.cpp \
|
||||
DigiSettingsPanel.cpp \
|
||||
FSUDAQ.cpp \
|
||||
|
|
66
FSUDAQr.pro
Normal file
66
FSUDAQr.pro
Normal file
|
@ -0,0 +1,66 @@
|
|||
######################################################################
|
||||
# Automatically generated by qmake (3.1) Thu Sep 12 11:32:09 2024
|
||||
######################################################################
|
||||
|
||||
TEMPLATE = app
|
||||
TARGET = FSUDAQr
|
||||
INCLUDEPATH += .
|
||||
|
||||
QT += core widgets charts printsupport
|
||||
|
||||
LIBS += -lCAENDigitizer -lcurl
|
||||
|
||||
#==== for enable GDB debug
|
||||
#QMAKE_CXXFLAGS += -g
|
||||
#QMAKE_CXXFLAGS_RELEASE = -O0
|
||||
#QMAKE_CFLAGS_RELEASE = -O0
|
||||
|
||||
# You can make your code fail to compile if you use deprecated APIs.
|
||||
# In order to do so, uncomment the following line.
|
||||
# Please consult the documentation of the deprecated API in order to know
|
||||
# how to port your code away from it.
|
||||
# You can also select to disable deprecated APIs only up to a certain version of Qt.
|
||||
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
|
||||
|
||||
# Input
|
||||
HEADERS += ClassData.h \
|
||||
ClassDigitizer.h \
|
||||
ClassInfluxDB.h \
|
||||
CustomThreads.h \
|
||||
CustomWidgets.h \
|
||||
DigiSettingsPanel.h \
|
||||
FSUDAQ.h \
|
||||
Histogram1D.h \
|
||||
Histogram2D.h \
|
||||
Hit.h \
|
||||
macro.h \
|
||||
MultiBuilder.h \
|
||||
qcustomplot.h \
|
||||
RegisterAddress.h \
|
||||
Scope.h \
|
||||
SingleSpectra.h \
|
||||
analyzers/Analyser.h \
|
||||
analyzers/BeamTune.h \
|
||||
analyzers/CoincidentAnalyzer.h \
|
||||
analyzers/Cross.h \
|
||||
analyzers/EncoreAnalyzer.h \
|
||||
analyzers/Isotope.h \
|
||||
analyzers/MCP.h \
|
||||
analyzers/MCPandPSD.h \
|
||||
analyzers/PID.h \
|
||||
analyzers/RAISOR1.h \
|
||||
analyzers/RAISOR2.h \
|
||||
analyzers/SplitPoleAnalyzer.h \
|
||||
analyzers/SplitPoleHit.h \
|
||||
analyzers/Target.h \
|
||||
analyzers/TEST.h
|
||||
SOURCES += ClassDigitizer.cpp \
|
||||
ClassInfluxDB.cpp \
|
||||
DigiSettingsPanel.cpp \
|
||||
FSUDAQ.cpp \
|
||||
main.cpp \
|
||||
MultiBuilder.cpp \
|
||||
qcustomplot.cpp \
|
||||
Scope.cpp \
|
||||
SingleSpectra.cpp \
|
||||
analyzers/Analyser.cpp
|
|
@ -276,6 +276,7 @@ public:
|
|||
UpdatePlot();
|
||||
}
|
||||
|
||||
void SetLineTitle(QString title, int lineID = 0) { graph(lineID)->setName(title); }
|
||||
void SetXTitle(QString xTitle) { xAxis->setLabel(xTitle);}
|
||||
|
||||
void Rebin(int xbin, double xmin, double xmax){
|
||||
|
@ -283,6 +284,7 @@ public:
|
|||
xMin = xmin;
|
||||
xMax = xmax;
|
||||
xBin = xbin;
|
||||
if( xBin > 1000) xBin = 1000;
|
||||
|
||||
dX = (xMax - xMin)/(xBin);
|
||||
|
||||
|
|
|
@ -310,6 +310,9 @@ inline void Histogram2D::Rebin(int xbin, double xmin, double xmax, int ybin, do
|
|||
xBin = xbin + 2;
|
||||
yBin = ybin + 2;
|
||||
|
||||
if( xBin > 1002) xBin = 1002;
|
||||
if( yBin > 1002) yBin = 1002;
|
||||
|
||||
colorMap->data()->clear();
|
||||
colorMap->data()->setSize(xBin, yBin);
|
||||
colorMap->data()->setRange(QCPRange(xMin, xMax), QCPRange(yMin, yMax));
|
||||
|
@ -752,7 +755,7 @@ inline void Histogram2D::LoadCuts(QString cutFileName){
|
|||
int colorID = tempCutID% colorCycle.count();
|
||||
text->setColor(colorCycle[colorID].first);
|
||||
cutTextIDList.push_back(itemCount() - 1);
|
||||
// cutList.push_back(tempCut);
|
||||
cutList.push_back(tempCut);
|
||||
cutIDList.push_back(tempCutID);
|
||||
}
|
||||
tempCut.clear();
|
||||
|
@ -792,6 +795,7 @@ inline void Histogram2D::LoadCuts(QString cutFileName){
|
|||
// Close the file
|
||||
file.close();
|
||||
qDebug() << "File read successfully from" << cutFileName;
|
||||
qDebug() << " Number of cut loaded " << numCut << ", " << cutList.count();
|
||||
|
||||
// PrintCutEntry();
|
||||
// DrawCut();
|
||||
|
|
180
MultiBuilder.cpp
180
MultiBuilder.cpp
|
@ -95,6 +95,8 @@ void MultiBuilder::PrintAllEvent(){
|
|||
}
|
||||
}
|
||||
|
||||
//^############################################### forward event builder
|
||||
|
||||
void MultiBuilder::FindEarlistTimeAndCh(bool verbose){
|
||||
DebugPrint("%s", "MultiBuilder");
|
||||
earlistTime = -1;
|
||||
|
@ -103,9 +105,7 @@ void MultiBuilder::FindEarlistTimeAndCh(bool verbose){
|
|||
nExhaushedCh = 0;
|
||||
for( int i = 0; i < nData; i++){
|
||||
|
||||
for( int j = 0; j < data[i]->GetNChannel(); j++ ) {
|
||||
chExhaused[i][j] = false;
|
||||
}
|
||||
for( int j = 0; j < data[i]->GetNChannel(); j++ ) chExhaused[i][j] = false;
|
||||
|
||||
for(unsigned int ch = 0; ch < data[i]->GetNChannel(); ch ++){
|
||||
|
||||
|
@ -118,7 +118,7 @@ void MultiBuilder::FindEarlistTimeAndCh(bool verbose){
|
|||
}
|
||||
|
||||
if( data[i]->GetTimestamp(ch, index) == 0 ||
|
||||
loopIndex[i][ch] * dataSize[i] > data[i]->GetLoopIndex(ch) * dataSize[i] + data[i]->GetDataIndex(ch)) {
|
||||
loopIndex[i][ch] * dataSize[i] + nextIndex[i][ch] > data[i]->GetLoopIndex(ch) * dataSize[i] + data[i]->GetDataIndex(ch)) {
|
||||
nExhaushedCh ++;
|
||||
chExhaused[i][ch] = true;
|
||||
continue;
|
||||
|
@ -138,42 +138,6 @@ void MultiBuilder::FindEarlistTimeAndCh(bool verbose){
|
|||
}
|
||||
|
||||
if( verbose ) printf("%s | bd : %d, ch : %d, %llu\n", __func__, earlistDigi, earlistCh, earlistTime);
|
||||
|
||||
}
|
||||
|
||||
void MultiBuilder::FindLatestTimeAndCh(bool verbose){
|
||||
DebugPrint("%s", "MultiBuilder");
|
||||
latestTime = 0;
|
||||
latestDigi = -1;
|
||||
latestCh = -1;
|
||||
|
||||
nExhaushedCh = 0;
|
||||
|
||||
for( int i = 0; i < nData; i++){
|
||||
|
||||
for( int j = 0; j < data[i]->GetNChannel(); j++ ) chExhaused[i][j] = false;
|
||||
|
||||
for(unsigned int ch = 0; ch < data[i]->GetNChannel(); ch ++){
|
||||
|
||||
if( nextIndex[i][ch] < 0 || data[i]->GetDataIndex(ch) < 0 || nextIndex[i][ch] <= lastBackWardIndex[i][ch] ) {
|
||||
nExhaushedCh ++;
|
||||
chExhaused[i][ch] = true;
|
||||
// printf(", exhanshed. %d \n", nExhaushedCh);
|
||||
continue;
|
||||
}
|
||||
|
||||
unsigned long long time = data[i]->GetTimestamp(ch, nextIndex[i][ch]);
|
||||
// printf(", time : %llu\n", time );
|
||||
if( time > latestTime ) {
|
||||
latestTime = time;
|
||||
latestDigi = i;
|
||||
latestCh = ch;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if( verbose ) printf("%s | bd : %d, ch : %d, %llu\n", __func__, latestDigi, latestCh, latestTime);
|
||||
|
||||
}
|
||||
|
||||
void MultiBuilder::FindEarlistTimeAmongLastData(bool verbose){
|
||||
|
@ -195,35 +159,16 @@ void MultiBuilder::FindEarlistTimeAmongLastData(bool verbose){
|
|||
}
|
||||
if( verbose ) printf("%s | bd : %d, ch : %d, %lld \n", __func__, latestDigi, latestCh, latestTime);
|
||||
}
|
||||
|
||||
void MultiBuilder::FindLatestTimeOfData(bool verbose){
|
||||
DebugPrint("%s", "MultiBuilder");
|
||||
latestTime = 0;
|
||||
latestCh = -1;
|
||||
latestDigi = -1;
|
||||
for( int i = 0; i < nData; i++){
|
||||
// printf("%s | digi-%d-th | %d\n", __func__, i, data[i]->GetNChannel());
|
||||
for( unsigned ch = 0; ch < data[i]->GetNChannel(); ch++ ){
|
||||
int index = data[i]->GetDataIndex(ch);
|
||||
// printf("ch-%2d | index : %d \n", ch, index);
|
||||
if( index == -1 ) continue;
|
||||
if( data[i]->GetTimestamp(ch, index) > latestTime ) {
|
||||
latestTime = data[i]->GetTimestamp(ch, index);
|
||||
latestCh = ch;
|
||||
latestDigi = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
if( verbose ) printf("%s | bd : %d, ch : %d, %lld \n", __func__, latestDigi, latestCh, latestTime);
|
||||
}
|
||||
|
||||
|
||||
void MultiBuilder::BuildEvents(bool isFinal, bool skipTrace, bool verbose){
|
||||
DebugPrint("%s", "MultiBuilder");
|
||||
|
||||
FindEarlistTimeAndCh(verbose); //Give the earliest time, ch, digi
|
||||
|
||||
FindEarlistTimeAmongLastData(verbose); // give lastest Time, Ch, and Digi for event building
|
||||
|
||||
FindEarlistTimeAndCh(verbose); //Give the earliest time, ch, digi
|
||||
if( earlistCh == -1 || nExhaushedCh == nData * MaxNChannels) return; /// no data
|
||||
if( earlistCh == -1 || nExhaushedCh == numTotCh) return; /// no data
|
||||
|
||||
eventBuilt = 0;
|
||||
//======= Start building event
|
||||
|
@ -235,14 +180,13 @@ void MultiBuilder::BuildEvents(bool isFinal, bool skipTrace, bool verbose){
|
|||
eventIndex ++;
|
||||
if( eventIndex >= MaxNEvent ) eventIndex = 0;
|
||||
events[eventIndex].clear();
|
||||
|
||||
em.Clear();
|
||||
|
||||
for( int k = 0; k < nData; k++){
|
||||
int bd = (k + earlistDigi) % nData;
|
||||
|
||||
// printf("##### %d/%d | ", k, nData);
|
||||
// data[k]->PrintAllData(true, 10);
|
||||
// printf("##### %d/%d | ", bd, nData);
|
||||
// data[bd]->PrintAllData(true);
|
||||
|
||||
const int numCh = data[bd]->GetNChannel();
|
||||
|
||||
|
@ -250,16 +194,22 @@ void MultiBuilder::BuildEvents(bool isFinal, bool skipTrace, bool verbose){
|
|||
int ch = (i + earlistCh ) % numCh;
|
||||
// printf("ch : %d | exhaused ? %s \n", ch, chExhaused[bd][ch] ? "Yes" : "No");
|
||||
if( chExhaused[bd][ch] ) continue;
|
||||
if( loopIndex[bd][ch] * dataSize[bd] + nextIndex[bd][ch] > data[bd]->GetLoopIndex(ch) * dataSize[bd] + data[bd]->GetDataIndex(ch)) {
|
||||
|
||||
// printf(" ch : %2d | %d(%d) | %d(%d)\n", ch, loopIndex[bd][ch], nextIndex[bd][ch], data[bd]->GetLoopIndex(ch), data[bd]->GetDataIndex(ch) );
|
||||
|
||||
if( nextIndex[bd][ch] == -1
|
||||
|| loopIndex[bd][ch] * dataSize[bd] + nextIndex[bd][ch] > data[bd]->GetLoopIndex(ch) * dataSize[bd] + data[bd]->GetDataIndex(ch)) {
|
||||
nExhaushedCh ++;
|
||||
chExhaused[bd][ch] = true;
|
||||
|
||||
// printf(" ch : %d exhaused\n", ch);
|
||||
continue;
|
||||
}
|
||||
|
||||
do {
|
||||
|
||||
unsigned long long time = data[bd]->GetTimestamp(ch, nextIndex[bd][ch]);
|
||||
//printf("%6ld, sn: %5d, ch: %2d, timestamp : %16llu | earlistTime : %16llu | timeWindow : %u \n", eventIndex, data[bd]->boardSN, ch, time, earlistTime, timeWindow);
|
||||
// printf("%6d, sn: %5d, ch: %2d, timestamp : %16llu | earlistTime : %16llu | timeWindow : %u \n", nextIndex[bd][ch], data[bd]->boardSN, ch, time, earlistTime, timeWindow);
|
||||
|
||||
if( time >= earlistTime && (time - earlistTime <= timeWindow) ){
|
||||
em.sn = snList[bd];
|
||||
|
@ -280,14 +230,21 @@ void MultiBuilder::BuildEvents(bool isFinal, bool skipTrace, bool verbose){
|
|||
}else{
|
||||
break;
|
||||
}
|
||||
if( timeWindow <= 0 ) break;
|
||||
if( timeWindow == 0 ) break;
|
||||
}while( true );
|
||||
if( timeWindow <= 0 ) break;
|
||||
if( timeWindow == 0 ) break;
|
||||
}
|
||||
if( timeWindow <= 0 ) break;
|
||||
if( timeWindow == 0 ) break;
|
||||
}
|
||||
|
||||
if( events[eventIndex].size() == 0 ) continue;
|
||||
if( events[eventIndex].size() == 0 ) {
|
||||
if( eventIndex > 1) {
|
||||
eventIndex --;
|
||||
}else{
|
||||
eventIndex = MaxNEvent - 1;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
if( events[eventIndex].size() > 1) {
|
||||
std::sort(events[eventIndex].begin(), events[eventIndex].end(), [](const Hit& a, const Hit& b) {
|
||||
|
@ -295,21 +252,21 @@ void MultiBuilder::BuildEvents(bool isFinal, bool skipTrace, bool verbose){
|
|||
});
|
||||
}
|
||||
|
||||
lastEventTime = events[eventIndex].back().timestamp;
|
||||
// lastEventTime = events[eventIndex].back().timestamp;
|
||||
|
||||
///Find the next earlist
|
||||
FindEarlistTimeAndCh(false);
|
||||
|
||||
// //if there is a time jump, say, bigger than TimeJump. break
|
||||
if( earlistTime - lastEventTime > timeJump ) {
|
||||
if( verbose ){
|
||||
printf("!!!!!!!! Time Jump detected stop event building and get more data.\n");
|
||||
printf("event index : %6lu, earlist time : %16llu\n", eventIndex, earlistTime);
|
||||
printf(" %6s last event time : %16llu \n", "", lastEventTime);
|
||||
printf(" %6s time jump > %16llu \n", "", timeJump);
|
||||
}
|
||||
return;
|
||||
}
|
||||
// if( earlistTime - lastEventTime > timeJump ) {
|
||||
// if( verbose ){
|
||||
// printf("!!!!!!!! Time Jump detected stop event building and get more data.\n");
|
||||
// printf("event index : %6lu, last event time : %16llu\n", eventIndex, lastEventTime);
|
||||
// printf(" %6s earilest time : %16llu \n", "", earlistTime);
|
||||
// printf(" %6s time jump > %16llu \n", "", timeJump);
|
||||
// }
|
||||
// return;
|
||||
// }
|
||||
|
||||
eventBuilt ++;
|
||||
totalEventBuilt ++;
|
||||
|
@ -329,7 +286,7 @@ void MultiBuilder::BuildEvents(bool isFinal, bool skipTrace, bool verbose){
|
|||
printf("%05d, %02d | %5d | %5d %llu \n", sn, chxxx, nextIndex[bd][chxxx], events[eventIndex][i].energy, events[eventIndex][i].timestamp);
|
||||
}
|
||||
|
||||
if( nExhaushedCh == nData * MaxNChannels ) {
|
||||
if( nExhaushedCh == numTotCh ) {
|
||||
printf("######################### no more event to be built\n");
|
||||
break;
|
||||
}
|
||||
|
@ -348,12 +305,67 @@ void MultiBuilder::BuildEvents(bool isFinal, bool skipTrace, bool verbose){
|
|||
break;
|
||||
}
|
||||
}
|
||||
}while(nExhaushedCh < nData * MaxNChannels);
|
||||
}while(nExhaushedCh < numTotCh);
|
||||
|
||||
forceStop = false;
|
||||
|
||||
}
|
||||
|
||||
//^############################################### backward event builder
|
||||
|
||||
void MultiBuilder::FindLatestTimeAndCh(bool verbose){
|
||||
DebugPrint("%s", "MultiBuilder");
|
||||
latestTime = 0;
|
||||
latestDigi = -1;
|
||||
latestCh = -1;
|
||||
|
||||
nExhaushedCh = 0;
|
||||
|
||||
for( int i = 0; i < nData; i++){
|
||||
for( int j = 0; j < data[i]->GetNChannel(); j++ ) chExhaused[i][j] = false;
|
||||
|
||||
for(unsigned int ch = 0; ch < data[i]->GetNChannel(); ch ++){
|
||||
if( nextIndex[i][ch] < 0 || data[i]->GetDataIndex(ch) < 0 || nextIndex[i][ch] <= lastBackWardIndex[i][ch] ) {
|
||||
nExhaushedCh ++;
|
||||
chExhaused[i][ch] = true;
|
||||
// printf(", exhanshed. %d \n", nExhaushedCh);
|
||||
continue;
|
||||
}
|
||||
|
||||
unsigned long long time = data[i]->GetTimestamp(ch, nextIndex[i][ch]);
|
||||
// printf(", time : %llu\n", time );
|
||||
if( time > latestTime ) {
|
||||
latestTime = time;
|
||||
latestDigi = i;
|
||||
latestCh = ch;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if( verbose ) printf("%s | bd : %d, ch : %d, %llu\n", __func__, latestDigi, latestCh, latestTime);
|
||||
}
|
||||
|
||||
void MultiBuilder::FindLatestTimeOfData(bool verbose){
|
||||
DebugPrint("%s", "MultiBuilder");
|
||||
latestTime = 0;
|
||||
latestCh = -1;
|
||||
latestDigi = -1;
|
||||
for( int i = 0; i < nData; i++){
|
||||
// printf("%s | digi-%d-th | %d\n", __func__, i, data[i]->GetNChannel());
|
||||
for( unsigned ch = 0; ch < data[i]->GetNChannel(); ch++ ){
|
||||
int index = data[i]->GetDataIndex(ch);
|
||||
// printf("ch-%2d | index : %d \n", ch, index);
|
||||
if( index == -1 ) continue;
|
||||
if( data[i]->GetTimestamp(ch, index) > latestTime ) {
|
||||
latestTime = data[i]->GetTimestamp(ch, index);
|
||||
latestCh = ch;
|
||||
latestDigi = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
if( verbose ) printf("%s | bd : %d, ch : %d, %lld \n", __func__, latestDigi, latestCh, latestTime);
|
||||
}
|
||||
|
||||
void MultiBuilder::BuildEventsBackWard(int maxNumEvent, bool verbose){
|
||||
DebugPrint("%s", "MultiBuilder");
|
||||
//skip trace, and only build for maxNumEvent events max
|
||||
|
|
|
@ -151,6 +151,9 @@ SingleSpectra::SingleSpectra(Digitizer ** digi, unsigned int nDigi, QString rawD
|
|||
|
||||
// Setup the timer to trigger every second
|
||||
connect(timer, &QTimer::timeout, histWorker, &HistWorker::FillHistograms);
|
||||
|
||||
connect( histWorker, &HistWorker::workDone, this, &SingleSpectra::ReplotHistograms);
|
||||
|
||||
workerThread->start();
|
||||
|
||||
}
|
||||
|
@ -314,6 +317,20 @@ void SingleSpectra::FillHistograms(){
|
|||
|
||||
}
|
||||
|
||||
void SingleSpectra::ReplotHistograms(){
|
||||
|
||||
int ID = cbDigi->currentData().toInt();
|
||||
int ch = cbCh->currentData().toInt();
|
||||
|
||||
if( ch == digi[ID]->GetNumInputCh()) {
|
||||
if( hist2DVisibility[ID] ) hist2D[ID]->UpdatePlot();
|
||||
return;
|
||||
}
|
||||
|
||||
if( histVisibility[ID][ch] ) hist[ID][ch]->UpdatePlot();
|
||||
|
||||
}
|
||||
|
||||
void SingleSpectra::SaveSetting(){
|
||||
DebugPrint("%s", "SingleSpectra");
|
||||
|
||||
|
|
|
@ -43,6 +43,8 @@ public:
|
|||
|
||||
QVector<int> generateNonRepeatedCombination(int size);
|
||||
|
||||
void ReplotHistograms();
|
||||
|
||||
public slots:
|
||||
void FillHistograms();
|
||||
void ChangeHistView();
|
||||
|
|
|
@ -60,6 +60,8 @@ Analyzer::Analyzer(Digitizer ** digi, unsigned int nDigi, QMainWindow * parent )
|
|||
// printf(" --------- work Done\n");
|
||||
// });
|
||||
|
||||
connect( anaWorker, &AnalyzerWorker::workDone, this, &Analyzer::ReplotHistograms);
|
||||
|
||||
anaThread->start();
|
||||
|
||||
}
|
||||
|
@ -138,12 +140,12 @@ void Analyzer::SetDatabase(QString IP, QString Name, QString Token){
|
|||
influx = nullptr;
|
||||
}
|
||||
}else{
|
||||
printf("Database name : %s NOT found.\n", dataBaseName.toStdString().c_str());
|
||||
printf(RED "Database name : %s NOT found.\n" RESET, dataBaseName.toStdString().c_str());
|
||||
delete influx;
|
||||
influx = nullptr;
|
||||
}
|
||||
}else{
|
||||
printf("InfluxDB URL (%s) is NOT Valid. \n", dataBaseIP.toStdString().c_str());
|
||||
printf(RED "InfluxDB URL (%s) is NOT Valid. \n" RESET, dataBaseIP.toStdString().c_str());
|
||||
delete influx;
|
||||
influx = nullptr;
|
||||
}
|
||||
|
@ -242,4 +244,9 @@ void Analyzer::SetUpCanvas(){
|
|||
void Analyzer::UpdateHistograms(){
|
||||
|
||||
|
||||
}
|
||||
|
||||
void Analyzer::ReplotHistograms(){
|
||||
|
||||
|
||||
}
|
|
@ -17,6 +17,7 @@
|
|||
#include "CustomWidgets.h"
|
||||
#include "MultiBuilder.h"
|
||||
#include "ClassInfluxDB.h"
|
||||
#include "math.h"
|
||||
|
||||
/**************************************
|
||||
|
||||
|
@ -62,18 +63,19 @@ public:
|
|||
|
||||
virtual void SetUpCanvas();
|
||||
virtual void UpdateHistograms(); // where event-building, analysis, and ploting
|
||||
virtual void ReplotHistograms();
|
||||
|
||||
public slots:
|
||||
void startTimer(){
|
||||
// printf("start timer\n");
|
||||
mb->ForceStop(false);
|
||||
mb->ClearEvents();
|
||||
anaTimer->start(waitTimeinSec*1000);
|
||||
}
|
||||
void stopTimer(){
|
||||
// printf("stop worker\n");
|
||||
anaTimer->stop();
|
||||
mb->ForceStop(true);
|
||||
mb->ClearEvents();
|
||||
}
|
||||
|
||||
private slots:
|
||||
|
@ -130,4 +132,4 @@ private:
|
|||
Analyzer * SS;
|
||||
};
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
|
296
analyzers/BeamTune.h
Normal file
296
analyzers/BeamTune.h
Normal file
|
@ -0,0 +1,296 @@
|
|||
#ifndef BeamTune_h
|
||||
#define BeamTune_h
|
||||
|
||||
/*********************************************
|
||||
* This is online analyzer for PID, ANL
|
||||
*
|
||||
* Created by Khushi @ 2024-09-03
|
||||
*
|
||||
* ******************************************/
|
||||
#include "Analyser.h"
|
||||
#include <cmath>
|
||||
#include "math.h"
|
||||
#include <algorithm>
|
||||
//#include "TLine.h"
|
||||
//#include <TMarker.h>
|
||||
#include <vector>
|
||||
#include <iostream>
|
||||
class BeamTune : public Analyzer{
|
||||
|
||||
|
||||
|
||||
public:
|
||||
BeamTune(Digitizer ** digi, unsigned int nDigi, QMainWindow * parent = nullptr): Analyzer(digi, nDigi, parent){
|
||||
|
||||
|
||||
SetUpdateTimeInSec(2.0);
|
||||
|
||||
RedefineEventBuilder({0}); // only builder for the 0-th digitizer.
|
||||
tick2ns = digi[0]->GetTick2ns();
|
||||
|
||||
SetBackwardBuild(false, 100); // using normal building (acceding in time) or backward building, int the case of backward building, default events to be build is 100.
|
||||
evtbder = GetEventBuilder();
|
||||
evtbder->SetTimeWindow(500);
|
||||
|
||||
//========== use the influx from the Analyzer
|
||||
influx = new InfluxDB("https://localhost:8086");
|
||||
dataBaseName = "testing";
|
||||
|
||||
SetUpCanvas(); // see below
|
||||
|
||||
};
|
||||
|
||||
void SetUpCanvas();
|
||||
|
||||
public slots:
|
||||
void UpdateHistograms();
|
||||
|
||||
|
||||
private:
|
||||
|
||||
MultiBuilder *evtbder;
|
||||
|
||||
//Histogram2D * hPID;
|
||||
|
||||
Histogram2D * hFrame; // dE versus E : ch1 versus ch4
|
||||
Histogram2D * hFrame1; // dE versus E : ch1 versus ch4
|
||||
//Histogram2D * hdEtotE; // dE versus totE : ch1 versus (ch1+ch4)
|
||||
|
||||
int tick2ns;
|
||||
|
||||
float s0, s1, s2, s3;
|
||||
unsigned long long s_t0, s_t1, s_t2, s_t3;
|
||||
|
||||
float e0, e1, e2, e3, dE1, dE2;
|
||||
unsigned long long t0, t1, t2, t3, dE1_t, dE2_t;
|
||||
|
||||
float ch1, ch4, ch7;
|
||||
//unsigned long long t1, t4, t7;
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
inline void BeamTune::SetUpCanvas(){
|
||||
|
||||
setGeometry(0, 0, 2000, 1000);
|
||||
|
||||
//============ histograms
|
||||
|
||||
//hPID = new Histogram2D("RAISOR", "E", "dE", 100, 0, 5000, 100, 0, 5000, this);
|
||||
//layout->addWidget(hPID, 2, 0);
|
||||
|
||||
hFrame = new Histogram2D("X Map", "X-axis", "Y-axis", 100, -10, 110, 100, -0.8, 0.8, this);
|
||||
layout->addWidget(hFrame, 0, 0, 1, 2);
|
||||
|
||||
hFrame1 = new Histogram2D("X Map", "X-axis", "Y-axis", 100, -10, 110, 100, -0.8, 0.8, this);
|
||||
layout->addWidget(hFrame1, 1, 0, 1, 2);
|
||||
|
||||
|
||||
/*
|
||||
hdEdT = new Histogram2D("dE vs TOF", "TOF [ns]", "dE", 100, 0, 500, 100, 0, 4000, this);
|
||||
layout->addWidget(hdEdT, 1, 3);
|
||||
|
||||
hdEtotE = new Histogram2D("dE vs TotE", "TotE[ch]", "dE[ch]", 500, 0, 10000, 500, 0, 10000, this);
|
||||
layout->addWidget(hdEtotE, 1, 0, 1, 2);
|
||||
*/
|
||||
}
|
||||
|
||||
inline void BeamTune::UpdateHistograms(){
|
||||
|
||||
if( this->isVisible() == false ) return;
|
||||
|
||||
BuildEvents(false); // call the event builder to build events
|
||||
|
||||
//============ Get events, and do analysis
|
||||
long eventBuilt = evtbder->eventBuilt;
|
||||
if( eventBuilt == 0 ) return;
|
||||
|
||||
//============ Get the cut list, if any
|
||||
/*
|
||||
QList<QPolygonF> cutList = hPID->GetCutList();
|
||||
const int nCut = cutList.count();
|
||||
unsigned long long tMin[nCut] = {0xFFFFFFFFFFFFFFFF}, tMax[nCut] = {0};
|
||||
unsigned int count[nCut]={0};
|
||||
|
||||
QList<QPolygonF> cutList1 = hFrame->GetCutList();
|
||||
const int nCut1 = cutList1.count();
|
||||
unsigned long long tMin1[nCut1] = {0xFFFFFFFFFFFFFFFF}, tMax1[nCut1] = {0};
|
||||
unsigned int count1[nCut1]={0};
|
||||
*/
|
||||
/*
|
||||
QList<QPolygonF> cutList2 = hdEtotE->GetCutList();
|
||||
const int nCut2 = cutList2.count();
|
||||
unsigned long long tMin2[nCut2] = {0xFFFFFFFFFFFFFFFF}, tMax2[nCut2] = {0};
|
||||
unsigned int count2[nCut2]={0};
|
||||
*/
|
||||
//============ Processing data and fill histograms
|
||||
long eventIndex = evtbder->eventIndex;
|
||||
long eventStart = eventIndex - eventBuilt + 1;
|
||||
if(eventStart < 0 ) eventStart += MaxNEvent;
|
||||
|
||||
for( long i = eventStart ; i <= eventIndex; i ++ ){
|
||||
std::vector<Hit> event = evtbder->events[i];
|
||||
//printf("-------------- %ld\n", i);
|
||||
|
||||
if( event.size() == 0 ) return;
|
||||
|
||||
|
||||
e0 = 0;
|
||||
e1 = 0;
|
||||
e2 = 0;
|
||||
e3 = 0;
|
||||
|
||||
t0 = 0;
|
||||
t1 = 0;
|
||||
t2 = 0;
|
||||
t3 = 0;
|
||||
|
||||
s0 = 0;
|
||||
s1 = 0;
|
||||
s2 = 0;
|
||||
s3 = 0;
|
||||
|
||||
s_t0 = 0;
|
||||
s_t1 = 0;
|
||||
s_t2 = 0;
|
||||
s_t3 = 0;
|
||||
|
||||
|
||||
//std::vector<TLine*> lines; // Store lines to draw after the loop
|
||||
//std::vector<TMarker*> markers; // Store markers to draw after the loop
|
||||
//int lineCount = 0; // Counter to keep track of the number of lines
|
||||
|
||||
for( int k = 0; k < (int) event.size(); k++ ){
|
||||
//event[k].Print();
|
||||
|
||||
if( event[k].ch == 2 ) {s0 = event[k].energy; s_t0 = event[k].timestamp;} //
|
||||
if( event[k].ch == 3 ) {s1 = event[k].energy; s_t1 = event[k].timestamp;} // The 4 output signals from the
|
||||
if( event[k].ch == 4 ) {s2 = event[k].energy; s_t2 = event[k].timestamp;} // MCP detector
|
||||
if( event[k].ch == 5 ) {s3 = event[k].energy; s_t3 = event[k].timestamp;} //
|
||||
|
||||
if( event[k].ch == 10 ) {e0 = event[k].energy; t0 = event[k].timestamp;} //
|
||||
if( event[k].ch == 11 ) {e1= event[k].energy; t1 = event[k].timestamp;} // The 4 output signals from the
|
||||
if( event[k].ch == 12 ) {e2 = event[k].energy; t2 = event[k].timestamp;} // position sensitive E detector
|
||||
if( event[k].ch == 13 ) {e3= event[k].energy; t3 = event[k].timestamp;} //
|
||||
|
||||
}
|
||||
|
||||
if (s0>10 && s1>10 && s2>10 && s3>10 && e0>10 && e1>10 && e2>10 && e3>10) {
|
||||
float_t rotation_angle = 31.;
|
||||
double_t Xr = (((s1+s2)/(s0+s1+s2+s3))-0.51)*cos(-rotation_angle*M_PI/180)-(((s2+s3)/(s0+s1+s2+s3))-0.51)*sin(-rotation_angle*M_PI/180);
|
||||
double_t Yr = (((s1+s2)/(s0+s1+s2+s3))-0.51)*sin(-rotation_angle*M_PI/180)+(((s2+s3)/(s0+s1+s2+s3))-0.51)*cos(-rotation_angle*M_PI/180);
|
||||
|
||||
double_t X2 = ((e0-e1)/(e0+e1)); // PSD X position
|
||||
double_t Y2 = ((e3-e2)/(e2+e3)); // PSD Y position
|
||||
// printf("(E, dE) = (%f, %f)\n", E, dE);
|
||||
|
||||
|
||||
// Create the line and store it in the vector
|
||||
//TLine *line = new TLine(Xr, Yr, X2, Y2);
|
||||
//line->SetLineColor(kBlack);
|
||||
// Set line color based on Y2 value
|
||||
/*
|
||||
if (Y2 > 0) {
|
||||
line->SetLineColor(kPink); // Pink color if Y2 > 0
|
||||
} else {
|
||||
line->SetLineColor(kBlack); // Black otherwise
|
||||
}
|
||||
*/
|
||||
//lines.push_back(line);
|
||||
//lineCount++; // Increment the counter
|
||||
|
||||
//Create markers at the start and end of the line
|
||||
//TMarker *startMarker = new TMarker(Xr, Yr, kFullCircle);
|
||||
//startMarker->SetMarkerColor(kRed);
|
||||
//startMarker->SetMarkerSize(0.1);
|
||||
//markers.push_back(startMarker);
|
||||
|
||||
//TMarker *endMarker = new TMarker(X2, Y2, kFullCircle);
|
||||
//endMarker->SetMarkerColor(kGreen);
|
||||
//endMarker->SetMarkerSize(0.2);
|
||||
//markers.push_back(endMarker);
|
||||
|
||||
|
||||
//hFrame->Fill(Xr,Yr, sX2,Y2);
|
||||
//hFrame1->Fill(X2,Y2);
|
||||
|
||||
// Draw all the lines after the loop
|
||||
|
||||
//for (auto line : lines) {
|
||||
// line->Draw();
|
||||
//}
|
||||
|
||||
// Draw all the markers after the lines
|
||||
//for (auto marker : markers) {
|
||||
// marker->Draw();
|
||||
//}
|
||||
//gStyle->SetOptStat(0000000);
|
||||
//hdEtotE->Fill(ch1*0.25*0.25 + ch4,ch1);
|
||||
|
||||
}
|
||||
//check events inside any Graphical cut and extract the rate
|
||||
/*
|
||||
for(int p = 0; p < cutList.count(); p++ ){
|
||||
if( cutList[p].isEmpty() ) continue;
|
||||
if( cutList[p].containsPoint(QPointF(ch4, ch1), Qt::OddEvenFill) ){
|
||||
if( t1 < tMin[p] ) tMin[p] = t1;
|
||||
if( t1 > tMax[p] ) tMax[p] = t1;
|
||||
count[p] ++;
|
||||
//printf(".... %d \n", count[p]);
|
||||
}
|
||||
}
|
||||
|
||||
for(int p = 0; p < cutList1.count(); p++ ){
|
||||
if( cutList1[p].isEmpty() ) continue;
|
||||
if( cutList1[p].containsPoint(QPointF(ch4, ch1), Qt::OddEvenFill) ){
|
||||
if( t1 < tMin1[p] ) tMin1[p] = t1;
|
||||
if( t1 > tMax1[p] ) tMax1[p] = t1;
|
||||
count1[p] ++;
|
||||
//printf("hdEE.... %d \n", count1[p]);
|
||||
}
|
||||
}
|
||||
|
||||
for(int p = 0; p < cutList2.count(); p++ ){
|
||||
if( cutList2[p].isEmpty() ) continue;
|
||||
if( cutList2[p].containsPoint(QPointF(ch1+ch4,ch1), Qt::OddEvenFill) ){
|
||||
if( t1 < tMin2[p] ) tMin2[p] = t1;
|
||||
if( t1 > tMax2[p] ) tMax2[p] = t1;
|
||||
count2[p] ++;
|
||||
//printf("hdEtotE.... %d \n", count2[p]);
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
/*
|
||||
for(int p = 0; p < cutList2.count(); p++ ){
|
||||
printf("hdEE.... %d %d \n", p, count1[p]);
|
||||
}
|
||||
*/
|
||||
//hPID->UpdatePlot();
|
||||
|
||||
hFrame->UpdatePlot();
|
||||
hFrame1->UpdatePlot();
|
||||
//hdEtotE->UpdatePlot();
|
||||
|
||||
/*
|
||||
//========== output to Influx
|
||||
QList<QString> cutNameList = hPID->GetCutNameList();
|
||||
for( int p = 0; p < cutList.count(); p ++){
|
||||
if( cutList[p].isEmpty() ) continue;
|
||||
double dT = (tMax[p]-tMin[p]) * tick2ns / 1e9; // tick to sec
|
||||
double rate = count[p]*1.0/(dT);
|
||||
//printf("%llu %llu, %f %d\n", tMin[p], tMax[p], dT, count[p]);
|
||||
//printf("%10s | %d | %f Hz \n", cutNameList[p].toStdString().c_str(), count[p], rate);
|
||||
|
||||
influx->AddDataPoint("Cut,name=" + cutNameList[p].toStdString()+ " value=" + std::to_string(rate));
|
||||
influx->WriteData(dataBaseName);
|
||||
influx->ClearDataPointsBuffer();
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
#endif
|
|
@ -497,7 +497,7 @@ inline void CoincidentAnalyzer::UpdateHistograms(){
|
|||
if( cutList[p].isEmpty() ) continue;
|
||||
double dT = (tMax[p]-tMin[p]) / 1e9;
|
||||
double rate = count[p]*1.0/(dT);
|
||||
printf("%llu %llu, %f %d\n", tMin[p], tMax[p], dT, count[p]);
|
||||
// printf("%llu %llu, %f %d\n", tMin[p], tMax[p], dT, count[p]);
|
||||
printf("%10s | %d | %f Hz \n", cutNameList[p].toStdString().c_str(), count[p], rate);
|
||||
|
||||
influx->AddDataPoint("Cut,name=" + cutNameList[p].toStdString()+ " value=" + std::to_string(rate));
|
||||
|
@ -542,7 +542,6 @@ inline void CoincidentAnalyzer::SaveSettings(){
|
|||
lines << QString::number(h2D->GetYMin());
|
||||
lines << QString::number(h2D->GetYMax());
|
||||
|
||||
|
||||
lines << QString::number(sbUpdateTime->value());
|
||||
lines << QString::number(chkBackWardBuilding->isChecked());
|
||||
lines << QString::number(sbBackwardCount->value());
|
||||
|
|
312
analyzers/Cross.h
Normal file
312
analyzers/Cross.h
Normal file
|
@ -0,0 +1,312 @@
|
|||
#ifndef Cross_h
|
||||
#define Cross_h
|
||||
|
||||
/*********************************************
|
||||
* This is online analyzer for PID, ANL
|
||||
*
|
||||
* Created by Khushi @ 2024-09-03
|
||||
*
|
||||
* ******************************************/
|
||||
#include "Analyser.h"
|
||||
|
||||
|
||||
class Cross : public Analyzer{
|
||||
|
||||
public:
|
||||
Cross(Digitizer ** digi, unsigned int nDigi, QMainWindow * parent = nullptr): Analyzer(digi, nDigi, parent){
|
||||
|
||||
SetUpdateTimeInSec(1.0);
|
||||
|
||||
RedefineEventBuilder({0}); // only builder for the 0-th digitizer.
|
||||
tick2ns = digi[0]->GetTick2ns();
|
||||
|
||||
SetBackwardBuild(false, 100); // using normal building (acceding in time) or backward building, int the case of backward building, default events to be build is 100.
|
||||
evtbder = GetEventBuilder();
|
||||
evtbder->SetTimeWindow(500);
|
||||
|
||||
SetDatabase("http://localhost:8086/", "testing", "zKhzKk4Yhf1l9QU-yE2GsIZ1RazqUgoW3NlF8LJqq_xDMwatOJwg1sKrjgq36uLEsQf8Fmn4sJALP7Kkilk14A==");
|
||||
|
||||
SetUpCanvas(); // see below
|
||||
|
||||
};
|
||||
|
||||
void SetUpCanvas();
|
||||
|
||||
public slots:
|
||||
void UpdateHistograms();
|
||||
void ReplotHistograms();
|
||||
|
||||
private:
|
||||
|
||||
MultiBuilder *evtbder;
|
||||
|
||||
//Histogram2D * hPID;
|
||||
|
||||
Histogram1D * hdE; // raw dE (ch=1): ch1
|
||||
Histogram1D * hE; // raw E (ch=4) : ch4
|
||||
Histogram1D * hdT; // raw dT (ch=7): ch7
|
||||
|
||||
Histogram1D * hTotE; // total energy (dE+E): ch1+ch4
|
||||
Histogram1D * hTWin; // coincidence time window TWin: (t4-t1)*1e9
|
||||
|
||||
Histogram2D * hdEE; // dE versus E : ch1 versus ch4
|
||||
Histogram2D * hdEtotE; // dE versus totE : ch1 versus (ch1+ch4)
|
||||
|
||||
Histogram2D * hdEdT; // dE versus TOF: ch1 versus (t7-t1)*1e9
|
||||
|
||||
Histogram1D * hMulti; //Multiplicity of an event
|
||||
|
||||
int tick2ns;
|
||||
|
||||
int chDE, chE;
|
||||
float energyDE, energyE, ch7;
|
||||
unsigned long long t1, t4, t7;
|
||||
|
||||
QPushButton * bnClearHist;
|
||||
QLabel * lbInfluxIP;
|
||||
RComboBox * cbLocation;
|
||||
QCheckBox * chkDEFourTime;
|
||||
|
||||
};
|
||||
|
||||
inline void Cross::ReplotHistograms(){
|
||||
|
||||
hdE->UpdatePlot();
|
||||
hE->UpdatePlot();
|
||||
hdT->UpdatePlot();
|
||||
hTotE->UpdatePlot();
|
||||
hdEE->UpdatePlot();
|
||||
hdEtotE->UpdatePlot();
|
||||
hdEdT->UpdatePlot();
|
||||
hTWin->UpdatePlot();
|
||||
hMulti->UpdatePlot();
|
||||
|
||||
}
|
||||
|
||||
inline void Cross::SetUpCanvas(){
|
||||
|
||||
setGeometry(0, 0, 2000, 1000);
|
||||
|
||||
//============ histograms
|
||||
|
||||
//hPID = new Histogram2D("RAISOR", "E", "dE", 100, 0, 5000, 100, 0, 5000, this);
|
||||
//layout->addWidget(hPID, 2, 0);
|
||||
|
||||
int row = 0;
|
||||
cbLocation = new RComboBox(this);
|
||||
cbLocation->addItem("Cross", 0);
|
||||
cbLocation->addItem("Target", 1);
|
||||
layout->addWidget(cbLocation, row, 0);
|
||||
|
||||
connect(cbLocation, &RComboBox::currentIndexChanged, this, [=](){
|
||||
switch (cbLocation->currentData().toInt() ) {
|
||||
case 0 : {
|
||||
hdE->SetLineTitle("raw dE (ch = 0)");
|
||||
hE->SetLineTitle("raw E (ch = 2)");
|
||||
hdE->replot();
|
||||
hE->replot();
|
||||
chDE = 0;
|
||||
chE = 2;
|
||||
//Can also set histograms range
|
||||
|
||||
}
|
||||
break;
|
||||
case 1 : {
|
||||
hdE->SetLineTitle("raw dE (ch = 1)");
|
||||
hE->SetLineTitle("raw E (ch = 4)");
|
||||
hdE->replot();
|
||||
hE->replot();
|
||||
chDE = 1;
|
||||
chE = 4;
|
||||
//Can also set histograms range
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
chkDEFourTime = new QCheckBox("dE channel / 4", this);
|
||||
layout->addWidget(chkDEFourTime, row, 1);
|
||||
|
||||
bnClearHist = new QPushButton("Clear All Hist.", this);
|
||||
layout->addWidget(bnClearHist, row, 2);
|
||||
|
||||
connect( bnClearHist, &QPushButton::clicked, this, [=](){
|
||||
hdE->Clear();
|
||||
hE->Clear();
|
||||
hdT->Clear();
|
||||
hTotE->Clear();
|
||||
hdEE->Clear();
|
||||
hdEtotE->Clear();
|
||||
hdEdT->Clear();
|
||||
hTWin->Clear();
|
||||
hMulti->Clear();
|
||||
});
|
||||
|
||||
|
||||
QString haha;
|
||||
if( influx ) {
|
||||
haha = dataBaseIP + ", DB : " + dataBaseName;
|
||||
}else{
|
||||
haha = "No influxDB connection.";
|
||||
}
|
||||
lbInfluxIP = new QLabel( haha , this);
|
||||
if( influx == nullptr ) lbInfluxIP->setStyleSheet("color : red;");
|
||||
layout->addWidget(lbInfluxIP, row, 3, 1, 3);
|
||||
|
||||
row ++;
|
||||
hdEE = new Histogram2D("dE vs E", "E[ch]", "dE[ch]", 500, -100, 5000, 500, -100, 5000, this);
|
||||
layout->addWidget(hdEE, row, 0, 1, 2);
|
||||
|
||||
hdE = new Histogram1D("raw dE (ch=0)", "dE [ch]", 300, 0, 5000, this);
|
||||
layout->addWidget(hdE, row, 2);
|
||||
|
||||
hE = new Histogram1D("raw E (ch=2)", "E [ch]", 300, 0, 10000, this);
|
||||
layout->addWidget(hE, row, 3);
|
||||
|
||||
hTotE = new Histogram1D("total energy (dE+E)", "TotE [ch]", 300, 0, 16000, this);
|
||||
layout->addWidget(hTotE, row, 4);
|
||||
|
||||
hMulti = new Histogram1D("Multiplicity", "", 10, 0, 10, this);
|
||||
layout->addWidget(hMulti, row, 5);
|
||||
|
||||
row ++;
|
||||
hdEtotE = new Histogram2D("dE vs TotE", "TotE[ch]", "dE[ch]", 500, 0, 10000, 500, 0, 5000, this);
|
||||
layout->addWidget(hdEtotE, row, 0, 1, 2);
|
||||
|
||||
hdT = new Histogram1D("raw dT (ch=7)", "dT [ch]", 300, 0, 1000, this);
|
||||
layout->addWidget(hdT, row, 2);
|
||||
|
||||
hdEdT = new Histogram2D("dE vs TOF", "TOF [ns]", "dE", 100, 0, 500, 100, 0, 4000, this);
|
||||
layout->addWidget(hdEdT, row, 3);
|
||||
|
||||
hTWin = new Histogram1D("coincidence time window", "TWin [ns]", 100, 0, 100, this);
|
||||
layout->addWidget(hTWin, row, 4);
|
||||
|
||||
|
||||
}
|
||||
|
||||
inline void Cross::UpdateHistograms(){
|
||||
|
||||
if( this->isVisible() == false ) return;
|
||||
|
||||
BuildEvents(false); // call the event builder to build events
|
||||
|
||||
//============ Get events, and do analysis
|
||||
long eventBuilt = evtbder->eventBuilt;
|
||||
if( eventBuilt == 0 ) return;
|
||||
|
||||
//============ Get the cut list, if any
|
||||
QList<QPolygonF> cutList1 = hdEE->GetCutList();
|
||||
const int nCut1 = cutList1.count();
|
||||
unsigned long long tMin1[nCut1], tMax1[nCut1];
|
||||
unsigned int count1[nCut1];
|
||||
|
||||
QList<QPolygonF> cutList2 = hdEtotE->GetCutList();
|
||||
const int nCut2 = cutList2.count();
|
||||
unsigned long long tMin2[nCut2], tMax2[nCut2];
|
||||
unsigned int count2[nCut2];
|
||||
|
||||
//============ Processing data and fill histograms
|
||||
long eventIndex = evtbder->eventIndex;
|
||||
long eventStart = eventIndex - eventBuilt + 1;
|
||||
if(eventStart < 0 ) eventStart += MaxNEvent;
|
||||
|
||||
for( int i = 0; i < nCut1; i++) {
|
||||
tMin1[i] = -1;
|
||||
tMax1[i] = 0;
|
||||
count1[i] = 0;
|
||||
}
|
||||
|
||||
for( int i = 0; i < nCut2; i++) {
|
||||
tMin2[i] = -1;
|
||||
tMax2[i] = 0;
|
||||
count2[i] = 0;
|
||||
}
|
||||
|
||||
for( long i = eventStart ; i <= eventIndex; i ++ ){
|
||||
|
||||
std::vector<Hit> event = evtbder->events[i];
|
||||
//printf("-------------- %ld\n", i);
|
||||
|
||||
if( event.size() == 0 ) return;
|
||||
|
||||
hMulti->Fill(event.size());
|
||||
|
||||
energyDE = -100; t1 = 0;
|
||||
energyE = -100; t4 = 0;
|
||||
ch7 = -100; t7 = 0;
|
||||
|
||||
for( int k = 0; k < (int) event.size(); k++ ){
|
||||
//event[k].Print();
|
||||
if( event[k].ch == chDE ) {energyDE = event[k].energy; t1 = event[k].timestamp;} // Reads channel 0 of the digitizer corresponding to dE
|
||||
if( event[k].ch == chE ) {energyE = event[k].energy; t4 = event[k].timestamp;} // Reads channel 2 of the digitizer corresponding to E
|
||||
if( event[k].ch == 7 ) {ch7 = event[k].energy; t7 = event[k].timestamp;} //RF Timing if setup
|
||||
|
||||
}
|
||||
|
||||
// printf("(E, dE) = (%f, %f)\n", E, dE);
|
||||
//hPID->Fill(ch4 , ch1); // x, y
|
||||
//etotal = ch1*0.25*0.25 + ch4
|
||||
if( energyDE > 0 ) hdE->Fill(energyDE);
|
||||
if( energyE > 0 ) hE->Fill(energyE);
|
||||
if( ch7 > 0 ) hdT->Fill(ch7);
|
||||
if( energyDE > 0 && energyE > 0 ){
|
||||
hTotE->Fill(0.25 * energyDE + energyE);
|
||||
hdEE->Fill(energyE,energyDE);
|
||||
if( t4 > t1 ) {
|
||||
hTWin->Fill((t4-t1));
|
||||
}else{
|
||||
hTWin->Fill((t1-t4));
|
||||
}
|
||||
hdEtotE->Fill( (chkDEFourTime->isChecked() ? 0.25 : 1) * energyDE + energyE,energyDE);
|
||||
}
|
||||
|
||||
if( energyDE > 0 && ch7 > 0) hdEdT->Fill((t7-t1)*1e9,energyDE);
|
||||
|
||||
//check events inside any Graphical cut and extract the rate
|
||||
// if( ch1 == 0 && ch4 == 0 ) continue;
|
||||
for(int p = 0; p < cutList1.count(); p++ ){
|
||||
if( cutList1[p].isEmpty() ) continue;
|
||||
if( cutList1[p].containsPoint(QPointF(energyE, energyDE), Qt::OddEvenFill) ){
|
||||
if( t1 < tMin1[p] ) tMin1[p] = t1;
|
||||
if( t1 > tMax1[p] ) tMax1[p] = t1;
|
||||
count1[p] ++;
|
||||
//printf("hdEE.... %d \n", count1[p]);
|
||||
}
|
||||
}
|
||||
|
||||
for(int p = 0; p < cutList2.count(); p++ ){
|
||||
if( cutList2[p].isEmpty() ) continue;
|
||||
if( cutList2[p].containsPoint(QPointF(energyDE+energyE,energyDE), Qt::OddEvenFill) ){
|
||||
if( t1 < tMin2[p] ) tMin2[p] = t1;
|
||||
if( t1 > tMax2[p] ) tMax2[p] = t1;
|
||||
count2[p] ++;
|
||||
//printf("hdEtotE.... %d \n", count2[p]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
for(int p = 0; p < cutList2.count(); p++ ){
|
||||
printf("hdEE.... %d %d \n", p, count1[p]);
|
||||
}
|
||||
|
||||
//========== output to Influx
|
||||
QList<QString> cutNameList1 = hdEE->GetCutNameList();
|
||||
for( int p = 0; p < cutList1.count(); p ++){
|
||||
if( cutList1[p].isEmpty() ) continue;
|
||||
double dT = (tMax1[p]-tMin1[p]) / 1e9; // tick to sec
|
||||
double rate = count1[p]*1.0/(dT);
|
||||
//printf("%llu %llu, %f %d\n", tMin1[p], tMax1[p], dT, count1[p]);
|
||||
printf("%10s | %d | %f Hz \n", cutNameList1[p].toStdString().c_str(), count1[p], rate);
|
||||
|
||||
if( influx ){
|
||||
influx->AddDataPoint("Cut,name=" + cutNameList1[p].toStdString()+ " value=" + std::to_string(rate));
|
||||
influx->WriteData("testing");
|
||||
influx->ClearDataPointsBuffer();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endif
|
258
analyzers/MCP.h
Normal file
258
analyzers/MCP.h
Normal file
|
@ -0,0 +1,258 @@
|
|||
#ifndef MCP_h
|
||||
#define MCP_h
|
||||
|
||||
/*********************************************
|
||||
* This is online analyzer for MCP, ANL
|
||||
*
|
||||
* Created by Khushi @ 2024-03-27
|
||||
*
|
||||
* ******************************************/
|
||||
#include "Analyser.h"
|
||||
#include <cmath>
|
||||
#include "math.h"
|
||||
#include <algorithm>
|
||||
|
||||
//#define M_PI 3.14159265
|
||||
|
||||
class MCP : public Analyzer{
|
||||
|
||||
|
||||
|
||||
public:
|
||||
MCP(Digitizer ** digi, unsigned int nDigi, QMainWindow * parent = nullptr): Analyzer(digi, nDigi, parent){
|
||||
|
||||
|
||||
SetUpdateTimeInSec(2.0);
|
||||
|
||||
RedefineEventBuilder({0}); // only builder for the 0-th digitizer.
|
||||
tick2ns = digi[0]->GetTick2ns();
|
||||
|
||||
SetBackwardBuild(false, 100); // using normal building (acceding in time) or backward building, int the case of backward building, default events to be build is 100.
|
||||
evtbder = GetEventBuilder();
|
||||
evtbder->SetTimeWindow(500); //ns
|
||||
|
||||
SetDatabase("https://localhost:8086", "testing", "zKhzKk4Yhf1l9QU-yE2GsIZ1RazqUgoW3NlF8LJqq_xDMwatOJwg1sKrjgq36uLEsQf8Fmn4sJALP7Kkilk14A==");
|
||||
|
||||
SetUpCanvas(); // see below
|
||||
|
||||
};
|
||||
|
||||
void SetUpCanvas();
|
||||
|
||||
public slots:
|
||||
void UpdateHistograms();
|
||||
|
||||
|
||||
private:
|
||||
|
||||
MultiBuilder *evtbder;
|
||||
|
||||
Histogram2D * hPID;
|
||||
|
||||
//Histogram2D * hXX; // X1 versus X2 : e[1] versus e[0]
|
||||
//Histogram2D * hYY; // Y1 versus Y2 : e[3] versus e[2]
|
||||
|
||||
Histogram1D * hX; // X position:((e[0]+e[1])/(e[0]+e[1]+e[2]+e[3]))
|
||||
Histogram1D * hY; // Y position:((e[2]+e[3])/((e[0]+e[1]+e[2]+e[3])))
|
||||
|
||||
Histogram1D * hXr; // X position angle rotated
|
||||
Histogram1D * hYr; // Y position angle rotated
|
||||
|
||||
Histogram2D * hXY; // 2D position plot: ((e[2]+e[3])/((e[0]+e[1]+e[2]+e[3]))) versus ((e[0]+e[1])/(e[0]+e[1]+e[2]+e[3]))
|
||||
Histogram2D * hXYr;
|
||||
Histogram1D * he0; // e0: signal 0
|
||||
Histogram1D * he1; // e1: signal 1
|
||||
Histogram1D * he2; // e2: signal 2
|
||||
Histogram1D * he3; // e3: signal 3
|
||||
|
||||
Histogram1D * ht; // time window
|
||||
|
||||
|
||||
int tick2ns;
|
||||
|
||||
float dE, E;
|
||||
unsigned long long dE_t, E_t;
|
||||
|
||||
float e0, e1, e2, e3;
|
||||
unsigned long long t0, t1, t2, t3;
|
||||
|
||||
};
|
||||
|
||||
|
||||
inline void MCP::SetUpCanvas(){
|
||||
|
||||
setGeometry(0, 0, 2000, 800);
|
||||
|
||||
//============ histograms
|
||||
hPID = new Histogram2D("MCP", "E", "dE", 100, 0, 5000, 100, 0, 5000, this);
|
||||
layout->addWidget(hPID, 0, 0);
|
||||
|
||||
|
||||
|
||||
hXYr = new Histogram2D("2D rot posi", "Xr position", "Yr position", 200, -0.5, 0.5, 200, -0.5, 0.5, this);
|
||||
layout->addWidget(hXYr, 0, 1);
|
||||
|
||||
hXY = new Histogram2D("2D position plot", "X position", "Y position", 500, 0, 1, 500, 0, 1, this);
|
||||
layout->addWidget(hXY, 0, 2);
|
||||
|
||||
ht = new Histogram1D("Time Window", "t", 50, 0, 500, this);
|
||||
layout->addWidget(ht, 0, 3);
|
||||
|
||||
|
||||
hX = new Histogram1D("X position", "X", 250, 0, 1, this);
|
||||
layout->addWidget(hX, 2, 0);
|
||||
|
||||
hY = new Histogram1D("Y position", "Y", 250, 0, 1, this);
|
||||
layout->addWidget(hY, 2, 1);
|
||||
|
||||
hXr = new Histogram1D("Angle rot X posi", "Xr", 250, -0.5, 0.5, this);
|
||||
layout->addWidget(hXr, 2, 2);
|
||||
|
||||
hYr = new Histogram1D("Angle rot Y posi", "Yr", 250, -0.5, 0.5, this);
|
||||
layout->addWidget(hYr, 2, 3);
|
||||
// UNCOMMENT FOLLOWING 8 LINES TO SEE INDIVIDUAL SIGNALS
|
||||
he0 = new Histogram1D("Signal 0", "e0", 200, 0, 8000, this);
|
||||
layout->addWidget(he0, 1, 0);
|
||||
|
||||
he1 = new Histogram1D("Signal 1", "e1", 200, 0, 8000, this);
|
||||
layout->addWidget(he1, 1, 1);
|
||||
|
||||
he2 = new Histogram1D("Signal 2", "e2", 200, 0, 8000, this);
|
||||
layout->addWidget(he2, 1, 2);
|
||||
|
||||
he3 = new Histogram1D("Signal 3", "e3", 200, 0, 8000, this);
|
||||
layout->addWidget(he3, 1, 3);
|
||||
|
||||
|
||||
//
|
||||
}
|
||||
|
||||
inline void MCP::UpdateHistograms(){
|
||||
|
||||
if( this->isVisible() == false ) return;
|
||||
|
||||
BuildEvents(false); // call the event builder to build events
|
||||
|
||||
//============ Get events, and do analysis
|
||||
long eventBuilt = evtbder->eventBuilt;
|
||||
if( eventBuilt == 0 ) return;
|
||||
|
||||
//============ Get the cut list, if any
|
||||
|
||||
QList<QPolygonF> cutList = hPID->GetCutList();
|
||||
const int nCut = cutList.count();
|
||||
unsigned long long tMin[nCut] = {0xFFFFFFFFFFFFFFFF}, tMax[nCut] = {0};
|
||||
unsigned int count[nCut]={0};
|
||||
|
||||
//============ Processing data and fill histograms
|
||||
long eventIndex = evtbder->eventIndex;
|
||||
long eventStart = eventIndex - eventBuilt + 1;
|
||||
if(eventStart < 0 ) eventStart += MaxNEvent;
|
||||
|
||||
for( long i = eventStart ; i <= eventIndex; i ++ ){
|
||||
std::vector<Hit> event = evtbder->events[i];
|
||||
//printf("-------------- %ld\n", i);
|
||||
|
||||
if( event.size() == 0 ) return;
|
||||
//if( event.size() < 2 ) return;
|
||||
cout<< "event size " << event.size() <<endl;
|
||||
|
||||
e0 = 0;
|
||||
e1 = 0;
|
||||
e2 = 0;
|
||||
e3 = 0;
|
||||
|
||||
t0 = 0;
|
||||
t1 = 0;
|
||||
t2 = 0;
|
||||
t3 = 0;
|
||||
|
||||
|
||||
for( int k = 0; k < (int) event.size(); k++ ){
|
||||
//event[k].Print();
|
||||
if( event[k].ch == 2 ) {dE = event[k].energy; dE_t = event[k].timestamp;}
|
||||
if( event[k].ch == 2 ) {E = event[k].energy; E_t = event[k].timestamp;}
|
||||
|
||||
if( event[k].ch == 2 ) {e0 = event[k].energy; t0 = event[k].timestamp;}
|
||||
if( event[k].ch == 3 ) {e1= event[k].energy; t1 = event[k].timestamp;}
|
||||
|
||||
if( event[k].ch == 4 ) {e2 = event[k].energy; t2 = event[k].timestamp;}
|
||||
if( event[k].ch == 5 ) {e3= event[k].energy; t3 = event[k].timestamp;}
|
||||
|
||||
}
|
||||
if (e0>10 && e1>10 && e2>10 && e3>10) {
|
||||
float_t rotation_angle = 31.;
|
||||
double_t Xr = (((e1+e2)/(e0+e1+e2+e3))-0.51)*cos(-rotation_angle*M_PI/180)-(((e2+e3)/(e0+e1+e2+e3))-0.51)*sin(-rotation_angle*M_PI/180);
|
||||
double_t Yr = (((e1+e2)/(e0+e1+e2+e3))-0.51)*sin(-rotation_angle*M_PI/180)+(((e2+e3)/(e0+e1+e2+e3))-0.51)*cos(-rotation_angle*M_PI/180);
|
||||
|
||||
hPID->Fill(E + RandomGauss(0, 100), dE+ RandomGauss(0, 100)); // x, y
|
||||
|
||||
hXY->Fill(((e1+e2)/(e0+e1+e2+e3)),((e2+e3)/(e0+e1+e2+e3)));
|
||||
hXYr->Fill(Xr,Yr);
|
||||
hX->Fill(((e1+e2)/(e0+e1+e2+e3)));
|
||||
hY->Fill(((e2+e3)/(e0+e1+e2+e3)));
|
||||
hXr->Fill(Xr);
|
||||
hYr->Fill(Yr);
|
||||
}
|
||||
|
||||
he0->Fill(e0);
|
||||
he1->Fill(e1);
|
||||
he2->Fill(e2);
|
||||
he3->Fill(e3);
|
||||
|
||||
ht->Fill(max(max(t0,t1),max(t2,t3))-min(min(t0,t1),min(t2,t3)));
|
||||
|
||||
// cout << "t0: " << t0 << endl;
|
||||
// cout << "t1: " << t1 << endl;
|
||||
// cout << "t2: " << t2 << endl;
|
||||
// cout << "t3: " << t3 << endl;
|
||||
// cout << "time window " << max(max(t0,t1),max(t2,t3))-min(min(t0,t1),min(t2,t3)) <<endl;
|
||||
// cout <<"---------------------" << endl;
|
||||
//check events inside any Graphical cut and extract the rate
|
||||
|
||||
for(int p = 0; p < cutList.count(); p++ ){
|
||||
if( cutList[p].isEmpty() ) continue;
|
||||
if( cutList[p].containsPoint(QPointF(E, dE), Qt::OddEvenFill) ){
|
||||
if( dE_t < tMin[p] ) tMin[p] = dE_t;
|
||||
if( dE_t > tMax[p] ) tMax[p] = dE_t;
|
||||
count[p] ++;
|
||||
//printf(".... %d \n", count[p]);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
hPID->UpdatePlot();
|
||||
//hXX->UpdatePlot();//
|
||||
//hYY->UpdatePlot();
|
||||
hXY->UpdatePlot();
|
||||
hXYr->UpdatePlot();
|
||||
hX->UpdatePlot();
|
||||
hY->UpdatePlot();
|
||||
hXr->UpdatePlot();
|
||||
hYr->UpdatePlot();
|
||||
he0->UpdatePlot();
|
||||
he1->UpdatePlot();
|
||||
he2->UpdatePlot();
|
||||
he3->UpdatePlot();
|
||||
ht->UpdatePlot();
|
||||
|
||||
|
||||
|
||||
//========== output to Influx
|
||||
QList<QString> cutNameList = hPID->GetCutNameList();
|
||||
for( int p = 0; p < cutList.count(); p ++){
|
||||
if( cutList[p].isEmpty() ) continue;
|
||||
double dT = (tMax[p]-tMin[p]) * tick2ns / 1e9; // tick to sec
|
||||
double rate = count[p]*1.0/(dT);
|
||||
//printf("%llu %llu, %f %d\n", tMin[p], tMax[p], dT, count[p]);
|
||||
//printf("%10s | %d | %f Hz \n", cutNameList[p].toStdString().c_str(), count[p], rate);
|
||||
|
||||
influx->AddDataPoint("Cut,name=" + cutNameList[p].toStdString()+ " value=" + std::to_string(rate));
|
||||
influx->WriteData(dataBaseName.toStdString());
|
||||
influx->ClearDataPointsBuffer();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#endif
|
360
analyzers/MCPandPSD.h
Normal file
360
analyzers/MCPandPSD.h
Normal file
|
@ -0,0 +1,360 @@
|
|||
#ifndef MCPandPSD_h
|
||||
#define MCPandPSD_h
|
||||
|
||||
/*********************************************
|
||||
* This is online analyzer for RASIOR, ANL
|
||||
*
|
||||
* Created by Ryan @ 2023-10-16
|
||||
*
|
||||
* ******************************************/
|
||||
#include "Analyser.h"
|
||||
#include <cmath>
|
||||
#include "math.h"
|
||||
#include <algorithm>
|
||||
|
||||
|
||||
class MCPandPSD : public Analyzer{
|
||||
|
||||
public:
|
||||
MCPandPSD(Digitizer ** digi, unsigned int nDigi, QMainWindow * parent = nullptr): Analyzer(digi, nDigi, parent){
|
||||
|
||||
|
||||
SetUpdateTimeInSec(4.0);
|
||||
|
||||
RedefineEventBuilder({0}); // only builder for the 0-th digitizer.
|
||||
tick2ns = digi[0]->GetTick2ns();
|
||||
|
||||
SetBackwardBuild(false, 100); // using normal building (acceding in time) or backward building, int the case of backward building, default events to be build is 100.
|
||||
evtbder = GetEventBuilder();
|
||||
evtbder->SetTimeWindow(500);
|
||||
|
||||
SetDatabase("https://localhost:8086", "testing", "zKhzKk4Yhf1l9QU-yE2GsIZ1RazqUgoW3NlF8LJqq_xDMwatOJwg1sKrjgq36uLEsQf8Fmn4sJALP7Kkilk14A==");
|
||||
|
||||
SetUpCanvas(); // see below
|
||||
|
||||
};
|
||||
|
||||
void SetUpCanvas();
|
||||
|
||||
public slots:
|
||||
void UpdateHistograms();
|
||||
|
||||
|
||||
private:
|
||||
|
||||
MultiBuilder *evtbder;
|
||||
|
||||
//Histogram2D * hPID;
|
||||
|
||||
Histogram2D * hXYE; // 2D energy plot: e[2]+e[3] versus e[0]+e[1]
|
||||
|
||||
Histogram1D * hX; // X position:((e[0]-e[1])/(e[0]+e[1]))
|
||||
Histogram1D * hY; // Y position:((e[2]-e[3])/(e[2]+e[3]))
|
||||
|
||||
Histogram1D * hXmcp; // X position
|
||||
Histogram1D * hYmcp; // Y position
|
||||
|
||||
Histogram2D * hXY; // 2D position plot: ((e[2]-e[3])/(e[2]+e[3])) versus ((e[0]-e[1])/(e[0]+e[1]))
|
||||
Histogram2D * hXYMCP; // 2D position plot for MCP: ((e[2]+e[3])/((e[0]+e[1]+e[2]+e[3]))) versus ((e[0]+e[1])/(e[0]+e[1]+e[2]+e[3]))
|
||||
Histogram2D * hXYr; // 2D position plot rotated for MCP:
|
||||
|
||||
|
||||
Histogram2D * hXEdE1; //X energy versus dE signal 1
|
||||
Histogram2D * hYEdE1; //Y energy versus dE signal 1
|
||||
|
||||
Histogram2D * hXEdE2; //X energy versus dE signal 2
|
||||
Histogram2D * hYEdE2; //Y energy versus dE signal 2
|
||||
/*
|
||||
Histogram1D * he0; // e0: signal 0 from PSD
|
||||
Histogram1D * he1; // e1: signal 1 from PSD
|
||||
Histogram1D * he2; // e2: signal 2 from PSD
|
||||
Histogram1D * he3; // e3: signal 3 from PSD
|
||||
|
||||
Histogram1D * hmcp0; // s0: signal 0 from MCP
|
||||
Histogram1D * hmcp1; // s1: signal 1 from MCP
|
||||
Histogram1D * hmcp2; // s2: signal 2 from MCP
|
||||
Histogram1D * hmcp3; // s3: signal 3 from MCP
|
||||
*/
|
||||
|
||||
|
||||
int tick2ns;
|
||||
|
||||
//float dE, E;
|
||||
//unsigned long long dE_t, E_t;
|
||||
|
||||
float e0, e1, e2, e3, dE1, dE2;
|
||||
unsigned long long t0, t1, t2, t3, dE1_t, dE2_t;
|
||||
|
||||
float s0, s1, s2, s3;
|
||||
unsigned long long s_t0, s_t1, s_t2, s_t3;
|
||||
|
||||
};
|
||||
|
||||
|
||||
inline void MCPandPSD::SetUpCanvas(){
|
||||
|
||||
setGeometry(0, 0, 1500, 2000);
|
||||
|
||||
//============ histograms
|
||||
//hPID = new Histogram2D("RAISOR2", "E", "dE", 100, 0, 11000, 100, 0, 11000, this);
|
||||
//layout->addWidget(hPID, 0, 0);
|
||||
|
||||
hXY = new Histogram2D("2D position plot PSD_E", "X position", "Y position", 200, -1, 1, 200, -1, 1, this);
|
||||
layout->addWidget(hXY, 0, 0);
|
||||
|
||||
hX = new Histogram1D("X position", "X", 300, -1, 1, this);
|
||||
layout->addWidget(hX, 0, 1);
|
||||
|
||||
hY = new Histogram1D("Y position", "Y", 300, -1, 1, this);
|
||||
layout->addWidget(hY, 0, 2);
|
||||
/*
|
||||
he0 = new Histogram1D("PSD_E 0", "e0", 200, 0, 8000, this);
|
||||
layout->addWidget(he0, 0, 1);
|
||||
|
||||
he1 = new Histogram1D("PSD_E 1", "e1", 200, 0, 8000, this);
|
||||
layout->addWidget(he1, 0, 2);
|
||||
|
||||
he2 = new Histogram1D("PSD_E 2", "e2", 200, 0, 8000, this);
|
||||
layout->addWidget(he2, 0, 3);
|
||||
|
||||
he3 = new Histogram1D("PSD_E 3", "e3", 200, 0, 8000, this);
|
||||
layout->addWidget(he3, 0, 4);
|
||||
*/
|
||||
hXYMCP = new Histogram2D("2D position MCP", "X position", "Y position", 500, 0, 1, 500, 0, 1, this);
|
||||
layout->addWidget(hXYMCP, 1, 1);
|
||||
|
||||
hXYr = new Histogram2D("2D rot pos MCP", "Xr position", "Yr position", 200, -0.5, 0.5, 200, -0.5, 0.5, this);
|
||||
layout->addWidget(hXYr, 1, 0);
|
||||
/*
|
||||
hmcp0 = new Histogram1D("MCP 0", "s0", 200, 0, 8000, this);
|
||||
layout->addWidget(hmcp0, 1, 1);
|
||||
|
||||
hmcp1 = new Histogram1D("MCP 1", "s1", 200, 0, 8000, this);
|
||||
layout->addWidget(hmcp1, 1, 2);
|
||||
|
||||
hmcp2 = new Histogram1D("MCP 2", "s2", 200, 0, 8000, this);
|
||||
layout->addWidget(hmcp2, 1, 3);
|
||||
|
||||
hmcp3 = new Histogram1D("MCP 3", "s3", 200, 0, 8000, this);
|
||||
layout->addWidget(hmcp3, 1, 4);
|
||||
*/
|
||||
hXmcp = new Histogram1D("X pos rot MCP", "X", 250, -0.5, 0.5, this);
|
||||
layout->addWidget(hXmcp, 1, 2);
|
||||
|
||||
hYmcp = new Histogram1D("Y pos rot MCP", "Y", 250, -0.5, 0.5, this);
|
||||
layout->addWidget(hYmcp, 1, 3);
|
||||
|
||||
hXEdE1 = new Histogram2D("X energy versus dE signal 1", "Ex", "dE signal 1", 100, 0, 8000, 100, 0, 8000, this);
|
||||
layout->addWidget(hXEdE1, 2, 0);
|
||||
|
||||
hYEdE1 = new Histogram2D("Y energy versus dE signal 1", "Ey", "dE signal 1", 100, 0, 8000, 100, 0, 8000, this);
|
||||
layout->addWidget(hYEdE1, 2, 1);
|
||||
|
||||
hXEdE2 = new Histogram2D("X energy versus dE signal 2", "Ex", "dE signal 2", 100, 0, 8000, 100, 0, 8000, this);
|
||||
layout->addWidget(hXEdE2, 2, 2);
|
||||
|
||||
hYEdE2 = new Histogram2D("Y energy versus dE signal 2", "Ey", "dE signal 2", 100, 0, 8000, 100, 0, 8000, this);
|
||||
layout->addWidget(hYEdE2, 2, 3);
|
||||
|
||||
hXYE = new Histogram2D("2D energy plot", "Ex", "Ey", 100, 0, 8000, 100, 0, 8000, this);
|
||||
layout->addWidget(hXYE, 0, 3);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
inline void MCPandPSD::UpdateHistograms(){
|
||||
|
||||
if( this->isVisible() == false ) return;
|
||||
|
||||
BuildEvents(false); // call the event builder to build events
|
||||
|
||||
//============ Get events, and do analysis
|
||||
long eventBuilt = evtbder->eventBuilt;
|
||||
if( eventBuilt == 0 ) return;
|
||||
|
||||
//============ Get the cut list, if any
|
||||
/*
|
||||
QList<QPolygonF> cutList = hPID->GetCutList();
|
||||
const int nCut = cutList.count();
|
||||
unsigned long long tMin[nCut] = {0xFFFFFFFFFFFFFFFF}, tMax[nCut] = {0};
|
||||
unsigned int count[nCut]={0};
|
||||
|
||||
QList<QPolygonF> cutList1 = hXEdE1->GetCutList();
|
||||
const int nCut1 = cutList1.count();
|
||||
unsigned long long tMin1[nCut1] = {0xFFFFFFFFFFFFFFFF}, tMax1[nCut1] = {0};
|
||||
unsigned int count1[nCut1]={0};
|
||||
|
||||
QList<QPolygonF> cutList2 = hYEdE1->GetCutList();
|
||||
const int nCut2 = cutList2.count();
|
||||
unsigned long long tMin2[nCut2] = {0xFFFFFFFFFFFFFFFF}, tMax2[nCut2] = {0};
|
||||
unsigned int count2[nCut2]={0};
|
||||
|
||||
QList<QPolygonF> cutList3 = hXY->GetCutList();
|
||||
const int nCut3 = cutList3.count();
|
||||
unsigned long long tMin3[nCut3] = {0xFFFFFFFFFFFFFFFF}, tMax3[nCut3] = {0};
|
||||
unsigned int count3[nCut3]={0};
|
||||
*/
|
||||
//============ Processing data and fill histograms
|
||||
long eventIndex = evtbder->eventIndex;
|
||||
long eventStart = eventIndex - eventBuilt + 1;
|
||||
if(eventStart < 0 ) eventStart += MaxNEvent;
|
||||
|
||||
for( long i = eventStart ; i <= eventIndex; i ++ ){
|
||||
std::vector<Hit> event = evtbder->events[i];
|
||||
//printf("-------------- %ld\n", i);
|
||||
|
||||
if( event.size() == 0 ) return;
|
||||
|
||||
|
||||
if( event.size() == 0 ) return;
|
||||
//if( event.size() < 2 ) return;
|
||||
cout<< "event size " << event.size() <<endl;
|
||||
|
||||
s0 = 0;
|
||||
s1 = 0;
|
||||
s2 = 0;
|
||||
s3 = 0;
|
||||
|
||||
s_t0 = 0;
|
||||
s_t1 = 0;
|
||||
s_t2 = 0;
|
||||
s_t3 = 0;
|
||||
|
||||
for( int k = 0; k < (int) event.size(); k++ ){
|
||||
//event[k].Print();
|
||||
|
||||
if( event[k].ch == 2 ) {s0 = event[k].energy; s_t0 = event[k].timestamp;} //
|
||||
if( event[k].ch == 3 ) {s1= event[k].energy; s_t1 = event[k].timestamp;} // The 4 output signals from the
|
||||
if( event[k].ch == 4 ) {s2 = event[k].energy; s_t2 = event[k].timestamp;} // MCP detector
|
||||
if( event[k].ch == 5 ) {s3= event[k].energy; s_t3 = event[k].timestamp;} //
|
||||
|
||||
if( event[k].ch == 10 ) {e0 = event[k].energy; t0 = event[k].timestamp;} //
|
||||
if( event[k].ch == 11 ) {e1= event[k].energy; t1 = event[k].timestamp;} // The 4 output signals from the
|
||||
if( event[k].ch == 12 ) {e2 = event[k].energy; t2 = event[k].timestamp;} // position sensitive E detector
|
||||
if( event[k].ch == 13 ) {e3= event[k].energy; t3 = event[k].timestamp;} //
|
||||
|
||||
if( event[k].ch == 14 ) {dE1 = event[k].energy; dE1_t = event[k].timestamp;} // The 2 output signals from the
|
||||
if( event[k].ch == 15 ) {dE2= event[k].energy; dE2_t = event[k].timestamp;} // square dE detector
|
||||
}
|
||||
|
||||
if (s0>10 && s1>10 && s2>10 && s3>10) {
|
||||
float_t rotation_angle = 31.;
|
||||
double_t Xr = (((s1+s2)/(s0+s1+s2+s3))-0.51)*cos(-rotation_angle*M_PI/180)-(((s2+s3)/(s0+s1+s2+s3))-0.51)*sin(-rotation_angle*M_PI/180);
|
||||
double_t Yr = (((s1+s2)/(s0+s1+s2+s3))-0.51)*sin(-rotation_angle*M_PI/180)+(((s2+s3)/(s0+s1+s2+s3))-0.51)*cos(-rotation_angle*M_PI/180);
|
||||
// printf("(E, dE) = (%f, %f)\n", E, dE);
|
||||
//hPID->Fill(E + RandomGauss(0, 100), dE+ RandomGauss(0, 100)); // x, y
|
||||
|
||||
hXY->Fill(((e0-e1)/(e0+e1)),((e3-e2)/(e2+e3)));
|
||||
hXYMCP->Fill(((s1+s2)/(s0+s1+s2+s3)),((s2+s3)/(s0+s1+s2+s3)));
|
||||
|
||||
hX->Fill(((e0-e1)/(e0+e1)));
|
||||
hY->Fill(((e3-e2)/(e2+e3)));
|
||||
hXmcp->Fill(Xr);
|
||||
hYmcp->Fill(Yr);
|
||||
hXEdE1->Fill((e0+e1),dE1);
|
||||
hYEdE1->Fill(e2+e3,dE1);
|
||||
hXEdE2->Fill(e0+e1,dE2);
|
||||
hYEdE2->Fill(e2+e3,dE2);
|
||||
hXYE->Fill(e0+e1,e2+e3);
|
||||
hXYr->Fill(Xr,Yr);
|
||||
}
|
||||
/*
|
||||
he0->Fill(e0);
|
||||
he1->Fill(e1);
|
||||
he2->Fill(e2);
|
||||
he3->Fill(e3);
|
||||
|
||||
hmcp0->Fill(s0);
|
||||
hmcp1->Fill(s1);
|
||||
hmcp2->Fill(s2);
|
||||
hmcp3->Fill(s3);
|
||||
*/
|
||||
//check events inside any Graphical cut and extract the rate
|
||||
/*
|
||||
for(int p = 0; p < cutList.count(); p++ ){
|
||||
if( cutList[p].isEmpty() ) continue;
|
||||
if( cutList[p].containsPoint(QPointF(E, dE), Qt::OddEvenFill) ){
|
||||
if( dE_t < tMin[p] ) tMin[p] = dE_t;
|
||||
if( dE_t > tMax[p] ) tMax[p] = dE_t;
|
||||
count[p] ++;
|
||||
//printf(".... %d \n", count[p]);
|
||||
}
|
||||
}
|
||||
|
||||
for(int p = 0; p < cutList1.count(); p++ ){
|
||||
if( cutList1[p].isEmpty() ) continue;
|
||||
if( cutList1[p].containsPoint(QPointF((e0+e1), dE1), Qt::OddEvenFill) ){
|
||||
if( dE1_t < tMin1[p] ) tMin1[p] = dE1_t;
|
||||
if( dE1_t > tMax1[p] ) tMax1[p] = dE1_t;
|
||||
count1[p] ++;
|
||||
//printf("hXX.... %d \n", count1[p]);
|
||||
}
|
||||
}
|
||||
|
||||
for(int p = 0; p < cutList2.count(); p++ ){
|
||||
if( cutList2[p].isEmpty() ) continue;
|
||||
if( cutList2[p].containsPoint(QPointF((e2+e3), dE1), Qt::OddEvenFill) ){
|
||||
if( dE1_t < tMin2[p] ) tMin2[p] = dE1_t;
|
||||
if( dE1_t > tMax2[p] ) tMax2[p] = dE1_t;
|
||||
count2[p] ++;
|
||||
//printf("hXX.... %d \n", count2[p]);
|
||||
}
|
||||
}
|
||||
|
||||
for(int p = 0; p < cutList3.count(); p++ ){
|
||||
if( cutList3[p].isEmpty() ) continue;
|
||||
if( cutList3[p].containsPoint(QPointF(((e0-e1)/(e0+e1)), ((e2-e3)/(e2+e3))), Qt::OddEvenFill) ){
|
||||
if( ((t2-t3)/(t2+t3)) < tMin3[p] ) tMin3[p] = ((t2-t3)/(t2+t3));
|
||||
if( ((t2-t3)/(t2+t3)) > tMax3[p] ) tMax3[p] = ((t2-t3)/(t2+t3));
|
||||
count3[p] ++;
|
||||
//printf("hXX.... %d \n", count3[p]);
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
//hPID->UpdatePlot();
|
||||
hXY->UpdatePlot();
|
||||
hXYr->UpdatePlot();
|
||||
hXYMCP->UpdatePlot();
|
||||
|
||||
hX->UpdatePlot();
|
||||
hY->UpdatePlot();
|
||||
hXmcp->UpdatePlot();
|
||||
hYmcp->UpdatePlot();
|
||||
hXEdE1->UpdatePlot();
|
||||
hYEdE1->UpdatePlot();
|
||||
hXEdE2->UpdatePlot();
|
||||
hYEdE2->UpdatePlot();
|
||||
hXYE->UpdatePlot();
|
||||
/*
|
||||
he0->UpdatePlot();
|
||||
he1->UpdatePlot();
|
||||
he2->UpdatePlot();
|
||||
he3->UpdatePlot();
|
||||
|
||||
hmcp0->UpdatePlot();
|
||||
hmcp1->UpdatePlot();
|
||||
hmcp2->UpdatePlot();
|
||||
hmcp3->UpdatePlot();
|
||||
*/
|
||||
//========== output to Influx
|
||||
/*
|
||||
QList<QString> cutNameList = hPID->GetCutNameList();
|
||||
for( int p = 0; p < cutList.count(); p ++){
|
||||
if( cutList[p].isEmpty() ) continue;
|
||||
double dT = (tMax[p]-tMin[p]) * tick2ns / 1e9; // tick to sec
|
||||
double rate = count[p]*1.0/(dT);
|
||||
//printf("%llu %llu, %f %d\n", tMin[p], tMax[p], dT, count[p]);
|
||||
//printf("%10s | %d | %f Hz \n", cutNameList[p].toStdString().c_str(), count[p], rate);
|
||||
|
||||
influx->AddDataPoint("Cut,name=" + cutNameList[p].toStdString()+ " value=" + std::to_string(rate));
|
||||
influx->WriteData(dataBaseName);
|
||||
influx->ClearDataPointsBuffer();
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
#endif
|
229
analyzers/PID.h
Normal file
229
analyzers/PID.h
Normal file
|
@ -0,0 +1,229 @@
|
|||
#ifndef PID_h
|
||||
#define PID_h
|
||||
|
||||
/*********************************************
|
||||
* This is online analyzer for PID, ANL
|
||||
*
|
||||
* Created by Khushi @ 2024-03-27
|
||||
*
|
||||
* ******************************************/
|
||||
#include "Analyser.h"
|
||||
|
||||
|
||||
class PID : public Analyzer{
|
||||
|
||||
|
||||
|
||||
public:
|
||||
PID(Digitizer ** digi, unsigned int nDigi, QMainWindow * parent = nullptr): Analyzer(digi, nDigi, parent){
|
||||
|
||||
|
||||
SetUpdateTimeInSec(2.0);
|
||||
|
||||
RedefineEventBuilder({0}); // only builder for the 0-th digitizer.
|
||||
tick2ns = digi[0]->GetTick2ns();
|
||||
|
||||
SetBackwardBuild(false, 100); // using normal building (acceding in time) or backward building, int the case of backward building, default events to be build is 100.
|
||||
evtbder = GetEventBuilder();
|
||||
evtbder->SetTimeWindow(500);
|
||||
|
||||
SetDatabase("https://localhost:8086", "testing", "zKhzKk4Yhf1l9QU-yE2GsIZ1RazqUgoW3NlF8LJqq_xDMwatOJwg1sKrjgq36uLEsQf8Fmn4sJALP7Kkilk14A==");
|
||||
|
||||
SetUpCanvas(); // see below
|
||||
|
||||
};
|
||||
|
||||
void SetUpCanvas();
|
||||
|
||||
public slots:
|
||||
void UpdateHistograms();
|
||||
|
||||
|
||||
private:
|
||||
|
||||
MultiBuilder *evtbder;
|
||||
|
||||
//Histogram2D * hPID;
|
||||
|
||||
Histogram1D * hdE; // raw dE (ch=1): ch1
|
||||
Histogram1D * hE; // raw E (ch=4) : ch4
|
||||
Histogram1D * hdT; // raw dT (ch=7): ch7
|
||||
|
||||
Histogram1D * hTotE; // total energy (dE+E): ch1+ch4
|
||||
Histogram1D * hTWin; // coincidence time window TWin: (t4-t1)*1e9
|
||||
|
||||
Histogram2D * hdEE; // dE versus E : ch1 versus ch4
|
||||
Histogram2D * hdEtotE; // dE versus totE : ch1 versus (ch1+ch4)
|
||||
|
||||
Histogram2D * hdEdT; // dE versus TOF: ch1 versus (t7-t1)*1e9
|
||||
|
||||
|
||||
int tick2ns;
|
||||
|
||||
float ch1, ch4, ch7;
|
||||
unsigned long long t1, t4, t7;
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
inline void PID::SetUpCanvas(){
|
||||
|
||||
setGeometry(0, 0, 2000, 1000);
|
||||
|
||||
//============ histograms
|
||||
|
||||
//hPID = new Histogram2D("RAISOR", "E", "dE", 100, 0, 5000, 100, 0, 5000, this);
|
||||
//layout->addWidget(hPID, 2, 0);
|
||||
|
||||
hdEE = new Histogram2D("dE vs E", "E[ch]", "dE[ch]", 500, -100, 10000, 500, -100, 10000, this);
|
||||
layout->addWidget(hdEE, 0, 0, 1, 2);
|
||||
|
||||
hdE = new Histogram1D("raw dE (ch=1)", "dE [ch]", 300, 0, 8000, this);
|
||||
layout->addWidget(hdE, 0, 2);
|
||||
|
||||
hdEdT = new Histogram2D("dE vs TOF", "TOF [ns]", "dE", 100, 0, 500, 100, 0, 4000, this);
|
||||
layout->addWidget(hdEdT, 1, 3);
|
||||
|
||||
hE = new Histogram1D("raw E (ch=4)", "E [ch]", 300, 0, 10000, this);
|
||||
layout->addWidget(hE, 0, 3);
|
||||
|
||||
hdEtotE = new Histogram2D("dE vs TotE", "TotE[ch]", "dE[ch]", 500, 0, 10000, 500, 0, 10000, this);
|
||||
layout->addWidget(hdEtotE, 1, 0, 1, 2);
|
||||
|
||||
hdT = new Histogram1D("raw dT (ch=7)", "dT [ch]", 300, 0, 1000, this);
|
||||
layout->addWidget(hdT, 1, 2);
|
||||
|
||||
hTotE = new Histogram1D("total energy (dE+E)", "TotE [ch]", 300, 0, 16000, this);
|
||||
layout->addWidget(hTotE, 0, 4);
|
||||
|
||||
hTWin = new Histogram1D("coincidence time window", "TWin [ns]", 300, 0, 500, this);
|
||||
layout->addWidget(hTWin, 1, 4);
|
||||
|
||||
}
|
||||
|
||||
inline void PID::UpdateHistograms(){
|
||||
|
||||
if( this->isVisible() == false ) return;
|
||||
|
||||
BuildEvents(false); // call the event builder to build events
|
||||
|
||||
//============ Get events, and do analysis
|
||||
long eventBuilt = evtbder->eventBuilt;
|
||||
if( eventBuilt == 0 ) return;
|
||||
|
||||
//============ Get the cut list, if any
|
||||
/*
|
||||
QList<QPolygonF> cutList = hPID->GetCutList();
|
||||
const int nCut = cutList.count();
|
||||
unsigned long long tMin[nCut] = {0xFFFFFFFFFFFFFFFF}, tMax[nCut] = {0};
|
||||
unsigned int count[nCut]={0};
|
||||
*/
|
||||
QList<QPolygonF> cutList1 = hdEE->GetCutList();
|
||||
const int nCut1 = cutList1.count();
|
||||
unsigned long long tMin1[nCut1] = {0xFFFFFFFFFFFFFFFF}, tMax1[nCut1] = {0};
|
||||
unsigned int count1[nCut1]={0};
|
||||
|
||||
QList<QPolygonF> cutList2 = hdEtotE->GetCutList();
|
||||
const int nCut2 = cutList2.count();
|
||||
unsigned long long tMin2[nCut2] = {0xFFFFFFFFFFFFFFFF}, tMax2[nCut2] = {0};
|
||||
unsigned int count2[nCut2]={0};
|
||||
|
||||
//============ Processing data and fill histograms
|
||||
long eventIndex = evtbder->eventIndex;
|
||||
long eventStart = eventIndex - eventBuilt + 1;
|
||||
if(eventStart < 0 ) eventStart += MaxNEvent;
|
||||
|
||||
for( long i = eventStart ; i <= eventIndex; i ++ ){
|
||||
std::vector<Hit> event = evtbder->events[i];
|
||||
//printf("-------------- %ld\n", i);
|
||||
|
||||
if( event.size() == 0 ) return;
|
||||
|
||||
for( int k = 0; k < (int) event.size(); k++ ){
|
||||
//event[k].Print();
|
||||
if( event[k].ch == 6 ) {ch1 = event[k].energy; t1 = event[k].timestamp;}
|
||||
if( event[k].ch == 7 ) {ch4 = event[k].energy; t4 = event[k].timestamp;}
|
||||
if( event[k].ch == 1 ) {ch7 = event[k].energy; t7 = event[k].timestamp;}
|
||||
|
||||
}
|
||||
|
||||
// printf("(E, dE) = (%f, %f)\n", E, dE);
|
||||
//hPID->Fill(ch4 , ch1); // x, y
|
||||
//etotal = ch1*0.25*0.25 + ch4
|
||||
hdE->Fill(ch1);
|
||||
hE->Fill(ch4);
|
||||
hdT->Fill(ch7);
|
||||
hTotE->Fill(ch1*0.25*0.25 + ch4);
|
||||
hdEE->Fill(ch4,ch1);
|
||||
hdEtotE->Fill(ch1*0.25*0.25 + ch4,ch1);
|
||||
hdEdT->Fill((t7-t1)*1e9,ch1);
|
||||
hTWin->Fill((t4-t1)*1e9);
|
||||
|
||||
//check events inside any Graphical cut and extract the rate
|
||||
/*
|
||||
for(int p = 0; p < cutList.count(); p++ ){
|
||||
if( cutList[p].isEmpty() ) continue;
|
||||
if( cutList[p].containsPoint(QPointF(ch4, ch1), Qt::OddEvenFill) ){
|
||||
if( t1 < tMin[p] ) tMin[p] = t1;
|
||||
if( t1 > tMax[p] ) tMax[p] = t1;
|
||||
count[p] ++;
|
||||
//printf(".... %d \n", count[p]);
|
||||
}
|
||||
}
|
||||
*/
|
||||
for(int p = 0; p < cutList1.count(); p++ ){
|
||||
if( cutList1[p].isEmpty() ) continue;
|
||||
if( cutList1[p].containsPoint(QPointF(ch4, ch1), Qt::OddEvenFill) ){
|
||||
if( t1 < tMin1[p] ) tMin1[p] = t1;
|
||||
if( t1 > tMax1[p] ) tMax1[p] = t1;
|
||||
count1[p] ++;
|
||||
//printf("hdEE.... %d \n", count1[p]);
|
||||
}
|
||||
}
|
||||
|
||||
for(int p = 0; p < cutList2.count(); p++ ){
|
||||
if( cutList2[p].isEmpty() ) continue;
|
||||
if( cutList2[p].containsPoint(QPointF(ch1+ch4,ch1), Qt::OddEvenFill) ){
|
||||
if( t1 < tMin2[p] ) tMin2[p] = t1;
|
||||
if( t1 > tMax2[p] ) tMax2[p] = t1;
|
||||
count2[p] ++;
|
||||
//printf("hdEtotE.... %d \n", count2[p]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
for(int p = 0; p < cutList2.count(); p++ ){
|
||||
printf("hdEE.... %d %d \n", p, count1[p]);
|
||||
}
|
||||
|
||||
//hPID->UpdatePlot();
|
||||
hdE->UpdatePlot();
|
||||
hE->UpdatePlot();
|
||||
hdT->UpdatePlot();
|
||||
hTotE->UpdatePlot();
|
||||
hdEE->UpdatePlot();
|
||||
hdEtotE->UpdatePlot();
|
||||
hdEdT->UpdatePlot();
|
||||
hTWin->UpdatePlot();
|
||||
/*
|
||||
//========== output to Influx
|
||||
QList<QString> cutNameList = hPID->GetCutNameList();
|
||||
for( int p = 0; p < cutList.count(); p ++){
|
||||
if( cutList[p].isEmpty() ) continue;
|
||||
double dT = (tMax[p]-tMin[p]) * tick2ns / 1e9; // tick to sec
|
||||
double rate = count[p]*1.0/(dT);
|
||||
//printf("%llu %llu, %f %d\n", tMin[p], tMax[p], dT, count[p]);
|
||||
//printf("%10s | %d | %f Hz \n", cutNameList[p].toStdString().c_str(), count[p], rate);
|
||||
|
||||
influx->AddDataPoint("Cut,name=" + cutNameList[p].toStdString()+ " value=" + std::to_string(rate));
|
||||
influx->WriteData(dataBaseName);
|
||||
influx->ClearDataPointsBuffer();
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
#endif
|
268
analyzers/RAISOR1.h
Normal file
268
analyzers/RAISOR1.h
Normal file
|
@ -0,0 +1,268 @@
|
|||
#ifndef RASIOR1_h
|
||||
#define RASIOR1_h
|
||||
|
||||
/*********************************************
|
||||
* This is online analyzer for RASIOR, ANL
|
||||
*
|
||||
* Created by Ryan @ 2023-10-16
|
||||
*
|
||||
* ******************************************/
|
||||
#include "Analyser.h"
|
||||
|
||||
|
||||
class RAISOR1 : public Analyzer{
|
||||
|
||||
public:
|
||||
RAISOR1(Digitizer ** digi, unsigned int nDigi, QMainWindow * parent = nullptr): Analyzer(digi, nDigi, parent){
|
||||
|
||||
|
||||
SetUpdateTimeInSec(1.0);
|
||||
|
||||
RedefineEventBuilder({0}); // only builder for the 0-th digitizer.
|
||||
tick2ns = digi[0]->GetTick2ns();
|
||||
|
||||
SetBackwardBuild(false, 100); // using normal building (acceding in time) or backward building, int the case of backward building, default events to be build is 100.
|
||||
evtbder = GetEventBuilder();
|
||||
evtbder->SetTimeWindow(500);
|
||||
|
||||
SetDatabase("https://localhost:8086", "testing", "zKhzKk4Yhf1l9QU-yE2GsIZ1RazqUgoW3NlF8LJqq_xDMwatOJwg1sKrjgq36uLEsQf8Fmn4sJALP7Kkilk14A==");
|
||||
|
||||
SetUpCanvas(); // see below
|
||||
|
||||
};
|
||||
|
||||
void SetUpCanvas();
|
||||
|
||||
public slots:
|
||||
void UpdateHistograms();
|
||||
|
||||
|
||||
private:
|
||||
|
||||
MultiBuilder *evtbder;
|
||||
|
||||
Histogram2D * hPID;
|
||||
|
||||
Histogram2D * hXX; // X1 versus X2 : e[1] versus e[0]
|
||||
Histogram2D * hYY; // Y1 versus Y2 : e[3] versus e[2]
|
||||
|
||||
Histogram1D * hXE; // X energy: e[0]+e[1]
|
||||
Histogram1D * hYE; // Y energy: e[2]+e[3]
|
||||
|
||||
Histogram2D * hXYE; // 2D energy plot: e[2]+e[3] versus e[0]+e[1]
|
||||
|
||||
Histogram1D * hX; // X position:((e[0]-e[1])/(e[0]+e[1]))
|
||||
Histogram1D * hY; // Y position:((e[2]-e[3])/(e[2]+e[3]))
|
||||
|
||||
Histogram2D * hXY; // 2D position plot: ((e[2]-e[3])/(e[2]+e[3])) versus ((e[0]-e[1])/(e[0]+e[1]))
|
||||
|
||||
|
||||
Histogram2D * hXPE; // X position versus X energy: ((e[0]-e[1])/(e[0]+e[1])) versus (e[0]+e[1])
|
||||
Histogram2D * hYPE; // Y position versus Y energy: ((e[2]-e[3])/(e[2]+e[3])) versus (e[2]+e[3])
|
||||
|
||||
//TH1F * hX1, * hX2, * hY1, *hY2;
|
||||
|
||||
Histogram2D * hXEdE1; //X energy versus dE signal 1
|
||||
Histogram2D * hYEdE1; //Y energy versus dE signal 1
|
||||
|
||||
Histogram2D * hXEdE2; //X energy versus dE signal 2
|
||||
Histogram2D * hYEdE2; //Y energy versus dE signal 2
|
||||
|
||||
Histogram1D * hX1, * hX2, * hY1, * hY2;
|
||||
|
||||
int chX1, chX2; // yellow, Red
|
||||
int chY1, chY2; // Blue, White
|
||||
|
||||
int tick2ns;
|
||||
|
||||
float dE, E;
|
||||
unsigned long long dE_t, E_t;
|
||||
|
||||
float e0, e1, e2, e3, dE1, dE2;
|
||||
unsigned long long t0, t1, t2, t3, dE1_t, dE2_t;
|
||||
//unsigned Int_t * energy;
|
||||
//unsigned long energy;
|
||||
/*
|
||||
chX1 = 0; // left
|
||||
chX2 = 1; // right
|
||||
|
||||
chY1 = 2; // top
|
||||
chY2 = 3; // bottom
|
||||
*/
|
||||
|
||||
};
|
||||
|
||||
|
||||
inline void RAISOR1::SetUpCanvas(){
|
||||
|
||||
setGeometry(0, 0, 1500, 2000);
|
||||
|
||||
//============ histograms
|
||||
hPID = new Histogram2D("RAISOR", "E", "dE", 100, 0, 5000, 100, 0, 5000, this);
|
||||
layout->addWidget(hPID, 0, 0);
|
||||
|
||||
hXY = new Histogram2D("2D position plot", "X position", "Y position", 100, -1, 1, 100, -1, 1, this);
|
||||
layout->addWidget(hXY, 0, 1);
|
||||
|
||||
hXX = new Histogram2D("X1 versus X2", "X2", "X1", 100, 0, 5000, 100, 0, 5000, this);
|
||||
layout->addWidget(hXX, 0, 2);
|
||||
|
||||
hYY = new Histogram2D("Y1 versus Y2", "Y2", "Y1", 100, 0, 3000, 100, 0, 3000, this);
|
||||
layout->addWidget(hYY, 0, 3);
|
||||
|
||||
hXE = new Histogram1D("X energy", "Ex", 300, 0, 8000, this);
|
||||
layout->addWidget(hXE, 1, 0);
|
||||
|
||||
hYE = new Histogram1D("Y energy", "Ey", 300, 0, 4000, this);
|
||||
layout->addWidget(hYE, 1, 1);
|
||||
|
||||
hX = new Histogram1D("X position", "X", 300, -1, 1, this);
|
||||
layout->addWidget(hX, 1, 2);
|
||||
|
||||
hY = new Histogram1D("Y position", "Y", 300, -1, 1, this);
|
||||
layout->addWidget(hY, 1, 3);
|
||||
|
||||
hXPE = new Histogram2D("X energy versus X position", "X position", "X energy", 100, -1, 1, 100, -2000, 20000, this);
|
||||
layout->addWidget(hXPE, 0, 4);
|
||||
|
||||
hYPE = new Histogram2D("Y energy versus Y position", "Y position", "Y energy", 100, -1, 1, 100, 0, 5000, this);
|
||||
layout->addWidget(hYPE, 1, 4);
|
||||
|
||||
hXEdE1 = new Histogram2D("X energy versus dE signal 1", "Ex", "dE signal 1", 100, -200, 20000, 100, -200, 10000, this);
|
||||
layout->addWidget(hXEdE1, 2, 0);
|
||||
|
||||
hYEdE1 = new Histogram2D("Y energy versus dE signal 1", "Ey", "dE signal 1", 100, 0, 6000, 100, 0, 6000, this);
|
||||
layout->addWidget(hYEdE1, 2, 1);
|
||||
|
||||
hXEdE2 = new Histogram2D("X energy versus dE signal 2", "Ex", "dE signal 2", 100, -500, 20000, 100, -500, 15000, this);
|
||||
layout->addWidget(hXEdE2, 2, 2);
|
||||
|
||||
hYEdE2 = new Histogram2D("Y energy versus dE signal 2", "Ey", "dE signal 2", 100, -500, 5000, 100, -500, 12000, this);
|
||||
layout->addWidget(hYEdE2, 2, 3);
|
||||
|
||||
hXYE = new Histogram2D("2D energy plot", "Ex", "Ey", 100, 0, 10000, 100, 0, 6000, this);
|
||||
layout->addWidget(hXYE, 2, 4);
|
||||
|
||||
|
||||
}
|
||||
|
||||
inline void RAISOR1::UpdateHistograms(){
|
||||
|
||||
if( this->isVisible() == false ) return;
|
||||
|
||||
BuildEvents(false); // call the event builder to build events
|
||||
|
||||
//============ Get events, and do analysis
|
||||
long eventBuilt = evtbder->eventBuilt;
|
||||
if( eventBuilt == 0 ) return;
|
||||
|
||||
//============ Get the cut list, if any
|
||||
QList<QPolygonF> cutList = hPID->GetCutList();
|
||||
const int nCut = cutList.count();
|
||||
unsigned long long tMin[nCut] = {0xFFFFFFFFFFFFFFFF}, tMax[nCut] = {0};
|
||||
unsigned int count[nCut]={0};
|
||||
|
||||
|
||||
QList<QPolygonF> cutList1 = hXX->GetCutList();
|
||||
const int nCut1 = cutList1.count();
|
||||
unsigned long long tMin1[nCut1] = {0xFFFFFFFFFFFFFFFF}, tMax1[nCut1] = {0};
|
||||
unsigned int count1[nCut1]={0};
|
||||
|
||||
//============ Processing data and fill histograms
|
||||
long eventIndex = evtbder->eventIndex;
|
||||
long eventStart = eventIndex - eventBuilt + 1;
|
||||
if(eventStart < 0 ) eventStart += MaxNEvent;
|
||||
|
||||
for( long i = eventStart ; i <= eventIndex; i ++ ){
|
||||
std::vector<Hit> event = evtbder->events[i];
|
||||
//printf("-------------- %ld\n", i);
|
||||
|
||||
if( event.size() == 0 ) return;
|
||||
|
||||
for( int k = 0; k < (int) event.size(); k++ ){
|
||||
//event[k].Print();
|
||||
if( event[k].ch == 8 ) {dE = event[k].energy; dE_t = event[k].timestamp;} // Surface Barrier dE detector
|
||||
if( event[k].ch == 8 ) {E = event[k].energy; E_t = event[k].timestamp;} // Surface Barrier E detector
|
||||
|
||||
if( event[k].ch == 10 ) {e0 = event[k].energy; t0 = event[k].timestamp;} //
|
||||
if( event[k].ch == 11 ) {e1= event[k].energy; t1 = event[k].timestamp;} // The 4 output signals from the
|
||||
if( event[k].ch == 12 ) {e2 = event[k].energy; t2 = event[k].timestamp;} // position sensitive E detector
|
||||
if( event[k].ch == 13 ) {e3= event[k].energy; t3 = event[k].timestamp;} //
|
||||
|
||||
if( event[k].ch == 14 ) {dE1 = event[k].energy; dE1_t = event[k].timestamp;} // The 2 output signals from the
|
||||
if( event[k].ch == 15 ) {dE2= event[k].energy; dE2_t = event[k].timestamp;} // square dE detector
|
||||
}
|
||||
|
||||
// printf("(E, dE) = (%f, %f)\n", E, dE);
|
||||
hPID->Fill(E + RandomGauss(0, 100), dE+ RandomGauss(0, 100)); // x, y
|
||||
hXX->Fill(e1, e0); //
|
||||
hYY->Fill(e3, e2);
|
||||
hXY->Fill(((e0-e1)/(e0+e1)),((e2-e3)/(e2+e3)));
|
||||
hXE->Fill(e0+e1);
|
||||
hYE->Fill(e2+e3);
|
||||
hX->Fill(((e0-e1)/(e0+e1)));
|
||||
hY->Fill(((e2-e3)/(e2+e3)));
|
||||
hXPE->Fill(((e0-e1)/(e0+e1)),(e0+e1));
|
||||
hYPE->Fill(((e2-e3)/(e2+e3)),(e2+e3));
|
||||
hXEdE1->Fill((e0+e1),dE1);
|
||||
hYEdE1->Fill(e2+e3,dE1);
|
||||
hXEdE2->Fill(e0+e1,dE2);
|
||||
hYEdE2->Fill(e2+e3,dE2);
|
||||
hXYE->Fill(e0+e1,e2+e3);
|
||||
|
||||
//check events inside any Graphical cut and extract the rate
|
||||
for(int p = 0; p < cutList.count(); p++ ){
|
||||
if( cutList[p].isEmpty() ) continue;
|
||||
if( cutList[p].containsPoint(QPointF(E, dE), Qt::OddEvenFill) ){
|
||||
if( dE_t < tMin[p] ) tMin[p] = dE_t;
|
||||
if( dE_t > tMax[p] ) tMax[p] = dE_t;
|
||||
count[p] ++;
|
||||
printf("hPID.... %d \n", count[p]);
|
||||
}
|
||||
}
|
||||
|
||||
for(int p = 0; p < cutList1.count(); p++ ){
|
||||
if( cutList1[p].isEmpty() ) continue;
|
||||
if( cutList1[p].containsPoint(QPointF(e1, e0), Qt::OddEvenFill) ){
|
||||
if( t0 < tMin1[p] ) tMin1[p] = t0;
|
||||
if( t0 > tMax1[p] ) tMax1[p] = t0;
|
||||
count1[p] ++;
|
||||
printf("hXX.... %d \n", count1[p]);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
hPID->UpdatePlot();
|
||||
hXY->UpdatePlot();
|
||||
hXX->UpdatePlot();
|
||||
hYY->UpdatePlot();
|
||||
hXE->UpdatePlot();
|
||||
hYE->UpdatePlot();
|
||||
hX->UpdatePlot();
|
||||
hY->UpdatePlot();
|
||||
hXPE->UpdatePlot();
|
||||
hYPE->UpdatePlot();
|
||||
hXEdE1->UpdatePlot();
|
||||
hYEdE1->UpdatePlot();
|
||||
hXEdE2->UpdatePlot();
|
||||
hYEdE2->UpdatePlot();
|
||||
hXYE->UpdatePlot();
|
||||
|
||||
//========== output to Influx
|
||||
QList<QString> cutNameList = hPID->GetCutNameList();
|
||||
for( int p = 0; p < cutList.count(); p ++){
|
||||
if( cutList[p].isEmpty() ) continue;
|
||||
double dT = (tMax[p]-tMin[p]) * tick2ns / 1e9; // tick to sec
|
||||
double rate = count[p]*1.0/(dT);
|
||||
//printf("%llu %llu, %f %d\n", tMin[p], tMax[p], dT, count[p]);
|
||||
//printf("%10s | %d | %f Hz \n", cutNameList[p].toStdString().c_str(), count[p], rate);
|
||||
|
||||
influx->AddDataPoint("Cut,name=" + cutNameList[p].toStdString()+ " value=" + std::to_string(rate));
|
||||
influx->WriteData(dataBaseName.toStdString());
|
||||
influx->ClearDataPointsBuffer();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#endif
|
297
analyzers/RAISOR2.h
Normal file
297
analyzers/RAISOR2.h
Normal file
|
@ -0,0 +1,297 @@
|
|||
#ifndef RASIOR2_h
|
||||
#define RASIOR2_h
|
||||
|
||||
/*********************************************
|
||||
* This is online analyzer for RASIOR, ANL
|
||||
*
|
||||
* Created by Ryan @ 2023-10-16
|
||||
*
|
||||
* ******************************************/
|
||||
#include "Analyser.h"
|
||||
|
||||
|
||||
class RAISOR2 : public Analyzer{
|
||||
|
||||
public:
|
||||
RAISOR2(Digitizer ** digi, unsigned int nDigi, QMainWindow * parent = nullptr): Analyzer(digi, nDigi, parent){
|
||||
|
||||
|
||||
SetUpdateTimeInSec(4.0);
|
||||
|
||||
RedefineEventBuilder({0}); // only builder for the 0-th digitizer.
|
||||
tick2ns = digi[0]->GetTick2ns();
|
||||
|
||||
SetBackwardBuild(false, 100); // using normal building (acceding in time) or backward building, int the case of backward building, default events to be build is 100.
|
||||
evtbder = GetEventBuilder();
|
||||
evtbder->SetTimeWindow(500);
|
||||
|
||||
//========== use the influx from the Analyzer
|
||||
SetDatabase("https://localhost:8086", "testing", "zKhzKk4Yhf1l9QU-yE2GsIZ1RazqUgoW3NlF8LJqq_xDMwatOJwg1sKrjgq36uLEsQf8Fmn4sJALP7Kkilk14A==");
|
||||
|
||||
SetUpCanvas(); // see below
|
||||
|
||||
};
|
||||
|
||||
void SetUpCanvas();
|
||||
|
||||
public slots:
|
||||
void UpdateHistograms();
|
||||
|
||||
|
||||
private:
|
||||
|
||||
MultiBuilder *evtbder;
|
||||
|
||||
Histogram2D * hPID;
|
||||
|
||||
Histogram2D * hXX; // X1 versus X2 : e[1] versus e[0]
|
||||
Histogram2D * hYY; // Y1 versus Y2 : e[3] versus e[2]
|
||||
|
||||
Histogram1D * hXE; // X energy: e[0]+e[1]
|
||||
Histogram1D * hYE; // Y energy: e[2]+e[3]
|
||||
|
||||
Histogram2D * hXYE; // 2D energy plot: e[2]+e[3] versus e[0]+e[1]
|
||||
|
||||
Histogram1D * hX; // X position:((e[0]-e[1])/(e[0]+e[1]))
|
||||
Histogram1D * hY; // Y position:((e[2]-e[3])/(e[2]+e[3]))
|
||||
|
||||
Histogram2D * hXY; // 2D position plot: ((e[2]-e[3])/(e[2]+e[3])) versus ((e[0]-e[1])/(e[0]+e[1]))
|
||||
|
||||
|
||||
Histogram2D * hXPE; // X position versus X energy: ((e[0]-e[1])/(e[0]+e[1])) versus (e[0]+e[1])
|
||||
Histogram2D * hYPE; // Y position versus Y energy: ((e[2]-e[3])/(e[2]+e[3])) versus (e[2]+e[3])
|
||||
|
||||
//TH1F * hX1, * hX2, * hY1, *hY2;
|
||||
|
||||
Histogram2D * hXEdE1; //X energy versus dE signal 1
|
||||
Histogram2D * hYEdE1; //Y energy versus dE signal 1
|
||||
|
||||
Histogram2D * hXEdE2; //X energy versus dE signal 2
|
||||
Histogram2D * hYEdE2; //Y energy versus dE signal 2
|
||||
|
||||
Histogram1D * hX1, * hX2, * hY1, * hY2;
|
||||
|
||||
int chX1, chX2; // yellow, Red
|
||||
int chY1, chY2; // Blue, White
|
||||
|
||||
int tick2ns;
|
||||
|
||||
float dE, E;
|
||||
unsigned long long dE_t, E_t;
|
||||
|
||||
float e0, e1, e2, e3, dE1, dE2;
|
||||
unsigned long long t0, t1, t2, t3, dE1_t, dE2_t;
|
||||
//unsigned Int_t * energy;
|
||||
//unsigned long energy;
|
||||
/*
|
||||
chX1 = 0; // left
|
||||
chX2 = 1; // right
|
||||
|
||||
chY1 = 2; // top
|
||||
chY2 = 3; // bottom
|
||||
*/
|
||||
|
||||
};
|
||||
|
||||
|
||||
inline void RAISOR2::SetUpCanvas(){
|
||||
|
||||
setGeometry(0, 0, 1500, 2000);
|
||||
|
||||
//============ histograms
|
||||
hPID = new Histogram2D("RAISOR2", "E", "dE", 100, 0, 11000, 100, 0, 11000, this);
|
||||
layout->addWidget(hPID, 0, 0);
|
||||
|
||||
hXY = new Histogram2D("2D position plot", "X position", "Y position", 200, -1, 1, 200, -1, 1, this);
|
||||
layout->addWidget(hXY, 0, 1);
|
||||
|
||||
hXX = new Histogram2D("X1 versus X2", "X2", "X1", 100, 0, 8000, 100, 0, 8000, this);
|
||||
layout->addWidget(hXX, 0, 2);
|
||||
|
||||
hYY = new Histogram2D("Y1 versus Y2", "Y2", "Y1", 100, 0, 8000, 100, 0, 8000, this);
|
||||
layout->addWidget(hYY, 0, 3);
|
||||
|
||||
hXE = new Histogram1D("X energy", "Ex", 300, 0, 8000, this);
|
||||
layout->addWidget(hXE, 1, 0);
|
||||
|
||||
hYE = new Histogram1D("Y energy", "Ey", 300, 0, 8000, this);
|
||||
layout->addWidget(hYE, 1, 1);
|
||||
|
||||
hX = new Histogram1D("X position", "X", 300, -1, 1, this);
|
||||
layout->addWidget(hX, 1, 2);
|
||||
|
||||
hY = new Histogram1D("Y position", "Y", 300, -1, 1, this);
|
||||
layout->addWidget(hY, 1, 3);
|
||||
|
||||
hXPE = new Histogram2D("X energy versus X position", "X position", "X energy", 100, -1, 1, 100, 0, 8000, this);
|
||||
layout->addWidget(hXPE, 0, 4);
|
||||
|
||||
hYPE = new Histogram2D("Y energy versus Y position", "Y position", "Y energy", 100, -1, 1, 100, 0, 8000, this);
|
||||
layout->addWidget(hYPE, 1, 4);
|
||||
|
||||
hXEdE1 = new Histogram2D("X energy versus dE signal 1", "Ex", "dE signal 1", 100, 0, 8000, 100, 0, 8000, this);
|
||||
layout->addWidget(hXEdE1, 2, 0);
|
||||
|
||||
hYEdE1 = new Histogram2D("Y energy versus dE signal 1", "Ey", "dE signal 1", 100, 0, 8000, 100, 0, 8000, this);
|
||||
layout->addWidget(hYEdE1, 2, 1);
|
||||
|
||||
hXEdE2 = new Histogram2D("X energy versus dE signal 2", "Ex", "dE signal 2", 100, 0, 8000, 100, 0, 8000, this);
|
||||
layout->addWidget(hXEdE2, 2, 2);
|
||||
|
||||
hYEdE2 = new Histogram2D("Y energy versus dE signal 2", "Ey", "dE signal 2", 100, 0, 8000, 100, 0, 8000, this);
|
||||
layout->addWidget(hYEdE2, 2, 3);
|
||||
|
||||
hXYE = new Histogram2D("2D energy plot", "Ex", "Ey", 100, 0, 8000, 100, 0, 8000, this);
|
||||
layout->addWidget(hXYE, 2, 4);
|
||||
|
||||
|
||||
}
|
||||
|
||||
inline void RAISOR2::UpdateHistograms(){
|
||||
|
||||
if( this->isVisible() == false ) return;
|
||||
|
||||
BuildEvents(false); // call the event builder to build events
|
||||
|
||||
//============ Get events, and do analysis
|
||||
long eventBuilt = evtbder->eventBuilt;
|
||||
if( eventBuilt == 0 ) return;
|
||||
|
||||
//============ Get the cut list, if any
|
||||
QList<QPolygonF> cutList = hPID->GetCutList();
|
||||
const int nCut = cutList.count();
|
||||
unsigned long long tMin[nCut] = {0xFFFFFFFFFFFFFFFF}, tMax[nCut] = {0};
|
||||
unsigned int count[nCut]={0};
|
||||
|
||||
QList<QPolygonF> cutList1 = hXEdE1->GetCutList();
|
||||
const int nCut1 = cutList1.count();
|
||||
unsigned long long tMin1[nCut1] = {0xFFFFFFFFFFFFFFFF}, tMax1[nCut1] = {0};
|
||||
unsigned int count1[nCut1]={0};
|
||||
|
||||
QList<QPolygonF> cutList2 = hYEdE1->GetCutList();
|
||||
const int nCut2 = cutList2.count();
|
||||
unsigned long long tMin2[nCut2] = {0xFFFFFFFFFFFFFFFF}, tMax2[nCut2] = {0};
|
||||
unsigned int count2[nCut2]={0};
|
||||
|
||||
QList<QPolygonF> cutList3 = hXY->GetCutList();
|
||||
const int nCut3 = cutList3.count();
|
||||
unsigned long long tMin3[nCut3] = {0xFFFFFFFFFFFFFFFF}, tMax3[nCut3] = {0};
|
||||
unsigned int count3[nCut3]={0};
|
||||
//============ Processing data and fill histograms
|
||||
long eventIndex = evtbder->eventIndex;
|
||||
long eventStart = eventIndex - eventBuilt + 1;
|
||||
if(eventStart < 0 ) eventStart += MaxNEvent;
|
||||
|
||||
for( long i = eventStart ; i <= eventIndex; i ++ ){
|
||||
std::vector<Hit> event = evtbder->events[i];
|
||||
//printf("-------------- %ld\n", i);
|
||||
|
||||
if( event.size() == 0 ) return;
|
||||
|
||||
for( int k = 0; k < (int) event.size(); k++ ){
|
||||
//event[k].Print();
|
||||
if( event[k].ch == 14 ) {dE = event[k].energy; dE_t = event[k].timestamp;} // Surface Barrier dE detector
|
||||
if( event[k].ch == 15 ) {E = event[k].energy; E_t = event[k].timestamp;} // Surface Barrier E detector
|
||||
|
||||
if( event[k].ch == 10 ) {e0 = event[k].energy; t0 = event[k].timestamp;} //
|
||||
if( event[k].ch == 11 ) {e1= event[k].energy; t1 = event[k].timestamp;} // The 4 output signals from the
|
||||
if( event[k].ch == 12 ) {e2 = event[k].energy; t2 = event[k].timestamp;} // position sensitive E detector
|
||||
if( event[k].ch == 13 ) {e3= event[k].energy; t3 = event[k].timestamp;} //
|
||||
|
||||
if( event[k].ch == 14 ) {dE1 = event[k].energy; dE1_t = event[k].timestamp;} // The 2 output signals from the
|
||||
if( event[k].ch == 15 ) {dE2= event[k].energy; dE2_t = event[k].timestamp;} // square dE detector
|
||||
}
|
||||
|
||||
// printf("(E, dE) = (%f, %f)\n", E, dE);
|
||||
hPID->Fill(E + RandomGauss(0, 100), dE+ RandomGauss(0, 100)); // x, y
|
||||
hXX->Fill(e1 , e0); //
|
||||
hYY->Fill(e3, e2);
|
||||
hXY->Fill(((e0-e1)/(e0+e1)),((e3-e2)/(e2+e3)));
|
||||
hXE->Fill(e0+e1);
|
||||
hYE->Fill(e2+e3);
|
||||
hX->Fill(((e0-e1)/(e0+e1))); // X position
|
||||
hY->Fill(((e3-e2)/(e2+e3))); // Y position
|
||||
hXPE->Fill(((e0-e1)/(e0+e1)),(e0+e1));
|
||||
hYPE->Fill(((e3-e2)/(e2+e3)),(e2+e3));
|
||||
hXEdE1->Fill((e0+e1),dE1);
|
||||
hYEdE1->Fill(e2+e3,dE1);
|
||||
hXEdE2->Fill(e0+e1,dE2);
|
||||
hYEdE2->Fill(e2+e3,dE2);
|
||||
hXYE->Fill(e0+e1,e2+e3);
|
||||
|
||||
//check events inside any Graphical cut and extract the rate
|
||||
for(int p = 0; p < cutList.count(); p++ ){
|
||||
if( cutList[p].isEmpty() ) continue;
|
||||
if( cutList[p].containsPoint(QPointF(E, dE), Qt::OddEvenFill) ){
|
||||
if( dE_t < tMin[p] ) tMin[p] = dE_t;
|
||||
if( dE_t > tMax[p] ) tMax[p] = dE_t;
|
||||
count[p] ++;
|
||||
//printf(".... %d \n", count[p]);
|
||||
}
|
||||
}
|
||||
|
||||
for(int p = 0; p < cutList1.count(); p++ ){
|
||||
if( cutList1[p].isEmpty() ) continue;
|
||||
if( cutList1[p].containsPoint(QPointF((e0+e1), dE1), Qt::OddEvenFill) ){
|
||||
if( dE1_t < tMin1[p] ) tMin1[p] = dE1_t;
|
||||
if( dE1_t > tMax1[p] ) tMax1[p] = dE1_t;
|
||||
count1[p] ++;
|
||||
//printf("hXX.... %d \n", count1[p]);
|
||||
}
|
||||
}
|
||||
|
||||
for(int p = 0; p < cutList2.count(); p++ ){
|
||||
if( cutList2[p].isEmpty() ) continue;
|
||||
if( cutList2[p].containsPoint(QPointF((e2+e3), dE1), Qt::OddEvenFill) ){
|
||||
if( dE1_t < tMin2[p] ) tMin2[p] = dE1_t;
|
||||
if( dE1_t > tMax2[p] ) tMax2[p] = dE1_t;
|
||||
count2[p] ++;
|
||||
//printf("hXX.... %d \n", count2[p]);
|
||||
}
|
||||
}
|
||||
|
||||
for(int p = 0; p < cutList3.count(); p++ ){
|
||||
if( cutList3[p].isEmpty() ) continue;
|
||||
if( cutList3[p].containsPoint(QPointF(((e0-e1)/(e0+e1)), ((e2-e3)/(e2+e3))), Qt::OddEvenFill) ){
|
||||
if( ((t2-t3)/(t2+t3)) < tMin3[p] ) tMin3[p] = ((t2-t3)/(t2+t3));
|
||||
if( ((t2-t3)/(t2+t3)) > tMax3[p] ) tMax3[p] = ((t2-t3)/(t2+t3));
|
||||
count3[p] ++;
|
||||
//printf("hXX.... %d \n", count3[p]);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
hPID->UpdatePlot();
|
||||
hXY->UpdatePlot();
|
||||
hXX->UpdatePlot();
|
||||
hYY->UpdatePlot();
|
||||
hXE->UpdatePlot(); // X Energy
|
||||
hYE->UpdatePlot(); // Y Energy
|
||||
hX->UpdatePlot(); // X position
|
||||
hY->UpdatePlot(); // Y position
|
||||
hXPE->UpdatePlot();
|
||||
hYPE->UpdatePlot();
|
||||
hXEdE1->UpdatePlot();
|
||||
hYEdE1->UpdatePlot();
|
||||
hXEdE2->UpdatePlot();
|
||||
hYEdE2->UpdatePlot();
|
||||
hXYE->UpdatePlot();
|
||||
|
||||
//========== output to Influx
|
||||
QList<QString> cutNameList = hPID->GetCutNameList();
|
||||
for( int p = 0; p < cutList.count(); p ++){
|
||||
if( cutList[p].isEmpty() ) continue;
|
||||
double dT = (tMax[p]-tMin[p]) * tick2ns / 1e9; // tick to sec
|
||||
double rate = count[p]*1.0/(dT);
|
||||
//printf("%llu %llu, %f %d\n", tMin[p], tMax[p], dT, count[p]);
|
||||
//printf("%10s | %d | %f Hz \n", cutNameList[p].toStdString().c_str(), count[p], rate);
|
||||
|
||||
influx->AddDataPoint("Cut,name=" + cutNameList[p].toStdString()+ " value=" + std::to_string(rate));
|
||||
influx->WriteData(dataBaseName.toStdString());
|
||||
influx->ClearDataPointsBuffer();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#endif
|
|
@ -8,9 +8,10 @@ The AnalyzerWorker moves to the QThread. QTimer::timeout will trigger AnalyzerWo
|
|||
|
||||
There is an important bool 'isWorking'. This boolean variable is true when AnalyzerWorker::UpdateHistograms() is running, and it is false when finsihed. This prevent UpdateHistograms() runs twice at the same time.
|
||||
|
||||
There are two virual methods
|
||||
There are three virual methods
|
||||
- SetupCanvas()
|
||||
- UpdateHistograms()
|
||||
- ReplotHistograms()
|
||||
|
||||
Users must implement these two methods in theie custom analyzer.
|
||||
|
||||
|
@ -33,6 +34,7 @@ public:
|
|||
void SetUpCanvas();
|
||||
public slots:
|
||||
void UpdateHistograms();
|
||||
void ReplotHistograms();
|
||||
|
||||
private:
|
||||
|
||||
|
@ -84,10 +86,14 @@ inline void CustomAnalyzer::UpdateHistograms(){
|
|||
|
||||
//analysis and fill historgam
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
4. implement the ReplotHistograms() method
|
||||
```cpp
|
||||
inline void CustomAnalyzer::ReplotHistograms(){
|
||||
//Render histograms
|
||||
h2D->UpdatePlot();
|
||||
h1D->UpdatePlot();
|
||||
|
||||
}
|
||||
```
|
271
analyzers/TEST.h
Normal file
271
analyzers/TEST.h
Normal file
|
@ -0,0 +1,271 @@
|
|||
#ifndef TEST_h
|
||||
#define TEST_h
|
||||
|
||||
/*********************************************
|
||||
* This is online analyzer for RASIOR, ANL
|
||||
*
|
||||
* Created by Ryan @ 2023-10-16
|
||||
*
|
||||
* ******************************************/
|
||||
#include "Analyser.h"
|
||||
|
||||
|
||||
class TEST : public Analyzer{
|
||||
|
||||
public:
|
||||
TEST(Digitizer ** digi, unsigned int nDigi, QMainWindow * parent = nullptr): Analyzer(digi, nDigi, parent){
|
||||
|
||||
|
||||
SetUpdateTimeInSec(4.0);
|
||||
|
||||
RedefineEventBuilder({0}); // only builder for the 0-th digitizer.
|
||||
tick2ns = digi[0]->GetTick2ns();
|
||||
|
||||
SetBackwardBuild(false, 100); // using normal building (acceding in time) or backward building, int the case of backward building, default events to be build is 100.
|
||||
evtbder = GetEventBuilder();
|
||||
evtbder->SetTimeWindow(500);
|
||||
|
||||
SetDatabase("https://localhost:8086", "testing", "zKhzKk4Yhf1l9QU-yE2GsIZ1RazqUgoW3NlF8LJqq_xDMwatOJwg1sKrjgq36uLEsQf8Fmn4sJALP7Kkilk14A==");
|
||||
|
||||
SetUpCanvas(); // see below
|
||||
|
||||
};
|
||||
|
||||
void SetUpCanvas();
|
||||
|
||||
public slots:
|
||||
void UpdateHistograms();
|
||||
|
||||
|
||||
private:
|
||||
|
||||
MultiBuilder *evtbder;
|
||||
|
||||
Histogram2D * hPID;
|
||||
|
||||
Histogram2D * hXX; // X1 versus X2 : e[1] versus e[0]
|
||||
Histogram2D * hYY; // Y1 versus Y2 : e[3] versus e[2]
|
||||
|
||||
Histogram1D * hXE; // X energy: e[0]+e[1]
|
||||
Histogram1D * hYE; // Y energy: e[2]+e[3]
|
||||
|
||||
Histogram2D * hXYE; // 2D energy plot: e[2]+e[3] versus e[0]+e[1]
|
||||
|
||||
Histogram1D * hX; // X position:((e[0]-e[1])/(e[0]+e[1]))
|
||||
Histogram1D * hY; // Y position:((e[2]-e[3])/(e[2]+e[3]))
|
||||
|
||||
Histogram2D * hXY; // 2D position plot: ((e[2]-e[3])/(e[2]+e[3])) versus ((e[0]-e[1])/(e[0]+e[1]))
|
||||
|
||||
|
||||
Histogram2D * hXPE; // X position versus X energy: ((e[0]-e[1])/(e[0]+e[1])) versus (e[0]+e[1])
|
||||
Histogram2D * hYPE; // Y position versus Y energy: ((e[2]-e[3])/(e[2]+e[3])) versus (e[2]+e[3])
|
||||
|
||||
//TH1F * hX1, * hX2, * hY1, *hY2;
|
||||
|
||||
Histogram2D * hXEdE1; //X energy versus dE signal 1
|
||||
Histogram2D * hYEdE1; //Y energy versus dE signal 1
|
||||
|
||||
Histogram2D * hXEdE2; //X energy versus dE signal 2
|
||||
Histogram2D * hYEdE2; //Y energy versus dE signal 2
|
||||
|
||||
Histogram1D * hX1, * hX2, * hY1, * hY2;
|
||||
|
||||
int chX1, chX2; // yellow, Red
|
||||
int chY1, chY2; // Blue, White
|
||||
|
||||
int tick2ns;
|
||||
|
||||
float dE, E;
|
||||
unsigned long long dE_t, E_t;
|
||||
|
||||
float e0, e1, e2, e3, dE1, dE2;
|
||||
unsigned long long t0, t1, t2, t3, dE1_t, dE2_t;
|
||||
//unsigned Int_t * energy;
|
||||
//unsigned long energy;
|
||||
/*
|
||||
chX1 = 0; // left
|
||||
chX2 = 1; // right
|
||||
|
||||
chY1 = 2; // top
|
||||
chY2 = 3; // bottom
|
||||
*/
|
||||
|
||||
};
|
||||
|
||||
|
||||
inline void TEST::SetUpCanvas(){
|
||||
|
||||
setGeometry(0, 0, 1500, 2000);
|
||||
|
||||
//============ histograms
|
||||
hPID = new Histogram2D("Test", "E", "dE", 100, 0, 11500, 100, 0, 11500, this);
|
||||
layout->addWidget(hPID, 0, 0);
|
||||
|
||||
hXY = new Histogram2D("2D position plot", "X position", "Y position", 100, -100, 100, 100, -100, 100, this);
|
||||
layout->addWidget(hXY, 0, 1);
|
||||
|
||||
hXX = new Histogram2D("X1 versus X2", "X2", "X1", 100, 0, 12500, 100, 0, 12500, this);
|
||||
layout->addWidget(hXX, 0, 2);
|
||||
|
||||
hYY = new Histogram2D("Y1 versus Y2", "Y2", "Y1", 100, -2000, 12500, 100, -2000, 12500, this);
|
||||
layout->addWidget(hYY, 0, 3);
|
||||
|
||||
hXE = new Histogram1D("X energy", "Ex", 300, -500, 25000, this);
|
||||
layout->addWidget(hXE, 1, 0);
|
||||
|
||||
hYE = new Histogram1D("Y energy", "Ey", 300, -500, 25000, this);
|
||||
layout->addWidget(hYE, 1, 1);
|
||||
|
||||
hX = new Histogram1D("X position", "X", 300, -1, 1, this);
|
||||
layout->addWidget(hX, 1, 2);
|
||||
|
||||
hY = new Histogram1D("Y position", "Y", 300, -1, 1, this);
|
||||
layout->addWidget(hY, 1, 3);
|
||||
|
||||
hXPE = new Histogram2D("X energy versus X position", "X position", "X energy", 100, -1, 1, 100, -2000, 25000, this);
|
||||
layout->addWidget(hXPE, 0, 4);
|
||||
|
||||
hYPE = new Histogram2D("Y energy versus Y position", "Y position", "Y energy", 100, -1000, 1000, 100, -2000, 30000, this);
|
||||
layout->addWidget(hYPE, 1, 4);
|
||||
|
||||
hXEdE1 = new Histogram2D("X energy versus dE signal 1", "Ex", "dE signal 1", 100, -500, 25000, 100, -200, 12500, this);
|
||||
layout->addWidget(hXEdE1, 2, 0);
|
||||
|
||||
hYEdE1 = new Histogram2D("Y energy versus dE signal 1", "Ey", "dE signal 1", 100, -500, 25000, 100, -2000, 12500, this);
|
||||
layout->addWidget(hYEdE1, 2, 1);
|
||||
|
||||
hXEdE2 = new Histogram2D("X energy versus dE signal 2", "Ex", "dE signal 2", 100, -500, 25000, 100, -500, 12500, this);
|
||||
layout->addWidget(hXEdE2, 2, 2);
|
||||
|
||||
hYEdE2 = new Histogram2D("Y energy versus dE signal 2", "Ey", "dE signal 2", 100, -500, 25000, 100, -2000, 12500, this);
|
||||
layout->addWidget(hYEdE2, 2, 3);
|
||||
|
||||
hXYE = new Histogram2D("2D energy plot", "Ex", "Ey", 100, 0, 25000, 100, 0, 30000, this);
|
||||
layout->addWidget(hXYE, 2, 4);
|
||||
|
||||
|
||||
}
|
||||
|
||||
inline void TEST::UpdateHistograms(){
|
||||
|
||||
if( this->isVisible() == false ) return;
|
||||
|
||||
BuildEvents(false); // call the event builder to build events
|
||||
|
||||
//============ Get events, and do analysis
|
||||
long eventBuilt = evtbder->eventBuilt;
|
||||
if( eventBuilt == 0 ) return;
|
||||
|
||||
//============ Get the cut list, if any
|
||||
QList<QPolygonF> cutList = hPID->GetCutList();
|
||||
const int nCut = cutList.count();
|
||||
unsigned long long tMin[nCut] = {0xFFFFFFFFFFFFFFFF}, tMax[nCut] = {0};
|
||||
unsigned int count[nCut]={0};
|
||||
|
||||
QList<QPolygonF> cutList1 = hXX->GetCutList();
|
||||
const int nCut1 = cutList1.count();
|
||||
unsigned long long tMin1[nCut1] = {0xFFFFFFFFFFFFFFFF}, tMax1[nCut1] = {0};
|
||||
unsigned int count1[nCut1]={0};
|
||||
|
||||
//============ Processing data and fill histograms
|
||||
long eventIndex = evtbder->eventIndex;
|
||||
long eventStart = eventIndex - eventBuilt + 1;
|
||||
if(eventStart < 0 ) eventStart += MaxNEvent;
|
||||
|
||||
for( long i = eventStart ; i <= eventIndex; i ++ ){
|
||||
std::vector<Hit> event = evtbder->events[i];
|
||||
//printf("-------------- %ld\n", i);
|
||||
|
||||
if( event.size() == 0 ) return;
|
||||
|
||||
|
||||
for( int k = 0; k < (int) event.size(); k++ ){
|
||||
//event[k].Print();
|
||||
if( event[k].ch == 8 ) {dE = event[k].energy; dE_t = event[k].timestamp;} // Surface Barrier dE detector
|
||||
if( event[k].ch == 8 ) {E = event[k].energy; E_t = event[k].timestamp;} // Surface Barrier E detector
|
||||
|
||||
if( event[k].ch == 8 ) {e0 = event[k].energy; t0 = event[k].timestamp;} //
|
||||
if( event[k].ch == 8 ) {e1= event[k].energy; t1 = event[k].timestamp;} // The 4 output signals from the
|
||||
if( event[k].ch == 8 ) {e2 = event[k].energy; t2 = event[k].timestamp;} // position sensitive E detector
|
||||
if( event[k].ch == 8 ) {e3= event[k].energy; t3 = event[k].timestamp;} //
|
||||
|
||||
if( event[k].ch == 8 ) {dE1 = event[k].energy; dE1_t = event[k].timestamp;} // The 2 output signals from the
|
||||
if( event[k].ch == 8 ) {dE2= event[k].energy; dE2_t = event[k].timestamp;} // square dE detector
|
||||
}
|
||||
|
||||
// printf("(E, dE) = (%f, %f)\n", E, dE);
|
||||
hPID->Fill(E + RandomGauss(0, 100), dE + RandomGauss(0, 100)); // x, y
|
||||
//hXX->Fill(e1 + RandomGauss(0, 100), e0 + RandomGauss(0, 100)); //
|
||||
hXX->Fill(e1, e0 ); //
|
||||
hYY->Fill(e3 + RandomGauss(0, 100), e2 + RandomGauss(0, 100));
|
||||
hXY->Fill(((e0-e1)/(e0+e1)) + RandomGauss(0, 100),((e2-e3)/(e2+e3)) + RandomGauss(0, 100));
|
||||
hXE->Fill(e0+e1);
|
||||
hYE->Fill(e2+e3);
|
||||
hX->Fill(((e0-e1)/(e0+e1)));
|
||||
hY->Fill(((e2-e3)/(e2+e3)));
|
||||
hXPE->Fill(((e0-e1)/(e0+e1)) + RandomGauss(0, 100),(e0+e1) + RandomGauss(0, 100));
|
||||
hYPE->Fill(((e2-e3)/(e2+e3)) + RandomGauss(0, 100),(e2+e3) + RandomGauss(0, 100));
|
||||
hXEdE1->Fill((e0+e1)+ RandomGauss(0, 100),dE1 + RandomGauss(0, 100));
|
||||
hYEdE1->Fill((e2+e3) + RandomGauss(0, 100),dE1 + RandomGauss(0, 100));
|
||||
hXEdE2->Fill((e0+e1)+ RandomGauss(0, 100),dE2 + RandomGauss(0, 100));
|
||||
hYEdE2->Fill((e2+e3)+ RandomGauss(0, 100),dE2 + + RandomGauss(0, 100));
|
||||
hXYE->Fill((e0+e1) + RandomGauss(0, 100),(e2+e3) + RandomGauss(0, 100));
|
||||
|
||||
//check events inside any Graphical cut and extract the rate
|
||||
for(int p = 0; p < cutList.count(); p++ ){
|
||||
if( cutList[p].isEmpty() ) continue;
|
||||
if( cutList[p].containsPoint(QPointF(E, dE), Qt::OddEvenFill) ){
|
||||
if( dE_t < tMin[p] ) tMin[p] = dE_t;
|
||||
if( dE_t > tMax[p] ) tMax[p] = dE_t;
|
||||
count[p] ++;
|
||||
//printf(".... %d \n", count[p]);
|
||||
}
|
||||
}
|
||||
|
||||
for(int p = 0; p < cutList1.count(); p++ ){
|
||||
if( cutList1[p].isEmpty() ) continue;
|
||||
if( cutList1[p].containsPoint(QPointF(e1, e0), Qt::OddEvenFill) ){
|
||||
if( t0 < tMin1[p] ) tMin1[p] = t0;
|
||||
if( t0 > tMax1[p] ) tMax1[p] = t0;
|
||||
count1[p] ++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for(int p = 0; p < cutList1.count(); p++ ){
|
||||
printf("hXX.... %d %d \n", p, count1[p]);
|
||||
}
|
||||
|
||||
hPID->UpdatePlot();
|
||||
hXY->UpdatePlot();
|
||||
hXX->UpdatePlot();
|
||||
hYY->UpdatePlot();
|
||||
hXE->UpdatePlot();
|
||||
hYE->UpdatePlot();
|
||||
hX->UpdatePlot();
|
||||
hY->UpdatePlot();
|
||||
hXPE->UpdatePlot();
|
||||
hYPE->UpdatePlot();
|
||||
hXEdE1->UpdatePlot();
|
||||
hYEdE1->UpdatePlot();
|
||||
hXEdE2->UpdatePlot();
|
||||
hYEdE2->UpdatePlot();
|
||||
hXYE->UpdatePlot();
|
||||
|
||||
//========== output to Influx
|
||||
QList<QString> cutNameList = hPID->GetCutNameList();
|
||||
for( int p = 0; p < cutList.count(); p ++){
|
||||
if( cutList[p].isEmpty() ) continue;
|
||||
double dT = (tMax[p]-tMin[p]) * tick2ns / 1e9; // tick to sec
|
||||
double rate = count[p]*1.0/(dT);
|
||||
//printf("%llu %llu, %f %d\n", tMin[p], tMax[p], dT, count[p]);
|
||||
//printf("%10s | %d | %f Hz \n", cutNameList[p].toStdString().c_str(), count[p], rate);
|
||||
|
||||
influx->AddDataPoint("Cut,name=" + cutNameList[p].toStdString()+ " value=" + std::to_string(rate));
|
||||
influx->WriteData(dataBaseName.toStdString());
|
||||
influx->ClearDataPointsBuffer();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#endif
|
229
analyzers/Target.h
Normal file
229
analyzers/Target.h
Normal file
|
@ -0,0 +1,229 @@
|
|||
#ifndef Target_h
|
||||
#define Target_h
|
||||
|
||||
/*********************************************
|
||||
* This is online analyzer for PID, ANL
|
||||
*
|
||||
* Created by Khushi @ 2024-09-03
|
||||
*
|
||||
* ******************************************/
|
||||
#include "Analyser.h"
|
||||
|
||||
|
||||
class Target : public Analyzer{
|
||||
|
||||
|
||||
|
||||
public:
|
||||
Target(Digitizer ** digi, unsigned int nDigi, QMainWindow * parent = nullptr): Analyzer(digi, nDigi, parent){
|
||||
|
||||
|
||||
SetUpdateTimeInSec(2.0);
|
||||
|
||||
RedefineEventBuilder({0}); // only builder for the 0-th digitizer.
|
||||
tick2ns = digi[0]->GetTick2ns();
|
||||
|
||||
SetBackwardBuild(false, 100); // using normal building (acceding in time) or backward building, int the case of backward building, default events to be build is 100.
|
||||
evtbder = GetEventBuilder();
|
||||
evtbder->SetTimeWindow(500);
|
||||
|
||||
SetDatabase("https://localhost:8086", "testing", "zKhzKk4Yhf1l9QU-yE2GsIZ1RazqUgoW3NlF8LJqq_xDMwatOJwg1sKrjgq36uLEsQf8Fmn4sJALP7Kkilk14A==");
|
||||
|
||||
SetUpCanvas(); // see below
|
||||
|
||||
};
|
||||
|
||||
void SetUpCanvas();
|
||||
|
||||
public slots:
|
||||
void UpdateHistograms();
|
||||
|
||||
|
||||
private:
|
||||
|
||||
MultiBuilder *evtbder;
|
||||
|
||||
//Histogram2D * hPID;
|
||||
|
||||
Histogram1D * hdE; // raw dE (ch=1): ch1
|
||||
Histogram1D * hE; // raw E (ch=4) : ch4
|
||||
Histogram1D * hdT; // raw dT (ch=7): ch7
|
||||
|
||||
Histogram1D * hTotE; // total energy (dE+E): ch1+ch4
|
||||
Histogram1D * hTWin; // coincidence time window TWin: (t4-t1)*1e9
|
||||
|
||||
Histogram2D * hdEE; // dE versus E : ch1 versus ch4
|
||||
Histogram2D * hdEtotE; // dE versus totE : ch1 versus (ch1+ch4)
|
||||
|
||||
Histogram2D * hdEdT; // dE versus TOF: ch1 versus (t7-t1)*1e9
|
||||
|
||||
|
||||
int tick2ns;
|
||||
|
||||
float ch1, ch4, ch7;
|
||||
unsigned long long t1, t4, t7;
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
inline void Target::SetUpCanvas(){
|
||||
|
||||
setGeometry(0, 0, 2000, 1000);
|
||||
|
||||
//============ histograms
|
||||
|
||||
//hPID = new Histogram2D("RAISOR", "E", "dE", 100, 0, 5000, 100, 0, 5000, this);
|
||||
//layout->addWidget(hPID, 2, 0);
|
||||
|
||||
hdEE = new Histogram2D("dE vs E", "E[ch]", "dE[ch]", 500, -100, 10000, 500, -100, 10000, this);
|
||||
layout->addWidget(hdEE, 0, 0, 1, 2);
|
||||
|
||||
hdE = new Histogram1D("raw dE (ch=1)", "dE [ch]", 300, 0, 8000, this);
|
||||
layout->addWidget(hdE, 0, 2);
|
||||
|
||||
hdEdT = new Histogram2D("dE vs TOF", "TOF [ns]", "dE", 100, 0, 500, 100, 0, 4000, this);
|
||||
layout->addWidget(hdEdT, 1, 3);
|
||||
|
||||
hE = new Histogram1D("raw E (ch=4)", "E [ch]", 300, 0, 10000, this);
|
||||
layout->addWidget(hE, 0, 3);
|
||||
|
||||
hdEtotE = new Histogram2D("dE vs TotE", "TotE[ch]", "dE[ch]", 500, 0, 10000, 500, 0, 10000, this);
|
||||
layout->addWidget(hdEtotE, 1, 0, 1, 2);
|
||||
|
||||
hdT = new Histogram1D("raw dT (ch=7)", "dT [ch]", 300, 0, 1000, this);
|
||||
layout->addWidget(hdT, 1, 2);
|
||||
|
||||
hTotE = new Histogram1D("total energy (dE+E)", "TotE [ch]", 300, 0, 16000, this);
|
||||
layout->addWidget(hTotE, 0, 4);
|
||||
|
||||
hTWin = new Histogram1D("coincidence time window", "TWin [ns]", 300, 0, 500, this);
|
||||
layout->addWidget(hTWin, 1, 4);
|
||||
|
||||
}
|
||||
|
||||
inline void Target::UpdateHistograms(){
|
||||
|
||||
if( this->isVisible() == false ) return;
|
||||
|
||||
BuildEvents(false); // call the event builder to build events
|
||||
|
||||
//============ Get events, and do analysis
|
||||
long eventBuilt = evtbder->eventBuilt;
|
||||
if( eventBuilt == 0 ) return;
|
||||
|
||||
//============ Get the cut list, if any
|
||||
/*
|
||||
QList<QPolygonF> cutList = hPID->GetCutList();
|
||||
const int nCut = cutList.count();
|
||||
unsigned long long tMin[nCut] = {0xFFFFFFFFFFFFFFFF}, tMax[nCut] = {0};
|
||||
unsigned int count[nCut]={0};
|
||||
*/
|
||||
QList<QPolygonF> cutList1 = hdEE->GetCutList();
|
||||
const int nCut1 = cutList1.count();
|
||||
unsigned long long tMin1[nCut1] = {0xFFFFFFFFFFFFFFFF}, tMax1[nCut1] = {0};
|
||||
unsigned int count1[nCut1]={0};
|
||||
|
||||
QList<QPolygonF> cutList2 = hdEtotE->GetCutList();
|
||||
const int nCut2 = cutList2.count();
|
||||
unsigned long long tMin2[nCut2] = {0xFFFFFFFFFFFFFFFF}, tMax2[nCut2] = {0};
|
||||
unsigned int count2[nCut2]={0};
|
||||
|
||||
//============ Processing data and fill histograms
|
||||
long eventIndex = evtbder->eventIndex;
|
||||
long eventStart = eventIndex - eventBuilt + 1;
|
||||
if(eventStart < 0 ) eventStart += MaxNEvent;
|
||||
|
||||
for( long i = eventStart ; i <= eventIndex; i ++ ){
|
||||
std::vector<Hit> event = evtbder->events[i];
|
||||
//printf("-------------- %ld\n", i);
|
||||
|
||||
if( event.size() == 0 ) return;
|
||||
|
||||
for( int k = 0; k < (int) event.size(); k++ ){
|
||||
//event[k].Print();
|
||||
if( event[k].ch == 4 ) {ch1 = event[k].energy; t1 = event[k].timestamp;} // Reads channel 6 of the digitizer corresponding to dE
|
||||
if( event[k].ch == 6 ) {ch4 = event[k].energy; t4 = event[k].timestamp;} // Reads channel 7 of the digitizer corresponding to E
|
||||
if( event[k].ch == 7 ) {ch7 = event[k].energy; t7 = event[k].timestamp;}
|
||||
|
||||
}
|
||||
|
||||
// printf("(E, dE) = (%f, %f)\n", E, dE);
|
||||
//hPID->Fill(ch4 , ch1); // x, y
|
||||
//etotal = ch1*0.25*0.25 + ch4
|
||||
hdE->Fill(ch1);
|
||||
hE->Fill(ch4);
|
||||
hdT->Fill(ch7);
|
||||
hTotE->Fill(ch1 + ch4);
|
||||
hdEE->Fill(ch4,ch1);
|
||||
hdEtotE->Fill(ch1 + ch4,ch1);
|
||||
hdEdT->Fill((t7-t1)*1e9,ch1);
|
||||
hTWin->Fill((t4-t1)*1e9);
|
||||
|
||||
//check events inside any Graphical cut and extract the rate
|
||||
/*
|
||||
for(int p = 0; p < cutList.count(); p++ ){
|
||||
if( cutList[p].isEmpty() ) continue;
|
||||
if( cutList[p].containsPoint(QPointF(ch4, ch1), Qt::OddEvenFill) ){
|
||||
if( t1 < tMin[p] ) tMin[p] = t1;
|
||||
if( t1 > tMax[p] ) tMax[p] = t1;
|
||||
count[p] ++;
|
||||
//printf(".... %d \n", count[p]);
|
||||
}
|
||||
}
|
||||
*/
|
||||
for(int p = 0; p < cutList1.count(); p++ ){
|
||||
if( cutList1[p].isEmpty() ) continue;
|
||||
if( cutList1[p].containsPoint(QPointF(ch4, ch1), Qt::OddEvenFill) ){
|
||||
if( t1 < tMin1[p] ) tMin1[p] = t1;
|
||||
if( t1 > tMax1[p] ) tMax1[p] = t1;
|
||||
count1[p] ++;
|
||||
//printf("hdEE.... %d \n", count1[p]);
|
||||
}
|
||||
}
|
||||
|
||||
for(int p = 0; p < cutList2.count(); p++ ){
|
||||
if( cutList2[p].isEmpty() ) continue;
|
||||
if( cutList2[p].containsPoint(QPointF(ch1+ch4,ch1), Qt::OddEvenFill) ){
|
||||
if( t1 < tMin2[p] ) tMin2[p] = t1;
|
||||
if( t1 > tMax2[p] ) tMax2[p] = t1;
|
||||
count2[p] ++;
|
||||
//printf("hdEtotE.... %d \n", count2[p]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
for(int p = 0; p < cutList2.count(); p++ ){
|
||||
printf("hdEE.... %d %d \n", p, count1[p]);
|
||||
}
|
||||
|
||||
//hPID->UpdatePlot();
|
||||
hdE->UpdatePlot();
|
||||
hE->UpdatePlot();
|
||||
hdT->UpdatePlot();
|
||||
hTotE->UpdatePlot();
|
||||
hdEE->UpdatePlot();
|
||||
hdEtotE->UpdatePlot();
|
||||
hdEdT->UpdatePlot();
|
||||
hTWin->UpdatePlot();
|
||||
/*
|
||||
//========== output to Influx
|
||||
QList<QString> cutNameList = hPID->GetCutNameList();
|
||||
for( int p = 0; p < cutList.count(); p ++){
|
||||
if( cutList[p].isEmpty() ) continue;
|
||||
double dT = (tMax[p]-tMin[p]) * tick2ns / 1e9; // tick to sec
|
||||
double rate = count[p]*1.0/(dT);
|
||||
//printf("%llu %llu, %f %d\n", tMin[p], tMax[p], dT, count[p]);
|
||||
//printf("%10s | %d | %f Hz \n", cutNameList[p].toStdString().c_str(), count[p], rate);
|
||||
|
||||
influx->AddDataPoint("Cut,name=" + cutNameList[p].toStdString()+ " value=" + std::to_string(rate));
|
||||
influx->WriteData(dataBaseName);
|
||||
influx->ClearDataPointsBuffer();
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
#endif
|
13
macro.h
13
macro.h
|
@ -1,8 +1,8 @@
|
|||
#ifndef MACRO_H
|
||||
#define MACRO_H
|
||||
|
||||
#define MaxNPorts 4 //for optical link
|
||||
#define MaxNBoards 4 //for both optical link and usb
|
||||
#define MaxNPorts 2 //for optical link
|
||||
#define MaxNBoards 2 //for both optical link and usb
|
||||
|
||||
#define MaxNDigitizer MaxNPorts * MaxNBoards
|
||||
|
||||
|
@ -19,6 +19,15 @@
|
|||
|
||||
#define SETTINGSIZE 2048
|
||||
|
||||
#define RESET "\033[0m"
|
||||
#define RED "\033[31m"
|
||||
#define GREEN "\033[32m"
|
||||
#define YELLOW "\033[33m"
|
||||
#define BLUE "\033[34m"
|
||||
#define MAGENTA "\033[35m"
|
||||
#define CYAN "\033[36m"
|
||||
#define WHITE "\033[37m"
|
||||
|
||||
#define DAQLockFile "DAQLock.dat"
|
||||
#define PIDFile "pid.dat"
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user