8#include <tracking/modules/fitter/timeEstimator/BaseTrackTimeEstimatorModule.h>
10#include <tracking/trackFitting/fitter/base/TrackFitter.h>
12#include <framework/geometry/B2Vector3.h>
18 double calculateVelocity(
const ROOT::Math::XYZVector& momentum,
const Const::ChargedStable& particleHypothesis)
21 const double m = particleHypothesis.
getMass();
22 const double p = momentum.R();
23 const double E = hypot(m, p);
24 const double beta = p /
E;
34 setDescription(
"Module estimating the track time of RecoTracks - before or after the fit. "
35 "Loops over all RecoTracks and set their time seed correctly. In case of using the fitted information,"
36 "it also sets the track seeds of the position and momentum into the first measurement (where the time seed"
37 "is calculated). It also deletes all fitted information. Do not forget to refit "
38 "the tracks afterwards.");
45 " or the tracking seeds for doing the extrapolation. Of course, the track fit has to be performed to use the fitted information.",
49 "Which PDG code to use for creating the time estimate. How this information is used"
50 "depends on the implementation details of the child modules. Please only use the positive pdg code.",
57 "In cases where the readout of the trigger is not located at the trigger directly and the signal has to"
58 "propagate a non-vanashing distance, you can set the readout position here. Please note that you have to"
59 "enable this feature by using the useReadoutPosition flag. You can control the propagation speed with the"
62 "When this feature is enabled, the length from the incident of the particle in the trigger to the position"
63 "set by the readoutPosition flag is calculated and using the readoutPositionPropagationSpeed, a time is"
64 "calculated which is used in the time estimation as an offset."
67 "Speed of the propagation from the hit on the trigger to the readoutPosition. Only is used when the"
77 B2FATAL(
"The combination of using the seed information and the readout position is not implemented in the moment.");
91 }
catch (genfit::Exception& e) {
92 B2WARNING(
"Time extraction from fitted state failed because of " << e.what());
99 if (!(timeSeed > -1000)) {
101 B2WARNING(
"Fixing calculated seed Time " << timeSeed <<
" to zero.");
108 B2DEBUG(28,
"Setting seed to " << timeSeed);
109 recoTrack.setTimeSeed(timeSeed);
119 if (not trackRepresentation or not recoTrack.
wasFitSuccessful(trackRepresentation)) {
120 B2WARNING(
"Could not estimate a correct time, as the last fit failed.");
127 recoTrack.
setPositionAndMomentum(ROOT::Math::XYZVector(measuredState.getPos()), ROOT::Math::XYZVector(measuredState.getMom()));
132 const ROOT::Math::XYZVector& momentum = ROOT::Math::XYZVector(measuredState.getMom());
133 const double v = calculateVelocity(momentum, particleHypothesis);
135 const double flightTime = flightLength / v;
140 const ROOT::Math::XYZVector& position = ROOT::Math::XYZVector(measuredState.getPos());
143 const double propagationLength = (position - readoutPosition).
R();
146 return flightTime - propagationTime;
160 const double v = calculateVelocity(momentum, particleHypothesis);
virtual double estimateFlightLengthUsingFittedInformation(genfit::MeasuredStateOnPlane &measuredStateOnPlane) const =0
Overload this function to implement a specific extrapolation mechanism for fitted tracks....
double estimateTimeSeedUsingFittedInformation(RecoTrack &recoTrack, const Const::ChargedStable &particleHypothesis) const
Private helper function which calls the estimateFlightLengthUsingFittedInformation with the correct m...
void initialize() override
Initialize the needed StoreArrays and ensure they are created properly.
double m_param_timeOffset
If you want to subtract or add a certain time, you can use this variable.
void event() override
Loop over all RecoTracks and set their time seed correctly.
virtual double estimateFlightLengthUsingSeedInformation(const RecoTrack &recoTrack) const =0
Overload this function to implement a specific extrapolation mechanism for track seeds.
BaseTrackTimeEstimatorModule()
Initialize the module parameters.
bool m_param_useFittedInformation
Whether to use the information in the measurements (after fit) or the tracking seeds for doing the ex...
std::vector< double > m_param_readoutPosition
In cases where the readout of the trigger is not located at the trigger directly and the signal has t...
std::string m_param_recoTracksStoreArrayName
StoreArray name of the input and output reco tracks.
double estimateTimeSeedUsingSeedInformation(const RecoTrack &recoTrack, const Const::ChargedStable &particleHypothesis) const
Private helper function which calls the estimateFlightLengthUsingSeedInformation and computes the fli...
StoreArray< RecoTrack > m_recoTracks
RecoTracks StoreArray.
unsigned int m_param_pdgCodeToUseForEstimation
Which PDG code to use for creating the time estimate.
bool m_param_useReadoutPosition
Enable the usage of the readout position.
double m_param_readoutPositionPropagationSpeed
Speed of the propagation from the hit on the trigger to the readoutPosition.
Provides a type-safe way to pass members of the chargedStableSet set.
double getMass() const
Particle mass.
static const double speedOfLight
[cm/ns]
void setDescription(const std::string &description)
Sets the description of the module.
void setPropertyFlags(unsigned int propertyFlags)
Sets the flags for the module properties.
@ c_ParallelProcessingCertified
This module can be run in parallel processing mode safely (All I/O must be done through the data stor...
This is the Reconstruction Event-Data Model Track.
bool wasFitSuccessful(const genfit::AbsTrackRep *representation=nullptr) const
Returns true if the last fit with the given representation was successful.
void setPositionAndMomentum(const ROOT::Math::XYZVector &positionSeed, const ROOT::Math::XYZVector &momentumSeed)
Set the position and momentum seed of the reco track. ATTENTION: This is not the fitted position or m...
const genfit::MeasuredStateOnPlane & getMeasuredStateOnPlaneFromFirstHit(const genfit::AbsTrackRep *representation=nullptr) const
Return genfit's MeasuredStateOnPlane for the first hit in a fit useful for extrapolation of measureme...
ROOT::Math::XYZVector getMomentumSeed() const
Return the momentum seed stored in the reco track. ATTENTION: This is not the fitted momentum.
genfit::AbsTrackRep * getTrackRepresentationForPDG(int pdgCode) const
Return an already created track representation of the given reco track for the PDG.
bool isRequired(const std::string &name="")
Ensure this array/object has been registered previously.
static int createCorrectPDGCodeForChargedStable(const Const::ChargedStable &particleType, const RecoTrack &recoTrack)
Helper function to multiply the PDG code of a charged stable with the charge of the reco track (if ne...
void addParam(const std::string &name, T ¶mVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module.
Abstract base class for different kinds of events.