added global_macro.h, new thread for filling histogram

This commit is contained in:
Ryan Tang 2022-04-13 15:34:04 -04:00
parent 66e2b9d8f6
commit b1f5157f68
11 changed files with 179 additions and 65 deletions

View File

@ -48,23 +48,23 @@ pixieDict.cxx : pixieDAQ.h pixieDAQLinkDef.h
@echo "--------- creating pcm and cxx " @echo "--------- creating pcm and cxx "
@rootcling -f pixieDict.cxx -c pixieDAQ.h -p $(PIXIE_LIB_PATH) pixieDAQLinkDef.h @rootcling -f pixieDict.cxx -c pixieDAQ.h -p $(PIXIE_LIB_PATH) pixieDAQLinkDef.h
pixieDAQ.o : pixieDict.cxx pixieDAQ.cpp pixieDAQ.h pixieDAQ.o : pixieDict.cxx pixieDAQ.cpp pixieDAQ.h global_macro.h
@echo "--------- creating pixieDAQ.o" @echo "--------- creating pixieDAQ.o"
$(CC) $(CFLAGS) $(PIXIE_LIB_PATH) pixieDAQ.cpp Pixie16Class.cpp pixieDict.cxx $(ROOT_FLAG) $(CC) $(CFLAGS) $(PIXIE_LIB_PATH) pixieDAQ.cpp Pixie16Class.cpp pixieDict.cxx $(ROOT_FLAG)
settingsSummary.o : settingsSummary.cpp settingsSummary.h settingsSummary.o : settingsSummary.cpp settingsSummary.h global_macro.h
@echo "--------- creating settingsSummary.o" @echo "--------- creating settingsSummary.o"
$(CC) $(CFLAGS) $(PIXIE_LIB_PATH) settingsSummary.cpp $(ROOT_FLAG) $(CC) $(CFLAGS) $(PIXIE_LIB_PATH) settingsSummary.cpp $(ROOT_FLAG)
scalarPanel.o : scalarPanel.cpp scalarPanel.h scalarPanel.o : scalarPanel.cpp scalarPanel.h global_macro.h
@echo "--------- creating scalarPanel.o.o" @echo "--------- creating scalarPanel.o.o"
$(CC) $(CFLAGS) $(PIXIE_LIB_PATH) scalarPanel.cpp $(ROOT_FLAG) $(CC) $(CFLAGS) $(PIXIE_LIB_PATH) scalarPanel.cpp $(ROOT_FLAG)
moduleSetting.o : moduleSetting.cpp moduleSetting.h moduleSetting.o : moduleSetting.cpp moduleSetting.h global_macro.h
@echo "--------- creating moduleSetting.o" @echo "--------- creating moduleSetting.o"
$(CC) $(CFLAGS) $(PIXIE_LIB_PATH) moduleSetting.cpp $(ROOT_FLAG) $(CC) $(CFLAGS) $(PIXIE_LIB_PATH) moduleSetting.cpp $(ROOT_FLAG)
channelSetting.o : channelSetting.cpp channelSetting.h 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)

View File

