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

Changed absolute fit limits to relative one which takes spatial resolution of detector into account

(cherry picked from commit 984d0a60)
parent 8e9b7a8e
......@@ -20,8 +20,7 @@ Prealignment::Prealignment(Configuration config, std::shared_ptr<Detector> detec
damping_factor = m_config.get<double>("damping_factor", 1.0);
method = m_config.get<std::string>("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"));
fit_range_rel = m_config.get<int>("fit_range_rel", 500);
// Backwards compatibilty: also allow timing_cut to be used for time_cut_abs
m_config.setAlias("time_cut_abs", "timing_cut", true);
......@@ -127,10 +126,27 @@ void Prealignment::finalise() {
double shift_X = 0.;
double shift_Y = 0.;
LOG(INFO) << "Using prealignment method: " << prealign_method;
LOG(INFO) << "Using prealignment method: " << method;
if(method == "gauss_fit") {
correlationX->Fit("gaus", "Q", "", fit_low, fit_high);
correlationY->Fit("gaus", "Q", "", fit_low, fit_high);
int binMaxX = correlationX->GetMaximumBin();
double fit_low_x =
correlationX->GetXaxis()->GetBinCenter(binMaxX) - m_detector->getSpatialResolution().x() * fit_range_rel;
double fit_high_x =
correlationX->GetXaxis()->GetBinCenter(binMaxX) + m_detector->getSpatialResolution().x() * fit_range_rel;
int binMaxY = correlationY->GetMaximumBin();
double fit_low_y =
correlationY->GetXaxis()->GetBinCenter(binMaxY) - m_detector->getSpatialResolution().y() * fit_range_rel;
double fit_high_y =
correlationY->GetXaxis()->GetBinCenter(binMaxY) + m_detector->getSpatialResolution().y() * fit_range_rel;
LOG(DEBUG) << "Fit range in x direction from: " << Units::display(fit_low_x, {"mm", "um"}) << " to "
<< Units::display(fit_high_x, {"mm", "um"});
LOG(DEBUG) << "Fit range in y direction from: " << Units::display(fit_low_y, {"mm", "um"}) << " to "
<< Units::display(fit_high_y, {"mm", "um"});
correlationX->Fit("gaus", "Q", "", fit_low_x, fit_high_x);
correlationY->Fit("gaus", "Q", "", fit_low_y, fit_high_y);
shift_X = correlationX->GetFunction("gaus")->GetParameter(1);
shift_Y = correlationY->GetFunction("gaus")->GetParameter(1);
} else if(method == "mean") {
......@@ -141,6 +157,8 @@ void Prealignment::finalise() {
shift_X = correlationX->GetXaxis()->GetBinCenter(binMaxX);
int binMaxY = correlationY->GetMaximumBin();
shift_Y = correlationY->GetXaxis()->GetBinCenter(binMaxY);
} else {
throw InvalidValueError(m_config, "method", "Invalid prealignment method");
}
LOG(INFO) << "Detector " << m_detector->name() << ": x = " << Units::display(shift_X, {"mm", "um"})
......
......@@ -50,9 +50,8 @@ namespace corryvreckan {
double max_correlation_rms;
double damping_factor;
double timeCut;
std::string prealign_method;
double fit_high;
double fit_low;
std::string method;
int fit_range_rel;
};
} // namespace corryvreckan
#endif // PREALIGNMENT_H
......@@ -19,7 +19,7 @@ However, for the prealignment this is a an acceptable estimation which works wit
* `max_correlation_rms`: The maximum RMS of the 1D correlation histograms allowed for the shifts to be applied. This factor should be tuned for each run, and is combat the effect of flat distributions. Default value is `6mm`.
* `time_cut_rel`: Number of standard deviations the `time_resolution` of the detector plane will be multiplied by. This value is then used as the maximum time difference between a cluster on the current detector and a cluster on the reference plane to be considered in the prealignment. Absolute and relative time cuts are mutually exclusive. Defaults to `3.0`.
* `time_cut_abs`: Specifies an absolute value for the maximum time difference between a cluster on the current detector and a cluster on the reference plane to be considered in the prealignment. Absolute and relative time cuts are mutually exclusive. No default value.
* `method`: Specifies which method should be used to compute the translational shifts. With the option `mean` the mean of the 1D correlation histogram is used. The option `maximum` uses the maximum value of the histogram and with `gauss_fit` a Gaussian is fitted in the range `fit_low` to `fit_high` and its mean is used for the translational shift. Default is to `mean`. The default of the fitting range is `fit_low` = -2mm and `fit_high` = 2mm.
* `method`: Specifies which method should be used to compute the translational shifts. With the option `mean` the mean of the 1D correlation histogram is used. The option `maximum` uses the maximum value of the histogram and with `gauss_fit` a Gaussian is fitted. The fit range is given by `fit_range_rel` times the spatial resolution of the corresponding detector around the maximum of the histogram. The mean of the fitted Gaussian is used for the translational shift. Default is to `mean`. The default of the relative fit range is `fit_range_rel` = 500.
### Plots Created
......
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