add Real time and live time in scalar

This commit is contained in:
Ryan Tang 2022-04-01 18:54:59 -04:00
parent 436c7b7d5a
commit ca63063e62
6 changed files with 54 additions and 24 deletions

View File

@ -398,6 +398,12 @@ void Pixie16::StopRun(){
}
void Pixie16::CheckExternalFIFOWords(unsigned short modID){
if( Pixie16CheckRunStatus(modID) == 1){
retval = Pixie16CheckExternalFIFOStatus (&nFIFOWords, modID);
if( CheckError("Pixie16CheckExternalFIFOStatus") < 0 ) return;
}
}
void Pixie16::ReadData(unsigned short modID){
@ -418,9 +424,9 @@ void Pixie16::ReadData(unsigned short modID){
}
}
bool Pixie16::ProcessSingleData(){
int Pixie16::ProcessSingleData(){
bool breakProcessLoopFlag = false;
int breakProcessLoopFlag = 0;
if( nextWord < nFIFOWords ){
data->ch = ExtFIFO_Data[nextWord] & 0xF ;
@ -455,8 +461,8 @@ bool Pixie16::ProcessSingleData(){
nextWord += data->eventLength ;
if( nextWord == nFIFOWords ) {nextWord = 0; breakProcessLoopFlag = true;}
if( nextWord > nFIFOWords ) {nextWord = nextWord - nFIFOWords; breakProcessLoopFlag = true;}
if( nextWord == nFIFOWords ) {nextWord = 0; breakProcessLoopFlag = 1;}
if( nextWord > nFIFOWords ) {nextWord = nextWord - nFIFOWords; breakProcessLoopFlag = 2;}
}

View File

@ -194,14 +194,14 @@ public:
double GetRealTime(unsigned short modID);
void PrintStatistics(unsigned short modID);
void CheckExternalFIFOWords(unsigned short modID);
void ReadData(unsigned short modID);
unsigned int GetTotalNumWords() {return totNumFIFOWords;}
unsigned int GetnFIFOWords() {return nFIFOWords;}
unsigned int GetNextWord() {return nextWord;}
DataBlock * GetData() {return data;}
bool ProcessSingleData();
int ProcessSingleData();
void PrintExtFIFOWords() {
unsigned int nWords = (ExtFIFO_Data[nextWord] >> 17) & 0x3FFF;

View File

@ -11,7 +11,7 @@
#include <TGraph.h>
#include <TGTextEditor.h>
#include <TAxis.h>
#include <TBenchmark.h>
#include <unistd.h>
#include <ctime>
@ -275,6 +275,7 @@ void MainWindow::GetADCTrace() {
gTrace->SetPoint(i, i*dt, haha[i]);
}
gTrace->GetXaxis()->SetTitle("time [us]");
gTrace->GetXaxis()->SetRangeUser(0, pixie->GetADCTraceLength()*dt);
gTrace->Draw("APL");
TCanvas *fCanvas = fEcanvas->GetCanvas();
@ -325,10 +326,12 @@ void MainWindow::Scope(){
DataBlock * data = pixie->GetData();
LogMsg("[Scope] Take data for 200 msec.");
int runDuration = 200; ///msec
LogMsg(Form("[Scope] Take data for %d msec.", runDuration));
pixie->StartRun(1);
usleep(200*1000);
usleep(runDuration*1000);
pixie->ReadData(0);
pixie->StopRun();
@ -337,9 +340,7 @@ void MainWindow::Scope(){
///printf(" next word : %u\n", pixie->GetNextWord());
///printf("number of word received : %u\n", pixie->GetnFIFOWords());
//TODO add statistics, like trigger rate
while(!pixie->ProcessSingleData()){
while( pixie->ProcessSingleData() <= 1 ){ /// full set of dataBlack
if( pixie->GetNextWord() >= pixie->GetnFIFOWords() ) break;
if( data->slot < 2 ) break;
@ -353,6 +354,7 @@ void MainWindow::Scope(){
gTrace->SetPoint(i, i*dt, (data->trace)[i]);
}
gTrace->GetXaxis()->SetTitle("time [us]");
gTrace->GetXaxis()->SetRangeUser(0, data->trace_length * dt);
gTrace->SetTitle(Form("mod-%d, ch-%02d\n", modID, ch));
gTrace->Draw("APL");
@ -402,11 +404,9 @@ void MainWindow::StopRun(){
pixie->SaveData();
LogMsg("Stop Run");
LogMsg(Form("File Size : %.2f MB", pixie->GetFileSize()/1024./1024.));
pixie->CloseFile();
pixie->PrintStatistics(0);
bStartRun->SetEnabled(true);
bStopRun->SetEnabled(false);

View File

@ -8,6 +8,7 @@
#include <TGTextEdit.h>
#include <TThread.h>
#include <TH1F.h>
#include <TBenchmark.h>
#include "Pixie16Class.h"
#include "settingsSummary.h"
@ -48,7 +49,7 @@ private:
TThread * fillHistThread;
static TH1F * h1[13][16];
public:
MainWindow(const TGWindow *p, UInt_t w, UInt_t h);

View File

@ -16,6 +16,9 @@ Pixie16 * ScalarPanel::pixie = NULL;
bool ScalarPanel::updateFlag = true;
int ScalarPanel::nMod = 0;
TGTextEntry * ScalarPanel::teRate[][MAXCH] = {NULL};
TGTextEntry * ScalarPanel::teRealTime[MAXMOD] = {NULL};
int updateTime = 500; // msec
ScalarPanel::ScalarPanel(const TGWindow *p, UInt_t w, UInt_t h, Pixie16 * pixie){
@ -24,7 +27,7 @@ ScalarPanel::ScalarPanel(const TGWindow *p, UInt_t w, UInt_t h, Pixie16 * pixie)
nMod = pixie->GetNumModule();
fMain = new TGMainFrame(p,w,h);
fMain->SetWindowName("Scalar Panel");
fMain->SetWindowName("Pixie16 Scalar Panel");
fMain->Connect("CloseWindow()", "ScalarPanel", this, "CloseWindow()");
///Module choose
@ -36,6 +39,10 @@ ScalarPanel::ScalarPanel(const TGWindow *p, UInt_t w, UInt_t h, Pixie16 * pixie)
///------ Channel labels
TGVerticalFrame * hChannelLabels = new TGVerticalFrame(hframe);
hframe->AddFrame(hChannelLabels, new TGLayoutHints(kLHintsCenterX | kLHintsCenterY, 2,2,2,2));
TGLabel * labelRealTime = new TGLabel(hChannelLabels, "Read Time");
labelRealTime->SetWidth(width);
labelRealTime->Resize(width, 50);
hChannelLabels->AddFrame(labelRealTime, new TGLayoutHints(kLHintsCenterX | kLHintsCenterY, 2,2,5,5));
TGLabel * labelCh[MAXCH];
for( int ch = 0; ch < MAXCH; ch ++){
@ -45,22 +52,28 @@ ScalarPanel::ScalarPanel(const TGWindow *p, UInt_t w, UInt_t h, Pixie16 * pixie)
hChannelLabels->AddFrame(labelCh[ch], new TGLayoutHints(kLHintsCenterX | kLHintsCenterY, 2,2,5,5));
}
///------- Rate
TGVerticalFrame * hScalarMod[nMod];
for ( int mod = 0 ; mod < nMod ; mod ++){
hScalarMod[mod] = new TGVerticalFrame(hframe);
hframe->AddFrame(hScalarMod[mod], new TGLayoutHints(kLHintsCenterX | kLHintsCenterY, 2,2,2,2));
teRealTime[mod] = new TGTextEntry(hScalarMod[mod], new TGTextBuffer(10));
teRealTime[mod]->SetEnabled(false);
teRealTime[mod]->SetAlignment(kTextRight);
hScalarMod[mod]->AddFrame(teRealTime[mod], new TGLayoutHints(kLHintsCenterX | kLHintsCenterY, 2,2,2,2));
for( int ch = 0 ; ch < MAXCH ; ch ++){
teRate[mod][ch] = new TGTextEntry(hScalarMod[mod], new TGTextBuffer(10));
teRate[mod][ch]->SetEnabled(false);
teRate[mod][ch]->SetAlignment(kTextRight);
hScalarMod[mod]->AddFrame(teRate[mod][ch], new TGLayoutHints(kLHintsCenterX | kLHintsCenterY, 2,2,2,2));
}
}
TGLabel * labelFootNote = new TGLabel(fMain, Form("Update every %d msec.", updateTime));
fMain->AddFrame(labelFootNote, new TGLayoutHints(kLHintsExpandX | kLHintsCenterY, 2,2,5,5));
fMain->MapSubwindows();
fMain->Resize(fMain->GetDefaultSize());
@ -82,6 +95,8 @@ ScalarPanel::~ScalarPanel(){
for( int j = 0; j < MAXCH; j++ ){
delete teRate[i][j];
}
delete teRealTime[i];
}
/// fMain must be delete last;
@ -100,17 +115,22 @@ void * ScalarPanel::UpdateScalar(void * ptr){
for( int mod = 0; mod < nMod; mod++){
Pixie16ReadStatisticsFromModule (statistics, mod);
double realTime = Pixie16ComputeRealTime (statistics, mod);
teRealTime[mod]->SetText(Form("%.2f", realTime));
for( int ch = 0; ch < MAXCH ; ch ++){
double ICR = Pixie16ComputeInputCountRate (statistics, mod, ch);
double OCR = Pixie16ComputeOutputCountRate (statistics, mod, ch);
double liveTime = Pixie16ComputeLiveTime (statistics, mod, ch);
teRate[mod][ch]->SetText(Form("%.2f[%.2f] %.2f", ICR, OCR, liveTime));
teRate[mod][ch]->SetText(Form("%.2f[%.2f]", ICR, OCR));
}
gSystem->Sleep(500); ///0.5 sec
gSystem->Sleep(updateTime);
}

View File

@ -24,6 +24,9 @@ private:
static bool updateFlag;
static TGTextEntry * teRate[MAXMOD][MAXCH];
static TGTextEntry * teRealTime[MAXMOD];
TThread * thread;
public:
@ -36,7 +39,7 @@ public:
bool isOpened;
static TGTextEntry * teRate[MAXMOD][MAXCH];
};