1 / 20

Implementation Highlights

Implementation Highlights. Mike Miller Yale University. Large Scale Project, expanding scope 106 header files, 96 source files 25k lines of code more than 110 classes. Focus! (4 topics) Object creation, ownership Object communication Hit/Material pattern Pattern Recognition. Outline.

matia
Download Presentation

Implementation Highlights

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Implementation Highlights Mike Miller Yale University

  2. Large Scale Project, expanding scope 106 header files, 96 source files 25k lines of code more than 110 classes Focus! (4 topics) Object creation, ownership Object communication Hit/Material pattern Pattern Recognition Outline

  3. Speed, Speed, Speed! Memory allocation takes time O(1000) tracks/event O(100,000) hits/event But, can use transient objects Allocate objects once, reuses Flexibility Dynamic control type of objects to make But, code must be maintainable, readable (minimize conditionals, e.g. bfc.C) Use factory pattern to make, serve objects Creation/Ownership: Why the Fuss?

  4. Memory Pool Allocate memory in large chunks (pool) Third party is responsible for rationing pool ITTF actually re-uses objects each event No calls to new or delete! Factory Instead of calling new/delete for objects, request objects from factory Factory decides what objects to make User code (e.g., tracker) is independent of actual object type Creation/Ownership: Two Design Patterns in One

  5. StiObjectFactory • Manage objects • StiObjectFactoryInterface<T> • Define Polymorphic Interface • StiTrackFactory • makeNewObject() • StiRDTrackFactory • makeNewObject() Creation/Ownership: Class Design

  6. Creation/Ownership: An Example StiObjectFactoryInterface<StiTrack> • Run in GUI? • StiToolKit makes the right factory • Seed Finder gets a pointer to the factory interface • Seed Finder requests new tracks from the factory • Leak free, type safe, fast! StiTrackFactory StiRDTrackFactory StiToolKit StiIOBroker StiTrackSeedFinder

  7. Communication: StiIOBroker • Goal: centralize all dynamic parameters in one place • class StiIOBroker • Abstract class to define get/set methods • Singleton • class StiRootIOBroker : public StiIOBroker • Available at the root prompt • Currently used to pass info at the macro level • class StiMySqlIOBroker : public StiIOBroker • Not yet implemented

  8. a=50 b=30 c=20 notification requests Communication: Subject/Observer Pattern (I) Guarantee dynamic propagation of information Define a one to many relationship Observer Observer Observer Subject

  9. class Subscriber { public: add(Observer*); detach(Observer*); notify(); private: vector<Observer*> mVec; }; Communication: Subject/Observer Pattern (II) class Observer { public: update(Subject*)=0; private: Subject* mSubject; }; Simply derive from these classes and dynamic updates are guaranteed!

  10. Subject StiIOBroker Observer Observer StiKalmanTrackFinder StiTrackMerger Observer Observer StiTrackFilter StiTrackSeedFinder Communication: Example

  11. Hits/Material: Why Separate? • “Hits come from detectors, don’t they?” • Charge: Plug and Play • Decouple patter recognition algorithms (track finding) from track fitting algorithms (kalman) • But, be quick about it! • Design: • Decouple: StiHitContainer, StiDetectorContainer • Preserve simple, fast, natural mapping

  12. StiHitContainer: Requirements • Treat hits from all subsystems equally • Identify minimal information for common representation • Extremely fast • fill, sort, retrieve O(500k) hits/event in <5cpu sec • Return hits in some window about reference. • Applicable to all pattern recognition algorithms • Must function in “local” and “global” representations

  13. StiHitContainer: Intro to STL • Standard Template Library • Sequential, associative containers • Many classes of iterators • Algorithms! • Consequences • No c arrays (no out of bounds run errors!) • Decouple algorithms from containers • Never right another algorithm: • Sort, find, search, count, transform, etc… • Many numerical algorithms -> STL usage

  14. StiHitMap StiHitMapKey vector<StiHit*> 1 2 . . n StiHitContainer: Storage • Use STL map/vector to organize hits • Establish one to many relationships • Fast retrieval of layer via key • Fast retrieval of subset of hits in layer

  15. StiHitContainer: Retrieval • Set reference point • Predicted intersection of track + plane • Time: O(log(M)) • M~number of detectors (~45*12) • Key into hit map • Binary search in global z-window • Hits sorted by z in detector plane • Time: O(log(N)) • N~number of hits in plane (~100) • Linear search in distance along (pad) plane • Time: O(P) • P~number of hits in z window (<10)

  16. Root Mid Backward Forward Layer 1 Layer n Section 1 Section n Element 1 Element n StiDetectorContainer: Design • Version 5.x • tried multimap, lattice, polygons, volumes, tree • Ordered composite tree structure • Fast • Flexible • StiCompositeTreeNode<T>

  17. StiDetectorContainer: Navigation • Set to element • Defined by region, position, angle • moveIn(), moveOut(), movePlusPhi(), moveMinusPhi() • Example: moveIn() • Remember angle • If next layer preserves symmetry, constant time • If next layer has different symmetry, O(log(N)) • 10k swims from padrow 45-vertex in 0.17 cpu sec

  18. StiSeedFinder: Requirements • Responsible for pattern recognition • “Plug and Play” • easily implement new pattern recognition algorithms • Multiple algorithms in series and/or parallel • Fast • Less than 10 cpu sec per central event

  19. StiTrackSeedFinder StiCompositeSeedFinder StiLocalTrackSeedFinder Any new seed finder StiSeedFinder: Hierarchy StiSeedFinder

  20. Set to element Sample hit More hits Make 2pt seed Extend seed Fit Seed Initialize Track StiLocalTrackSeedFinder: Algorithm • Implement road-finder • Begin tracking at outside of tpc • Spiral inwards • Extend tracks into innermost layer • T.B.D. • Second pass (e.g., merge spirals)

More Related