snapshot June-4
This commit is contained in:
parent
c8d5d2d0c4
commit
f7b78a9f19
|
@ -20,10 +20,13 @@
|
|||
#include "analyzers/EncoreAnalyzer.h"
|
||||
#include "analyzers/RAISOR1.h"
|
||||
#include "analyzers/RAISOR2.h"
|
||||
#include "analyzers/TEST.h"
|
||||
#include "analyzers/MCP.h"
|
||||
#include "analyzers/MCPandPSD.h"
|
||||
#include "analyzers/PID.h"
|
||||
|
||||
std::vector<std::string> onlineAnalyzerList = {"Coincident","Splie-Pole", "Encore", "RAISOR1", "MCP", "PID", "RAISOR2" };
|
||||
|
||||
std::vector<std::string> onlineAnalyzerList = {"Coincident","Splie-Pole", "Encore", "RAISOR1", "MCP", "PID", "RAISOR2", "TEST", "MCPandPSD" };
|
||||
|
||||
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent){
|
||||
DebugPrint("%s", "FSUDAQ");
|
||||
|
@ -1737,6 +1740,8 @@ void MainWindow::OpenAnalyzer(){
|
|||
if( id == 4 ) onlineAnalyzer = new MCP(digi, nDigi);
|
||||
if( id == 5 ) onlineAnalyzer = new PID(digi, nDigi);
|
||||
if( id == 6 ) onlineAnalyzer = new RAISOR2(digi, nDigi);
|
||||
if( id == 7 ) onlineAnalyzer = new TEST(digi, nDigi);
|
||||
if( id == 8 ) onlineAnalyzer = new MCPandPSD(digi, nDigi);
|
||||
if( id >= 0 ) onlineAnalyzer->show();
|
||||
}else{
|
||||
|
||||
|
@ -1749,6 +1754,8 @@ void MainWindow::OpenAnalyzer(){
|
|||
if( id == 4 ) onlineAnalyzer = new MCP(digi, nDigi);
|
||||
if( id == 5 ) onlineAnalyzer = new PID(digi, nDigi);
|
||||
if( id == 6 ) onlineAnalyzer = new RAISOR2(digi, nDigi);
|
||||
if( id == 7 ) onlineAnalyzer = new TEST(digi, nDigi);
|
||||
if( id == 8 ) onlineAnalyzer = new MCPandPSD(digi, nDigi);
|
||||
if( id >= 0 ){
|
||||
onlineAnalyzer->show();
|
||||
onlineAnalyzer->activateWindow();
|
||||
|
|
|
@ -46,6 +46,8 @@ HEADERS += ClassData.h \
|
|||
analyzers/EncoreAnalyzer.h \
|
||||
analyzers/RAISOR1.h \
|
||||
analyzers/RAISOR2.h \
|
||||
analyzers/TEST.h \
|
||||
analyzers/MCPandPSD.h \
|
||||
analyzers/MCP.h \
|
||||
analyzers/PID.h
|
||||
SOURCES += ClassDigitizer.cpp \
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
#include "CustomWidgets.h"
|
||||
#include "MultiBuilder.h"
|
||||
#include "ClassInfluxDB.h"
|
||||
#include "math.h"
|
||||
|
||||
/**************************************
|
||||
|
||||
|
@ -32,6 +33,7 @@ derivative class should define the SetUpCanvas() and UpdateHistogram();
|
|||
#include "Histogram1D.h"
|
||||
#include "Histogram2D.h"
|
||||
|
||||
|
||||
//^==============================================
|
||||
//^==============================================
|
||||
class Analyzer : public QMainWindow{
|
||||
|
@ -83,4 +85,4 @@ private:
|
|||
|
||||
|
||||
};
|
||||
#endif
|
||||
#endif
|
||||
|
|
130
analyzers/MCP.h
130
analyzers/MCP.h
|
@ -8,7 +8,11 @@
|
|||
*
|
||||
* ******************************************/
|
||||
#include "Analyser.h"
|
||||
#include <cmath>
|
||||
#include "math.h"
|
||||
#include <algorithm>
|
||||
|
||||
//#define M_PI 3.14159265
|
||||
|
||||
class MCP : public Analyzer{
|
||||
|
||||
|
@ -18,14 +22,14 @@ public:
|
|||
MCP(Digitizer ** digi, unsigned int nDigi, QMainWindow * parent = nullptr): Analyzer(digi, nDigi, parent){
|
||||
|
||||
|
||||
SetUpdateTimeInSec(1.0);
|
||||
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);
|
||||
evtbder->SetTimeWindow(500); //ns
|
||||
|
||||
//========== use the influx from the Analyzer
|
||||
influx = new InfluxDB("https://fsunuc.physics.fsu.edu/influx/");
|
||||
|
@ -47,18 +51,23 @@ private:
|
|||
|
||||
Histogram2D * hPID;
|
||||
|
||||
Histogram2D * hXX; // X1 versus X2 : e[1] versus e[0]
|
||||
Histogram2D * hYY; // Y1 versus Y2 : e[3] versus e[2]
|
||||
//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]))
|
||||
Histogram1D * hY; // Y position:((e[2]-e[3])/(e[2]+e[3]))
|
||||
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])))
|
||||
|
||||
Histogram2D * hXY; // 2D position plot: ((e[2]-e[3])/(e[2]+e[3])) versus ((e[0]-e[1])/(e[0]+e[1]))
|
||||
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;
|
||||
|
@ -80,33 +89,44 @@ inline void MCP::SetUpCanvas(){
|
|||
hPID = new Histogram2D("MCP", "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);
|
||||
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);
|
||||
|
||||
hYY = new Histogram2D("Y1 versus Y2", "Y2", "Y1", 100, 0, 3000, 100, 0, 3000, this);
|
||||
layout->addWidget(hYY, 1, 0);
|
||||
hXY = new Histogram2D("2D position plot", "X position", "Y position", 500, 0, 1, 500, 0, 1, this);
|
||||
layout->addWidget(hXY, 0, 2);
|
||||
|
||||
hX = new Histogram1D("X position", "X", 300, -1, 1, this);
|
||||
layout->addWidget(hX, 1, 1);
|
||||
ht = new Histogram1D("Time Window", "t", 50, 0, 500, this);
|
||||
layout->addWidget(ht, 0, 3);
|
||||
|
||||
|
||||
hY = new Histogram1D("Y position", "Y", 300, -1, 1, this);
|
||||
layout->addWidget(hY, 1, 2);
|
||||
/* UNCOMMENT THESE LINES TO SEE INDIVIDUAL SIGNALS
|
||||
he0 = new Histogram1D("Signal 0", "e0", 300, -1, 1, this);
|
||||
layout->addWidget(he0, 0, 3);
|
||||
hX = new Histogram1D("X position", "X", 250, 0, 1, this);
|
||||
layout->addWidget(hX, 2, 0);
|
||||
|
||||
he1 = new Histogram1D("Signal 1", "e1", 300, -1, 1, this);
|
||||
layout->addWidget(he1, 0, 4);
|
||||
hY = new Histogram1D("Y position", "Y", 250, 0, 1, this);
|
||||
layout->addWidget(hY, 2, 1);
|
||||
|
||||
he2 = new Histogram1D("Signal 2", "e2", 300, -1, 1, this);
|
||||
layout->addWidget(he2, 1, 3);
|
||||
hXr = new Histogram1D("Angle rot X posi", "Xr", 250, -0.5, 0.5, this);
|
||||
layout->addWidget(hXr, 2, 2);
|
||||
|
||||
he3 = new Histogram1D("Signal 3", "e3", 300, -1, 1, this);
|
||||
layout->addWidget(he3, 1, 4);
|
||||
*/
|
||||
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(){
|
||||
|
@ -120,6 +140,7 @@ inline void MCP::UpdateHistograms(){
|
|||
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};
|
||||
|
@ -135,11 +156,24 @@ inline void MCP::UpdateHistograms(){
|
|||
//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 == 0 ) {dE = event[k].energy; dE_t = event[k].timestamp;}
|
||||
if( event[k].ch == 1 ) {E = event[k].energy; E_t = event[k].timestamp;}
|
||||
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;}
|
||||
|
@ -148,21 +182,36 @@ inline void MCP::UpdateHistograms(){
|
|||
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);
|
||||
|
||||
// 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)));
|
||||
hX->Fill(((e0-e1)/(e0+e1)));
|
||||
hY->Fill(((e2-e3)/(e2+e3)));
|
||||
|
||||
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) ){
|
||||
|
@ -172,18 +221,23 @@ inline void MCP::UpdateHistograms(){
|
|||
//printf(".... %d \n", count[p]);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
hPID->UpdatePlot();
|
||||
hXX->UpdatePlot();//
|
||||
hYY->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();
|
||||
|
||||
|
||||
|
||||
|
|
362
analyzers/MCPandPSD.h
Normal file
362
analyzers/MCPandPSD.h
Normal file
|
@ -0,0 +1,362 @@
|
|||
#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);
|
||||
|
||||
//========== use the influx from the Analyzer
|
||||
influx = new InfluxDB("https://fsunuc.physics.fsu.edu/influx/");
|
||||
dataBaseName = "testing";
|
||||
|
||||
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
|
|
@ -18,11 +18,11 @@ public:
|
|||
PID(Digitizer ** digi, unsigned int nDigi, QMainWindow * parent = nullptr): Analyzer(digi, nDigi, parent){
|
||||
|
||||
|
||||
SetUpdateTimeInSec(1.0);
|
||||
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);
|
||||
|
@ -45,7 +45,7 @@ private:
|
|||
|
||||
MultiBuilder *evtbder;
|
||||
|
||||
Histogram2D * hPID;
|
||||
//Histogram2D * hPID;
|
||||
|
||||
Histogram1D * hdE; // raw dE (ch=1): ch1
|
||||
Histogram1D * hE; // raw E (ch=4) : ch4
|
||||
|
@ -76,26 +76,29 @@ inline void PID::SetUpCanvas(){
|
|||
|
||||
//============ histograms
|
||||
|
||||
hdEE = new Histogram2D("dE vs E", "E[ch]", "dE[ch]", 100, 0, 7000, 100, 0, 4000, this);
|
||||
//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, 2500, this);
|
||||
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, 0, 3);
|
||||
layout->addWidget(hdEdT, 1, 3);
|
||||
|
||||
hE = new Histogram1D("raw E (ch=4)", "E [ch]", 300, 0, 5000, this);
|
||||
layout->addWidget(hE, 0, 4);
|
||||
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]", 100, 0, 8000, 100, 0, 4000, this);
|
||||
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, 7000, this);
|
||||
layout->addWidget(hTotE, 1, 3);
|
||||
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);
|
||||
|
@ -113,10 +116,21 @@ inline void PID::UpdateHistograms(){
|
|||
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;
|
||||
|
@ -131,24 +145,26 @@ inline void PID::UpdateHistograms(){
|
|||
|
||||
for( int k = 0; k < (int) event.size(); k++ ){
|
||||
//event[k].Print();
|
||||
if( event[k].ch == 0 ) {ch1 = event[k].energy; t1 = event[k].timestamp;}
|
||||
if( event[k].ch == 1 ) {ch4 = event[k].energy; t4 = event[k].timestamp;}
|
||||
if( event[k].ch == 2 ) {ch7 = event[k].energy; t7 = event[k].timestamp;}
|
||||
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 + RandomGauss(0, 100), ch1 + RandomGauss(0, 100)); // x, y
|
||||
//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);
|
||||
hTotE->Fill(ch1*0.25*0.25 + ch4);
|
||||
hdEE->Fill(ch4,ch1);
|
||||
hdEtotE->Fill(ch1+ch4+ RandomGauss(0, 100),ch1+ RandomGauss(0, 100));
|
||||
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) ){
|
||||
|
@ -158,10 +174,34 @@ inline void PID::UpdateHistograms(){
|
|||
//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();
|
||||
//hPID->UpdatePlot();
|
||||
hdE->UpdatePlot();
|
||||
hE->UpdatePlot();
|
||||
hdT->UpdatePlot();
|
||||
|
@ -170,7 +210,7 @@ inline void PID::UpdateHistograms(){
|
|||
hdEtotE->UpdatePlot();
|
||||
hdEdT->UpdatePlot();
|
||||
hTWin->UpdatePlot();
|
||||
|
||||
/*
|
||||
//========== output to Influx
|
||||
QList<QString> cutNameList = hPID->GetCutNameList();
|
||||
for( int p = 0; p < cutList.count(); p ++){
|
||||
|
@ -184,6 +224,7 @@ inline void PID::UpdateHistograms(){
|
|||
influx->WriteData(dataBaseName);
|
||||
influx->ClearDataPointsBuffer();
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,133 +0,0 @@
|
|||
#ifndef RASIOR_h
|
||||
#define RASIOR_h
|
||||
|
||||
/*********************************************
|
||||
* This is online analyzer for RASIOR, ANL
|
||||
*
|
||||
* Created by Ryan @ 2023-10-16
|
||||
*
|
||||
* ******************************************/
|
||||
#include "Analyser.h"
|
||||
|
||||
|
||||
class RAISOR : public Analyzer{
|
||||
|
||||
public:
|
||||
RAISOR(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);
|
||||
|
||||
//========== use the influx from the Analyzer
|
||||
influx = new InfluxDB("https://fsunuc.physics.fsu.edu/influx/");
|
||||
dataBaseName = "testing";
|
||||
|
||||
SetUpCanvas(); // see below
|
||||
|
||||
};
|
||||
|
||||
void SetUpCanvas();
|
||||
|
||||
public slots:
|
||||
void UpdateHistograms();
|
||||
|
||||
|
||||
private:
|
||||
|
||||
MultiBuilder *evtbder;
|
||||
|
||||
Histogram2D * hPID;
|
||||
|
||||
int tick2ns;
|
||||
|
||||
float dE, E;
|
||||
unsigned long long dE_t, E_t;
|
||||
|
||||
};
|
||||
|
||||
|
||||
inline void RAISOR::SetUpCanvas(){
|
||||
|
||||
setGeometry(0, 0, 500, 500);
|
||||
|
||||
//============ histograms
|
||||
hPID = new Histogram2D("RAISOR", "E", "dE", 100, 0, 5000, 100, 0, 20000, this);
|
||||
layout->addWidget(hPID, 0, 0);
|
||||
|
||||
}
|
||||
|
||||
inline void RAISOR::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;
|
||||
|
||||
for( int k = 0; k < (int) event.size(); k++ ){
|
||||
//event[k].Print();
|
||||
if( event[k].ch == 0 ) {dE = event[k].energy; dE_t = event[k].timestamp;}
|
||||
if( event[k].ch == 1 ) {E = event[k].energy; E_t = event[k].timestamp;}
|
||||
|
||||
}
|
||||
|
||||
// printf("(E, dE) = (%f, %f)\n", E, dE);
|
||||
hPID->Fill(E + RandomGauss(0, 100), dE+ RandomGauss(0, 100)); // x, y
|
||||
|
||||
//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();
|
||||
|
||||
//========== 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
|
|
@ -163,7 +163,13 @@ inline void RAISOR1::UpdateHistograms(){
|
|||
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;
|
||||
|
@ -174,29 +180,11 @@ inline void RAISOR1::UpdateHistograms(){
|
|||
//printf("-------------- %ld\n", i);
|
||||
|
||||
if( event.size() == 0 ) return;
|
||||
/*
|
||||
int E = energy[chX1] +energy[chX2] ;//+ gRandom->Gaus(0, 500);
|
||||
int dE = energy[chY1] + energy[chY2] ;//+ gRandom->Gaus(0, 500);
|
||||
float X = 0;
|
||||
//float Y = 0;
|
||||
if( energy[chX1] !=0 && energy[chX2] !=0) {
|
||||
X = ((float)energy[chX1] - (float)energy[chX2])/((float)energy[chX1] + (float)energy[chX2]);
|
||||
hXX->Fill(energy[chX1],energy[chX2]);
|
||||
//hXE->Fill(E,X);
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
if( energy[chY1] !=0 && energy[chY2] !=0 ) {
|
||||
Y = ((float)energy[chY1] - (float)energy[chY2])/((float)energy[chY1] + (float)energy[chY2]);
|
||||
hYY->Fill(energy[chY1],energy[chY2]);
|
||||
hYE->Fill(dE,X);
|
||||
}
|
||||
*/
|
||||
|
||||
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 == 9 ) {E = event[k].energy; E_t = event[k].timestamp;} // Surface Barrier E 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
|
||||
|
@ -231,9 +219,20 @@ inline void RAISOR1::UpdateHistograms(){
|
|||
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]);
|
||||
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();
|
||||
|
|
|
@ -16,7 +16,7 @@ public:
|
|||
RAISOR2(Digitizer ** digi, unsigned int nDigi, QMainWindow * parent = nullptr): Analyzer(digi, nDigi, parent){
|
||||
|
||||
|
||||
SetUpdateTimeInSec(1.0);
|
||||
SetUpdateTimeInSec(4.0);
|
||||
|
||||
RedefineEventBuilder({0}); // only builder for the 0-th digitizer.
|
||||
tick2ns = digi[0]->GetTick2ns();
|
||||
|
@ -100,22 +100,22 @@ inline void RAISOR2::SetUpCanvas(){
|
|||
setGeometry(0, 0, 1500, 2000);
|
||||
|
||||
//============ histograms
|
||||
hPID = new Histogram2D("RAISOR2", "E", "dE", 100, 0, 2000, 100, 0, 2000, this);
|
||||
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", 100, -1, 1, 100, -1, 1, this);
|
||||
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, 5000, 100, 0, 5000, this);
|
||||
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, 3000, 100, 0, 3000, this);
|
||||
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, 4000, this);
|
||||
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);
|
||||
|
@ -124,25 +124,25 @@ inline void RAISOR2::SetUpCanvas(){
|
|||
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);
|
||||
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, 5000, this);
|
||||
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, -200, 20000, 100, -200, 10000, this);
|
||||
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, 6000, 100, 0, 6000, this);
|
||||
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, -500, 20000, 100, -500, 15000, this);
|
||||
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, -500, 5000, 100, -500, 12000, this);
|
||||
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, 10000, 100, 0, 6000, this);
|
||||
hXYE = new Histogram2D("2D energy plot", "Ex", "Ey", 100, 0, 8000, 100, 0, 8000, this);
|
||||
layout->addWidget(hXYE, 2, 4);
|
||||
|
||||
|
||||
|
@ -163,7 +163,21 @@ inline void RAISOR2::UpdateHistograms(){
|
|||
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;
|
||||
|
@ -174,29 +188,11 @@ inline void RAISOR2::UpdateHistograms(){
|
|||
//printf("-------------- %ld\n", i);
|
||||
|
||||
if( event.size() == 0 ) return;
|
||||
/*
|
||||
int E = energy[chX1] +energy[chX2] ;//+ gRandom->Gaus(0, 500);
|
||||
int dE = energy[chY1] + energy[chY2] ;//+ gRandom->Gaus(0, 500);
|
||||
float X = 0;
|
||||
//float Y = 0;
|
||||
if( energy[chX1] !=0 && energy[chX2] !=0) {
|
||||
X = ((float)energy[chX1] - (float)energy[chX2])/((float)energy[chX1] + (float)energy[chX2]);
|
||||
hXX->Fill(energy[chX1],energy[chX2]);
|
||||
//hXE->Fill(E,X);
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
if( energy[chY1] !=0 && energy[chY2] !=0 ) {
|
||||
Y = ((float)energy[chY1] - (float)energy[chY2])/((float)energy[chY1] + (float)energy[chY2]);
|
||||
hYY->Fill(energy[chY1],energy[chY2]);
|
||||
hYE->Fill(dE,X);
|
||||
}
|
||||
*/
|
||||
|
||||
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 == 9 ) {E = event[k].energy; E_t = event[k].timestamp;} // Surface Barrier E detector
|
||||
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
|
||||
|
@ -209,15 +205,15 @@ inline void RAISOR2::UpdateHistograms(){
|
|||
|
||||
// printf("(E, dE) = (%f, %f)\n", E, dE);
|
||||
hPID->Fill(E + RandomGauss(0, 100), dE+ RandomGauss(0, 100)); // x, y
|
||||
hXX->Fill(e1, e0); //
|
||||
hXX->Fill(e1 , e0); //
|
||||
hYY->Fill(e3, e2);
|
||||
hXY->Fill(((e0-e1)/(e0+e1)),((e2-e3)/(e2+e3)));
|
||||
hXY->Fill(((e0-e1)/(e0+e1)),((e3-e2)/(e2+e3)));
|
||||
hXE->Fill(e0+e1);
|
||||
hYE->Fill(e2+e3);
|
||||
hX->Fill(((e0-e1)/(e0+e1)));
|
||||
hY->Fill(((e2-e3)/(e2+e3)));
|
||||
hY->Fill(((e3-e2)/(e2+e3)));
|
||||
hXPE->Fill(((e0-e1)/(e0+e1)),(e0+e1));
|
||||
hYPE->Fill(((e2-e3)/(e2+e3)),(e2+e3));
|
||||
hYPE->Fill(((e3-e2)/(e2+e3)),(e2+e3));
|
||||
hXEdE1->Fill((e0+e1),dE1);
|
||||
hYEdE1->Fill(e2+e3,dE1);
|
||||
hXEdE2->Fill(e0+e1,dE2);
|
||||
|
@ -234,6 +230,37 @@ inline void RAISOR2::UpdateHistograms(){
|
|||
//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();
|
||||
|
|
273
analyzers/TEST.h
Normal file
273
analyzers/TEST.h
Normal file
|
@ -0,0 +1,273 @@
|
|||
#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);
|
||||
|
||||
//========== use the influx from the Analyzer
|
||||
influx = new InfluxDB("https://fsunuc.physics.fsu.edu/influx/");
|
||||
dataBaseName = "testing";
|
||||
|
||||
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);
|
||||
influx->ClearDataPointsBuffer();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue
Block a user