8 #include <tracking/modules/fitter/timeEstimator/BaseTrackTimeEstimatorModule.h>
10 #include <tracking/trackFitting/fitter/base/TrackFitter.h>
11 #include <tracking/dataobjects/RecoTrack.h>
20 double calculateVelocity(
const TVector3& momentum,
const Const::ChargedStable& particleHypothesis)
23 const double m = particleHypothesis.
getMass();
24 const double p = momentum.Mag();
25 const double E = hypot(m, p);
26 const double beta = p / E;
27 const double v = beta * Const::speedOfLight;
33 BaseTrackTimeEstimatorModule::BaseTrackTimeEstimatorModule() :
36 setDescription(
"Module estimating the track time of RecoTracks - before or after the fit. "
37 "Loops over all RecoTracks and set their time seed correctly. In case of using the fitted information,"
38 "it also sets the track seeds of the position and momentum into the first measurement (where the time seed"
39 "is calculated). It also deletes all fitted information. Do not forget to refit "
40 "the tracks afterwards.");
47 " or the tracking seeds for doing the extrapolation. Of course, the track fit has to be performed to use the fitted information.",
51 "Which PDG code to use for creating the time estimate. How this information is used"
52 "depends on the implementation details of the child modules. Please only use the positive pdg code.",
59 "In cases where the readout of the trigger is not located at the trigger directly and the signal has to"
60 "propagate a non-vanashing distance, you can set the readout position here. Please note that you have to"
61 "enable this feature by using the useReadoutPosition flag. You can control the propagation speed with the"
64 "When this feature is enabled, the length from the incident of the particle in the trigger to the position"
65 "set by the readoutPosition flag is calculated and using the readoutPositionPropagationSpeed, a time is"
66 "calculated which is used in the time estimation as an offset."
69 "Speed of the propagation from the hit on the trigger to the readoutPosition. Only is used when the"
80 B2FATAL(
"The combination of using the seed information and the readout position is not implemented in the moment.");
91 for (
auto& recoTrack : recoTracks) {
97 B2WARNING(
"Time extraction from fitted state failed because of " << e.what());
104 if (!(timeSeed > -1000)) {
106 B2WARNING(
"Fixing calculated seed Time " << timeSeed <<
" to zero.");
113 B2DEBUG(100,
"Setting seed to " << timeSeed);
114 recoTrack.setTimeSeed(timeSeed);
124 if (not trackRepresentation or not recoTrack.
wasFitSuccessful(trackRepresentation)) {
125 B2WARNING(
"Could not estimate a correct time, as the last fit failed.");
137 const TVector3& momentum = measuredState.getMom();
138 const double v = calculateVelocity(momentum, particleHypothesis);
140 const double flightTime = flightLength / v;
145 const TVector3& position = measuredState.getPos();
148 const double propagationLength = (position - readoutPositionAsTVector3).Mag();
151 return flightTime - propagationTime;
165 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.
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...
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.
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 TVector3 &positionSeed, const TVector3 &momentumSeed)
Set the position and momentum seed of the reco track. ATTENTION: This is not the fitted position or m...
genfit::AbsTrackRep * getTrackRepresentationForPDG(int pdgCode)
Return an already created track representation of the given reco track for the PDG.
TVector3 getMomentumSeed() const
Return the momentum seed stored in the reco track. ATTENTION: This is not the fitted momentum.
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...
bool isRequired(const std::string &name="")
Ensure this array/object has been registered previously.
Accessor to arrays stored in the data store.
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...
Abstract base class for a track representation.
Exception class for error handling in GENFIT (provides storage for diagnostic information)
#StateOnPlane with additional covariance matrix.
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.