diff --git a/Pixie16Class.cpp b/Pixie16Class.cpp index 453f7bd..2496359 100644 --- a/Pixie16Class.cpp +++ b/Pixie16Class.cpp @@ -745,8 +745,6 @@ void Pixie16::PrintStatistics(unsigned short modID){ printf(" %7d |", (int) (ICR * liveTime) ); printf(" %7d \n", (int) (OCR * realTime) ); } - - } } @@ -790,10 +788,7 @@ void Pixie16::SaveSettings(std::string fileName){ } } - - void Pixie16::OpenFile(std::string fileName, bool append){ - if( !outFile.is_open() ) { if( append ) { outFile.open(fileName, std::ios::out | std::ios::binary | std::ios::app); diff --git a/Pixie16Class.h b/Pixie16Class.h index f73e598..93603c0 100644 --- a/Pixie16Class.h +++ b/Pixie16Class.h @@ -153,6 +153,7 @@ public: 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);} + bool GetChannelQDCsumOnOff(unsigned short modID, unsigned short ch, bool verbose = false) {return GetCSRA(CSRA_BIT::ENABLE_QDC, modID, ch, verbose);} void PrintChannelAllSettings(unsigned short modID, unsigned short ch); void PrintChannelSettingsSummary(unsigned short modID); @@ -177,6 +178,7 @@ public: 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 SetChannelQDCsumOnOff(bool high, unsigned short modID, unsigned short ch) { SetCSRABit(CSRA_BIT::ENABLE_QDC, high, modID, ch); } void SaveSettings(std::string fileName); diff --git a/channelSetting.cpp b/channelSetting.cpp index ea237ba..c3fede9 100644 --- a/channelSetting.cpp +++ b/channelSetting.cpp @@ -10,7 +10,9 @@ #include "channelSetting.h" -///---------------------------------------------- NAME, DIGI, unit +//TODO set MAX + +///---------------------------------------------- NAME, DIGI, unit ... MAX TString settingName[NUM_CHANNEL_SETTING][3] = {{"TRIGGER_RISETIME", "2", "us"}, {"TRIGGER_FLATTOP", "2", "us"}, {"TRIGGER_THRESHOLD", "0", "ADC"}, @@ -25,14 +27,14 @@ TString settingName[NUM_CHANNEL_SETTING][3] = {{"TRIGGER_RISETIME", "2", "us" {"BASELINE_AVERAGE", "0", ""}, {"BLCUT", "0", ""}, {"EMIN", "0", ""}, - {"QDCLen0", "3", "us"}, - {"QDCLen1", "3", "us"}, - {"QDCLen2", "3", "us"}, - {"QDCLen3", "3", "us"}, - {"QDCLen4", "3", "us"}, - {"QDCLen5", "3", "us"}, - {"QDCLen6", "3", "us"}, - {"QDCLen7", "3", "us"}, + {"QDCLen0", "2", "us"}, + {"QDCLen1", "2", "us"}, + {"QDCLen2", "2", "us"}, + {"QDCLen3", "2", "us"}, + {"QDCLen4", "2", "us"}, + {"QDCLen5", "2", "us"}, + {"QDCLen6", "2", "us"}, + {"QDCLen7", "2", "us"}, {"MultiplicityMaskL", "0", ""}, {"MultiplicityMaskH", "0", ""}, {"CHANNEL_CSRA", "0", ""}}; @@ -90,8 +92,9 @@ ChannelSetting::ChannelSetting(const TGWindow *p, UInt_t w, UInt_t h, Pixie16 * int modID = modIDEntry->GetNumber(); int ch = chIDEntry->GetNumber(); - int width = 135; + int width = 80; + ///----------- on/off TGHorizontalFrame *hframeOnOff = new TGHorizontalFrame(vframe, 50, 50 ); vframe->AddFrame(hframeOnOff, new TGLayoutHints(kLHintsRight, 2,2,2,2)); @@ -99,19 +102,31 @@ ChannelSetting::ChannelSetting(const TGWindow *p, UInt_t w, UInt_t h, Pixie16 * cbOnOff->AddEntry("ON", 1); cbOnOff->AddEntry("off", 0); cbOnOff->Resize(width, 20); - if( pixie->GetChannelOnOff(modID, ch) ){ - cbOnOff->Select(1); - }else{ - cbOnOff->Select(0); - } + pixie->GetChannelOnOff(modID, ch) ? cbOnOff->Select(1) : cbOnOff->Select(0); cbOnOff->Connect("Selected(Int_t, Int_t)", "ChannelSetting", this, "ChangeOnOff()"); hframeOnOff->AddFrame(cbOnOff, new TGLayoutHints(kLHintsRight, 5,5,3,4)); TGLabel * lbOnOff = new TGLabel(hframeOnOff, "On/Off"); hframeOnOff->AddFrame(lbOnOff, new TGLayoutHints(kLHintsRight | kLHintsCenterY, 5, 5, 3, 4)); + ///----------- Polarity + TGHorizontalFrame *hframePol = new TGHorizontalFrame(vframe, 50, 50 ); + vframe->AddFrame(hframePol, new TGLayoutHints(kLHintsRight, 2,2,2,2)); + cbPolarity = new TGComboBox(hframePol); + cbPolarity->AddEntry("Positive +", 1); + cbPolarity->AddEntry("Negative -", 0); + cbPolarity->Resize(width, 20); + pixie->GetChannelPolarity(modID, ch) ? cbPolarity->Select(1) : cbPolarity->Select(0); + cbPolarity->Connect("Selected(Int_t, Int_t)", "ChannelSetting", this, "ChangeOnOff()"); + hframePol->AddFrame(cbPolarity, new TGLayoutHints(kLHintsRight, 5,5,3,4)); + + TGLabel * lbPol = new TGLabel(hframePol, "Polarity"); + hframePol->AddFrame(lbPol, new TGLayoutHints(kLHintsRight | kLHintsCenterY, 5, 5, 3, 4)); + + + ///----- all other TGHorizontalFrame *hframe[NUM_CHANNEL_SETTING]; TGLabel * lb[NUM_CHANNEL_SETTING]; @@ -119,6 +134,39 @@ ChannelSetting::ChannelSetting(const TGWindow *p, UInt_t w, UInt_t h, Pixie16 * hframe[i] = new TGHorizontalFrame(vframe, 50, 50 ); vframe->AddFrame(hframe[i], new TGLayoutHints(kLHintsRight, 2,2,2,2)); + ///----------- Trace on/off + if(settingName[i][0] == "TAU"){ + TGHorizontalFrame *hframeTraceOnOff = new TGHorizontalFrame(vframe, 50, 50 ); + vframe->AddFrame(hframeTraceOnOff, new TGLayoutHints(kLHintsRight, 2,2,2,2)); + + cbTraceOnOff = new TGComboBox(hframeTraceOnOff); + cbTraceOnOff->AddEntry("On", 1); + cbTraceOnOff->AddEntry("Off", 0); + cbTraceOnOff->Resize(width, 20); + pixie->GetChannelTraceOnOff(modID, ch) ? cbTraceOnOff->Select(1) : cbTraceOnOff->Select(0); + cbTraceOnOff->Connect("Selected(Int_t, Int_t)", "ChannelSetting", this, "ChangeOnOff()"); + hframeTraceOnOff->AddFrame(cbTraceOnOff, new TGLayoutHints(kLHintsRight, 5,5,3,4)); + + TGLabel * lbTraceOnOff = new TGLabel(hframeTraceOnOff, "Trace On/Off"); + hframeTraceOnOff->AddFrame(lbTraceOnOff, new TGLayoutHints(kLHintsRight | kLHintsCenterY, 5, 5, 3, 4)); + } + ///----------- QDC sum on/off + if( settingName[i][0] == "EMIN"){ + TGHorizontalFrame *hframeQDCsumOnOff = new TGHorizontalFrame(vframe, 50, 50 ); + vframe->AddFrame(hframeQDCsumOnOff, new TGLayoutHints(kLHintsRight, 2,2,2,2)); + + cbQDCsumOnOff = new TGComboBox(hframeQDCsumOnOff); + cbQDCsumOnOff->AddEntry("On", 1); + cbQDCsumOnOff->AddEntry("Off", 0); + cbQDCsumOnOff->Resize(width, 20); + pixie->GetChannelQDCsumOnOff(modID, ch) ? cbQDCsumOnOff->Select(1) : cbQDCsumOnOff->Select(0); + cbQDCsumOnOff->Connect("Selected(Int_t, Int_t)", "ChannelSetting", this, "ChangeQDCsumOnOff()"); + hframeQDCsumOnOff->AddFrame(cbQDCsumOnOff, new TGLayoutHints(kLHintsRight, 5,5,3,4)); + + TGLabel * lbQDCsumOnOff = new TGLabel(hframeQDCsumOnOff, "Trace On/Off"); + hframeQDCsumOnOff->AddFrame(lbQDCsumOnOff, new TGLayoutHints(kLHintsRight | kLHintsCenterY, 5, 5, 3, 4)); + } + double temp = pixie->GetChannelSetting(settingName[i][0].Data(), modID, ch, false); TGNumberFormat::EStyle digi = TGNumberFormat::kNESInteger; @@ -130,8 +178,11 @@ ChannelSetting::ChannelSetting(const TGWindow *p, UInt_t w, UInt_t h, Pixie16 * entry[i] = new TGNumberEntry(hframe[i], temp, 0, 0, digi, TGNumberFormat::kNEANonNegative); entry[i]->Resize(width, 20); - entry[i]->Connect("Modified()", "ChannelSetting", this, Form("ChangeID(=%d)", i)); - + if( i >= NUM_CHANNEL_SETTING - 3 ) { + entry[i]->SetState(false); + }else{ + entry[i]->Connect("Modified()", "ChannelSetting", this, Form("ChangeID(=%d)", i)); + } hframe[i]->AddFrame(entry[i], new TGLayoutHints(kLHintsRight, 5,5,3,4)); lb[i] = new TGLabel(hframe[i], settingName[i][0] + (settingName[i][2] != "" ? " [" + settingName[i][2] + "]" : "")); @@ -155,7 +206,10 @@ ChannelSetting::~ChannelSetting(){ delete modIDEntry; delete cbOnOff; - + delete cbTraceOnOff; + delete cbPolarity; + delete cbQDCsumOnOff; + for ( int i = 0; i < NUM_CHANNEL_SETTING; i++){ delete entry[i]; } @@ -176,11 +230,9 @@ void ChannelSetting::ChangeCh(){ int modID = modIDEntry->GetNumber(); int ch = chIDEntry->GetNumber(); - if( pixie->GetChannelOnOff(modID, ch) ){ - cbOnOff->Select(1); - }else{ - cbOnOff->Select(0); - } + pixie->GetChannelOnOff(modID, ch) ? cbOnOff->Select(1) : cbOnOff->Select(0); + pixie->GetChannelPolarity(modID, ch) ? cbPolarity->Select(1) : cbPolarity->Select(0); + pixie->GetChannelTraceOnOff(modID, ch) ? cbTraceOnOff->Select(1) : cbTraceOnOff->Select(0); for( int i = 0 ; i < NUM_CHANNEL_SETTING; i++){ double temp = pixie->GetChannelSetting(settingName[i][0].Data(), modID, ch, false); @@ -198,6 +250,33 @@ void ChannelSetting::ChangeOnOff(){ pixie->SaveSettings(pixie->GetSettingFile(modIDEntry->GetNumber())); } +void ChannelSetting::ChangePolarity(){ + short modID = modIDEntry->GetNumber(); + short ch = chIDEntry->GetNumber(); + int val = cbPolarity->GetSelected(); + + pixie->SetChannelPositivePolarity(val, modID, ch); + pixie->SaveSettings(pixie->GetSettingFile(modIDEntry->GetNumber())); +} + +void ChannelSetting::ChangeTraceOnOff(){ + short modID = modIDEntry->GetNumber(); + short ch = chIDEntry->GetNumber(); + int val = cbTraceOnOff->GetSelected(); + + pixie->SetChannelTraceOnOff(val, modID, ch); + pixie->SaveSettings(pixie->GetSettingFile(modIDEntry->GetNumber())); +} + +void ChannelSetting::ChangeQDCsumOnOff(){ + short modID = modIDEntry->GetNumber(); + short ch = chIDEntry->GetNumber(); + int val = cbQDCsumOnOff->GetSelected(); + + pixie->SetChannelQDCsumOnOff(val, modID, ch); + pixie->SaveSettings(pixie->GetSettingFile(modIDEntry->GetNumber())); +} + void ChannelSetting::ChangeID(int id){ short modID = modIDEntry->GetNumber(); short ch = chIDEntry->GetNumber(); diff --git a/channelSetting.h b/channelSetting.h index 8c3300b..e5baf52 100644 --- a/channelSetting.h +++ b/channelSetting.h @@ -21,6 +21,9 @@ private: TGNumberEntry * modIDEntry, * chIDEntry; TGComboBox * cbOnOff; + TGComboBox * cbPolarity; + TGComboBox * cbTraceOnOff; + TGComboBox * cbQDCsumOnOff; TGNumberEntry * entry[NUM_CHANNEL_SETTING]; @@ -36,6 +39,9 @@ public: void ChangeCh(); void ChangeOnOff(); + void ChangePolarity(); + void ChangeTraceOnOff(); + void ChangeQDCsumOnOff(); void ChangeID(int id); bool isOpened; diff --git a/moduleSetting.cpp b/moduleSetting.cpp index 4f03ecb..5fb1c0a 100644 --- a/moduleSetting.cpp +++ b/moduleSetting.cpp @@ -30,7 +30,7 @@ ModuleSetting::ModuleSetting(const TGWindow *p, UInt_t w, UInt_t h, Pixie16 * pi this->pixie = pixie; fMain = new TGMainFrame(p,w,h); - fMain->SetWindowName("Pixie16 Channel Settings "); + fMain->SetWindowName("Pixie16 Module Settings "); fMain->Connect("CloseWindow()", "ModuleSetting", this, "CloseWindow()"); TGVerticalFrame * vframe = new TGVerticalFrame(fMain); diff --git a/settingsSummary.cpp b/settingsSummary.cpp index c902897..71bad3e 100644 --- a/settingsSummary.cpp +++ b/settingsSummary.cpp @@ -18,7 +18,7 @@ SettingsSummary::SettingsSummary(const TGWindow *p, UInt_t w, UInt_t h, Pixie16 settingFileName = pixie->GetSettingFile(0); fMain = new TGMainFrame(p,w,h); - fMain->SetWindowName("Pixie16 Channel Settings "); + fMain->SetWindowName("Pixie16 Settings Summary"); fMain->Connect("CloseWindow()", "SettingsSummary", this, "CloseWindow()"); gClient->GetColorByName("red", red); @@ -56,18 +56,17 @@ SettingsSummary::SettingsSummary(const TGWindow *p, UInt_t w, UInt_t h, Pixie16 /// Setting int modID = modIDEntry->GetNumber(); - int numItems = 14; - TString labelText[numItems] = {"CH", "ON/off", "Gain", "Trig L", "Trig G", "Threshold", "Polarity", "Energy L", "Energy G", "Tau", "Trace Len", "Trace delay", "V offset", "BaseLine"}; - double width[numItems] = { 50, 50, 50, 60, 60, 80, 60, 60, 60, 60, 80, 80, 70, 80}; + int numItems = 15; + TString labelText[numItems] = {"CH", "ON/off", "Gain", "Trig L", "Trig G", "Threshold", "Polarity", "Energy L", "Energy G", "Tau", "Trace I/O", "Trace Len", "Trace delay", "V offset", "BaseLine"}; + double width[numItems] = { 50, 50, 50, 60, 60, 80, 60, 60, 60, 60, 50, 80, 80, 70, 80}; TGVerticalFrame *hframeSettings = new TGVerticalFrame(fMain, w, 600 ); fMain->AddFrame(hframeSettings, new TGLayoutHints(kLHintsCenterX, 2,2,2,2)); - + + ///---------- label row TGHorizontalFrame * hframeLabel = new TGHorizontalFrame(hframeSettings, w, 50); hframeSettings->AddFrame(hframeLabel, new TGLayoutHints(kLHintsExpandX, 2,2,2,2)); - 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); @@ -75,8 +74,8 @@ SettingsSummary::SettingsSummary(const TGWindow *p, UInt_t w, UInt_t h, Pixie16 hframeLabel->AddFrame(labelItems[i], new TGLayoutHints(kLHintsCenterX | kLHintsCenterY, 5, 5, 3, 4)); } - TGHorizontalFrame * hframeCh[MAXCH]; - + + TGHorizontalFrame * hframeCh[MAXCH]; for( int i = 0; i < MAXCH ; i ++){ //printf("-----------------------%d\n", i); @@ -165,18 +164,23 @@ SettingsSummary::SettingsSummary(const TGWindow *p, UInt_t w, UInt_t h, Pixie16 hframeCh[i]->AddFrame(neTau[i], new TGLayoutHints(kLHintsCenterX , 5, 5, 3, 4)); col++; - double tracelen = pixie->GetChannelTraceLength(modID, i); - if( pixie->GetChannelTraceOnOff(modID, i) == false ) tracelen = 0; - neTraceLength[i] = new TGNumberEntry(hframeCh[i], tracelen, 0, 0, TGNumberFormat::kNESRealTwo, TGNumberFormat::kNEANonNegative); + cbTraceOnOff[i] = new TGComboBox(hframeCh[i], i); + cbTraceOnOff[i]->AddEntry("On", 1); + cbTraceOnOff[i]->AddEntry("off", 0); + 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)); + + col++; + neTraceLength[i] = new TGNumberEntry(hframeCh[i], pixie->GetChannelTraceLength(modID, i), 0, 0, TGNumberFormat::kNESRealTwo, TGNumberFormat::kNEANonNegative); neTraceLength[i]->SetWidth(width[col]); neTraceLength[i]->SetLimits(TGNumberFormat::kNELLimitMinMax, 0, 20.0); neTraceLength[i]->Connect("Modified()", "SettingsSummary", this, Form("ChangeTraceLenght(=%d)", i)); hframeCh[i]->AddFrame(neTraceLength[i], new TGLayoutHints(kLHintsCenterX , 5, 5, 3, 4)); col++; - double tracedel = pixie->GetChannelTraceDelay(modID, i); - if( pixie->GetChannelTraceOnOff(modID, i) == false ) tracedel = 0; - neTraceDelay[i] = new TGNumberEntry(hframeCh[i], tracedel, 0, 0, TGNumberFormat::kNESRealTwo, TGNumberFormat::kNEANonNegative); + neTraceDelay[i] = new TGNumberEntry(hframeCh[i], pixie->GetChannelTraceDelay(modID, i), 0, 0, TGNumberFormat::kNESRealTwo, TGNumberFormat::kNEANonNegative); neTraceDelay[i]->SetWidth(width[col]); neTraceDelay[i]->SetLimits(TGNumberFormat::kNELLimitMinMax, 0, 20.0); neTraceDelay[i]->Connect("Modified()", "SettingsSummary", this, Form("ChangeTraceDelay(=%d)", i)); @@ -214,6 +218,7 @@ SettingsSummary::~SettingsSummary(){ delete cbOnOff[i] ; delete cbGain[i] ; delete cbPol[i] ; + delete cbTraceOnOff[i]; delete neTrigL[i] ; delete neTrigG[i] ; delete neThreshold[i] ; @@ -261,6 +266,13 @@ void SettingsSummary::ChangePol(unsigned short ch){ teFileName->SetText(settingFileName + " (not saved)"); } +void SettingsSummary::ChangeTraceOnOff(unsigned short ch){ + short modID = modIDEntry->GetNumber(); + int val = cbPol[ch]->GetSelected(); + pixie->SetChannelTraceOnOff(val, modID, ch); + teFileName->SetText(settingFileName + " (not saved)"); +} + void SettingsSummary::ChangeTrigL(unsigned short ch){ short modID = modIDEntry->GetNumber(); double val = neTrigL[ch]->GetNumber(); @@ -305,29 +317,14 @@ void SettingsSummary::ChangeTau(unsigned short ch){ void SettingsSummary::ChangeTraceLenght(unsigned short ch){ short modID = modIDEntry->GetNumber(); double val = neTraceLength[ch]->GetNumber(); - if( val > 0 ){ - pixie->SetChannelTraceOnOff(true, modID, ch); - pixie->SetChannelTraceLenght(val, modID, ch); - neTraceDelay[ch]->SetNumber(pixie->GetChannelTraceDelay(modID, ch)); - }else{ - pixie->SetChannelTraceOnOff(false, modID, ch); - neTraceDelay[ch]->SetNumber(0.); - } + pixie->SetChannelTraceLenght(val, modID, ch); teFileName->SetText(settingFileName + " (not saved)"); } void SettingsSummary::ChangeTraceDelay(unsigned short ch){ short modID = modIDEntry->GetNumber(); double val = neTraceDelay[ch]->GetNumber(); - - if( val > 0 ){ - pixie->SetChannelTraceOnOff(true, modID, ch); - pixie->SetChannelTraceDelay(val, modID, ch); - neTraceLength[ch]->SetNumber(pixie->GetChannelTraceLength(modID, ch)); - }else{ - pixie->SetChannelTraceOnOff(false, modID, ch); - neTraceLength[ch]->SetNumber(0.); - } + pixie->SetChannelTraceDelay(val, modID, ch); teFileName->SetText(settingFileName + " (not saved)"); } diff --git a/settingsSummary.h b/settingsSummary.h index 8ac950a..8313aee 100644 --- a/settingsSummary.h +++ b/settingsSummary.h @@ -27,6 +27,7 @@ private: TGComboBox * cbOnOff[MAXCH] ; TGComboBox * cbGain[MAXCH] ; TGComboBox * cbPol[MAXCH] ; + TGComboBox * cbTraceOnOff[MAXCH] ; TGLabel * lbCh[MAXCH]; TGNumberEntry * neTrigL[MAXCH] ; @@ -59,6 +60,7 @@ public: void ChangeOnOff(unsigned short ch); void ChangeGain(unsigned short ch); void ChangePol(unsigned short ch); + void ChangeTraceOnOff(unsigned short ch); void ChangeTrigL(unsigned short ch); void ChangeTrigG(unsigned short ch); void ChangeThreshold(unsigned short ch); diff --git a/test_ryan.set b/test_ryan.set index 2959d2a..5d13e86 100644 --- a/test_ryan.set +++ b/test_ryan.set @@ -669,7 +669,7 @@ 188 ], "QDCLen7": [ - 213, + 214, 213, 213, 213, @@ -1016,7 +1016,7 @@ "ChanNum": 0, "CoincPattern": 0, "CoincWait": 0, - "ControlTask": 0, + "ControlTask": 5, "CrateID": 0, "FIFOLength": 8188, "FastFilterRange": 0,