Belle II Software development
CDCCKFStateCreator Class Referenceabstract

Create CKF states, based on the current path. Perform some basic selection at this stage (based on phi, max. jump of layers) More...

#include <CDCCKFStateCreator.h>

Inheritance diagram for CDCCKFStateCreator:
Findlet< CDCCKFState, const CDCCKFState, const TrackFindingCDC::CDCWireHit *const > CompositeProcessingSignalListener ProcessingSignalListener

Classes

struct  CDCCKFWireHitCache
 Store basic wire info for faster access. More...
 

Public Types

using IOTypes = std::tuple< AIOTypes... >
 Types that should be served to apply on invocation.
 
using IOVectors = std::tuple< std::vector< AIOTypes >... >
 Vector types that should be served to apply on invocation.
 

Public Member Functions

void exposeParameters (ModuleParamList *moduleParamList, const std::string &prefix) override
 Expose the parameters of the sub findlets.
 
void beginEvent () override
 Clear the wireHit cache.
 
void apply (std::vector< CDCCKFState > &nextStates, const CDCCKFPath &path, const std::vector< const TrackFindingCDC::CDCWireHit * > &wireHits) override
 Main method of the findlet. Select + create states (output parameter nextStates) suitable for the input path, based on input wireHits.
 
virtual std::string getDescription ()
 Brief description of the purpose of the concrete findlet.
 
virtual void apply (ToVector< AIOTypes > &... ioVectors)=0
 Main function executing the algorithm.
 
void initialize () override
 Receive and dispatch signal before the start of the event processing.
 
void beginRun () override
 Receive and dispatch signal for the beginning of a new run.
 
void endRun () override
 Receive and dispatch signal for the end of the run.
 
void terminate () override
 Receive and dispatch Signal for termination of the event processing.
 

Protected Types

using ToVector = typename ToVectorImpl< T >::Type
 Short hand for ToRangeImpl.
 

Protected Member Functions

void addProcessingSignalListener (ProcessingSignalListener *psl)
 Register a processing signal listener to be notified.
 
int getNProcessingSignalListener ()
 Get the number of currently registered listeners.
 

Private Types

using Super = TrackFindingCDC::Findlet< CDCCKFState, const CDCCKFState, const TrackFindingCDC::CDCWireHit *const >
 Parent class.
 

Private Attributes

int m_maximalLayerJump = 2
 Maximum allowed step over layers.
 
int m_maximalLayerJump_backwardSeed = 3
 Maximum allowed step over layers (if outside->in CKF) for first step after seed (e.g. ECLShower)
 
double m_maximalDeltaPhi = TMath::Pi() / 8
 Maximal distance in phi between the path last hit/seed and the candidate hit.
 
std::string m_param_writeOutDirectionAsString = "forward"
 Parameter for the direction in which the tracks are built.
 
TrackFindingCDC::EForwardBackward m_param_writeOutDirection = TrackFindingCDC::EForwardBackward::c_Unknown
 Direction parameter converted from the string parameters.
 
bool doForward = true
 Direction parameter converted to boolean for convenience.
 
std::vector< CDCCKFWireHitCachem_wireHitCache = {}
 Cache to store frequently used information.
 
std::vector< ProcessingSignalListener * > m_subordinaryProcessingSignalListeners
 References to subordinary signal processing listener contained in this findlet.
 
bool m_initialized = false
 Flag to keep track whether initialization happened before.
 
bool m_terminated = false
 Flag to keep track whether termination happened before.
 
std::string m_initializedAs
 Name of the type during initialisation.
 

Detailed Description

Create CKF states, based on the current path. Perform some basic selection at this stage (based on phi, max. jump of layers)

Definition at line 33 of file CDCCKFStateCreator.h.

Member Typedef Documentation

◆ IOTypes

using IOTypes = std::tuple<AIOTypes...>
inherited

Types that should be served to apply on invocation.

Definition at line 30 of file Findlet.h.

◆ IOVectors

using IOVectors = std::tuple< std::vector<AIOTypes>... >
inherited

Vector types that should be served to apply on invocation.

Definition at line 53 of file Findlet.h.

◆ Super

Parent class.

Definition at line 38 of file CDCCKFStateCreator.h.

