Compare commits

..

No commits in common. "04e27e9d708d9eb1c1d9a5613f6178dd63ea8979" and "be62125e77430ecff6115a4f9d1d12262953f4fc" have entirely different histories.

9 changed files with 65 additions and 141 deletions

View File

@ -283,7 +283,6 @@ 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,9 +310,6 @@ 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));
@ -795,7 +792,6 @@ 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,7 +258,6 @@ 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,9 +151,6 @@ 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();
} }
@ -317,20 +314,6 @@ 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,8 +43,6 @@ 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,8 +60,6 @@ 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();
} }
@ -244,9 +242,4 @@ void Analyzer::SetUpCanvas(){
void Analyzer::UpdateHistograms(){ void Analyzer::UpdateHistograms(){
}
void Analyzer::ReplotHistograms(){
} }

View File

@ -63,7 +63,6 @@ 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,11 +12,13 @@
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(1.0); SetUpdateTimeInSec(2.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();
@ -25,9 +27,9 @@ public:
evtbder = GetEventBuilder(); evtbder = GetEventBuilder();
evtbder->SetTimeWindow(500); evtbder->SetTimeWindow(500);
SetDatabase("http://localhost:8086/", "testing", "zKhzKk4Yhf1l9QU-yE2GsIZ1RazqUgoW3NlF8LJqq_xDMwatOJwg1sKrjgq36uLEsQf8Fmn4sJALP7Kkilk14A=="); //========== use the influx from the Analyzer
influx = new InfluxDB("http://localhost:8086");
printf(" %p \n", influx); dataBaseName = "testing";
SetUpCanvas(); // see below SetUpCanvas(); // see below
@ -37,7 +39,7 @@ public:
public slots: public slots:
void UpdateHistograms(); void UpdateHistograms();
void ReplotHistograms();
private: private:
@ -57,30 +59,16 @@ 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(){
@ -90,52 +78,30 @@ 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);
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);
hdE = new Histogram1D("raw dE (ch=0)", "dE [ch]", 300, 0, 5000, this); hdEE = new Histogram2D("dE vs E", "E[ch]", "dE[ch]", 500, -100, 10000, 500, -100, 10000, this);
layout->addWidget(hdE, row, 2); layout->addWidget(hdEE, 0, 0, 1, 2);
hE = new Histogram1D("raw E (ch=2)", "E [ch]", 300, 0, 10000, this); hdE = new Histogram1D("raw dE (ch=1)", "dE [ch]", 300, 0, 8000, this);
layout->addWidget(hE, row, 3); layout->addWidget(hdE, 0, 2);
hTotE = new Histogram1D("total energy (dE+E)", "TotE [ch]", 300, 0, 16000, this);
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); hdEdT = new Histogram2D("dE vs TOF", "TOF [ns]", "dE", 100, 0, 500, 100, 0, 4000, this);
layout->addWidget(hdEdT, row, 3); layout->addWidget(hdEdT, 1, 3);
hTWin = new Histogram1D("coincidence time window", "TWin [ns]", 100, 0, 100, this); hE = new Histogram1D("raw E (ch=4)", "E [ch]", 300, 0, 10000, this);
layout->addWidget(hTWin, row, 4); 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);
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);
} }
@ -158,38 +124,24 @@ inline void Cross::UpdateHistograms(){
*/ */
QList<QPolygonF> cutList1 = hdEE->GetCutList(); QList<QPolygonF> cutList1 = hdEE->GetCutList();
const int nCut1 = cutList1.count(); const int nCut1 = cutList1.count();
printf(" >>>>>> num of cut = %d, event Size : %ld\n", nCut1, eventBuilt); unsigned long long tMin1[nCut1] = {0xFFFFFFFFFFFFFFFF}, tMax1[nCut1] = {0};
unsigned long long tMin1[nCut1], tMax1[nCut1]; unsigned int count1[nCut1]={0};
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}; // not a proper way to initialized unsigned long long tMin2[nCut2] = {0xFFFFFFFFFFFFFFFF}, tMax2[nCut2] = {0};
unsigned int count2[nCut2]={0}; unsigned int count2[nCut2]={0};
//============ Processing data and fill histograms //============ Processing data and fill histograms
long eventIndex = evtbder->eventIndex; long eventIndex = evtbder->eventIndex;
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();
@ -202,24 +154,27 @@ 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
if( ch1 > 0 ) hdE->Fill(ch1); hdE->Fill(ch1);
if( ch4 > 0 ) hE->Fill(ch4); hE->Fill(ch4);
if( ch7 > 0 ) hdT->Fill(ch7); hdT->Fill(ch7);
if( ch1 > 0 && ch4 > 0 ){ hTotE->Fill(ch1 + ch4);
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) ){
@ -243,8 +198,18 @@ inline void Cross::UpdateHistograms(){
for(int p = 0; p < cutList2.count(); p++ ){ 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 //========== output to Influx
QList<QString> cutNameList1 = hdEE->GetCutNameList(); QList<QString> cutNameList1 = hdEE->GetCutNameList();
@ -255,11 +220,9 @@ inline void Cross::UpdateHistograms(){
//printf("%llu %llu, %f %d\n", tMin1[p], tMax1[p], dT, count1[p]); //printf("%llu %llu, %f %d\n", tMin1[p], tMax1[p], dT, count1[p]);
printf("%10s | %d | %f Hz \n", cutNameList1[p].toStdString().c_str(), count1[p], rate); printf("%10s | %d | %f Hz \n", cutNameList1[p].toStdString().c_str(), count1[p], rate);
if( influx ){ influx->AddDataPoint("Cut,name=" + cutNameList1[p].toStdString()+ " value=" + std::to_string(rate));
influx->AddDataPoint("Cut,name=" + cutNameList1[p].toStdString()+ " value=" + std::to_string(rate)); influx->WriteData("testing");
influx->WriteData("testing"); influx->ClearDataPointsBuffer();
influx->ClearDataPointsBuffer();
}
} }
} }

View File

@ -8,10 +8,9 @@ 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 three virual methods There are two 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.
@ -34,7 +33,6 @@ public:
void SetUpCanvas(); void SetUpCanvas();
public slots: public slots:
void UpdateHistograms(); void UpdateHistograms();
void ReplotHistograms();
private: private:
@ -86,14 +84,10 @@ 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();
} }
``` ```