@ -56,8 +56,11 @@ Pixie16::Pixie16(){
FIFOEnergies = new unsigned short[MAXFIFODATABLOCK]; FIFOEnergies = new unsigned short[MAXFIFODATABLOCK];
FIFOChannels = new unsigned short[MAXFIFODATABLOCK]; FIFOChannels = new unsigned short[MAXFIFODATABLOCK];
FIFOMods = new unsigned short[MAXFIFODATABLOCK];
FIFOTimestamps = new unsigned long long[MAXFIFODATABLOCK]; FIFOTimestamps = new unsigned long long[MAXFIFODATABLOCK];
FIFONumDataBlock = 0; FIFONumDataBlock = 0;
AccumulatedFIFONumDataBlock = 0;
FIFOisUsed = false;
data = new DataBlock(); data = new DataBlock();
nextWord = 0; nextWord = 0;
@ -72,6 +75,7 @@ Pixie16::~Pixie16(){
delete FIFOEnergies; delete FIFOEnergies;
delete FIFOChannels; delete FIFOChannels;
delete FIFOMods;
delete FIFOTimestamps; delete FIFOTimestamps;
delete PXISlotMap; delete PXISlotMap;
@ -380,10 +384,12 @@ void Pixie16::StartRun(bool listMode){
if( listMode ){ if( listMode ){
///listmode ///listmode
totNumFIFOWords = 0; totNumFIFOWords = 0;
AccumulatedFIFONumDataBlock = 0;
nextWord = 0; nextWord = 0;
retval = Pixie16StartListModeRun(NumModules, LIST_MODE_RUN, mode); retval = Pixie16StartListModeRun(NumModules, LIST_MODE_RUN, mode);
if( CheckError("Pixie16StartListModeRun") < 0 ) return; if( CheckError("Pixie16StartListModeRun") < 0 ) return;
printf("\033[32m LIST_MODE run\033[0m\n"); printf("\033[32m LIST_MODE run\033[0m\n");
}else{ }else{
///MCA mode ///MCA mode
retval = Pixie16StartHistogramRun(NumModules, mode); retval = Pixie16StartHistogramRun(NumModules, mode);
@ -392,8 +398,6 @@ void Pixie16::StartRun(bool listMode){
} }
isRunning = true; isRunning = true;
} }
@ -427,15 +431,15 @@ void Pixie16::ReadData(unsigned short modID){
retval = Pixie16ReadDataFromExternalFIFO(ExtFIFO_Data, nFIFOWords, modID); retval = Pixie16ReadDataFromExternalFIFO(ExtFIFO_Data, nFIFOWords, modID);
CheckError("Pixie16ReadDataFromExternalFIFO"); CheckError("Pixie16ReadDataFromExternalFIFO");
totNumFIFOWords += nFIFOWords; totNumFIFOWords += nFIFOWords;
FIFONumDataBlock = 0;
} }
}else{ }else{
printf("Pixie16 is not running.\n"); ///printf("Pixie16 is not running.\n");
} }
} }
unsigned int Pixie16::ScanNumDataBlockInExtFIFO(){ unsigned int Pixie16::ScanNumDataBlockInExtFIFO(){
unsigned int FIFONumDataBlock = 0;
unsigned int nextWordtemp = nextWord; unsigned int nextWordtemp = nextWord;
///if( nextWordtemp < nFIFOWords ) printf("============= FIFOWord : %u \n", nFIFOWords); ///if( nextWordtemp < nFIFOWords ) printf("============= FIFOWord : %u \n", nFIFOWords);
@ -445,6 +449,7 @@ unsigned int Pixie16::ScanNumDataBlockInExtFIFO(){
FIFOEnergies[FIFONumDataBlock] = (ExtFIFO_Data[nextWordtemp + 3] & 0xFFFF ); FIFOEnergies[FIFONumDataBlock] = (ExtFIFO_Data[nextWordtemp + 3] & 0xFFFF );
FIFOChannels[FIFONumDataBlock] = (ExtFIFO_Data[nextWordtemp] & 0xF ); FIFOChannels[FIFONumDataBlock] = (ExtFIFO_Data[nextWordtemp] & 0xF );
FIFOMods[FIFONumDataBlock] = ((ExtFIFO_Data[nextWordtemp] >> 4) & 0xF) - 2;
FIFOTimestamps[FIFONumDataBlock] = ((unsigned long long)(ExtFIFO_Data[nextWordtemp+2] & 0xFFFF) << 32) + ExtFIFO_Data[nextWordtemp+1]; FIFOTimestamps[FIFONumDataBlock] = ((unsigned long long)(ExtFIFO_Data[nextWordtemp+2] & 0xFFFF) << 32) + ExtFIFO_Data[nextWordtemp+1];
nextWordtemp += eventLen; nextWordtemp += eventLen;
@ -453,6 +458,7 @@ unsigned int Pixie16::ScanNumDataBlockInExtFIFO(){
} }
nextWord = nextWordtemp - nFIFOWords ; nextWord = nextWordtemp - nFIFOWords ;
AccumulatedFIFONumDataBlock += FIFONumDataBlock;
return FIFONumDataBlock; return FIFONumDataBlock;
} }

