Commit 7e8a7ba2 authored by Simon Spannagel's avatar Simon Spannagel
Browse files
parents 7fa5997c 427758eb
Pipeline #259197 passed with stages
in 5 minutes and 45 seconds
......@@ -28,11 +28,28 @@ Alignment::Alignment(Configuration config, std::vector<Detector*> detectors)
LOG(INFO) << "Aligning detector \"" << detectorToAlign << "\"";
}
void Alignment::initialise() {}
void Alignment::initialise() {
if(alignmentMethod == 1) {
auto detector = get_detector(detectorToAlign);
auto detname = detector->name();
std::string title = detname + "_residualsX";
residualsXPlot = new TH1F(title.c_str(), title.c_str(), 400, -0.2, 0.2);
title = detname + "_residualsY";
residualsYPlot = new TH1F(title.c_str(), title.c_str(), 400, -0.2, 0.2);
title = detname + "_profile_dY_X";
profile_dY_X = new TProfile(title.c_str(), title.c_str(), 400, -0.2, 0.2);
title = detname + "_profile_dY_Y";
profile_dY_Y = new TProfile(title.c_str(), title.c_str(), 400, -0.2, 0.2);
title = detname + "_profile_dX_X";
profile_dX_X = new TProfile(title.c_str(), title.c_str(), 400, -0.2, 0.2);
title = detname + "_profile_dX_Y";
profile_dX_Y = new TProfile(title.c_str(), title.c_str(), 400, -0.2, 0.2);
}
}
// During run, just pick up tracks and save them till the end
StatusCode Alignment::run(Clipboard* clipboard) {
auto detector = get_detector(detectorToAlign);
// Get the tracks
Tracks* tracks = (Tracks*)clipboard->get("tracks");
if(tracks == NULL) {
......@@ -44,8 +61,30 @@ StatusCode Alignment::run(Clipboard* clipboard) {
Track* track = (*tracks)[iTrack];
Track* alignmentTrack = new Track(track);
m_alignmenttracks.push_back(alignmentTrack);
}
Clusters associatedClusters = track->associatedClusters();
if(alignmentMethod == 0)
continue;
// Find the cluster that needs to have its position recalculated
for(auto& associatedCluster : associatedClusters) {
// Recalculate the global position from the local
PositionVector3D<Cartesian3D<double>> positionLocal(
associatedCluster->localX(), associatedCluster->localY(), associatedCluster->localZ());
PositionVector3D<Cartesian3D<double>> positionGlobal = *(detector->localToGlobal()) * positionLocal;
// Get the track intercept with the detector
ROOT::Math::XYZPoint intercept = track->intercept(positionGlobal.Z());
// Calculate the residuals
double residualX = intercept.X() - positionGlobal.X();
double residualY = intercept.Y() - positionGlobal.Y();
// Fill the alignment residual profile plots
residualsXPlot->Fill(residualX);
residualsYPlot->Fill(residualY);
profile_dY_X->Fill(residualY, positionLocal.X(), 1);
profile_dY_Y->Fill(residualY, positionLocal.Y(), 1);
profile_dX_X->Fill(residualX, positionLocal.X(), 1);
profile_dX_Y->Fill(residualX, positionLocal.Y(), 1);
}
}
// If we have enough tracks for the alignment, tell the event loop to finish
if(m_alignmenttracks.size() >= m_numberOfTracksForAlignment) {
LOG(STATUS) << "Accumulated " << m_alignmenttracks.size() << " tracks, interrupting processing.";
......@@ -241,7 +280,6 @@ void Alignment::finalise() {
detector->rotationY(rotationY);
detector->rotationZ(rotationZ);
}
LOG(INFO) << detectorToAlign << " new alignment: T(" << detector->displacementX() << "," << detector->displacementY()
<< "," << detector->displacementZ() << ") R(" << detector->rotationX() << "," << detector->rotationY()
<< "," << detector->rotationZ() << ")";
......
......@@ -6,6 +6,8 @@
#include "Minuit2/Minuit2Minimizer.h"
#include "TError.h"
#include "TGraph.h"
#include "TH1F.h"
#include "TProfile.h"
// Local includes
#include "core/algorithm/Algorithm.h"
#include "objects/Cluster.h"
......@@ -34,6 +36,14 @@ namespace corryvreckan {
int m_numberOfTracksForAlignment;
int alignmentMethod;
TH1F* residualsXPlot;
TH1F* residualsYPlot;
TProfile* profile_dY_X;
TProfile* profile_dY_Y;
TProfile* profile_dX_X;
TProfile* profile_dX_Y;
std::map<std::string, TGraph*> align_correction_shiftX;
std::map<std::string, TGraph*> align_correction_shiftY;
std::map<std::string, TGraph*> align_correction_shiftZ;
......
......@@ -24,7 +24,7 @@ For the detector specified by the `detectorToAlign` parameter, this method moves
* `reference`: Name of the detector used as the alignment reference plane. All other telescope planes are aligned with respect to the reference plane.
#### Plots produced
For each detector the following plots are produced:
For each detector the following plots are produced when using `alignmentMethod = 0`:
* Translational shift along X-axis vs. iteration number
* Translational shift along Y-axis vs. iteration number
* Translational shift along Z-axis vs. iteration number
......@@ -32,6 +32,14 @@ For each detector the following plots are produced:
* Rotational shift around Y-axis vs. iteration number
* 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 Y
* Profile plot of residual in X vs. X position
* Profile plot of residual in X vs. Y position
* Profile plot of residual in Y vs. X position
* Profile plot of residual in Y vs. Y position
#### Usage
```toml
......
......@@ -10,6 +10,7 @@ BasicTracking::BasicTracking(Configuration config, std::vector<Detector*> detect
// Default values for cuts
timingCut = m_config.get<double>("timingCut", 200. / 1000000000.); // 200 ns
spatialCut = m_config.get<double>("spatialCut", 0.2); // 200 um
spatialCut_DUT = m_config.get<double>("spatialCutDUT", Units::convert(0.2, "mm"));
minHitsOnTrack = m_config.get<int>("minHitsOnTrack", 6);
excludeDUT = m_config.get<bool>("excludeDUT", true);
}
......@@ -222,9 +223,9 @@ StatusCode BasicTracking::run(Clipboard* clipboard) {
ROOT::Math::XYZPoint intercept = track->intercept(dutcluster->globalZ());
double xdistance = intercept.X() - dutcluster->globalX();
double ydistance = intercept.Y() - dutcluster->globalY();
if(abs(xdistance) > spatialCut)
if(abs(xdistance) > spatialCut_DUT)
continue;
if(abs(ydistance) > spatialCut)
if(abs(ydistance) > spatialCut_DUT)
continue;
LOG(DEBUG) << "Found associated cluster";
......@@ -263,33 +264,4 @@ Cluster* BasicTracking::getNearestCluster(long long int timestamp, Clusters clus
return bestCluster;
}
// Timepix3Cluster* BasicTracking::getNearestCluster(Timepix3Cluster* cluster,
// map<Timepix3Cluster*, bool> used, Timepix3Clusters* clusters){
//
// // Loop over all clusters and return the closest in space with an acceptable
// time cut
// Timepix3Cluster* bestCluster = NULL;
// double closestApproach = 1000000.;
//
// // Loop over all clusters
// for(int iCluster=0;iCluster<clusters->size();iCluster++){
// Timepix3Cluster* candidate = (*clusters)[iCluster];
// // Check if within time window
// if( abs((double)((candidate->timestamp() - cluster->timestamp()) /
// (4096.*40000000.))) > timinigCut ) continue;
// // Check how close it is (2D - assumes z-axis parallel to beam)
// if(bestCluster == NULL){ bestCluster = candidate; continue; }
// double distanceX = candidate->globalX() - cluster->globalX();
// double distanceY = candidate->globalY() - cluster->globalY();
// double approach = sqrt(distanceX*distanceX + distanceY*distanceY);
// // Check if it is closer than previous clusters, and apply spatial cut
// if( approach < closestApproach && approach < spatialCut){
// bestCluster = candidate;
// closestApproach = approach;
// }
// }
//
// return bestCluster;
//}
void BasicTracking::finalise() {}
......@@ -47,6 +47,7 @@ namespace corryvreckan {
// Cuts for tracking
double timingCut;
double spatialCut;
double spatialCut_DUT;
int minHitsOnTrack;
bool excludeDUT;
};
......
......@@ -8,8 +8,9 @@ This algorithm performs a basic tracking method.
Clusters from the first plane in Z (named the seed plane) are related to clusters close in time on the other detector planes using straight line tracks. The DUT plane can be excluded from the track finding and DUT clusters potentially associated with the track stored.
#### Parameters
* `timingCut`: Maximum time difference allowed between clusters for association. In units of seconds. Default value is `0.0000002` (200ns).
* `spatialCut`: Maximum spatial distance in the XY plane allowed between clusters for association. In units of millimetres. Default value is `0.2` (200um).
* `timingCut`: Maximum time difference allowed between clusters for association. Default value is `200ns`.
* `spatialCut`: Maximum spatial distance in the XY plane allowed between clusters for association for the telescope planes. Default value is `0.2mm`.
* `spatialCut_DUT`: Maximum spatial distance in the XY plane allowed between clusters for association for the DUT. Default value is `0.2mm`.
* `minHitsOnTrack`: Minium number of associated clusters needed to create a track, equivalent to the minimum number of planes required for each track. Default value is `6`.
* `excludeDUT`: Boolean to chose if the DUT plane is included in the track finding. In either case, the DUT clusters possibly associated with the track are saved. Default value is `true`.
* `DUT`: Name of the DUT plane.
......
......@@ -119,11 +119,6 @@ void ClicpixAnalysis::initialise() {
hPixelTOTRow2pix = new TH1F("hPixelTOTRow2pix", "hPixelTOTRow2pix", 50, 0, 50);
hPixelTOTCol2pix = new TH1F("hPixelTOTCol2pix", "hPixelTOTCol2pix", 50, 0, 50);
hResidualsLocalRow2pixClusterTOT =
new TH2F("hResidualsLocalRow2pixClusterTOT", "hResidualsLocalRow2pixClusterTOT", 50, 0, 50, 600, -0.3, 0.3);
hResidualsLocalRow2pixPixelIntercept =
new TH2F("hResidualsLocalRow2pixPixelIntercept", "hResidualsLocalRow2pixPixelIntercept", 50, 0, 25, 600, -0.3, 0.3);
// Maps
hTrackIntercepts = new TH2F("hTrackIntercepts", "hTrackIntercepts", 200, -2.0, 2.0, 300, -1., 2);
hTrackInterceptsAssociated =
......
......@@ -89,8 +89,6 @@ namespace corryvreckan {
TH1F* hPixelTOTCol2pix;
TH1F* hClusterTOTRatioRow2pix;
TH1F* hClusterTOTRatioCol2pix;
TH2F* hResidualsLocalRow2pixClusterTOT;
TH2F* hResidualsLocalRow2pixPixelIntercept;
// Maps
TH2F* hTrackIntercepts;
......
......@@ -167,6 +167,7 @@ void DataOutput::finalise() {
auto DUT = get_detector(m_config.get<std::string>("DUT"));
auto directory = m_outputFile->mkdir("Directory");
directory->cd();
LOG(STATUS) << filledEvents << " events written to file " << m_fileName;
auto orientation = DUT->rotation();
directory->WriteObject(&orientation, "DUTorientation");
......
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