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