◆ ToVector

using ToVector = typename ToVectorImpl<T>::Type
protectedinherited

Short hand for ToRangeImpl.

Definition at line 49 of file Findlet.h.

Member Function Documentation

◆ addProcessingSignalListener()

void addProcessingSignalListener ( ProcessingSignalListener psl)
protectedinherited

Register a processing signal listener to be notified.

Definition at line 55 of file CompositeProcessingSignalListener.cc.

56{
58}
std::vector< ProcessingSignalListener * > m_subordinaryProcessingSignalListeners
References to subordinary signal processing listener contained in this findlet.

◆ apply()

void apply ( std::vector< CDCCKFState > &  nextStates,
const CDCCKFPath path,
const std::vector< const TrackFindingCDC::CDCWireHit * > &  wireHits 
)
inlineoverride

Main method of the findlet. Select + create states (output parameter nextStates) suitable for the input path, based on input wireHits.

Definition at line 83 of file CDCCKFStateCreator.h.

85 {
86 // TODO: as we do not need any information on the current state (track state) of the path, we could in principle
87 // TODO: precalculate everything in here
88
89 // Create cache over wirehits, if empty:
90 if (m_wireHitCache.empty()) {
91 const size_t nHits = wireHits.size();
92 m_wireHitCache.reserve(nHits);
93 for (auto hitPtr : wireHits) {
94 // to speed things up, don't consider background/taken hits at all (and not just in the loop below).
95 // I can't just remove them from the list, otherwise the relation to the wireHits is broken
96 // so set the layer index to a high number.
97 if (hitPtr->getAutomatonCell().hasBackgroundFlag() || hitPtr->getAutomatonCell().hasTakenFlag()) {
98 m_wireHitCache.push_back(CDCCKFWireHitCache{99999, 0.});
99 } else {
100 m_wireHitCache.push_back(CDCCKFWireHitCache{hitPtr->getWire().getICLayer(), hitPtr->getRefPos2D().phi()});
101 }
102 }
103 }
104
105 // Cache last-on-the-path state info too:
106 const auto& lastState = path.back();
107 double lastPhi = 0;
108 double lastICLayer = -1;
109 if (lastState.isSeed()) {
110 if (doForward) {
111 lastICLayer = 0;
112 } else {
113 const auto& wireTopology = TrackFindingCDC::CDCWireTopology::getInstance();
114 const auto& wires = wireTopology.getWires();
115 const float maxForwardZ = wires.back().getForwardZ(); // 157.615
116 const float maxBackwardZ = wires.back().getBackwardZ(); // -72.0916
117
118 const TrackFindingCDC::Vector3D seedPos(lastState.getSeed()->getPositionSeed());
119 const float seedPosZ = seedPos.z();
120
121 if (seedPosZ < maxForwardZ && seedPosZ > maxBackwardZ) {
122 lastICLayer = 56;
123 } else {
124 // do straight extrapolation of seed momentum to CDC outer walls
125 TrackFindingCDC::Vector3D seedMomZOne(lastState.getSeed()->getMomentumSeed());
126 seedMomZOne = seedMomZOne / seedMomZOne.z();
127 // const float maxZ = seedPosZ > 0 ? maxForwardZ : maxBackwardZ;
128 // const TrackFindingCDC::Vector3D extrapolatedPos = seedPos - seedMom / seedMom.norm() * (seedPosZ - maxZ);
129
130 // find closest iCLayer
131 float minDist = 99999;
132 for (const auto& wire : wires) {
133 const float maxZ = seedPosZ > 0 ? wire.getForwardZ() : wire.getBackwardZ();
134 const TrackFindingCDC::Vector3D extrapolatedPos = seedPos - seedMomZOne * (seedPosZ - maxZ);
135
136 const auto distance = wire.getDistance(extrapolatedPos);
137 if (distance < minDist) {
138 minDist = distance;
139 lastICLayer = wire.getICLayer();
140 }
141 }
142 B2DEBUG(29, lastICLayer << " (d=" << minDist << ")");
143 }
144 }
145 } else {
146 lastPhi = lastState.getWireHit()->getRefPos2D().phi();
147 lastICLayer = lastState.getWireHit()->getWire().getICLayer();
148 }
149
150 // Get sorted vector of wireHits on the path for faster search
151 std::vector<const TrackFindingCDC::CDCWireHit*> wireHitsOnPath;
152 for (auto const& state : path) {
153 if (! state.isSeed()) {
154 wireHitsOnPath.push_back(state.getWireHit());
155 }
156 }
157 std::sort(wireHitsOnPath.begin(), wireHitsOnPath.end());
158
159 size_t nHits = wireHits.size();
160 for (size_t i = 0; i < nHits; i++) {
161 // adjust direction of loop (minimal speed gain)
162 int idx = doForward ? i : nHits - i - 1;
163
164 const auto iCLayer = m_wireHitCache[idx].icLayer; // wireHit->getWire().getICLayer();
165 if (m_param_writeOutDirection == TrackFindingCDC::EForwardBackward::c_Backward && lastState.isSeed()) {
166 if (std::abs(lastICLayer - iCLayer) > m_maximalLayerJump_backwardSeed) {
167 continue;
168 }
169 } else if (std::abs(lastICLayer - iCLayer) > m_maximalLayerJump) {
170 continue;
171 }
172
173 if (! lastState.isSeed()) {
174 double deltaPhi = TrackFindingCDC::AngleUtil::normalised(lastPhi - m_wireHitCache[idx].phi);
175 if (fabs(deltaPhi) > m_maximalDeltaPhi) {
176 continue;
177 }
178 }
179
180 const TrackFindingCDC::CDCWireHit* wireHit = wireHits[idx];
181
182 if (std::binary_search(wireHitsOnPath.begin(), wireHitsOnPath.end(), wireHit)) {
183 continue;
184 }
185
186 nextStates.emplace_back(wireHit);
187 }
188 }
double m_maximalDeltaPhi
Maximal distance in phi between the path last hit/seed and the candidate hit.
int m_maximalLayerJump_backwardSeed
Maximum allowed step over layers (if outside->in CKF) for first step after seed (e....
int m_maximalLayerJump
Maximum allowed step over layers.
bool doForward
Direction parameter converted to boolean for convenience.
std::vector< CDCCKFWireHitCache > m_wireHitCache
Cache to store frequently used information.
TrackFindingCDC::EForwardBackward m_param_writeOutDirection
Direction parameter converted from the string parameters.
static CDCWireTopology & getInstance()
Getter for the singleton instance of the wire topology.
static double normalised(const double angle)
Normalise an angle to lie in the range from [-pi, pi].
Definition: Angle.h:33

◆ beginEvent()

void beginEvent ( )
inlineoverridevirtual

Clear the wireHit cache.

Reimplemented from ProcessingSignalListener.

Definition at line 65 of file CDCCKFStateCreator.h.

66 {
68 m_wireHitCache.clear();
69
70 // Determine direction of track building
72
73 if (m_param_writeOutDirection == TrackFindingCDC::EForwardBackward::c_Forward) {
74 doForward = true;
75 } else if (m_param_writeOutDirection == TrackFindingCDC::EForwardBackward::c_Backward) {
76 doForward = false;
77 } else {
78 B2FATAL("CDCCKFStateCreator: No valid direction specified. Please use forward/backward.");
79 }
80 }
std::string m_param_writeOutDirectionAsString
Parameter for the direction in which the tracks are built.
void beginEvent() override
Receive and dispatch signal for the start of a new event.
TrackFindingCDC::EForwardBackward fromString(const std::string &directionString)
Helper function to turn a direction string into a valid forward backward information.

◆ beginRun()

void beginRun ( )
overridevirtualinherited

Receive and dispatch signal for the beginning of a new run.

Reimplemented from ProcessingSignalListener.

Reimplemented in LayerRelationFilter< AFilter >, FourHitFilter, QualityIndicatorFilter, ThreeHitFilter, TwoHitVirtualIPFilter, TwoHitVirtualIPQIFilter, RecoTrackStorer, ROIFinder, SpacePointLoaderAndPreparer, and TrackCandidateResultRefiner.

Definition at line 23 of file CompositeProcessingSignalListener.cc.

24{
27 psl->beginRun();
28 }
29}
Interface for an algorithm part that needs to receive the module processing signals.
virtual void beginRun()
Receive signal for the beginning of a new run.

