Commit 07d3cceb authored by Alexander Ferk's avatar Alexander Ferk
Browse files

fixed corrections calculation bug in GblTrack introduced by 95ff71c8

parent 565d30d0
......@@ -57,9 +57,8 @@ void GblTrack::fit() {
}
std::vector<GblPoint> points;
// get the seedcluster for the fit - simply the first one in the list
auto seedcluster =
std::find_if(m_planes.begin(), m_planes.end(), [](auto plane) { return plane.hasCluster(); })->cluster();
// get the seedcluster for the fit - find the first plane with a cluster to use
setSeedCluster(std::find_if(m_planes.begin(), m_planes.end(), [](auto plane) { return plane.hasCluster(); })->cluster());
double prevPos = m_planes.front().position();
// lambda to calculate the scattering theta
......@@ -80,11 +79,11 @@ void GblTrack::fit() {
Jac(4, 2) = Jac(3, 1);
return Jac;
};
auto addMeasurementtoGblPoint = [&seedcluster](GblPoint& point, std::vector<Plane>::iterator& p) {
auto addMeasurementtoGblPoint = [this](GblPoint& point, std::vector<Plane>::iterator& p) {
auto cluster = p->cluster();
Eigen::Vector2d initialResidual;
initialResidual(0) = cluster->global().x() - seedcluster->global().x();
initialResidual(1) = cluster->global().y() - seedcluster->global().y();
initialResidual(0) = cluster->global().x() - getSeedCluster()->global().x();
initialResidual(1) = cluster->global().y() - getSeedCluster()->global().y();
// FIXME uncertainty of single hit - rotations ignored
Eigen::Matrix2d covv = Eigen::Matrix2d::Identity();
covv(0, 0) = 1. / cluster->errorX() / cluster->errorX();
......@@ -227,11 +226,22 @@ ROOT::Math::XYZPoint GblTrack::state(std::string detectorID) const {
// Using the global detector position here is of course not correct, it works for small/no rotations
// For larger rotations it is an issue
return ROOT::Math::XYZPoint(clusters().at(0)->global().x() + correction(detectorID).x(),
clusters().at(0)->global().y() + correction(detectorID).y(),
return ROOT::Math::XYZPoint(getSeedCluster()->global().x() + correction(detectorID).x(),
getSeedCluster()->global().y() + correction(detectorID).y(),
m_materialBudget.at(detectorID).second);
}
void GblTrack::setSeedCluster(const Cluster* cluster) {
m_seedCluster = const_cast<Cluster*>(cluster);
}
Cluster* GblTrack::getSeedCluster() const {
if(!m_seedCluster.IsValid() || m_seedCluster.GetObject() == nullptr) {
throw MissingReferenceException(typeid(*this), typeid(Cluster));
}
return dynamic_cast<Cluster*>(m_seedCluster.GetObject());
}
ROOT::Math::XYZVector GblTrack::direction(std::string detectorID) const {
// Defining the direction following the particle results in the direction
......
......@@ -38,6 +38,18 @@ namespace corryvreckan {
*/
void fit() override;
/**
* @brief Set seedcluster used for track fitting
* @param Pointer to seedcluster of the GblTrack
*/
void setSeedCluster(const Cluster* cluster);
/**
* @brief Get seedcluster used for track fitting
* @return Pointer to seedcluster of the GblTrack if set, nullptr otherwise
*/
Cluster* getSeedCluster() const;
/**
* @brief Get the track position for a certain z position
* @param z positon
......@@ -60,8 +72,10 @@ namespace corryvreckan {
ROOT::Math::XYZVector direction(std::string detectorID) const override;
private:
// Member variables
TRef m_seedCluster{nullptr};
// ROOT I/O class definition - update version number when you change this class!
ClassDefOverride(GblTrack, 0)
ClassDefOverride(GblTrack, 2)
};
// Vector type declaration
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment