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 TrackingUtilities::CDCWireHit *const > CompositeProcessingSignalListener ProcessingSignalListener

Classes

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

Public Types

using IOTypes
 Types that should be served to apply on invocation.
 
using IOTypes
 Types that should be served to apply on invocation.
 
using IOVectors
 Vector types that should be served to apply on invocation.
 
using IOVectors
 Vector types that should be served to apply on invocation.
 

Public Member Functions

void setMaximalLayerJump (int maximalLayerJump)
 Set maximal layer jump for state creation.
 
void setMaximalLayerJumpBackwardSeed (int maximalLayerJumpBackwardSeed)
 Set maximal layer jump for backward seed tracks.
 
void setMaximalDeltaPhi (double maximalDeltaPhi)
 Set maximal delta phi for state creation.
 
void setHitFindingDirection (const std::string &hitFindingDirection)
 Set hit finding direction.
 
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 TrackingUtilities::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 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
 Short hand for ToRangeImpl.
 
using ToVector
 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 = TrackingUtilities::Findlet<CDCCKFState, const CDCCKFState, const TrackingUtilities::CDCWireHit* const>
 Parent class.
 

Private Attributes

int m_maximalLayerJump = 2
 Maximum allowed step over layers.
 
int m_firstActiveCDCLayer = 0
 First active inner CDC layer (0 for default Belle II, 14 if SL0 and SL1 deactivated)
 
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.
 
TrackingUtilities::EForwardBackward m_param_writeOutDirection = TrackingUtilities::EForwardBackward::c_Unknown
 Direction parameter converted from the string parameters.
 
bool doForward = true
 Direction parameter converted to boolean for convenience.
 
std::vector< CDCCKFWireHitCache > m_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
 Flag to keep track whether initialization happened before.
 
bool m_terminated
 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 35 of file CDCCKFStateCreator.h.

Member Typedef Documentation

◆ IOTypes [1/2]

using IOTypes
inherited

Types that should be served to apply on invocation.

Definition at line 30 of file Findlet.h.

◆ IOTypes [2/2]

using IOTypes
inherited

Types that should be served to apply on invocation.

Definition at line 30 of file Findlet.h.

◆ IOVectors [1/2]

using IOVectors
inherited

Vector types that should be served to apply on invocation.

Definition at line 53 of file Findlet.h.

◆ IOVectors [2/2]

using IOVectors
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 40 of file CDCCKFStateCreator.h.

◆ ToVector [1/2]

using ToVector
protectedinherited

Short hand for ToRangeImpl.

Definition at line 49 of file Findlet.h.

◆ ToVector [2/2]

using ToVector
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 53 of file CompositeProcessingSignalListener.cc.

56{
58}
Interface for a minimal algorithm part that wants to expose some parameters to a module.
Definition Findlet.h:26

◆ apply()

