From 2f640d6e51ecf2e03e2456fe4cf6c62bb8806ce7 Mon Sep 17 00:00:00 2001 From: "Ryan@Debain10" Date: Mon, 7 Mar 2022 12:30:18 -0500 Subject: [PATCH] cannot figure out why the baseline is high and the trace has threshold... --- Pixie16Class.cpp | 24 ++++++++++--------- Pixie16Class.h | 29 ++++++++++++++++++----- test.cpp | 61 +++++++++++++++++++++++++++--------------------- test_ryan.set | 6 ++--- 4 files changed, 73 insertions(+), 47 deletions(-) diff --git a/Pixie16Class.cpp b/Pixie16Class.cpp index e12443e..07f849c 100644 --- a/Pixie16Class.cpp +++ b/Pixie16Class.cpp @@ -1,10 +1,10 @@ #ifndef PIXIE16_CPP #define PIXIE16_CPP - -//#include "pixie16app_export.h" -//#include "pixie16sys_export.h" -//#include "def21160.h" +///legacy pixie libaray +///#include "pixie16app_export.h" +///#include "pixie16sys_export.h" +///#include "def21160.h" #include #include @@ -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 *)"/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; + printf("########################## \n"); printf("Number of Module : %d \n", NumModules); printf("Slot Map : "); for( int i = 0; i < NumModules ; i++) printf("%d\t", PXISlotMap[i]); 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(" 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(" 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(" 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"); @@ -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(" 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(" 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) : "); int pileUpVaule = (CSRA & CSRA_BIT::PILEUP); 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){ - printf("====+=====+========+========+===========+==========+==========+==========+========+========+=========+======+====== \n"); - printf(" ch | En | Trig_L | Trig_G | Threshold | Polarity | Energy_L | Energy_G | Tau | Trace | Trace_d | Voff | BL \n"); - printf("----+-----+--------+--------+-----------+----------+----------+----------+--------+--------+---------+------+------ \n"); + printf("====+=====+======+========+========+===========+==========+==========+==========+========+========+=========+======+====== \n"); + printf(" ch | En | Gain | Trig_L | Trig_G | Threshold | Polarity | Energy_L | Energy_G | Tau | Trace | Trace_d | Voff | BL \n"); + printf("----+-----+------+--------+--------+-----------+----------+----------+----------+--------+--------+---------+------+------ \n"); for( int ch = 0; ch < 16; 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 |", GetChannelTriggerFlatTop(modID, ch)); printf(" %9.2f |", GetChannelTriggerThreshold(modID, ch)); diff --git a/Pixie16Class.h b/Pixie16Class.h index 3763ce9..aa3a39a 100644 --- a/Pixie16Class.h +++ b/Pixie16Class.h @@ -114,7 +114,6 @@ public: 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);} - 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 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 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); - 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 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 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 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 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); @@ -175,6 +177,21 @@ public: unsigned int GetNextWord() {return nextWord;} DataBlock * GetData() {return data;} 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 SaveData(); diff --git a/test.cpp b/test.cpp index 3ce8d24..b9feef0 100644 --- a/test.cpp +++ b/test.cpp @@ -13,7 +13,6 @@ #include "Pixie16Class.h" - #include "TROOT.h" #include "TSystem.h" #include "TStyle.h" @@ -77,7 +76,7 @@ int main(int argc, char *argv[]){ TH1F * hch = new TH1F("hch", "channel", 16, 0, 16); TH1F * hE = new TH1F("hE", "energy", 400, 0, 30000); TGraph * gTrace = new TGraph(); - gTrace->GetXaxis()->SetTitle("time [ch]"); + gTrace->GetXaxis()->SetTitle("time [ch = 4 ns]"); //pixie->SetDigitizerPresetRunTime(100000, 0); @@ -95,7 +94,7 @@ int main(int argc, char *argv[]){ */ int ch = 6; - double time = 2.0; ///sec + double time = 1.0; ///sec /* for( int i = 0; i < 16; i++){ @@ -109,30 +108,32 @@ int main(int argc, char *argv[]){ //pixie->SetChannelEnergyRiseTime(2, 0, ch); - //pixie->SetChannelTriggerThreshold(300, 0, ch); + pixie->SetChannelTriggerThreshold(300, 0, ch); //pixie->SetChannelEnergyTau(50, 0, ch); //pixie->SetChannelOnOff(true, 0, ch); //pixie->SetChannelPositivePolarity(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->SetChannelTraceLenght(10, 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->PrintChannelsMainSettings(0); - - //pixie->CaptureADCTrace(0, ch); - //unsigned short * haha = pixie->GetADCTrace(); - //for( int i = 0 ; i < pixie->GetADCTraceLength(); i++){ - // gTrace->SetPoint(i, i, haha[i]); - //} - //canvas->cd(3); gTrace->Draw("APL"); - + /* + pixie->CaptureADCTrace(0, ch); + unsigned short * haha = pixie->GetADCTrace(); + for( int i = 0 ; i < pixie->GetADCTraceLength(); i++){ + gTrace->SetPoint(i, i, haha[i]); + } + gTrace->GetXaxis()->SetTitle("time [us]"); + canvas->cd(3); gTrace->Draw("APL"); + */ //pixie->CaptureBaseLine(0, ch); //double * baseline = pixie->GetBasline(); @@ -158,27 +159,33 @@ int main(int argc, char *argv[]){ while( pixie->GetNextWord() < pixie->GetnFIFOWords() ){ + //if( data->eventID %100 == 99 ) pixie->PrintExtFIFOWords(); bool breakFlag = pixie->ProcessSingleData(); - data->Print(0); - printf("--------------next word : %d (%d) | event lenght : %d \n", pixie->GetNextWord(), pixie->GetnFIFOWords(), data->eventLength); + //data->Print(0); + //printf("--------------next word : %d (%d) | event lenght : %d \n", pixie->GetNextWord(), pixie->GetnFIFOWords(), data->eventLength); hch->Fill( data->ch); hE->Fill( data->energy ); - if( data->trace_length > 0 ) { - for( int i = 0 ; i < data->trace_length; i++){ - gTrace->SetPoint(i, i, data->trace[i]); + + if( data->eventID %10 == 0 ){ + 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(); - canvas->cd(2); hE->Draw(); - canvas->Modified(); - canvas->Update(); - gSystem->ProcessEvents(); - + if( data->eventID %100 == 0 ){ + //data->Print(0); + canvas->cd(1); hch->Draw(); + canvas->cd(2); hE->Draw(); + canvas->Modified(); + canvas->Update(); + gSystem->ProcessEvents(); + } if( breakFlag ) break; } diff --git a/test_ryan.set b/test_ryan.set index d8e153e..95a66b1 100644 --- a/test_ryan.set +++ b/test_ryan.set @@ -9,7 +9,7 @@ 31, 31, 1, - 291, + 32, 32, 1, 1, @@ -27,7 +27,7 @@ 10, 10, 10, - 10, + 90, 10, 10, 10, @@ -1016,7 +1016,7 @@ "ChanNum": 0, "CoincPattern": 0, "CoincWait": 0, - "ControlTask": 0, + "ControlTask": 6, "CrateID": 0, "FIFOLength": 8188, "FastFilterRange": 0,