full commit at end of c11 experiment, still many bugs etc

This commit is contained in:
Calem@RAISOR 2024-09-23 10:20:31 -05:00
parent 1466f8540f
commit 04e27e9d70
14 changed files with 133 additions and 64 deletions

View File

@ -283,6 +283,7 @@ public:
xMin = xmin; xMin = xmin;
xMax = xmax; xMax = xmax;
xBin = xbin; xBin = xbin;
if( xBin > 1000) xBin = 1000;
dX = (xMax - xMin)/(xBin); dX = (xMax - xMin)/(xBin);

View File

@ -310,6 +310,9 @@ inline void Histogram2D::Rebin(int xbin, double xmin, double xmax, int ybin, do
xBin = xbin + 2; xBin = xbin + 2;
yBin = ybin + 2; yBin = ybin + 2;
if( xBin > 1002) xBin = 1002;
if( yBin > 1002) yBin = 1002;
colorMap->data()->clear(); colorMap->data()->clear();
colorMap->data()->setSize(xBin, yBin); colorMap->data()->setSize(xBin, yBin);
colorMap->data()->setRange(QCPRange(xMin, xMax), QCPRange(yMin, yMax)); colorMap->data()->setRange(QCPRange(xMin, xMax), QCPRange(yMin, yMax));
@ -792,6 +795,7 @@ inline void Histogram2D::LoadCuts(QString cutFileName){
// Close the file // Close the file
file.close(); file.close();
qDebug() << "File read successfully from" << cutFileName; qDebug() << "File read successfully from" << cutFileName;
qDebug() << " NUmber of cut loaded " << numCut;
// PrintCutEntry(); // PrintCutEntry();
// DrawCut(); // DrawCut();

View File

@ -258,6 +258,7 @@ void MultiBuilder::BuildEvents(bool isFinal, bool skipTrace, bool verbose){
do { do {
if ( nextIndex[bd][ch] < 0 ) break; // hotfix
unsigned long long time = data[bd]->GetTimestamp(ch, nextIndex[bd][ch]); 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("%6ld, sn: %5d, ch: %2d, timestamp : %16llu | earlistTime : %16llu | timeWindow : %u \n", eventIndex, data[bd]->boardSN, ch, time, earlistTime, timeWindow);

View File

@ -151,6 +151,9 @@ SingleSpectra::SingleSpectra(Digitizer ** digi, unsigned int nDigi, QString rawD
// Setup the timer to trigger every second // Setup the timer to trigger every second
connect(timer, &QTimer::timeout, histWorker, &HistWorker::FillHistograms); connect(timer, &QTimer::timeout, histWorker, &HistWorker::FillHistograms);
connect( histWorker, &HistWorker::workDone, this, &SingleSpectra::ReplotHistograms);
workerThread->start(); 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(){ void SingleSpectra::SaveSetting(){
DebugPrint("%s", "SingleSpectra"); DebugPrint("%s", "SingleSpectra");

View File

@ -43,6 +43,8 @@ public:
QVector<int> generateNonRepeatedCombination(int size); QVector<int> generateNonRepeatedCombination(int size);
void ReplotHistograms();
public slots: public slots:
void FillHistograms(); void FillHistograms();
void ChangeHistView(); void ChangeHistView();

View File

@ -60,6 +60,8 @@ Analyzer::Analyzer(Digitizer ** digi, unsigned int nDigi, QMainWindow * parent )
// printf(" --------- work Done\n"); // printf(" --------- work Done\n");
// }); // });
connect( anaWorker, &AnalyzerWorker::workDone, this, &Analyzer::ReplotHistograms);
anaThread->start(); anaThread->start();
} }
@ -242,4 +244,9 @@ void Analyzer::SetUpCanvas(){
void Analyzer::UpdateHistograms(){ void Analyzer::UpdateHistograms(){
}
void Analyzer::ReplotHistograms(){
} }

View File

@ -63,6 +63,7 @@ public:
virtual void SetUpCanvas(); virtual void SetUpCanvas();
virtual void UpdateHistograms(); // where event-building, analysis, and ploting virtual void UpdateHistograms(); // where event-building, analysis, and ploting
virtual void ReplotHistograms();
public slots: public slots:
void startTimer(){ void startTimer(){

View File

@ -12,13 +12,11 @@
class Cross : public Analyzer{ class Cross : public Analyzer{
public: public:
Cross(Digitizer ** digi, unsigned int nDigi, QMainWindow * parent = nullptr): Analyzer(digi, nDigi, parent){ Cross(Digitizer ** digi, unsigned int nDigi, QMainWindow * parent = nullptr): Analyzer(digi, nDigi, parent){
SetUpdateTimeInSec(2.0); SetUpdateTimeInSec(1.0);
RedefineEventBuilder({0}); // only builder for the 0-th digitizer. RedefineEventBuilder({0}); // only builder for the 0-th digitizer.
tick2ns = digi[0]->GetTick2ns(); tick2ns = digi[0]->GetTick2ns();
@ -39,7 +37,7 @@ public:
public slots: public slots:
void UpdateHistograms(); void UpdateHistograms();
void ReplotHistograms();
private: private:
@ -59,16 +57,30 @@ private:
Histogram2D * hdEdT; // dE versus TOF: ch1 versus (t7-t1)*1e9 Histogram2D * hdEdT; // dE versus TOF: ch1 versus (t7-t1)*1e9
Histogram1D * hMulti; //Multiplicity of an event
int tick2ns; int tick2ns;
float ch1, ch4, ch7; float ch1, ch4, ch7;
unsigned long long t1, t4, t7; unsigned long long t1, t4, t7;
QPushButton * bnClearHist;
}; };
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(){ inline void Cross::SetUpCanvas(){
@ -79,29 +91,51 @@ inline void Cross::SetUpCanvas(){
//hPID = new Histogram2D("RAISOR", "E", "dE", 100, 0, 5000, 100, 0, 5000, this); //hPID = new Histogram2D("RAISOR", "E", "dE", 100, 0, 5000, 100, 0, 5000, this);
//layout->addWidget(hPID, 2, 0); //layout->addWidget(hPID, 2, 0);
hdEE = new Histogram2D("dE vs E", "E[ch]", "dE[ch]", 500, -100, 10000, 500, -100, 10000, this); int row = 0;
layout->addWidget(hdEE, 0, 0, 1, 2); bnClearHist = new QPushButton("Clear All Hist.", this);
layout->addWidget(bnClearHist, row, 0);
hdE = new Histogram1D("raw dE (ch=1)", "dE [ch]", 300, 0, 8000, this); connect( bnClearHist, &QPushButton::clicked, this, [=](){
layout->addWidget(hdE, 0, 2); hdE->Clear();
hE->Clear();
hdT->Clear();
hTotE->Clear();
hdEE->Clear();
hdEtotE->Clear();
hdEdT->Clear();
hTWin->Clear();
hMulti->Clear();
});
hdEdT = new Histogram2D("dE vs TOF", "TOF [ns]", "dE", 100, 0, 500, 100, 0, 4000, this); row ++;
layout->addWidget(hdEdT, 1, 3); hdEE = new Histogram2D("dE vs E", "E[ch]", "dE[ch]", 500, -100, 5000, 500, -100, 5000, this);
layout->addWidget(hdEE, row, 0, 1, 2);
hE = new Histogram1D("raw E (ch=4)", "E [ch]", 300, 0, 10000, this); hdE = new Histogram1D("raw dE (ch=0)", "dE [ch]", 300, 0, 5000, this);
layout->addWidget(hE, 0, 3); layout->addWidget(hdE, row, 2);
hdEtotE = new Histogram2D("dE vs TotE", "TotE[ch]", "dE[ch]", 500, 0, 10000, 500, 0, 10000, this); hE = new Histogram1D("raw E (ch=2)", "E [ch]", 300, 0, 10000, this);
layout->addWidget(hdEtotE, 1, 0, 1, 2); layout->addWidget(hE, row, 3);
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); hTotE = new Histogram1D("total energy (dE+E)", "TotE [ch]", 300, 0, 16000, this);
layout->addWidget(hTotE, 0, 4); 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);
hTWin = new Histogram1D("coincidence time window", "TWin [ns]", 300, 0, 500, this);
layout->addWidget(hTWin, 1, 4);
} }
@ -124,12 +158,13 @@ inline void Cross::UpdateHistograms(){
*/ */
QList<QPolygonF> cutList1 = hdEE->GetCutList(); QList<QPolygonF> cutList1 = hdEE->GetCutList();
const int nCut1 = cutList1.count(); const int nCut1 = cutList1.count();
unsigned long long tMin1[nCut1] = {0xFFFFFFFFFFFFFFFF}, tMax1[nCut1] = {0}; printf(" >>>>>> num of cut = %d, event Size : %ld\n", nCut1, eventBuilt);
unsigned int count1[nCut1]={0}; unsigned long long tMin1[nCut1], tMax1[nCut1];
unsigned int count1[nCut1];
QList<QPolygonF> cutList2 = hdEtotE->GetCutList(); QList<QPolygonF> cutList2 = hdEtotE->GetCutList();
const int nCut2 = cutList2.count(); const int nCut2 = cutList2.count();
unsigned long long tMin2[nCut2] = {0xFFFFFFFFFFFFFFFF}, tMax2[nCut2] = {0}; unsigned long long tMin2[nCut2] = {0xFFFFFFFFFFFFFFFF}, tMax2[nCut2] = {0}; // not a proper way to initialized
unsigned int count2[nCut2]={0}; unsigned int count2[nCut2]={0};
//============ Processing data and fill histograms //============ Processing data and fill histograms
@ -137,12 +172,25 @@ inline void Cross::UpdateHistograms(){
long eventStart = eventIndex - eventBuilt + 1; long eventStart = eventIndex - eventBuilt + 1;
if(eventStart < 0 ) eventStart += MaxNEvent; if(eventStart < 0 ) eventStart += MaxNEvent;
for( int i = 0; i < nCut1; i++) {
tMin1[i] = -1;
tMax1[i] = 0;
count1[i] = 0;
}
for( long i = eventStart ; i <= eventIndex; i ++ ){ for( long i = eventStart ; i <= eventIndex; i ++ ){
std::vector<Hit> event = evtbder->events[i]; std::vector<Hit> event = evtbder->events[i];
//printf("-------------- %ld\n", i); //printf("-------------- %ld\n", i);
if( event.size() == 0 ) return; if( event.size() == 0 ) return;
hMulti->Fill(event.size());
ch1 = -100; t1 = 0;
ch4 = -100; t4 = 0;
ch7 = -100; t7 = 0;
for( int k = 0; k < (int) event.size(); k++ ){ for( int k = 0; k < (int) event.size(); k++ ){
//event[k].Print(); //event[k].Print();
if( event[k].ch == 0 ) {ch1 = event[k].energy; t1 = event[k].timestamp;} // Reads channel 0 of the digitizer corresponding to dE if( event[k].ch == 0 ) {ch1 = event[k].energy; t1 = event[k].timestamp;} // Reads channel 0 of the digitizer corresponding to dE
@ -154,27 +202,24 @@ inline void Cross::UpdateHistograms(){
// printf("(E, dE) = (%f, %f)\n", E, dE); // printf("(E, dE) = (%f, %f)\n", E, dE);
//hPID->Fill(ch4 , ch1); // x, y //hPID->Fill(ch4 , ch1); // x, y
//etotal = ch1*0.25*0.25 + ch4 //etotal = ch1*0.25*0.25 + ch4
hdE->Fill(ch1); if( ch1 > 0 ) hdE->Fill(ch1);
hE->Fill(ch4); if( ch4 > 0 ) hE->Fill(ch4);
hdT->Fill(ch7); if( ch7 > 0 ) hdT->Fill(ch7);
hTotE->Fill(ch1 + ch4); if( ch1 > 0 && ch4 > 0 ){
hTotE->Fill(0.25 * ch1 + ch4);
hdEE->Fill(ch4,ch1); hdEE->Fill(ch4,ch1);
hdEtotE->Fill(ch1 + ch4,ch1); if( t4 > t1 ) {
hdEdT->Fill((t7-t1)*1e9,ch1); hTWin->Fill((t4-t1));
hTWin->Fill((t4-t1)*1e9); }else{
hTWin->Fill((t1-t4));
}
hdEtotE->Fill(0.25 * ch1 + ch4,ch1);
}
if( ch1 > 0 && ch7 > 0) hdEdT->Fill((t7-t1)*1e9,ch1);
//check events inside any Graphical cut and extract the rate //check events inside any Graphical cut and extract the rate
/* // if( ch1 == 0 && ch4 == 0 ) continue;
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++ ){ for(int p = 0; p < cutList1.count(); p++ ){
if( cutList1[p].isEmpty() ) continue; if( cutList1[p].isEmpty() ) continue;
if( cutList1[p].containsPoint(QPointF(ch4, ch1), Qt::OddEvenFill) ){ if( cutList1[p].containsPoint(QPointF(ch4, ch1), Qt::OddEvenFill) ){
@ -201,16 +246,6 @@ inline void Cross::UpdateHistograms(){
printf("hdEE.... %d %d \n", p, count1[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 //========== output to Influx
QList<QString> cutNameList1 = hdEE->GetCutNameList(); QList<QString> cutNameList1 = hdEE->GetCutNameList();
for( int p = 0; p < cutList1.count(); p ++){ for( int p = 0; p < cutList1.count(); p ++){

View File

@ -31,7 +31,6 @@ public:
evtbder = GetEventBuilder(); evtbder = GetEventBuilder();
evtbder->SetTimeWindow(500); //ns evtbder->SetTimeWindow(500); //ns
influx = new InfluxDB();
SetDatabase("https://localhost:8086", "testing", "zKhzKk4Yhf1l9QU-yE2GsIZ1RazqUgoW3NlF8LJqq_xDMwatOJwg1sKrjgq36uLEsQf8Fmn4sJALP7Kkilk14A=="); SetDatabase("https://localhost:8086", "testing", "zKhzKk4Yhf1l9QU-yE2GsIZ1RazqUgoW3NlF8LJqq_xDMwatOJwg1sKrjgq36uLEsQf8Fmn4sJALP7Kkilk14A==");
SetUpCanvas(); // see below SetUpCanvas(); // see below

View File

@ -28,7 +28,6 @@ public:
evtbder = GetEventBuilder(); evtbder = GetEventBuilder();
evtbder->SetTimeWindow(500); evtbder->SetTimeWindow(500);
influx = new InfluxDB();
SetDatabase("https://localhost:8086", "testing", "zKhzKk4Yhf1l9QU-yE2GsIZ1RazqUgoW3NlF8LJqq_xDMwatOJwg1sKrjgq36uLEsQf8Fmn4sJALP7Kkilk14A=="); SetDatabase("https://localhost:8086", "testing", "zKhzKk4Yhf1l9QU-yE2GsIZ1RazqUgoW3NlF8LJqq_xDMwatOJwg1sKrjgq36uLEsQf8Fmn4sJALP7Kkilk14A==");
SetUpCanvas(); // see below SetUpCanvas(); // see below

View File

@ -25,7 +25,6 @@ public:
evtbder = GetEventBuilder(); evtbder = GetEventBuilder();
evtbder->SetTimeWindow(500); evtbder->SetTimeWindow(500);
influx = new InfluxDB();
SetDatabase("https://localhost:8086", "testing", "zKhzKk4Yhf1l9QU-yE2GsIZ1RazqUgoW3NlF8LJqq_xDMwatOJwg1sKrjgq36uLEsQf8Fmn4sJALP7Kkilk14A=="); SetDatabase("https://localhost:8086", "testing", "zKhzKk4Yhf1l9QU-yE2GsIZ1RazqUgoW3NlF8LJqq_xDMwatOJwg1sKrjgq36uLEsQf8Fmn4sJALP7Kkilk14A==");
SetUpCanvas(); // see below SetUpCanvas(); // see below

View File

@ -26,7 +26,6 @@ public:
evtbder->SetTimeWindow(500); evtbder->SetTimeWindow(500);
//========== use the influx from the Analyzer //========== use the influx from the Analyzer
influx = new InfluxDB();
SetDatabase("https://localhost:8086", "testing", "zKhzKk4Yhf1l9QU-yE2GsIZ1RazqUgoW3NlF8LJqq_xDMwatOJwg1sKrjgq36uLEsQf8Fmn4sJALP7Kkilk14A=="); SetDatabase("https://localhost:8086", "testing", "zKhzKk4Yhf1l9QU-yE2GsIZ1RazqUgoW3NlF8LJqq_xDMwatOJwg1sKrjgq36uLEsQf8Fmn4sJALP7Kkilk14A==");
SetUpCanvas(); // see below SetUpCanvas(); // see below

View File

@ -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 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() - SetupCanvas()
- UpdateHistograms() - UpdateHistograms()
- ReplotHistograms()
Users must implement these two methods in theie custom analyzer. Users must implement these two methods in theie custom analyzer.
@ -33,6 +34,7 @@ public:
void SetUpCanvas(); void SetUpCanvas();
public slots: public slots:
void UpdateHistograms(); void UpdateHistograms();
void ReplotHistograms();
private: private:
@ -84,10 +86,14 @@ inline void CustomAnalyzer::UpdateHistograms(){
//analysis and fill historgam //analysis and fill historgam
} }
}
```
4. implement the ReplotHistograms() method
```cpp
inline void CustomAnalyzer::ReplotHistograms(){
//Render histograms //Render histograms
h2D->UpdatePlot(); h2D->UpdatePlot();
h1D->UpdatePlot(); h1D->UpdatePlot();
} }
``` ```

View File

@ -27,7 +27,6 @@ public:
evtbder = GetEventBuilder(); evtbder = GetEventBuilder();
evtbder->SetTimeWindow(500); evtbder->SetTimeWindow(500);
influx = new InfluxDB();
SetDatabase("https://localhost:8086", "testing", "zKhzKk4Yhf1l9QU-yE2GsIZ1RazqUgoW3NlF8LJqq_xDMwatOJwg1sKrjgq36uLEsQf8Fmn4sJALP7Kkilk14A=="); SetDatabase("https://localhost:8086", "testing", "zKhzKk4Yhf1l9QU-yE2GsIZ1RazqUgoW3NlF8LJqq_xDMwatOJwg1sKrjgq36uLEsQf8Fmn4sJALP7Kkilk14A==");
SetUpCanvas(); // see below SetUpCanvas(); // see below