8#include <tracking/modules/fitter/timeEstimator/PlaneTriggerTrackTimeEstimatorModule.h>
10#include <tracking/dataobjects/RecoTrack.h>
11#include <framework/dataobjects/Helix.h>
12#include <framework/geometry/BFieldManager.h>
13#include <framework/geometry/B2Vector3.h>
40 const double s = measuredStateOnPlane.extrapolateToPlane(genfit::SharedPlanePtr(
new genfit::DetPlane(triggerPlanePosition,
41 triggerPlaneNormalDirection)));
45 }
catch (
const genfit::Exception& e) {
46 B2WARNING(
"Extrapolation failed: " << e.what());
62 const Helix h(position, momentum, charge, bZ);
64 const double arcLengthAtPosition = h.getArcLength2DAtXY(position.X(), position.Y());
66 double arcLengthOfIntersection = NAN;
74 if (triggerPlaneNormalDirection.
X() == 0 and triggerPlaneNormalDirection.
Y() == 0) {
76 arcLengthOfIntersection = (triggerPlanePosition.
Z() - h.getZ0()) / h.getTanLambda();
77 }
else if (triggerPlaneNormalDirection.
Z() == 0) {
84 triggerPlaneNormalDirection.
RotateZ(-h.getPhi0());
85 triggerPlanePosition.
RotateZ(-h.getPhi0());
87 const double n_x = triggerPlaneNormalDirection.
X();
88 const double n_y = triggerPlaneNormalDirection.
Y();
91 const double alpha = triggerPlanePosition.
Dot(triggerPlaneNormalDirection);
94 if (fabs(h.getOmega()) < 1e-3) {
96 const double arcLengthOfTrigger = (alpha + n_y * h.getD0()) / n_x;
98 arcLengthOfIntersection = arcLengthAtPosition - arcLengthOfTrigger;
101 const double beta = n_y * h.getOmega() * h.getD0() + alpha * h.getOmega();
108 const double A1 = (
sqrt(n_x * n_x * n_y * n_y - 2 * beta * n_y * n_y * n_y - beta * beta * n_y * n_y) - beta * n_x - n_x * n_y) /
109 (n_x * n_x + n_y * n_y);
110 const double A2 = (-
sqrt(n_x * n_x * n_y * n_y - 2 * beta * n_y * n_y * n_y - beta * beta * n_y * n_y) - beta * n_x - n_x * n_y) /
111 (n_x * n_x + n_y * n_y);
113 const double x1_unrotated = -A1 / h.getOmega();
114 const double y1_unrotated = -(1 -
sqrt(1 - A1 * A1)) / h.getOmega() - h.getD0();
115 const double x2_unrotated = -A2 / h.getOmega();
116 const double y2_unrotated = -(1 -
sqrt(1 - A2 * A2)) / h.getOmega() - h.getD0();
118 const double x1_rotated = h.getCosPhi0() * x1_unrotated + h.getSinPhi0() * y1_unrotated;
119 const double y1_rotated = -h.getSinPhi0() * x1_unrotated + h.getCosPhi0() * y1_unrotated;
120 const double x2_rotated = h.getCosPhi0() * x2_unrotated + h.getSinPhi0() * y2_unrotated;
121 const double y2_rotated = -h.getSinPhi0() * x2_unrotated + h.getCosPhi0() * y2_unrotated;
124 const double arcLengthOfTrigger1 = h.getArcLength2DAtXY(x1_rotated, y1_rotated);
125 const double arcLengthOfTrigger2 = h.getArcLength2DAtXY(x2_rotated, y2_rotated);
127 const double arcLengthOfIntersection1 = arcLengthAtPosition - arcLengthOfTrigger1;
128 const double arcLengthOfIntersection2 = arcLengthAtPosition - arcLengthOfTrigger2;
130 arcLengthOfIntersection = fabs(arcLengthOfIntersection1) < fabs(arcLengthOfIntersection2) ? arcLengthOfIntersection1 :
131 arcLengthOfIntersection2;
136 B2FATAL(
"This case for the normal direction is not implemented for using tracking seeds!");
139 const double s = arcLengthOfIntersection * hypot(1, h.getTanLambda());
DataType Z() const
access variable Z (= .at(2) without boundary check)
DataType X() const
access variable X (= .at(0) without boundary check)
DataType Y() const
access variable Y (= .at(1) without boundary check)
void RotateZ(DataType angle)
Rotates the B2Vector3 around the z-axis.
DataType Dot(const B2Vector3< DataType > &p) const
Scalar product.
Base Module estimating the track time of RecoTracks - before or after the fit.
double estimateFlightLengthUsingSeedInformation(const RecoTrack &recoTrack) const override
Estimate the flight length using only the tracking seeds.
double estimateFlightLengthUsingFittedInformation(genfit::MeasuredStateOnPlane &measuredStateOnPlane) const override
Estimate the flight length to the given plane using the extrapolation of the fit.
std::vector< double > m_param_triggerPlaneNormalDirection
3-Normal direction of the plane of the trigger.
std::vector< double > m_param_triggerPlanePosition
3-Position of the plane of the trigger.
PlaneTriggerTrackTimeEstimatorModule()
Initialize the module parameters.
This is the Reconstruction Event-Data Model Track.
ROOT::Math::XYZVector getPositionSeed() const
Return the position seed stored in the reco track. ATTENTION: This is not the fitted position.
short int getChargeSeed() const
Return the charge seed stored in the reco track. ATTENTION: This is not the fitted charge.
ROOT::Math::XYZVector getMomentumSeed() const
Return the momentum seed stored in the reco track. ATTENTION: This is not the fitted momentum.
static const double T
[tesla]
void addParam(const std::string &name, T ¶mVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module.
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
static void getField(const double *pos, double *field)
return the magnetic field at a given position.
double sqrt(double a)
sqrt for double
Abstract base class for different kinds of events.