various fixes and change for testClover

This commit is contained in:
tandem 2022-11-07 17:42:11 -05:00
parent 0e614db437
commit 34a90be3d3
12 changed files with 274 additions and 58 deletions

2
.gitignore vendored
View File

@ -12,3 +12,5 @@ read-set
*.cxx *.cxx
*.pcm *.pcm
pixieDAQ pixieDAQ
data

View File

@ -29,7 +29,7 @@ APIBASE = /usr/opt/xia/PixieSDK/lib/
LIBS = $(APIBASE)libPixie16Api.so $(APIBASE)libPixieSDK.a $(PLXBASE)PlxApi.a LIBS = $(APIBASE)libPixie16Api.so $(APIBASE)libPixieSDK.a $(PLXBASE)PlxApi.a
OBJS = pixieDAQ.o Pixie16Class.o settingsSummary.o scalarPanel.o moduleSetting.o channelSetting.o OBJS = startStopDialog.o pixieDAQ.o Pixie16Class.o settingsSummary.o scalarPanel.o moduleSetting.o channelSetting.o
all: testing/test testing/example pixieDAQ all: testing/test testing/example pixieDAQ
@ -68,6 +68,10 @@ channelSetting.o : channelSetting.cpp channelSetting.h global_macro.h
@echo "--------- creating channelSetting.o" @echo "--------- creating channelSetting.o"
$(CC) $(CFLAGS) $(PIXIE_LIB_PATH) channelSetting.cpp $(ROOT_FLAG) $(CC) $(CFLAGS) $(PIXIE_LIB_PATH) channelSetting.cpp $(ROOT_FLAG)
startStopDialog.o : startStopDialog.cpp startStopDialog.h
@echo "--------- creating startStopDialog.o"
$(CC) $(CFLAGS) $(PIXIE_LIB_PATH) startStopDialog.cpp $(ROOT_FLAG)
#-------------------------- #--------------------------

View File

@ -502,7 +502,7 @@ int Pixie16::ProcessSingleData(short ch){
if( nextWord == nFIFOWords ) {nextWord = 0; breakProcessLoopFlag = 1;} if( nextWord == nFIFOWords ) {nextWord = 0; breakProcessLoopFlag = 1;}
if( nextWord > nFIFOWords ) {nextWord = nextWord - nFIFOWords; breakProcessLoopFlag = 2;} if( nextWord > nFIFOWords ) {nextWord = nextWord - nFIFOWords; breakProcessLoopFlag = 2;}
if( data->ch == ch ) breakProcessLoopFlag = 1; if( data->ch == ch ) {nextWord = 0; breakProcessLoopFlag = 3;}
} }
return breakProcessLoopFlag ; return breakProcessLoopFlag ;

79
elogEntry.sh Executable file
View File

