From 9af7ff721cb17a7a9374238cdc5ed12709821657 Mon Sep 17 00:00:00 2001 From: "Ryan@SOLARIS_testStation" Date: Tue, 13 Aug 2024 12:45:24 -0400 Subject: [PATCH] after SPS test --- Aux/EventBuilder.cpp | 10 +++++-- Aux/SplitPolePlotter.C | 32 ++++++++++---------- Aux/fsuReader.h | 20 ++++++++----- Aux/script.C | 26 ++++++++++------- FSUDAQ.cpp | 4 +-- Scope.cpp | 5 ++-- analyzers/SplitPoleAnalyzer.h | 55 ++++++++++++++++++++--------------- analyzers/SplitPoleHit.h | 36 ++++++++++++++--------- 8 files changed, 109 insertions(+), 79 deletions(-) diff --git a/Aux/EventBuilder.cpp b/Aux/EventBuilder.cpp index 8183b1b..012e6ed 100644 --- a/Aux/EventBuilder.cpp +++ b/Aux/EventBuilder.cpp @@ -101,7 +101,8 @@ int main(int argc, char **argv) { for( int i = 1; i < nFile; i++){ FSUReader * readerB = new FSUReader(inFileName[i].Data(), 1, 1); readerB->ScanNumBlock(0,0); - if( readerB->GetOptimumBatchSize() > batchSize ) batchSize = readerB->GetOptimumBatchSize(); + // if( readerB->GetOptimumBatchSize() > batchSize ) batchSize = readerB->GetOptimumBatchSize(); + batchSize = readerB->GetOptimumBatchSize(); totalHitCount += readerB->GetTotalHitCount(); fileInfo = {inFileName[i].Data(), readerB->GetSN() * 1000 + readerB->GetFileOrder(), readerB->GetTotalHitCount()}; @@ -251,8 +252,8 @@ int main(int argc, char **argv) { do{ - if( (long int)(hitList[ig].at(ID[ig]).timestamp - t0) <= timeWindow ){ - events.push_back(hitList[ig].at(ID[ig])); + if( (long int)(hitList[ig][ID[ig]].timestamp - t0) <= timeWindow ){ + events.push_back(hitList[ig][ID[ig]]); ID[ig] ++; }else{ break; @@ -291,6 +292,9 @@ int main(int argc, char **argv) { multi = events.size() ; if( events.size() >= MAX_MULTI ) { printf("\033[31m event %lld has size = %d > MAX_MULTI = %d \033[0m\n", evID, multi, MAX_MULTI); + for( int po = 0 ; po < 10 ; po ++){ + events[po].Print(); + } multi = MAX_MULTI; } if( debug ) printf("=================================== filling data | %u \n", multi); diff --git a/Aux/SplitPolePlotter.C b/Aux/SplitPolePlotter.C index dfa7bab..92f0aed 100644 --- a/Aux/SplitPolePlotter.C +++ b/Aux/SplitPolePlotter.C @@ -20,10 +20,10 @@ namespace ChMap{ const short ScinR = 0; const short ScinL = 1; - const short dFR = 8; - const short dFL = 9; - const short dBR = 10; - const short dBL = 11; + const short dFR = 9; + const short dFL = 8; + const short dBR = 11; + const short dBL = 10; const short Cathode = 7; const short AnodeF = 13; const short AnodeB = 15; @@ -56,8 +56,8 @@ TH1F * hEx; ULong64_t t1, t2; -#define XMIN -20 -#define XMAX 150 +#define XMIN -200 +#define XMAX 200 //^########################################### @@ -83,7 +83,7 @@ void SplitPolePlotter(TChain *tree){ //*====================================================== histograms - PID = new TH2F("hPID", "PID; Scin_X ; AnodeB", 200, 0, 2000, 100, 0, 4000); + PID = new TH2F("hPID", "PID; Scin_X ; AnodeB", 200, 0, 20000, 100, 0, 40000); coin = new TH2F("hCoin", "Coincident ", 16, 0, 16, 16, 0, 16); hMulti = new TH1F("hMulti", "Multiplicity", 16, 0, 16); @@ -93,16 +93,16 @@ void SplitPolePlotter(TChain *tree){ hXavg = new TH1F("hAvg", "Xavg", 600, XMIN, XMAX); hFocal = new TH2F("hFocal", "Front vs Back ", 200, XMIN, XMAX, 200, XMIN, XMAX); - hXavg_Q = new TH2F("hXavg_Q", "Xavg vs Q ", 200, XMIN, XMAX, 200, 0, 5000); - hXavg_Theta = new TH2F("hXavg_Theta", "Xavg vs Theta ", 200, XMIN, XMAX, 200, 2.5, 3); + hXavg_Q = new TH2F("hXavg_Q", "Xavg vs Q ", 200, XMIN, XMAX, 200, 0, 40000); + hXavg_Theta = new TH2F("hXavg_Theta", "Xavg vs Theta ", 200, XMIN, XMAX, 200, 0.5, 2); haha = new TH2F("haha", "", 400, XMIN, XMAX, 400, -50, 50); - hEx = new TH1F("hEx", "Ex; Ex [MeV]; count/100 keV", 250, -5, 20); + hEx = new TH1F("hEx", "Ex; Ex [MeV]; count/100 keV", 250, -5, 5); hit.SetMassTablePath("../analyzers/mass20.txt"); - hit.CalConstants("36S", "d", "p", 80, 12); // 80MeV, 5 deg - hit.CalZoffset(1.41); // 1.41 T + hit.CalConstants("12C", "d", "p", 16, 20); // 80MeV, 5 deg + hit.CalZoffset(0.751); // 1.41 T t1 = 0; t2 = 0; @@ -152,6 +152,8 @@ void SplitPolePlotter(TChain *tree){ if( t2 < t1 ) printf("entry %lld-%d, timestamp is not in order. %llu, %llu\n", processedEntries, i, t2, t1); if( i == 0 ) t1 = e_t[i]; + // if( e[i] == 65535 ) continue; + if( ch[i] == ChMap::ScinR ) {hit.eSR = e[i]; hit.tSR = e_t[i] + e_f[i]/1000;} if( ch[i] == ChMap::ScinL ) {hit.eSL = e[i]; hit.tSL = e_t[i] + e_f[i]/1000;} if( ch[i] == ChMap::dFR ) {hit.eFR = e[i]; hit.tFR = e_t[i] + e_f[i]/1000;} @@ -168,7 +170,7 @@ void SplitPolePlotter(TChain *tree){ } unsigned int dQ = hit.eAB; // delta Q - unsigned int Qt = hit.eSR; // total Q + unsigned int Qt = hit.eSL; // total Q if( Qt > 0 && dQ > 0 ) { PID->Fill(Qt, dQ); @@ -178,9 +180,9 @@ void SplitPolePlotter(TChain *tree){ // if( hit.eCath == 0 ) return kTRUE; // if( hit.eCath > 13000 ) return kTRUE; - hit.CalData(4); + hit.CalData(2); - if( !TMath::IsNaN(hit.x1) || !TMath::IsNaN(hit.x2) ) { + if( (!TMath::IsNaN(hit.x1) || !TMath::IsNaN(hit.x2)) && 1000 < dQ && dQ < 9000) { hFocal->Fill(hit.x1, hit.x2); hF->Fill(hit.x1); hB->Fill(hit.x2); diff --git a/Aux/fsuReader.h b/Aux/fsuReader.h index fcc8450..a264290 100644 --- a/Aux/fsuReader.h +++ b/Aux/fsuReader.h @@ -3,7 +3,7 @@ #include #include -#define DEFAULT_HALFBUFFERSIZE 500000 +#define DEFAULT_HALFBUFFERSIZE 5000000 class FSUReader{ @@ -262,14 +262,16 @@ inline void FSUReader::OpenFile(std::string fileName, uInt dataSize, int verbose std::string token; while (std::getline(iss, token, '_')) { tokens.push_back(token); } - sn = atoi(tokens[2].c_str()); - tick2ns = atoi(tokens[4].c_str()); - order = atoi(tokens[5].c_str()); + short token_size = tokens.size(); + // for( short i = 0; i < token_size; i ++ ) printf("%d | %s\n", i, tokens[i].c_str()); + sn = atoi(tokens[token_size-4].c_str()); + tick2ns = atoi(tokens[token_size-2].c_str()); + order = atoi(tokens[token_size-1].c_str()); DPPType = 0; - if( fileName.find("PHA") != std::string::npos ) DPPType = DPPTypeCode::DPP_PHA_CODE; - if( fileName.find("PSD") != std::string::npos ) DPPType = DPPTypeCode::DPP_PSD_CODE; - if( fileName.find("QDC") != std::string::npos ) DPPType = DPPTypeCode::DPP_QDC_CODE; + if( fileName.find("PHA") != std::string::npos ) { printf("Using PHA decode.\n"); DPPType = DPPTypeCode::DPP_PHA_CODE;} + if( fileName.find("PSD") != std::string::npos ) { printf("Using PSD decode.\n"); DPPType = DPPTypeCode::DPP_PSD_CODE;} + if( fileName.find("QDC") != std::string::npos ) { printf("Using QDC decode.\n"); DPPType = DPPTypeCode::DPP_QDC_CODE;} if( DPPType == 0 ){ fclose(inFile); inFile = nullptr; @@ -365,7 +367,7 @@ inline int FSUReader::ReadNextBlock(bool traceON, int verbose, uShort saveData){ for( int i = start; i < start + data->NumEventsDecoded[ch]; i++ ){ int k = i % data->GetDataSize(); - + temp.sn = sn; temp.ch = ch; temp.energy = data->GetEnergy(ch, k); @@ -381,6 +383,8 @@ inline int FSUReader::ReadNextBlock(bool traceON, int verbose, uShort saveData){ if( temp.trace.size() > 0 ) temp.trace.clear(); } + // temp.Print(); + hit.push_back(temp); } } diff --git a/Aux/script.C b/Aux/script.C index b2572ce..6a0c556 100644 --- a/Aux/script.C +++ b/Aux/script.C @@ -1,27 +1,31 @@ -// #include "fsuReader.h" +#include "fsuReader.h" // #include "../MultiBuilder.cpp" #include "SplitPolePlotter.C" void script(){ - TChain * chain = new TChain("tree"); + TChain * chain = new TChain("tree"); - // chain->Add("data/temp_002_336_1000.root"); - chain->Add("run123_100000.root"); + chain->Add("data/12C_dp_009_3000.root"); +// chain->Add("run13._3000.root"); - SplitPolePlotter(chain); + SplitPolePlotter(chain); //^===================================================== - // FSUReader * reader = new FSUReader("~/ExpData/testing/.fsu", 16); - // Data * data = reader->GetData(); - // data->tick2ns = 4; + // FSUReader * reader = new FSUReader("data/12C_dp_002_19555_PSD_4_000.fsu", 10000, 2); - // reader->ScanNumBlock(); + // reader->ScanNumBlock(1, 0); - // // for( int i = 0; i < 500 ; i++ ) reader->ReadNextBlock(0, 0); + // reader->ReadNextBlock(0, 9); + + // for( int i = 0; i < 10 ; i++ ) reader->ReadNextBlock(0, 9); + + // std::vector hitList = reader->ReadBatch(10, true); + + // for ( int i = 0; i < 10 ; i ++) hitList[i].Print(); // // int ch = 5; // // std::vector tList; @@ -99,4 +103,4 @@ void script(){ // delete mb; // delete reader; -} \ No newline at end of file +} diff --git a/FSUDAQ.cpp b/FSUDAQ.cpp index b118ba7..0f34b1b 100644 --- a/FSUDAQ.cpp +++ b/FSUDAQ.cpp @@ -127,7 +127,7 @@ FSUDAQ::FSUDAQ(QWidget *parent) : QMainWindow(parent){ layout->addWidget(leDatabaseName, rowID, 4); chkInflux = new QCheckBox("Enable", this); - chkInflux->setChecked(false); + chkInflux->setChecked(true); layout->addWidget(chkInflux, rowID, 5); rowID ++; @@ -148,7 +148,7 @@ FSUDAQ::FSUDAQ(QWidget *parent) : QMainWindow(parent){ layout->addWidget(leElogName, rowID, 4); chkElog = new QCheckBox("Enable", this); - chkElog->setChecked(false); + chkElog->setChecked(true); layout->addWidget(chkElog, rowID, 5); connect(bnLock, &QPushButton::clicked, this, &FSUDAQ::SetAndLockInfluxElog); diff --git a/Scope.cpp b/Scope.cpp index c25f1a9..d151237 100644 --- a/Scope.cpp +++ b/Scope.cpp @@ -746,7 +746,7 @@ void Scope::SetUpSpinBox(RSpinBox * &sb, QString str, int row, int col, const Re value = uint16_t((1.0 - sb->value()/100.) * 0xFFFF); } - if( para == DPP::PHA::TriggerThreshold ){ + if( para == DPP::PHA::TriggerThreshold || para == DPP::PSD::TriggerThreshold){ value = sb->value(); } @@ -755,7 +755,7 @@ void Scope::SetUpSpinBox(RSpinBox * &sb, QString str, int row, int col, const Re if( digi[ID]->GetDPPType() == DPPTypeCode::DPP_QDC_CODE ){ int grp = ch/8; // convert ch to grp digiMTX[ID].lock(); - digi[ID]->WriteRegister(para, value, grp); + digi[ID]->WriteRegister(para, value, grp); digiMTX[ID].unlock(); }else{ digiMTX[ID].lock(); @@ -1264,6 +1264,7 @@ void Scope::UpdatePanel_PSD(){ UpdateSpinBox(sbShortGate, DPP::PSD::ShortGateWidth); UpdateSpinBox(sbLongGate, DPP::PSD::LongGateWidth); UpdateSpinBox(sbGateOffset, DPP::PSD::GateOffset); + UpdateSpinBox(sbThreshold, DPP::PSD::TriggerThreshold); uint32_t BdCfg = digi[ID]->GetSettingFromMemory(DPP::BoardConfiguration, ch); diff --git a/analyzers/SplitPoleAnalyzer.h b/analyzers/SplitPoleAnalyzer.h index d98a3aa..f1725c5 100644 --- a/analyzers/SplitPoleAnalyzer.h +++ b/analyzers/SplitPoleAnalyzer.h @@ -31,7 +31,7 @@ public: 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(1000); + evtbder->SetTimeWindow(3000); //========== use the influx from the Analyzer influx = new InfluxDB("https://fsunuc.physics.fsu.edu/influx/"); @@ -41,7 +41,7 @@ public: leTarget->setText("12C"); leBeam->setText("d"); leRecoil->setText("p"); - sbBfield->setValue(0.76); + sbBfield->setValue(0.75); sbAngle->setValue(20); sbEnergy->setValue(16); @@ -222,7 +222,7 @@ inline void SplitPole::SetUpCanvas(){ sbEventWin->setSingleStep(100); sbEventWin->setMaximum(1000000); boxLayout->addWidget(sbEventWin, 4, 1); - sbEventWin->setValue(1000); + sbEventWin->setValue(3000); connect(sbEventWin, &RSpinBox::returnPressed, this, [=](){ evtbder->SetTimeWindow(sbEventWin->value()); }); @@ -323,20 +323,20 @@ inline void SplitPole::SetUpCanvas(){ } //============ histograms - hMulti = new Histogram1D("Multiplicity", "", 10, 0, 10, this); + hMulti = new Histogram1D("Multiplicity", "", 16, 0, 16, this); layout->addWidget(hMulti, 0, 1); // the "this" make the histogram a child of the SplitPole class. When SplitPole destory, all childs destory as well. - hPID = new Histogram2D("Split Pole PID", "Scin-L", "Anode-Font", 100, 0, 5000, 100, 0, 5000, this); + hPID = new Histogram2D("Split Pole PID", "Scin-L", "Anode-Back", 100, 0, 20000, 100, 0, 40000, this); //layout is inheriatge from Analyzer layout->addWidget(hPID, 1, 0, 2, 1); - h1 = new Histogram1D("Spectrum", "x", 300, 30, 70, this); + h1 = new Histogram1D("Spectrum", "x1", 300, -200, 200, this); h1->SetColor(Qt::darkGreen); //h1->AddDataList("Test", Qt::red); // add another histogram in h1, Max Data List is 10 layout->addWidget(h1, 1, 1); - h1g = new Histogram1D("Spectrum (PID gated)", "Ex", 300, -2, 10, this); + h1g = new Histogram1D("Spectrum (PID gated)", "x1", 300, -200, 200, this); layout->addWidget(h1g, 2, 1); layout->setColumnStretch(0, 1); @@ -378,28 +378,32 @@ inline void SplitPole::UpdateHistograms(){ for( int k = 0; k < (int) event.size(); k++ ){ //event[k].Print(); - if( event[k].ch == SPS::ChMap::ScinR ) {hit.eSR = event[k].energy; hit.tSR = event[k].timestamp;} - if( event[k].ch == SPS::ChMap::ScinL ) {hit.eSL = event[k].energy; hit.tSL = event[k].timestamp;} - if( event[k].ch == SPS::ChMap::dFR ) {hit.eFR = event[k].energy; hit.tFR = event[k].timestamp;} - if( event[k].ch == SPS::ChMap::dFL ) {hit.eFL = event[k].energy; hit.tFL = event[k].timestamp;} - if( event[k].ch == SPS::ChMap::dBR ) {hit.eBL = event[k].energy; hit.tBL = event[k].timestamp;} - if( event[k].ch == SPS::ChMap::dBL ) {hit.eBL = event[k].energy; hit.tBL = event[k].timestamp;} - if( event[k].ch == SPS::ChMap::Cathode ) {hit.eCath = event[k].energy; hit.tCath = event[k].timestamp;} - if( event[k].ch == SPS::ChMap::AnodeF ) {hit.eAF = event[k].energy; hit.tAF = event[k].timestamp;} - if( event[k].ch == SPS::ChMap::AnodeB ) {hit.eAB = event[k].energy; hit.tAB = event[k].timestamp;} + if( event[k].ch == SPS::ChMap::ScinR ) {hit.eSR = event[k].energy; hit.tSR = event[k].timestamp + event[k].fineTime/1000.;} + if( event[k].ch == SPS::ChMap::ScinL ) {hit.eSL = event[k].energy; hit.tSL = event[k].timestamp + event[k].fineTime/1000.;} + if( event[k].ch == SPS::ChMap::dFR ) {hit.eFR = event[k].energy; hit.tFR = event[k].timestamp + event[k].fineTime/1000.;} + if( event[k].ch == SPS::ChMap::dFL ) {hit.eFL = event[k].energy; hit.tFL = event[k].timestamp + event[k].fineTime/1000.;} + if( event[k].ch == SPS::ChMap::dBR ) {hit.eBL = event[k].energy; hit.tBL = event[k].timestamp + event[k].fineTime/1000.;} + if( event[k].ch == SPS::ChMap::dBL ) {hit.eBL = event[k].energy; hit.tBL = event[k].timestamp + event[k].fineTime/1000.;} + if( event[k].ch == SPS::ChMap::Cathode ) {hit.eCath = event[k].energy; hit.tCath = event[k].timestamp + event[k].fineTime/1000.;} + if( event[k].ch == SPS::ChMap::AnodeF ) {hit.eAF = event[k].energy; hit.tAF = event[k].timestamp + event[k].fineTime/1000.;} + if( event[k].ch == SPS::ChMap::AnodeB ) {hit.eAB = event[k].energy; hit.tAB = event[k].timestamp + event[k].fineTime/1000.;} } hit.CalData(); double pidX = hit.eSL; unsigned long long tPidX = hit.tSL; - double pidY = hit.eAF; + double pidY = hit.eAB; - hPID->Fill(pidX, pidY); // x, y - - h1->Fill(hit.xAvg); + if( pidX > 0 && pidY > 0 ){ + hPID->Fill(pidX, pidY); // x, y + } + if( !std::isnan(hit.x1) ) { + h1->Fill(hit.x1); + } //h1->Fill(hit.eSR, 1); + //check events inside any Graphical cut and extract the rate, using tSR only for(int p = 0; p < cutList.count(); p++ ){ if( cutList[p].isEmpty() ) continue; @@ -408,10 +412,13 @@ inline void SplitPole::UpdateHistograms(){ if( tPidX > tMax[p] ) tMax[p] = tPidX; count[p] ++; //printf(".... %d \n", count[p]); - if( p == 0 ) { - double xAvg = hit.xAvg * 10; - double xAvgC = xAvg * sbRhoScale->value() + sbRhoOffset->value(); - h1g->Fill(hit.Rho2Ex(xAvgC/1000.)); + // if( p == 0 ) { + // double xAvg = hit.xAvg * 10; + // double xAvgC = xAvg * sbRhoScale->value() + sbRhoOffset->value(); + // h1g->Fill(hit.Rho2Ex(xAvgC/1000.)); + // } + if( p == 0 ){ + h1g->Fill(hit.x1); } } } diff --git a/analyzers/SplitPoleHit.h b/analyzers/SplitPoleHit.h index 90f6d93..23f048a 100644 --- a/analyzers/SplitPoleHit.h +++ b/analyzers/SplitPoleHit.h @@ -39,10 +39,10 @@ namespace SPS{ const short ScinL = 1; const short dFR = 9; const short dFL = 8; - const short dBR = 10; - const short dBL = 11; + const short dBR = 11; + const short dBL = 10; const short Cathode = 7; - const short AnodeF = 12; + const short AnodeF = 13; const short AnodeB = 15; }; @@ -64,19 +64,19 @@ public: ClearData(); } - unsigned int eSR; unsigned long long tSR; - unsigned int eSL; unsigned long long tSL; - unsigned int eFR; unsigned long long tFR; - unsigned int eFL; unsigned long long tFL; - unsigned int eBR; unsigned long long tBR; - unsigned int eBL; unsigned long long tBL; + unsigned int eSR; unsigned long long tSR; + unsigned int eSL; unsigned long long tSL; + unsigned int eFR; unsigned long long tFR; + unsigned int eFL; unsigned long long tFL; + unsigned int eBR; unsigned long long tBR; + unsigned int eBL; unsigned long long tBL; unsigned int eCath; unsigned long long tCath; - unsigned int eAF; unsigned long long tAF; - unsigned int eAB; unsigned long long tAB; + unsigned int eAF; unsigned long long tAF; + unsigned int eAB; unsigned long long tAB; float eSAvg; float x1, x2, theta; - float xAvg; + double xAvg; double GetQ0() const {return Q0;} double GetRho0() const {return rho0;} @@ -200,8 +200,16 @@ public: if( eSR > 0 && eSL == 0 ) eSAvg = eSR; if( eSR == 0 && eSL > 0 ) eSAvg = eSL; - if( tFR > 0 && tFL > 0 ) x1 = (tFL - tFR)/scale/2.1; - if( tBR > 0 && tBL > 0 ) x2 = (tBL - tBR)/scale/1.98; + if( tFR > 0 && tFL > 0 ) { + if( tFL > tFR) x1 = (tFL - tFR)/scale/2.1; + if( tFL < tFR) x1 = (tFR - tFL)/scale/-2.1; + } + if( tBR > 0 && tBL > 0 ) { + if( tBL > tBR) x2 = (tBL - tBR)/scale/1.98; + if( tBR > tBL) x2 = (tBR - tBL)/scale/-1.98; + } + + // printf("x1: %f, x2 : %f \n", x1, x2); if( !std::isnan(x1) && !std::isnan(x2)) {