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

Merge branch 'AnalysisEfficiency' into 'master'

Merge AnalysisEfficiency

See merge request !106
parents de56d943 6a0df09b
Pipeline #860572 passed with stages
in 17 minutes and 15 seconds
......@@ -27,6 +27,9 @@ AnalysisEfficiency::AnalysisEfficiency(Configuration config, std::shared_ptr<Det
void AnalysisEfficiency::initialise() {
hPixelEfficiency = new TH1D(
"hPixelEfficiency", "hPixelEfficiency; single pixel efficiency; # entries", 201, 0, 1.005); // get 0.5%-wide bins
auto pitch_x = static_cast<double>(Units::convert(m_detector->pitch().X(), "um"));
auto pitch_y = static_cast<double>(Units::convert(m_detector->pitch().Y(), "um"));
......@@ -83,6 +86,80 @@ void AnalysisEfficiency::initialise() {
1.5 * m_detector->size().Y(),
0,
1);
eTotalEfficiency =
new TEfficiency("eTotalEfficiency", "totalEfficiency; axis has no meaning; total chip efficiency", 1, 0, 1);
totalEfficiency = new TNamed("totalEffiency", "totalEffiency");
hTrackTimeToPrevHit_matched =
new TH1D("trackTimeToPrevHit_matched", "trackTimeToPrevHit_matched;time to prev hit [us];# events", 1e6, 0, 1e6);
hTrackTimeToPrevHit_notmatched = new TH1D(
"trackTimeToPrevHit_notmatched", "trackTimeToPrevHit_notmatched;time to prev hit [us];# events", 1e6, 0, 1e6);
title = m_detector->name() + "time difference to previous track (if this has assoc cluster)";
hTimeDiffPrevTrack_assocCluster = new TH1D("timeDiffPrevTrack_assocCluster", title.c_str(), 11000, -1000, 10000);
hTimeDiffPrevTrack_assocCluster->GetXaxis()->SetTitle("time diff [#mus]");
hTimeDiffPrevTrack_assocCluster->GetYaxis()->SetTitle("events");
title = m_detector->name() + "time difference to previous track (if this has no assoc cluster)";
hTimeDiffPrevTrack_noAssocCluster = new TH1D("timeDiffPrevTrack_noAssocCluster", title.c_str(), 11000, -1000, 10000);
hTimeDiffPrevTrack_noAssocCluster->GetXaxis()->SetTitle("time diff [#mus]");
hTimeDiffPrevTrack_noAssocCluster->GetYaxis()->SetTitle("events");
hRowDiffPrevTrack_assocCluster = new TH1D("rowDiffPrevTrack_assocCluster",
"rowDiffPrevTrack_assocCluster",
2 * m_detector->nPixels().Y(),
-m_detector->nPixels().Y(),
m_detector->nPixels().Y());
hRowDiffPrevTrack_assocCluster->GetXaxis()->SetTitle("row difference (matched track to prev track) [px]");
hRowDiffPrevTrack_assocCluster->GetYaxis()->SetTitle("# events");
hColDiffPrevTrack_assocCluster = new TH1D("colDiffPrevTrack_assocCluster",
"colDiffPrevTrack_assocCluster",
2 * m_detector->nPixels().X(),
-m_detector->nPixels().X(),
m_detector->nPixels().X());
hColDiffPrevTrack_assocCluster->GetXaxis()->SetTitle("column difference (matched track to prev track) [px]");
hColDiffPrevTrack_assocCluster->GetYaxis()->SetTitle("# events");
hRowDiffPrevTrack_noAssocCluster = new TH1D("rowDiffPrevTrack_noAssocCluster",
"rowDiffPrevTrack_noAssocCluster",
2 * m_detector->nPixels().Y(),
-m_detector->nPixels().Y(),
m_detector->nPixels().Y());
hRowDiffPrevTrack_noAssocCluster->GetXaxis()->SetTitle("row difference (non-matched track - prev track) [px]");
hRowDiffPrevTrack_noAssocCluster->GetYaxis()->SetTitle("events");
hColDiffPrevTrack_noAssocCluster = new TH1D("colDiffPrevTrack_noAassocCluster",
"colDiffPrevTrack_noAssocCluster",
2 * m_detector->nPixels().X(),
-m_detector->nPixels().X(),
m_detector->nPixels().X());
hColDiffPrevTrack_noAssocCluster->GetXaxis()->SetTitle("column difference (non-matched track - prev track) [px]");
hColDiffPrevTrack_noAssocCluster->GetYaxis()->SetTitle("events");
hPosDiffPrevTrack_assocCluster = new TH2D("posDiffPrevTrack_assocCluster",
"posDiffPrevTrack_assocCluster",
2 * m_detector->nPixels().X(),
-m_detector->nPixels().X(),
m_detector->nPixels().X(),
2 * m_detector->nPixels().Y(),
-m_detector->nPixels().Y(),
m_detector->nPixels().Y());
hPosDiffPrevTrack_assocCluster->GetXaxis()->SetTitle("column difference (matched track - prev track) [px]");
hPosDiffPrevTrack_assocCluster->GetYaxis()->SetTitle("row difference (matched track - prev track) [px]");
hPosDiffPrevTrack_noAssocCluster = new TH2D("posDiffPrevTrack_noAssocCluster",
"posDiffPrevTrack_noAssocCluster",
2 * m_detector->nPixels().X(),
-m_detector->nPixels().X(),
m_detector->nPixels().X(),
2 * m_detector->nPixels().Y(),
-m_detector->nPixels().Y(),
m_detector->nPixels().Y());
hPosDiffPrevTrack_noAssocCluster->GetXaxis()->SetTitle("column difference (non-matched track - prev track) [px]");
hPosDiffPrevTrack_noAssocCluster->GetYaxis()->SetTitle("row difference (non-matched track - prev track) [px]");
// initialize matrix with hit timestamps to all 0:
auto nRows = static_cast<size_t>(m_detector->nPixels().Y());
auto nCols = static_cast<size_t>(m_detector->nPixels().X());
std::vector<double> v_row(nRows, 0.); // create vector will zeros of length <nRows>
prev_hit_ts.assign(nCols, v_row); // use vector v_row to construct matrix
}
StatusCode AnalysisEfficiency::run(std::shared_ptr<Clipboard> clipboard) {
......@@ -119,6 +196,7 @@ StatusCode AnalysisEfficiency::run(std::shared_ptr<Clipboard> clipboard) {
if(!m_detector->isWithinROI(track)) {
LOG(DEBUG) << " - track outside ROI";
is_within_roi = false;
// here we don't continue because only some particular histograms shall be effected
}
// Check that it doesn't go through/near a masked pixel
......@@ -183,21 +261,76 @@ StatusCode AnalysisEfficiency::run(std::shared_ptr<Clipboard> clipboard) {
// For pixels, only look at the ROI:
if(is_within_roi) {
hPixelEfficiencyMap_trackPos->Fill(xmod, ymod, has_associated_cluster);
eTotalEfficiency->Fill(has_associated_cluster, 0); // use 0th bin for total efficiency
}
if(has_associated_cluster == false) {
auto intercept_col = static_cast<size_t>(m_detector->getColumn(localIntercept));
auto intercept_row = static_cast<size_t>(m_detector->getRow(localIntercept));
if(has_associated_cluster) {
hTimeDiffPrevTrack_assocCluster->Fill(
static_cast<double>(Units::convert(track->timestamp() - last_track_timestamp, "us")));
hRowDiffPrevTrack_assocCluster->Fill(m_detector->getRow(localIntercept) - last_track_row);
hColDiffPrevTrack_assocCluster->Fill(m_detector->getColumn(localIntercept) - last_track_col);
hPosDiffPrevTrack_assocCluster->Fill(m_detector->getColumn(localIntercept) - last_track_col,
m_detector->getRow(localIntercept) - last_track_row);
if((prev_hit_ts.at(intercept_col)).at(intercept_row) != 0) {
hTrackTimeToPrevHit_matched->Fill(static_cast<double>(
Units::convert(track->timestamp() - prev_hit_ts.at(intercept_col).at(intercept_row), "us")));
}
} else {
hGlobalEfficiencyMap_clustPos->Fill(globalIntercept.X(), globalIntercept.Y(), has_associated_cluster);
hChipEfficiencyMap_clustPos->Fill(
m_detector->getColumn(localIntercept), m_detector->getRow(localIntercept), has_associated_cluster);
hTimeDiffPrevTrack_noAssocCluster->Fill(
static_cast<double>(Units::convert(track->timestamp() - last_track_timestamp, "us")));
hRowDiffPrevTrack_noAssocCluster->Fill(m_detector->getRow(localIntercept) - last_track_row);
hColDiffPrevTrack_noAssocCluster->Fill(m_detector->getColumn(localIntercept) - last_track_col);
hPosDiffPrevTrack_noAssocCluster->Fill(m_detector->getColumn(localIntercept) - last_track_col,
m_detector->getRow(localIntercept) - last_track_row);
if((prev_hit_ts.at(intercept_col)).at(intercept_row) != 0) {
LOG(DEBUG) << "Found a time difference of "
<< Units::display(track->timestamp() - prev_hit_ts.at(intercept_col).at(intercept_row), "us");
hTrackTimeToPrevHit_notmatched->Fill(static_cast<double>(
Units::convert(track->timestamp() - prev_hit_ts.at(intercept_col).at(intercept_row), "us")));
}
}
last_track_timestamp = track->timestamp();
last_track_col = m_detector->getColumn(localIntercept);
last_track_row = m_detector->getRow(localIntercept);
} // end loop over tracks
// Before going to the next event, loop over all pixels (all hits incl. noise)
// and fill matrix with timestamps of previous pixels.
Pixels* pixels = reinterpret_cast<Pixels*>(clipboard->get(m_detector->name(), "pixels"));
if(pixels == nullptr) {
LOG(DEBUG) << "Detector " << m_detector->name() << " does not have any pixels on the clipboard";
return StatusCode::Success;
}
for(auto& pixel : (*pixels)) {
prev_hit_ts.at(static_cast<size_t>(pixel->column())).at(static_cast<size_t>(pixel->row())) = pixel->timestamp();
}
return StatusCode::Success;
}
void AnalysisEfficiency::finalise() {
LOG(INFO) << "No. matched tracks=" << matched_tracks;
LOG(INFO) << "Total no. tracks=" << total_tracks;
LOG(STATUS) << "Total efficiency of detector " << m_detector->name() << ": "
<< (100 * matched_tracks / (total_tracks > 0 ? total_tracks : 1)) << "%, measured with " << total_tracks
<< " tracks";
double totalEff = 100 * static_cast<double>(matched_tracks) / (total_tracks > 0 ? total_tracks : 1);
LOG(STATUS) << "Total efficiency of detector " << m_detector->name() << ": " << totalEff << "%, measured with "
<< matched_tracks << "/" << total_tracks << " matched/total tracks";
totalEfficiency->SetName((to_string(totalEff) + " %").c_str());
totalEfficiency->Write();
for(int icol = 1; icol < m_detector->nPixels().X() + 1; icol++) {
for(int irow = 1; irow < m_detector->nPixels().Y() + 1; irow++) {
// calculate total efficiency: (just to double check the other calculation)
double eff = hChipEfficiencyMap_trackPos->GetBinContent(icol, irow);
if(eff > 0) {
LOG(TRACE) << "col/row = " << icol << "/" << irow << ", binContent = " << eff;
hPixelEfficiency->Fill(hChipEfficiencyMap_trackPos->GetBinContent(icol, irow));
}
}
}
}
......@@ -15,6 +15,9 @@
#include "core/module/Module.hpp"
#include "TEfficiency.h"
#include "TH2D.h"
#include "TNamed.h"
#include "TProfile2D.h"
namespace corryvreckan {
......@@ -39,14 +42,38 @@ namespace corryvreckan {
private:
std::shared_ptr<Detector> m_detector;
TH1D* hPixelEfficiency;
TProfile2D* hPixelEfficiencyMap_trackPos;
TProfile2D* hChipEfficiencyMap_trackPos;
TProfile2D* hGlobalEfficiencyMap_trackPos;
TProfile2D* hChipEfficiencyMap_clustPos;
TProfile2D* hGlobalEfficiencyMap_clustPos;
TEfficiency* eTotalEfficiency;
TNamed* totalEfficiency;
TH1D* hTimeDiffPrevTrack_assocCluster;
TH1D* hTimeDiffPrevTrack_noAssocCluster;
TH1D* hRowDiffPrevTrack_assocCluster;
TH1D* hColDiffPrevTrack_assocCluster;
TH1D* hRowDiffPrevTrack_noAssocCluster;
TH1D* hColDiffPrevTrack_noAssocCluster;
TH1D* hTrackTimeToPrevHit_matched;
TH1D* hTrackTimeToPrevHit_notmatched;
TH2D* hPosDiffPrevTrack_assocCluster;
TH2D* hPosDiffPrevTrack_noAssocCluster;
double m_chi2ndofCut, m_timeCutFrameEdge, m_pixelTolerance, m_inpixelBinSize;
int total_tracks, matched_tracks;
int total_tracks = 0;
int matched_tracks = 0;
double last_track_timestamp = 0;
double last_track_col = 0.;
double last_track_row = 0.;
Matrix<double> prev_hit_ts; // matrix containing previous hit timestamp for every pixel
};
} // namespace corryvreckan
# AnalysisEfficiency
**Maintainer**: Simon Spannagel (simon.spannagel@cern.ch)
**Maintainer**: Simon Spannagel (simon.spannagel@cern.ch), Jens Kroeger (jens.kroeger@cern.ch)
**Module Type**: *DUT*
**Detector Type**: *all*
**Status**: Functional
### Description
This module measures the efficiency of the device under test by comparing its cluster positions with the interpolated track position at the DUT.
It also comprises a range of histograms to investigate where inefficiencies might come from.
### Parameters
* `pixel_tolerance`: Parameter to discard tracks, which are extrapolated to
......@@ -15,14 +16,30 @@ the edge of the DUT. Defaults to `1.`, which excludes column/row zero and max.
* `inpixel_bin_size`: Parameter to set the bin size of the in-pixel 2D efficiency histogram. This should be given in units of distance and the same value is used in both axes. Defaults to `1.0um`.
### Plots produced
* 2D Map of in-pixel efficiency
* 2D Map of the chip efficiency in local coordinates, filled at the position of the track intercept point
* 2D Map of the chip efficiency on global coordinates, filled at the position of the track intercept point
* 2D Map of the chip efficiency in local coordinates, filled at the position of the associated cluster centre
* 2D Map of the chip efficiency on global coordinates, filled at the position of the associated cluster centre
* 2D histograms:
* 2D Map of in-pixel efficiency
* 2D Map of the chip efficiency in local coordinates, filled at the position of the track intercept point
* 2D Map of the chip efficiency on global coordinates, filled at the position of the track intercept point
* 2D Map of the chip efficiency in local coordinates, filled at the position of the associated cluster centre
* 2D Map of the chip efficiency on global coordinates, filled at the position of the associated cluster centre
* 2D Map of the position difference of a track (with associated cluster) to the previous track
* 2D Map of the position difference of a track (without associated cluster) to the previous track
* 1D histograms:
* Histogram of all single-pixel efficiencies
* Histogram of time difference of the matched track time (with associated cluster) to the previous track
* Histogram of time difference of the non-matched track time (without associated cluster) to the previous track
* Histogram of row difference of the matched track time (with associated cluster) to the previous track
* Histogram of row difference of the non-matched track time (without associated cluster) to the previous track
* Histogram of column difference of the matched track time (with associated cluster) to the previous track
* Histogram of column difference of the non-matched track time (without associated cluster) to the previous track
* Histogram of the time difference of a matched cluster (with associated cluster) to a previous hit (not matter if noise or track)
* Histogram of the time difference of a non-matched cluster (without associated cluster) to a previous hit (not matter if noise or track)
* Other:
* Value of total efficiency as `TEfficiency` including (asymmetric) error bars
* Value of total efficency as `TName` so it can be read off easily by eye from the root file
### Usage
```toml
[AnalysisEfficiency]
chi2ndof_cut = 5
```
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