GSI Go4 Online Offline Object Orientedweb-docs.gsi.de/~go4/go4gside/chep2001/chep2001.pdf ·...

22
04.09.01 Go4 - http://go4.gsi.de 1 J. Adamczewski, M. Al-Turany, D. Bertini, H.G.Essel CHEP 2001 Multithreaded Inter-Task Communication with ROOT - writing non-blocking GUIs GSI Online Offline Object Oriented Go4

Transcript of GSI Go4 Online Offline Object Orientedweb-docs.gsi.de/~go4/go4gside/chep2001/chep2001.pdf ·...

Page 1: GSI Go4 Online Offline Object Orientedweb-docs.gsi.de/~go4/go4gside/chep2001/chep2001.pdf · 2015-04-30 · – creates a Qt independent main window (QMainWindow) – sets TQRootCanvas

04.09.01 Go4 - http://go4.gsi.de 1

J. Adamczewski, M. Al-Turany, D. Bertini, H.G.Essel

CHEP 2001

Multithreaded Inter-Task Communication with ROOT -writing non-blocking GUIs

GSIOnlineOfflineObjectOriented

Go4

Page 2: GSI Go4 Online Offline Object Orientedweb-docs.gsi.de/~go4/go4gside/chep2001/chep2001.pdf · 2015-04-30 · – creates a Qt independent main window (QMainWindow) – sets TQRootCanvas

04.09.01 Go4 - http://go4.gsi.de 2

Contents

• Go4: Software layers and architecture

• Go4 Requirements

• Multithreading (threadmanager library)

• Inter task communication (taskhandler library)

• Example: GUI task and analysis task

• GUI implemetation with ROOT-Qt Interface

• Demo (movie)

• Summary

Page 3: GSI Go4 Online Offline Object Orientedweb-docs.gsi.de/~go4/go4gside/chep2001/chep2001.pdf · 2015-04-30 · – creates a Qt independent main window (QMainWindow) – sets TQRootCanvas

04.09.01 Go4 - http://go4.gsi.de 3

Go4 Package Layers

ROOT FrameworkTThread

Go4 GUI (Server)

Go4 Event Analysis Loop (Client)

Qt LibraryInterface

Go4TaskHandler

Go4ThreadManager

Page 4: GSI Go4 Online Offline Object Orientedweb-docs.gsi.de/~go4/go4gside/chep2001/chep2001.pdf · 2015-04-30 · – creates a Qt independent main window (QMainWindow) – sets TQRootCanvas

04.09.01 Go4 - http://go4.gsi.de 4

Requirements of Go4

On-line Analysis with non blocking GUI

• Analysis based on ROOT

• Analysis runs permanently

• Analysis updates graphics asynchronously

• GUI is never blocked

• GUI controls and steers analysis

Page 5: GSI Go4 Online Offline Object Orientedweb-docs.gsi.de/~go4/go4gside/chep2001/chep2001.pdf · 2015-04-30 · – creates a Qt independent main window (QMainWindow) – sets TQRootCanvas

04.09.01 Go4 - http://go4.gsi.de 5

• Multithreading necessary

• ROOT classes not inherently thread save

���� lock object creation and ROOT services

���� nonblocking GUI and analysis: different tasks

• Communication between tasks

Problems to solve

Threadmanager library

Taskhandler library

Page 6: GSI Go4 Online Offline Object Orientedweb-docs.gsi.de/~go4/go4gside/chep2001/chep2001.pdf · 2015-04-30 · – creates a Qt independent main window (QMainWindow) – sets TQRootCanvas

04.09.01 Go4 - http://go4.gsi.de 6

Go4 Multitasking system

• Only one working thread per task(object creation, memory allocation, ROOT system calls)

• Analysis and GUI in separate tasks(non blocking GUI, continuous analysis)

• Communication:

• raw socket transport(dedicated threads with TBuffer fields in TGo4Socket)

• Object streaming by ROOT(working thread uses TGo4Queue methods)

