frameworks and common packages - laser...
TRANSCRIPT
![Page 1: Frameworks and Common Packages - LASER Foundationlaser.inf.ethz.ch/2013/material/mato/Mato-Lecture3.pdf · E.g. a GUI framework based on signal-slot can be used to build GUI ... Starting](https://reader034.vdocument.in/reader034/viewer/2022042915/5f525c5ebb457d6de95fedbf/html5/thumbnails/1.jpg)
Lecture 3
Frameworks and Common PackagesLASER Summer School on Software Engineering 2013, Elba Island, ItalyPere Mato/CERN
1
Monday, September 9, 13
![Page 2: Frameworks and Common Packages - LASER Foundationlaser.inf.ethz.ch/2013/material/mato/Mato-Lecture3.pdf · E.g. a GUI framework based on signal-slot can be used to build GUI ... Starting](https://reader034.vdocument.in/reader034/viewer/2022042915/5f525c5ebb457d6de95fedbf/html5/thumbnails/2.jpg)
Frameworks
2
Applications
Event DetDesc.
Calib.
Experiment Framework
Simulation AnalysisDataMngmt.
Core Libraries
non-HEP specificsoftware packages
Monday, September 9, 13
![Page 3: Frameworks and Common Packages - LASER Foundationlaser.inf.ethz.ch/2013/material/mato/Mato-Lecture3.pdf · E.g. a GUI framework based on signal-slot can be used to build GUI ... Starting](https://reader034.vdocument.in/reader034/viewer/2022042915/5f525c5ebb457d6de95fedbf/html5/thumbnails/3.jpg)
✤ A software framework is an abstraction in which common code providing generic functionality can be selectively overridden or specialized by user code providing specific functionality.
✤ A software framework is similar to software libraries in that they are reusable abstractions of code wrapped in a well-defined API✤ Typically the framework “calls” the user provided adaptations for specific
functionality ✤ Is the realization of a software architecture and facilitates software re-
use
Software Framework
3
In practice: a skeleton of an application into which developers plug in their code and provides most of the common functionality
Monday, September 9, 13
![Page 4: Frameworks and Common Packages - LASER Foundationlaser.inf.ethz.ch/2013/material/mato/Mato-Lecture3.pdf · E.g. a GUI framework based on signal-slot can be used to build GUI ... Starting](https://reader034.vdocument.in/reader034/viewer/2022042915/5f525c5ebb457d6de95fedbf/html5/thumbnails/4.jpg)
✤ A single Framework does for fit everywhere ✤ Each software domain provides its specialized framework
✤ E.g. a GUI framework based on signal-slot can be used to build GUI application
✤ E.g. a Simulation framework can be used to simulate the passage of particles through matter
✤ Real complex applications are made typically with a collaboration of frameworks✤ The main challenge is often that each framework ‘thinks’ is the main one
Not a Single Framework
4
Monday, September 9, 13
![Page 5: Frameworks and Common Packages - LASER Foundationlaser.inf.ethz.ch/2013/material/mato/Mato-Lecture3.pdf · E.g. a GUI framework based on signal-slot can be used to build GUI ... Starting](https://reader034.vdocument.in/reader034/viewer/2022042915/5f525c5ebb457d6de95fedbf/html5/thumbnails/5.jpg)
✤ Common vocabulary, better specifications of what needs to be done, better understanding of the system✤ E.g. GUI framework: windows, widgets, slots, events, etc.
✤ Low coupling between concurrent developments✤ Smooth integration✤ Organization of the development
✤ Robustness, resilient to change (change-tolerant)✤ Provides some isolation between developer’s code and services (OS,
networking, I/O, etc.)✤ Fostering code re-use
✤ E.g. generic widgets can re-used many times to build GUI applications
Framework Benefits
5
Monday, September 9, 13
![Page 6: Frameworks and Common Packages - LASER Foundationlaser.inf.ethz.ch/2013/material/mato/Mato-Lecture3.pdf · E.g. a GUI framework based on signal-slot can be used to build GUI ... Starting](https://reader034.vdocument.in/reader034/viewer/2022042915/5f525c5ebb457d6de95fedbf/html5/thumbnails/6.jpg)
Date
Gaudi Architecture and FrameworkAn Example of Framework for HEP Applications
6
Monday, September 9, 13
![Page 7: Frameworks and Common Packages - LASER Foundationlaser.inf.ethz.ch/2013/material/mato/Mato-Lecture3.pdf · E.g. a GUI framework based on signal-slot can be used to build GUI ... Starting](https://reader034.vdocument.in/reader034/viewer/2022042915/5f525c5ebb457d6de95fedbf/html5/thumbnails/7.jpg)
✤ Separation between “data” and “algorithms”✤ Three basic categories of “data”
✤ event data, detector data, statistical data✤ Separation between “transient” and “persistent” representations of
data✤ Data store-centered (“whiteboard”) architectural style✤ “User code” encapsulated in only few specific places✤ Well defined component “interfaces” with plug-in capabilities
Principal Design Choices
7
The Gaudi Framework is used by ATLAS and LHCb among others
Monday, September 9, 13
![Page 8: Frameworks and Common Packages - LASER Foundationlaser.inf.ethz.ch/2013/material/mato/Mato-Lecture3.pdf · E.g. a GUI framework based on signal-slot can be used to build GUI ... Starting](https://reader034.vdocument.in/reader034/viewer/2022042915/5f525c5ebb457d6de95fedbf/html5/thumbnails/8.jpg)
Gaudi Object Diagram
8
Converter
Algorithm
Event Data Service
Persistency Service
Data Files
Algorithm Algorithm
Detec. Data Service
Persistency Service
Data Files
Transient Detector
Store
Message Service
JobOptions Service
Particle Prop. Service
Other Services Histogram
Service Persistency
Service Data Files
Transient Histogram
Store
Application Manager Converter Converter Event
Selector
Transient Event Store
Monday, September 9, 13
![Page 9: Frameworks and Common Packages - LASER Foundationlaser.inf.ethz.ch/2013/material/mato/Mato-Lecture3.pdf · E.g. a GUI framework based on signal-slot can be used to build GUI ... Starting](https://reader034.vdocument.in/reader034/viewer/2022042915/5f525c5ebb457d6de95fedbf/html5/thumbnails/9.jpg)
Algorithms and Data Flows✤ The meat of the applications is
coded by physicists in terms of Algorithms✤ They transform raw input event data
into processed data✤ e.g. from digits -> hits -> tracks ->
jets -> etc✤ Algorithms solely interact with the
Event Data Store (“whiteboard”) to get input data and put the results✤ Agnostic to the actual “producer” and
“consumer” of the data✤ Complete data-flows are programmed
by the integrator of the application (e.g. Reconstruction, Trigger, etc.)
9
Algorithm A
Algorithm B
Algorithm C
Transient Event Data Store
Data T1
Data T2, T3
Data T2
Data T3, T4
Data T4
Data T5
Data T1 Data T1
Data T5
Real dataflow
Apparent dataflow
Monday, September 9, 13
![Page 10: Frameworks and Common Packages - LASER Foundationlaser.inf.ethz.ch/2013/material/mato/Mato-Lecture3.pdf · E.g. a GUI framework based on signal-slot can be used to build GUI ... Starting](https://reader034.vdocument.in/reader034/viewer/2022042915/5f525c5ebb457d6de95fedbf/html5/thumbnails/10.jpg)
Definition of Terms✤ Algorithm
✤ Atomic data processing unit (visible & controlled by framework)
✤ Algorithm Tool✤ Class called by the Algorithm or
another Tool to perform a specific function (private and public)
✤ Data Object✤ Atomic data unit (visible and
managed by transient data store)✤ Transient Data Store
✤ Central service and repository for data objects (data location, life cycle, load on demand, …)
10
✤ Services✤ Globally available software
components providing framework functionality
✤ Data Converter✤ Provides explicit/implicit
conversion from/to persistent data format to/from transient data
✤ Properties✤ Control and data parameters for
Algorithms and Services
Monday, September 9, 13
![Page 11: Frameworks and Common Packages - LASER Foundationlaser.inf.ethz.ch/2013/material/mato/Mato-Lecture3.pdf · E.g. a GUI framework based on signal-slot can be used to build GUI ... Starting](https://reader034.vdocument.in/reader034/viewer/2022042915/5f525c5ebb457d6de95fedbf/html5/thumbnails/11.jpg)
✤ Users write Concrete Algorithms✤ It is called once per physics event✤ Implements three methods in
addition to the constructor and destructor✤ initialize(), execute(), finalize()
AlgorithmIAlgorithm• initialize()• execute()• finalize()
Algorithm
ConcreteAlgorithm
IProperty• setProperty()• getProperty()
11
Monday, September 9, 13
![Page 12: Frameworks and Common Packages - LASER Foundationlaser.inf.ethz.ch/2013/material/mato/Mato-Lecture3.pdf · E.g. a GUI framework based on signal-slot can be used to build GUI ... Starting](https://reader034.vdocument.in/reader034/viewer/2022042915/5f525c5ebb457d6de95fedbf/html5/thumbnails/12.jpg)
Interfaces
ConcreteAlgorithm
EventDataSvcIDataProviderSvc
IDataProviderSvc
IHistogramSvc
IMessageSvc
IAlgorithm IProperty
Obj_B
DetectorDataSvc
HistogramSvc
MessageSvc
ParticlePropertySvcIParticlePropertySvc
ApplicationMgrISvcLocator
Obj_A
12
Monday, September 9, 13
![Page 13: Frameworks and Common Packages - LASER Foundationlaser.inf.ethz.ch/2013/material/mato/Mato-Lecture3.pdf · E.g. a GUI framework based on signal-slot can be used to build GUI ... Starting](https://reader034.vdocument.in/reader034/viewer/2022042915/5f525c5ebb457d6de95fedbf/html5/thumbnails/13.jpg)
VCR Interface Model
VCR
IEuroConnectorIRfInput
IUserInterface IInfraredInput
TV set
•Each interface is specialized in a domain.
• Interfaces are independent of concrete implementations.
•You can mix devices from several constructors.
•Application built by composing.•Standardizing on the interfaces gives us big leverage.
13
Monday, September 9, 13
![Page 14: Frameworks and Common Packages - LASER Foundationlaser.inf.ethz.ch/2013/material/mato/Mato-Lecture3.pdf · E.g. a GUI framework based on signal-slot can be used to build GUI ... Starting](https://reader034.vdocument.in/reader034/viewer/2022042915/5f525c5ebb457d6de95fedbf/html5/thumbnails/14.jpg)
✤ Program extensions to provide a certain, usually very specific function "on demand”
✤ Applications/frameworks support plug-ins for many reasons (in HEP)✤ to enable third-party developers to create capabilities to extend an application✤ to support features yet
unforeseen✤ to reduce the size of the
basic application
Plug-ins
14
Monday, September 9, 13
![Page 15: Frameworks and Common Packages - LASER Foundationlaser.inf.ethz.ch/2013/material/mato/Mato-Lecture3.pdf · E.g. a GUI framework based on signal-slot can be used to build GUI ... Starting](https://reader034.vdocument.in/reader034/viewer/2022042915/5f525c5ebb457d6de95fedbf/html5/thumbnails/15.jpg)
} Each Framework component can be configured by a set of ‘properties’ (name/ value pairs)
} In total thousands of parameters need to be specified to fully configure a complex HEP application
} Using Python to facilitate the task◦ Build-in type checking
Configuring the Application
15
Monday, September 9, 13
![Page 16: Frameworks and Common Packages - LASER Foundationlaser.inf.ethz.ch/2013/material/mato/Mato-Lecture3.pdf · E.g. a GUI framework based on signal-slot can be used to build GUI ... Starting](https://reader034.vdocument.in/reader034/viewer/2022042915/5f525c5ebb457d6de95fedbf/html5/thumbnails/16.jpg)
} Interactivity and scripting are essential use cases for any HEP framework◦ Scripts for rapid prototyping and trying new ideas◦ Testing frameworks◦ GUI applications
} A convenient way to achieve it is to provide bindings to a scripting language such as Python (or a C++ interpreter)◦ Once this is done the rest comes automatically
Interactivity and Scripting
16
Monday, September 9, 13
![Page 17: Frameworks and Common Packages - LASER Foundationlaser.inf.ethz.ch/2013/material/mato/Mato-Lecture3.pdf · E.g. a GUI framework based on signal-slot can be used to build GUI ... Starting](https://reader034.vdocument.in/reader034/viewer/2022042915/5f525c5ebb457d6de95fedbf/html5/thumbnails/17.jpg)
PyROOT: Mode d’emploi } From class definitions (.h
files) a “dictionary” library is produced◦Description of the class◦ “stub” functions to class
methods} Absolutely non-intrusive} The PyROOT module does
the adaptation between Python objects and C++ objects in a generic way◦ It works for any dictionary
MyClass.hMyClassDict.so
select.xml
genreflex
Python interpreter
loadMyClass.so
MyScript.py
PyROOT
17
Monday, September 9, 13
![Page 18: Frameworks and Common Packages - LASER Foundationlaser.inf.ethz.ch/2013/material/mato/Mato-Lecture3.pdf · E.g. a GUI framework based on signal-slot can be used to build GUI ... Starting](https://reader034.vdocument.in/reader034/viewer/2022042915/5f525c5ebb457d6de95fedbf/html5/thumbnails/18.jpg)
✤ All HEP experiments have developed Software Frameworks✤ General architecture of any event processing applications (simulation, trigger,
reconstruction, analysis, etc.)✤ To achieve coherency and to facilitate software re-use✤ Hide technical details to the end-user Physicists✤ Help the Physicists to focus on their physics algorithms
✤ Applications are developed by customizing the Framework✤ By the “composition” of elemental Algorithms to form complete applications✤ Using third-party components wherever possible and configuring them
✤ ALICE: AliROOT; ATLAS+LHCb: Athena/Gaudi; CMS: CMSSW
Summary: Frameworks
18
Monday, September 9, 13
![Page 19: Frameworks and Common Packages - LASER Foundationlaser.inf.ethz.ch/2013/material/mato/Mato-Lecture3.pdf · E.g. a GUI framework based on signal-slot can be used to build GUI ... Starting](https://reader034.vdocument.in/reader034/viewer/2022042915/5f525c5ebb457d6de95fedbf/html5/thumbnails/19.jpg)
Common Packages (examples)
19
Applications
Event DetDesc.
Calib.
Experiment Framework
Simulation AnalysisDataMngmt.
Core Libraries
non-HEP specificsoftware packages
Monday, September 9, 13
![Page 20: Frameworks and Common Packages - LASER Foundationlaser.inf.ethz.ch/2013/material/mato/Mato-Lecture3.pdf · E.g. a GUI framework based on signal-slot can be used to build GUI ... Starting](https://reader034.vdocument.in/reader034/viewer/2022042915/5f525c5ebb457d6de95fedbf/html5/thumbnails/20.jpg)
✤ ROOT is a extensive data handling and analysis framework✤ Efficient object data store scaling from KB’s to PB’s ✤ C++ and Python interpreter ✤ Extensive 2D+3D scientific data visualization capabilities ✤ Extensive set of data fitting, modeling and analysis methods ✤ Complete set of GUI widgets ✤ Classes for threading, shared memory, networking, etc. ✤ Parallel version of analysis engine runs on clusters and multi- core ✤ Fully cross platform, Unix/Linux, Mac OS X and Windows ✤ 2.7 million lines of C++, building into more than 100 shared libs
✤ Development started in 1995✤ Licensed under the LGPL
ROOT
20
http://root.cern.ch
Monday, September 9, 13
![Page 21: Frameworks and Common Packages - LASER Foundationlaser.inf.ethz.ch/2013/material/mato/Mato-Lecture3.pdf · E.g. a GUI framework based on signal-slot can be used to build GUI ... Starting](https://reader034.vdocument.in/reader034/viewer/2022042915/5f525c5ebb457d6de95fedbf/html5/thumbnails/21.jpg)
✤ ROOT is shipped with an C/C++ interpreter, CINT✤ C++ not trivial to interpret and not foreseen in the language standard!
✤ Provides interactive shell✤ Can interpret
“macros” (not compiled programs)✤ Rapid prototyping
possible✤ ROOT provides also Python bindings (PyROOT),
which are very popular among physicists✤ Starting from ROOT 6, the interpreter will be
Cling (based on LLVM/Clang)
ROOT Interpreter
21
CINT/ROOT C/C++ Interpreter version 5.18.00, July 2, 2010Type ? for help. Commands must be C++ statements.Enclose multiple statements between { }.
root [0] TH1D histo("normal","Normal histogram", 100, -10., +10);root [1] for(int i = 0; i < 10000; i++) {end with '}', '@':abort > histo.Fill(gRandom->Gaus());end with '}', '@':abort > }root [2] histo.Draw();
Monday, September 9, 13
![Page 22: Frameworks and Common Packages - LASER Foundationlaser.inf.ethz.ch/2013/material/mato/Mato-Lecture3.pdf · E.g. a GUI framework based on signal-slot can be used to build GUI ... Starting](https://reader034.vdocument.in/reader034/viewer/2022042915/5f525c5ebb457d6de95fedbf/html5/thumbnails/22.jpg)
ROOT in Numbers✤ Ever increasing number of users
✤ 6800 forum members, 68750 posts, 1300 on mailing list
✤ Used by basically all HEP experiments and beyond
22
As of today 177 PB of LHC data stored in ROOT format
ALICE: 30PB, ATLAS: 55PB, CMS: 85PB, LHCb: 7PB
Monday, September 9, 13
![Page 23: Frameworks and Common Packages - LASER Foundationlaser.inf.ethz.ch/2013/material/mato/Mato-Lecture3.pdf · E.g. a GUI framework based on signal-slot can be used to build GUI ... Starting](https://reader034.vdocument.in/reader034/viewer/2022042915/5f525c5ebb457d6de95fedbf/html5/thumbnails/23.jpg)
ROOT in Plots
23
Monday, September 9, 13
![Page 24: Frameworks and Common Packages - LASER Foundationlaser.inf.ethz.ch/2013/material/mato/Mato-Lecture3.pdf · E.g. a GUI framework based on signal-slot can be used to build GUI ... Starting](https://reader034.vdocument.in/reader034/viewer/2022042915/5f525c5ebb457d6de95fedbf/html5/thumbnails/24.jpg)
ROOT Object Persistency
24
✤ Scalable, efficient, machine independent format ✤ Orthogonal to object model
✤ Persistency does not dictate object model ✤ Based on object serialization to a buffer ✤ Automatic schema evolution (backward and forward compatibility) ✤ Object versioning ✤ Compression ✤ Easily tunable granularity and clustering ✤ Remote access
✤ HTTP, HDFS, Amazon S3, CloudFront and Google Storage ✤ Self describing file format (stores reflection information) ✤ ROOT I/O is used to store all LHC data (actually all HEP data)
Monday, September 9, 13
![Page 25: Frameworks and Common Packages - LASER Foundationlaser.inf.ethz.ch/2013/material/mato/Mato-Lecture3.pdf · E.g. a GUI framework based on signal-slot can be used to build GUI ... Starting](https://reader034.vdocument.in/reader034/viewer/2022042915/5f525c5ebb457d6de95fedbf/html5/thumbnails/25.jpg)
Object Containers - TTree✤ Special container for very large number of objects of the same type
(events) ✤ Minimum amount of overhead per entry
✤ Objects can be clustered per sub object or even per single attribute (clusters are called branches)
✤ Each branch can be read individually ✤ A branch is a
column
25
Physicists perform final data analysis
processing large TTrees(more later)
Monday, September 9, 13
![Page 26: Frameworks and Common Packages - LASER Foundationlaser.inf.ethz.ch/2013/material/mato/Mato-Lecture3.pdf · E.g. a GUI framework based on signal-slot can be used to build GUI ... Starting](https://reader034.vdocument.in/reader034/viewer/2022042915/5f525c5ebb457d6de95fedbf/html5/thumbnails/26.jpg)
✤ Provide ROOT file access entirely locally in a browser without any prior ROOT installation on the server or client✤ ROOT files are self describing ...
ROOT in Javascript
26
Monday, September 9, 13
![Page 27: Frameworks and Common Packages - LASER Foundationlaser.inf.ethz.ch/2013/material/mato/Mato-Lecture3.pdf · E.g. a GUI framework based on signal-slot can be used to build GUI ... Starting](https://reader034.vdocument.in/reader034/viewer/2022042915/5f525c5ebb457d6de95fedbf/html5/thumbnails/27.jpg)
EVE Event Display
27
Monday, September 9, 13
![Page 28: Frameworks and Common Packages - LASER Foundationlaser.inf.ethz.ch/2013/material/mato/Mato-Lecture3.pdf · E.g. a GUI framework based on signal-slot can be used to build GUI ... Starting](https://reader034.vdocument.in/reader034/viewer/2022042915/5f525c5ebb457d6de95fedbf/html5/thumbnails/28.jpg)
EVE Event Display
27
Monday, September 9, 13
![Page 29: Frameworks and Common Packages - LASER Foundationlaser.inf.ethz.ch/2013/material/mato/Mato-Lecture3.pdf · E.g. a GUI framework based on signal-slot can be used to build GUI ... Starting](https://reader034.vdocument.in/reader034/viewer/2022042915/5f525c5ebb457d6de95fedbf/html5/thumbnails/29.jpg)
PROOF-The Parallel Query Engine✤ A system for running ROOT queries in parallel on a large number of
distributed computers or many-core machines ✤ PROOF is designed to be a transparent, scalable and adaptable extension of
the local interactive ROOT analysis session ✤ For optimal CPU load it needs fast data access (SSD, disk, network) as
queries are often I/O bound ✤ The packetizer is the heart of the system
✤ It runs on the client/master and hands out work to the workers
✤ It takes data locality and storage type into account
✤ Tries to avoid storage device overload
✤ It makes sure all workers end at the same time
28
Monday, September 9, 13
![Page 30: Frameworks and Common Packages - LASER Foundationlaser.inf.ethz.ch/2013/material/mato/Mato-Lecture3.pdf · E.g. a GUI framework based on signal-slot can be used to build GUI ... Starting](https://reader034.vdocument.in/reader034/viewer/2022042915/5f525c5ebb457d6de95fedbf/html5/thumbnails/30.jpg)
PROOF User Interface: TSelector✤ Users write specializations of TSelector class to
perform data analysis✤ Results are typically N-tuples, histograms, etc.
✤ Only 3 methods have to be defined✤ Begin : initializations (histograms, global variables,
etc...)✤ Process : event selection and treatment. It is called
for each entry in the ROOT tree✤ Terminate : end of the analysis (global calculations,
write results in a file, etc...)
29
Monday, September 9, 13
![Page 31: Frameworks and Common Packages - LASER Foundationlaser.inf.ethz.ch/2013/material/mato/Mato-Lecture3.pdf · E.g. a GUI framework based on signal-slot can be used to build GUI ... Starting](https://reader034.vdocument.in/reader034/viewer/2022042915/5f525c5ebb457d6de95fedbf/html5/thumbnails/31.jpg)
Various Flavors of PROOF✤ PROOF-Lite (optimized for single many-core machines)
✤ Zero configuration setup (no config files and no daemons) ✤ Workers are processes and not threads for added robustness ✤ Once your analysis runs on PROOF Lite it will also run on PROOF ✤ Works with exactly the same user code as PROOF
✤ Dedicated PROOF Analysis Facilities (multi-user)✤ Cluster of dedicated physical nodes
✤ E.g. department cluster, experiment dedicated farm✤ Some local storage, sandboxing, basic scheduling, basic monitoring
✤ PROOF on Demand (single-user)✤ Create a temporary dedicated PROOF cluster on batch resources (Grid or Cloud)✤ Uses an resource management system to start daemons ✤ Each user gets a private cluster✤ Sandboxing, daemon in single-user mode (robustness)
30
Monday, September 9, 13
![Page 32: Frameworks and Common Packages - LASER Foundationlaser.inf.ethz.ch/2013/material/mato/Mato-Lecture3.pdf · E.g. a GUI framework based on signal-slot can be used to build GUI ... Starting](https://reader034.vdocument.in/reader034/viewer/2022042915/5f525c5ebb457d6de95fedbf/html5/thumbnails/32.jpg)
Geant4✤ A software (C++) toolkit for the
Monte Carlo simulation of the passage of particles through matter✤ ‘propagates’ particles through
geometrical structures of materials, including magnetic field
✤ simulates processes the particles undergo✤ creates secondary particles✤ decays particles
✤ calculates the deposited energy along the trajectories and allows to store the information for further processing (‘hits’)
31
Simulated Higgs event in CMS
Monday, September 9, 13
![Page 33: Frameworks and Common Packages - LASER Foundationlaser.inf.ethz.ch/2013/material/mato/Mato-Lecture3.pdf · E.g. a GUI framework based on signal-slot can be used to build GUI ... Starting](https://reader034.vdocument.in/reader034/viewer/2022042915/5f525c5ebb457d6de95fedbf/html5/thumbnails/33.jpg)
Monte Carlo simulation✤ What is Monte Carlo
✤ Throwing random numbers✤ to calculate integrals✤ to pick among possible choices
✤ Why Monte Carlo✤ Because Einstein was wrong: God does throw dice! ✤ Quantum mechanics: amplitudes => probabilities
✤ Anything that possibly can happen, will! (but more or less often)✤ Want to generate events in as much detail as Mother Nature
✤ get average and fluctuations right✤ make random choices,∼as in nature
32
Monday, September 9, 13
![Page 34: Frameworks and Common Packages - LASER Foundationlaser.inf.ethz.ch/2013/material/mato/Mato-Lecture3.pdf · E.g. a GUI framework based on signal-slot can be used to build GUI ... Starting](https://reader034.vdocument.in/reader034/viewer/2022042915/5f525c5ebb457d6de95fedbf/html5/thumbnails/34.jpg)
Why do we need it?✤ To design and to construct the devices
✤ to get what we are looking for✤ to be able to see the relevant ‘events’
✤ not to get what we do not want✤ radiation damage, etc
✤ To operate the devices✤ to adjust and to tune the aparatus
✤ medical physics: dose calculation, etc✤ To understand the experimental results
✤ to compare to the existing theories and models✤ to make discoveries
33
Monday, September 9, 13
![Page 35: Frameworks and Common Packages - LASER Foundationlaser.inf.ethz.ch/2013/material/mato/Mato-Lecture3.pdf · E.g. a GUI framework based on signal-slot can be used to build GUI ... Starting](https://reader034.vdocument.in/reader034/viewer/2022042915/5f525c5ebb457d6de95fedbf/html5/thumbnails/35.jpg)
Needed to make Discoveries✤ We need to understand the
detector to do physics✤ imperfections✤ calibrations
✤ We need to know what to expect to✤ verify existing models✤ find new physics
34
Monday, September 9, 13
![Page 36: Frameworks and Common Packages - LASER Foundationlaser.inf.ethz.ch/2013/material/mato/Mato-Lecture3.pdf · E.g. a GUI framework based on signal-slot can be used to build GUI ... Starting](https://reader034.vdocument.in/reader034/viewer/2022042915/5f525c5ebb457d6de95fedbf/html5/thumbnails/36.jpg)
Geant4 Application
35
Geometry implementation
User ‘actions’
Primary particles
Geant4 kernel
‘Hits’(energy
deposition)
‘MC truth’(generated
secondaries)
Visualisation
magnetic field
physics models
Monday, September 9, 13
![Page 37: Frameworks and Common Packages - LASER Foundationlaser.inf.ethz.ch/2013/material/mato/Mato-Lecture3.pdf · E.g. a GUI framework based on signal-slot can be used to build GUI ... Starting](https://reader034.vdocument.in/reader034/viewer/2022042915/5f525c5ebb457d6de95fedbf/html5/thumbnails/37.jpg)
Geometry and Materials
36
✤ How to implement (efficiently) this in your computer program?
✤ You need ‘bricks’✤ ‘solids’, ‘shapes’✤ you need to position them✤ you want to ‘reuse’ as much as possible
the same ‘templates’✤ Database of Materials
✤ National Institute of Standards (NIST)✤ Magnetic Fields
✤ numerical integration of the equation of motion (Runge-Kutta method)
Monday, September 9, 13
![Page 38: Frameworks and Common Packages - LASER Foundationlaser.inf.ethz.ch/2013/material/mato/Mato-Lecture3.pdf · E.g. a GUI framework based on signal-slot can be used to build GUI ... Starting](https://reader034.vdocument.in/reader034/viewer/2022042915/5f525c5ebb457d6de95fedbf/html5/thumbnails/38.jpg)
Physics...✤ What happens to a particles in matter?✤ We need to implement the physics we
know✤ each possible physics process provides the
“interaction length” compared with distance to next boundary✤ the smallest wins
✤ generating a “final state” and secondaries tracks
✤ Electromagnetic ✤ gammas and charged particles
✤ Hadronic✤ neutrons, mesons (K,!), muons, ...
37
Because of the detailed geometries, the detailed physics and the required precision
the simulation is very CPU hungry
Monday, September 9, 13
![Page 39: Frameworks and Common Packages - LASER Foundationlaser.inf.ethz.ch/2013/material/mato/Mato-Lecture3.pdf · E.g. a GUI framework based on signal-slot can be used to build GUI ... Starting](https://reader034.vdocument.in/reader034/viewer/2022042915/5f525c5ebb457d6de95fedbf/html5/thumbnails/39.jpg)
Software Re-use:Integrating Technologies
38
Monday, September 9, 13
![Page 40: Frameworks and Common Packages - LASER Foundationlaser.inf.ethz.ch/2013/material/mato/Mato-Lecture3.pdf · E.g. a GUI framework based on signal-slot can be used to build GUI ... Starting](https://reader034.vdocument.in/reader034/viewer/2022042915/5f525c5ebb457d6de95fedbf/html5/thumbnails/40.jpg)
✤ At occasions you need to a build software system/application made of independently developed components✤ Using existing class libraries ✤ They cannot be re-done using a single ‘framework’✤ Building adaptation layers are not always possible and effective
✤ Examples✤ Integrating MC generators in ROOT✤ Performing ROOT I/O on Geant4 Applications
When Frameworks are not Possible
39
Monday, September 9, 13
![Page 41: Frameworks and Common Packages - LASER Foundationlaser.inf.ethz.ch/2013/material/mato/Mato-Lecture3.pdf · E.g. a GUI framework based on signal-slot can be used to build GUI ... Starting](https://reader034.vdocument.in/reader034/viewer/2022042915/5f525c5ebb457d6de95fedbf/html5/thumbnails/41.jpg)
40
Software Integration Elements✤ Dictionaries
✤ Dictionaries provide meta data information (reflection) to allow introspection and interaction of objects in a generic manner
✤ Scripting languages✤ Interpreted languages are ideal for rapid prototyping✤ They allow integration of independently developed software modules
(software bus)✤ Standardizing on CINT and Python scripting languages
✤ Component model and plugin management✤ Modeling the application as components with well defined interfaces✤ Loading the required functionality at runtime
Monday, September 9, 13
![Page 42: Frameworks and Common Packages - LASER Foundationlaser.inf.ethz.ch/2013/material/mato/Mato-Lecture3.pdf · E.g. a GUI framework based on signal-slot can be used to build GUI ... Starting](https://reader034.vdocument.in/reader034/viewer/2022042915/5f525c5ebb457d6de95fedbf/html5/thumbnails/42.jpg)
41
Strategic role of C++ reflexion
X.h
ReflexDS
rootcint -cint
rootcint -reflexXDictcint.so
ReflexROOT
Root meta C++
CINTPython
rootcint -gccxml
Object I/OScripting
(CINT, Python)Plug-in management
etc.
Monday, September 9, 13
![Page 43: Frameworks and Common Packages - LASER Foundationlaser.inf.ethz.ch/2013/material/mato/Mato-Lecture3.pdf · E.g. a GUI framework based on signal-slot can be used to build GUI ... Starting](https://reader034.vdocument.in/reader034/viewer/2022042915/5f525c5ebb457d6de95fedbf/html5/thumbnails/43.jpg)
42
Python <-> C++ Interoperation✤ The bulk of code for the new HEP experiments is written in C++
✤ Still some portions of FORTRAN with plans to migrate✤ Java and other languages almost non-existent
✤ Need Python bindings to C++ code ✤ Hand-written (C-API) or generated ✤ Requires taking care of:
✤ Object, parameter conversions ✤ Memory management ✤ C++ function overloading ✤ C++ templates✤ Inheritance and function callbacks✤ etc.
Monday, September 9, 13
![Page 44: Frameworks and Common Packages - LASER Foundationlaser.inf.ethz.ch/2013/material/mato/Mato-Lecture3.pdf · E.g. a GUI framework based on signal-slot can be used to build GUI ... Starting](https://reader034.vdocument.in/reader034/viewer/2022042915/5f525c5ebb457d6de95fedbf/html5/thumbnails/44.jpg)
43
Python as Software “Bus”
Pythonmath
shellGaudiPython
DatabaseEDG APIGUI
Very rich set of Python standard
modules
Several GUI toolkits
XML
Very rich set specialized generic modules
GaudiFramework
PyROOT
ROOTClasses
PVSS
JPE
JavaClasses
LHC modules
Gat
eway
s to
othe
r fr
amew
orks
Monday, September 9, 13
![Page 45: Frameworks and Common Packages - LASER Foundationlaser.inf.ethz.ch/2013/material/mato/Mato-Lecture3.pdf · E.g. a GUI framework based on signal-slot can be used to build GUI ... Starting](https://reader034.vdocument.in/reader034/viewer/2022042915/5f525c5ebb457d6de95fedbf/html5/thumbnails/45.jpg)
Language Symbiosis✤ Getting the best from C++ (number crunching) and Python (rapid
prototyping)✤ Scientists are able
to express sophisticateddata analysis algorithms using high level Pythonconstructs✤ E.g. D* analysis in LHCb✤ Fits in a single page
✤ Very little performance impact
✤ Very easy to make changes
44
from bendermodule import *class Dstar(Algo): def analyse( self ) : self.select ( tag=‘K-’, cuts=(‘K-’ ==ID)&(PT>1*GeV) ) self.select ( tag=‘pi+’,cuts=(‘pi+’==ID)&(P >3*GeV) ) dmass = ABSDM(“D0”) < 30 * MeV
for D0 in self.loop ( formula=‘K- pi+’, pid=‘D0’ ) : if ( VCHI2(D0) < 4 ) & dmass( D0 ) : D0.save(‘D0’)
tup = self.nTuple ( title = “D*+ N-Tuple ” ) for Dst in self.loop ( formula=‘D0 pi+’, pid=‘D*(2010)+’ ) : ! dm = M(Dst)-M1(Dst) h1 = self.plot( title = “Delta mass for D*+” , value = dm , low=130 , high=170 ) tup.column( name = ‘M’ , value = M(Dst) / GeV ) tup.column( name = ‘DM’ , value = dm / GeV ) tup.column( name = ‘p’ , value = P (Dst) / GeV ) tup.column( name = ‘pt’ , value = PT(Dst) / GeV ) tup.write () return SUCCESS !
Monday, September 9, 13
![Page 46: Frameworks and Common Packages - LASER Foundationlaser.inf.ethz.ch/2013/material/mato/Mato-Lecture3.pdf · E.g. a GUI framework based on signal-slot can be used to build GUI ... Starting](https://reader034.vdocument.in/reader034/viewer/2022042915/5f525c5ebb457d6de95fedbf/html5/thumbnails/46.jpg)
✤ Introduced software frameworks used in HEP and their hierarchy✤ Used GAUDI framework as an example of HEP event data processing
framework✤ The main design criteria✤ Introduction to few of the main concepts and functionalities
✤ Two examples of common software packages: ROOT and Geant4✤ Basically used by any HEP experiment ✤ Examples of software re-use
✤ Software integration elements✤ Dictionaries, Plugins and the role of Python
Take Away Messages
45
Monday, September 9, 13