@ -0,0 +1,79 @@
#!/bin/bash -l
ExpName="testClover"
ElogIP="elog.physics.fsu.edu"
DataPath="/home/tandem/XIAEventBuilder/data"
elogIDFile="/home/tandem/XIAEventBuilder/data/elogID.txt"
echo "======================================= making elog Entry"
elogIDFile=${DataPath}"/elogID.txt"
if [ -f ${elogIDFile} ]; then
source ${elogIDFile}
else
touch ${elogIDFile}
fi
isStart=$1
lastRunID=$2
Comment=$3
elogFileName=${DataPath}"/elogText.txt"
#Get file size
RUN=${lastRunID}
runLen=${#lastRunID}
if [ ${runLen} -eq 1 ]; then
RUN="00"${RUN}
elif [ ${runLen} -eq 2 ]; then
RUN="0"${RUN}
fi;
if [ ${isStart} == "1" ]; then
#make text file for elog text
echo "************************************************************************** <br />" > ${elogFileName}
echo "Run-${RUN} start at $(date) <br />" >> ${elogFileName}
echo "Start Run Comment : "${Comment}" <br />">> ${elogFileName}
echo "-------------------------------------------------------------------------- <br />" >> ${elogFileName}
#push to elog
IDStr=$(elog -h ${ElogIP} -l ${ExpName} -u GeneralFox fsuphysics888 -a Author="GeneralFox" -a Category="Run" -a RunNo=${lastRunID} -a Subject="Run Log" -n 2 -m ${elogFileName})
echo ${IDStr}
IDStr=$(echo ${IDStr} | tail -1 | awk '{print $4}')
if [ ${IDStr:0:3} == "ID=" ] && [[ ${IDStr:3} =~ ${re} ]]; then
elogIDStr="Elog"${IDStr}
echo "Elog is succefully pushed at ${elogIDStr}"
echo ${elogIDStr} >> ${elogIDFile}
fi
else
elogFileName2=${DataPath}"/elogText2.txt"
#download elog entry
echo "====== getting elog entry"
elog -h ${ElogIP} -l elog/${ExpName} -u GeneralFox fsuphysics888 -w ${ElogID} > ${elogFileName2}
cutLineNum=$(grep -n "==============" ${elogFileName2} | cut -d: -f1)
#check encoding
encoding=$(grep "Encoding" ${elogFileName2} | awk '{print $2}')
if [ $encoding = "plain" ]; then encodingID=1 ; fi
if [ $encoding = "HTML" ]; then encodingID=2 ; fi
if [ $encoding = "ELcode" ]; then encodingID=0 ; fi
#remove all header
sed -i "1,${cutLineNum}d" ${elogFileName2}
echo "Run Stop at $(date) <br />" >> ${elogFileName2}
echo "End Run Comment : "${Comment}" <br />" >> ${elogFileName2}
totalFileSize=$(du -hc ${DataPath}"/"testRun_${RUN}* | tail -1| awk {'print $1'})
echo "File Size : "${totalFileSize}" <br />">> ${elogFileName2}
echo "************************************************************************** <br />" >> ${elogFileName2}
cat ${elogFileName2}
elog -h ${ElogIP} -p 8080 -l ${ExpName} -u GeneralFox fsuphysics888 -e ${ElogID} -n ${encodingID} -m ${elogFileName2}
fi

View File

@ -159,7 +159,7 @@ MainWindow::MainWindow(const TGWindow *p,UInt_t w,UInt_t h) {
tePath = new TGTextEntry(hframe2, new TGTextBuffer(30)); tePath = new TGTextEntry(hframe2, new TGTextBuffer(30));
tePath->SetWidth(50); tePath->SetWidth(50);
tePath->SetText("testRun"); tePath->SetText("data/testRun");
hframe2->AddFrame(tePath, uniLayoutHints); hframe2->AddFrame(tePath, uniLayoutHints);
runIDEntry = new TGNumberEntry(hframe2, 0, 0, 0, TGNumberFormat::kNESInteger, TGNumberFormat::kNEANonNegative); runIDEntry = new TGNumberEntry(hframe2, 0, 0, 0, TGNumberFormat::kNESInteger, TGNumberFormat::kNEANonNegative);
@ -258,6 +258,7 @@ MainWindow::~MainWindow() {
delete moduleSetting; delete moduleSetting;
delete channelSetting; delete channelSetting;
delete scalarPanel; delete scalarPanel;
delete startStopDialog;
delete saveDataThread; delete saveDataThread;
delete fillHistThread; delete fillHistThread;
@ -432,7 +433,7 @@ void MainWindow::Scope(){
///printf(" next word : %u\n", pixie->GetNextWord()); ///printf(" next word : %u\n", pixie->GetNextWord());
///printf("number of word received : %u\n", pixie->GetnFIFOWords()); ///printf("number of word received : %u\n", pixie->GetnFIFOWords());
while( pixie->ProcessSingleData() < 1 ){ /// full set of dataBlack while( pixie->ProcessSingleData() <= 1 ){ /// full set of dataBlack
if( pixie->GetNextWord() >= pixie->GetnFIFOWords() ) break; if( pixie->GetNextWord() >= pixie->GetnFIFOWords() ) break;
if( data->slot < 2 ) break; if( data->slot < 2 ) break;
@ -554,54 +555,74 @@ void MainWindow::GoodBye(){
void MainWindow::StartRun(){ void MainWindow::StartRun(){
TString saveFileName = Form("%s_%03lu.evt", tePath->GetText(), runIDEntry->GetIntNumber()); startStopDialog = new StartStopDialog(gClient->GetRoot(), fMain, 400, 200, true);
pixie->OpenFile(saveFileName.Data(), false); if( StartStopDialog::isOK){
LogMsg(Form("Start Run. Save data at %s.\n", saveFileName.Data())); TString saveFileName = Form("%s_%03lu.evt", tePath->GetText(), runIDEntry->GetIntNumber());
///clear histogram; pixie->OpenFile(saveFileName.Data(), false);
isEnergyHistFilled = false;
for( unsigned int iMod = 0 ; iMod < pixie->GetNumModule(); iMod++){ LogMsg(Form("Start Run. Save data at %s.\n", saveFileName.Data()));
for( int j = 0; j < MAXCH ; j++){
hEnergy[iMod][j]->Reset(); ///clear histogram;
isEnergyHistFilled = false;
for( unsigned int iMod = 0 ; iMod < pixie->GetNumModule(); iMod++){
for( int j = 0; j < MAXCH ; j++){
hEnergy[iMod][j]->Reset();
}
} }
TString cmd = Form("/home/tandem/PixieDAQ/elogEntry.sh %d %d \"%s\"", 1, (int) runIDEntry->GetIntNumber(), StartStopDialog::Comment.Data() );
int temp = system(cmd.Data());
pixie->StartRun(1);
if( pixie->IsRunning() ) saveDataThread->Run(); /// call SaveData()
//if( pixie->IsRunning() ) fillHistThread->Run(); /// call SaveData()
bStartRun->SetEnabled(false);
bStopRun->SetEnabled(true);
bFitTrace->SetEnabled(false);
} }
pixie->StartRun(1);
if( pixie->IsRunning() ) saveDataThread->Run(); /// call SaveData()
//if( pixie->IsRunning() ) fillHistThread->Run(); /// call SaveData()
bStartRun->SetEnabled(false);
bStopRun->SetEnabled(true);
} }
void MainWindow::StopRun(){ void MainWindow::StopRun(){
pixie->StopRun(); startStopDialog = new StartStopDialog(gClient->GetRoot(), fMain, 400, 200, true);
pixie->ReadData(0);
pixie->SaveData();
LogMsg("Stop Run"); if( StartStopDialog::isOK){
LogMsg(Form("File Size : %.2f MB", pixie->GetFileSize()/1024./1024.));
pixie->CloseFile();
pixie->PrintStatistics(0); pixie->StopRun();
bStartRun->SetEnabled(true); saveDataThread->Join();
bStopRun->SetEnabled(false); usleep(200*1000);
pixie->ReadData(0);
pixie->SaveData();
runIDEntry->SetIntNumber(runIDEntry->GetIntNumber()+1); LogMsg("Stop Run");
LogMsg(Form("File Size : %.2f MB", pixie->GetFileSize()/1024./1024.));
pixie->CloseFile();
pixie->PrintStatistics(0);
bStartRun->SetEnabled(true);
bStopRun->SetEnabled(false);
bFitTrace->SetEnabled(true);
TString cmd = Form("/home/tandem/PixieDAQ/elogEntry.sh %d %d \"%s\"", 0, (int)runIDEntry->GetIntNumber(), StartStopDialog::Comment.Data() );
int temp = system(cmd.Data());
runIDEntry->SetIntNumber(runIDEntry->GetIntNumber()+1);
}
} }
void MainWindow::OpenScalar(){ void MainWindow::OpenScalar(){
if( scalarPanel == NULL ) { if( scalarPanel == NULL ) {
scalarPanel = new ScalarPanel(gClient->GetRoot(), 600, 600, pixie); scalarPanel = new ScalarPanel(gClient->GetRoot(), fMain, 600, 600, pixie);
}else{ }else{
if( !scalarPanel->isOpened ) scalarPanel = new ScalarPanel(gClient->GetRoot(), 600, 600, pixie); if( !scalarPanel->isOpened ) scalarPanel = new ScalarPanel(gClient->GetRoot(), fMain, 600, 600, pixie);
} }
} }
@ -666,7 +687,7 @@ void * MainWindow::SaveData(void* ptr){
if( pixie->GetnFIFOWords() > 0 ) { if( pixie->GetnFIFOWords() > 0 ) {
pixie->SaveData(); pixie->SaveData();
///ScanNumDataBlockInExtFIFO() should be here after ReadData(). becasue not a whlole dataBlock is in FIFO. ///ScanNumDataBlockInExtFIFO() should be here after ReadData(). becasue not a whlole dataBlock is in FIFO.
//pixie->ScanNumDataBlockInExtFIFO(); //TODO need to check the time comsumtion pixie->ScanNumDataBlockInExtFIFO(); //TODO need to check the time comsumtion
pixie->SetFIFOisUsed(false); pixie->SetFIFOisUsed(false);
localClock.Stop("timer"); localClock.Stop("timer");
@ -702,7 +723,6 @@ void * MainWindow::SaveData(void* ptr){
} }
} }
} }
pixie->ReadData(0); pixie->ReadData(0);
pixie->SaveData(); pixie->SaveData();

View File

@ -18,6 +18,7 @@
#include "scalarPanel.h" #include "scalarPanel.h"
#include "moduleSetting.h" #include "moduleSetting.h"
#include "channelSetting.h" #include "channelSetting.h"
#include "startStopDialog.h"
class TGWindow; class TGWindow;
class TGMainFrame; class TGMainFrame;
@ -51,6 +52,7 @@ private:
ModuleSetting * moduleSetting; ModuleSetting * moduleSetting;
ChannelSetting * channelSetting; ChannelSetting * channelSetting;
ScalarPanel * scalarPanel; ScalarPanel * scalarPanel;
StartStopDialog * startStopDialog;
TThread * saveDataThread; TThread * saveDataThread;
TThread * fillHistThread; TThread * fillHistThread;

View File

@ -20,15 +20,16 @@ TGTextEntry * ScalarPanel::teRealTime[MAXMOD] = {NULL};
int updateTime = 500; // msec int updateTime = 500; // msec
ScalarPanel::ScalarPanel(const TGWindow *p, UInt_t w, UInt_t h, Pixie16 * pixie){ ScalarPanel::ScalarPanel(const TGWindow *p, const TGWindow *main, UInt_t w, UInt_t h, Pixie16 * pixie){
this->pixie = pixie; this->pixie = pixie;
nMod = pixie->GetNumModule(); nMod = pixie->GetNumModule();
fMain = new TGMainFrame(p,w,h); fMain = new TGTransientFrame(p,main,w,h);
fMain->SetWindowName("Pixie16 Scalar Panel"); fMain->SetWindowName("Pixie16 Scalar Panel");
fMain->Connect("CloseWindow()", "ScalarPanel", this, "CloseWindow()"); fMain->Connect("CloseWindow()", "ScalarPanel", this, "CloseWindow()");
fMain->SetMWMHints(1,4, 0);
///Module choose ///Module choose
TGHorizontalFrame *hframe = new TGHorizontalFrame(fMain, w, 50 ); TGHorizontalFrame *hframe = new TGHorizontalFrame(fMain, w, 50 );
@ -120,7 +121,7 @@ void * ScalarPanel::UpdateScalar(void * ptr){
Pixie16ReadStatisticsFromModule (statistics, mod); Pixie16ReadStatisticsFromModule (statistics, mod);
double realTime = Pixie16ComputeRealTime (statistics, mod); double realTime = Pixie16ComputeRealTime (statistics, mod);
teRealTime[mod]->SetText(Form("%.2f", realTime)); teRealTime[mod]->SetText(Form("%.0f", realTime));
for( int ch = 0; ch < MAXCH ; ch ++){ for( int ch = 0; ch < MAXCH ; ch ++){
@ -128,7 +129,7 @@ void * ScalarPanel::UpdateScalar(void * ptr){
double OCR = Pixie16ComputeOutputCountRate (statistics, mod, ch); double OCR = Pixie16ComputeOutputCountRate (statistics, mod, ch);
double liveTime = Pixie16ComputeLiveTime (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] %.0f", ICR, OCR, liveTime));
} }
gSystem->Sleep(updateTime); gSystem->Sleep(updateTime);
} }

View File

@ -15,7 +15,7 @@ class TGMainFrame;
class ScalarPanel{ class ScalarPanel{
private: private:
TGMainFrame * fMain; TGTransientFrame * fMain;
static int nMod; static int nMod;
static Pixie16 * pixie; static Pixie16 * pixie;
@ -28,7 +28,7 @@ private:
TThread * thread; TThread * thread;
public: public:
ScalarPanel(const TGWindow *p, UInt_t w, UInt_t h, Pixie16 * pixie); ScalarPanel(const TGWindow *p, const TGWindow *main, UInt_t w, UInt_t h, Pixie16 * pixie);
virtual ~ScalarPanel(); virtual ~ScalarPanel();
static void * UpdateScalar(void * ptr); static void * UpdateScalar(void * ptr);

View File

@ -20,6 +20,7 @@ SettingsSummary::SettingsSummary(const TGWindow *p, UInt_t w, UInt_t h, Pixie16
fMain = new TGMainFrame(p,w,h); fMain = new TGMainFrame(p,w,h);
fMain->SetWindowName("Pixie16 Settings Summary"); fMain->SetWindowName("Pixie16 Settings Summary");
fMain->Connect("CloseWindow()", "SettingsSummary", this, "CloseWindow()"); fMain->Connect("CloseWindow()", "SettingsSummary", this, "CloseWindow()");
fMain->SetMWMHints(1,4, 0);
gClient->GetColorByName("red", red); gClient->GetColorByName("red", red);
gClient->GetColorByName("black", black); gClient->GetColorByName("black", black);

70
startStopDialog.cpp Normal file
View File

@ -0,0 +1,70 @@
#include "startStopDialog.h"
TString StartStopDialog::Comment = "";
bool StartStopDialog::isOK = false;
StartStopDialog::StartStopDialog(const TGWindow *p, const TGWindow *main, UInt_t w, UInt_t h, bool isStart){
this->isStart = isStart;
this->isOK = false;
Comment = "";
fMain = new TGTransientFrame(p, main, w, h, kVerticalFrame);
fMain->DontCallClose(); /// to avoid double deletions.
//fMain->SetCleanup(kDeepCleanup); /// use hierarchical cleaning
fMain->Connect("CloseWindow()", "StartStopDialog", this, "CloseWindow()");
TGHorizontalFrame * fFrame1 = new TGHorizontalFrame(fMain); fMain->AddFrame(fFrame1, new TGLayoutHints(kLHintsCenterX | kLHintsExpandX, 5, 5, 5, 5));
txtComment = new TGTextEntry(fFrame1, ""); fFrame1->AddFrame(txtComment);
txtComment->Resize(300, 20);
txtComment->Connect("ReturnPressed()", "StartStopDialog", this, "DoOK()");
TGHorizontalFrame * fFrame2 = new TGHorizontalFrame(fMain); fMain->AddFrame(fFrame2,new TGLayoutHints(kLHintsCenterX | kLHintsExpandX, 5, 5, 5, 5));
TGTextButton * bOK = new TGTextButton(fFrame2, "OK"); fFrame2->AddFrame(bOK, new TGLayoutHints(kLHintsCenterX));
bOK->Connect("Clicked()", "StartStopDialog", this, "DoOK()");
TGTextButton * bCancel = new TGTextButton(fFrame2, "Cancel"); fFrame2->AddFrame(bCancel, new TGLayoutHints(kLHintsCenterX));
bCancel->Connect("Clicked()", "StartStopDialog", this, "DoClose()");
TGHorizontalFrame * fFrame3 = new TGHorizontalFrame(fMain); fMain->AddFrame(fFrame3,new TGLayoutHints(kLHintsCenterX | kLHintsExpandX, 5, 5, 5, 5));
if( isStart ){
TGLabel * lbInfo = new TGLabel(fFrame3, "* Cancel or Close this dialog box will cancel START run.\n Only OK or press Enter will process."); fFrame3->AddFrame(lbInfo);
}else{
TGLabel * lbInfo = new TGLabel(fFrame3, "* Cancel or Close this dialog box will cancel STOP run.\n* Only OK or press Enter will process."); fFrame3->AddFrame(lbInfo);
}
fMain->MapSubwindows();
fMain->Resize();
fMain->CenterOnParent(); /// position relative to the parent's window
if( isStart) {
fMain->SetWindowName("Start Comment");
}else{
fMain->SetWindowName("Stop Comment");
}
fMain->MapWindow();
gClient->WaitFor(fMain); /// make everything wait for it
}
StartStopDialog::~StartStopDialog(){
printf("-------- %s |%s| %d\n", __func__, Comment.Data(), isOK);
delete txtComment;
fMain->DeleteWindow(); /// deletes fMain
}
void StartStopDialog::DoClose(){
isOK = false;
///Wait for 500 msec
TTimer::SingleShot(500, "StartStopDialog", this, "CloseWindow()");
}
void StartStopDialog::DoOK(){
Comment = "";
Comment = txtComment->GetText();
isOK = true;
TTimer::SingleShot(500, "StartStopDialog", this, "CloseWindow()");
}

37
startStopDialog.h Normal file
View File

@ -0,0 +1,37 @@
#ifndef START_STOP_DIALOG_H
#define START_STOP_DIALOG_H
#include <TQObject.h>
#include <RQ_OBJECT.h>
#include <TGButton.h>
#include <TGLabel.h>
#include <TTimer.h>
#include <TGTextEntry.h>
class TGWindow;
class TGMainFrame;
class StartStopDialog{
RQ_OBJECT("StartStopDialog")
private:
TGTextEntry * txtComment;
bool isStart;
public:
StartStopDialog(const TGWindow *p, const TGWindow *main, UInt_t w, UInt_t h, bool isStart);
virtual ~StartStopDialog();
TGTransientFrame * fMain;
void DoClose();
void DoOK();
void CloseWindow() { delete this;}
static TString Comment;
static bool isOK;
};
#endif

View File

@ -7,12 +7,12 @@
1, 1,
1, 1,
31, 31,
5, 120,
69, 43,
8, 8,
32, 32,
6, 6,
2, 306,
0, 0,
1, 1,
107, 107,
@ -25,7 +25,7 @@
10, 10,
2, 2,
10, 10,
10, 3,
10, 10,
10, 10,
10, 10,
@ -97,12 +97,12 @@
16544, 16544,
16544, 16544,
16544, 16544,
16548, 132,
16548, 132,
16544, 16544,
16544, 16544,
16548, 16544,
16548, 132,
16544, 16544,
16544, 16544,
16544, 16544,
@ -259,12 +259,12 @@
65535, 65535,
65535, 65535,
65535, 65535,
4000, 40000,
4000, 40000,
4000, 4000,
65535, 65535,
4000, 4000,
4000, 40000,
65535, 65535,
65535, 65535,
4000, 4000,
@ -421,12 +421,12 @@
32768, 32768,
32768, 32768,
32768, 32768,
21845, 48059,
21845, 48059,
21845, 21845,
32768, 32768,
21845, 21845,
21845, 50244,
32768, 32768,
32768, 32768,
21845, 21845,
@ -529,8 +529,8 @@
1100456650, 1100456650,
1100456650, 1100456650,
1100456650, 1100456650,
1112014848, 1095552204,
1112014848, 1095552204,
1112012226, 1112012226,
1100456650, 1100456650,
1112014848, 1112014848,