Commit 70b77809 authored by Katharina Dort's avatar Katharina Dort Committed by Jens Kroeger
Browse files

Added option to use gaussian fit or maximum of histogram for Prealignment

(cherry picked from commit f347c8ac)
parent be0410c4
......@@ -19,6 +19,10 @@ Prealignment::Prealignment(Configuration config, std::shared_ptr<Detector> detec
max_correlation_rms = m_config.get<double>("max_correlation_rms", Units::get<double>(6, "mm"));
damping_factor = m_config.get<double>("damping_factor", 1.0);
prealign_method = m_config.get<std::string>("prealign_method", "mean");
fit_high = m_config.get<double>("fit_high", Units::get<double>(2, "mm"));
fit_low = m_config.get<double>("fit_low", Units::get<double>(-2, "mm"));
// Backwards compatibilty: also allow timing_cut to be used for time_cut_abs
m_config.setAlias("time_cut_abs", "timing_cut", true);
......@@ -119,14 +123,34 @@ void Prealignment::finalise() {
// Move all but the reference:
if(!m_detector->isReference()) {
double mean_X = correlationX->GetMean();
double mean_Y = correlationY->GetMean();
LOG(INFO) << "Detector " << m_detector->name() << ": x = " << Units::display(mean_X, {"mm", "um"})
<< " , 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"});
m_detector->displacement(XYZPoint(m_detector->displacement().X() + damping_factor * mean_X,
m_detector->displacement().Y() + damping_factor * mean_Y,
double shift_X = 0.;
double shift_Y = 0.;
LOG(INFO) << "Using prealignment method: " << prealign_method;
if(prealign_method == "gauss_fit"){
correlationX->Fit("gaus", "Q","", fit_low, fit_high);
correlationY->Fit("gaus", "Q","", fit_low, fit_high);
shift_X = correlationX->GetFunction("gaus")->GetParameter(1);
shift_Y = correlationY->GetFunction("gaus")->GetParameter(1);
}
else if(prealign_method == "mean"){
shift_X = correlationX->GetMean();
shift_Y = correlationY->GetMean();
}
else if(prealign_method == "maximum"){
int binMaxX = correlationX->GetMaximumBin();
shift_X = correlationX->GetXaxis()->GetBinCenter(binMaxX);
int binMaxY = correlationY->GetMaximumBin();
shift_Y = correlationY->GetXaxis()->GetBinCenter(binMaxY);
}
LOG(INFO) << "Detector " << m_detector->name() << ": x = " << Units::display(shift_X, {"mm", "um"})
<< " , y = " << Units::display(shift_Y, {"mm", "um"});
LOG(INFO) << "Move in x by = " << Units::display(shift_X * damping_factor, {"mm", "um"})
<< " , and in y by = " << Units::display(shift_Y * damping_factor, {"mm", "um"});
m_detector->displacement(XYZPoint(m_detector->displacement().X() + damping_factor * shift_X,
m_detector->displacement().Y() + damping_factor * shift_Y,
m_detector->displacement().Z()));
}
}
......@@ -14,6 +14,7 @@
#include <TCanvas.h>
#include <TH1F.h>
#include <TH2F.h>
#include <TF1.h>
#include <iostream>
#include "core/module/Module.hpp"
#include "objects/Cluster.hpp"
......@@ -49,6 +50,9 @@ namespace corryvreckan {
double max_correlation_rms;
double damping_factor;
double timeCut;
std::string prealign_method;
double fit_high;
double fit_low;
};
} // namespace corryvreckan
#endif // PREALIGNMENT_H
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