#include #include #include #include #include #include #include #include #include #include "channelSetting.h" //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"}, {"ENERGY_RISETIME", "1", "us"}, {"ENERGY_FLATTOP", "1", "us"}, {"TAU", "2", "us"}, {"TRACE_LENGTH", "2", "us"}, {"TRACE_DELAY", "2", "us"}, {"VOFFSET", "2", "V"}, {"XDT", "2", "us"}, {"BASELINE_PERCENT", "0", "%"}, {"BASELINE_AVERAGE", "0", ""}, {"BLCUT", "0", ""}, {"EMIN", "0", ""}, {"MultiplicityMaskL", "0", ""}, {"MultiplicityMaskH", "0", ""}, {"CHANNEL_CSRA", "0", ""}}; ChannelSetting::ChannelSetting(const TGWindow *p, UInt_t w, UInt_t h, Digitizer ** digi, int nDigi){ this->digi = digi; fMain = new TGMainFrame(p,w,h); fMain->SetWindowName("Channel Settings "); fMain->Connect("CloseWindow()", "ChannelSetting", this, "CloseWindow()"); TGVerticalFrame * vframe = new TGVerticalFrame(fMain); fMain->AddFrame(vframe, new TGLayoutHints(kLHintsCenterX, 2,2,2,2)); ///==========Board choose TGHorizontalFrame *hframe0 = new TGHorizontalFrame(vframe, w, 50 ); vframe->AddFrame(hframe0, new TGLayoutHints(kLHintsCenterX, 2,2,2,2)); TGLabel * lb0 = new TGLabel(hframe0, "Module ID :"); hframe0->AddFrame(lb0, new TGLayoutHints(kLHintsCenterX | kLHintsCenterY, 5, 5, 3, 4)); boardIDEntry = new TGNumberEntry(hframe0, 0, 0, 0, TGNumberFormat::kNESInteger, TGNumberFormat::kNEANonNegative); boardIDEntry->SetWidth(50); boardIDEntry->SetLimits(TGNumberFormat::kNELLimitMinMax, 0, nDigi); boardIDEntry->Connect("Modified()", "ChannelSetting", this, "ChangeBoard()"); if( nDigi <= 1 ) boardIDEntry->SetState(false); NChannel = 16 ;// digi[0]->GetNChannel(); hframe0->AddFrame(boardIDEntry, new TGLayoutHints(kLHintsCenterX , 5, 5, 3, 4)); TGLabel * lb1 = new TGLabel(hframe0, "Channel :"); hframe0->AddFrame(lb1, new TGLayoutHints(kLHintsCenterX | kLHintsCenterY, 5, 5, 3, 4)); chIDEntry = new TGNumberEntry(hframe0, 0, 0, 0, TGNumberFormat::kNESInteger, TGNumberFormat::kNEANonNegative); chIDEntry->SetWidth(50); chIDEntry->SetLimits(TGNumberFormat::kNELLimitMinMax, 0, NChannel-1); chIDEntry->Connect("Modified()", "ChannelSetting", this, "ChangeCh()"); hframe0->AddFrame(chIDEntry, new TGLayoutHints(kLHintsCenterX , 5, 5, 3, 4)); int boardID = boardIDEntry->GetNumber(); int ch = chIDEntry->GetNumber(); int width = 80; ///----------- on/off TGHorizontalFrame *hframeOnOff = new TGHorizontalFrame(vframe, 50, 50 ); vframe->AddFrame(hframeOnOff, new TGLayoutHints(kLHintsRight, 2,2,2,2)); cbOnOff = new TGComboBox(hframeOnOff); cbOnOff->AddEntry("ON", 1); cbOnOff->AddEntry("off", 0); cbOnOff->Resize(width, 20); //pixie->GetChannelOnOff(boardID, 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(boardID, 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]; for( int i = 0 ; i < NUM_CHANNEL_SETTING; i++){ 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(boardID, 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)); } double temp = 0; // pixie->GetChannelSetting(settingName[i][0].Data(), boardID, ch, false); TGNumberFormat::EStyle digi = TGNumberFormat::kNESInteger; if( settingName[i][1] == "0" ) digi = TGNumberFormat::kNESInteger; if( settingName[i][1] == "1" ) digi = TGNumberFormat::kNESRealOne; if( settingName[i][1] == "2" ) digi = TGNumberFormat::kNESRealTwo; if( settingName[i][1] == "3" ) digi = TGNumberFormat::kNESRealThree; entry[i] = new TGNumberEntry(hframe[i], temp, 0, 0, digi, TGNumberFormat::kNEANonNegative); entry[i]->Resize(width, 20); 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] + "]" : "")); hframe[i]->AddFrame(lb[i], new TGLayoutHints(kLHintsRight | kLHintsCenterY, 5, 5, 3, 4)); } fMain->MapSubwindows(); fMain->Resize(fMain->GetDefaultSize()); fMain->MapWindow(); isOpened = true; } ChannelSetting::~ChannelSetting(){ isOpened = false; delete boardIDEntry; delete cbOnOff; delete cbTraceOnOff; delete cbPolarity; for ( int i = 0; i < NUM_CHANNEL_SETTING; i++){ delete entry[i]; } /// fMain must be delete last; fMain->Cleanup(); delete fMain; } void ChannelSetting::ChangeBoard(){ ChangeCh(); } void ChannelSetting::ChangeCh(){ int boardID = boardIDEntry->GetNumber(); int ch = chIDEntry->GetNumber(); //pixie->GetChannelOnOff(boardID, ch) ? cbOnOff->Select(1) : cbOnOff->Select(0); //pixie->GetChannelPolarity(boardID, ch) ? cbPolarity->Select(1) : cbPolarity->Select(0); //pixie->GetChannelTraceOnOff(boardID, ch) ? cbTraceOnOff->Select(1) : cbTraceOnOff->Select(0); for( int i = 0 ; i < NUM_CHANNEL_SETTING; i++){ double temp = 0 ;//pixie->GetChannelSetting(settingName[i][0].Data(), boardID, ch, false); entry[i]->SetNumber(temp ); } } void ChannelSetting::ChangeOnOff(){ short boardID = boardIDEntry->GetNumber(); short ch = chIDEntry->GetNumber(); int val = cbOnOff->GetSelected(); //pixie->SetChannelOnOff(val, boardID, ch); //pixie->SaveSettings(pixie->GetSettingFile(boardIDEntry->GetNumber())); } void ChannelSetting::ChangePolarity(){ short boardID = boardIDEntry->GetNumber(); short ch = chIDEntry->GetNumber(); int val = cbPolarity->GetSelected(); //pixie->SetChannelPositivePolarity(val, boardID, ch); //pixie->SaveSettings(pixie->GetSettingFile(boardIDEntry->GetNumber())); } void ChannelSetting::ChangeTraceOnOff(){ short boardID = boardIDEntry->GetNumber(); short ch = chIDEntry->GetNumber(); int val = cbTraceOnOff->GetSelected(); //pixie->SetChannelTraceOnOff(val, boardID, ch); //pixie->SaveSettings(pixie->GetSettingFile(boardIDEntry->GetNumber())); } void ChannelSetting::ChangeID(int id){ short boardID = boardIDEntry->GetNumber(); short ch = chIDEntry->GetNumber(); double val = entry[id]->GetNumber(); //pixie->SetChannelSetting(settingName[id][0].Data(), val, boardID, ch, 1); //pixie->SaveSettings(pixie->GetSettingFile(boardIDEntry->GetNumber())); }