Commit dcaaed46 authored by Mateus Vicente's avatar Mateus Vicente
Browse files

new pixel efficiency plot and config variables

parent a07b9a57
......@@ -23,11 +23,14 @@ AnalysisEfficiency::AnalysisEfficiency(Configuration& config, std::shared_ptr<De
config_.setDefault<double>("time_cut_frameedge", Units::get<double>(20, "ns"));
config_.setDefault<double>("chi2ndof_cut", 3.);
config_.setDefault<double>("inpixel_bin_size", Units::get<double>(1.0, "um"));
config_.setDefault<double>("inpixelEdge_cut", 5.);
config_.setDefault<double>("maskedPixelDistance_cut", 1.);
m_timeCutFrameEdge = config_.get<double>("time_cut_frameedge");
m_chi2ndofCut = config_.get<double>("chi2ndof_cut");
m_inpixelBinSize = config_.get<double>("inpixel_bin_size");
require_associated_cluster_on_ = config_.getArray<std::string>("require_associated_cluster_on", {});
m_inpixelEdgeCut = config_.get<double>("inpixelEdge_cut");
m_maskedPixelDistanceCut = config_.get<double>("maskedPixelDistance_cut");
}
void AnalysisEfficiency::initialize() {
......@@ -35,6 +38,9 @@ void AnalysisEfficiency::initialize() {
hPixelEfficiency = new TH1D(
"hPixelEfficiency", "hPixelEfficiency; single pixel efficiency; # entries", 201, 0, 1.005); // get 0.5%-wide bins
hPixelEfficiencyMatrix = new TH1D(
"hPixelEfficiencyMatrix", "hPixelEfficiencyMatrix; single pixel efficiency; # entries", 201, 0, 1.005); // get 0.5%-wide bins
auto pitch_x = static_cast<double>(Units::convert(m_detector->getPitch().X(), "um"));
auto pitch_y = static_cast<double>(Units::convert(m_detector->getPitch().Y(), "um"));
......@@ -84,7 +90,19 @@ void AnalysisEfficiency::initialize() {
-0.5,
m_detector->nPixels().Y() - 0.5);
title = m_detector->getName() + " Global efficiency map;x [mm];y [mm];#epsilon";
title = m_detector->getName() + " Pixel efficiency matrix;x [px];y [px];#epsilon";
hPixelEfficiencyMatrix_TProfile = new TProfile2D("hPixelEfficiencyMatrix",
title.c_str(),
m_detector->nPixels().X(),
-0.5,
m_detector->nPixels().X() - 0.5,
m_detector->nPixels().Y(),
-0.5,
m_detector->nPixels().Y() - 0.5,
0,
1);
title = m_detector->getName() + " Global efficiency map;x [mm];y [mm];#epsilon";
hGlobalEfficiencyMap_trackPos_TProfile = new TProfile2D("globalEfficiencyMap_trackPos_TProfile",
title.c_str(),
300,
......@@ -281,7 +299,7 @@ StatusCode AnalysisEfficiency::run(const std::shared_ptr<Clipboard>& clipboard)
// Check that it doesn't go through/near a masked pixel
LOG(TRACE) << " Checking if track is close to masked pixel";
if(m_detector->hitMasked(track.get(), 1.)) {
if(m_detector->hitMasked(track.get(), m_maskedPixelDistanceCut)) {
n_masked++;
LOG(DEBUG) << " - track close to masked pixel";
continue;
......@@ -307,21 +325,6 @@ StatusCode AnalysisEfficiency::run(const std::shared_ptr<Clipboard>& clipboard)
continue;
}
// check if track has an associated cluster on required detector(s):
auto foundRequiredAssocCluster = [this](Track* t) {
for(auto& requireAssocCluster : require_associated_cluster_on_) {
if(!requireAssocCluster.empty() && t->getAssociatedClusters(requireAssocCluster).size() == 0) {
LOG(DEBUG) << "No associated cluster from required detector " << requireAssocCluster << " on the track.";
return false;
}
}
return true;
};
if(!foundRequiredAssocCluster(track.get())) {
n_requirecluster++;
continue;
}
// Count this as reference track:
total_tracks++;
......@@ -336,6 +339,13 @@ StatusCode AnalysisEfficiency::run(const std::shared_ptr<Clipboard>& clipboard)
auto cluster = track->getClosestCluster(m_detector->getName());
has_associated_cluster = true;
matched_tracks++;
auto pixels = cluster->pixels();
for(auto& pixel : pixels) {
if((pixel->column() == static_cast<int>(m_detector->getColumn(localIntercept)) && pixel->row() == static_cast<int>(m_detector->getRow(localIntercept))) &&
(55 - abs(xmod*2) < m_inpixelEdgeCut || 55 - abs(ymod*2) < m_inpixelEdgeCut) )
hPixelEfficiencyMatrix_TProfile->Fill(pixel->column(), pixel->row(), 1);
}
auto clusterLocal = m_detector->globalToLocal(cluster->global());
auto distance =
......@@ -353,6 +363,9 @@ StatusCode AnalysisEfficiency::run(const std::shared_ptr<Clipboard>& clipboard)
has_associated_cluster, m_detector->getColumn(clusterLocal), m_detector->getRow(clusterLocal));
}
if(!has_associated_cluster && (55 - abs(xmod*2) < m_inpixelEdgeCut || 55 - abs(ymod*2) < m_inpixelEdgeCut))
hPixelEfficiencyMatrix_TProfile->Fill(m_detector->getColumn(localIntercept), m_detector->getRow(localIntercept), 0);
hGlobalEfficiencyMap_trackPos_TProfile->Fill(globalIntercept.X(), globalIntercept.Y(), has_associated_cluster);
hGlobalEfficiencyMap_trackPos->Fill(has_associated_cluster, globalIntercept.X(), globalIntercept.Y());
......@@ -436,7 +449,6 @@ void AnalysisEfficiency::finalize(const std::shared_ptr<ReadonlyClipboard>&) {
<< "* track outside DUT -" << n_dut << std::endl
<< "* track close to masked px -" << n_masked << std::endl
<< "* track close to frame edge -" << n_frameedge << std::endl
<< "* track without an associated cluster on required detector - " << n_requirecluster << std::endl
<< "Accepted tracks: " << total_tracks;
double totalEff = 100 * static_cast<double>(matched_tracks) / (total_tracks > 0 ? total_tracks : 1);
......@@ -447,11 +459,16 @@ void AnalysisEfficiency::finalize(const std::shared_ptr<ReadonlyClipboard>&) {
for(int irow = 1; irow < m_detector->nPixels().Y() + 1; irow++) {
// calculate total efficiency: (just to double check the other calculation)
const int bin = hChipEfficiencyMap_trackPos->GetGlobalBin(icol, irow);
const double eff = hChipEfficiencyMap_trackPos->GetEfficiency(bin);
double eff = hChipEfficiencyMap_trackPos->GetEfficiency(bin);
if(eff > 0) {
LOG(TRACE) << "col/row = " << icol << "/" << irow << ", binContent = " << eff;
hPixelEfficiency->Fill(eff);
}
eff = hPixelEfficiencyMatrix_TProfile->GetBinContent(bin);
if(eff > 0) {
LOG(TRACE) << "col/row = " << icol << "/" << irow << ", binContent = " << eff;
hPixelEfficiencyMatrix->Fill(eff);
}
}
}
}
......@@ -44,10 +44,12 @@ namespace corryvreckan {
std::shared_ptr<Detector> m_detector;
TH1D* hPixelEfficiency;
TH1D* hPixelEfficiencyMatrix;
// Profile version
TProfile2D* hPixelEfficiencyMap_trackPos_TProfile;
TProfile2D* hChipEfficiencyMap_trackPos_TProfile;
TProfile2D* hPixelEfficiencyMatrix_TProfile;
TProfile2D* hGlobalEfficiencyMap_trackPos_TProfile;
TProfile2D* hChipEfficiencyMap_clustPos_TProfile;
TProfile2D* hGlobalEfficiencyMap_clustPos_TProfile;
......@@ -75,15 +77,15 @@ namespace corryvreckan {
TH2D* hPosDiffPrevTrack_assocCluster;
TH2D* hPosDiffPrevTrack_noAssocCluster;
TH2D* hDistanceCluster_track;
double m_chi2ndofCut, m_timeCutFrameEdge, m_inpixelBinSize;
double m_chi2ndofCut, m_timeCutFrameEdge, m_inpixelBinSize, m_inpixelEdgeCut;
int m_maskedPixelDistanceCut;
int total_tracks = 0;
int matched_tracks = 0;
double last_track_timestamp = 0;
double last_track_col = 0.;
double last_track_row = 0.;
double n_track = 0, n_chi2 = 0, n_dut = 0, n_roi = 0, n_masked = 0, n_frameedge = 0, n_requirecluster = 0;
std::vector<std::string> require_associated_cluster_on_;
double n_track = 0, n_chi2 = 0, n_dut = 0, n_roi = 0, n_masked = 0, n_frameedge = 0;
Matrix<double> prev_hit_ts; // matrix containing previous hit timestamp for every pixel
};
......
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