Page 7: GSI Go4 Online Offline Object Orientedweb-docs.gsi.de/~go4/go4gside/chep2001/chep2001.pdf · 2015-04-30 · – creates a Qt independent main window (QMainWindow) – sets TQRootCanvas

04.09.01 Go4 - http://go4.gsi.de 7

Functional overview

CommandThread

StatusThread

DataThread

CommandThread

StatusThread

DataThread

WorkThread

WatcherThread

LoggingThread

ConnectorThread

LaunchThread

GUIUseraction

DataLoop

queu

e

queu

e

queu

e

queu

e

queu

e

queu

e

IP Network

DrawingThread

Display Task (Server)

Analysis Tasks (Client 1,2,...)

Task

Han

dler

Task

Han

dler

Page 8: GSI Go4 Online Offline Object Orientedweb-docs.gsi.de/~go4/go4gside/chep2001/chep2001.pdf · 2015-04-30 · – creates a Qt independent main window (QMainWindow) – sets TQRootCanvas

04.09.01 Go4 - http://go4.gsi.de 8

Go4 GUI

• Complex GUI• Rapid prototyping

• Go4 GUI architecture:– signal-slot mechanism (both Qt and ROOT)

– gui singleton: registry + dispatcher (modified mediator pattern)

– persistent status objects per window

Qt graphics libraryprofessional, powerful, free,tools (QtDesigner), well documented

}

• Use ROOT and Qt together!no changes to ROOT sources

Page 9: GSI Go4 Online Offline Object Orientedweb-docs.gsi.de/~go4/go4gside/chep2001/chep2001.pdf · 2015-04-30 · – creates a Qt independent main window (QMainWindow) – sets TQRootCanvas

04.09.01 Go4 - http://go4.gsi.de 9

QROOTApplication

QTimer

TQROOTCanvasQWidget

TCanvas

TQROOTCanvasQWidget

TCanvas

TQROOTCanvasQWidget

TCanvas

QApplication

Go4 GUI: Qt-ROOT interface

Qt Eventloop

QApplication::Exec()

ROOT EventloopTSystem::InnerLoop()

TApplicationTQApplication

TRootGuiFactory

TQRootGuiFactory

TCanvasImpTQCanvasImp

TTimer TThread

TSocket other...QWidgetQWidget

Page 10: GSI Go4 Online Offline Object Orientedweb-docs.gsi.de/~go4/go4gside/chep2001/chep2001.pdf · 2015-04-30 · – creates a Qt independent main window (QMainWindow) – sets TQRootCanvas

04.09.01 Go4 - http://go4.gsi.de 10

Go4 GUI: Qt-ROOT interface

• Follows the general ROOT GUI ABC– no changes in ROOT source necessary

• Inheritance from ROOT base classes– TQRootGuiFactory (TRootGuiFactory)

– Qt Factory GUI components– TQCanvasImp (TCanvasImp)

– creates a Qt independent main window (QMainWindow)

– sets TQRootCanvas as a central widget

– TQApplication (TApplication)– ROOT environment set with a Qt GUI factory

• Inheritance from Qt base class– QRootApplication (QApplication)

– enable Qt evt-loop to drive Qt based GUI applications

– call ROOT inner loop repeatedly to enable ROOT system events

Page 11: GSI Go4 Online Offline Object Orientedweb-docs.gsi.de/~go4/go4gside/chep2001/chep2001.pdf · 2015-04-30 · – creates a Qt independent main window (QMainWindow) – sets TQRootCanvas

04.09.01 Go4 - http://go4.gsi.de 11

Qt Designer screenshot

Page 12: GSI Go4 Online Offline Object Orientedweb-docs.gsi.de/~go4/go4gside/chep2001/chep2001.pdf · 2015-04-30 · – creates a Qt independent main window (QMainWindow) – sets TQRootCanvas

04.09.01 Go4 - http://go4.gsi.de 12

Using Qt designer

Page 13: GSI Go4 Online Offline Object Orientedweb-docs.gsi.de/~go4/go4gside/chep2001/chep2001.pdf · 2015-04-30 · – creates a Qt independent main window (QMainWindow) – sets TQRootCanvas

