21 std::vector<SamplePoint> points{};
22 const double stepWidth = rtRel.
tBinWidth();
23 double time = rtRel.
tLower();
24 while (time <= rtRel.
tUpper()){
25 const double r = rtRel.
radius(time);
26 points.emplace_back(time,
r, relUnc);
32 std::vector<SamplePoint> points{};
33 const double stepWidth = rtRel.
tBinWidth();
34 double time = rtRel.
tLower();
35 while (time <= rtRel.
tUpper()){
41 std::vector<SamplePoint>
resoFromRadius(
const std::vector<SamplePoint>& points,
42 const double uncert) {
43 std::vector<SamplePoint> outPoints{};
44 outPoints.reserve(points.size());
46 outPoints.emplace_back(point.x2(),point.error(), uncert);
51 const double uncert) {
52 std::vector<SamplePoint> outPoints{};
53 outPoints.reserve(points.size());
55 outPoints.emplace_back(point.x1(),point.error(), uncert);
61 std::vector<SamplePoint>
swapCoordinates(
const std::vector<SamplePoint>& inPoints,
64 std::vector<SamplePoint> outPoints{};
65 outPoints.reserve(inPoints.size());
71 outPoints.emplace_back(in.x2(), in.x1(), in.error() / (fPrime > 0 ? fPrime : 1.));
74 return a.x1() < b.x1();
78 std::vector<SamplePoint>
normalizeDomain(
const std::vector<SamplePoint>& dataPoints) {
79 const auto [minX, maxX] =
interval(dataPoints);
80 std::vector<SamplePoint> normedPoints{dataPoints};
81 for (
unsigned k = 0; k < dataPoints.size(); ++k) {
86 std::pair<double, double>
minMax(
const std::vector<SamplePoint>& points) {
87 double min{std::numeric_limits<double>::max()},
max{-std::numeric_limits<double>::max()};
89 min = std::min(
min, point.x2());
90 max = std::max(
max, point.x2());
92 return std::make_pair(
min,
max);
94 std::pair<double, double>
interval(
const std::vector<SamplePoint>& points) {
95 double min{std::numeric_limits<double>::max()},
max{-std::numeric_limits<double>::max()};
97 min = std::min(
min, point.x1());
98 max = std::max(
max, point.x1());
100 return std::make_pair(
min,
max);
106 chi2+=std::pow((point.x2() - rtRel.
radius(point.x1())) / point.error(), 2);
114 chi2+=std::pow((point.x2() - trRel.
driftTime(point.x1()).value_or(2.*trRel.
maxRadius()) ) / point.error(), 2);
122 chi2+=std::pow((point.x2() - rtReso.
resolution(point.x1())) / point.error(), 2);
generic interface for a rt-relation
virtual double tLower() const =0
Returns the lower time covered by the r-t.
virtual double tBinWidth() const =0
Returns the step-size for the sampling.
virtual double radius(double t) const =0
returns drift radius for a given time
virtual double tUpper() const =0
Returns the upper time covered by the r-t.
virtual double driftVelocity(double t) const =0
Returns the drift velocity for a given time.
Generic interface to retrieve the resolution on the drift radius as a function of the drift time.
virtual double resolution(double t, double bgRate=0.0) const =0
returns resolution for a give time and background rate
virtual double maxRadius() const =0
Returns the maximum drift-radius.
virtual std::optional< double > driftTime(const double r) const =0
Interface method for fetching the drift-time from the radius Returns a nullopt if the time is out of ...
This class provides a sample point for the BaseFunctionFitter.
double chi2(TH1 *h0, TH1 *h1)
CscCalcPed - algorithm that finds the Cathode Strip Chamber pedestals from an RDO.
std::pair< double, double > interval(const std::vector< SamplePoint > &points)
Returns the interval covered by the sample points.
std::pair< double, double > minMax(const std::vector< SamplePoint > &points)
Returns the minimum & maximum values covered by the sample points.
double mapToUnitInterval(const double x, const double lowerEdge, const double upperEdge)
Maps the number x which is in [lowEdge;upperEdge] to the interval [-1;1].
std::vector< SamplePoint > resoFromRadius(const std::vector< SamplePoint > &points, const double uncert)
Creates a new vector of sample points where the x2 coordinate becomes the x1 coordinate and the resol...
std::vector< SamplePoint > normalizeDomain(const std::vector< SamplePoint > &dataPoints)
Normalizes the domain of the samples points to the interval -1 to 1.
std::vector< SamplePoint > swapCoordinates(const std::vector< SamplePoint > &points, const IRtRelation &rtRel)
Creates a new vector of samples points with x1 exchanged by x2 and vice-versa.
double calculateChi2(const std::vector< SamplePoint > &dataPoints, const IRtRelation &rtRel)
Returns the chi2 of the rt-relation w.r.t.
std::vector< SamplePoint > fetchResolution(const std::vector< SamplePoint > &points, const double uncert)
Creates a new vector of sample points where the x2 is assigned to the uncertainty and the uncertainty...
std::vector< SamplePoint > fetchDataPoints(const IRtRelation &rtRel, const double relUnc)
Constructs a list of sample points from the rt-relation.