Commit de08030d authored by Lennart Huth's avatar Lennart Huth
Browse files

const string&

parent acf9c004
......@@ -20,7 +20,7 @@ using namespace corryvreckan;
using namespace gbl;
using namespace Eigen;
ROOT::Math::XYPoint GblTrack::getKinkAt(std::string detectorID) const {
ROOT::Math::XYPoint GblTrack::getKinkAt(const std::string& detectorID) const {
if(kink_.count(detectorID) == 1) {
return kink_.at(detectorID);
} else {
......@@ -97,6 +97,8 @@ void GblTrack::fit() {
// lambda to add a scatterer to a GBLPoint
auto addScattertoGblPoint = [&total_material, &scatteringTheta, &localTangent](GblPoint& point, double material) {
Matrix<double, 2, 2> scatter;
// This can only happen if someone messes up the tracking code. Simply renormalizing would shadow the mistake made at
// a different position and therefore the used plane distances would be wrong.
if(localTangent(2) != 1)
throw TrackError(typeid(GblTrack),
"wrong normalization of local slope, should be 1 but is " + std::to_string(localTangent(2)));
......@@ -143,7 +145,7 @@ void GblTrack::fit() {
point.addMeasurement(initialResidual, covv);
initital_residual_[p->getName()] = ROOT::Math::XYPoint(initialResidual(0), initialResidual(1));
if(logging_) {
std::cout << "*********** Plane: " << p->getName() << " \n Global Res to fit: \t("
std::cout << "Plane: " << p->getName() << " \n Global Res to fit: \t("
<< (cluster->global().x() - planes_.begin()->getCluster()->global().x()) << ", "
<< (cluster->global().y() - planes_.begin()->getCluster()->global().y()) << ")\n Local Res to fit: \t("
<< (cluster->local().x() - localPosTrack[0]) << ", " << (cluster->local().y() - localPosTrack[1])
......@@ -271,10 +273,10 @@ void GblTrack::fit() {
unsigned int numData = 2;
for(auto plane : planes_) {
auto name = plane.getName();
traj.getScatResults(
plane.getGblPointPosition(), numData, gblResiduals, gblErrorsMeasurements, gblErrorsResiduals, gblDownWeights);
// this is of course the kink in local coordinates and not to meaningful for further usage if rotations are large
auto name = plane.getName();
// fixme: Kinks are in local coordinates and would be more reasonably in global
kink_[name] = ROOT::Math::XYPoint(gblResiduals(0), gblResiduals(1));
traj.getResults(int(plane.getGblPointPosition()), localPar, localCov);
corrections_[name] = ROOT::Math::XYZPoint(localPar(3), localPar(4), 0);
......@@ -334,7 +336,7 @@ ROOT::Math::XYZPoint GblTrack::getIntercept(double z) const {
return (getState(layer) + getDirection(layer) * (z - getState(layer).z()));
}
ROOT::Math::XYZPoint GblTrack::getState(std::string detectorID) const {
ROOT::Math::XYZPoint GblTrack::getState(const std::string& detectorID) const {
// The track state is given in global coordinates and represents intersect of track and detetcor plane.
// Let's check first if the data is fitted and all components are there
if(logging_)
......@@ -364,7 +366,7 @@ Cluster* GblTrack::get_seed_cluster() const {
return dynamic_cast<Cluster*>(seed_cluster_.GetObject());
}
ROOT::Math::XYZVector GblTrack::getDirection(std::string detectorID) const {
ROOT::Math::XYZVector GblTrack::getDirection(const std::string& detectorID) const {
// Defining the direction following the particle results in the direction
// beeing definded from the requested plane onwards to the next one
......
......@@ -12,6 +12,7 @@
#define CORRYVRECKAN_GBLTRACK_H 1
#include "Track.hpp"
namespace corryvreckan {
/**
* @ingroup Objects
......@@ -42,21 +43,21 @@ namespace corryvreckan {
* @param name of detector
* @return ROOT::Math::XYZPoint state at detetcor layer
*/
ROOT::Math::XYZPoint getState(std::string detectorID) const override;
ROOT::Math::XYZPoint getState(const std::string& detectorID) const override;
/**
* @brief Get the track direction at a detector
* @param name of detector
* @return ROOT::Math::XYZPoint direction at detetcor layer
*/
ROOT::Math::XYZVector getDirection(std::string detectorID) const override;
ROOT::Math::XYZVector getDirection(const std::string& detectorID) const override;
/**
* @brief Return kink of track at given detector
* @param detectorID Detector ID at which the kink should be evaluated
* @return Kink at given detector
*/
ROOT::Math::XYPoint getKinkAt(std::string detectorID) const override;
ROOT::Math::XYPoint getKinkAt(const std::string& detectorID) const override;
void setVolumeScatter(double length) override;
......
......@@ -27,7 +27,7 @@ Multiplet::Multiplet(std::shared_ptr<Track> upstream, std::shared_ptr<Track> dow
}
}
ROOT::Math::XYPoint Multiplet::getKinkAt(std::string) const {
ROOT::Math::XYPoint Multiplet::getKinkAt(const std::string&) const {
return ROOT::Math::XYPoint(0, 0);
}
......@@ -72,12 +72,12 @@ ROOT::Math::XYZPoint Multiplet::getIntercept(double z) const {
: (z < m_scattererPosition ? m_upstream->getIntercept(z) : m_downstream->getIntercept(z));
}
ROOT::Math::XYZPoint Multiplet::getState(std::string detectorID) const {
ROOT::Math::XYZPoint Multiplet::getState(const std::string& detectorID) const {
return getClusterFromDetector(detectorID)->global().z() <= m_scattererPosition ? m_upstream->getState(detectorID)
: m_downstream->getState(detectorID);
}
ROOT::Math::XYZVector Multiplet::getDirection(std::string detectorID) const {
ROOT::Math::XYZVector Multiplet::getDirection(const std::string& detectorID) const {
return getClusterFromDetector(detectorID)->global().z() <= m_scattererPosition ? m_upstream->getDirection(detectorID)
: m_downstream->getDirection(detectorID);
}
......
......@@ -48,14 +48,14 @@ namespace corryvreckan {
* @param name of detector
* @return ROOT::Math::XYZPoint state at detetcor layer
*/
ROOT::Math::XYZPoint getState(std::string detectorID) const override;
ROOT::Math::XYZPoint getState(const std::string& detectorID) const override;
/**
* @brief Get the track direction at a detector
* @param name of detector
* @return ROOT::Math::XYZPoint direction at detetcor layer
*/
ROOT::Math::XYZVector getDirection(std::string detectorID) const override;
ROOT::Math::XYZVector getDirection(const std::string& detectorID) const override;
/**
* @brief Get the track intercept at the position of the scatterer
......@@ -84,7 +84,7 @@ namespace corryvreckan {
std::shared_ptr<Track> getUpstreamTracklet() { return m_upstream; };
std::shared_ptr<Track> getDownstreamTracklet() { return m_downstream; };
ROOT::Math::XYPoint getKinkAt(std::string) const override;
ROOT::Math::XYPoint getKinkAt(const std::string&) const override;
void setVolumeScatter(double) override{};
private:
......
......@@ -29,7 +29,7 @@ ROOT::Math::XYPoint StraightLineTrack::distance(const Cluster* cluster) const {
return ROOT::Math::XYPoint(dx, dy);
}
ROOT::Math::XYPoint StraightLineTrack::getKinkAt(std::string) const {
ROOT::Math::XYPoint StraightLineTrack::getKinkAt(const std::string&) const {
return ROOT::Math::XYPoint(0, 0);
}
......
......@@ -47,14 +47,14 @@ namespace corryvreckan {
* @param name of detector
* @return ROOT::Math::XYZPoint state at detetcor layer
*/
ROOT::Math::XYZPoint getState(std::string) const override { return m_state; }
ROOT::Math::XYZPoint getState(const std::string&) const override { return m_state; }
/**
* @brief Get the track direction at a detector
* @param name of detector
* @return ROOT::Math::XYZPoint direction at detetcor layer
*/
ROOT::Math::XYZVector getDirection(std::string) const override { return m_direction; }
ROOT::Math::XYZVector getDirection(const std::string&) const override { return m_direction; }
ROOT::Math::XYPoint distance(const Cluster* cluster) const;
......@@ -63,7 +63,7 @@ namespace corryvreckan {
* @param detectorID Detector ID at which the kink should be evaluated
* @return Kink at given detector
*/
ROOT::Math::XYPoint getKinkAt(std::string detectorID) const override;
ROOT::Math::XYPoint getKinkAt(const std::string& detectorID) const override;
void setVolumeScatter(double) override{};
......
......@@ -20,6 +20,15 @@ Cluster* Plane::getCluster() const {
return dynamic_cast<Cluster*>(cluster_.GetObject());
}
void Plane::print(std::ostream& os) const {
os << "Plane at " << z_ << " with rad. length " << x_x0_ << ", name " << name_ << " and";
if(hasCluster()) {
os << "cluster with global pos: " << getCluster()->global();
} else {
os << "no clsuter";
}
}
void Track::addCluster(const Cluster* cluster) {
track_clusters_.push_back(const_cast<Cluster*>(cluster));
}
......@@ -116,7 +125,7 @@ bool Track::isAssociated(Cluster* cluster) const {
return true;
}
bool Track::hasDetector(std::string detectorID) const {
bool Track::hasDetector(const std::string& detectorID) const {
auto it = find_if(track_clusters_.begin(), track_clusters_.end(), [&detectorID](TRef cl) {
auto cluster = dynamic_cast<Cluster*>(cl.GetObject());
return cluster->getDetectorID() == detectorID;
......@@ -138,7 +147,12 @@ Cluster* Track::getClusterFromDetector(std::string detectorID) const {
return dynamic_cast<Cluster*>(it->GetObject());
}
ROOT::Math::XYZPoint Track::getCorrection(std::string detectorID) const {
double Track::getMaterialBudget(const std::string& detectorID) const {
return std::find_if(planes_.begin(), planes_.end(), [&detectorID](Plane plane) { return plane.getName() == detectorID; })
->getMaterialBudget();
}
ROOT::Math::XYZPoint Track::getCorrection(const std::string& detectorID) const {
if(corrections_.count(detectorID) == 1)
return corrections_.at(detectorID);
else
......
......@@ -50,14 +50,7 @@ namespace corryvreckan {
void setToLocal(Transform3D toLocal) { to_local_ = toLocal; }
void setToGlobal(Transform3D toGlobal) { to_global_ = toGlobal; }
void print(std::ostream& os) const override {
os << "Plane at " << z_ << " with rad. length " << x_x0_ << ", name " << name_ << " and";
if(hasCluster()) {
os << "cluster with global pos: " << getCluster()->global();
} else {
os << "no clsuter";
}
}
void print(std::ostream& os) const override;
private:
double z_, x_x0_;
......@@ -192,7 +185,7 @@ namespace corryvreckan {
* @param detectorID DetectorID of the detector to check
* @return True if detector has a cluster on this Track, false if not.
*/
bool hasDetector(std::string detectorID) const;
bool hasDetector(const std::string& detectorID) const;
/**
* @brief Get a Track cluster from a given detector
......@@ -226,14 +219,14 @@ namespace corryvreckan {
* @param name of detector
* @return ROOT::Math::XYZPoint state at detetcor layer
*/
virtual ROOT::Math::XYZPoint getState(std::string) const { return ROOT::Math::XYZPoint(0.0, 0.0, 0.0); }
virtual ROOT::Math::XYZPoint getState(const std::string&) const { return ROOT::Math::XYZPoint(0.0, 0.0, 0.0); }
/**
* @brief Get the track direction at a detector
* @param name of detector
* @return ROOT::Math::XYZPoint direction at detetcor layer
*/
virtual ROOT::Math::XYZVector getDirection(std::string) const { return ROOT::Math::XYZVector(0.0, 0.0, 0.0); }
virtual ROOT::Math::XYZVector getDirection(const std::string&) const { return ROOT::Math::XYZVector(0.0, 0.0, 0.0); }
/**
* @brief check if the fitting routine already has been called. Chi2 etc are not set before
......@@ -246,27 +239,23 @@ namespace corryvreckan {
* @param detectorID
* @return 2D residual as ROOT::Math::XYPoint
*/
ROOT::Math::XYPoint getResidual(std::string detectorID) const { return residual_.at(detectorID); }
ROOT::Math::XYPoint getResidual(const std::string& detectorID) const { return residual_.at(detectorID); }
/**
* @brief Get the kink at a given detector layer. This is ill defined for last and first layer
* @param detectorID Detector ID at which the kink should be evaluated
* @return 2D kink at given detector
*/
virtual ROOT::Math::XYPoint getKinkAt(std::string detectorID) const = 0;
virtual ROOT::Math::XYPoint getKinkAt(const std::string& detectorID) const = 0;
/**
* @brief Get the materialBudget of a detector layer
* @param detectorID
* @return Material Budget for given layer
*/
double getMaterialBudget(std::string detectorID) const {
return std::find_if(
planes_.begin(), planes_.end(), [&detectorID](Plane plane) { return plane.getName() == detectorID; })
->getMaterialBudget();
}
double getMaterialBudget(const std::string& detectorID) const;
ROOT::Math::XYZPoint getCorrection(std::string detectorID) const;
ROOT::Math::XYZPoint getCorrection(const std::string& detectorID) const;
virtual void setVolumeScatter(double length) = 0;
void setLogging(bool on = false) { logging_ = on; }
......
Supports Markdown
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