430 likes | 527 Views
OO Implementation for the LHCb Rich. Niko Neufeld Dietrich Liko. Introduction. Study of OO Implementation of a Reconstruction program Based on Standalone Program by Roger Forty et al. Present a comparison Review Object Oriented features. Objective. Results of the FORTRAN Physics
E N D
OO Implementationfor the LHCb Rich Niko Neufeld Dietrich Liko
Introduction • Study of OO Implementation of a Reconstruction program • Based on Standalone Programby Roger Forty et al. • Present a comparison • Review Object Oriented features
Objective • Results of the FORTRAN • Physics • Resources • To be better then FORTRAN • Object Orientation • Modularity • Interfaces
UML Process UML Unified Modeling Language by Booch, Jacobson & Rumbaugh • Specification using UML • Use cases • Development using UML case tool • Rational Rose • Iterative Development • Several internal iterations
Program Specification • Technical Proposal • LHCb Note • FORTRAN Program • Summary with all information • Partial capture in use cases
One page on physics • Cherenkov Effect • Emission of Photons • Aerogel & Gas Radiator • Reflection of Photons • Observation of Photons • Quantum Efficiency • Detector Geometry
One page on algorithm • Local Likelihood • Global Likelihood • Very effective • CPU intensive • Other Algorithm possible • Average emission angle
Framework • OO Framework to implement reconstruction algorithms • Simulation also possible • Here the Global Likelihood will be implemented • Benchmark for usability
Use Cases • Question a Physicist might ask ... • to a particle ... • to a pixel ... • Global Likelihood
Detector Simplified UML Class Diagram Static relations of Classes Rich Radiator Detector Reflector
I should be called DetectorElement ! Event Event Track Pixel Track Extrapolation Photon Track Segment
Other Entities PhotonSpectrum PixelID GeneratedPhoton
Lifetime • Present for all Events • Rich, Radiator, Reflector, Detector • Present for one Event • Tracks, TrackExtrapolations,Pixel, Photons • Temporary • Photon Spectrum, PixelID, Single Photon
I am not so smart ... Pixel id tube But I am smart! RecPixel signal globalPosition localPosition size The PhotonDetector does all the work for me ! Photon Detector • Example trivial • expensive calculations • context questions
Architecture Algorithm Strategy Interface Event Detector
Standalone Program • Minimal Environment • Contains its own Transient Event Model • Parameter Files • Histograms from CLHEP • Only for this test!
Optimisations • Since last presentation • two weeks ago • Program about a factor 2 slower • Profiling and Debugging • Allocation of STL container • operator[] • Algorithmic improvements
500 Events B pp background “Clean” Technical Proposal
500 Events B pp background “Clean” Results Difference in particle population, in particular for X particles: Different sample, small differences in the modeling of the inner edges Reduced m Purity Migration p to m Reduced p Efficiency
CPU Comparison 100 Events B Background “Clean” G77 7.52 G++ 8.32 500 Mhz Pentium III Sec/Event 7 8 9
Kuck & Associates, Inc. • Commercial C++ compiler • Standard compliant • Templates • Patented optimization techniques • Precompiled headers • http://www.kai.com • Time-locked trial version for RH6.1
CPU Comparison 100 Events B Background “Clean” G77 7.52 G++ 8.32 500 Mhz Pentium III KCC 7.32 Sec/Event 7 8 9
Summary • Outlined the development process • Show physics results • Show CPU comparisons • Why an OO program should be better ?
Track Segment Length Track length Aerogel Radiator
FORTRAN REAL FUNCTION DIST(POS,DIR) C A line is given by POS and DIS REAL POS(3), DIR(3) C Radiator wall is described by its z position REAL ZPOS(2) COMMON /RADIATOR/ ZPOS DIST = ACOS(DIR(3),VMOD(DIR,3))*(ZPOS(2)-ZPOS(1)) END
FORTRAN • Does what it should • Math is simple • Probably more complicated in praxis • walls not normal to z • more then one radiator • Some variables which are interpreted in the context • But your program works soon!
Sometimes later ... • … you want to improve the program • More realistic tracks • More realistic radiators • But assumptions are not isolated • There will be other places which depend on these variables • You have to find all uses of the variables • In your program at n places • In other people programs at unknown places
Object Based • Assume two classes present • Plane • Ray (can intersect with plane) • My programhas ... • class Algorithm • dist method
Object Based class Algorithm { PlaneRadiator[2]; virtual double dist(const Ray & track) const; } double Algorithm::dist(const Ray & track) const { return Radiator[1].intersect(track) - Radiator[0].intersect(track); }
Object Based • More compact • Probably more general • Math is done by somebody else But main critic remains • If you want to improve the program,you have to find ... • n places in your own program • unknown places in other programs
Object Oriented class Track { public: virtual double dist() const; virtual double intersect(const Plane & plane) const; virtual double intersect(……) const; private: Radiator * radiator_; } class Radiator { public: virtual double dist(const Track & track) const; }
Sequence Diagram Track Radiator Simplified UML Sequence Diagram dynamic relation of classes dist dist intersect intersect return dist return dist
Object Oriented • If one changes the Radiator ... • One place to do the modifications • If one changes the Track ... • Another single place to do the change • Implementation is hidden behind the interface • No dependency on the implementation details Visitor Pattern
Summarize • FORTRAN • does the job • difficult to maintain • Object Based C++ • does the job probably better • still difficult to maintain • Object Oriented C++ • dependencies are reduced
Our Program does not depend on ... • Track implementation • Pixel implementation • General Detector Geometry • Photon radiation process • Mirror choice • Type of Photon Detector • Photon Detector Assembly Details • Reconstruction Strategy • …..
Integration to GAUDI • Algorithm is interfaced • Package is nearly ready • Release next week • Detailed documentation from the Rose Model available • We plan to include some “hand written” documentation for the release
Future in GAUDI • Next steps … • Detector Description • Other Algorithms • Photon Detector Implementation • Not addressed • Structure of a general LHCb reconstruction program
Final Summary • UML process for software development • Standalone program has similar performance as the TP • Pleasant surprise: you can do a lot OO for reconstruction applications • There is the promise for a program that will be easier to maintain • You can try it yourself in GAUDI