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

Correlations: remove make_correlations parameter

parent 3651ffa9
......@@ -6,7 +6,6 @@ using namespace std;
Correlations::Correlations(Configuration config, std::shared_ptr<Detector> detector)
: Module(std::move(config), detector), m_detector(detector) {
makeCorrelations = m_config.get<bool>("make_correlations", false);
do_time_cut_ = m_config.get<bool>("do_time_cut", false);
if(m_config.count({"time_cut_rel", "time_cut_abs"}) > 1) {
throw InvalidCombinationError(
......@@ -51,109 +50,102 @@ void Correlations::initialise() {
0,
m_detector->nPixels().Y());
if(makeCorrelations) {
// Correlation plots
title = m_detector->name() + ": correlation X;x_{ref}-x [mm];events";
correlationX = new TH1F("correlationX", title.c_str(), 1000, -10., 10.);
title = m_detector->name() + ": correlation Y;y_{ref}-y [mm];events";
correlationY = new TH1F("correlationY", title.c_str(), 1000, -10., 10.);
title = m_detector->name() + ": correlation XY;y_{ref}-x [mm];events";
correlationXY = new TH1F("correlationXY", title.c_str(), 1000, -10., 10.);
title = m_detector->name() + ": correlation YX;x_{ref}-y [mm];events";
correlationYX = new TH1F("correlationYX", title.c_str(), 1000, -10., 10.);
// time correlation plot range should cover length of events. nanosecond binning.
title = m_detector->name() + "Reference cluster time stamp - cluster time stamp;t_{ref}-t [ns];events";
correlationTime = new TH1F("correlationTime", title.c_str(), static_cast<int>(2. * timeCut), -1 * timeCut, timeCut);
if(m_corr_vs_time) {
title = m_detector->name() + " Correlation X versus time;t [s];x_{ref}-x [mm];events";
std::string name = "correlationXVsTime";
correlationXVsTime = new TH2F(name.c_str(), title.c_str(), 600, 0, 3e3, 200, -10., 10.);
title = m_detector->name() + " Correlation Y versus time;t [s];y_{ref}-y [mm];events";
name = "correlationYVsTime";
correlationYVsTime = new TH2F(name.c_str(), title.c_str(), 600, 0, 3e3, 200, -10., 10.);
title = m_detector->name() +
"Reference cluster time stamp - cluster time stamp over time;t [s];t_{ref}-t [ns];events";
correlationTimeOverTime = new TH2F("correlationTimeOverTime",
title.c_str(),
3e3,
0,
3e3,
static_cast<int>(2. * timeCut),
-1 * timeCut,
timeCut);
}
title = m_detector->name() + "Reference pixel time stamp - pixel time stamp;t_{ref}-t [ns];events";
correlationTime_px =
new TH1F("correlationTime_px", title.c_str(), static_cast<int>(2. * timeCut), -1 * timeCut, timeCut);
title = m_detector->name() + "Reference cluster time stamp - cluster time stamp;t_{ref}-t [1/40MHz];events";
correlationTimeInt = new TH1F("correlationTimeInt", title.c_str(), 8000, -40000, 40000);
// 2D correlation plots (pixel-by-pixel, local coordinates):
title = m_detector->name() + ": 2D correlation X (local);x [px];x_{ref} [px];events";
correlationX2Dlocal = new TH2F("correlationX_2Dlocal",
title.c_str(),
m_detector->nPixels().X(),
0,
m_detector->nPixels().X(),
reference->nPixels().X(),
0,
reference->nPixels().X());
title = m_detector->name() + ": 2D correlation Y (local);y [px];y_{ref} [px];events";
correlationY2Dlocal = new TH2F("correlationY_2Dlocal",
title.c_str(),
m_detector->nPixels().Y(),
0,
m_detector->nPixels().Y(),
reference->nPixels().Y(),
0,
reference->nPixels().Y());
title = m_detector->name() + ": correlation col to col;col [px];col_{ref} [px];events";
correlationColCol_px = new TH2F("correlationColCol_px",
title.c_str(),
m_detector->nPixels().X(),
0,
m_detector->nPixels().X(),
reference->nPixels().X(),
0,
reference->nPixels().X());
title = m_detector->name() + ": correlation col to row;col [px];row_{ref} [px];events";
correlationColRow_px = new TH2F("correlationColRow_px",
title.c_str(),
m_detector->nPixels().X(),
0,
m_detector->nPixels().X(),
reference->nPixels().Y(),
0,
reference->nPixels().Y());
title = m_detector->name() + ": correlation row to col;row [px];col_{ref} [px];events";
correlationRowCol_px = new TH2F("correlationRowCol_px",
title.c_str(),
m_detector->nPixels().Y(),
0,
m_detector->nPixels().Y(),
reference->nPixels().X(),
0,
reference->nPixels().X());
title = m_detector->name() + ": correlation row to row;row [px];row_{ref} [px];events";
correlationRowRow_px = new TH2F("correlationRowRow_px",
title.c_str(),
m_detector->nPixels().Y(),
0,
m_detector->nPixels().Y(),
reference->nPixels().Y(),
0,
reference->nPixels().Y());
title = m_detector->name() + ": 2D correlation X (global);x [mm];x_{ref} [mm];events";
correlationX2D = new TH2F("correlationX_2D", title.c_str(), 100, -10., 10., 100, -10., 10.);
title = m_detector->name() + ": 2D correlation Y (global);y [mm];y_{ref} [mm];events";
correlationY2D = new TH2F("correlationY_2D", title.c_str(), 100, -10., 10., 100, -10., 10.);
// Correlation plots
title = m_detector->name() + ": correlation X;x_{ref}-x [mm];events";
correlationX = new TH1F("correlationX", title.c_str(), 1000, -10., 10.);
title = m_detector->name() + ": correlation Y;y_{ref}-y [mm];events";
correlationY = new TH1F("correlationY", title.c_str(), 1000, -10., 10.);
title = m_detector->name() + ": correlation XY;y_{ref}-x [mm];events";
correlationXY = new TH1F("correlationXY", title.c_str(), 1000, -10., 10.);
title = m_detector->name() + ": correlation YX;x_{ref}-y [mm];events";
correlationYX = new TH1F("correlationYX", title.c_str(), 1000, -10., 10.);
// time correlation plot range should cover length of events. nanosecond binning.
title = m_detector->name() + "Reference cluster time stamp - cluster time stamp;t_{ref}-t [ns];events";
correlationTime = new TH1F("correlationTime", title.c_str(), static_cast<int>(2. * timeCut), -1 * timeCut, timeCut);
if(m_corr_vs_time) {
title = m_detector->name() + " Correlation X versus time;t [s];x_{ref}-x [mm];events";
std::string name = "correlationXVsTime";
correlationXVsTime = new TH2F(name.c_str(), title.c_str(), 600, 0, 3e3, 200, -10., 10.);
title = m_detector->name() + " Correlation Y versus time;t [s];y_{ref}-y [mm];events";
name = "correlationYVsTime";
correlationYVsTime = new TH2F(name.c_str(), title.c_str(), 600, 0, 3e3, 200, -10., 10.);
title =
m_detector->name() + "Reference cluster time stamp - cluster time stamp over time;t [s];t_{ref}-t [ns];events";
correlationTimeOverTime = new TH2F(
"correlationTimeOverTime", title.c_str(), 3e3, 0, 3e3, static_cast<int>(2. * timeCut), -1 * timeCut, timeCut);
}
title = m_detector->name() + "Reference pixel time stamp - pixel time stamp;t_{ref}-t [ns];events";
correlationTime_px =
new TH1F("correlationTime_px", title.c_str(), static_cast<int>(2. * timeCut), -1 * timeCut, timeCut);
title = m_detector->name() + "Reference cluster time stamp - cluster time stamp;t_{ref}-t [1/40MHz];events";
correlationTimeInt = new TH1F("correlationTimeInt", title.c_str(), 8000, -40000, 40000);
// 2D correlation plots (pixel-by-pixel, local coordinates):
title = m_detector->name() + ": 2D correlation X (local);x [px];x_{ref} [px];events";
correlationX2Dlocal = new TH2F("correlationX_2Dlocal",
title.c_str(),
m_detector->nPixels().X(),
0,
m_detector->nPixels().X(),
reference->nPixels().X(),
0,
reference->nPixels().X());
title = m_detector->name() + ": 2D correlation Y (local);y [px];y_{ref} [px];events";
correlationY2Dlocal = new TH2F("correlationY_2Dlocal",
title.c_str(),
m_detector->nPixels().Y(),
0,
m_detector->nPixels().Y(),
reference->nPixels().Y(),
0,
reference->nPixels().Y());
title = m_detector->name() + ": correlation col to col;col [px];col_{ref} [px];events";
correlationColCol_px = new TH2F("correlationColCol_px",
title.c_str(),
m_detector->nPixels().X(),
0,
m_detector->nPixels().X(),
reference->nPixels().X(),
0,
reference->nPixels().X());
title = m_detector->name() + ": correlation col to row;col [px];row_{ref} [px];events";
correlationColRow_px = new TH2F("correlationColRow_px",
title.c_str(),
m_detector->nPixels().X(),
0,
m_detector->nPixels().X(),
reference->nPixels().Y(),
0,
reference->nPixels().Y());
title = m_detector->name() + ": correlation row to col;row [px];col_{ref} [px];events";
correlationRowCol_px = new TH2F("correlationRowCol_px",
title.c_str(),
m_detector->nPixels().Y(),
0,
m_detector->nPixels().Y(),
reference->nPixels().X(),
0,
reference->nPixels().X());
title = m_detector->name() + ": correlation row to row;row [px];row_{ref} [px];events";
correlationRowRow_px = new TH2F("correlationRowRow_px",
title.c_str(),
m_detector->nPixels().Y(),
0,
m_detector->nPixels().Y(),
reference->nPixels().Y(),
0,
reference->nPixels().Y());
title = m_detector->name() + ": 2D correlation X (global);x [mm];x_{ref} [mm];events";
correlationX2D = new TH2F("correlationX_2D", title.c_str(), 100, -10., 10., 100, -10., 10.);
title = m_detector->name() + ": 2D correlation Y (global);y [mm];y_{ref} [mm];events";
correlationY2D = new TH2F("correlationY_2D", title.c_str(), 100, -10., 10., 100, -10., 10.);
// Timing plots
title = m_detector->name() + ": event time;t [s];events";
eventTimes = new TH1F("eventTimes", title.c_str(), 3000000, 0, 300);
......@@ -196,66 +188,62 @@ StatusCode Correlations::run(std::shared_ptr<Clipboard> clipboard) {
}
// Loop over all clusters and fill histograms
if(makeCorrelations) {
for(auto& pixel : (*pixels)) {
// Loop over reference plane pixels:
for(auto& refPixel : (*referencePixels)) {
correlationColCol_px->Fill(pixel->column(), refPixel->column());
correlationColRow_px->Fill(pixel->column(), refPixel->row());
correlationRowCol_px->Fill(pixel->row(), refPixel->column());
correlationRowRow_px->Fill(pixel->row(), refPixel->row());
correlationTime_px->Fill(
static_cast<double>(Units::convert(refPixel->timestamp() - pixel->timestamp(), "ns")));
}
for(auto& pixel : (*pixels)) {
// Loop over reference plane pixels:
for(auto& refPixel : (*referencePixels)) {
correlationColCol_px->Fill(pixel->column(), refPixel->column());
correlationColRow_px->Fill(pixel->column(), refPixel->row());
correlationRowCol_px->Fill(pixel->row(), refPixel->column());
correlationRowRow_px->Fill(pixel->row(), refPixel->row());
correlationTime_px->Fill(static_cast<double>(Units::convert(refPixel->timestamp() - pixel->timestamp(), "ns")));
}
}
for(auto& cluster : (*clusters)) {
for(auto& cluster : (*clusters)) {
// Check that track is within region of interest using winding number algorithm
if(!m_detector->isWithinROI(cluster)) {
LOG(DEBUG) << " - cluster outside ROI";
} else {
// Loop over reference plane clusters to make correlation plots
for(auto& refCluster : (*referenceClusters)) {
// Check that track is within region of interest using winding number algorithm
if(!m_detector->isWithinROI(cluster)) {
LOG(DEBUG) << " - cluster outside ROI";
} else {
// Loop over reference plane clusters to make correlation plots
for(auto& refCluster : (*referenceClusters)) {
double timeDifference = refCluster->timestamp() - cluster->timestamp();
// in 40 MHz:
long long int timeDifferenceInt = static_cast<long long int>(timeDifference / 25);
// Correlation plots
if(abs(timeDifference) < timeCut || !do_time_cut_) {
correlationX->Fill(refCluster->global().x() - cluster->global().x());
correlationX2D->Fill(cluster->global().x(), refCluster->global().x());
correlationX2Dlocal->Fill(cluster->column(), refCluster->column());
correlationY->Fill(refCluster->global().y() - cluster->global().y());
correlationY2D->Fill(cluster->global().y(), refCluster->global().y());
correlationY2Dlocal->Fill(cluster->row(), refCluster->row());
correlationXY->Fill(refCluster->global().y() - cluster->global().x());
correlationYX->Fill(refCluster->global().x() - cluster->global().y());
}
double timeDifference = refCluster->timestamp() - cluster->timestamp();
// in 40 MHz:
long long int timeDifferenceInt = static_cast<long long int>(timeDifference / 25);
correlationTime->Fill(timeDifference); // time difference in ns
LOG(DEBUG) << "Time difference: " << Units::display(timeDifference, {"ns", "us"})
<< ", Time ref. cluster: " << Units::display(refCluster->timestamp(), {"ns", "us"})
<< ", Time cluster: " << Units::display(cluster->timestamp(), {"ns", "us"});
// Correlation plots
if(m_corr_vs_time) {
if(abs(timeDifference) < timeCut || !do_time_cut_) {
correlationX->Fill(refCluster->global().x() - cluster->global().x());
correlationX2D->Fill(cluster->global().x(), refCluster->global().x());
correlationX2Dlocal->Fill(cluster->column(), refCluster->column());
correlationY->Fill(refCluster->global().y() - cluster->global().y());
correlationY2D->Fill(cluster->global().y(), refCluster->global().y());
correlationY2Dlocal->Fill(cluster->row(), refCluster->row());
correlationXY->Fill(refCluster->global().y() - cluster->global().x());
correlationYX->Fill(refCluster->global().x() - cluster->global().y());
}
correlationTime->Fill(timeDifference); // time difference in ns
LOG(DEBUG) << "Time difference: " << Units::display(timeDifference, {"ns", "us"})
<< ", Time ref. cluster: " << Units::display(refCluster->timestamp(), {"ns", "us"})
<< ", Time cluster: " << Units::display(cluster->timestamp(), {"ns", "us"});
if(m_corr_vs_time) {
if(abs(timeDifference) < timeCut || !do_time_cut_) {
correlationXVsTime->Fill(static_cast<double>(Units::convert(cluster->timestamp(), "s")),
refCluster->global().x() - cluster->global().x());
correlationYVsTime->Fill(static_cast<double>(Units::convert(cluster->timestamp(), "s")),
refCluster->global().y() - cluster->global().y());
}
// Time difference in ns
correlationTimeOverTime->Fill(static_cast<double>(Units::convert(cluster->timestamp(), "s")),
timeDifference);
correlationXVsTime->Fill(static_cast<double>(Units::convert(cluster->timestamp(), "s")),
refCluster->global().x() - cluster->global().x());
correlationYVsTime->Fill(static_cast<double>(Units::convert(cluster->timestamp(), "s")),
refCluster->global().y() - cluster->global().y());
}
correlationTimeInt->Fill(static_cast<double>(timeDifferenceInt));
// Time difference in ns
correlationTimeOverTime->Fill(static_cast<double>(Units::convert(cluster->timestamp(), "s")),
timeDifference);
}
correlationTimeInt->Fill(static_cast<double>(timeDifferenceInt));
}
}
}
......
......@@ -52,7 +52,6 @@ namespace corryvreckan {
TH2F* correlationYVsTime;
// Parameters which can be set by user
bool makeCorrelations;
double timeCut;
bool do_time_cut_;
bool m_corr_vs_time;
......
......@@ -2,14 +2,13 @@
**Maintainer**: Simon Spannagel (<simon.spannagel@cern.ch>), Daniel Hynds (<daniel.hynds@cern.ch>)
**Module Type**: *DETECTOR*
**Detector Type**: *all*
**Status**: Functional
**Status**: Functional
### Description
This module collects `pixel` and `cluster` objects from the clipboard and creates correlation and timing plots with respect to the reference detector.
### Parameters
* `make_correlations`: Boolean to change if correlation plots should be outputted. Default value is `false`.
* `do_time_cut`: Boolean to switch on/off the cut on cluster times for correlations. Defaults to `false`.
* `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 for cluster correlation if `do_time_cut = true`. A relative time cut is applied by default when `do_time_cut = true`. Absolute and relative time cuts are mutually exclusive. Defaults to `3.0`.
* `time_cut_abs`: Specifies an absolute value for the maximum time difference allowed for cluster correlation if `do_time_cut = true`. Absolute and relative time cuts are mutually exclusive. No default value.
......
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