#include #include using namespace std; #include #include "bcv_mainframe.h" #include "bcview.h" #include #include #include #include #include #include #include extern JApplication *japp; TGeoVolume *MOTHER = NULL; TGeoCombiTrans *MotherRotTrans = NULL; bool GO = false; // true=continuously display events false=wait for user int DOT_SOURCE; // 1=section 2=shower 3=none int Z_SOURCE; // 1=TDC 2=ADC int AMP_SOURCE; // 1=Raw 2=Calibrated int POSITION_WEIGHT; // 1=linear 2=logarithmic //------------------- // Constructor //------------------- bcv_mainframe::bcv_mainframe(const TGWindow *p, UInt_t w, UInt_t h):TGMainFrame(p,w,h) { UInt_t canvas_width = w - 100; UInt_t canvas_height = w/2; // Frame for canvas and sidebar controls TGHorizontalFrame *middleframe = new TGHorizontalFrame(this, w, canvas_height); AddFrame(middleframe, new TGLayoutHints(kLHintsCenterX, 2,2,2,2)); // Main canvas for drawing everything emcanvas = new TRootEmbeddedCanvas("Main Canvas",middleframe,canvas_width, canvas_height, kSunkenFrame, GetWhitePixel()); emcanvas->SetScrolling(TGCanvas::kCanvasNoScroll); middleframe->AddFrame(emcanvas, new TGLayoutHints(kLHintsLeft | kLHintsCenterY)); // Sidebar controls frame TGVerticalFrame *sidebuttonframe = new TGVerticalFrame(middleframe, w-canvas_width, canvas_height); middleframe->AddFrame(sidebuttonframe, new TGLayoutHints(kLHintsRight, 5,5,5,5)); // Section or Shower TGVButtonGroup *sec_show = new TGVButtonGroup(sidebuttonframe,"Dots are center of:"); sec_show->Connect("Clicked(Int_t)","bcv_mainframe", this, "DoSelectDotSource(int)"); sidebuttonframe->AddFrame(sec_show, new TGLayoutHints(kLHintsTop)); new TGRadioButton(sec_show, "Section"); TGRadioButton *shower_button = new TGRadioButton(sec_show, "Shower"); new TGRadioButton(sec_show, "None"); shower_button->SetDown(true, true); sec_show->Show(); // TDC or ADC TGVButtonGroup *tdc_adc = new TGVButtonGroup(sidebuttonframe,"Z-pos. derived from:"); tdc_adc->Connect("Clicked(Int_t)","bcv_mainframe", this, "DoSelectZSource(int)"); sidebuttonframe->AddFrame(tdc_adc, new TGLayoutHints(kLHintsTop)); new TGRadioButton(tdc_adc, "TDC"); TGRadioButton *adc_button = new TGRadioButton(tdc_adc, "ADC"); adc_button->SetDown(true, true); tdc_adc->Show(); // RAW or calibrated amplitudes TGVButtonGroup *raw_cal = new TGVButtonGroup(sidebuttonframe,"Amplitude Source:"); raw_cal->Connect("Clicked(Int_t)","bcv_mainframe", this, "DoSelectAmplitudeSource(int)"); sidebuttonframe->AddFrame(raw_cal, new TGLayoutHints(kLHintsTop)); TGRadioButton *raw_button = new TGRadioButton(raw_cal, "Raw"); new TGRadioButton(raw_cal, "Calibrated"); raw_button->SetDown(true, true); raw_cal->Show(); // Linear or Logarithmic weighting TGVButtonGroup *lin_log = new TGVButtonGroup(sidebuttonframe,"Shower position:"); lin_log->Connect("Clicked(Int_t)","bcv_mainframe", this, "DoSelectLinLog(int)"); sidebuttonframe->AddFrame(lin_log, new TGLayoutHints(kLHintsTop)); TGRadioButton *lin_button = new TGRadioButton(lin_log, "Linear"); new TGRadioButton(lin_log, "Logarithmic"); lin_button->SetDown(true, true); lin_log->Show(); // Buttons frame TGHorizontalFrame *buttonframe = new TGHorizontalFrame(this, w, 50); AddFrame(buttonframe, new TGLayoutHints(kLHintsCenterX, 5,5,5,5)); TGTextButton *quit = new TGTextButton(buttonframe, "&Quit"); TGTextButton *next = new TGTextButton(buttonframe, "&Next"); TGTextButton *stop = new TGTextButton(buttonframe, "&Stop"); TGTextButton *cont = new TGTextButton(buttonframe, "&Cont"); quit->Connect("Clicked","bcv_mainframe", this, "DoQuit()"); next->Connect("Clicked","bcv_mainframe", this, "DoNext()"); stop->Connect("Clicked","bcv_mainframe", this, "DoStop()"); cont->Connect("Clicked","bcv_mainframe", this, "DoCont()"); buttonframe->AddFrame(next, new TGLayoutHints(kLHintsLeft, 2,2,2,2)); buttonframe->AddFrame(stop, new TGLayoutHints(kLHintsLeft, 2,2,2,2)); buttonframe->AddFrame(cont, new TGLayoutHints(kLHintsLeft, 2,2,2,2)); buttonframe->AddFrame(quit, new TGLayoutHints(kLHintsRight, 2,2,2,2)); // Set up timer to call the DoTimer() method repeatedly // so events can be automatically advanced. timer = new TTimer(); timer->Connect("Timeout()", "bcv_mainframe", this, "DoTimer()"); timer->Start(0, kFALSE); SetWindowName("BCAL Event Viewer"); SetIconName("BCView"); MapSubwindows(); Resize(GetDefaultSize()); MapWindow(); maincanvas = emcanvas->GetCanvas(); maincanvas->cd(0); maincanvas->Range(0.0, 0.0, 600, 600/2); current_runnumber = 0; run_text = new TText(10.0, 25.0," Run: "); run_text->Draw(); current_eventnumber = 0; event_text = new TText(10.0, 10.0,"Event: "); event_text->Draw(); } //------------------- // DoQuit //------------------- void bcv_mainframe::DoQuit(void) { japp->Quit(); gApplication->Terminate(0); } //------------------- // DoNext //------------------- void bcv_mainframe::DoNext(void) { eventloop->OneEvent(); } //------------------- // DoPrev //------------------- void bcv_mainframe::DoPrev(void) { //eventloop->GotoEvent(current_eventnumber-1); eventloop->OneEvent(); } //------------------- // DoStop //------------------- void bcv_mainframe::DoStop(void) { GO = 0; } //------------------- // DoCont //------------------- void bcv_mainframe::DoCont(void) { GO = 1; } //------------------- // DoSelectDotSource //------------------- void bcv_mainframe::DoSelectDotSource(int val) { DOT_SOURCE = val; } //------------------- // DoSelectZSource //------------------- void bcv_mainframe::DoSelectZSource(int val) { Z_SOURCE = val; } //------------------- // DoSelectAmplitudeSource //------------------- void bcv_mainframe::DoSelectAmplitudeSource(int val) { AMP_SOURCE = val; } //------------------- // DoSelectLinLog //------------------- void bcv_mainframe::DoSelectLinLog(int val) { POSITION_WEIGHT = val; } //------------------- // DoTimer //------------------- void bcv_mainframe::DoTimer(void) { /// This gets called periodically (value is set in constructor) /// It is used to automatically call DoNext() periodically /// so long as the global GO is set to 1. timer->TurnOff(); if(GO)DoNext(); timer->TurnOn(); } //------------------- // SetRun //------------------- void bcv_mainframe::SetRun(int runNumber) { // NOTE: Do NOT call the Draw() method here! It will // cause the program to get progressively slower. The // label will be updated automatically at the next // maincanvas->Update() call. char str[256]; sprintf(str," Run: %5d", runNumber); run_text->SetTitle(str); current_runnumber = runNumber; } //------------------- // SetEvent //------------------- void bcv_mainframe::SetEvent(int eventNumber) { // NOTE: Do NOT call the Draw() method here! It will // cause the program to get progressively slower. The // label will be updated automatically at the next // maincanvas->Update() call. char str[256]; sprintf(str,"Event: %5d", eventNumber); event_text->SetTitle(str); //event_text->Draw(); current_eventnumber = eventNumber; }