void apply ( std::vector< CDCCKFState > & nextStates,
const CDCCKFPath & path,
const std::vector< const TrackingUtilities::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 118 of file CDCCKFStateCreator.h.

120 {
121 // TODO: as we do not need any information on the current state (track state) of the path, we could in principle
122 // TODO: precalculate everything in here
123
124 // Create cache over wirehits, if empty:
125 if (m_wireHitCache.empty()) {
126 const size_t nHits = wireHits.size();
127 m_wireHitCache.reserve(nHits);
128 for (auto hitPtr : wireHits) {
129 // to speed things up, don't consider background/taken hits at all (and not just in the loop below).
130 // I can't just remove them from the list, otherwise the relation to the wireHits is broken
131 // so set the layer index to a high number.
132 if (hitPtr->getAutomatonCell().hasBackgroundFlag() || hitPtr->getAutomatonCell().hasTakenFlag()) {
133 m_wireHitCache.push_back(CDCCKFWireHitCache{99999, 0.});
134 } else {
135 m_wireHitCache.push_back(CDCCKFWireHitCache{hitPtr->getWire().getICLayer(), hitPtr->getRefPos2D().Phi()});
136 }
137 }
138 }
139
140 // Cache last-on-the-path state info too:
141 const auto& lastState = path.back();
142 double lastPhi = 0;
143 double lastICLayer = -1;
144 if (lastState.isSeed()) {
145 if (doForward) {
146 lastICLayer = m_firstActiveCDCLayer; // if SL0 and SL1 turned off this 14, nominal 0
147 } else {
148 const auto& wireTopology = CDC::CDCWireTopology::getInstance();
149 const auto& wires = wireTopology.getWires();
150 const float maxForwardZ = wires.back().getForwardZ(); // 157.615
151 const float maxBackwardZ = wires.back().getBackwardZ(); // -72.0916
152
153 const ROOT::Math::XYZVector seedPos(lastState.getSeed()->getPositionSeed());
154 const float seedPosZ = seedPos.z();
155
156 if (seedPosZ < maxForwardZ && seedPosZ > maxBackwardZ) {
157 lastICLayer = 56;
158 } else {
159 // do straight extrapolation of seed momentum to CDC outer walls
160 ROOT::Math::XYZVector seedMomZOne(lastState.getSeed()->getMomentumSeed());
161 seedMomZOne = seedMomZOne / seedMomZOne.z();
162 // const float maxZ = seedPosZ > 0 ? maxForwardZ : maxBackwardZ;
163 // const ROOT::Math::XYZVector extrapolatedPos = seedPos - seedMom / seedMom.R() * (seedPosZ - maxZ);
164
165 // find closest iCLayer
166 float minDist = 99999;
167 for (const auto& wire : wires) {
168 const float maxZ = seedPosZ > 0 ? wire.getForwardZ() : wire.getBackwardZ();
169 const ROOT::Math::XYZVector extrapolatedPos = seedPos - seedMomZOne * (seedPosZ - maxZ);
170
171 const auto distance = wire.getDistance(extrapolatedPos);
172 if (distance < minDist) {
173 minDist = distance;
174 lastICLayer = wire.getICLayer();
175 }
176 }
177 B2DEBUG(29, lastICLayer << " (d=" << minDist << ")");
178 }
179 }
180 } else {
181 lastPhi = lastState.getWireHit()->getRefPos2D().Phi();
182 lastICLayer = lastState.getWireHit()->getWire().getICLayer();
183 }
184
185 // Get sorted vector of wireHits on the path for faster search
186 std::vector<const TrackingUtilities::CDCWireHit*> wireHitsOnPath;
187 for (auto const& state : path) {
188 if (! state.isSeed()) {
189 wireHitsOnPath.push_back(state.getWireHit());
190 }
191 }
192 std::sort(wireHitsOnPath.begin(), wireHitsOnPath.end());
193
194 size_t nHits = wireHits.size();
195 for (size_t i = 0; i < nHits; i++) {
196 // adjust direction of loop (minimal speed gain)
197 int idx = doForward ? i : nHits - i - 1;
198
199 const auto iCLayer = m_wireHitCache[idx].icLayer; // wireHit->getWire().getICLayer();
200 if (m_param_writeOutDirection == TrackingUtilities::EForwardBackward::c_Backward && lastState.isSeed()) {
201 if (std::abs(lastICLayer - iCLayer) > m_maximalLayerJump_backwardSeed) {
202 continue;
203 }
204 } else if (std::abs(lastICLayer - iCLayer) > m_maximalLayerJump) {
205 continue;
206 }
207
208 if (! lastState.isSeed()) {
209 double deltaPhi = TrackingUtilities::AngleUtil::normalised(lastPhi - m_wireHitCache[idx].phi);
210 if (fabs(deltaPhi) > m_maximalDeltaPhi) {
211 continue;
212 }
213 }
214
215 const TrackingUtilities::CDCWireHit* wireHit = wireHits[idx];
216
217 if (std::binary_search(wireHitsOnPath.begin(), wireHitsOnPath.end(), wireHit)) {
218 continue;
219 }
220
221 nextStates.emplace_back(wireHit);
222 }
223 }

◆ beginEvent()

void beginEvent ( )
inlineoverridevirtual

Clear the wireHit cache.

Reimplemented from ProcessingSignalListener.

Definition at line 100 of file CDCCKFStateCreator.h.

101 {
102 Super::beginEvent();
103 m_wireHitCache.clear();
104
105 // Determine direction of track building
106 m_param_writeOutDirection = fromString(m_param_writeOutDirectionAsString);
107
108 if (m_param_writeOutDirection == TrackingUtilities::EForwardBackward::c_Forward) {
109 doForward = true;
110 } else if (m_param_writeOutDirection == TrackingUtilities::EForwardBackward::c_Backward) {
111 doForward = false;
112 } else {
113 B2FATAL("CDCCKFStateCreator: No valid direction specified. Please use forward/backward.");
114 }
115 }
TrackingUtilities::EForwardBackward fromString(const std::string &directionString)
Helper function to turn a direction string into a valid forward backward information.

◆ beginRun()

void beginRun ( )
overrideinherited

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

Definition at line 33 of file CompositeProcessingSignalListener.cc.

24{
27 psl->beginRun();
28 }
29}
void beginRun() override
Receive and dispatch signal for the beginning of a new run.
virtual void beginRun()
Receive signal for the beginning of a new run.

◆ endRun()

void endRun ( )
overrideinherited

Receive and dispatch signal for the end of the run.

Definition at line 39 of file CompositeProcessingSignalListener.cc.

40{
42 psl->endRun();
43 }
45}
void endRun() override
Receive and dispatch signal for the end of the run.
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 CompositeProcessingSignalListener.

Definition at line 84 of file CDCCKFStateCreator.h.

85 {
86 moduleParamList->addParameter(TrackingUtilities::prefixed(prefix, "maximalLayerJump"),
87 m_maximalLayerJump, "Maximal jump over N layers", m_maximalLayerJump);
88 moduleParamList->addParameter(TrackingUtilities::prefixed(prefix, "maximalLayerJumpBackwardSeed"),
89 m_maximalLayerJump_backwardSeed, "Maximal jump over N layers", m_maximalLayerJump_backwardSeed);
90 moduleParamList->addParameter(TrackingUtilities::prefixed(prefix, "maximalDeltaPhi"),
91 m_maximalDeltaPhi, "Maximal distance in phi between wires for Z=0 plane", m_maximalDeltaPhi);
92 moduleParamList->addParameter(TrackingUtilities::prefixed(prefix, "hitFindingDirection"),
93 m_param_writeOutDirectionAsString, "Start from innermost/outermost CDC layers", m_param_writeOutDirectionAsString);
94
95 moduleParamList->addParameter(TrackingUtilities::prefixed(prefix, "firstActiveCDCLayer"),
96 m_firstActiveCDCLayer, "First CDC layer which is active (i.e. considered for layer jumps)", m_firstActiveCDCLayer);
97 }

◆ getDescription() [1/2]

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 }

◆ getDescription() [2/2]

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 56 of file CompositeProcessingSignalListener.cc.

61{
63}

◆ initialize()

void initialize ( )
overrideinherited

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

Definition at line 30 of file CompositeProcessingSignalListener.cc.

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

◆ setHitFindingDirection()

void setHitFindingDirection ( const std::string & hitFindingDirection)
inline

Set hit finding direction.

Parameters
hitFindingDirectionStart from innermost/outermost CDC layers

Definition at line 78 of file CDCCKFStateCreator.h.

79 {
80 m_param_writeOutDirectionAsString = hitFindingDirection;
81 }

◆ setMaximalDeltaPhi()

void setMaximalDeltaPhi ( double maximalDeltaPhi)
inline

Set maximal delta phi for state creation.

Parameters
maximalDeltaPhiMaximum distance in phi between wires for Z=0 plane

Definition at line 72 of file CDCCKFStateCreator.h.

72{ m_maximalDeltaPhi = maximalDeltaPhi; }

◆ setMaximalLayerJump()

void setMaximalLayerJump ( int maximalLayerJump)
inline

Set maximal layer jump for state creation.

Parameters
maximalLayerJumpMaximum number of layers to jump

Definition at line 57 of file CDCCKFStateCreator.h.

57{ m_maximalLayerJump = maximalLayerJump; }

◆ setMaximalLayerJumpBackwardSeed()

void setMaximalLayerJumpBackwardSeed ( int maximalLayerJumpBackwardSeed)
inline

Set maximal layer jump for backward seed tracks.

Parameters
maximalLayerJumpBackwardSeedMaximum number of layers to jump for backward seeds

Definition at line 63 of file CDCCKFStateCreator.h.

64 {
65 m_maximalLayerJump_backwardSeed = maximalLayerJumpBackwardSeed;
66 }

◆ terminate()

void terminate ( )
overrideinherited

Receive and dispatch Signal for termination of the event processing.

Definition at line 42 of file CompositeProcessingSignalListener.cc.

48{
50 psl->terminate();
51 }
53}
void terminate() override
Receive and dispatch Signal for termination of the event processing.
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 239 of file CDCCKFStateCreator.h.

◆ m_firstActiveCDCLayer

int m_firstActiveCDCLayer = 0
private

First active inner CDC layer (0 for default Belle II, 14 if SL0 and SL1 deactivated)

Definition at line 229 of file CDCCKFStateCreator.h.

◆ m_initialized

bool m_initialized
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 233 of file CDCCKFStateCreator.h.

◆ m_maximalLayerJump

int m_maximalLayerJump = 2
private

Maximum allowed step over layers.

Definition at line 227 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 231 of file CDCCKFStateCreator.h.

◆ m_param_writeOutDirection

TrackingUtilities::EForwardBackward m_param_writeOutDirection = TrackingUtilities::EForwardBackward::c_Unknown
private

Direction parameter converted from the string parameters.

Definition at line 237 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 235 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 60 of file CompositeProcessingSignalListener.h.

◆ m_terminated

bool m_terminated
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 242 of file CDCCKFStateCreator.h.

242{};

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