04.09.01 Go4 - http://go4.gsi.de 13

Qt GUI

Widgets

StatusSlots

Root GUI

Widgets

StatusSlots

GUISingletonregistry

command dispatcherstatus mediator

Go4 GUI design

Displaytaskhandler

server

update

commands

register(dependency)

data IP

to analysis

Qt GUI

Widgets

StatusSlots

Qt GUI

Widgets

StatusSlots

Page 14: GSI Go4 Online Offline Object Orientedweb-docs.gsi.de/~go4/go4gside/chep2001/chep2001.pdf · 2015-04-30 · – creates a Qt independent main window (QMainWindow) – sets TQRootCanvas

04.09.01 Go4 - http://go4.gsi.de 14

Summary

• Go4 thread manager package

• Go4 task handler package

• Go4 Qt-ROOT interface

ready to use for any ROOT application

• Client task could be analysis framework, slow ctrl,...

• GUI task can use Qt graphics library

• Go4 analysis framework and GUI is being under development...

http://go4.gsi.de

Page 15: GSI Go4 Online Offline Object Orientedweb-docs.gsi.de/~go4/go4gside/chep2001/chep2001.pdf · 2015-04-30 · – creates a Qt independent main window (QMainWindow) – sets TQRootCanvas

04.09.01 Go4 - http://go4.gsi.de 15

Go4 demo

localobjects

Control panel

monitoredhistograms

remoteobjects

analysisstatus

ROOTcanvas

Page 16: GSI Go4 Online Offline Object Orientedweb-docs.gsi.de/~go4/go4gside/chep2001/chep2001.pdf · 2015-04-30 · – creates a Qt independent main window (QMainWindow) – sets TQRootCanvas

04.09.01 Go4 - http://go4.gsi.de 16

Go4 demo

• Initializing a remote analysis

• Control of analysis: run status, list object folders

• Monitor remote histograms continuously

• Get and update local object copies

• Working on local histograms (fit panel, save)

• ROOT TBrowser works in parallel

• Go4 Browser plots: superimpose, multiwindow

Page 17: GSI Go4 Online Offline Object Orientedweb-docs.gsi.de/~go4/go4gside/chep2001/chep2001.pdf · 2015-04-30 · – creates a Qt independent main window (QMainWindow) – sets TQRootCanvas

04.09.01 Go4 - http://go4.gsi.de 17

Go4 demo

Page 18: GSI Go4 Online Offline Object Orientedweb-docs.gsi.de/~go4/go4gside/chep2001/chep2001.pdf · 2015-04-30 · – creates a Qt independent main window (QMainWindow) – sets TQRootCanvas

04.09.01 Go4 - http://go4.gsi.de 18

Go4 demo

Page 19: GSI Go4 Online Offline Object Orientedweb-docs.gsi.de/~go4/go4gside/chep2001/chep2001.pdf · 2015-04-30 · – creates a Qt independent main window (QMainWindow) – sets TQRootCanvas

04.09.01 Go4 - http://go4.gsi.de 19

Go4 demo

Page 20: GSI Go4 Online Offline Object Orientedweb-docs.gsi.de/~go4/go4gside/chep2001/chep2001.pdf · 2015-04-30 · – creates a Qt independent main window (QMainWindow) – sets TQRootCanvas

04.09.01 Go4 - http://go4.gsi.de 20

Go4 demo

Page 21: GSI Go4 Online Offline Object Orientedweb-docs.gsi.de/~go4/go4gside/chep2001/chep2001.pdf · 2015-04-30 · – creates a Qt independent main window (QMainWindow) – sets TQRootCanvas

04.09.01 Go4 - http://go4.gsi.de 21

Go4 demo

regular ROOT TBrowser,works together with Qt

Page 22: GSI Go4 Online Offline Object Orientedweb-docs.gsi.de/~go4/go4gside/chep2001/chep2001.pdf · 2015-04-30 · – creates a Qt independent main window (QMainWindow) – sets TQRootCanvas

04.09.01 Go4 - http://go4.gsi.de 22

Go4 demo