◆ endRun()

void endRun ( )
overridevirtualinherited

Receive and dispatch signal for the end of the run.

Reimplemented from ProcessingSignalListener.

Definition at line 39 of file CompositeProcessingSignalListener.cc.

40{
42 psl->endRun();
43 }
45}
virtual void endRun()
Receive signal for the end of the run.

◆ exposeParameters()

void exposeParameters ( ModuleParamList moduleParamList,
const std::string &  prefix 
)
inlineoverridevirtual

Expose the parameters of the sub findlets.

Reimplemented from Findlet< CDCCKFState, const CDCCKFState, const TrackFindingCDC::CDCWireHit *const >.

Definition at line 52 of file CDCCKFStateCreator.h.

53 {
54 moduleParamList->addParameter(TrackFindingCDC::prefixed(prefix, "maximalLayerJump"),
55 m_maximalLayerJump, "Maximal jump over N layers", m_maximalLayerJump);
56 moduleParamList->addParameter(TrackFindingCDC::prefixed(prefix, "maximalLayerJumpBackwardSeed"),
58 moduleParamList->addParameter(TrackFindingCDC::prefixed(prefix, "maximalDeltaPhi"),
59 m_maximalDeltaPhi, "Maximal distance in phi between wires for Z=0 plane", m_maximalDeltaPhi);
60 moduleParamList->addParameter(TrackFindingCDC::prefixed(prefix, "hitFindingDirection"),
61 m_param_writeOutDirectionAsString, "Start from innermost/outermost CDC layers", m_param_writeOutDirectionAsString);
62 }

◆ getDescription()

virtual std::string getDescription ( )
inlinevirtualinherited

Brief description of the purpose of the concrete findlet.

Definition at line 60 of file Findlet.h.

61 {
62 return "(no description)";
63 }

◆ getNProcessingSignalListener()

int getNProcessingSignalListener ( )
protectedinherited

Get the number of currently registered listeners.

Definition at line 60 of file CompositeProcessingSignalListener.cc.

61{
63}

◆ initialize()

void initialize ( )
overridevirtualinherited

Receive and dispatch signal before the start of the event processing.

Reimplemented from ProcessingSignalListener.

Reimplemented in UnionVarSet< AObject >, UnionVarSet< Object >, VariadicUnionVarSet< AVarSets >, ResultStorer< Belle2::CKFToPXDResult >, ResultStorer< Belle2::CKFToSVDResult >, BaseEventTimeExtractor< RecoTrack * >, BaseEventTimeExtractor< TrackFindingCDC::CDCWireHit & >, StereoHitTrackQuadTreeMatcher< Belle2::TrackFindingCDC::HyperHough >, StereoHitTrackQuadTreeMatcher< Belle2::TrackFindingCDC::QuadraticLegendre >, StereoHitTrackQuadTreeMatcher< Belle2::TrackFindingCDC::Z0TanLambdaLegendre >, OnVarSet< Filter< ATruthVarSet::Object > >, OnVarSet< Filter< AVarSet::Object > >, OnVarSet< BaseFacetFilter >, OnVarSet< BaseFacetRelationFilter >, OnVarSet< BaseAxialSegmentPairFilter >, OnVarSet< BaseSegmentRelationFilter >, OnVarSet< BaseTrackRelationFilter >, OnVarSet< BaseSegmentPairRelationFilter >, MCSymmetric< BaseAxialSegmentPairFilter >, MCSymmetric< BaseFacetFilter >, MCSymmetric< BaseFacetRelationFilter >, MCSymmetric< BaseSegmentPairFilter >, MCSymmetric< BaseSegmentPairRelationFilter >, MCSymmetric< BaseSegmentRelationFilter >, MCSymmetric< BaseSegmentTripleFilter >, MCSymmetric< BaseSegmentTripleRelationFilter >, MCSymmetric< BaseTrackRelationFilter >, StoreArrayLoader< const Belle2::SpacePoint >, StoreArrayLoader< DataStoreInputTypeRefType >, StoreVectorSwapper< Belle2::TrackFindingCDC::CDCFacet >, StoreVectorSwapper< Belle2::TrackFindingCDC::CDCWireHit, true >, StoreVectorSwapper< Belle2::TrackFindingCDC::CDCSegment2D >, StoreVectorSwapper< Belle2::TrackFindingCDC::CDCTrack >, StoreVectorSwapper< Belle2::TrackFindingCDC::CDCSegmentPair >, StoreVectorSwapper< Belle2::TrackFindingCDC::CDCSegmentTriple >, RelationVarSet< ABaseVarSet >, QualityIndicatorFilter, TwoHitVirtualIPQIFilter, MultiHoughSpaceFastInterceptFinder, RawTrackCandCleaner< AHit >, RawTrackCandCleaner< Belle2::vxdHoughTracking::VXDHoughState >, RecoTrackStorer, ROIFinder, SingleHoughSpaceFastInterceptFinder, SpacePointLoaderAndPreparer, TrackCandidateOverlapResolver, and TrackCandidateResultRefiner.

Definition at line 15 of file CompositeProcessingSignalListener.cc.

16{
19 psl->initialize();
20 }
21}
virtual void initialize()
Receive signal before the start of the event processing.

