diff --git a/analyzers/BeamTune.h b/analyzers/BeamTune.h new file mode 100644 index 0000000..eb54292 --- /dev/null +++ b/analyzers/BeamTune.h @@ -0,0 +1,296 @@ +#ifndef BeamTune_h +#define BeamTune_h + +/********************************************* + * This is online analyzer for PID, ANL + * + * Created by Khushi @ 2024-09-03 + * + * ******************************************/ +#include "Analyser.h" +#include +#include "math.h" +#include +#include "TLine.h" +//#include +#include +#include +class BeamTune : public Analyzer{ + + + +public: + BeamTune(Digitizer ** digi, unsigned int nDigi, QMainWindow * parent = nullptr): Analyzer(digi, nDigi, parent){ + + + SetUpdateTimeInSec(2.0); + + RedefineEventBuilder({0}); // only builder for the 0-th digitizer. + tick2ns = digi[0]->GetTick2ns(); + + 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. + evtbder = GetEventBuilder(); + evtbder->SetTimeWindow(500); + + //========== use the influx from the Analyzer + influx = new InfluxDB("https://fsunuc.physics.fsu.edu/influx/"); + dataBaseName = "testing"; + + SetUpCanvas(); // see below + + }; + + void SetUpCanvas(); + +public slots: + void UpdateHistograms(); + + +private: + + MultiBuilder *evtbder; + + //Histogram2D * hPID; + + Histogram2D * hFrame; // dE versus E : ch1 versus ch4 + Histogram2D * hFrame1; // dE versus E : ch1 versus ch4 + //Histogram2D * hdEtotE; // dE versus totE : ch1 versus (ch1+ch4) + + int tick2ns; + + float s0, s1, s2, s3; + unsigned long long s_t0, s_t1, s_t2, s_t3; + + float e0, e1, e2, e3, dE1, dE2; + unsigned long long t0, t1, t2, t3, dE1_t, dE2_t; + + float ch1, ch4, ch7; + //unsigned long long t1, t4, t7; + + +}; + + + +inline void BeamTune::SetUpCanvas(){ + + setGeometry(0, 0, 2000, 1000); + + //============ histograms + + //hPID = new Histogram2D("RAISOR", "E", "dE", 100, 0, 5000, 100, 0, 5000, this); + //layout->addWidget(hPID, 2, 0); + + hFrame = new Histogram2D("X Map", "X-axis", "Y-axis", 100, -10, 110, 100, -0.8, 0.8, this); + layout->addWidget(hFrame, 0, 0, 1, 2); + + hFrame1 = new Histogram2D("X Map", "X-axis", "Y-axis", 100, -10, 110, 100, -0.8, 0.8, this); + layout->addWidget(hFrame1, 1, 1, 1, 2); + + + /* + hdEdT = new Histogram2D("dE vs TOF", "TOF [ns]", "dE", 100, 0, 500, 100, 0, 4000, this); + layout->addWidget(hdEdT, 1, 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); + */ +} + +inline void BeamTune::UpdateHistograms(){ + + if( this->isVisible() == false ) return; + + BuildEvents(false); // call the event builder to build events + + //============ Get events, and do analysis + long eventBuilt = evtbder->eventBuilt; + if( eventBuilt == 0 ) return; + + //============ Get the cut list, if any + /* + QList cutList = hPID->GetCutList(); + const int nCut = cutList.count(); + unsigned long long tMin[nCut] = {0xFFFFFFFFFFFFFFFF}, tMax[nCut] = {0}; + unsigned int count[nCut]={0}; + + QList cutList1 = hFrame->GetCutList(); + const int nCut1 = cutList1.count(); + unsigned long long tMin1[nCut1] = {0xFFFFFFFFFFFFFFFF}, tMax1[nCut1] = {0}; + unsigned int count1[nCut1]={0}; + */ + /* + QList cutList2 = hdEtotE->GetCutList(); + const int nCut2 = cutList2.count(); + unsigned long long tMin2[nCut2] = {0xFFFFFFFFFFFFFFFF}, tMax2[nCut2] = {0}; + 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( long i = eventStart ; i <= eventIndex; i ++ ){ + std::vector event = evtbder->events[i]; + //printf("-------------- %ld\n", i); + + if( event.size() == 0 ) return; + + + e0 = 0; + e1 = 0; + e2 = 0; + e3 = 0; + + t0 = 0; + t1 = 0; + t2 = 0; + t3 = 0; + + s0 = 0; + s1 = 0; + s2 = 0; + s3 = 0; + + s_t0 = 0; + s_t1 = 0; + s_t2 = 0; + s_t3 = 0; + + + //std::vector lines; // Store lines to draw after the loop + //std::vector markers; // Store markers to draw after the loop + //int lineCount = 0; // Counter to keep track of the number of lines + + for( int k = 0; k < (int) event.size(); k++ ){ + //event[k].Print(); + + if( event[k].ch == 2 ) {s0 = event[k].energy; s_t0 = event[k].timestamp;} // + if( event[k].ch == 3 ) {s1= event[k].energy; s_t1 = event[k].timestamp;} // The 4 output signals from the + if( event[k].ch == 4 ) {s2 = event[k].energy; s_t2 = event[k].timestamp;} // MCP detector + if( event[k].ch == 5 ) {s3= event[k].energy; s_t3 = event[k].timestamp;} // + + if( event[k].ch == 10 ) {e0 = event[k].energy; t0 = event[k].timestamp;} // + if( event[k].ch == 11 ) {e1= event[k].energy; t1 = event[k].timestamp;} // The 4 output signals from the + if( event[k].ch == 12 ) {e2 = event[k].energy; t2 = event[k].timestamp;} // position sensitive E detector + if( event[k].ch == 13 ) {e3= event[k].energy; t3 = event[k].timestamp;} // + + } + + if (s0>10 && s1>10 && s2>10 && s3>10 && e0>10 && e1>10 && e2>10 && e3>10) { + float_t rotation_angle = 31.; + double_t Xr = (((s1+s2)/(s0+s1+s2+s3))-0.51)*cos(-rotation_angle*M_PI/180)-(((s2+s3)/(s0+s1+s2+s3))-0.51)*sin(-rotation_angle*M_PI/180); + double_t Yr = (((s1+s2)/(s0+s1+s2+s3))-0.51)*sin(-rotation_angle*M_PI/180)+(((s2+s3)/(s0+s1+s2+s3))-0.51)*cos(-rotation_angle*M_PI/180); + + double_t X2 = ((e0-e1)/(e0+e1)); // PSD X position + double_t Y2 = ((e3-e2)/(e2+e3)); // PSD Y position + // printf("(E, dE) = (%f, %f)\n", E, dE); + + + // Create the line and store it in the vector + TLine *line = new TLine(Xr, Yr, X2, Y2); + //line->SetLineColor(kBlack); + // Set line color based on Y2 value + /* + if (Y2 > 0) { + line->SetLineColor(kPink); // Pink color if Y2 > 0 + } else { + line->SetLineColor(kBlack); // Black otherwise + } + */ + //lines.push_back(line); + //lineCount++; // Increment the counter + + //Create markers at the start and end of the line + //TMarker *startMarker = new TMarker(Xr, Yr, kFullCircle); + //startMarker->SetMarkerColor(kRed); + //startMarker->SetMarkerSize(0.1); + //markers.push_back(startMarker); + + //TMarker *endMarker = new TMarker(X2, Y2, kFullCircle); + //endMarker->SetMarkerColor(kGreen); + //endMarker->SetMarkerSize(0.2); + //markers.push_back(endMarker); + + + hFrame->Fill(Xr,Yr, sX2,Y2); + hFrame1->Fill(X2,Y2); + + // Draw all the lines after the loop + + //for (auto line : lines) { + // line->Draw(); + //} + + // Draw all the markers after the lines + //for (auto marker : markers) { + // marker->Draw(); + //} + //gStyle->SetOptStat(0000000); + //hdEtotE->Fill(ch1*0.25*0.25 + ch4,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]); + } + } + + for(int p = 0; p < cutList1.count(); p++ ){ + if( cutList1[p].isEmpty() ) continue; + if( cutList1[p].containsPoint(QPointF(ch4, ch1), Qt::OddEvenFill) ){ + if( t1 < tMin1[p] ) tMin1[p] = t1; + if( t1 > tMax1[p] ) tMax1[p] = t1; + count1[p] ++; + //printf("hdEE.... %d \n", count1[p]); + } + } + + for(int p = 0; p < cutList2.count(); p++ ){ + if( cutList2[p].isEmpty() ) continue; + if( cutList2[p].containsPoint(QPointF(ch1+ch4,ch1), Qt::OddEvenFill) ){ + if( t1 < tMin2[p] ) tMin2[p] = t1; + if( t1 > tMax2[p] ) tMax2[p] = t1; + count2[p] ++; + //printf("hdEtotE.... %d \n", count2[p]); + } + } + */ + } + + /* + for(int p = 0; p < cutList2.count(); p++ ){ + printf("hdEE.... %d %d \n", p, count1[p]); + } +*/ + //hPID->UpdatePlot(); + + hFrame->UpdatePlot(); + hFrame1->UpdatePlot(); + //hdEtotE->UpdatePlot(); + + /* + //========== output to Influx + QList cutNameList = hPID->GetCutNameList(); + 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)); + influx->WriteData(dataBaseName); + influx->ClearDataPointsBuffer(); + } + */ +} + + +#endif diff --git a/analyzers/Cross.h b/analyzers/Cross.h new file mode 100644 index 0000000..8d58ac8 --- /dev/null +++ b/analyzers/Cross.h @@ -0,0 +1,231 @@ +#ifndef Cross_h +#define Cross_h + +/********************************************* + * This is online analyzer for PID, ANL + * + * Created by Khushi @ 2024-09-03 + * + * ******************************************/ +#include "Analyser.h" + + +class Cross : public Analyzer{ + + + +public: + Cross(Digitizer ** digi, unsigned int nDigi, QMainWindow * parent = nullptr): Analyzer(digi, nDigi, parent){ + + + SetUpdateTimeInSec(2.0); + + RedefineEventBuilder({0}); // only builder for the 0-th digitizer. + tick2ns = digi[0]->GetTick2ns(); + + 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. + evtbder = GetEventBuilder(); + evtbder->SetTimeWindow(500); + + //========== use the influx from the Analyzer + influx = new InfluxDB("https://fsunuc.physics.fsu.edu/influx/"); + dataBaseName = "testing"; + + SetUpCanvas(); // see below + + }; + + void SetUpCanvas(); + +public slots: + void UpdateHistograms(); + + +private: + + MultiBuilder *evtbder; + + //Histogram2D * hPID; + + Histogram1D * hdE; // raw dE (ch=1): ch1 + Histogram1D * hE; // raw E (ch=4) : ch4 + Histogram1D * hdT; // raw dT (ch=7): ch7 + + Histogram1D * hTotE; // total energy (dE+E): ch1+ch4 + Histogram1D * hTWin; // coincidence time window TWin: (t4-t1)*1e9 + + Histogram2D * hdEE; // dE versus E : ch1 versus ch4 + Histogram2D * hdEtotE; // dE versus totE : ch1 versus (ch1+ch4) + + Histogram2D * hdEdT; // dE versus TOF: ch1 versus (t7-t1)*1e9 + + + int tick2ns; + + float ch1, ch4, ch7; + unsigned long long t1, t4, t7; + + +}; + + + +inline void Cross::SetUpCanvas(){ + + setGeometry(0, 0, 2000, 1000); + + //============ histograms + + //hPID = new Histogram2D("RAISOR", "E", "dE", 100, 0, 5000, 100, 0, 5000, this); + //layout->addWidget(hPID, 2, 0); + + 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=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); + + 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); + +} + +inline void Cross::UpdateHistograms(){ + + if( this->isVisible() == false ) return; + + BuildEvents(false); // call the event builder to build events + + //============ Get events, and do analysis + long eventBuilt = evtbder->eventBuilt; + if( eventBuilt == 0 ) return; + + //============ Get the cut list, if any + /* + QList cutList = hPID->GetCutList(); + const int nCut = cutList.count(); + unsigned long long tMin[nCut] = {0xFFFFFFFFFFFFFFFF}, tMax[nCut] = {0}; + unsigned int count[nCut]={0}; + */ + QList cutList1 = hdEE->GetCutList(); + const int nCut1 = cutList1.count(); + unsigned long long tMin1[nCut1] = {0xFFFFFFFFFFFFFFFF}, tMax1[nCut1] = {0}; + unsigned int count1[nCut1]={0}; + + QList cutList2 = hdEtotE->GetCutList(); + const int nCut2 = cutList2.count(); + unsigned long long tMin2[nCut2] = {0xFFFFFFFFFFFFFFFF}, tMax2[nCut2] = {0}; + 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( long i = eventStart ; i <= eventIndex; i ++ ){ + std::vector event = evtbder->events[i]; + //printf("-------------- %ld\n", i); + + if( event.size() == 0 ) return; + + for( int k = 0; k < (int) event.size(); k++ ){ + //event[k].Print(); + if( event[k].ch == 6 ) {ch1 = event[k].energy; t1 = event[k].timestamp;} // Reads channel 6 of the digitizer corresponding to dE + if( event[k].ch == 7 ) {ch4 = event[k].energy; t4 = event[k].timestamp;} // Reads channel 7 of the digitizer corresponding to E + if( event[k].ch == 1 ) {ch7 = event[k].energy; t7 = event[k].timestamp;} + + } + + // 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*0.25*0.25 + ch4); + hdEE->Fill(ch4,ch1); + hdEtotE->Fill(ch1*0.25*0.25 + ch4,ch1); + hdEdT->Fill((t7-t1)*1e9,ch1); + hTWin->Fill((t4-t1)*1e9); + + //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]); + } + } + */ + for(int p = 0; p < cutList1.count(); p++ ){ + if( cutList1[p].isEmpty() ) continue; + if( cutList1[p].containsPoint(QPointF(ch4, ch1), Qt::OddEvenFill) ){ + if( t1 < tMin1[p] ) tMin1[p] = t1; + if( t1 > tMax1[p] ) tMax1[p] = t1; + count1[p] ++; + //printf("hdEE.... %d \n", count1[p]); + } + } + + for(int p = 0; p < cutList2.count(); p++ ){ + if( cutList2[p].isEmpty() ) continue; + if( cutList2[p].containsPoint(QPointF(ch1+ch4,ch1), Qt::OddEvenFill) ){ + if( t1 < tMin2[p] ) tMin2[p] = t1; + if( t1 > tMax2[p] ) tMax2[p] = t1; + count2[p] ++; + //printf("hdEtotE.... %d \n", count2[p]); + } + } + } + + + for(int p = 0; p < cutList2.count(); 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 cutNameList = hPID->GetCutNameList(); + 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)); + influx->WriteData(dataBaseName); + influx->ClearDataPointsBuffer(); + } + */ +} + + +#endif diff --git a/analyzers/Target.h b/analyzers/Target.h new file mode 100644 index 0000000..f3962de --- /dev/null +++ b/analyzers/Target.h @@ -0,0 +1,231 @@ +#ifndef Target_h +#define Target_h + +/********************************************* + * This is online analyzer for PID, ANL + * + * Created by Khushi @ 2024-09-03 + * + * ******************************************/ +#include "Analyser.h" + + +class Target : public Analyzer{ + + + +public: + Target(Digitizer ** digi, unsigned int nDigi, QMainWindow * parent = nullptr): Analyzer(digi, nDigi, parent){ + + + SetUpdateTimeInSec(2.0); + + RedefineEventBuilder({0}); // only builder for the 0-th digitizer. + tick2ns = digi[0]->GetTick2ns(); + + 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. + evtbder = GetEventBuilder(); + evtbder->SetTimeWindow(500); + + //========== use the influx from the Analyzer + influx = new InfluxDB("https://fsunuc.physics.fsu.edu/influx/"); + dataBaseName = "testing"; + + SetUpCanvas(); // see below + + }; + + void SetUpCanvas(); + +public slots: + void UpdateHistograms(); + + +private: + + MultiBuilder *evtbder; + + //Histogram2D * hPID; + + Histogram1D * hdE; // raw dE (ch=1): ch1 + Histogram1D * hE; // raw E (ch=4) : ch4 + Histogram1D * hdT; // raw dT (ch=7): ch7 + + Histogram1D * hTotE; // total energy (dE+E): ch1+ch4 + Histogram1D * hTWin; // coincidence time window TWin: (t4-t1)*1e9 + + Histogram2D * hdEE; // dE versus E : ch1 versus ch4 + Histogram2D * hdEtotE; // dE versus totE : ch1 versus (ch1+ch4) + + Histogram2D * hdEdT; // dE versus TOF: ch1 versus (t7-t1)*1e9 + + + int tick2ns; + + float ch1, ch4, ch7; + unsigned long long t1, t4, t7; + + +}; + + + +inline void Target::SetUpCanvas(){ + + setGeometry(0, 0, 2000, 1000); + + //============ histograms + + //hPID = new Histogram2D("RAISOR", "E", "dE", 100, 0, 5000, 100, 0, 5000, this); + //layout->addWidget(hPID, 2, 0); + + 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=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); + + 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); + +} + +inline void Target::UpdateHistograms(){ + + if( this->isVisible() == false ) return; + + BuildEvents(false); // call the event builder to build events + + //============ Get events, and do analysis + long eventBuilt = evtbder->eventBuilt; + if( eventBuilt == 0 ) return; + + //============ Get the cut list, if any + /* + QList cutList = hPID->GetCutList(); + const int nCut = cutList.count(); + unsigned long long tMin[nCut] = {0xFFFFFFFFFFFFFFFF}, tMax[nCut] = {0}; + unsigned int count[nCut]={0}; + */ + QList cutList1 = hdEE->GetCutList(); + const int nCut1 = cutList1.count(); + unsigned long long tMin1[nCut1] = {0xFFFFFFFFFFFFFFFF}, tMax1[nCut1] = {0}; + unsigned int count1[nCut1]={0}; + + QList cutList2 = hdEtotE->GetCutList(); + const int nCut2 = cutList2.count(); + unsigned long long tMin2[nCut2] = {0xFFFFFFFFFFFFFFFF}, tMax2[nCut2] = {0}; + 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( long i = eventStart ; i <= eventIndex; i ++ ){ + std::vector event = evtbder->events[i]; + //printf("-------------- %ld\n", i); + + if( event.size() == 0 ) return; + + for( int k = 0; k < (int) event.size(); k++ ){ + //event[k].Print(); + if( event[k].ch == 6 ) {ch1 = event[k].energy; t1 = event[k].timestamp;} // Reads channel 6 of the digitizer corresponding to dE + if( event[k].ch == 7 ) {ch4 = event[k].energy; t4 = event[k].timestamp;} // Reads channel 7 of the digitizer corresponding to E + if( event[k].ch == 1 ) {ch7 = event[k].energy; t7 = event[k].timestamp;} + + } + + // 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*0.25*0.25 + ch4); + hdEE->Fill(ch4,ch1); + hdEtotE->Fill(ch1*0.25*0.25 + ch4,ch1); + hdEdT->Fill((t7-t1)*1e9,ch1); + hTWin->Fill((t4-t1)*1e9); + + //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]); + } + } + */ + for(int p = 0; p < cutList1.count(); p++ ){ + if( cutList1[p].isEmpty() ) continue; + if( cutList1[p].containsPoint(QPointF(ch4, ch1), Qt::OddEvenFill) ){ + if( t1 < tMin1[p] ) tMin1[p] = t1; + if( t1 > tMax1[p] ) tMax1[p] = t1; + count1[p] ++; + //printf("hdEE.... %d \n", count1[p]); + } + } + + for(int p = 0; p < cutList2.count(); p++ ){ + if( cutList2[p].isEmpty() ) continue; + if( cutList2[p].containsPoint(QPointF(ch1+ch4,ch1), Qt::OddEvenFill) ){ + if( t1 < tMin2[p] ) tMin2[p] = t1; + if( t1 > tMax2[p] ) tMax2[p] = t1; + count2[p] ++; + //printf("hdEtotE.... %d \n", count2[p]); + } + } + } + + + for(int p = 0; p < cutList2.count(); 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 cutNameList = hPID->GetCutNameList(); + 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)); + influx->WriteData(dataBaseName); + influx->ClearDataPointsBuffer(); + } + */ +} + + +#endif