added some UI elements, can fill histogram when StartRUN

This commit is contained in:
carina@hades 2022-09-29 15:26:40 -04:00
parent f29dfb1438
commit e0b922000b
8 changed files with 319 additions and 172 deletions

View File

@ -20,6 +20,7 @@ class Data{
public:
int DPPType;
float ch2ns;
unsigned int nByte; /// number of byte
char *buffer; /// readout buffer
uint32_t AllocatedSize;
@ -80,6 +81,7 @@ class Data{
inline Data::Data(){
ch2ns = 2.0;
buffer = NULL;
for ( int i = 0; i < MaxNChannels; i++) TotNumEvents[i] = 0;
ClearData();
@ -98,17 +100,19 @@ inline Data::~Data(){
inline void Data::AllocateMemory(){
//delete buffer;
BufferSize = 1000000; /// 1M byte
buffer = (char *) malloc( BufferSize);
printf("Allocated %d byte for buffer \n", BufferSize);
///for( int i = 0 ; i < MaxNChannels ; i++ ) Events[i] = (CAEN_DGTZ_DPP_PHA_Event_t *) malloc( BufferSize);
///printf("Allocated %d byte for Events for each channel \n", BufferSize);
}
inline void Data::FreeMemory(){
printf("======= Free memory\n");
//if( buffer != NULL ) delete buffer;
//delete buffer;
}
inline void Data::ClearData(){
@ -154,9 +158,15 @@ inline void Data::SaveBuffer(const char * fileName){
inline void Data::PrintStat(){
for(int i = 0; i < MaxNChannels; i++){
printf("%2d | %6d | %6lu\n", i, NumEvents[i], TotNumEvents[i]);
printf("%2s | %6s | %9s | %6s\n", "ch", "# Evt.", "Rate [Hz]", "Tot. Evt.");
printf("---+--------+-----------+----------\n");
for(int ch = 0; ch < MaxNChannels; ch++){
unsigned long long dTime = Timestamp[ch][NumEvents[ch]-1] - Timestamp[ch][0];
double sec = dTime * ch2ns / 1e9;
printf("%2d | %6d | %9.2f | %6lu\n", ch, NumEvents[ch], NumEvents[ch]/sec, TotNumEvents[ch]);
}
printf("---+--------+-----------+----------\n");
}

View File

@ -100,6 +100,8 @@ int Digitizer::OpenDigitizer(int boardID, int portID, bool program, bool verbose
case CAEN_DGTZ_V1730: ch2ns = 2.0; break; ///ns -> 500 MSamples/s
case CAEN_DGTZ_V1725: ch2ns = 4.0; break; ///ns -> 250 MSamples/s
}
data->ch2ns = ch2ns;
ADCbits = BoardInfo.ADC_NBits;
ADCFullSize = (unsigned int)( pow(2, ADCbits) -1 );
@ -114,6 +116,7 @@ int Digitizer::OpenDigitizer(int boardID, int portID, bool program, bool verbose
///====================== Check DPP firmware revision
sscanf(BoardInfo.AMC_FirmwareRel, "%d", &DPPType);
data->DPPType = DPPType;
switch (DPPType){
case V1724_DPP_PHA_CODE: DPPTypeStr = "DPP-PHA x724"; break;
case V1720_DPP_CI_CODE : DPPTypeStr = "DPP-CI x720"; break;
@ -333,8 +336,8 @@ void Digitizer::ReadData(){
}
ret = CAEN_DGTZ_ReadData(handle, CAEN_DGTZ_SLAVE_TERMINATED_READOUT_MBLT, data->buffer, &(data->nByte));
uint32_t EventSize = ReadRegister(Register::DPP::EventSize); // Is it as same as data->nByte?
printf("Read Buffer size %d byte, Event Size : %d byte \n", data->nByte, EventSize);
//uint32_t EventSize = ReadRegister(Register::DPP::EventSize); // Is it as same as data->nByte?
//printf("Read Buffer size %d byte, Event Size : %d byte \n", data->nByte, EventSize);
if (ret || data->nByte == 0) {
ErrorMsg(__func__);
@ -583,7 +586,7 @@ int Digitizer::ProgramPHABoard(){
printf("======== program board PHA\n");
ret = CAEN_DGTZ_WriteRegister(handle, Register::DPP::RecordLength_G + 0x7000, 250);
ret = CAEN_DGTZ_WriteRegister(handle, Register::DPP::BoardConfiguration, 0x84F8115);
ret = CAEN_DGTZ_WriteRegister(handle, Register::DPP::BoardConfiguration, 0x0F8115);
//TODO change to write register
ret = CAEN_DGTZ_SetAcquisitionMode(handle, CAEN_DGTZ_SW_CONTROLLED); /// software command

View File

@ -91,7 +91,7 @@ class Digitizer{
unsigned int ReadBits(uint32_t address, unsigned int bitLength, unsigned int bitSmallestPos, int ch = -1 );
unsigned int GetDPPAlgorithmControl(int ch = -1) {return ReadRegister(Register::DPP::DPPAlgorithmControl, ch);}
bool isACQRunning() {return AcqRun;}
bool IsRunning() {return AcqRun;}
uint32_t PrintRegister(uint32_t address, std::string msg);

View File

@ -1,5 +1,7 @@
#include <TApplication.h>
#include <TGClient.h>
#include <TSystem.h>
#include <TStyle.h>
#include <TCanvas.h>
#include <TF1.h>
#include <TRandom.h>
@ -13,8 +15,7 @@
#include <TF1.h>
#include <unistd.h>
#include <ctime>
#include "DigitizerPHA.h"
#include "DigitizerPSD.h"
#include "FSUDAQ.h"
@ -32,12 +33,26 @@ enum MenuIdentifiers{
M_PROGRAM_SETTINGS,
M_FINDPEAKS,
M_SHOW_CHANNELS_RATE
};
enum ModeIdentifiers{
Mode_EnergyHist,
Mode_CountHist,
Mode_Oscilloscope,
Mode_DataRun
};
///make static members
Digitizer ** MainWindow::digi = NULL;
TGTextEdit * MainWindow::teLog = NULL;
TRootEmbeddedCanvas * MainWindow::fEcanvas = NULL;
TGNumberEntry * MainWindow::boardIDEntry = NULL;
TGNumberEntry * MainWindow::chIDEntry = NULL;
TH1F * MainWindow::hEnergy[MaxNBoards][MaxNChannels] = {NULL};
TH1F * MainWindow::hChannel[MaxNBoards] = {NULL};
MainWindow::MainWindow(const TGWindow *p,UInt_t w,UInt_t h) {
@ -87,57 +102,82 @@ MainWindow::MainWindow(const TGWindow *p,UInt_t w,UInt_t h) {
TGHorizontalFrame *hframe = new TGHorizontalFrame(fMain); fMain->AddFrame(hframe, new TGLayoutHints(kLHintsCenterX,2,2,2,2));
{///================= Create a horizontal frame widget with buttons
TGGroupFrame * group0 = new TGGroupFrame(hframe, "Hahaha", kHorizontalFrame); hframe->AddFrame(group0 );
TGHorizontalFrame *hfg0 = new TGHorizontalFrame(group0,200,30); group0->AddFrame(hfg0 ,new TGLayoutHints(kLHintsLeft, 0, 0, 0, 0));
TGGroupFrame * group0 = new TGGroupFrame(hframe, "Run Control", kHorizontalFrame); hframe->AddFrame(group0 );
TGVerticalFrame * vframe = new TGVerticalFrame(group0); group0->AddFrame(vframe);
TGHorizontalFrame *hfg0 = new TGHorizontalFrame(vframe); vframe->AddFrame(hfg0 ,new TGLayoutHints(kLHintsLeft, 0, 0, 0, 0));
TGLayoutHints * uniLayoutHints = new TGLayoutHints(kLHintsNormal, 2,2,10,0); ///left, right, top, bottom
bOpenDigitizers = new TGTextButton(hfg0,"Open Digitizers"); hfg0->AddFrame(bOpenDigitizers, uniLayoutHints);
bOpenDigitizers->Connect("Clicked()","MainWindow",this,"OpenDigitizers()");
TGTextButton *bStartRun = new TGTextButton(hfg0,"Start Run"); hfg0->AddFrame(bStartRun, uniLayoutHints);
bStartRun = new TGTextButton(hfg0,"Start Run"); hfg0->AddFrame(bStartRun, uniLayoutHints);
bStartRun->Connect("Clicked()", "MainWindow", this, "StartRun()");
bStartRun->SetEnabled(false);
TGTextButton *bStopRun = new TGTextButton(hfg0,"Stop Run"); hfg0->AddFrame(bStopRun, uniLayoutHints);
bStopRun = new TGTextButton(hfg0,"Stop Run"); hfg0->AddFrame(bStopRun, uniLayoutHints);
bStopRun->Connect("Clicked()", "MainWindow", this, "StopRun()");
bStopRun->SetEnabled(false);
TGCheckButton* bSaveData = new TGCheckButton(hfg0, "ACQ Start/Arm", 1); hfg0->AddFrame(bSaveData, uniLayoutHints);
bSaveData->SetState(kButtonDown);
TGLabel * lbMode = new TGLabel(hfg0, "Mode"); hfg0->AddFrame(lbMode, uniLayoutHints);
cbMode = new TGComboBox(hfg0); hfg0->AddFrame(cbMode, uniLayoutHints);
cbMode->AddEntry("Energy Hist.", Mode_EnergyHist);
cbMode->AddEntry("Count Hist.", Mode_CountHist);
cbMode->AddEntry("Ocsilloscope.", Mode_Oscilloscope);
cbMode->AddEntry("Data Run", Mode_DataRun);
cbMode->Select(1, false);
cbMode->Resize(80, 20);
TGHorizontalFrame *hfg1 = new TGHorizontalFrame(vframe); vframe->AddFrame(hfg1 ,new TGLayoutHints(kLHintsLeft, 0, 0, 0, 0));
TGLabel * lbDataPath = new TGLabel(hfg1, "Save Data Prefix"); hfg1->AddFrame(lbDataPath, uniLayoutHints);
dataPrefix = new TGTextEntry(hfg1, "test"); hfg1->AddFrame(dataPrefix,uniLayoutHints);
dataPrefix->Resize(100, 20);
TGLabel * lbRunNum = new TGLabel(hfg1, "Run"); hfg1->AddFrame(lbRunNum, uniLayoutHints);
runIDEntry = new TGNumberEntry(hfg1, 0, 0, 0, TGNumberFormat::kNESInteger, TGNumberFormat::kNEANonNegative); hfg1->AddFrame(runIDEntry, uniLayoutHints);
runIDEntry->SetWidth(50);
}
{///================= sigle Channel group
{///================= single Channel group
TGGroupFrame * group1 = new TGGroupFrame(hframe, "Single Channel", kHorizontalFrame); hframe->AddFrame(group1 );
TGHorizontalFrame *hfg1 = new TGHorizontalFrame(group1,200,30); group1->AddFrame(hfg1 ,new TGLayoutHints(kLHintsLeft, 0, 0, 0, 0));
TGLayoutHints * haha = new TGLayoutHints(kLHintsLeft | kLHintsCenterY, 2, 2, 10, 0); ///left, right, top, bottom
TGLabel * lb0 = new TGLabel(hfg1, "Board"); hfg1->AddFrame(lb0, haha);
TGNumberEntry * boardIDEntry = new TGNumberEntry(hfg1, 0, 0, 0, TGNumberFormat::kNESInteger, TGNumberFormat::kNEANonNegative); hfg1->AddFrame(boardIDEntry, haha);
boardIDEntry = new TGNumberEntry(hfg1, 0, 0, 0, TGNumberFormat::kNESInteger, TGNumberFormat::kNEANonNegative); hfg1->AddFrame(boardIDEntry, haha);
boardIDEntry->SetWidth(50);
//boardIDEntry->SetLimits(TGNumberFormat::kNELLimitMinMax, 0, nBoard-1);
boardIDEntry->SetState(false);
boardIDEntry->Connect("Modified()", "MainWindow", this, "ChangeBoard()");
TGLabel * lb1 = new TGLabel(hfg1, "Channel"); hfg1->AddFrame(lb1, haha);
TGNumberEntry* chIDEntry = new TGNumberEntry(hfg1, 0, 0, 0, TGNumberFormat::kNESInteger, TGNumberFormat::kNEAAnyNumber); hfg1->AddFrame(chIDEntry, haha);
chIDEntry = new TGNumberEntry(hfg1, 0, 0, 0, TGNumberFormat::kNESInteger, TGNumberFormat::kNEAAnyNumber); hfg1->AddFrame(chIDEntry, haha);
chIDEntry->SetWidth(50);
chIDEntry->SetState(false);
TGLabel * lbMode = new TGLabel(hfg1, "Mode"); hfg1->AddFrame(lbMode, haha);
TGComboBox* cbMode = new TGComboBox(hfg1); hfg1->AddFrame(cbMode, haha);
cbMode->AddEntry("Energy Hist", 0);
cbMode->AddEntry("Ocs.", 1);
cbMode->Select(1, false);
cbMode->Resize(80, 20);
bPlotSingleTrace = new TGTextButton(hfg1,"Plot Trace"); hfg1->AddFrame(bPlotSingleTrace, haha);
bPlotSingleTrace->Connect("Clicked()", "MainWindow", this, "PlotSingleTrace()");
bPlotSingleTrace->SetEnabled(false);
bFitTrace = new TGTextButton(hfg1,"Fit Trace"); hfg1->AddFrame(bFitTrace, haha);
bFitTrace->Connect("Clicked()", "MainWindow", this, "FitTrace()");
bFitTrace->SetEnabled(false);
}
///================= canvas widget
{///================= canvas widget
fEcanvas = new TRootEmbeddedCanvas("Ecanvas",fMain,900,400);
fMain->AddFrame(fEcanvas, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 10,10,10,10));
///================= Log massage
}
{///================= Log massage
TGGroupFrame * groupLog = new TGGroupFrame(fMain, "Log Message", kHorizontalFrame);
fMain->AddFrame(groupLog, new TGLayoutHints(kLHintsExpandX, 10,10,10,10) );
teLog = new TGTextEdit(groupLog, w, 100); groupLog->AddFrame(teLog, new TGLayoutHints(kLHintsExpandX, 2,2,10,0) );
}
/// Set a name to the main frame
fMain->SetWindowName("FSU DAQ");
@ -152,17 +192,16 @@ MainWindow::MainWindow(const TGWindow *p,UInt_t w,UInt_t h) {
/// setup thread
//saveDataThread = new TThread("hahaha", SaveData, (void *) 1);
//fillHistThread = new TThread("kakaka", FillHistogram, (void *) 1);
fillHistThread = new TThread("kakaka", FillHistogram, (void *) 1);
///settingsSummary = NULL;
boardSetting = NULL;
channelSettingPHA = NULL;
///settingsSummary = NULL;
///scalarPanel = NULL;
LogMsg("Please \"Open Digitizers\" to start.");
//HandleMenu(M_DIGITIZER_OPEN);
LogMsg((char*)"Please \"Open Digitizers\" to start.");
HandleMenu(M_DIGITIZER_OPEN);
//HandleMenu(M_BOARD_SETTINGS);
//HandleMenu(M_CH_SETTING_PHA);
//HandleMenu(M_CH_SETTING_PSD);
@ -172,6 +211,8 @@ MainWindow::MainWindow(const TGWindow *p,UInt_t w,UInt_t h) {
gDigiTrace1 = NULL;
gDigiTrace2 = NULL;
gStyle->SetOptStat("neiou");
}
MainWindow::~MainWindow() {
@ -180,27 +221,41 @@ MainWindow::~MainWindow() {
delete fMenuDigitizers;
delete fMenuUtility;
//delete boardIDEntry;
//delete chEntry;
//delete tePath;
delete teLog;
delete boardIDEntry;
delete chIDEntry;
if( digi != NULL ) delete [] digi;
delete teLog;
//delete tePath;
delete bOpenDigitizers;
delete bStartRun;
delete bStopRun;
delete cbMode;
delete bPlotSingleTrace;
delete bFitTrace;
delete [] digi;
delete boardSetting;
delete channelSettingPHA;
delete channelSettingPSD;
//delete settingsSummary;
//delete scalarPanel;
//
//delete saveDataThread;
//delete fillHistThread;
delete fillHistThread;
delete gAnaTrace1;
delete gAnaTrace2;
delete gDigiTrace1;
delete gDigiTrace2;
for( int i = 0; i < MaxNBoards; i++){
delete hChannel[i];
for( int j = 0; j < MaxNChannels; j++) delete hEnergy[i][j];
}
/// Clean up used widgets: frames, buttons, layout hints
fMain->Cleanup();
@ -256,7 +311,7 @@ void MainWindow::HandleMenu(Int_t id){
///========================= Program setting
case M_PROGRAM_SETTINGS:{
LogMsg("[Program settings] Not impelmented");
LogMsg((char*)"[Program settings] Not impelmented");
}break;
///====================== Show channel rate;
@ -264,11 +319,10 @@ void MainWindow::HandleMenu(Int_t id){
}break;
///====================== Fit Gaussian
case M_FINDPEAKS:{
LogMsg("[Find Peaks] Not impelmented");
LogMsg((char*)"[Find Gaussian Peaks] Not impelmented");
}break;
@ -278,7 +332,7 @@ void MainWindow::HandleMenu(Int_t id){
void MainWindow::OpenDigitizers(){
LogMsg("============= detect digitizers");
LogMsg((char*)"============= detect digitizers");
vector<int> DPPType;
DPPType.clear();
portID.clear();
@ -286,7 +340,7 @@ void MainWindow::OpenDigitizers(){
nDigi = 0;
Digitizer * dig = new Digitizer();
LogMsg("Finding Digitizer for 4 ports and 3 boards for each port...");
LogMsg((char*)"Finding Digitizer for 4 ports and 3 boards for each port...");
for( int port = 0; port < 4 ; port ++){
for( int board = 0; board < 3 ; board ++){
dig->OpenDigitizer(board, port);
@ -326,25 +380,29 @@ void MainWindow::OpenDigitizers(){
fMenuDigitizers->EnableEntry( M_TRIGGER_SUMMARY);
bOpenDigitizers->SetEnabled(false);
bStartRun->SetEnabled(true);
boardIDEntry->SetState(true);
chIDEntry->SetState(true);
boardIDEntry->SetLimits(TGNumberFormat::kNELLimitMinMax, 0, nDigi-1);
boardIDEntry->SetNumber(0, false);
chIDEntry->SetLimits(TGNumberFormat::kNELLimitMinMax, 0, digi[0]->GetNChannel() -1 );
bPlotSingleTrace->SetEnabled(true);
for( int i = 0; i < nDigi; i++){
hChannel[i] = new TH1F(Form("hBd%02d", i),Form("hBd%02d; ch; count", i), digi[i]->GetNChannel(), 0, digi[i]->GetNChannel()-1);
for( int j = 0; j < MaxNChannels; j++) hEnergy[i][j] = new TH1F(Form("hE%02dch%02d", i, j),Form("hE bd-%02d ch-%02d; Energy[ch]; count", i, j), 400, 0, 20000);
}
}
Double_t standardPulse(Double_t *x, Double_t * par){
/// par[0] = start time
/// par[1] = rise time
/// par[2] = decay time
/// par[3] = amplitude
/// par[4] = baseline
Double_t z = x[0] - par[0];
if( z <= 0 ) {
return par[4];
}else{
return par[3]*(1-TMath::Exp(-1*z/par[1]))*TMath::Exp(-1*z/par[2]) + par[4];
}
void MainWindow::ChangeBoard(){
int boardID = boardIDEntry->GetNumber();
chIDEntry->SetLimits(TGNumberFormat::kNELLimitMinMax, 0, digi[boardID]->GetNChannel() -1 );
}
void MainWindow::GoodBye(){
@ -359,9 +417,19 @@ void MainWindow::StartRun(){
LogMsg(Form("%s",__func__));
if( digi == NULL) return;
for( int bd = 0; bd < nDigi; bd++){
for( int ch = 0; ch < MaxNChannels; ch++){
hEnergy[bd][ch]->Reset();
}
}
bStartRun->SetEnabled(false);
bStopRun->SetEnabled(true);
digi[0]->StartACQ();
if( digi[0]->IsRunning() ) fillHistThread->Run();
}
@ -369,6 +437,15 @@ void MainWindow::StopRun(){
LogMsg(Form("%s",__func__));
if( digi == NULL) return;
digi[0]->StopACQ();
bStartRun->SetEnabled(true);
bStopRun->SetEnabled(false);
if( cbMode->GetSelected() == Mode_DataRun ){
int runID = runIDEntry->GetNumber();
runIDEntry->SetNumber(runID +1);
}
}
void MainWindow::OpenChannelSetting(Int_t boardID){
@ -378,7 +455,7 @@ void MainWindow::OpenChannelSetting(Int_t boardID){
if( digi[boardID]->GetDPPType() == V1730_DPP_PHA_CODE ){
channelSettingPHA = new ChannelSettingPHA(gClient->GetRoot(), 600, 600, digi, nDigi, boardID);
channelSettingPHA->Connect("LogMsg(char*)", "MainWindow", this, "LogMsg(char*)");
channelSettingPHA->Connect("SendPlotTraceCmd()", "MainWindow", this, "PlotTrace()");
channelSettingPHA->Connect("SendPlotTraceCmd()", "MainWindow", this, "PlotSingleTrace()");
}
if( digi[boardID]->GetDPPType() == V1730_DPP_PSD_CODE ){
@ -407,44 +484,45 @@ void MainWindow::LogMsg(char * msg){
}
void MainWindow::PlotTrace(){
void MainWindow::PlotSingleTrace(){
printf("=== %s\n", __func__);
Data * data = digi[0]->GetData();
if( digi == NULL ) return;
int boardID = boardIDEntry->GetNumber();
int chID = chIDEntry->GetNumber();
Data * data = digi[boardID]->GetData();
data->AllocateMemory();
data->DPPType = digi[0]->GetDPPType();
int ch2ns = (int) digi[0]->GetCh2ns();
int ch2ns = (int) digi[boardID]->GetCh2ns();
digi[0]->StartACQ();
digi[boardID]->StartACQ();
int count = 0;
while(count < 10){
//sleep(1);
usleep(500*1000); /// wait half sec
digi[0]->ReadData();
usleep(100*1000); /// wait half sec
digi[boardID]->ReadData();
if( data->nByte > 0 ){
data->DecodeBuffer(1);
data->DecodeBuffer(0);
data->PrintStat();
delete gAnaTrace1; gAnaTrace1 = new TGraph();
delete gDigiTrace1; gDigiTrace1 = new TGraph();
delete gDigiTrace1; gDigiTrace1 = new TGraph(); gDigiTrace1->SetLineColor(4);
int traceLength = (data->Waveform1[0][0]).size();
int traceLength = (data->Waveform1[chID][0]).size();
printf("0----------%d \n", traceLength);
if( traceLength == 0 ) {
LogMsg((char *)"no trace");
bFitTrace->SetEnabled(false);
}else{
for( int i = 0; i < traceLength ; i++) {
//printf("%d, ", (data->Waveform1[0][0])[i]);
gAnaTrace1->SetPoint(i, i*ch2ns, (data->Waveform1[0][0])[i]);
gDigiTrace1->SetPoint(i, i*ch2ns, 2000*(data->DigiWaveform1[0][0])[i] + 2000);
gAnaTrace1->SetPoint(i, i*ch2ns, (data->Waveform1[chID][0])[i]);
gDigiTrace1->SetPoint(i, i*ch2ns, 2000*(data->DigiWaveform1[chID][0])[i] + 2000);
}
}
data->ClearData();
@ -455,16 +533,64 @@ void MainWindow::PlotTrace(){
fEcanvas->GetCanvas()->Update();
break;
bFitTrace->SetEnabled(true);
}
count++;
};
digi[0]->StopACQ();
if( count == 10 ) LogMsg("Plot Trace TimeOut, please check setting");
if( count == 10 ) LogMsg((char*)"Plot Trace TimeOut, please check setting");
}
void MainWindow::FitTrace(){
printf("=== %s not impletement.\n", __func__);
}
void * MainWindow::FillHistogram(void * ptr){
printf("=== %s\n", __func__);
if( digi == NULL ) return 0;
//int boardID = boardIDEntry->GetNumber();
//int ch = chIDEntry->GetNumber();
int boardID = 0;
int ch = 0;
Data * data = digi[boardID]->GetData();
data->AllocateMemory();
while(digi[boardID]->IsRunning()){
usleep(100*1000); /// wait half sec
digi[boardID]->ReadData();
if( data->nByte > 0 ){
data->DecodeBuffer(0);
data->PrintStat();
//for( int ch = 0; ch < digi[boardID]->GetNChannel(); ch++){
for( int i = 0; i < data->NumEvents[ch]; i++){
hEnergy[boardID][ch]->Fill( data->Energy[ch][i]);
}
//}
data->ClearData();
fEcanvas->GetCanvas()->cd();
hEnergy[boardID][ch]->Draw();
fEcanvas->GetCanvas()->Update();
gSystem->ProcessEvents();
}
}
return ptr;
}
//############################################
int main(int argc, char **argv) {
printf(" Welcome to FSU DQ \n");

View File

@ -10,11 +10,13 @@
#include <TGraph.h>
#include <TBenchmark.h>
#include <TGTextEditor.h>
#include <TGTextEntry.h>
#include "CAENDigitizer.h"
#include "macro.h"
#include "DigitizerPHA.h"
#include "DigitizerPSD.h"
#include "ClassDigitizer.h"
#include "boardSetting.h"
#include "channelSettingPHA.h"
@ -26,6 +28,7 @@ class TGWindow;
class TGMainFrame;
class TRootEmbeddedCanvas;
class TGNumberEntry;
class MainWindow{
RQ_OBJECT("MainWindow")
private:
@ -35,17 +38,19 @@ private:
TGMenuBar *fMenuBar;
TGPopupMenu *fMenuFile, *fMenuDigitizers, *fMenuUtility;
//static TGNumberEntry * boardIDEntry, *chEntry;
//TGNumberEntry * runIDEntry;
//TGTextEntry * tePath;
//
static TGNumberEntry * boardIDEntry, *chIDEntry;
static TGTextEdit * teLog;
//
//TGTextButton *bStartRun;
//TGTextButton *bStopRun;
//TGTextButton *bFitTrace;
TGTextButton *bOpenDigitizers;
TGTextButton *bStartRun;
TGTextButton *bStopRun;
TGComboBox* cbMode;
TGTextEntry * dataPrefix;
TGNumberEntry * runIDEntry;
TGTextButton *bPlotSingleTrace;
TGTextButton *bFitTrace;
unsigned short nDigi;
vector<int> portID;
@ -61,9 +66,10 @@ private:
//ScalarPanel * scalarPanel;
//
//TThread * saveDataThread;
//TThread * fillHistThread;
//static TH1F * hEnergy[MAXMOD][MAXCH];
//static TH1F * hChannel[MAXMOD];
TThread * fillHistThread;
static TH1F * hEnergy [MaxNBoards][MaxNChannels];
static TH1F * hChannel[MaxNBoards];
TGraph * gAnaTrace1; /// analogy trace 1
TGraph * gAnaTrace2; /// analogy trace 2
@ -77,20 +83,19 @@ public:
void HandleMenu(Int_t id);
void OpenDigitizers();
void ChangeBoard();
//void GetADCTrace();
//void GetBaseLine();
//void Scope();
//void FitTrace();
void StartRun();
//static void * SaveData(void* ptr ); /// thread
void StopRun();
//void OpenScalar();
//static void * FillHistogram(void * ptr); /// thread
//void ChangeMod();
//void ChangeChannel();
//static void * SaveData(void* ptr ); /// thread
void PlotTrace();
//void OpenScalar();
static void * FillHistogram(void * ptr); /// thread
void PlotSingleTrace();
void FitTrace();
void Oscilloscope();
void OpenChannelSetting(Int_t);
void LogMsg(char * );

View File

@ -917,7 +917,7 @@ void BoardSetting::ChangeBoard(){
cbDP1->AddEntry("Armed (Triggered)", 1);
cbDP1->AddEntry("Peak Run", 2);
cbDP1->AddEntry("Pile-Up", 3);
///cbDP1->AddEntry("Peaking", 4); Duplicated?
cbDP1->AddEntry("Peaking", 4); ///Duplicated?
cbDP1->AddEntry("TRG Validation Win.", 5);
cbDP1->AddEntry("Baseline freeze", 6);
cbDP1->AddEntry("TRG holdoff", 7);

View File

@ -1,7 +1,7 @@
#ifndef MACRO_H
#define MACRO_H
#define MaxNBoards 22
#define MaxNChannels 16
#define MaxRecordLength 0x3fff * 8

View File

@ -120,7 +120,6 @@ int main(int argc, char* argv[]){
Data * data = dig[0]->GetData();
data->AllocateMemory();
data->DPPType = dig[0]->GetDPPType();
dig[0]->StartACQ();
@ -143,24 +142,10 @@ int main(int argc, char* argv[]){
data->SaveBuffer("test.bin");
data->DecodeBuffer(0);
for(int i = 0; i < dig[0]->GetNChannel(); i++){
//printf("%2d | %d \n", i, data->NumEvents[i]);
h1->Fill(i, data->NumEvents[i]);
}
for( int i = 0; i < data->NumEvents[0]; i++){
//printf("%2d | %d, %llu\n", i, data->Energy[0][i], data->Timestamp[0][i]);
h2->Fill( data->Energy[0][i]);
}
haha = data->Waveform1[0][0];
unsigned short nData = data->NumEvents[0]; //channel-0
haha = data->Waveform1[0][nData-1];
for( int i = 0; i < waveFormLength; i++) g1->SetPoint(i, i*ch2ns, haha[i]);
data->ClearData();
canvas->cd(1); h1->Draw("hist");
canvas->cd(2); h2->Draw();
canvas->cd(3); g1->Draw("AP");
canvas->Modified();
@ -175,7 +160,25 @@ int main(int argc, char* argv[]){
if( ElapsedTime > 1000 ){
int temp = system("clear");
data->PrintStat();
for(int i = 0; i < dig[0]->GetNChannel(); i++){
h1->Fill(i, data->NumEvents[i]);
}
for( int i = 0; i < data->NumEvents[0]; i++){
h2->Fill( data->Energy[0][i]);
}
data->ClearData();
canvas->cd(1); h1->Draw("hist");
canvas->cd(2); h2->Draw();
canvas->Modified();
canvas->Update();
gSystem->ProcessEvents();
PreviousTime = CurrentTime;
printf("Press any key to Stop\n");
}