View File

@ -79,10 +79,13 @@ private:
unsigned int * Statistics; unsigned int * Statistics;
unsigned int totNumFIFOWords; unsigned int totNumFIFOWords;
unsigned short * FIFOMods;
unsigned short * FIFOChannels; unsigned short * FIFOChannels;
unsigned short * FIFOEnergies; unsigned short * FIFOEnergies;
unsigned long long * FIFOTimestamps; unsigned long long * FIFOTimestamps;
unsigned int FIFONumDataBlock; unsigned int FIFONumDataBlock;
unsigned int AccumulatedFIFONumDataBlock;
bool FIFOisUsed;
double Baselines[3640], TimeStamps[3640]; ///for baseline double Baselines[3640], TimeStamps[3640]; ///for baseline
unsigned short ADCTrace[8192]; unsigned short ADCTrace[8192];
@ -209,11 +212,16 @@ public:
int ProcessSingleData(); int ProcessSingleData();
unsigned int ScanNumDataBlockInExtFIFO(); /// also fill the FIFOEnergies, FIFOChannels, FIFOTimestamps, output FIFONumDataBlock unsigned int ScanNumDataBlockInExtFIFO(); /// also fill the FIFOEnergies, FIFOChannels, FIFOTimestamps, output FIFONumDataBlock
unsigned int GetAccumulatedFIFONumDataBlock() {return AccumulatedFIFONumDataBlock;}
unsigned int GetFIFONumDataBlock() {return FIFONumDataBlock;} unsigned int GetFIFONumDataBlock() {return FIFONumDataBlock;}
unsigned short * GetFIFOEnergies() {return FIFOEnergies;} unsigned short * GetFIFOEnergies() {return FIFOEnergies;}
unsigned short * GetFIFOChannels() {return FIFOChannels;} unsigned short * GetFIFOChannels() {return FIFOChannels;}
unsigned short * GetFIFOMods() {return FIFOMods;}
unsigned long long * GetFIFOTimestamps() {return FIFOTimestamps;} unsigned long long * GetFIFOTimestamps() {return FIFOTimestamps;}
/// FIFOisUsed is not used in this Class, it is for sync in thread
void SetFIFOisUsed(bool isUsed) {this->FIFOisUsed = isUsed;};
bool GetFIFOisUsed() {return FIFOisUsed;}
void PrintExtFIFOWords() { void PrintExtFIFOWords() {
unsigned int nWords = (ExtFIFO_Data[nextWord] >> 17) & 0x3FFF; unsigned int nWords = (ExtFIFO_Data[nextWord] >> 17) & 0x3FFF;

View File

@ -7,13 +7,11 @@
#include <TGLabel.h> #include <TGLabel.h>
#include "Pixie16Class.h" #include "Pixie16Class.h"
#include "global_macro.h"
class TGWindow; class TGWindow;
class TGMainFrame; class TGMainFrame;
#define MAXCH 16
#define NUM_CHANNEL_SETTING 25
class ChannelSetting{ class ChannelSetting{
private: private:
TGMainFrame * fMain; TGMainFrame * fMain;

10
global_macro.h Normal file
View File

@ -0,0 +1,10 @@
#ifndef GLOBAL_MACRO_H
#define GLOBAL_MACRO_H
#define MAXCH 16
#define MAXMOD 13
#define NUM_MOD_SETTING 13
#define NUM_CHANNEL_SETTING 25
#endif

View File

@ -7,13 +7,11 @@
#include <TGLabel.h> #include <TGLabel.h>
#include "Pixie16Class.h" #include "Pixie16Class.h"
#include "global_macro.h"
class TGWindow; class TGWindow;
class TGMainFrame; class TGMainFrame;
#define MAXCH 16
#define NUM_MOD_SETTING 13
class ModuleSetting{ class ModuleSetting{
private: private:
TGMainFrame * fMain; TGMainFrame * fMain;

View File

@ -37,7 +37,10 @@ enum MenuIdentifiers{
Pixie16 * MainWindow::pixie = NULL; Pixie16 * MainWindow::pixie = NULL;
TGTextEdit * MainWindow::teLog = NULL; TGTextEdit * MainWindow::teLog = NULL;
TRootEmbeddedCanvas * MainWindow::fEcanvas = NULL; TRootEmbeddedCanvas * MainWindow::fEcanvas = NULL;
TH1F * MainWindow::h1[13][16]={NULL}; TGNumberEntry * MainWindow::modIDEntry = NULL;
TGNumberEntry * MainWindow::chEntry = NULL;
TH1F * MainWindow::hEnergy[MAXMOD][MAXCH]={NULL};
bool MainWindow::isEnergyHistFilled = false;
MainWindow::MainWindow(const TGWindow *p,UInt_t w,UInt_t h) { MainWindow::MainWindow(const TGWindow *p,UInt_t w,UInt_t h) {
@ -50,6 +53,12 @@ MainWindow::MainWindow(const TGWindow *p,UInt_t w,UInt_t h) {
GoodBye(); GoodBye();
} }
for( unsigned int i = 0; i < pixie->GetNumModule() ; i++){
for( int j = 0; j < MAXCH ; j++){
hEnergy[i][j] = new TH1F(Form("hEnergy%02d_%02d", i, j), Form("Energy mod:%02d ch:%02d", i, j), 200, 0, 160000);
}
}
/// Create a main frame /// Create a main frame
fMain = new TGMainFrame(p,w,h); fMain = new TGMainFrame(p,w,h);
///fMain->SetWMPosition(500, 500); //does not work ///fMain->SetWMPosition(500, 500); //does not work
@ -96,6 +105,7 @@ MainWindow::MainWindow(const TGWindow *p,UInt_t w,UInt_t h) {
modIDEntry = new TGNumberEntry(hframe1, 0, 0, 0, TGNumberFormat::kNESInteger, TGNumberFormat::kNEANonNegative); modIDEntry = new TGNumberEntry(hframe1, 0, 0, 0, TGNumberFormat::kNESInteger, TGNumberFormat::kNEANonNegative);
modIDEntry->SetWidth(50); modIDEntry->SetWidth(50);
modIDEntry->SetLimits(TGNumberFormat::kNELLimitMinMax, 0, pixie->GetNumModule()-1); modIDEntry->SetLimits(TGNumberFormat::kNELLimitMinMax, 0, pixie->GetNumModule()-1);
modIDEntry->Connect("Modified()", "MainWindow", this, "ChangeMod()");
hframe1->AddFrame(modIDEntry, uniLayoutHints); hframe1->AddFrame(modIDEntry, uniLayoutHints);
TGLabel * lb2 = new TGLabel(hframe1, "Ch :"); TGLabel * lb2 = new TGLabel(hframe1, "Ch :");
@ -104,6 +114,7 @@ MainWindow::MainWindow(const TGWindow *p,UInt_t w,UInt_t h) {
chEntry = new TGNumberEntry(hframe1, 0, 0, 0, TGNumberFormat::kNESInteger, TGNumberFormat::kNEANonNegative); chEntry = new TGNumberEntry(hframe1, 0, 0, 0, TGNumberFormat::kNESInteger, TGNumberFormat::kNEANonNegative);
chEntry->SetWidth(50); chEntry->SetWidth(50);
chEntry->SetLimits(TGNumberFormat::kNELLimitMinMax, 0, pixie->GetDigitizerNumChannel(0)); chEntry->SetLimits(TGNumberFormat::kNELLimitMinMax, 0, pixie->GetDigitizerNumChannel(0));
chEntry->Connect("Modified()", "MainWindow", this, "ChangeChannel()");
hframe1->AddFrame(chEntry, uniLayoutHints); hframe1->AddFrame(chEntry, uniLayoutHints);
TGTextButton *bGetADCTrace = new TGTextButton(hframe1,"Get &ADC Trace"); TGTextButton *bGetADCTrace = new TGTextButton(hframe1,"Get &ADC Trace");
@ -131,10 +142,19 @@ MainWindow::MainWindow(const TGWindow *p,UInt_t w,UInt_t h) {
TGHorizontalFrame *hframe2 = new TGHorizontalFrame(group2,200,30); TGHorizontalFrame *hframe2 = new TGHorizontalFrame(group2,200,30);
group2->AddFrame(hframe2); group2->AddFrame(hframe2);
tePath = new TGTextEntry(hframe2, new TGTextBuffer(10)); TGLabel * lb1Prefix = new TGLabel(hframe2, "Save Prefix:");
tePath->SetText("haha.evt"); hframe2->AddFrame(lb1Prefix, uniLayoutHints);
tePath = new TGTextEntry(hframe2, new TGTextBuffer(30));
tePath->SetWidth(50);
tePath->SetText("haha");
hframe2->AddFrame(tePath, uniLayoutHints); hframe2->AddFrame(tePath, uniLayoutHints);
runIDEntry = new TGNumberEntry(hframe2, 0, 0, 0, TGNumberFormat::kNESInteger, TGNumberFormat::kNEANonNegative);
runIDEntry->SetWidth(50);
runIDEntry->SetLimits(TGNumberFormat::kNELLimitMinMax, 0, 999);
hframe2->AddFrame(runIDEntry, uniLayoutHints);
bStartRun = new TGTextButton(hframe2,"Start &Run"); bStartRun = new TGTextButton(hframe2,"Start &Run");
bStartRun->Connect("Clicked()","MainWindow",this,"StartRun()"); bStartRun->Connect("Clicked()","MainWindow",this,"StartRun()");
hframe2->AddFrame(bStartRun, uniLayoutHints); hframe2->AddFrame(bStartRun, uniLayoutHints);
@ -186,10 +206,8 @@ MainWindow::MainWindow(const TGWindow *p,UInt_t w,UInt_t h) {
/// Map main frame /// Map main frame
fMain->MapWindow(); fMain->MapWindow();
/// setup thread /// setup thread
thread = new TThread("hahaha", SaveData, (void *) 1); saveDataThread = new TThread("hahaha", SaveData, (void *) 1);
fillHistThread = new TThread("kakaka", FillHistogram, (void *) 1); fillHistThread = new TThread("kakaka", FillHistogram, (void *) 1);
settingsSummary = NULL; settingsSummary = NULL;
@ -229,10 +247,11 @@ MainWindow::~MainWindow() {
delete channelSetting; delete channelSetting;
delete scalarPanel; delete scalarPanel;
delete thread; delete saveDataThread;
delete fillHistThread; delete fillHistThread;
delete gTrace; delete gTrace;
/// Clean up used widgets: frames, buttons, layout hints /// Clean up used widgets: frames, buttons, layout hints
fMain->Cleanup(); fMain->Cleanup();
delete fMain; delete fMain;
@ -307,11 +326,10 @@ void MainWindow::GetADCTrace() {
} }
gTrace->GetXaxis()->SetTitle("time [us]"); gTrace->GetXaxis()->SetTitle("time [us]");
gTrace->GetXaxis()->SetRangeUser(0, pixie->GetADCTraceLength()*dt); gTrace->GetXaxis()->SetRangeUser(0, pixie->GetADCTraceLength()*dt);
gTrace->Draw("APL");
TCanvas *fCanvas = fEcanvas->GetCanvas(); fEcanvas->GetCanvas()->cd();
fCanvas->cd(); gTrace->Draw("APL");
fCanvas->Update(); fEcanvas->GetCanvas()->Update();
} }
@ -333,11 +351,10 @@ void MainWindow::GetBaseLine(){
gTrace->SetPoint(i, baselineTime[i]*1000, baseline[i]); gTrace->SetPoint(i, baselineTime[i]*1000, baseline[i]);
} }
gTrace->GetXaxis()->SetTitle("time [ns]"); gTrace->GetXaxis()->SetTitle("time [ns]");
gTrace->Draw("APL");
TCanvas *fCanvas = fEcanvas->GetCanvas(); fEcanvas->GetCanvas()->cd();
fCanvas->cd(); gTrace->Draw("APL");
fCanvas->Update(); fEcanvas->GetCanvas()->Update();
} }
@ -388,11 +405,10 @@ void MainWindow::Scope(){
gTrace->GetXaxis()->SetTitle("time [ns]"); gTrace->GetXaxis()->SetTitle("time [ns]");
gTrace->GetXaxis()->SetRangeUser(0, data->trace_length * dt); gTrace->GetXaxis()->SetRangeUser(0, data->trace_length * dt);
gTrace->SetTitle(Form("mod-%d, ch-%02d\n", modID, ch)); gTrace->SetTitle(Form("mod-%d, ch-%02d\n", modID, ch));
gTrace->Draw("APL");
TCanvas *fCanvas = fEcanvas->GetCanvas(); fEcanvas->GetCanvas()->cd();
fCanvas->cd(); gTrace->Draw("APL");
fCanvas->Update(); fEcanvas->GetCanvas()->Update();
bFitTrace->SetEnabled(true); bFitTrace->SetEnabled(true);
@ -466,11 +482,9 @@ void MainWindow::FitTrace(){
gTrace->Fit("fit", "qR0"); gTrace->Fit("fit", "qR0");
fEcanvas->GetCanvas()->cd();
traceFunc->Draw("same"); traceFunc->Draw("same");
fEcanvas->GetCanvas()->Update();
TCanvas *fCanvas = fEcanvas->GetCanvas();
fCanvas->cd();
fCanvas->Update();
LogMsg("========= fit result"); LogMsg("========= fit result");
TString text[5] ={"start time", "rise time", "decay time", "amp", "baseline"}; TString text[5] ={"start time", "rise time", "decay time", "amp", "baseline"};
@ -497,12 +511,23 @@ void MainWindow::GoodBye(){
void MainWindow::StartRun(){ void MainWindow::StartRun(){
pixie->OpenFile(tePath->GetText(), false); TString saveFileName = Form("%s_%03lu.evt", tePath->GetText(), runIDEntry->GetIntNumber());
LogMsg(Form("Start Run. Save data at %s.\n", tePath->GetText())); pixie->OpenFile(saveFileName.Data(), false);
LogMsg(Form("Start Run. Save data at %s.\n", saveFileName.Data()));
///clear histogram;
isEnergyHistFilled = false;
for( unsigned int iMod = 0 ; iMod < pixie->GetNumModule(); iMod++){
for( int j = 0; j < MAXCH ; j++){
hEnergy[iMod][j]->Reset();
}
}
pixie->StartRun(1); pixie->StartRun(1);
if( pixie->IsRunning() ) thread->Run(); /// call SaveData() if( pixie->IsRunning() ) saveDataThread->Run(); /// call SaveData()
if( pixie->IsRunning() ) fillHistThread->Run(); /// call SaveData()
bStartRun->SetEnabled(false); bStartRun->SetEnabled(false);
bStopRun->SetEnabled(true); bStopRun->SetEnabled(true);
@ -523,6 +548,8 @@ void MainWindow::StopRun(){
bStartRun->SetEnabled(true); bStartRun->SetEnabled(true);
bStopRun->SetEnabled(false); bStopRun->SetEnabled(false);
runIDEntry->SetIntNumber(runIDEntry->GetIntNumber()+1);
} }
@ -536,6 +563,25 @@ void MainWindow::OpenScalar(){
} }
void MainWindow::ChangeMod(){
if( isEnergyHistFilled ){
int modID = modIDEntry->GetNumber();
int ch = chEntry->GetNumber();
fEcanvas->GetCanvas()->cd();
hEnergy[modID][ch]->Draw();
fEcanvas->GetCanvas()->Update();
}
}
void MainWindow::ChangeChannel(){
ChangeMod();
}
void MainWindow::LogMsg(TString msg){ void MainWindow::LogMsg(TString msg){
time_t now = time(0); time_t now = time(0);
@ -576,16 +622,20 @@ 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.
pixie->ScanNumDataBlockInExtFIFO(); //TODO need to check the time comsumtion
pixie->SetFIFOisUsed(false);
localClock.Stop("timer"); localClock.Stop("timer");
newTime = localClock.GetRealTime("timer"); /// sec newTime = localClock.GetRealTime("timer"); /// sec
localClock.Start("timer"); localClock.Start("timer");
if( newTime - oldTime > 1 ) { ///printf("Thread[SaveData] , FIFO: %u nData %u | %f\n", pixie->GetnFIFOWords(), nData, newTime);
//double MByteRead = pixie->GetnFIFOWords()*4./1024./1024.;
//if( MByteRead > 70 && pauseTime > 10) pauseTime = pauseTime - 20; if( newTime - oldTime > 1 ) {
///double MByteRead = pixie->GetnFIFOWords()*4./1024./1024.;
///if( MByteRead > 70 && pauseTime > 10) pauseTime = pauseTime - 20;
//TODO Fill HISTORGRAM;
time_t now = time(0); time_t now = time(0);
tm * ltm = localtime(&now); tm * ltm = localtime(&now);
int year = 1900 + ltm->tm_year; int year = 1900 + ltm->tm_year;
@ -601,10 +651,10 @@ void * MainWindow::SaveData(void* ptr){
oldFileSize = newFileSize; oldFileSize = newFileSize;
oldTime = newTime; oldTime = newTime;
//teLog->AddLine(Form("[%4d-%02d-%02d %02d:%02d:%02d] File Size : %.2f MB [%.2f MB/s], %.2f MB readed", ///teLog->AddLine(Form("[%4d-%02d-%02d %02d:%02d:%02d] File Size : %.2f MB [%.2f MB/s], %.2f MB readed",
// year, month, day, hour, minute, secound, newFileSize, rate, MByteRead)); /// year, month, day, hour, minute, secound, newFileSize, rate, MByteRead));
teLog->AddLine(Form("[%4d-%02d-%02d %02d:%02d:%02d] File Size : %.2f MB [%.2f MB/s]", teLog->AddLine(Form("[%4d-%02d-%02d %02d:%02d:%02d] File Size : %.2f MB [%.2f MB/s] Number of events recorded : %u",
year, month, day, hour, minute, secound, newFileSize, rate)); year, month, day, hour, minute, secound, newFileSize, rate, pixie->GetAccumulatedFIFONumDataBlock()));
teLog->LineDown(); teLog->LineDown();
} }
} }
@ -621,9 +671,50 @@ void * MainWindow::SaveData(void* ptr){
void * MainWindow::FillHistogram(void *ptr){ void * MainWindow::FillHistogram(void *ptr){
//using evtReader or process from ExtFIFOword, but in case in complete data ///double oldTime = 0, newTime = 0;
///TBenchmark localClock;
///localClock.Reset();
///localClock.Start("timer");
while( pixie->IsRunning() ){
if( pixie->GetFIFOisUsed() == false && pixie->GetnFIFOWords() > 0 && pixie->GetFIFONumDataBlock() > 0 ) {
///localClock.Stop("timer");
///newTime = localClock.GetRealTime("timer"); /// sec
///localClock.Start("timer");
///unsigned int nextWord = pixie->GetNextWord();
unsigned int nData = pixie->GetFIFONumDataBlock();
unsigned short channels[nData];
unsigned short energies[nData];
unsigned short mods[nData];
long long int timestamps[nData];
std::memcpy(mods, pixie->GetFIFOMods(), sizeof(unsigned short) * nData);
std::memcpy(channels, pixie->GetFIFOChannels(), sizeof(unsigned short) * nData);
std::memcpy(energies, pixie->GetFIFOEnergies(), sizeof(unsigned short) * nData);
std::memcpy(timestamps, pixie->GetFIFOTimestamps(), sizeof(long long int) * nData);
///printf("Thread[FillHistogram] ============= %u, nData : %d | %f\n",pixie->GetnFIFOWords(), nData, newTime);
for( unsigned int i = 0; i < nData; i++){
///printf("%3u| %2u, %3u, %7u, %llu \n", i, mods[i], channels[i], energies[i], timestamps[i]);
hEnergy[mods[i]][channels[i]]->Fill(energies[i]);
}
isEnergyHistFilled = true;
pixie->SetFIFOisUsed(true);
}
int modID = modIDEntry->GetNumber();
int ch = chEntry->GetNumber();
fEcanvas->GetCanvas()->cd();
hEnergy[modID][ch]->Draw();
fEcanvas->GetCanvas()->Update();
///usleep(300*1000);
}
return ptr; return ptr;
} }

View File

@ -12,6 +12,7 @@
#include <TBenchmark.h> #include <TBenchmark.h>
#include "Pixie16Class.h" #include "Pixie16Class.h"
#include "global_macro.h"
#include "settingsSummary.h" #include "settingsSummary.h"
#include "scalarPanel.h" #include "scalarPanel.h"
#include "moduleSetting.h" #include "moduleSetting.h"
@ -31,8 +32,11 @@ private:
TGMenuBar *fMenuBar; TGMenuBar *fMenuBar;
TGPopupMenu *fMenuFile, *fMenuSettings; TGPopupMenu *fMenuFile, *fMenuSettings;
TGNumberEntry * modIDEntry, *chEntry; static TGNumberEntry * modIDEntry, *chEntry;
TGNumberEntry * runIDEntry;
TGTextEntry * tePath; TGTextEntry * tePath;
static TGTextEdit * teLog; static TGTextEdit * teLog;
TGTextButton *bStartRun; TGTextButton *bStartRun;
@ -47,11 +51,11 @@ private:
ChannelSetting * channelSetting; ChannelSetting * channelSetting;
ScalarPanel * scalarPanel; ScalarPanel * scalarPanel;
TThread * thread; TThread * saveDataThread;
TThread * fillHistThread; TThread * fillHistThread;
static TH1F * h1[13][16]; static TH1F * hEnergy[MAXMOD][MAXCH];
static bool isEnergyHistFilled;
TGraph * gTrace; TGraph * gTrace;
@ -74,6 +78,8 @@ public:
void OpenScalar(); void OpenScalar();
static void * FillHistogram(void * ptr); /// thread static void * FillHistogram(void * ptr); /// thread
void ChangeMod();
void ChangeChannel();
void LogMsg(TString msg); void LogMsg(TString msg);

View File

@ -34,7 +34,7 @@ ScalarPanel::ScalarPanel(const TGWindow *p, UInt_t w, UInt_t h, Pixie16 * pixie)
TGHorizontalFrame *hframe = new TGHorizontalFrame(fMain, w, 50 ); TGHorizontalFrame *hframe = new TGHorizontalFrame(fMain, w, 50 );
fMain->AddFrame(hframe, new TGLayoutHints(kLHintsCenterX | kLHintsCenterY, 2,2,2,2)); fMain->AddFrame(hframe, new TGLayoutHints(kLHintsCenterX | kLHintsCenterY, 2,2,2,2));
int width = 30; int width = 35;
///------ Channel labels ///------ Channel labels
TGVerticalFrame * hChannelLabels = new TGVerticalFrame(hframe); TGVerticalFrame * hChannelLabels = new TGVerticalFrame(hframe);

View File

@ -8,13 +8,11 @@
#include <TGLabel.h> #include <TGLabel.h>
#include "Pixie16Class.h" #include "Pixie16Class.h"
#include "global_macro.h"
class TGWindow; class TGWindow;
class TGMainFrame; class TGMainFrame;
#define MAXCH 16
#define MAXMOD 13
class ScalarPanel{ class ScalarPanel{
private: private:
TGMainFrame * fMain; TGMainFrame * fMain;

View File

@ -8,12 +8,11 @@
#include <TGLabel.h> #include <TGLabel.h>
#include "Pixie16Class.h" #include "Pixie16Class.h"
#include "global_macro.h"
class TGWindow; class TGWindow;
class TGMainFrame; class TGMainFrame;
#define MAXCH 16
class SettingsSummary{ class SettingsSummary{
private: private:
TGMainFrame * fMain; TGMainFrame * fMain;