FSUDAQ_Qt6/analyzers
2024-10-22 16:38:01 -04:00
..
Analyser.cpp simplify code for multi thread 2024-10-22 13:56:26 -04:00
Analyser.h update the master branch from 0ee20bc 2024-09-30 18:38:48 -04:00
CoincidentAnalyzer.h fix all code with parallel thread 2024-10-22 16:38:01 -04:00
Cross.h update the master branch from 0ee20bc 2024-09-30 18:38:48 -04:00
EncoreAnalyzer.h bug fix on MUSICAnalyzer.h 2024-08-01 16:03:50 -05:00
Isotope.h separate out SplitPoleHit Class for easy reuse in other program 2023-10-20 17:57:03 -04:00
mass20.txt modified splitpoleanalyzer.h 2023-10-20 16:17:50 -04:00
MUSICAnalyzer.h bug fix on MUSICAnalyzer.h 2024-08-01 16:03:50 -05:00
NeutronGamma.h fix all code with parallel thread 2024-10-22 16:38:01 -04:00
RAISOR.h added analyzer/README.md, move the isWorking from the custom analyzer to Analyzer, so user don't need to worry 2024-08-29 15:47:07 -04:00
README.md added analyzer/README.md, move the isWorking from the custom analyzer to Analyzer, so user don't need to worry 2024-08-29 15:47:07 -04:00
SplitPoleAnalyzer.h fix all code with parallel thread 2024-10-22 16:38:01 -04:00
SplitPoleHit.h after SPS test 2024-08-13 12:45:24 -04:00

Introduction

This folder stored all online analyzers. The Analyser.cpp/h is the base class for all analyzer.

The Analyzer.cpp/h has the MultiBuilder (to handle event building) and InfluxDB (to handle pushing data to influxDB database) classes. In Addision, it has a QThread, a AnalyzerWorker, and a QTimer, these three object handle the threading of UpdateHistograms().

The AnalyzerWorker moves to the QThread. QTimer::timeout will trigger AnalyzerWorker::UpdateHistograms().

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

  • SetupCanvas()
  • UpdateHistograms()

Users must implement these two methods in theie custom analyzer.

Intruction to make new Analyzer

The CoindientAnalyzer.h is a good example.

  1. inheirate the Analyzer class
class CustomAnalyzer : public Analyzer{
  Q_OBJECT
public:
  CustomAnalyzer(Digitizer ** digi, unsigned int nDigi, QMainWindow * parent = nullptr): Analyzer(digi, nDigi, parent){
    SetUpdateTimeInSec(1.0); // set histogram update period in sec
    mb->SetTimeWindow(500); // set the event time windows
    // ... other custom stuffs
  }

  void SetUpCanvas();
public slots:
  void UpdateHistograms();

private:

  Histogram2D * h2D;
  Histogram1D * h1D;
  // some priavte variables

}
  1. implement the SetUpCanvas() method
inline void CustomAnalyzer::SetUpCanvas(){
  setWindowTitle("Title");
  setGeometry(0, 0, 1600, 1000);   

  h2D = new Histogram2D("Coincident Plot", "XXX", "YYY", 200, 0, 30000, 200, 0, 30000, this, rawDataPath);

  //layout is inheriatge from Analyzer
  layout->addWidget(h2D, 0, 0); // row-0, col-0

  h1 = new Histogram1D("1D Plot", "XXX", 300, 0, 30000, this);
  h1->SetColor(Qt::darkGreen);
  layout->addWidget(h1, 0, 1); // row-0, col-1

  //other GUI elements
}
  1. implement the UpdateHistograms() method
inline void CustomAnalyzer::UpdateHistograms(){
  // don't update histogram when the windows not visible
  if( this->isVisible() == false ) return; 

  BuildEvents(false); // call the event builder to build events, no verbose

  //check number of event built
  long eventBuilt = mb->eventBuilt;
  if( eventBuilt == 0 ) return;

  //============ Processing data and fill histograms
  long eventIndex = mb->eventIndex;
  long eventStart = eventIndex - eventBuilt + 1;
  if(eventStart < 0 ) eventStart += MaxNEvent;
  
  for( long i = eventStart ; i <= eventIndex; i ++ ){
    std::vector<Hit> event = mb->events[i];

    //analysis and fill historgam 
  }  

  //Render histograms
  h2D->UpdatePlot();
  h1D->UpdatePlot();

}