Commit 43ab95d6 authored by Simon Spannagel's avatar Simon Spannagel
Browse files

Merge branch 'alignment' into 'master'

Updates to Alignment

See merge request simonspa/corryvreckan!18
parents 3ee8264c 6cc81b0c
Pipeline #284380 passed with stages
in 10 minutes and 58 seconds
This diff is collapsed.
......@@ -32,9 +32,14 @@ namespace corryvreckan {
// Member variables
Tracks m_alignmenttracks;
int m_discardedtracks{};
int nIterations;
int m_numberOfTracksForAlignment;
int alignmentMethod;
bool m_pruneTracks;
int m_maxAssocClusters;
double m_maxTrackChi2;
TH1F* residualsXPlot;
TH1F* residualsYPlot;
......
## Alignment
**Maintainer**: Daniel Hynds (<daniel.hynds@cern.ch>)
**Maintainer**: Daniel Hynds (<daniel.hynds@cern.ch>), Simon Spannagel (<simon.spannagel@cern.ch>)
**Status**: Functional
#### Description
This algorithm performs translational and rotational telescope plane alignment.
This algorithm performs translational and rotational telescope plane alignment. The alignment is performed with respect to the reference plane set in the configuration file.
The alignment is performed with respect to the reference plane set in the configuration file.
This algorithm uses the tracks produced by the `BasicTracking` algorithm to align the telescope planes. If fewer than half of the tracks have associated clusters, a warning is produced on terminal.
This algorithm uses the tracks produced by the `BasicTracking` algorithm to align the telescope planes. There are two methods available for alignment:
There are two methods available for alignment:
##### 1) Minimising the track chi^2
For each telescope detector except the reference plane, this method moves the detector, refits all of the tracks, and minimises the chi^2 of these new tracks. The parameters `detectorToAlign` and `DUT` are not used in this method as it automatically iterates through all telescope planes except the DUT.
......@@ -22,6 +23,9 @@ For the detector specified by the `detectorToAlign` parameter, this method moves
* `detectorToAlign`: Parameter to set a particular plane to align. This parameter is only used in the residuals method (`alignmentMethod = 1`). The default is the `DUT` plane.
* `DUT`: Name of the DUT plane.
* `reference`: Name of the detector used as the alignment reference plane. All other telescope planes are aligned with respect to the reference plane.
* `prune_tracks`: Boolean to set if tracks with a number of associated clusters > `max_associated_clusters` or with a track chi^2 > `max_track_chi2ndof` should be excluded from use in the alignment. This parameter was designed for `alignmentMethod=1`. The number of discarded tracks is outputted on terminal. Default is `False`.
* `max_associated_clusters`: Maximum number of associated clusters per track allowed when `prune_tracks=True` for the track to be used in the alignment. Default value is `1`.
* `max_track_chi2ndof`: Maximum track chi^2 value allowed when `prune_tracks=True` for the track to be used in the alignment. Default value is `10.0`.
#### Plots produced
For each detector the following plots are produced when using `alignmentMethod = 0`:
......@@ -33,7 +37,7 @@ For each detector the following plots are produced when using `alignmentMethod =
* Rotational shift around Z-axis vs. iteration number
For the `detectorToAlign` the following plots are produced when using `alignmentMethod = 1`:
* Residual in X
* Residual in X (calculated in local coordinates)
* Residual in Y
* Profile plot of residual in X vs. X position
* Profile plot of residual in X vs. Y position
......
......@@ -17,20 +17,18 @@ Detector::Detector(const Configuration& config) {
// Number of pixels
auto npixels = config.get<ROOT::Math::DisplacementVector2D<Cartesian2D<int>>>("number_of_pixels");
// Size of the pixels
auto pitch = config.get<ROOT::Math::XYVector>("pixel_pitch");
m_pitch = config.get<ROOT::Math::XYVector>("pixel_pitch");
m_detectorName = config.getName();
m_detectorType = config.get<std::string>("type");
m_nPixelsX = npixels.x();
m_nPixelsY = npixels.y();
m_pitchX = pitch.x() / 1000.;
m_pitchY = pitch.y() / 1000.;
m_timingOffset = config.get<double>("time_offset", 0.0);
this->initialise();
LOG(TRACE) << "Initialized \"" << m_detectorType << "\": " << m_nPixelsX << "x" << m_nPixelsY << " px, pitch of "
<< m_pitchX << "/" << m_pitchY << "mm";
<< display_vector(m_pitch, {"mm", "um"});
LOG(TRACE) << " Position: " << display_vector(m_displacement, {"mm", "um"});
LOG(TRACE) << " Orientation: " << display_vector(m_orientation, {"deg"}) << " (" << m_orientation_mode << ")";
if(m_timingOffset > 0.) {
......@@ -147,8 +145,7 @@ Configuration Detector::getConfiguration() {
config.set("number_of_pixels", npixels);
// Size of the pixels
auto pitch = ROOT::Math::XYVector(m_pitchX * 1000., m_pitchY * 1000.);
config.set("pixel_pitch", pitch);
config.set("pixel_pitch", m_pitch);
if(m_timingOffset != 0.) {
config.set("time_offset", m_timingOffset);
......@@ -227,11 +224,11 @@ bool Detector::hitMasked(Track* track, int tolerance) {
// Functions to get row and column from local position
double Detector::getRow(PositionVector3D<Cartesian3D<double>> localPosition) {
double row = ((localPosition.Y() + m_pitchY / 2.) / m_pitchY) + m_nPixelsY / 2.;
double row = ((localPosition.Y() + m_pitch.Y() / 2.) / m_pitch.Y()) + m_nPixelsY / 2.;
return row;
}
double Detector::getColumn(PositionVector3D<Cartesian3D<double>> localPosition) {
double column = ((localPosition.X() + m_pitchY / 2.) / m_pitchX) + m_nPixelsX / 2.;
double column = ((localPosition.X() + m_pitch.X() / 2.) / m_pitch.X()) + m_nPixelsX / 2.;
return column;
}
......@@ -239,17 +236,17 @@ double Detector::getColumn(PositionVector3D<Cartesian3D<double>> localPosition)
PositionVector3D<Cartesian3D<double>> Detector::getLocalPosition(double row, double column) {
return PositionVector3D<Cartesian3D<double>>(
m_pitchX * (column - m_nPixelsX / 2.), m_pitchY * (row - m_nPixelsY / 2.), 0.);
m_pitch.X() * (column - m_nPixelsX / 2.), m_pitch.Y() * (row - m_nPixelsY / 2.), 0.);
}
// Function to get in-pixel position (value returned in microns)
double Detector::inPixelX(PositionVector3D<Cartesian3D<double>> localPosition) {
double column = getColumn(localPosition);
double inPixelX = m_pitchX * (column - floor(column));
double inPixelX = m_pitch.X() * (column - floor(column));
return 1000. * inPixelX;
}
double Detector::inPixelY(PositionVector3D<Cartesian3D<double>> localPosition) {
double row = getRow(localPosition);
double inPixelY = m_pitchY * (row - floor(row));
double inPixelY = m_pitch.Y() * (row - floor(row));
return 1000. * inPixelY;
}
......@@ -46,8 +46,8 @@ namespace corryvreckan {
Configuration getConfiguration();
double pitchX() { return m_pitchX; }
double pitchY() { return m_pitchY; }
double pitchX() { return m_pitch.X(); }
double pitchY() { return m_pitch.Y(); }
int nPixelsX() { return m_nPixelsX; }
int nPixelsY() { return m_nPixelsY; }
double timingOffset() { return m_timingOffset; }
......@@ -107,15 +107,16 @@ namespace corryvreckan {
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:
// Member variables
// Detector information
std::string m_detectorType;
std::string m_detectorName;
double m_pitchX;
double m_pitchY;
ROOT::Math::XYVector m_pitch;
int m_nPixelsX;
int m_nPixelsY;
double m_timingOffset;
......
......@@ -2,6 +2,7 @@
#define CLUSTER_H 1
#include <iostream>
#include "Math/Point3D.h"
#include "Pixel.h"
/*
......@@ -25,12 +26,8 @@ public:
virtual ~Cluster() {}
// Copy constructor
Cluster(Cluster* cluster) {
m_globalX = cluster->globalX();
m_globalY = cluster->globalY();
m_globalZ = cluster->globalZ();
m_localX = cluster->localX();
m_localY = cluster->localY();
m_localZ = cluster->localZ();
m_global = cluster->global();
m_local = cluster->local();
m_error = cluster->error();
m_detectorID = cluster->detectorID();
m_timestamp = cluster->timestamp();
......@@ -56,12 +53,17 @@ public:
double column() { return m_column; }
double tot() { return m_tot; }
double error() { return m_error; }
double globalX() { return m_globalX; }
double globalY() { return m_globalY; }
double globalZ() { return m_globalZ; }
double localX() { return m_localX; }
double localY() { return m_localY; }
double localZ() { return m_localZ; }
double globalX() { return m_global.X(); }
double globalY() { return m_global.Y(); }
double globalZ() { return m_global.Z(); }
ROOT::Math::XYZPoint global() { return m_global; }
double localX() { return m_local.X(); }
double localY() { return m_local.Y(); }
double localZ() { return m_local.Z(); }
ROOT::Math::XYZPoint local() { return m_local; }
size_t size() { return m_pixels.size(); }
double columnWidth() { return m_columnWidth; }
double rowWidth() { return m_rowWidth; }
......@@ -71,15 +73,16 @@ public:
void setRow(double row) { m_row = row; }
void setColumn(double col) { m_column = col; }
void setTot(double tot) { m_tot = tot; }
void setClusterCentre(ROOT::Math::XYZPoint global) { m_global = global; }
void setClusterCentre(double x, double y, double z) {
m_globalX = x;
m_globalY = y;
m_globalZ = z;
m_global.SetX(x);
m_global.SetY(y);
m_global.SetZ(z);
}
void setClusterCentreLocal(double x, double y, double z) {
m_localX = x;
m_localY = y;
m_localZ = z;
m_local.SetX(x);
m_local.SetY(y);
m_local.SetZ(z);
}
void setError(double error) { m_error = error; }
......@@ -92,18 +95,15 @@ private:
double m_error;
double m_columnWidth;
double m_rowWidth;
double m_globalX;
double m_globalY;
double m_globalZ;
double m_localX;
double m_localY;
double m_localZ;
ROOT::Math::XYZPoint m_local;
ROOT::Math::XYZPoint m_global;
std::map<int, bool> m_rowHits;
std::map<int, bool> m_columnHits;
// ROOT I/O class definition - update version number when you change this
// class!
ClassDef(Cluster, 3)
// ROOT I/O class definition - update version number when you change this class!
ClassDef(Cluster, 4)
};
// 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