◆ terminate()

void terminate ( )
overridevirtualinherited

Receive and dispatch Signal for termination of the event processing.

Reimplemented from ProcessingSignalListener.

Reimplemented in StereoHitTrackQuadTreeMatcher< Belle2::TrackFindingCDC::HyperHough >, StereoHitTrackQuadTreeMatcher< Belle2::TrackFindingCDC::QuadraticLegendre >, and StereoHitTrackQuadTreeMatcher< Belle2::TrackFindingCDC::Z0TanLambdaLegendre >.

Definition at line 47 of file CompositeProcessingSignalListener.cc.

48{
50 psl->terminate();
51 }
53}
virtual void terminate()
Receive Signal for termination of the event processing.

Member Data Documentation

◆ doForward

bool doForward = true
private

Direction parameter converted to boolean for convenience.

Definition at line 202 of file CDCCKFStateCreator.h.

◆ m_initialized

bool m_initialized = false
privateinherited

Flag to keep track whether initialization happened before.

Definition at line 52 of file ProcessingSignalListener.h.

◆ m_initializedAs

std::string m_initializedAs
privateinherited

Name of the type during initialisation.

Definition at line 58 of file ProcessingSignalListener.h.

◆ m_maximalDeltaPhi

double m_maximalDeltaPhi = TMath::Pi() / 8
private

