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

View File

@ -258,6 +258,7 @@ void MultiBuilder::BuildEvents(bool isFinal, bool skipTrace, bool verbose){
do {
if ( nextIndex[bd][ch] < 0 ) break; // hotfix
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);

View File

@ -151,6 +151,9 @@ SingleSpectra::SingleSpectra(Digitizer ** digi, unsigned int nDigi, QString rawD
// Setup the timer to trigger every second
connect(timer, &QTimer::timeout, histWorker, &HistWorker::FillHistograms);
connect( histWorker, &HistWorker::workDone, this, &SingleSpectra::ReplotHistograms);
workerThread->start();
}
@ -314,6 +317,20 @@ void SingleSpectra::FillHistograms(){
}
void SingleSpectra::ReplotHistograms(){
int ID = cbDigi->currentData().toInt();
int ch = cbCh->currentData().toInt();
if( ch == digi[ID]->GetNumInputCh()) {
if( hist2DVisibility[ID] ) hist2D[ID]->UpdatePlot();
return;
}
if( histVisibility[ID][ch] ) hist[ID][ch]->UpdatePlot();
}
void SingleSpectra::SaveSetting(){
DebugPrint("%s", "SingleSpectra");

View File

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

View File

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

View File

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

View File

@ -12,13 +12,11 @@
class Cross : public Analyzer{
public:
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.
tick2ns = digi[0]->GetTick2ns();
@ -39,7 +37,7 @@ public:
public slots:
void UpdateHistograms();
void ReplotHistograms();
private:
@ -59,16 +57,30 @@ private:
Histogram2D * hdEdT; // dE versus TOF: ch1 versus (t7-t1)*1e9
Histogram1D * hMulti; //Multiplicity of an event
int tick2ns;
float ch1, ch4, ch7;
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(){
@ -78,30 +90,52 @@ inline void Cross::SetUpCanvas(){
//hPID = new Histogram2D("RAISOR", "E", "dE", 100, 0, 5000, 100, 0, 5000, this);
//layout->addWidget(hPID, 2, 0);
int row = 0;
bnClearHist = new QPushButton("Clear All Hist.", this);
layout->addWidget(bnClearHist, row, 0);
connect( bnClearHist, &QPushButton::clicked, this, [=](){
hdE->Clear();
hE->Clear();
hdT->Clear();
hTotE->Clear();
hdEE->Clear();
hdEtotE->Clear();
hdEdT->Clear();
hTWin->Clear();
hMulti->Clear();
});
row ++;
hdEE = new Histogram2D("dE vs E", "E[ch]", "dE[ch]", 500, -100, 5000, 500, -100, 5000, this);
layout->addWidget(hdEE, row, 0, 1, 2);
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=0)", "dE [ch]", 300, 0, 5000, this);
layout->addWidget(hdE, row, 2);
hdE = new Histogram1D("raw dE (ch=1)", "dE [ch]", 300, 0, 8000, this);
layout->addWidget(hdE, 0, 2);
hdEdT = new Histogram2D("dE vs TOF", "TOF [ns]", "dE", 100, 0, 500, 100, 0, 4000, this);
layout->addWidget(hdEdT, 1, 3);
hE = new Histogram1D("raw E (ch=4)", "E [ch]", 300, 0, 10000, this);
layout->addWidget(hE, 0, 3);
hdEtotE = new Histogram2D("dE vs TotE", "TotE[ch]", "dE[ch]", 500, 0, 10000, 500, 0, 10000, this);
layout->addWidget(hdEtotE, 1, 0, 1, 2);
hdT = new Histogram1D("raw dT (ch=7)", "dT [ch]", 300, 0, 1000, this);
layout->addWidget(hdT, 1, 2);
hE = new Histogram1D("raw E (ch=2)", "E [ch]", 300, 0, 10000, this);
layout->addWidget(hE, row, 3);
hTotE = new Histogram1D("total energy (dE+E)", "TotE [ch]", 300, 0, 16000, this);
layout->addWidget(hTotE, 0, 4);
layout->addWidget(hTotE, row, 4);
hMulti = new Histogram1D("Multiplicity", "", 10, 0, 10, this);
layout->addWidget(hMulti, row, 5);
hTWin = new Histogram1D("coincidence time window", "TWin [ns]", 300, 0, 500, this);
layout->addWidget(hTWin, 1, 4);
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);
}
@ -124,24 +158,38 @@ inline void Cross::UpdateHistograms(){
*/
QList<QPolygonF> cutList1 = hdEE->GetCutList();
const int nCut1 = cutList1.count();
unsigned long long tMin1[nCut1] = {0xFFFFFFFFFFFFFFFF}, tMax1[nCut1] = {0};
unsigned int count1[nCut1]={0};
printf(" >>>>>> num of cut = %d, event Size : %ld\n", nCut1, eventBuilt);
unsigned long long tMin1[nCut1], tMax1[nCut1];
unsigned int count1[nCut1];
QList<QPolygonF> cutList2 = hdEtotE->GetCutList();
const int nCut2 = cutList2.count();
unsigned long long tMin2[nCut2] = {0xFFFFFFFFFFFFFFFF}, tMax2[nCut2] = {0};
unsigned long long tMin2[nCut2] = {0xFFFFFFFFFFFFFFFF}, tMax2[nCut2] = {0}; // not a proper way to initialized
unsigned int count2[nCut2]={0};
//============ Processing data and fill histograms
long eventIndex = evtbder->eventIndex;
long eventStart = eventIndex - eventBuilt + 1;
if(eventStart < 0 ) eventStart += MaxNEvent;
for( int i = 0; i < nCut1; i++) {
tMin1[i] = -1;
tMax1[i] = 0;
count1[i] = 0;
}
for( long i = eventStart ; i <= eventIndex; i ++ ){
std::vector<Hit> event = evtbder->events[i];
//printf("-------------- %ld\n", i);
if( event.size() == 0 ) return;
hMulti->Fill(event.size());
ch1 = -100; t1 = 0;
ch4 = -100; t4 = 0;
ch7 = -100; t7 = 0;
for( int k = 0; k < (int) event.size(); k++ ){
//event[k].Print();
@ -154,27 +202,24 @@ inline void Cross::UpdateHistograms(){
// printf("(E, dE) = (%f, %f)\n", E, dE);
//hPID->Fill(ch4 , ch1); // x, y
//etotal = ch1*0.25*0.25 + ch4
hdE->Fill(ch1);
hE->Fill(ch4);
hdT->Fill(ch7);
hTotE->Fill(ch1 + ch4);
hdEE->Fill(ch4,ch1);
hdEtotE->Fill(ch1 + ch4,ch1);
hdEdT->Fill((t7-t1)*1e9,ch1);
hTWin->Fill((t4-t1)*1e9);
if( ch1 > 0 ) hdE->Fill(ch1);
if( ch4 > 0 ) hE->Fill(ch4);
if( ch7 > 0 ) hdT->Fill(ch7);
if( ch1 > 0 && ch4 > 0 ){
hTotE->Fill(0.25 * ch1 + ch4);
hdEE->Fill(ch4,ch1);
if( t4 > t1 ) {
hTWin->Fill((t4-t1));
}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
/*
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]);
}
}
*/
// if( ch1 == 0 && ch4 == 0 ) continue;
for(int p = 0; p < cutList1.count(); p++ ){
if( cutList1[p].isEmpty() ) continue;
if( cutList1[p].containsPoint(QPointF(ch4, ch1), Qt::OddEvenFill) ){
@ -198,18 +243,8 @@ inline void Cross::UpdateHistograms(){
for(int p = 0; p < cutList2.count(); p++ ){
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
QList<QString> cutNameList1 = hdEE->GetCutNameList();

View File

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

View File

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

View File

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

View File

@ -26,7 +26,6 @@ public:
evtbder->SetTimeWindow(500);
//========== use the influx from the Analyzer
influx = new InfluxDB();
SetDatabase("https://localhost:8086", "testing", "zKhzKk4Yhf1l9QU-yE2GsIZ1RazqUgoW3NlF8LJqq_xDMwatOJwg1sKrjgq36uLEsQf8Fmn4sJALP7Kkilk14A==");
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 are two virual methods
There are three virual methods
- SetupCanvas()
- UpdateHistograms()
- ReplotHistograms()
Users must implement these two methods in theie custom analyzer.
@ -33,6 +34,7 @@ public:
void SetUpCanvas();
public slots:
void UpdateHistograms();
void ReplotHistograms();
private:
@ -84,10 +86,14 @@ inline void CustomAnalyzer::UpdateHistograms(){
//analysis and fill historgam
}
}
```
4. implement the ReplotHistograms() method
```cpp
inline void CustomAnalyzer::ReplotHistograms(){
//Render histograms
h2D->UpdatePlot();
h1D->UpdatePlot();
}
```

View File

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