cannot figure out why the baseline is high and the trace has threshold...

This commit is contained in:
Ryan Tang 2022-03-07 12:30:18 -05:00
parent e5af22d30c
commit 2f640d6e51
4 changed files with 73 additions and 47 deletions

View File

@ -1,10 +1,10 @@
#ifndef PIXIE16_CPP #ifndef PIXIE16_CPP
#define PIXIE16_CPP #define PIXIE16_CPP
///legacy pixie libaray
//#include "pixie16app_export.h" ///#include "pixie16app_export.h"
//#include "pixie16sys_export.h" ///#include "pixie16sys_export.h"
//#include "def21160.h" ///#include "def21160.h"
#include <bitset> #include <bitset>
#include <fstream> #include <fstream>
@ -102,10 +102,11 @@ bool Pixie16::LoadConfigFile(std::string fileName){
//DSPParFile [0] = (char *)"/usr/opt/Pixie16/Pixie-16_FSU_Custom_Firmware_06022020/Configuration/Pixie16_FSU_Sample_Setup.set"; //DSPParFile [0] = (char *)"/usr/opt/Pixie16/Pixie-16_FSU_Custom_Firmware_06022020/Configuration/Pixie16_FSU_Sample_Setup.set";
DSPParFile [0] = (char *)"/home/ryan/Pixie16/ryan/test_ryan.set"; DSPParFile [0] = (char *)"/home/ryan/Pixie16/ryan/test_ryan.set";
//DSPParFile [0] = (char *)"/home/ryan/Pixie16/ryan/Pixie16_FSU_Sample_Setup.set"; //DSPParFile [0] = (char *)"/home/ryan/Pixie16/ryan/Pixie16_example_legacy.set";
BootPattern = 0x7F; BootPattern = 0x7F;
printf("########################## \n");
printf("Number of Module : %d \n", NumModules); printf("Number of Module : %d \n", NumModules);
printf("Slot Map : "); for( int i = 0; i < NumModules ; i++) printf("%d\t", PXISlotMap[i]); printf("Slot Map : "); for( int i = 0; i < NumModules ; i++) printf("%d\t", PXISlotMap[i]);
printf("\n"); printf("\n");
@ -449,7 +450,7 @@ double Pixie16::GetChannelSetting(std::string parName, unsigned short modID, uns
printf(" channel enable (bit: 2) : %s \n", CSRA & CSRA_BIT::ENABLE_CHANNEL ? "\033[1;33mYes\033[m" : "\033[1;31mNo\033[m"); printf(" channel enable (bit: 2) : %s \n", CSRA & CSRA_BIT::ENABLE_CHANNEL ? "\033[1;33mYes\033[m" : "\033[1;31mNo\033[m");
printf(" channal validation signal selection (bit: 3) : %s \n", CSRA & CSRA_BIT::C_VALIFATION ? "module gate" : "global gate"); printf(" channal validation signal selection (bit: 3) : %s \n", CSRA & CSRA_BIT::C_VALIFATION ? "module gate" : "global gate");
printf("Block data acquisition if trace or header DPMs are full (bit: 4) : %s \n", CSRA & CSRA_BIT::BLOCK_DAQ_DPM_FULL ? "Yes" : "No"); printf("Block data acquisition if trace or header DPMs are full (bit: 4) : %s \n", CSRA & CSRA_BIT::BLOCK_DAQ_DPM_FULL ? "Yes" : "No");
printf(" signal polarity (bit: 5) : %s \n", CSRA & CSRA_BIT::POLARITY ? "Positive" : "Negative"); printf(" signal polarity (bit: 5) : %s \n", CSRA & CSRA_BIT::POLARITY ? "\033[1;33mPositive\033[m" : "\033[1;31mNegative\033[m");
printf(" veto channel trigger (bit: 6) : %s \n", CSRA & CSRA_BIT::VETO_TRIGGER ? "enable" : "disable"); printf(" veto channel trigger (bit: 6) : %s \n", CSRA & CSRA_BIT::VETO_TRIGGER ? "enable" : "disable");
printf(" Enable trace capture (bit: 8) : %s \n", CSRA & CSRA_BIT::ENABLE_TRACE ? "enable" : "disable"); printf(" Enable trace capture (bit: 8) : %s \n", CSRA & CSRA_BIT::ENABLE_TRACE ? "enable" : "disable");
printf(" Enable QDC sum capture (bit: 9) : %s \n", CSRA & CSRA_BIT::ENABLE_QDC ? "enable" : "disable"); printf(" Enable QDC sum capture (bit: 9) : %s \n", CSRA & CSRA_BIT::ENABLE_QDC ? "enable" : "disable");
@ -457,7 +458,7 @@ double Pixie16::GetChannelSetting(std::string parName, unsigned short modID, uns
printf(" required module validation trigger (bit: 11) : %s \n", CSRA & CSRA_BIT::REQ_M_VALIDATION ? "required" : "not required"); printf(" required module validation trigger (bit: 11) : %s \n", CSRA & CSRA_BIT::REQ_M_VALIDATION ? "required" : "not required");
printf(" Enable capture raw energy sums and baselines (bit: 12) : %s \n", CSRA & CSRA_BIT::CAPTURE_ESUMS_BASELINE ? "enable" : "disable"); printf(" Enable capture raw energy sums and baselines (bit: 12) : %s \n", CSRA & CSRA_BIT::CAPTURE_ESUMS_BASELINE ? "enable" : "disable");
printf(" required cahnnel validation trigger (bit: 13) : %s \n", CSRA & CSRA_BIT::REQ_C_VALIDATION ? "required" : "not required"); printf(" required cahnnel validation trigger (bit: 13) : %s \n", CSRA & CSRA_BIT::REQ_C_VALIDATION ? "required" : "not required");
printf(" Enable input relay (bit: 14) : %s \n", CSRA & CSRA_BIT::INPUT_RELAY ? "enable" : "disable"); printf(" Enable input relay (Gain) (bit: 14) : %s \n", CSRA & CSRA_BIT::INPUT_RELAY ? "\033[1;33mclose (no att.)\033[m" : "\033[1;31mopen (1/4 att.)\033[m");
printf(" Pile-up control (bit: 15-16) : "); printf(" Pile-up control (bit: 15-16) : ");
int pileUpVaule = (CSRA & CSRA_BIT::PILEUP); int pileUpVaule = (CSRA & CSRA_BIT::PILEUP);
if( pileUpVaule == 0 ) printf("no energy for pile-up\n"); if( pileUpVaule == 0 ) printf("no energy for pile-up\n");
@ -522,12 +523,13 @@ void Pixie16::PrintChannelAllSettings(unsigned short modID, unsigned short ch){
void Pixie16::PrintChannelsMainSettings(unsigned short modID){ void Pixie16::PrintChannelsMainSettings(unsigned short modID){
printf("====+=====+========+========+===========+==========+==========+==========+========+========+=========+======+====== \n"); printf("====+=====+======+========+========+===========+==========+==========+==========+========+========+=========+======+====== \n");
printf(" ch | En | Trig_L | Trig_G | Threshold | Polarity | Energy_L | Energy_G | Tau | Trace | Trace_d | Voff | BL \n"); printf(" ch | En | Gain | Trig_L | Trig_G | Threshold | Polarity | Energy_L | Energy_G | Tau | Trace | Trace_d | Voff | BL \n");
printf("----+-----+--------+--------+-----------+----------+----------+----------+--------+--------+---------+------+------ \n"); printf("----+-----+------+--------+--------+-----------+----------+----------+----------+--------+--------+---------+------+------ \n");
for( int ch = 0; ch < 16; ch ++){ for( int ch = 0; ch < 16; ch ++){
printf(" %2d |", ch); printf(" %2d |", ch);
printf(" %3s |", GetChannleOnOff(modID, ch) ? "On" : "Off" ); printf(" %3s |", GetChannelOnOff(modID, ch) ? "On" : "Off" );
printf(" %3s |", GetChannelGain(modID, ch) ? "x1" : "1/4" );
printf(" %6.2f |", GetChannelTriggerRiseTime(modID, ch)); printf(" %6.2f |", GetChannelTriggerRiseTime(modID, ch));
printf(" %6.2f |", GetChannelTriggerFlatTop(modID, ch)); printf(" %6.2f |", GetChannelTriggerFlatTop(modID, ch));
printf(" %9.2f |", GetChannelTriggerThreshold(modID, ch)); printf(" %9.2f |", GetChannelTriggerThreshold(modID, ch));

View File

@ -114,7 +114,6 @@ public:
void SetDigitizerInSynch(unsigned int val, unsigned short modID) { SetDigitizerSetting("IN_SYNCH", val, modID, 1);} void SetDigitizerInSynch(unsigned int val, unsigned short modID) { SetDigitizerSetting("IN_SYNCH", val, modID, 1);}
void SetDigitizerPresetRunTime(double val_in_sec, unsigned short modID) { SetDigitizerSetting("HOST_RT_PRESET", Decimal2IEEEFloating(val_in_sec), modID, 1);} void SetDigitizerPresetRunTime(double val_in_sec, unsigned short modID) { SetDigitizerSetting("HOST_RT_PRESET", Decimal2IEEEFloating(val_in_sec), modID, 1);}
double GetChannelSetting(std::string parName, unsigned short modID, unsigned short ch, bool verbose = false); double GetChannelSetting(std::string parName, unsigned short modID, unsigned short ch, bool verbose = false);
double GetChannelTriggerRiseTime (unsigned modID, unsigned short ch){ return GetChannelSetting("TRIGGER_RISETIME", modID, ch); } double GetChannelTriggerRiseTime (unsigned modID, unsigned short ch){ return GetChannelSetting("TRIGGER_RISETIME", modID, ch); }
double GetChannelTriggerFlatTop (unsigned modID, unsigned short ch){ return GetChannelSetting("TRIGGER_FLATTOP", modID, ch); } double GetChannelTriggerFlatTop (unsigned modID, unsigned short ch){ return GetChannelSetting("TRIGGER_FLATTOP", modID, ch); }
@ -127,13 +126,15 @@ public:
double GetChannelVOffset (unsigned modID, unsigned short ch){ return GetChannelSetting("VOFFSET", modID, ch); } double GetChannelVOffset (unsigned modID, unsigned short ch){ return GetChannelSetting("VOFFSET", modID, ch); }
double GetChannelBaseLinePrecent (unsigned modID, unsigned short ch){ return GetChannelSetting("BASELINE_PERCENT", modID, ch); } double GetChannelBaseLinePrecent (unsigned modID, unsigned short ch){ return GetChannelSetting("BASELINE_PERCENT", modID, ch); }
void PrintChannelAllSettings(unsigned short modID, unsigned short ch);
void PrintChannelsMainSettings(unsigned short modID);
unsigned short GetCSRA(int bitwise, unsigned short modID, unsigned short ch, bool verbose = false); unsigned short GetCSRA(int bitwise, unsigned short modID, unsigned short ch, bool verbose = false);
bool GetChannleOnOff(unsigned short modID, unsigned short ch, bool verbose = false) {return GetCSRA(CSRA_BIT::ENABLE_CHANNEL, modID, ch, verbose);} bool GetChannelOnOff(unsigned short modID, unsigned short ch, bool verbose = false) {return GetCSRA(CSRA_BIT::ENABLE_CHANNEL, modID, ch, verbose);}
bool GetChannelPolarity(unsigned short modID, unsigned short ch, bool verbose = false) {return GetCSRA(CSRA_BIT::POLARITY, modID, ch, verbose);} bool GetChannelPolarity(unsigned short modID, unsigned short ch, bool verbose = false) {return GetCSRA(CSRA_BIT::POLARITY, modID, ch, verbose);}
bool GetChannelTraceOnOff(unsigned short modID, unsigned short ch, bool verbose = false) {return GetCSRA(CSRA_BIT::ENABLE_TRACE, modID, ch, verbose);} bool GetChannelTraceOnOff(unsigned short modID, unsigned short ch, bool verbose = false) {return GetCSRA(CSRA_BIT::ENABLE_TRACE, modID, ch, verbose);}
bool GetChannelGain(unsigned short modID, unsigned short ch, bool verbose = false) {return GetCSRA(CSRA_BIT::INPUT_RELAY, modID, ch, verbose);}
void PrintChannelAllSettings(unsigned short modID, unsigned short ch);
void PrintChannelsMainSettings(unsigned short modID);
void SetChannelSetting(std::string parName, double val, unsigned short modID, unsigned short ch, bool verbose = false); void SetChannelSetting(std::string parName, double val, unsigned short modID, unsigned short ch, bool verbose = false);
void SetChannelTriggerRiseTime (double val, unsigned short modID, unsigned short ch){ SetChannelSetting("TRIGGER_RISETIME", val, modID, ch, 1);} void SetChannelTriggerRiseTime (double val, unsigned short modID, unsigned short ch){ SetChannelSetting("TRIGGER_RISETIME", val, modID, ch, 1);}
@ -150,9 +151,10 @@ public:
void SwitchCSRA(int bitwise, unsigned short modID, unsigned short ch); void SwitchCSRA(int bitwise, unsigned short modID, unsigned short ch);
void SetCSRABit(int bitwise, unsigned short val, unsigned short modID, unsigned short ch); void SetCSRABit(int bitwise, unsigned short val, unsigned short modID, unsigned short ch);
void SetChannelOnOff(bool enable, unsigned short modID, unsigned short ch) { SetCSRABit(CSRA_BIT::ENABLE_CHANNEL, enable, modID, ch); } void SetChannelOnOff(bool enable, unsigned short modID, unsigned short ch) { SetCSRABit(CSRA_BIT::ENABLE_CHANNEL, enable, modID, ch); }
void SetChannelPositivePolarity(bool positive, unsigned short modID, unsigned short ch) { SetCSRABit(CSRA_BIT::POLARITY, positive, modID, ch); } void SetChannelPositivePolarity(bool positive, unsigned short modID, unsigned short ch) { SetCSRABit(CSRA_BIT::POLARITY, positive, modID, ch); }
void SetChannelTraceOnOff(bool enable, unsigned short modID, unsigned short ch) { SetCSRABit(CSRA_BIT::ENABLE_TRACE, enable, modID, ch); } void SetChannelTraceOnOff(bool enable, unsigned short modID, unsigned short ch) { SetCSRABit(CSRA_BIT::ENABLE_TRACE, enable, modID, ch); }
void SetChannelGain(bool high, unsigned short modID, unsigned short ch) { SetCSRABit(CSRA_BIT::INPUT_RELAY, high, modID, ch); }
void SaveSettings(std::string fileName); void SaveSettings(std::string fileName);
@ -175,6 +177,21 @@ public:
unsigned int GetNextWord() {return nextWord;} unsigned int GetNextWord() {return nextWord;}
DataBlock * GetData() {return data;} DataBlock * GetData() {return data;}
bool ProcessSingleData(); bool ProcessSingleData();
void PrintExtFIFOWords() {
unsigned int nWords = (ExtFIFO_Data[nextWord] >> 17) & 0x3FFF;
printf("------------------- print dataBlock, nWords = %d\n", nWords);
int count = 0;
for( unsigned int i = nextWord; i < nextWord + nWords + 10 ; i++){
if( i == nextWord + nWords ) printf("===== end of dataBlock\n");
if( count % 4 == 3 ){
printf("%08X \n", ExtFIFO_Data[i]);
}else{
printf("%08X ", ExtFIFO_Data[i]);
}
count ++;
}
printf("\n------------------- \n");
}
void OpenFile(std::string fileName, bool append); void OpenFile(std::string fileName, bool append);
void SaveData(); void SaveData();

View File

@ -13,7 +13,6 @@
#include "Pixie16Class.h" #include "Pixie16Class.h"
#include "TROOT.h" #include "TROOT.h"
#include "TSystem.h" #include "TSystem.h"
#include "TStyle.h" #include "TStyle.h"
@ -77,7 +76,7 @@ int main(int argc, char *argv[]){
TH1F * hch = new TH1F("hch", "channel", 16, 0, 16); TH1F * hch = new TH1F("hch", "channel", 16, 0, 16);
TH1F * hE = new TH1F("hE", "energy", 400, 0, 30000); TH1F * hE = new TH1F("hE", "energy", 400, 0, 30000);
TGraph * gTrace = new TGraph(); TGraph * gTrace = new TGraph();
gTrace->GetXaxis()->SetTitle("time [ch]"); gTrace->GetXaxis()->SetTitle("time [ch = 4 ns]");
//pixie->SetDigitizerPresetRunTime(100000, 0); //pixie->SetDigitizerPresetRunTime(100000, 0);
@ -95,7 +94,7 @@ int main(int argc, char *argv[]){
*/ */
int ch = 6; int ch = 6;
double time = 2.0; ///sec double time = 1.0; ///sec
/* /*
for( int i = 0; i < 16; i++){ for( int i = 0; i < 16; i++){
@ -109,30 +108,32 @@ int main(int argc, char *argv[]){
//pixie->SetChannelEnergyRiseTime(2, 0, ch); //pixie->SetChannelEnergyRiseTime(2, 0, ch);
//pixie->SetChannelTriggerThreshold(300, 0, ch); pixie->SetChannelTriggerThreshold(300, 0, ch);
//pixie->SetChannelEnergyTau(50, 0, ch); //pixie->SetChannelEnergyTau(50, 0, ch);
//pixie->SetChannelOnOff(true, 0, ch); //pixie->SetChannelOnOff(true, 0, ch);
//pixie->SetChannelPositivePolarity(true, 0, ch); //pixie->SetChannelPositivePolarity(true, 0, ch);
//pixie->SetChannelTraceOnOff(true, 0, ch); //pixie->SetChannelTraceOnOff(true, 0, ch);
//pixie->SetChannelBaseLinePrecent(10, 0, ch); pixie->SetChannelBaseLinePrecent(90, 0, ch);
//pixie->SetChannelVOffset(0.0, 0, ch); //pixie->SetChannelVOffset(0.0, 0, ch);
//pixie->SetChannelTraceLenght(10, 0, ch); //pixie->SetChannelTraceLenght(10, 0, ch);
//pixie->SetChannelTraceDelay(2, 0, ch); //pixie->SetChannelTraceDelay(2, 0, ch);
//pixie->SaveSettings("test_ryan.set"); pixie->SetChannelGain(1, 0, ch);
pixie->SaveSettings("test_ryan.set");
pixie->PrintChannelAllSettings(0, ch); pixie->PrintChannelAllSettings(0, ch);
pixie->PrintChannelsMainSettings(0); pixie->PrintChannelsMainSettings(0);
/*
//pixie->CaptureADCTrace(0, ch); pixie->CaptureADCTrace(0, ch);
//unsigned short * haha = pixie->GetADCTrace(); unsigned short * haha = pixie->GetADCTrace();
//for( int i = 0 ; i < pixie->GetADCTraceLength(); i++){ for( int i = 0 ; i < pixie->GetADCTraceLength(); i++){
// gTrace->SetPoint(i, i, haha[i]); gTrace->SetPoint(i, i, haha[i]);
//} }
//canvas->cd(3); gTrace->Draw("APL"); gTrace->GetXaxis()->SetTitle("time [us]");
canvas->cd(3); gTrace->Draw("APL");
*/
//pixie->CaptureBaseLine(0, ch); //pixie->CaptureBaseLine(0, ch);
//double * baseline = pixie->GetBasline(); //double * baseline = pixie->GetBasline();
@ -158,27 +159,33 @@ int main(int argc, char *argv[]){
while( pixie->GetNextWord() < pixie->GetnFIFOWords() ){ while( pixie->GetNextWord() < pixie->GetnFIFOWords() ){
//if( data->eventID %100 == 99 ) pixie->PrintExtFIFOWords();
bool breakFlag = pixie->ProcessSingleData(); bool breakFlag = pixie->ProcessSingleData();
data->Print(0); //data->Print(0);
printf("--------------next word : %d (%d) | event lenght : %d \n", pixie->GetNextWord(), pixie->GetnFIFOWords(), data->eventLength); //printf("--------------next word : %d (%d) | event lenght : %d \n", pixie->GetNextWord(), pixie->GetnFIFOWords(), data->eventLength);
hch->Fill( data->ch); hch->Fill( data->ch);
hE->Fill( data->energy ); hE->Fill( data->energy );
if( data->trace_length > 0 ) {
for( int i = 0 ; i < data->trace_length; i++){ if( data->eventID %10 == 0 ){
gTrace->SetPoint(i, i, data->trace[i]); if( data->trace_length > 0 ) {
for( int i = 0 ; i < data->trace_length; i++){
gTrace->SetPoint(i, i, data->trace[i]);
}
gTrace->GetYaxis()->SetRangeUser(0, 5000);
canvas->cd(3); gTrace->Draw("APL");
} }
gTrace->GetYaxis()->SetRangeUser(0, 5000);
canvas->cd(3); gTrace->Draw("APL");
} }
canvas->cd(1); hch->Draw(); if( data->eventID %100 == 0 ){
canvas->cd(2); hE->Draw(); //data->Print(0);
canvas->Modified(); canvas->cd(1); hch->Draw();
canvas->Update(); canvas->cd(2); hE->Draw();
gSystem->ProcessEvents(); canvas->Modified();
canvas->Update();
gSystem->ProcessEvents();
}
if( breakFlag ) break; if( breakFlag ) break;
} }

View File

@ -9,7 +9,7 @@
31, 31,
31, 31,
1, 1,
291, 32,
32, 32,
1, 1,
1, 1,
@ -27,7 +27,7 @@
10, 10,
10, 10,
10, 10,
10, 90,
10, 10,
10, 10,
10, 10,
@ -1016,7 +1016,7 @@
"ChanNum": 0, "ChanNum": 0,
"CoincPattern": 0, "CoincPattern": 0,
"CoincWait": 0, "CoincWait": 0,
"ControlTask": 0, "ControlTask": 6,
"CrateID": 0, "CrateID": 0,
"FIFOLength": 8188, "FIFOLength": 8188,
"FastFilterRange": 0, "FastFilterRange": 0,