Maximal distance in phi between the path last hit/seed and the candidate hit.

Definition at line 196 of file CDCCKFStateCreator.h.

◆ m_maximalLayerJump

int m_maximalLayerJump = 2
private

Maximum allowed step over layers.

Definition at line 192 of file CDCCKFStateCreator.h.

◆ m_maximalLayerJump_backwardSeed

int m_maximalLayerJump_backwardSeed = 3
private

Maximum allowed step over layers (if outside->in CKF) for first step after seed (e.g. ECLShower)

Definition at line 194 of file CDCCKFStateCreator.h.

◆ m_param_writeOutDirection

TrackFindingCDC::EForwardBackward m_param_writeOutDirection = TrackFindingCDC::EForwardBackward::c_Unknown
private

Direction parameter converted from the string parameters.

Definition at line 200 of file CDCCKFStateCreator.h.

◆ m_param_writeOutDirectionAsString

std::string m_param_writeOutDirectionAsString = "forward"
private

Parameter for the direction in which the tracks are built.

Definition at line 198 of file CDCCKFStateCreator.h.

◆ m_subordinaryProcessingSignalListeners

std::vector<ProcessingSignalListener*> m_subordinaryProcessingSignalListeners
privateinherited

References to subordinary signal processing listener contained in this findlet.

Definition at line 52 of file CompositeProcessingSignalListener.h.

◆ m_terminated

bool m_terminated = false
privateinherited

Flag to keep track whether termination happened before.

Definition at line 55 of file ProcessingSignalListener.h.

◆ m_wireHitCache

std::vector<CDCCKFWireHitCache> m_wireHitCache = {}
private

Cache to store frequently used information.

Definition at line 205 of file CDCCKFStateCreator.h.


The documentation for this class was generated from the following file: