10#include <tracking/trackingUtilities/findlets/base/Findlet.h>
12#include <tracking/trackingUtilities/numerics/EForwardBackward.h>
13#include <tracking/ckf/general/utilities/SearchDirection.h>
15#include <tracking/ckf/cdc/entities/CDCCKFState.h>
16#include <tracking/ckf/cdc/entities/CDCCKFPath.h>
18#include <cdc/topology/CDCWire.h>
19#include <cdc/topology/CDCWireTopology.h>
21#include <tracking/trackingUtilities/utilities/StringManipulation.h>
22#include <framework/core/ModuleParamList.h>
23#include <tracking/trackingUtilities/numerics/Angle.h>
25#include <Math/Vector3D.h>
37 const TrackingUtilities::CDCWireHit* const > {
86 moduleParamList->
addParameter(TrackingUtilities::prefixed(prefix,
"maximalLayerJump"),
88 moduleParamList->
addParameter(TrackingUtilities::prefixed(prefix,
"maximalLayerJumpBackwardSeed"),
90 moduleParamList->
addParameter(TrackingUtilities::prefixed(prefix,
"maximalDeltaPhi"),
92 moduleParamList->
addParameter(TrackingUtilities::prefixed(prefix,
"hitFindingDirection"),
110 B2FATAL(
"CDCCKFStateCreator: No valid direction specified. Please use forward/backward.");
116 const std::vector<const TrackingUtilities::CDCWireHit*>& wireHits)
override
123 const size_t nHits = wireHits.size();
125 for (
auto hitPtr : wireHits) {
129 if (hitPtr->getAutomatonCell().hasBackgroundFlag() || hitPtr->getAutomatonCell().hasTakenFlag()) {
138 const auto& lastState = path.back();
140 double lastICLayer = -1;
141 if (lastState.isSeed()) {
146 const auto& wires = wireTopology.getWires();
147 const float maxForwardZ = wires.back().getForwardZ();
148 const float maxBackwardZ = wires.back().getBackwardZ();
150 const ROOT::Math::XYZVector seedPos(lastState.getSeed()->getPositionSeed());
151 const float seedPosZ = seedPos.z();
153 if (seedPosZ < maxForwardZ && seedPosZ > maxBackwardZ) {
157 ROOT::Math::XYZVector seedMomZOne(lastState.getSeed()->getMomentumSeed());
158 seedMomZOne = seedMomZOne / seedMomZOne.z();
163 float minDist = 99999;
164 for (
const auto& wire : wires) {
165 const float maxZ = seedPosZ > 0 ? wire.getForwardZ() : wire.getBackwardZ();
166 const ROOT::Math::XYZVector extrapolatedPos = seedPos - seedMomZOne * (seedPosZ - maxZ);
168 const auto distance = wire.getDistance(extrapolatedPos);
169 if (distance < minDist) {
171 lastICLayer = wire.getICLayer();
174 B2DEBUG(29, lastICLayer <<
" (d=" << minDist <<
")");
178 lastPhi = lastState.getWireHit()->getRefPos2D().Phi();
179 lastICLayer = lastState.getWireHit()->getWire().getICLayer();
183 std::vector<const TrackingUtilities::CDCWireHit*> wireHitsOnPath;
184 for (
auto const& state : path) {
185 if (! state.isSeed()) {
186 wireHitsOnPath.push_back(state.getWireHit());
189 std::sort(wireHitsOnPath.begin(), wireHitsOnPath.end());
191 size_t nHits = wireHits.size();
192 for (
size_t i = 0; i < nHits; i++) {
205 if (! lastState.isSeed()) {
214 if (std::binary_search(wireHitsOnPath.begin(), wireHitsOnPath.end(), wireHit)) {
218 nextStates.emplace_back(wireHit);
Create CKF states, based on the current path. Perform some basic selection at this stage (based on ph...
TrackingUtilities::Findlet< CDCCKFState, const CDCCKFState, const TrackingUtilities::CDCWireHit *const > Super
Parent class.
TrackingUtilities::EForwardBackward m_param_writeOutDirection
Direction parameter converted from the string parameters.
void setMaximalLayerJump(int maximalLayerJump)
Set maximal layer jump for state creation.
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.
void setMaximalDeltaPhi(double maximalDeltaPhi)
Set maximal delta phi for state creation.
void setMaximalLayerJumpBackwardSeed(int maximalLayerJumpBackwardSeed)
Set maximal layer jump for backward seed tracks.
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 inp...
void exposeParameters(ModuleParamList *moduleParamList, const std::string &prefix) override
Expose the parameters of the sub findlets.
std::string m_param_writeOutDirectionAsString
Parameter for the direction in which the tracks are built.
void setHitFindingDirection(const std::string &hitFindingDirection)
Set hit finding direction.
static CDCWireTopology & getInstance()
Getter for the singleton instance of the wire topology.
The Module parameter list class.
Class representing a hit wire in the central drift chamber.
void beginEvent() override
Receive and dispatch signal for the start of a new event.
Interface for a minimal algorithm part that wants to expose some parameters to a module.
void addParameter(const std::string &name, T ¶mVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module list.
std::vector< CDCCKFState > CDCCKFPath
Shortcut for the collection of CDC CKF-algorithm states.
TrackingUtilities::EForwardBackward fromString(const std::string &directionString)
Helper function to turn a direction string into a valid forward backward information.
Abstract base class for different kinds of events.
Store basic wire info for faster access.
double phi
azimuthal coordinate
static double normalised(const double angle)
Normalise an angle to lie in the range from [-pi, pi].