2023-06-12 16:32:01 -04:00
# ifndef SPLITPOLEANLAYZER_H
# define SPLITPOLEANLAYZER_H
/*********************************************
* This is online analyzer for Split - Pole at FSU
*
* It is a template for other analyzer .
*
* Any new analyzer add to added to FSUDAQ . cpp
2023-06-12 16:41:03 -04:00
* 1 ) add include header
* 2 ) in OpenAnalyzer ( ) , change the new
2023-06-12 16:32:01 -04:00
*
2023-06-12 16:41:03 -04:00
* add the source file in FSUDAQ_Qt6 . pro then compile
2023-06-12 16:32:01 -04:00
* > qmake6 FSUDAQ_Qt6 . pro
* > make
*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2023-10-20 17:57:03 -04:00
# include "SplitPoleHit.h"
2023-06-23 13:50:21 -04:00
# include "Analyser.h"
//^===========================================
//^===========================================
2023-06-12 16:32:01 -04:00
class SplitPole : public Analyzer {
Q_OBJECT
public :
2023-06-12 16:41:03 -04:00
SplitPole ( Digitizer * * digi , unsigned int nDigi , QMainWindow * parent = nullptr ) : Analyzer ( digi , nDigi , parent ) {
SetUpdateTimeInSec ( 1.0 ) ;
2023-06-20 11:57:39 -04:00
RedefineEventBuilder ( { 0 } ) ; // only build for the 0-th digitizer, otherwise, it will build event accross all digitizers
tick2ns = digi [ 0 ] - > GetTick2ns ( ) ;
2023-06-20 16:18:02 -04:00
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.
2024-08-29 16:49:52 -04:00
mb - > SetTimeWindow ( 3000 ) ;
2023-06-20 16:18:02 -04:00
2023-06-20 11:57:39 -04:00
//========== use the influx from the Analyzer
influx = new InfluxDB ( " https://fsunuc.physics.fsu.edu/influx/ " ) ;
dataBaseName = " testing " ;
2023-06-12 16:41:03 -04:00
SetUpCanvas ( ) ;
2023-06-27 15:47:34 -04:00
leTarget - > setText ( " 12C " ) ;
leBeam - > setText ( " d " ) ;
leRecoil - > setText ( " p " ) ;
2024-08-13 12:45:24 -04:00
sbBfield - > setValue ( 0.75 ) ;
2023-06-27 15:47:34 -04:00
sbAngle - > setValue ( 20 ) ;
sbEnergy - > setValue ( 16 ) ;
2023-10-20 17:57:03 -04:00
hit . CalConstants ( leTarget - > text ( ) . toStdString ( ) ,
leBeam - > text ( ) . toStdString ( ) ,
leRecoil - > text ( ) . toStdString ( ) , sbEnergy - > value ( ) , sbAngle - > value ( ) ) ;
2023-06-27 15:47:34 -04:00
2023-10-20 16:17:50 -04:00
hit . CalZoffset ( sbBfield - > value ( ) ) ;
2023-06-23 13:50:21 -04:00
2023-10-23 12:53:51 -04:00
FillConstants ( ) ;
hit . ClearData ( ) ;
2023-06-23 13:50:21 -04:00
2023-06-12 16:41:03 -04:00
}
/// ~SplitPole(); // comment out = defalt destructor
2023-06-12 16:32:01 -04:00
void SetUpCanvas ( ) ;
2023-10-20 16:17:50 -04:00
void FillConstants ( ) ;
2023-06-12 16:32:01 -04:00
public slots :
void UpdateHistograms ( ) ;
2024-10-22 16:38:01 -04:00
void ReplotHistograms ( ) ;
2023-06-12 16:32:01 -04:00
private :
2023-06-12 16:41:03 -04:00
// declaie histograms
2023-06-23 13:50:21 -04:00
Histogram2D * hPID ;
2023-06-12 16:32:01 -04:00
Histogram1D * h1 ;
2023-06-23 13:50:21 -04:00
Histogram1D * h1g ;
Histogram1D * hMulti ;
2023-06-12 16:32:01 -04:00
2023-06-20 11:57:39 -04:00
int tick2ns ;
2023-06-23 13:50:21 -04:00
SplitPoleHit hit ;
2023-06-27 15:47:34 -04:00
RSpinBox * sbBfield ;
QLineEdit * leTarget ;
QLineEdit * leBeam ;
QLineEdit * leRecoil ;
RSpinBox * sbEnergy ;
RSpinBox * sbAngle ;
2024-06-13 16:12:29 -04:00
RSpinBox * sbEventWin ;
2023-11-17 16:47:11 -05:00
QCheckBox * chkRunAnalyzer ;
2023-08-28 15:02:56 -04:00
2023-10-20 16:17:50 -04:00
QLineEdit * leMassTablePath ;
QLineEdit * leQValue ;
QLineEdit * leGSRho ;
QLineEdit * leZoffset ;
2023-10-23 12:53:51 -04:00
RSpinBox * sbRhoOffset ;
RSpinBox * sbRhoScale ;
2023-06-12 16:32:01 -04:00
} ;
2023-10-20 16:17:50 -04:00
inline void SplitPole : : FillConstants ( ) {
leQValue - > setText ( QString : : number ( hit . GetQ0 ( ) ) ) ;
2023-10-23 12:53:51 -04:00
leGSRho - > setText ( QString : : number ( hit . GetRho0 ( ) * 1000 ) ) ;
2023-10-20 16:17:50 -04:00
leZoffset - > setText ( QString : : number ( hit . GetZoffset ( ) ) ) ;
}
2023-06-12 16:32:01 -04:00
2023-06-12 16:41:03 -04:00
inline void SplitPole : : SetUpCanvas ( ) {
2023-06-23 13:50:21 -04:00
setGeometry ( 0 , 0 , 1600 , 1000 ) ;
2023-06-12 16:41:03 -04:00
2023-06-27 15:47:34 -04:00
{ //^====== magnet and reaction setting
QGroupBox * box = new QGroupBox ( " Configuration " , this ) ;
layout - > addWidget ( box , 0 , 0 ) ;
QGridLayout * boxLayout = new QGridLayout ( box ) ;
boxLayout - > setAlignment ( Qt : : AlignTop | Qt : : AlignLeft ) ;
box - > setLayout ( boxLayout ) ;
QLabel * lbBfield = new QLabel ( " B-field [T] " , box ) ;
lbBfield - > setAlignment ( Qt : : AlignRight | Qt : : AlignCenter ) ;
boxLayout - > addWidget ( lbBfield , 0 , 2 ) ;
sbBfield = new RSpinBox ( box ) ;
sbBfield - > setDecimals ( 3 ) ;
sbBfield - > setSingleStep ( 0.05 ) ;
boxLayout - > addWidget ( sbBfield , 0 , 3 ) ;
QLabel * lbTarget = new QLabel ( " Target " , box ) ;
lbTarget - > setAlignment ( Qt : : AlignRight | Qt : : AlignCenter ) ;
boxLayout - > addWidget ( lbTarget , 0 , 0 ) ;
leTarget = new QLineEdit ( box ) ;
boxLayout - > addWidget ( leTarget , 0 , 1 ) ;
QLabel * lbBeam = new QLabel ( " Beam " , box ) ;
lbBeam - > setAlignment ( Qt : : AlignRight | Qt : : AlignCenter ) ;
boxLayout - > addWidget ( lbBeam , 1 , 0 ) ;
leBeam = new QLineEdit ( box ) ;
boxLayout - > addWidget ( leBeam , 1 , 1 ) ;
QLabel * lbRecoil = new QLabel ( " Recoil " , box ) ;
lbRecoil - > setAlignment ( Qt : : AlignRight | Qt : : AlignCenter ) ;
boxLayout - > addWidget ( lbRecoil , 2 , 0 ) ;
leRecoil = new QLineEdit ( box ) ;
boxLayout - > addWidget ( leRecoil , 2 , 1 ) ;
QLabel * lbEnergy = new QLabel ( " Beam Energy [MeV] " , box ) ;
lbEnergy - > setAlignment ( Qt : : AlignRight | Qt : : AlignCenter ) ;
boxLayout - > addWidget ( lbEnergy , 1 , 2 ) ;
sbEnergy = new RSpinBox ( box ) ;
sbEnergy - > setDecimals ( 3 ) ;
sbEnergy - > setSingleStep ( 1.0 ) ;
boxLayout - > addWidget ( sbEnergy , 1 , 3 ) ;
QLabel * lbAngle = new QLabel ( " SPS Angle [Deg] " , box ) ;
lbAngle - > setAlignment ( Qt : : AlignRight | Qt : : AlignCenter ) ;
boxLayout - > addWidget ( lbAngle , 2 , 2 ) ;
sbAngle = new RSpinBox ( box ) ;
sbAngle - > setDecimals ( 3 ) ;
sbAngle - > setSingleStep ( 1.0 ) ;
boxLayout - > addWidget ( sbAngle , 2 , 3 ) ;
boxLayout - > setColumnStretch ( 0 , 1 ) ;
boxLayout - > setColumnStretch ( 1 , 2 ) ;
boxLayout - > setColumnStretch ( 2 , 1 ) ;
boxLayout - > setColumnStretch ( 3 , 2 ) ;
connect ( leTarget , & QLineEdit : : returnPressed , this , [ = ] ( ) {
2023-10-20 17:57:03 -04:00
hit . CalConstants ( leTarget - > text ( ) . toStdString ( ) ,
leBeam - > text ( ) . toStdString ( ) ,
2023-12-14 16:55:33 -05:00
leRecoil - > text ( ) . toStdString ( ) , sbEnergy - > value ( ) , sbAngle - > value ( ) ) ;
2023-10-20 16:17:50 -04:00
hit . CalZoffset ( sbBfield - > value ( ) ) ;
FillConstants ( ) ;
2023-06-27 15:47:34 -04:00
} ) ;
connect ( leBeam , & QLineEdit : : returnPressed , this , [ = ] ( ) {
2023-10-20 17:57:03 -04:00
hit . CalConstants ( leTarget - > text ( ) . toStdString ( ) ,
leBeam - > text ( ) . toStdString ( ) ,
2023-12-14 16:55:33 -05:00
leRecoil - > text ( ) . toStdString ( ) , sbEnergy - > value ( ) , sbAngle - > value ( ) ) ;
2023-10-20 16:17:50 -04:00
hit . CalZoffset ( sbBfield - > value ( ) ) ;
FillConstants ( ) ;
2023-06-27 15:47:34 -04:00
} ) ;
connect ( leRecoil , & QLineEdit : : returnPressed , this , [ = ] ( ) {
2023-10-20 17:57:03 -04:00
hit . CalConstants ( leTarget - > text ( ) . toStdString ( ) ,
leBeam - > text ( ) . toStdString ( ) ,
2023-12-14 16:55:33 -05:00
leRecoil - > text ( ) . toStdString ( ) , sbEnergy - > value ( ) , sbAngle - > value ( ) ) ;
2023-10-20 16:17:50 -04:00
hit . CalZoffset ( sbBfield - > value ( ) ) ;
FillConstants ( ) ;
2023-06-27 15:47:34 -04:00
} ) ;
connect ( sbBfield , & RSpinBox : : returnPressed , this , [ = ] ( ) {
2023-10-20 17:57:03 -04:00
hit . CalConstants ( leTarget - > text ( ) . toStdString ( ) ,
leBeam - > text ( ) . toStdString ( ) ,
2023-12-14 16:55:33 -05:00
leRecoil - > text ( ) . toStdString ( ) , sbEnergy - > value ( ) , sbAngle - > value ( ) ) ;
2023-10-20 16:17:50 -04:00
hit . CalZoffset ( sbBfield - > value ( ) ) ;
FillConstants ( ) ;
2023-06-27 15:47:34 -04:00
} ) ;
connect ( sbAngle , & RSpinBox : : returnPressed , this , [ = ] ( ) {
2023-10-20 17:57:03 -04:00
hit . CalConstants ( leTarget - > text ( ) . toStdString ( ) ,
leBeam - > text ( ) . toStdString ( ) ,
2023-12-14 16:55:33 -05:00
leRecoil - > text ( ) . toStdString ( ) , sbEnergy - > value ( ) , sbAngle - > value ( ) ) ;
2023-10-20 16:17:50 -04:00
hit . CalZoffset ( sbBfield - > value ( ) ) ;
FillConstants ( ) ;
2023-06-27 15:47:34 -04:00
} ) ;
connect ( sbEnergy , & RSpinBox : : returnPressed , this , [ = ] ( ) {
2023-10-20 17:57:03 -04:00
hit . CalConstants ( leTarget - > text ( ) . toStdString ( ) ,
leBeam - > text ( ) . toStdString ( ) ,
2023-12-14 16:55:33 -05:00
leRecoil - > text ( ) . toStdString ( ) , sbEnergy - > value ( ) , sbAngle - > value ( ) ) ;
2023-10-20 16:17:50 -04:00
hit . CalZoffset ( sbBfield - > value ( ) ) ;
FillConstants ( ) ;
2023-06-27 15:47:34 -04:00
} ) ;
2023-08-28 15:02:56 -04:00
2024-06-13 16:12:29 -04:00
QLabel * lbEventWindow = new QLabel ( " Event Window [ns] " , box ) ;
lbEventWindow - > setAlignment ( Qt : : AlignRight | Qt : : AlignCenter ) ;
boxLayout - > addWidget ( lbEventWindow , 4 , 0 ) ;
sbEventWin = new RSpinBox ( this ) ;
sbEventWin - > setDecimals ( 0 ) ;
sbEventWin - > setSingleStep ( 100 ) ;
sbEventWin - > setMaximum ( 1000000 ) ;
boxLayout - > addWidget ( sbEventWin , 4 , 1 ) ;
2024-08-13 12:45:24 -04:00
sbEventWin - > setValue ( 3000 ) ;
2024-06-13 16:12:29 -04:00
connect ( sbEventWin , & RSpinBox : : returnPressed , this , [ = ] ( ) {
2024-08-29 16:49:52 -04:00
mb - > SetTimeWindow ( sbEventWin - > value ( ) ) ;
2024-06-13 16:12:29 -04:00
} ) ;
chkRunAnalyzer = new QCheckBox ( " Run Analyzer " , this ) ;
boxLayout - > addWidget ( chkRunAnalyzer , 4 , 3 ) ;
2024-06-20 13:50:44 -04:00
connect ( chkRunAnalyzer , & QCheckBox : : stateChanged , this , [ = ] ( int state ) {
sbBfield - > setEnabled ( state ! = Qt : : Checked ) ;
leTarget - > setEnabled ( state ! = Qt : : Checked ) ;
leBeam - > setEnabled ( state ! = Qt : : Checked ) ;
leRecoil - > setEnabled ( state ! = Qt : : Checked ) ;
sbEnergy - > setEnabled ( state ! = Qt : : Checked ) ;
sbAngle - > setEnabled ( state ! = Qt : : Checked ) ;
sbEventWin - > setEnabled ( state ! = Qt : : Checked ) ;
} ) ;
2023-10-20 16:17:50 -04:00
2023-10-23 12:53:51 -04:00
QFrame * separator = new QFrame ( box ) ;
separator - > setFrameShape ( QFrame : : HLine ) ;
separator - > setFrameShadow ( QFrame : : Sunken ) ;
boxLayout - > addWidget ( separator , 5 , 0 , 1 , 4 ) ;
2023-10-20 16:17:50 -04:00
QLabel * lbMassTablePath = new QLabel ( " Mass Table Path : " , box ) ;
lbMassTablePath - > setAlignment ( Qt : : AlignRight | Qt : : AlignCenter ) ;
2023-10-23 12:53:51 -04:00
boxLayout - > addWidget ( lbMassTablePath , 6 , 0 ) ;
2023-10-20 16:17:50 -04:00
leMassTablePath = new QLineEdit ( QString : : fromStdString ( massData ) , box ) ;
2023-10-23 12:53:51 -04:00
leMassTablePath - > setReadOnly ( true ) ;
boxLayout - > addWidget ( leMassTablePath , 6 , 1 , 1 , 3 ) ;
2023-10-20 16:17:50 -04:00
QLabel * lbQValue = new QLabel ( " Q-Value [MeV] " , box ) ;
lbQValue - > setAlignment ( Qt : : AlignRight | Qt : : AlignCenter ) ;
2023-10-23 12:53:51 -04:00
boxLayout - > addWidget ( lbQValue , 7 , 0 ) ;
2023-10-20 16:17:50 -04:00
leQValue = new QLineEdit ( box ) ;
2023-10-23 12:53:51 -04:00
leQValue - > setReadOnly ( true ) ;
boxLayout - > addWidget ( leQValue , 7 , 1 ) ;
2023-10-20 16:17:50 -04:00
QLabel * lbGDRho = new QLabel ( " G.S. Rho [mm] " , box ) ;
lbGDRho - > setAlignment ( Qt : : AlignRight | Qt : : AlignCenter ) ;
2023-10-23 12:53:51 -04:00
boxLayout - > addWidget ( lbGDRho , 7 , 2 ) ;
2023-10-20 16:17:50 -04:00
leGSRho = new QLineEdit ( box ) ;
2023-10-23 12:53:51 -04:00
leGSRho - > setReadOnly ( true ) ;
boxLayout - > addWidget ( leGSRho , 7 , 3 ) ;
2023-10-20 16:17:50 -04:00
QLabel * lbZoffset = new QLabel ( " Z-offset [mm] " , box ) ;
lbZoffset - > setAlignment ( Qt : : AlignRight | Qt : : AlignCenter ) ;
2023-10-23 12:53:51 -04:00
boxLayout - > addWidget ( lbZoffset , 8 , 0 ) ;
2023-10-20 16:17:50 -04:00
leZoffset = new QLineEdit ( box ) ;
2023-10-23 12:53:51 -04:00
leZoffset - > setReadOnly ( true ) ;
boxLayout - > addWidget ( leZoffset , 8 , 1 ) ;
QFrame * separator1 = new QFrame ( box ) ;
separator1 - > setFrameShape ( QFrame : : HLine ) ;
separator1 - > setFrameShadow ( QFrame : : Sunken ) ;
boxLayout - > addWidget ( separator1 , 9 , 0 , 1 , 4 ) ;
QLabel * lbRhoOffset = new QLabel ( " Rho-offset [mm] " , box ) ;
lbRhoOffset - > setAlignment ( Qt : : AlignRight | Qt : : AlignCenter ) ;
boxLayout - > addWidget ( lbRhoOffset , 10 , 0 ) ;
sbRhoOffset = new RSpinBox ( box ) ;
sbRhoOffset - > setDecimals ( 2 ) ;
sbRhoOffset - > setSingleStep ( 1 ) ;
sbRhoOffset - > setValue ( 0 ) ;
boxLayout - > addWidget ( sbRhoOffset , 10 , 1 ) ;
QLabel * lbRhoScale = new QLabel ( " Rho-Scaling " , box ) ;
lbRhoScale - > setAlignment ( Qt : : AlignRight | Qt : : AlignCenter ) ;
boxLayout - > addWidget ( lbRhoScale , 10 , 2 ) ;
sbRhoScale = new RSpinBox ( box ) ;
sbRhoScale - > setDecimals ( 2 ) ;
sbRhoScale - > setSingleStep ( 0.01 ) ;
sbRhoScale - > setMinimum ( 0.5 ) ;
sbRhoScale - > setMaximum ( 1.5 ) ;
sbRhoScale - > setValue ( 1.0 ) ;
boxLayout - > addWidget ( sbRhoScale , 10 , 3 ) ;
2023-12-14 16:55:33 -05:00
QFrame * separator2 = new QFrame ( box ) ;
separator2 - > setFrameShape ( QFrame : : HLine ) ;
separator2 - > setFrameShadow ( QFrame : : Sunken ) ;
boxLayout - > addWidget ( separator2 , 11 , 0 , 1 , 4 ) ;
QString chMapStr = " ScinR = " + QString : : number ( SPS : : ChMap : : ScinR ) ;
chMapStr + = " , ScinL = " + QString : : number ( SPS : : ChMap : : ScinL ) ;
chMapStr + = " , dFR = " + QString : : number ( SPS : : ChMap : : dFR ) ;
chMapStr + = " , dFL = " + QString : : number ( SPS : : ChMap : : dFL ) ;
chMapStr + = " , dBR = " + QString : : number ( SPS : : ChMap : : dBR ) ;
chMapStr + = " , dBL = " + QString : : number ( SPS : : ChMap : : dBL ) ;
chMapStr + = " , Cathode = " + QString : : number ( SPS : : ChMap : : Cathode ) ;
chMapStr + = " , AnodeF = " + QString : : number ( SPS : : ChMap : : AnodeF ) ;
chMapStr + = " , AnodeB = " + QString : : number ( SPS : : ChMap : : AnodeB ) ;
QLabel * chMapLabel = new QLabel ( chMapStr , box ) ;
boxLayout - > addWidget ( chMapLabel , 12 , 0 , 1 , 4 ) ;
2023-06-27 15:47:34 -04:00
}
//============ histograms
2024-08-13 12:45:24 -04:00
hMulti = new Histogram1D ( " Multiplicity " , " " , 16 , 0 , 16 , this ) ;
2023-06-27 15:47:34 -04:00
layout - > addWidget ( hMulti , 0 , 1 ) ;
2023-06-12 16:41:03 -04:00
// the "this" make the histogram a child of the SplitPole class. When SplitPole destory, all childs destory as well.
2024-08-13 12:45:24 -04:00
hPID = new Histogram2D ( " Split Pole PID " , " Scin-L " , " Anode-Back " , 100 , 0 , 20000 , 100 , 0 , 40000 , this ) ;
2023-06-12 16:41:03 -04:00
//layout is inheriatge from Analyzer
2023-06-27 15:47:34 -04:00
layout - > addWidget ( hPID , 1 , 0 , 2 , 1 ) ;
2023-06-12 16:41:03 -04:00
2024-08-13 12:45:24 -04:00
h1 = new Histogram1D ( " Spectrum " , " x1 " , 300 , - 200 , 200 , this ) ;
2023-06-23 13:50:21 -04:00
h1 - > SetColor ( Qt : : darkGreen ) ;
2023-12-14 16:55:33 -05:00
//h1->AddDataList("Test", Qt::red); // add another histogram in h1, Max Data List is 10
2023-06-27 15:47:34 -04:00
layout - > addWidget ( h1 , 1 , 1 ) ;
2023-06-20 11:57:39 -04:00
2024-08-13 12:45:24 -04:00
h1g = new Histogram1D ( " Spectrum (PID gated) " , " x1 " , 300 , - 200 , 200 , this ) ;
2023-06-27 15:47:34 -04:00
layout - > addWidget ( h1g , 2 , 1 ) ;
layout - > setColumnStretch ( 0 , 1 ) ;
layout - > setColumnStretch ( 1 , 1 ) ;
2023-06-12 16:41:03 -04:00
}
inline void SplitPole : : UpdateHistograms ( ) {
2023-08-28 15:02:56 -04:00
if ( this - > isVisible ( ) = = false ) return ;
2023-11-17 16:47:11 -05:00
if ( chkRunAnalyzer - > isChecked ( ) = = false ) return ;
2023-08-28 15:02:56 -04:00
2023-06-12 16:41:03 -04:00
BuildEvents ( ) ; // call the event builder to build events
//============ Get events, and do analysis
2024-08-29 16:49:52 -04:00
long eventBuilt = mb - > eventBuilt ;
2023-06-12 16:41:03 -04:00
if ( eventBuilt = = 0 ) return ;
2023-06-20 11:57:39 -04:00
//============ Get the cut list, if any
2023-06-23 13:50:21 -04:00
QList < QPolygonF > cutList = hPID - > GetCutList ( ) ;
2023-06-20 11:57:39 -04:00
const int nCut = cutList . count ( ) ;
unsigned long long tMin [ nCut ] = { 0xFFFFFFFFFFFFFFFF } , tMax [ nCut ] = { 0 } ;
unsigned int count [ nCut ] = { 0 } ;
//============ Processing data and fill histograms
2024-08-29 16:49:52 -04:00
long eventIndex = mb - > eventIndex ;
2023-06-12 16:41:03 -04:00
long eventStart = eventIndex - eventBuilt + 1 ;
if ( eventStart < 0 ) eventStart + = MaxNEvent ;
2023-06-20 11:57:39 -04:00
2023-06-12 16:41:03 -04:00
for ( long i = eventStart ; i < = eventIndex ; i + + ) {
2024-08-29 16:49:52 -04:00
std : : vector < Hit > event = mb - > events [ i ] ;
2023-06-20 11:57:39 -04:00
//printf("-------------- %ld\n", i);
2023-06-23 13:50:21 -04:00
hMulti - > Fill ( ( int ) event . size ( ) ) ;
//if( event.size() < 9 ) return;
if ( event . size ( ) = = 0 ) return ;
2023-10-23 12:53:51 -04:00
hit . ClearData ( ) ;
2023-06-23 13:50:21 -04:00
2023-06-12 16:41:03 -04:00
for ( int k = 0 ; k < ( int ) event . size ( ) ; k + + ) {
2023-06-20 11:57:39 -04:00
//event[k].Print();
2024-08-13 12:45:24 -04:00
if ( event [ k ] . ch = = SPS : : ChMap : : ScinR ) { hit . eSR = event [ k ] . energy ; hit . tSR = event [ k ] . timestamp + event [ k ] . fineTime / 1000. ; }
if ( event [ k ] . ch = = SPS : : ChMap : : ScinL ) { hit . eSL = event [ k ] . energy ; hit . tSL = event [ k ] . timestamp + event [ k ] . fineTime / 1000. ; }
if ( event [ k ] . ch = = SPS : : ChMap : : dFR ) { hit . eFR = event [ k ] . energy ; hit . tFR = event [ k ] . timestamp + event [ k ] . fineTime / 1000. ; }
if ( event [ k ] . ch = = SPS : : ChMap : : dFL ) { hit . eFL = event [ k ] . energy ; hit . tFL = event [ k ] . timestamp + event [ k ] . fineTime / 1000. ; }
if ( event [ k ] . ch = = SPS : : ChMap : : dBR ) { hit . eBL = event [ k ] . energy ; hit . tBL = event [ k ] . timestamp + event [ k ] . fineTime / 1000. ; }
if ( event [ k ] . ch = = SPS : : ChMap : : dBL ) { hit . eBL = event [ k ] . energy ; hit . tBL = event [ k ] . timestamp + event [ k ] . fineTime / 1000. ; }
if ( event [ k ] . ch = = SPS : : ChMap : : Cathode ) { hit . eCath = event [ k ] . energy ; hit . tCath = event [ k ] . timestamp + event [ k ] . fineTime / 1000. ; }
if ( event [ k ] . ch = = SPS : : ChMap : : AnodeF ) { hit . eAF = event [ k ] . energy ; hit . tAF = event [ k ] . timestamp + event [ k ] . fineTime / 1000. ; }
if ( event [ k ] . ch = = SPS : : ChMap : : AnodeB ) { hit . eAB = event [ k ] . energy ; hit . tAB = event [ k ] . timestamp + event [ k ] . fineTime / 1000. ; }
2023-06-12 16:41:03 -04:00
}
2023-06-23 13:50:21 -04:00
hit . CalData ( ) ;
2023-06-20 11:57:39 -04:00
2023-12-14 16:55:33 -05:00
double pidX = hit . eSL ;
unsigned long long tPidX = hit . tSL ;
2024-08-13 12:45:24 -04:00
double pidY = hit . eAB ;
2023-12-14 16:55:33 -05:00
2024-08-13 12:45:24 -04:00
if ( pidX > 0 & & pidY > 0 ) {
hPID - > Fill ( pidX , pidY ) ; // x, y
}
if ( ! std : : isnan ( hit . x1 ) ) {
h1 - > Fill ( hit . x1 ) ;
}
2023-12-14 16:55:33 -05:00
//h1->Fill(hit.eSR, 1);
2023-06-20 11:57:39 -04:00
2024-08-13 12:45:24 -04:00
2023-06-23 13:50:21 -04:00
//check events inside any Graphical cut and extract the rate, using tSR only
2023-06-20 11:57:39 -04:00
for ( int p = 0 ; p < cutList . count ( ) ; p + + ) {
if ( cutList [ p ] . isEmpty ( ) ) continue ;
2023-12-14 16:55:33 -05:00
if ( cutList [ p ] . containsPoint ( QPointF ( pidX , pidY ) , Qt : : OddEvenFill ) ) {
if ( tPidX < tMin [ p ] ) tMin [ p ] = tPidX ;
if ( tPidX > tMax [ p ] ) tMax [ p ] = tPidX ;
2023-06-20 11:57:39 -04:00
count [ p ] + + ;
//printf(".... %d \n", count[p]);
2024-08-13 12:45:24 -04:00
// if( p == 0 ) {
// double xAvg = hit.xAvg * 10;
// double xAvgC = xAvg * sbRhoScale->value() + sbRhoOffset->value();
// h1g->Fill(hit.Rho2Ex(xAvgC/1000.));
// }
if ( p = = 0 ) {
h1g - > Fill ( hit . x1 ) ;
2023-12-14 16:55:33 -05:00
}
2023-06-20 11:57:39 -04:00
}
}
2023-06-12 16:41:03 -04:00
}
2023-06-23 13:50:21 -04:00
QList < QString > cutNameList = hPID - > GetCutNameList ( ) ;
2023-06-20 11:57:39 -04:00
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 ) ) ;
2024-08-26 13:59:04 -04:00
influx - > WriteData ( dataBaseName . toStdString ( ) ) ;
2023-06-20 11:57:39 -04:00
influx - > ClearDataPointsBuffer ( ) ;
}
2023-06-12 16:41:03 -04:00
}
2024-10-22 16:38:01 -04:00
inline void SplitPole : : ReplotHistograms ( ) {
hPID - > UpdatePlot ( ) ;
h1 - > UpdatePlot ( ) ;
hMulti - > UpdatePlot ( ) ;
h1g - > UpdatePlot ( ) ;
}
2023-06-12 16:41:03 -04:00
2023-06-12 16:32:01 -04:00
# endif