// // A Simple GUI to analyse trigger alignment data // A pop-up window to choose Correlation channels // class CorrelationFrame { RQ_OBJECT("CorrelationFrame") public: CorrelationFrame(const TGWindow *p, const TGWindow *main, UInt_t w, UInt_t h); virtual ~CorrelationFrame(); void DoClear(void); void DoReturnDefaults(void); void DoExit(void); private: // Main frames TGTransientFrame *CorrelationMainFrame; // Exit and save configuration buttons TGTextButton *ButtonExit; TGTextButton *ButtonClearChoices; TGTextButton *ButtonReturnDefaults; TGCheckButton *Correlations[ 24 ][ 24 ]; // Labels TGLabel *Text_1; TGLabel *Text_InputA[ 24 ]; TGLabel *Text_InputB[ 24 ]; TGLabel *Text_ParTitle; TGLabel *Text_Threshold; TGLabel *Text_CorrelationLimit; TGNumberEntry *NumberEntry_Threshold; TGNumberEntry *NumberEntry_CorrelationLimit; }; // Constructor CorrelationFrame::CorrelationFrame(const TGWindow *p, const TGWindow *main, UInt_t w, UInt_t h){ //NL0inputs = NL0inputs_in; CorrelationMainFrame = new TGTransientFrame(p, main, w, h); CorrelationMainFrame->SetLayoutBroken(kTRUE); CorrelationMainFrame->SetWindowName("Select Correlations to run"); CorrelationMainFrame->Connect("CloseWindow()", "CorrelationFrame", this, "DoExit()"); CorrelationMainFrame->DontCallClose(); // to avoid double deletions. // use hierarchical cleaning CorrelationMainFrame->SetCleanup(kTRUE); // Button: quit input configuration and save in exit ButtonExit = new TGTextButton(CorrelationMainFrame,"Exit and save"); ButtonExit->Connect("Clicked()","CorrelationFrame",this,"DoExit()"); ButtonExit->SetTextJustify(36); ButtonExit->SetMargins(0,0,0,0); ButtonExit->SetWrapLength(-1); CorrelationMainFrame->AddFrame(ButtonExit, new TGLayoutHints(kLHintsLeft | kLHintsTop,2,2,2,2)); ButtonExit->MoveResize(10,590,580,30); // Button: clear Choices ButtonClearChoices = new TGTextButton(CorrelationMainFrame,"Clear Correlation Choices"); ButtonClearChoices->Connect("Clicked()","CorrelationFrame",this,"DoClear()"); ButtonClearChoices->SetTextJustify(36); ButtonClearChoices->SetMargins(0,0,0,0); ButtonClearChoices->SetWrapLength(-1); CorrelationMainFrame->AddFrame(ButtonClearChoices, new TGLayoutHints(kLHintsLeft | kLHintsTop,2,2,2,2)); ButtonClearChoices->MoveResize(10,555,280,30); // Button: return default Choices ButtonReturnDefaults = new TGTextButton(CorrelationMainFrame,"Return defaults"); ButtonReturnDefaults->Connect("Clicked()","CorrelationFrame",this,"DoReturnDefaults()"); ButtonReturnDefaults->SetTextJustify(36); ButtonReturnDefaults->SetMargins(0,0,0,0); ButtonReturnDefaults->SetWrapLength(-1); CorrelationMainFrame->AddFrame(ButtonReturnDefaults, new TGLayoutHints(kLHintsLeft | kLHintsTop,2,2,2,2)); ButtonReturnDefaults->MoveResize(310,555,280,30); Int_t xshift = 50; Int_t yshift = 10; // Text above list Text_1 = new TGLabel(CorrelationMainFrame, "Input [A] x [B] correlation selections:"); Text_1->MoveResize(135+xshift,yshift,200,30); //Checkbox Creation Loop TString HelpText = ""; for(int i1 = 0; i1<24; i1++){ for(int j1 = 0; j1ReturnTriggerName(i1) ); HelpText.Append( " (" ) ; HelpText.Append( guiGlobals->GetDetectorName(i1) ); HelpText.Append( ") to " ); HelpText.Append( guiGlobals->ReturnTriggerName(j1) ); HelpText.Append( " (" ) ; HelpText.Append( guiGlobals->GetDetectorName(j1) ); HelpText.Append( ")" ); Correlations[i1][j1] = new TGCheckButton( CorrelationMainFrame ); Correlations[i1][j1]->SetToolTipText( HelpText, 250); if(guiGlobals->GetCorrelation(i1,j1)==0) { Correlations[i1][j1]->SetState(kFALSE); } if(guiGlobals->GetCorrelation(i1,j1)==1) { Correlations[i1][j1]->SetState(kTRUE); } Correlations[i1][j1]->MoveResize(xshift+(i1-1)*20,65+yshift+(j1-1)*20,25,25); if(i1==j1){ Correlations[i1][j1]->SetDisabledAndSelected(kFALSE); } } Text_InputA[ i1 ] = new TGLabel( CorrelationMainFrame ); TString Name = guiGlobals->ReturnTriggerName(i1); char number[10]; sprintf(number,"%i",i1+1); Name.Prepend(": "); Name.Prepend(number); Text_InputA[ i1 ]->SetText( Name ); Text_InputA[ i1 ]->SetTextJustify(kTextLeft); Text_InputA[ i1 ]->MoveResize(xshift+10+23*20,66+yshift+(i1-1)*20,100,25); Text_InputB[ i1 ] = new TGLabel( CorrelationMainFrame ); char number[10]; sprintf(number,"%i",i1+1); Text_InputB[ i1 ]->SetText( number ); Text_InputB[ i1 ]->SetTextJustify(kTextCenterX); Text_InputB[ i1 ]->MoveResize(xshift-2+(i1-1)*20,25+yshift,20,25); } //Two-parameter input fields: text Text_ParTitle = new TGLabel(CorrelationMainFrame, "Auto Alignment Check Parameters:"); Text_ParTitle->SetTextJustify(kTextLeft); Text_ParTitle->MoveResize(xshift-20,yshift+440,200,25); Text_Threshold = new TGLabel(CorrelationMainFrame, "Calculation Threshold:"); Text_Threshold->SetTextJustify(kTextLeft); Text_Threshold->MoveResize(xshift-20,yshift+470,150,25); Text_CorrelationLimit = new TGLabel(CorrelationMainFrame, "Correlation Trigger limit:"); Text_CorrelationLimit->SetTextJustify(kTextLeft); Text_CorrelationLimit->MoveResize(xshift-20,yshift+500,150,25); //Fields NumberEntry_Threshold = new TGNumberEntry(CorrelationMainFrame, guiGlobals->GetThreshold(), 9,999, TGNumberFormat::kNESInteger, TGNumberFormat::kNEANonNegative, TGNumberFormat::kNELLimitMinMax,1, 15); CorrelationMainFrame->AddFrame(NumberEntry_Threshold, new TGLayoutHints(kLHintsLeft | kLHintsTop,2,2,2,2)); NumberEntry_Threshold->MoveResize(xshift+125,yshift+470,80,25); NumberEntry_CorrelationLimit = new TGNumberEntry(CorrelationMainFrame, guiGlobals->GetCorrelationLimit(), 9,999, TGNumberFormat::kNESRealThree, TGNumberFormat::kNEANonNegative, TGNumberFormat::kNELLimitMinMax,0, 1); CorrelationMainFrame->AddFrame(NumberEntry_CorrelationLimit, new TGLayoutHints(kLHintsLeft | kLHintsTop,2,2,2,2)); NumberEntry_CorrelationLimit->MoveResize(xshift+125,yshift+500,80,25); // setups CorrelationMainFrame->MapSubwindows(); CorrelationMainFrame->MapWindow(); CorrelationMainFrame->CenterOnParent(); } // End Frame // Clear all choices. void CorrelationFrame::DoClear(){ for(int i1 = 0; i1<24; i1++){ for(int j1 = 0; j1SetState(kFALSE); } } } // Return to Defaults. void CorrelationFrame::DoReturnDefaults(){ guiGlobals->SetCorrelationDefaults(); NumberEntry_Threshold->SetIntNumber ( guiGlobals->GetThreshold() ); NumberEntry_CorrelationLimit->SetNumber ( guiGlobals->GetCorrelationLimit() ); for(int i1 = 0; i1<24; i1++){ for(int j1 = 0; j1GetCorrelation(i1,j1)==0) { Correlations[i1][j1]->SetState(kFALSE); } if(guiGlobals->GetCorrelation(i1,j1)==1) { Correlations[i1][j1]->SetState(kTRUE); } } } } CorrelationFrame::~CorrelationFrame() { // Delete window - destructor delete this; } // EXIT, update global variables accordingly when doing so. void CorrelationFrame::DoExit(){ for(int i1 = 0; i1<24; i1++){ for(int j1 = 0; j1IsOn()) { guiGlobals->SetCorrelation(i1,j1,1); } if(!Correlations[i1][j1]->IsOn()) { guiGlobals->SetCorrelation(i1,j1,0); } } } guiGlobals->SetCorrelationLimit( NumberEntry_CorrelationLimit->GetNumber() ); guiGlobals->SetThreshold( NumberEntry_Threshold->GetIntNumber() ); CorrelationMainFrame->DeleteWindow(); }