8 #include <tracking/eventTimeExtraction/findlets/DriftLengthBasedEventTimeExtractor.h>
10 #include <tracking/trackFindingCDC/eventdata/utils/DriftTimeUtil.h>
12 #include <genfit/KalmanFitterInfo.h>
13 #include <tracking/trackFitting/fitter/base/TrackFitter.h>
14 #include <tracking/dataobjects/RecoHitInformation.h>
15 #include <tracking/dataobjects/RecoTrack.h>
17 #include <Math/VectorUtil.h>
20 using namespace TrackFindingCDC;
27 std::vector<std::pair<double, double>>& eventT0WithWeights)
30 unsigned short iCLayer = wireID.getICLayer();
31 const ROOT::Math::XYZVector& pos = ROOT::Math::XYZVector(mSoP.getPos());
32 const ROOT::Math::XYZVector& mom = ROOT::Math::XYZVector(mSoP.getMom());
35 const bool smear =
false;
47 double flightTime = mSoP.getTime();
54 const ROOT::Math::XYZVector& wirePositon = ROOT::Math::XYZVector(mSoP.getPlane()->getO());
55 const double alpha = ROOT::Math::VectorUtil::DeltaPhi(wirePositon, mom);
56 const double theta = mom.Theta();
58 const TVectorD& stateOnPlane = mSoP.getState();
59 const double driftLengthEstimate = std::abs(stateOnPlane(3));
60 const bool rl = stateOnPlane(3) > 0;
66 const double dafWeight = kalmanFitterInfo->
getWeights().at(0);
68 const double eventT0 = measuredTime - propTime - flightTime - timeWalk - driftTime;
70 eventT0WithWeights.emplace_back(eventT0, dafWeight);
77 m_wasSuccessful =
false;
82 std::vector<std::pair<double, double>> eventT0WithWeights;
85 if (not trackFitter.
fit(*recoTrack)) {
90 for (
CDCHit* cdcHit : cdcHits) {
94 addEventT0AndWeight(mSoP, *cdcHit, *recoTrack, recoHitInformation, eventT0WithWeights);
102 std::sort(eventT0WithWeights.begin(), eventT0WithWeights.end(), [](
const auto & lhs,
const auto & rhs) {
103 return lhs.first < rhs.first;
106 double extractedEventT0 = NAN;
108 double weightSum = 0;
109 for (
const auto& pair : eventT0WithWeights) {
110 weightSum += pair.second;
114 for (
const auto& pair : eventT0WithWeights) {
115 cumSum += pair.second;
116 if (cumSum > 0.5 * weightSum) {
117 extractedEventT0 = pair.first;
122 if (not std::isnan(extractedEventT0)) {
124 m_eventT0->setEventT0(eventT0Component);
125 m_wasSuccessful =
true;
126 B2DEBUG(25,
"Drift length gave a result of " << extractedEventT0);
128 B2DEBUG(25,
"Extracted event t0 is nan.");
Class containing the result of the unpacker in raw data and the result of the digitizer in simulation...
short getTDCCount() const
Getter for TDC count.
unsigned short getID() const
Getter for encoded wire number.
unsigned short getADCCount() const
Getter for integrated charge.
This is the Reconstruction Event-Data Model Track.
const genfit::TrackPoint * getCreatedTrackPoint(const RecoHitInformation *recoHitInformation) const
Get a pointer to the TrackPoint that was created from this hit.
RecoHitInformation * getRecoHitInformation(HitType *hit) const
Return the reco hit information for a generic hit from the storeArray.
const genfit::MeasuredStateOnPlane & getMeasuredStateOnPlaneFromRecoHit(const RecoHitInformation *recoHitInfo, const genfit::AbsTrackRep *representation=nullptr) const
Return genfit's MeasuredStateOnPlane on plane for associated with one RecoHitInformation.
std::vector< Belle2::RecoTrack::UsedCDCHit * > getSortedCDCHitList() const
Return a sorted list of cdc hits. Sorted by the sortingParameter.
Algorithm class to handle the fitting of RecoTrack objects.
bool fit(RecoTrack &recoTrack, genfit::AbsTrackRep *trackRepresentation) const
Fit a reco track with a given non-default track representation.
Class to identify a wire inside the CDC.
std::vector< double > getWeights() const
Get weights of measurements.
#StateOnPlane with additional covariance matrix.
Object containing AbsMeasurement and AbsFitterInfo objects.
KalmanFitterInfo * getKalmanFitterInfo(const AbsTrackRep *rep=nullptr) const
Helper to avoid casting.
Abstract base class for different kinds of events.
Structure for storing the extracted event t0s together with its detector and its uncertainty.
static double getPropTime(const WireID &wireID, double z)
Getter for the in wire propagation time.
static double getDriftTime(double dist, unsigned short iCLayer, unsigned short lr, double alpha, double theta)
Return the drift time to the sense wire.
static double getMeasuredTime(const WireID &wireID, unsigned short tdcCount, bool smear)
Returns the time measured at the readout board.
static double getTimeWalk(const WireID &wireID, unsigned short adcCount)
Returns time-walk.