various fixes

This commit is contained in:
Ryan Tang 2022-11-04 16:25:33 -04:00
parent ecff324a27
commit 51ca791129
6 changed files with 107 additions and 95 deletions

View File

@ -8,7 +8,7 @@
#Slot Number for Each Module
#This must start at 2 and proceed sequentially at the moment
# slot modID fpgaID
S 2 0 25
S 9 0 25
#S 3 1 25
##########################################################################################################

View File

@ -274,7 +274,7 @@ void Pixie16::CheckHardware(){
//check pci is OK
ans = exec("lspci -vv| grep \"Unknown header type\" | wc -l");
if( atoi(ans.c_str()) > 0 ){
printf("found PLX PCI 9054, but not working. Unknown header Type.\n");
printf("Found PLX PCI 9054, but not working. Unknown header Type.\n");
retval = -3;
return;
}
@ -463,7 +463,7 @@ unsigned int Pixie16::ScanNumDataBlockInExtFIFO(){
return FIFONumDataBlock;
}
int Pixie16::ProcessSingleData(){
int Pixie16::ProcessSingleData(short ch){
int breakProcessLoopFlag = 0;
@ -502,7 +502,7 @@ int Pixie16::ProcessSingleData(){
if( nextWord == nFIFOWords ) {nextWord = 0; breakProcessLoopFlag = 1;}
if( nextWord > nFIFOWords ) {nextWord = nextWord - nFIFOWords; breakProcessLoopFlag = 2;}
if( data->ch == ch ) breakProcessLoopFlag = 1;
}
return breakProcessLoopFlag ;
@ -734,31 +734,39 @@ void Pixie16::SetCSRABit(int bitwise, unsigned short val, unsigned short modID,
retval = Pixie16ReadSglChanPar( (char *)"CHANNEL_CSRA", &ParData, modID, ch);
if( CheckError("Pixie16ReadSglChanPar::CHANNEL_CSRA") < 0 ) return;
std::cout << std::bitset<32>(ParData) << std::endl;
std::cout << std::bitset<32>(~bitwise) << std::endl;
int temp = ((int)ParData) & ~bitwise ;
int haha = 0;
if( bitwise == CSRA_BIT::FAST_TRIGGER ) haha = val << 0;
if( bitwise == CSRA_BIT::M_VALIDATION ) haha = val << 1;
if( bitwise == CSRA_BIT::ENABLE_CHANNEL ) haha = val << 2;
if( bitwise == CSRA_BIT::C_VALIFATION ) haha = val << 3;
if( bitwise == CSRA_BIT::BLOCK_DAQ_DPM_FULL ) haha = val << 4;
if( bitwise == CSRA_BIT::POLARITY ) haha = val << 5;
if( bitwise == CSRA_BIT::VETO_TRIGGER ) haha = val << 6;
if( bitwise == CSRA_BIT::HIST_ENERGY ) haha = val << 7;
if( bitwise == CSRA_BIT::ENABLE_TRACE ) haha = val << 8;
if( bitwise == CSRA_BIT::ENABLE_QDC ) haha = val << 9;
if( bitwise == CSRA_BIT::ENABLE_CFD ) haha = val << 10;
if( bitwise == CSRA_BIT::REQ_M_VALIDATION ) haha = val << 11;
if( bitwise == CSRA_BIT::CAPTURE_ESUMS_BASELINE ) haha = val << 12;
if( bitwise == CSRA_BIT::REQ_C_VALIDATION ) haha = val << 13;
if( bitwise == CSRA_BIT::INPUT_RELAY ) haha = val << 14;
if( bitwise == CSRA_BIT::PILEUP ) haha = val << 15;
if( bitwise == CSRA_BIT::NO_TRACE_LARGE_PULSE ) haha = val << 17;
if( bitwise == CSRA_BIT::GROUP_TRIGGER ) haha = val << 18;
if( bitwise == CSRA_BIT::CH_VETO ) haha = val << 19;
if( bitwise == CSRA_BIT::MO_VETO ) haha = val << 20;
if( bitwise == CSRA_BIT::EXT_TIMESTAMP ) haha = val << 21;
if( bitwise == CSRA_BIT::FAST_TRIGGER ) haha = ((val & 0x1) << 0);
if( bitwise == CSRA_BIT::M_VALIDATION ) haha = ((val & 0x1) << 1);
if( bitwise == CSRA_BIT::ENABLE_CHANNEL ) haha = ((val & 0x1) << 2);
if( bitwise == CSRA_BIT::C_VALIFATION ) haha = ((val & 0x1) << 3);
if( bitwise == CSRA_BIT::BLOCK_DAQ_DPM_FULL ) haha = ((val & 0x1) << 4);
if( bitwise == CSRA_BIT::POLARITY ) haha = ((val & 0x1) << 5);
if( bitwise == CSRA_BIT::VETO_TRIGGER ) haha = ((val & 0x1) << 6);
if( bitwise == CSRA_BIT::HIST_ENERGY ) haha = ((val & 0x1) << 7);
if( bitwise == CSRA_BIT::ENABLE_TRACE ) haha = ((val & 0x1) << 8);
if( bitwise == CSRA_BIT::ENABLE_QDC ) haha = ((val & 0x1) << 9);
if( bitwise == CSRA_BIT::ENABLE_CFD ) haha = ((val & 0x1) << 10);
if( bitwise == CSRA_BIT::REQ_M_VALIDATION ) haha = ((val & 0x1) << 11);
if( bitwise == CSRA_BIT::CAPTURE_ESUMS_BASELINE ) haha = ((val & 0x1) << 12);
if( bitwise == CSRA_BIT::REQ_C_VALIDATION ) haha = ((val & 0x1) << 13);
if( bitwise == CSRA_BIT::INPUT_RELAY ) haha = ((val & 0x1) << 14);
if( bitwise == CSRA_BIT::PILEUP ) haha = ((val & 0x1) << 15);
if( bitwise == CSRA_BIT::NO_TRACE_LARGE_PULSE ) haha = ((val & 0x1) << 17);
if( bitwise == CSRA_BIT::GROUP_TRIGGER ) haha = ((val & 0x1) << 18);
if( bitwise == CSRA_BIT::CH_VETO ) haha = ((val & 0x1) << 19);
if( bitwise == CSRA_BIT::MO_VETO ) haha = ((val & 0x1) << 20);
if( bitwise == CSRA_BIT::EXT_TIMESTAMP ) haha = ((val & 0x1) << 21);
SetChannelSetting("CHANNEL_CSRA", (temp | haha), modID, ch);
std::cout << std::bitset<32>(temp) << std::endl;
std::cout << std::bitset<32>(haha) << std::endl;
std::cout << std::bitset<32>(temp | haha) << std::endl;
SetChannelSetting("CHANNEL_CSRA", (temp | haha), modID, ch, true);
}

View File

@ -125,6 +125,7 @@ public:
int GetADCTraceLength() {return 8192;}
unsigned short * GetADCTrace() {return ADCTrace;}
///========================= Setting
unsigned short * GetSlotMap() {return PXISlotMap;};
unsigned int GetNumModule() {return NumModules;}
unsigned int GetDigitizerSerialNumber(unsigned short modID) { return ModSerNum[modID];}
@ -210,7 +211,7 @@ public:
unsigned int GetNextWord() {return nextWord;}
DataBlock * GetData() {return data;}
int ProcessSingleData();
int ProcessSingleData(short ch = -1);
unsigned int ScanNumDataBlockInExtFIFO(); /// also fill the FIFOEnergies, FIFOChannels, FIFOTimestamps, output FIFONumDataBlock
unsigned int GetAccumulatedFIFONumDataBlock() {return AccumulatedFIFONumDataBlock;}
unsigned int GetFIFONumDataBlock() {return FIFONumDataBlock;}

View File

@ -117,6 +117,7 @@ MainWindow::MainWindow(const TGWindow *p,UInt_t w,UInt_t h) {
modIDEntry->SetLimits(TGNumberFormat::kNELLimitMinMax, 0, pixie->GetNumModule()-1);
modIDEntry->Connect("Modified()", "MainWindow", this, "ChangeMod()");
if( pixie->GetNumModule() == 1 ) modIDEntry->SetState(false);
hframe1->AddFrame(modIDEntry, uniLayoutHints);
TGLabel * lb2 = new TGLabel(hframe1, "Ch :");
@ -154,11 +155,11 @@ MainWindow::MainWindow(const TGWindow *p,UInt_t w,UInt_t h) {
group2->AddFrame(hframe2);
TGLabel * lb1Prefix = new TGLabel(hframe2, "Save Prefix:");
hframe2->AddFrame(lb1Prefix, uniLayoutHints);
hframe2->AddFrame(lb1Prefix, new TGLayoutHints(kLHintsNormal, 5,5,10,3));
tePath = new TGTextEntry(hframe2, new TGTextBuffer(30));
tePath->SetWidth(50);
tePath->SetText("haha");
tePath->SetText("testRun");
hframe2->AddFrame(tePath, uniLayoutHints);
runIDEntry = new TGNumberEntry(hframe2, 0, 0, 0, TGNumberFormat::kNESInteger, TGNumberFormat::kNEANonNegative);
@ -198,14 +199,14 @@ MainWindow::MainWindow(const TGWindow *p,UInt_t w,UInt_t h) {
///================= Log massage
TGGroupFrame * groupLog = new TGGroupFrame(fMain, "Log Message", kHorizontalFrame);
fMain->AddFrame(groupLog, new TGLayoutHints(kLHintsCenterX, 5,5,0,5) );
fMain->AddFrame(groupLog, new TGLayoutHints(kLHintsCenterX | kLHintsExpandX, 5,5,0,5) );
teLog = new TGTextEdit(groupLog, w, 100);
groupLog->AddFrame(teLog, new TGLayoutHints(kLHintsNormal, 0,0,10,0));
/// Set a name to the main frame
fMain->SetWindowName("Pixie16 DAQ");
fMain->SetWindowName("Pixie16 DAQ (beta)");
/// Map all subwindows of main frame
fMain->MapSubwindows();
@ -401,14 +402,15 @@ void MainWindow::GetBaseLine(){
void MainWindow::Scope(){
int modID = modIDEntry->GetNumber();
unsigned short slotID = (pixie->GetSlotMap())[modID];
int ch = chEntry->GetNumber();
if( pixie->GetChannelOnOff(modID, ch) == false ){
if( pixie->GetChannelOnOff(modID, ch) == false || pixie->GetChannelTraceOnOff(modID, ch) == false ){
LogMsg(Form("mod:%d, ch-%d is disabled\n", modID, ch));
return;
}
LogMsg(Form("Get trace for mod:%d, ch-%02d", modID, ch));
LogMsg(Form("Get trace for mod:%d (slot:%d), ch-%02d", modID, slotID, ch));
double dt = pixie->GetCh2ns(modID);
@ -422,6 +424,7 @@ void MainWindow::Scope(){
usleep(runDuration*1000);
pixie->ReadData(0);
pixie->StopRun();
pixie->PrintStatistics(modID);
delete gTrace;
gTrace = new TGraph();
@ -429,15 +432,15 @@ void MainWindow::Scope(){
///printf(" next word : %u\n", pixie->GetNextWord());
///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( data->slot < 2 ) break;
if( data->eventID >= pixie->GetnFIFOWords() ) break;
if( data->eventID >= pixie->GetnFIFOWords() ) break;
///printf("mod:%d, ch:%d, event:%llu, %u, %u\n", data->slot-2, data->ch, data->eventID, pixie->GetNextWord(), pixie->GetnFIFOWords() );
//printf("mod:%d, ch:%d, event:%llu, %u, %u\n", data->slot-2,data->ch, data->eventID, pixie->GetNextWord(), pixie->GetnFIFOWords() );
if( data->ch == ch && data->slot == modID + 2 ){
if( data->ch == ch && data->slot == slotID ){
for( int i = 0 ; i < data->trace_length; i++){
gTrace->SetPoint(i, i*dt, (data->trace)[i]);
@ -567,7 +570,7 @@ void MainWindow::StartRun(){
pixie->StartRun(1);
if( pixie->IsRunning() ) saveDataThread->Run(); /// call SaveData()
if( pixie->IsRunning() ) fillHistThread->Run(); /// call SaveData()
//if( pixie->IsRunning() ) fillHistThread->Run(); /// call SaveData()
bStartRun->SetEnabled(false);
bStopRun->SetEnabled(true);
@ -663,7 +666,7 @@ void * MainWindow::SaveData(void* ptr){
if( pixie->GetnFIFOWords() > 0 ) {
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->ScanNumDataBlockInExtFIFO(); //TODO need to check the time comsumtion
pixie->SetFIFOisUsed(false);
localClock.Stop("timer");

View File

@ -66,13 +66,13 @@ SettingsSummary::SettingsSummary(const TGWindow *p, UInt_t w, UInt_t h, Pixie16
///---------- label row
TGHorizontalFrame * hframeLabel = new TGHorizontalFrame(hframeSettings, w, 50);
hframeSettings->AddFrame(hframeLabel, new TGLayoutHints(kLHintsExpandX, 2,2,2,2));
hframeSettings->AddFrame(hframeLabel, new TGLayoutHints(kLHintsExpandX, 2,2,0,0));
TGLabel * labelItems[numItems];
for(int i = 0; i < numItems; i++){
labelItems[i] = new TGLabel(hframeLabel, Form("%s", labelText[i].Data()));
labelItems[i]->Resize(width[i], 20);
labelItems[i]->SetMargins(0, (i == 0 ? 0 : 10) , 0, 0);
hframeLabel->AddFrame(labelItems[i], new TGLayoutHints(kLHintsCenterX | kLHintsCenterY, 5, 5, 3, 4));
hframeLabel->AddFrame(labelItems[i], new TGLayoutHints(kLHintsCenterX | kLHintsCenterY, 5, 5, 2, 2));
}
@ -81,13 +81,13 @@ SettingsSummary::SettingsSummary(const TGWindow *p, UInt_t w, UInt_t h, Pixie16
//printf("-----------------------%d\n", i);
hframeCh[i] = new TGHorizontalFrame(hframeSettings, w, 600 );
hframeSettings->AddFrame(hframeCh[i], new TGLayoutHints(kLHintsCenterX, 2,2,2,2));
hframeSettings->AddFrame(hframeCh[i], new TGLayoutHints(kLHintsCenterX, 2,2,0,0));
int col = 0;
lbCh[i] = new TGLabel(hframeCh[i] , Form("%02d", i));
lbCh[i]->SetWidth(width[col]);
lbCh[i]->SetTextColor(red);
hframeCh[i]->AddFrame(lbCh[i], new TGLayoutHints(kLHintsCenterX | kLHintsCenterY, 5, 5, 3, 4));
hframeCh[i]->AddFrame(lbCh[i], new TGLayoutHints(kLHintsCenterX | kLHintsCenterY, 5, 5, 2, 2));
col++;
cbOnOff[i] = new TGComboBox(hframeCh[i], i);
@ -102,7 +102,7 @@ SettingsSummary::SettingsSummary(const TGWindow *p, UInt_t w, UInt_t h, Pixie16
lbCh[i]->SetTextColor(black);
}
cbOnOff[i]->Connect("Selected(Int_t, Int_t)", "SettingsSummary", this, Form("ChangeOnOff(=%d)", i));
hframeCh[i]->AddFrame(cbOnOff[i], new TGLayoutHints(kLHintsCenterX | kLHintsCenterY, 5, 5, 3, 4));
hframeCh[i]->AddFrame(cbOnOff[i], new TGLayoutHints(kLHintsCenterX | kLHintsCenterY, 5, 5, 2, 2));
col++;
cbGain[i] = new TGComboBox(hframeCh[i], i);
@ -111,7 +111,7 @@ SettingsSummary::SettingsSummary(const TGWindow *p, UInt_t w, UInt_t h, Pixie16
cbGain[i]->Resize(width[col], 20);
pixie->GetChannelGain(modID, i) ? cbGain[i]->Select(1) : cbGain[i]->Select(0);
cbGain[i]->Connect("Selected(Int_t, Int_t)", "SettingsSummary", this, Form("ChangeGain(=%d)", i));
hframeCh[i]->AddFrame(cbGain[i], new TGLayoutHints(kLHintsCenterX | kLHintsCenterY, 5, 5, 3, 4));
hframeCh[i]->AddFrame(cbGain[i], new TGLayoutHints(kLHintsCenterX | kLHintsCenterY, 5, 5, 2, 2));
col++;
neTrigL[i] = new TGNumberEntry(hframeCh[i], pixie->GetChannelTriggerRiseTime(modID, i), 0, 0, TGNumberFormat::kNESRealTwo, TGNumberFormat::kNEANonNegative);
@ -141,7 +141,7 @@ SettingsSummary::SettingsSummary(const TGWindow *p, UInt_t w, UInt_t h, Pixie16
cbPol[i]->Resize(width[col], 20);
pixie->GetChannelPolarity(modID, i) ? cbPol[i]->Select(1) : cbPol[i]->Select(0);
cbPol[i]->Connect("Selected(Int_t, Int_t)", "SettingsSummary", this, Form("ChangePol(=%d)", i));
hframeCh[i]->AddFrame(cbPol[i], new TGLayoutHints(kLHintsCenterX | kLHintsCenterY, 5, 5, 3, 4));
hframeCh[i]->AddFrame(cbPol[i], new TGLayoutHints(kLHintsCenterX | kLHintsCenterY, 5, 5, 2, 2));
col++;
neEngL[i] = new TGNumberEntry(hframeCh[i], pixie->GetChannelEnergyRiseTime(modID, i), 0, 0, TGNumberFormat::kNESRealOne, TGNumberFormat::kNEANonNegative);
@ -171,7 +171,7 @@ SettingsSummary::SettingsSummary(const TGWindow *p, UInt_t w, UInt_t h, Pixie16
cbTraceOnOff[i]->Resize(width[col], 20);
pixie->GetChannelTraceOnOff(modID, i) ? cbTraceOnOff[i]->Select(1) : cbTraceOnOff[i]->Select(0);
cbTraceOnOff[i]->Connect("Selected(Int_t, Int_t)", "SettingsSummary", this, Form("ChangeTraceOnOff(=%d)", i));
hframeCh[i]->AddFrame(cbTraceOnOff[i], new TGLayoutHints(kLHintsCenterX | kLHintsCenterY, 5, 5, 3, 4));
hframeCh[i]->AddFrame(cbTraceOnOff[i], new TGLayoutHints(kLHintsCenterX | kLHintsCenterY, 5, 5, 2, 2));
col++;
neTraceLength[i] = new TGNumberEntry(hframeCh[i], pixie->GetChannelTraceLength(modID, i), 0, 0, TGNumberFormat::kNESRealTwo, TGNumberFormat::kNEANonNegative);
@ -269,7 +269,7 @@ void SettingsSummary::ChangePol(unsigned short ch){
void SettingsSummary::ChangeTraceOnOff(unsigned short ch){
short modID = modIDEntry->GetNumber();
int val = cbPol[ch]->GetSelected();
int val = cbTraceOnOff[ch]->GetSelected();
pixie->SetChannelTraceOnOff(val, modID, ch);
teFileName->SetText(settingFileName + " (not saved)");
}

View File

@ -3,25 +3,25 @@
"channel": {
"input": {
"BLcut": [
1,
90,
1,
1,
31,
31,
1,
5,
69,
8,
32,
106,
1,
6,
2,
0,
1,
1,
107,
1,
1,
2
],
"BaselinePercent": [
7,
10,
10,
2,
10,
@ -93,16 +93,16 @@
120
],
"ChanCSRa": [
2208,
18592,
16544,
16544,
16544,
16548,
16548,
16544,
16800,
16804,
16544,
420,
16544,
16548,
16548,
16544,
16544,
16544,
@ -219,7 +219,7 @@
20
],
"FastGap": [
14,
10,
10,
10,
10,
@ -237,7 +237,7 @@
10
],
"FastLength": [
14,
10,
10,
10,
10,
@ -255,19 +255,19 @@
10
],
"FastThresh": [
65535,
65535,
65535,
2000,
65535,
65535,
65535,
4000,
4000,
4000,
65535,
4000,
4000,
65535,
65535,
65535,
65535,
4000,
65535,
65535,
65535
@ -417,34 +417,34 @@
2
],
"OffsetDAC": [
32986,
32768,
32768,
32768,
34952,
32768,
21845,
32768,
21845,
32768,
32768,
32768,
21845,
21845,
21845,
32768,
21845,
21845,
32768,
32768,
21845,
32768,
32768,
32768
],
"PAFlength": [
1096,
1768,
1018,
1768,
1768,
1768,
1268,
1018,
666,
1768,
1018,
1768,
1018,
1792,
1768,
1768,
@ -489,7 +489,7 @@
0
],
"PeakSample": [
106,
95,
95,
95,
95,
@ -507,7 +507,7 @@
95
],
"PeakSep": [
108,
97,
97,
97,
97,
@ -525,19 +525,19 @@
97
],
"PreampTau": [
1112014848,
1100456650,
1100456650,
1100456650,
1100456650,
1100456650,
1100456650,
1112014848,
1112014848,
1112012226,
1100456650,
1100456650,
1100456650,
1112014848,
1112014848,
1100428083,
1100456650,
1100456650,
1112014848,
1100456650,
1100456650,
1100456650
@ -705,7 +705,7 @@
0
],
"SlowGap": [
25,
19,
19,
19,
19,
@ -723,7 +723,7 @@
19
],
"SlowLength": [
83,
78,
78,
78,
78,
@ -759,7 +759,7 @@
0
],
"TraceLength": [
2484,
5000,
5000,
5000,
5000,
@ -795,7 +795,7 @@
0
],
"TriggerDelay": [
856,
768,
768,
768,
768,
@ -993,7 +993,7 @@
"num-channels": 16,
"number": 0,
"serial-num": 1314,
"slot": 2,
"slot": 9,
"sys": {
"adc_bits": 16,
"adc_msps": 250,
@ -1016,7 +1016,7 @@
"ChanNum": 0,
"CoincPattern": 0,
"CoincWait": 0,
"ControlTask": 23,
"ControlTask": 0,
"CrateID": 0,
"FIFOLength": 8188,
"FastFilterRange": 0,
@ -1040,7 +1040,7 @@
0
],
"HostRunTimePreset": 1092616192,
"InSynch": 0,
"InSynch": 1,
"MaxEvents": 0,
"ModCSRA": 0,
"ModCSRB": 1,
@ -1049,7 +1049,7 @@
"ModNum": 0,
"Resume": 1,
"RunTask": 0,
"SlotID": 2,
"SlotID": 9,
"SlowFilterRange": 3,
"SynchWait": 1,
"TrigConfig": [