evolution of cluster design in the instrumented flux return (ifr) of babar
DESCRIPTION
Evolution of cluster design in the Instrumented Flux Return (IFR) of BaBar. Luca Lista INFN, Sezione di Napoli for the BaBar Computing Group. The Instrumented Flux Return of BaBar. 18-19 layers of Resistive Plate Chambers (RPC) 2 layers of cylindrical RPC inside the coil - PowerPoint PPT PresentationTRANSCRIPT
Evolution of cluster Evolution of cluster design in the design in the
Instrumented Flux Instrumented Flux Return (IFR) of BaBarReturn (IFR) of BaBar
Luca ListaINFN, Sezione di Napoli
for the BaBar Computing Group
Luca Lista - CHEP '98Luca Lista - CHEP '98
The Instrumented Flux The Instrumented Flux Return of BaBarReturn of BaBar
• 18-19 layers of Resistive Plate Chambers (RPC)
• 2 layers of cylindrical RPC inside the coil
• Digital strip readout, 2-3cm pitch
Luca Lista - CHEP '98Luca Lista - CHEP '98
Ifr basic reconstruction Ifr basic reconstruction informationinformation
• The Ifr reconstruction provides the following basic information
stripstrip 1D1D clustercluster3D cluster3D cluster
Luca Lista - CHEP '98Luca Lista - CHEP '98
Clustering in the IFRClustering in the IFR• The IFR identifies , and
K0L
• The reconstruction information in the IFR is made of clusters of strips which are “close” in space
• Details of the pattern information give particle ID discriminating power
• Estimate of the impact point provides a determination of the flight direction of the K0
L
clustercluster
clustercluster
Luca Lista - CHEP '98Luca Lista - CHEP '98
2D and 3D Clustering2D and 3D Clustering
• Projective geometry in the planar RPC’s 2D reconstruction in each
projection• 3D association of the two
projections
Ifr2DClusterIfr2DCluster
Luca Lista - CHEP '98Luca Lista - CHEP '98
• The basic class structure
• The initial interface:
Early class designEarly class design
Ifr2DClusternumberOfHits () : intnumberOfStrips () : intfirstLayer () : intlastLayer () : inthitLayer () : int
Ifr3DClustercenterOfGravity () : PointcovMatrix () : BbrError
direction (from : Point) : VectornumberOfHits () : intnumberOfStrips () : intfirstLayer () : intlastLayer () : inthitLayers () : int
21
Ifr1DClusternumberOfStrips( )
1
1..n
Ifr3DCluster Ifr2DCluster21 Ifr1DCluster1 1..n
Luca Lista - CHEP '98Luca Lista - CHEP '98
Ifr3DClustercenterOfGravity () : PointcovMatrix () : BbrError
direction (from : Point) : VectornumberOfHits () : intnumberOfStrips () : intfirstLayer () : intlastLayer () : inthitLayers () : int
Ifr3DCompositecenterOfGravity () : PointcovMatrix () : BbrError
direction (from : Point) : VectornumberOfHits () : intnumberOfStrips () : intfirstLayer () : intlastLayer () : inthitLayers () : int
1..n
Composite clustersComposite clusters• Cluster segments
associated to the same charged track are combined together
Luca Lista - CHEP '98Luca Lista - CHEP '98
Polimorphic clustersPolimorphic clusters
• The user shouldn’t care about the detail of the cluster substructure:– just use IfrAbs3D
• All clusters implement the same interface.
Ifr3DClustercenterOfGravity () : PointcovMatrix () : BbrError
direction (from : Point) : VectornumberOfHits () : intnumberOfStrips () : intfirstLayer () : intlastLayer () : inthitLayers () : int
IfrAbs3DcenterOfGravity () : PointcovMatrix () : BbrError
direction (from : Point) : VectornumberOfHits () : intnumberOfStrips () : intfirstLayer () : intlastLayer () : inthitLayers () : int
Ifr3DCompositecenterOfGravity () : PointcovMatrix () : BbrError
direction (from : Point) : VectornumberOfHits () : intnumberOfStrips () : intfirstLayer () : intlastLayer () : inthitLayers () : int
1..n
Luca Lista - CHEP '98Luca Lista - CHEP '98
Inner RPC clustersInner RPC clusters• The inner RPC readout layout changed during
software evolution:– stereo readout strips
• 2D clustering is no longer appropriate• Composite clusters can’t be done of
homogeneous elements
Luca Lista - CHEP '98Luca Lista - CHEP '98
Evolution of the Evolution of the cluster modelcluster model
IfrAbs3DIfrAbs3D () : IfrAbs3DIfrAbs3D (a : const IfrAbs3D&) : IfrAbs3Dposition () : HepPoint~IfrAbs3D ()numberOfDigis () : intnumberOfStrips () : intcovMatrix () : BbrErrorpolCovMatrix () : BbrError
$polCovMatrix ( : BbrError&, : HepPoint&) : BbrErrorfirstLayer () : intlastLayer () : inthitLayers () : inthitLayersI () : inthitsInLayer (n : int) : intstripsInLayer (n : int) : intmaxMissed () : int
sectionCode () : Ifr::SectionCodecomponent ( : int = 0) : Ifr3DCluster*numberOfComponents () : intnumberOfComponents ( : Ifr::SectorCode) : intnumberOfComponents ( : Ifr::SectionCode) : intgetComposite () : Ifr3DComposite*hasBarrel () : boolhasEndCap () : boolhasFwdCap () : boolhasBwdCap () : boolhasInner () : booloperator == ( : const IfrAbs3D&) : boolnumber () : unsigned int$resetCounter () : voidsaveGuts ( : RWvostream&) : voidrestoreGuts ( : RWvistream&) : void
Ifr3DComposite Ifr3DCluster1..n
• Cluster information is intrinsically complex
• It is not possible to predict now all the needed functions
• The extension of the class functions requires changing the base class interface
• Extension to new cluster types?
Luca Lista - CHEP '98Luca Lista - CHEP '98
Problems spotted during the Problems spotted during the developmentdevelopment
• The cluster class interface growth rate was more than linear with time
• Code which used deep information of the cluster pattern tended to “understand” which subclass type it was using (dynamic_cast)
• Dependencies on cluster subtypes rather than base class increased
• Problems to effectively evolve the design
Luca Lista - CHEP '98Luca Lista - CHEP '98
Visitor patternVisitor pattern• Each function of the cluster classes is implemented in a
separate class for all cluster types – all inherit from IfrClusterVisitor abstract interface
• Extending the functionality does not require any change to classe interfaces– just add a new visitor class
• Dependency on cluster subclasses is concentrated in the visitor classes
• The design is, according to an OO principle, – open to extensions– closed to class interface changes
Luca Lista - CHEP '98Luca Lista - CHEP '98
Visitor pattern Visitor pattern class diagramclass diagram
Ifr3DClusteraccept (const IfrClusterVisitor<T>& v) : T
Ifr2DClusteraccept (const IfrClusterVisitor<T>& v) : T
IfrAbs3Daccept (IfrClusterVisitor<T>) : T
Ifr3DCompositeaccept (const IfrClusterVisitor<T>& v) : T
T
IfrClusterVisitoroperate (const Ifr3DCluster*) : Toperate (const IfrInner3DCluster*) : Toperate (const Ifr3DComposite*) : Toperate (const Ifr2DCluster*) : T
IfrInner3DClusteraccept (const IfrClusterVisitor<T>& v) : T
{ return v.operate(this);}
1..n
IfrVstCenterOfGravityoperate (const Ifr3DCluster*) : Hep3Vectoroperate (const IfrInner3DCluster*) : Hep3Vectoroperate (const Ifr3DComposite*) : Hep3Vectoroperate (const Ifr2DCluster*) : Hep3Vector
IfrClusterVisitor{Hep3Vector}
2
Luca Lista - CHEP '98Luca Lista - CHEP '98
Visitors featuresVisitors features• New visitors can be added as new subclasses of
IfrClusterVisitor<myType> with no other changes• New cluster types can be added without mayor design
changes (e.g.: Ifr3DFastCluster)– but all the visitors subclasses should be updated to work
on the new cluster subclass• Details can be handled internally:
– calibrations, alignments• The code which uses IfrAbs3D and visitors appears to be
much more robust than before– a couple of unsolved bugs have been understood and fixed
during the migration
Luca Lista - CHEP '98Luca Lista - CHEP '98
Visitors features (cont.)Visitors features (cont.)• Recursive action on Ifr3DComposite
components matches the composite pattern – Ifr3DComposite has n IfrAbs3D’s
• A visitor subclass handles a built-in cache mechanism implemented with a hash dictionary. – a visitor “knows” the cluster he has already “visited” – the cache is invalidated at:
• destruction of every cluster for the deleted cluster• at the end of every event
(to prevent the accumulation of possible memory leaks)
Luca Lista - CHEP '98Luca Lista - CHEP '98
Available VisitorsAvailable Visitors• Visitors are
singleton/multiton
• Some of the available visitors are:
• IfrVstCenterOfGravity• IfrVstCovMatrix• IfrVstFirstLastLayer
– first | last | lastBarrel• IfrVstHasSector
– forward | backward | barrel • IfrVstHitLayers• IfrVstHitsInLayer
– n = 1, ... ,19• IfrVstMaxMissed• IfrVstNumberOfStrips• . . .
Luca Lista - CHEP '98Luca Lista - CHEP '98
Visitors UsageVisitors Usage• How to use visitors:IfrAbs3D* ifr; // get a cluster from somewhere
// compute center of gravityHepPoint c = ifr->accept( IfrVstCenterOfgravity::instance() );
// has hits in the barrel?bool barrel = ifr->accept(IfrVstHasSector::instance (IfrVstHasSector::barrel) ); // get number of hits in each layerint n[19], i;for (i = 0; i < 19; i++) n[i] = ifr->accept( IfrVstHitsInLayer::instance(i+1) );
// compute max. number of missed layersint maxMiss = ifr->accept( IfrVstMaxMissed::instance() );
Luca Lista - CHEP '98Luca Lista - CHEP '98
ReferencesReferences• On-line Ifr documentation:
– http://www1.na.infn.it/wsubnucl/accel/BaBar/Reco/6.7.3/see IfrData and IfrVisitor packages for class diagram and C++ code
• Original proposal document:– http://www1.na.infn.it/wsubnucl/accel/BaBar/Reco/visitors.html