Commit ba282946 authored by Simon Spannagel's avatar Simon Spannagel
Browse files

Clean up Detector class a bit: remove superfluous members

parent 30e9798a
......@@ -135,7 +135,7 @@ void Analysis::load_detectors() {
// Finally, sort the list of detectors by z position (from lowest to highest)
std::sort(detectors.begin(), detectors.end(), [](Detector* det1, Detector* det2) {
return det1->displacementZ() < det2->displacementZ();
return det1->displacement().Z() < det2->displacement().Z();
});
}
......
......@@ -56,18 +56,12 @@ namespace corryvreckan {
void displacementY(double y) { m_displacement.SetY(y); }
void displacementZ(double z) { m_displacement.SetZ(z); }
void displacement(ROOT::Math::XYZPoint displacement) { m_displacement = displacement; }
double displacementX() { return m_displacement.X(); }
double displacementY() { return m_displacement.Y(); }
double displacementZ() { return m_displacement.Z(); }
ROOT::Math::XYZPoint displacement() { return m_displacement; }
// Functions to set and retrieve basic rotation parameters
void rotationX(double rx) { m_orientation.SetX(rx); }
void rotationY(double ry) { m_orientation.SetY(ry); }
void rotationZ(double rz) { m_orientation.SetZ(rz); }
double rotationX() { return m_orientation.X(); }
double rotationY() { return m_orientation.Y(); }
double rotationZ() { return m_orientation.Z(); }
ROOT::Math::XYZVector rotation() { return m_orientation; }
void rotation(ROOT::Math::XYZVector rotation) { m_orientation = rotation; }
......@@ -107,9 +101,7 @@ namespace corryvreckan {
double inPixelX(PositionVector3D<Cartesian3D<double>> localPosition);
double inPixelY(PositionVector3D<Cartesian3D<double>> localPosition);
Transform3D* localToGlobal() { return m_localToGlobal; };
ROOT::Math::XYZPoint localToGlobal(ROOT::Math::XYZPoint local) { return (*m_localToGlobal) * local; };
Transform3D* globalToLocal() { return m_globalToLocal; };
ROOT::Math::XYZPoint globalToLocal(ROOT::Math::XYZPoint global) { return (*m_globalToLocal) * global; };
private:
......
......@@ -308,14 +308,17 @@ void Alignment::finalise() {
// Add the parameters to the fitter (z displacement not allowed to move!)
residualFitter->SetParameter(
0, (detectorToAlign + "_displacementX").c_str(), detector->displacementX(), 0.01, -50, 50);
0, (detectorToAlign + "_displacementX").c_str(), detector->displacement().X(), 0.01, -50, 50);
residualFitter->SetParameter(
1, (detectorToAlign + "_displacementY").c_str(), detector->displacementY(), 0.01, -50, 50);
1, (detectorToAlign + "_displacementY").c_str(), detector->displacement().Y(), 0.01, -50, 50);
residualFitter->SetParameter(
2, (detectorToAlign + "_displacementZ").c_str(), detector->displacementZ(), 0, -10, 500);
residualFitter->SetParameter(3, (detectorToAlign + "_rotationX").c_str(), detector->rotationX(), 0.001, -6.30, 6.30);
residualFitter->SetParameter(4, (detectorToAlign + "_rotationY").c_str(), detector->rotationY(), 0.001, -6.30, 6.30);
residualFitter->SetParameter(5, (detectorToAlign + "_rotationZ").c_str(), detector->rotationZ(), 0.001, -6.30, 6.30);
2, (detectorToAlign + "_displacementZ").c_str(), detector->displacement().Z(), 0, -10, 500);
residualFitter->SetParameter(
3, (detectorToAlign + "_rotationX").c_str(), detector->rotation().X(), 0.001, -6.30, 6.30);
residualFitter->SetParameter(
4, (detectorToAlign + "_rotationY").c_str(), detector->rotation().Y(), 0.001, -6.30, 6.30);
residualFitter->SetParameter(
5, (detectorToAlign + "_rotationZ").c_str(), detector->rotation().Z(), 0.001, -6.30, 6.30);
for(int iteration = 0; iteration < nIterations; iteration++) {
......@@ -376,17 +379,17 @@ void Alignment::finalise() {
detNum = det;
// Add the parameters to the fitter (z displacement not allowed to move!)
residualFitter->SetParameter(
det * 6 + 0, (detectorID + "_displacementX").c_str(), detector->displacementX(), 0.01, -50, 50);
det * 6 + 0, (detectorID + "_displacementX").c_str(), detector->displacement().X(), 0.01, -50, 50);
residualFitter->SetParameter(
det * 6 + 1, (detectorID + "_displacementY").c_str(), detector->displacementY(), 0.01, -50, 50);
det * 6 + 1, (detectorID + "_displacementY").c_str(), detector->displacement().Y(), 0.01, -50, 50);
residualFitter->SetParameter(
det * 6 + 2, (detectorID + "_displacementZ").c_str(), detector->displacementZ(), 0, -10, 500);
det * 6 + 2, (detectorID + "_displacementZ").c_str(), detector->displacement().Z(), 0, -10, 500);
residualFitter->SetParameter(
det * 6 + 3, (detectorID + "_rotationX").c_str(), detector->rotationX(), 0.001, -6.30, 6.30);
det * 6 + 3, (detectorID + "_rotationX").c_str(), detector->rotation().X(), 0.001, -6.30, 6.30);
residualFitter->SetParameter(
det * 6 + 4, (detectorID + "_rotationY").c_str(), detector->rotationY(), 0.001, -6.30, 6.30);
det * 6 + 4, (detectorID + "_rotationY").c_str(), detector->rotation().Y(), 0.001, -6.30, 6.30);
residualFitter->SetParameter(
det * 6 + 5, (detectorID + "_rotationZ").c_str(), detector->rotationZ(), 0.001, -6.30, 6.30);
det * 6 + 5, (detectorID + "_rotationZ").c_str(), detector->rotation().Z(), 0.001, -6.30, 6.30);
auto old_position = detector->displacement();
auto old_orientation = detector->rotation();
......@@ -403,12 +406,12 @@ void Alignment::finalise() {
auto rotationZ = residualFitter->GetParameter(det * 6 + 5);
// Store corrections:
shiftsX[detectorID].push_back(Units::convert(detector->displacementX() - old_position.X(), "um"));
shiftsY[detectorID].push_back(Units::convert(detector->displacementY() - old_position.Y(), "um"));
shiftsZ[detectorID].push_back(Units::convert(detector->displacementZ() - old_position.Z(), "um"));
rotX[detectorID].push_back(Units::convert(detector->rotationX() - old_orientation.X(), "deg"));
rotY[detectorID].push_back(Units::convert(detector->rotationY() - old_orientation.Y(), "deg"));
rotZ[detectorID].push_back(Units::convert(detector->rotationZ() - old_orientation.Z(), "deg"));
shiftsX[detectorID].push_back(Units::convert(detector->displacement().X() - old_position.X(), "um"));
shiftsY[detectorID].push_back(Units::convert(detector->displacement().Y() - old_position.Y(), "um"));
shiftsZ[detectorID].push_back(Units::convert(detector->displacement().Z() - old_position.Z(), "um"));
rotX[detectorID].push_back(Units::convert(detector->rotation().X() - old_orientation.X(), "deg"));
rotY[detectorID].push_back(Units::convert(detector->rotation().Y() - old_orientation.Y(), "deg"));
rotZ[detectorID].push_back(Units::convert(detector->rotation().Z() - old_orientation.Z(), "deg"));
LOG(INFO) << detector->name() << "/" << iteration << " dT"
<< display_vector(detector->displacement() - old_position, {"mm", "um"}) << " dR"
......
......@@ -252,7 +252,7 @@ StatusCode ClicpixAnalysis::run(Clipboard* clipboard) {
// Get the track intercept with the clicpix plane (global and local
// co-ordinates)
PositionVector3D<Cartesian3D<double>> trackIntercept = detector->getIntercept(track);
PositionVector3D<Cartesian3D<double>> trackInterceptLocal = *(detector->globalToLocal()) * trackIntercept;
PositionVector3D<Cartesian3D<double>> trackInterceptLocal = detector->globalToLocal(trackIntercept);
// Plot the difference between track intercepts and all clicpix clusters
// Also record which cluster is the closest
......@@ -579,7 +579,7 @@ void ClicpixAnalysis::fillResponseHistos(double trackInterceptX, double trackInt
Pixel* pixel = (*itp);
// Get the pixel local then global position
PositionVector3D<Cartesian3D<double>> pixelPositionLocal = detector->getLocalPosition(pixel->m_row, pixel->m_column);
PositionVector3D<Cartesian3D<double>> pixelPositionGlobal = *(detector->localToGlobal()) * pixelPositionLocal;
PositionVector3D<Cartesian3D<double>> pixelPositionGlobal = detector->localToGlobal(pixelPositionLocal);
// Fill the response histograms
hPixelResponseX->Fill(pixelPositionGlobal.X() - trackInterceptX);
......
......@@ -274,7 +274,7 @@ StatusCode DUTAnalysis::run(Clipboard* clipboard) {
}
auto detector = get_detector(cluster->detectorID());
residualsXMCtruth->Fill(cluster->localX() + detector->size().X() / 2 - particlePosition.X());
auto interceptLocal = *(detector->globalToLocal()) * intercept;
auto interceptLocal = detector->globalToLocal(intercept);
telescopeResolution->Fill(interceptLocal.X() + detector->size().X() / 2 - particlePosition.X());
}
......
......@@ -101,7 +101,7 @@ StatusCode DataOutput::run(Clipboard* clipboard) {
trackIntercept = DUT->getIntercept(track);
// Calculate the intercept in local coordinates
trackInterceptLocal = *(DUT->globalToLocal()) * trackIntercept;
trackInterceptLocal = DUT->globalToLocal(trackIntercept);
v_intercepts.push_back(trackInterceptLocal);
Cluster* cluster = associatedClusters.front();
......
......@@ -171,7 +171,7 @@ void Millepede::setConstraints(const unsigned int nPlanes) {
if(det->name() == m_config.get<std::string>("DUT")) {
continue;
}
avgz += det->displacementZ();
avgz += det->displacement().Z();
}
avgz /= nPlanes;
// Calculate the variance.
......@@ -180,7 +180,7 @@ void Millepede::setConstraints(const unsigned int nPlanes) {
if(det->name() == m_config.get<std::string>("DUT")) {
continue;
}
const double dz = det->displacementZ() - avgz;
const double dz = det->displacement().Z() - avgz;
varz += dz * dz;
}
varz /= nPlanes;
......@@ -203,7 +203,7 @@ void Millepede::setConstraints(const unsigned int nPlanes) {
continue;
}
const unsigned int i = m_millePlanes[det->name()];
const double sz = (det->displacementZ() - avgz) / varz;
const double sz = (det->displacement().Z() - avgz) / varz;
ftx[i] = 1.0;
fty[i + nPlanes] = 1.0;
ftz[i + 2 * nPlanes] = 1.0;
......@@ -287,9 +287,9 @@ bool Millepede::putTrack(Track* track, const unsigned int nPlanes) {
const double yg = cluster->globalY();
const double zg = cluster->globalZ();
// Calculate quasi-local coordinates.
const double zl = zg - detector->displacementZ();
const double xl = xg - detector->displacementX();
const double yl = yg - detector->displacementY();
const double zl = zg - detector->displacement().Z();
const double xl = xg - detector->displacement().X();
const double yl = yg - detector->displacement().Y();
std::vector<double> nonlinear = {nx, ny, 1., -yl + zl * ny, -xl + zl * nx, xl * ny - yl * nx};
const double den = 1. + tx * nx + ty * ny;
......@@ -582,12 +582,12 @@ void Millepede::updateGeometry() {
}
auto plane = m_millePlanes[det->name()];
det->displacementX(det->displacementX() + m_dparm[plane + 0 * nPlanes]);
det->displacementY(det->displacementY() + m_dparm[plane + 1 * nPlanes]);
det->displacementZ(det->displacementZ() + m_dparm[plane + 2 * nPlanes]);
det->rotationX(det->rotationX() + m_dparm[plane + 3 * nPlanes]);
det->rotationY(det->rotationY() + m_dparm[plane + 4 * nPlanes]);
det->rotationZ(det->rotationZ() + m_dparm[plane + 5 * nPlanes]);
det->displacementX(det->displacement().X() + m_dparm[plane + 0 * nPlanes]);
det->displacementY(det->displacement().Y() + m_dparm[plane + 1 * nPlanes]);
det->displacementZ(det->displacement().Z() + m_dparm[plane + 2 * nPlanes]);
det->rotationX(det->rotation().X() + m_dparm[plane + 3 * nPlanes]);
det->rotationY(det->rotation().Y() + m_dparm[plane + 4 * nPlanes]);
det->rotationZ(det->rotation().Z() + m_dparm[plane + 5 * nPlanes]);
det->update();
}
/*
......
......@@ -109,8 +109,8 @@ void Prealignment::finalise() {
<< " , y = " << Units::display(mean_Y, {"mm", "um"});
LOG(INFO) << "Move in x by = " << Units::display(mean_X * damping_factor, {"mm", "um"})
<< " , and in y by = " << Units::display(mean_Y * damping_factor, {"mm", "um"});
double x = detector->displacementX();
double y = detector->displacementY();
double x = detector->displacement().X();
double y = detector->displacement().Y();
detector->displacementX(x + damping_factor * mean_X);
detector->displacementY(y + damping_factor * mean_Y);
}
......
......@@ -194,7 +194,7 @@ void SpatialClustering::calculateClusterCentre(Detector* detector, Cluster* clus
detector->pitchY() * (row - detector->nPixelsY() / 2.),
0);
// Calculate global cluster position
PositionVector3D<Cartesian3D<double>> positionGlobal = *(detector->localToGlobal()) * positionLocal;
PositionVector3D<Cartesian3D<double>> positionGlobal = detector->localToGlobal(positionLocal);
// Set the cluster parameters
cluster->setRow(row);
......
......@@ -73,9 +73,9 @@ StatusCode SpatialTracking::run(Clipboard* clipboard) {
LOG(DEBUG) << "Detector " << detectorID << " does not have any clusters on the clipboard";
} else {
// Store the clusters of the first plane in Z as the reference
if(detector->displacementZ() < minZ) {
if(detector->displacement().Z() < minZ) {
referenceClusters = tempClusters;
minZ = detector->displacementZ();
minZ = detector->displacement().Z();
}
if(tempClusters->size() == 0)
continue;
......
......@@ -207,7 +207,7 @@ void Timepix3Clustering::calculateClusterCentre(Cluster* cluster) {
PositionVector3D<Cartesian3D<double>> positionLocal(
detector->pitchX() * (column - detector->nPixelsX() / 2), detector->pitchY() * (row - detector->nPixelsY() / 2), 0);
// Calculate global cluster position
PositionVector3D<Cartesian3D<double>> positionGlobal = *(detector->localToGlobal()) * positionLocal;
PositionVector3D<Cartesian3D<double>> positionGlobal = detector->localToGlobal(positionLocal);
// Set the cluster parameters
cluster->setRow(row);
......
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